PIPS
conversion.h File Reference
#include "matrice.h"
+ Include dependency graph for conversion.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void derive_new_basis (Pbase, Pbase *, entity(*)(entity))
 Warning! Do not modify this file that is automatically generated! More...
 
void change_of_base_index (Pbase, Pbase *)
 void change_of_base_index(Pbase base_oldindex, Pbase *base_newindex) change of variable index from base_oldindex to base_newindex More...
 
entity make_index_prime_entity (entity)
 
entity make_index_entity (entity)
 
Psysteme sc_change_baseindex (Psysteme, Pbase, Pbase)
 Psysteme sc_change_baseindex(Psysteme sc, Pbase base_old, Pbase base_new) le changement de base d'indice pour sc. More...
 
void scanning_base_to_vect (matrice, int, Pbase, Pvecteur[])
 code_change_of_basis.c More...
 
Pvecteur vect_change_base (Pvecteur, Pbase, Pvecteur[])
 
conslistexpres_to_listexpres_newbase (cons *, Pvecteur[], Pbase)
 
expression expression_to_expression_newbase (expression, Pvecteur[], Pbase)
 
void statement_newbase (statement, Pvecteur[], Pbase)
 
Psysteme loop_iteration_domaine_to_sc (list, Pbase *)
 loop_iteration_domaine_to_sc.c More...
 
void loop_index_domaine_to_contrainte (range, entity, Psysteme)
 
void look_for_nested_loop_statements (statement, statement(*)(list, bool(*)(statement)), bool(*)(statement))
 look_for_nested_loops.c More...
 
statement look_for_inner_loops (loop, list, statement(*)(list, bool(*)(statement)), bool(*)(statement))
 FI: I do not understand how debug levels are managed... More...
 
void look_for_nested_loops_unstructured (unstructured, statement(*)(list, bool(*)(statement)), bool(*)(statement))
 oid look_for_nested_loops_unstructured(unstructured u) search the nested loops contained in the unstructured u More...
 
expression Psysteme_to_expression (Psysteme)
 system_to_code.c More...
 
list Pcontrainte_to_expression_list (Pcontrainte, entity)
 
void set_information_for_code_optimizations (Psysteme)
 I could keep the system for further optimizations... More...
 
void reset_information_for_code_optimizations (void)
 
expression constraints_to_loop_bound (Pcontrainte, Variable, bool, entity)
 expression constraints_to_loop_bound(c, var, is_lower) More...
 
bool bounds_equal_p (Variable, Pcontrainte, Pcontrainte)
 this function checks whether the lower and upper constraints are going to generate the same bound on variable var. More...
 
statement systeme_to_loop_nest (Psysteme, list, statement, entity)
 sc is used to generate the loop nest bounds for variables vars. More...
 
statement generate_optional_if (Psysteme, statement)
 statement generate_optional_if(sc, stat) More...
 

Function Documentation

◆ bounds_equal_p()

bool bounds_equal_p ( Variable  var,
Pcontrainte  lower,
Pcontrainte  upper 
)

this function checks whether the lower and upper constraints are going to generate the same bound on variable var.

oeff for var in the constraint

??? the arithmetic ppcm version is on int instead of values

Parameters
varar
lowerower
upperpper

Definition at line 534 of file system_to_code.c.

538 {
539  Pvecteur v_lower, v_upper, sum;
540  Value val_lower, val_upper, the_ppcm;
541  bool result;
542 
543  if (nb_elems_list(lower)!=1 || nb_elems_list(upper)!=1) return(false);
544 
545  val_upper = vect_coeff(var, upper->vecteur); /*coeff for var in the constraint*/
546  val_lower = vect_coeff(var, lower->vecteur);
547 
548  /* ??? the arithmetic ppcm version is on int instead of values
549  */
550  the_ppcm = ppcm(value_uminus(val_lower), val_upper);
551 
552  v_lower = vect_dup(lower->vecteur);
553  v_lower = vect_multiply(v_lower,
554  value_div(value_uminus(the_ppcm),val_lower));
555 
556  v_upper = vect_dup(upper->vecteur);
557  v_upper = vect_multiply(v_upper,
558  value_div(the_ppcm,val_upper));
559 
560  sum = vect_add(v_lower, v_upper);
563 
564  result = VECTEUR_NUL_P(sum) ||
565  (sum->succ==NULL && var_of(sum)==TCST && val_of(sum)==0);
566 
567  vect_rm(v_lower), vect_rm(v_upper), vect_rm(sum);
568 
569  return result;
570 }
#define value_minus(v1, v2)
#define value_uminus(val)
unary operators on values
int Value
#define VALUE_ONE
#define value_div(v1, v2)
Value ppcm(Value, Value)
ppcm.c
Definition: ppcm.c:42
int nb_elems_list(Pcontrainte)
int nb_elems_list(Pcontrainte list): nombre de contraintes se trouvant dans une liste de contraintes
Definition: listes.c:129
Pvecteur vect_multiply(Pvecteur v, Value x)
Pvecteur vect_multiply(Pvecteur v, Value x): multiplication du vecteur v par le scalaire x,...
Definition: scalaires.c:123
t_real sum(int n1, int n2, int n3, t_real u[n1][n2][n3])
Definition: stencil.c:57
Pvecteur vecteur
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
#define val_of(varval)
#define VECTEUR_NUL_P(v)
#define var_of(varval)
Pvecteur vect_dup(Pvecteur v_in)
Pvecteur vect_dup(Pvecteur v_in): duplication du vecteur v_in; allocation de et copie dans v_out;.
Definition: alloc.c:51
void vect_rm(Pvecteur v)
void vect_rm(Pvecteur v): desallocation des couples de v;
Definition: alloc.c:78
Pvecteur vect_add(Pvecteur v1, Pvecteur v2)
package vecteur - operations binaires
Definition: binaires.c:53
void vect_add_elem(Pvecteur *pvect, Variable var, Value val)
void vect_add_elem(Pvecteur * pvect, Variable var, Value val): addition d'un vecteur colineaire au ve...
Definition: unaires.c:72
Value vect_coeff(Variable var, Pvecteur vect)
Variable vect_coeff(Variable var, Pvecteur vect): coefficient de coordonnee var du vecteur vect —> So...
Definition: unaires.c:228
void vect_normalize(Pvecteur v)
void vect_normalize(Pvecteur v): division de tous les coefficients de v par leur pgcd; "normalisation...
Definition: unaires.c:59

References nb_elems_list(), ppcm(), sum(), TCST, val_of, value_div, value_minus, VALUE_ONE, value_uminus, var_of, vect_add(), vect_add_elem(), vect_coeff(), vect_dup(), vect_multiply(), vect_normalize(), vect_rm(), Scontrainte::vecteur, and VECTEUR_NUL_P.

Referenced by region_to_minimal_dimensions(), and systeme_to_loop_nest().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ change_of_base_index()

void change_of_base_index ( Pbase  base_oldindex,
Pbase base_newindex 
)

void change_of_base_index(Pbase base_oldindex, Pbase *base_newindex) change of variable index from base_oldindex to base_newindex

Parameters
base_oldindexase_oldindex
base_newindexase_newindex

Definition at line 65 of file change_of_Pbase.c.

68 {
69  derive_new_basis(base_oldindex, base_newindex, make_index_prime_entity);
70 }
void derive_new_basis(Pbase base_oldindex, Pbase *base_newindex, entity(*new_entity)(entity))
package conversion
entity make_index_prime_entity(entity old_index)

References derive_new_basis(), and make_index_prime_entity().

Referenced by hyperplane(), and unimodular().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ constraints_to_loop_bound()

expression constraints_to_loop_bound ( Pcontrainte  c,
Variable  var,
bool  is_lower,
entity  divide 
)

expression constraints_to_loop_bound(c, var, is_lower)

the is_lower (lower/upper) loop bound for variable var relative to Pcontrainte c is generated. All the constraints in c are used, and they must be ok.

see also make_bound_expression in ri-util/bound_generation.c maybe move this function in ri-util/bound_generation.c? integer division to be called

the constraints are sorted first, to ensure a deterministic result ??? the sorting criterion is rather strange:-)

each constraint is considered in turn to generate a bound

ax+b <= 0 and a<0 => x >= (b+(-a-1))/(-a)

extract coefficients that are dividable by val... x = (ay+bz)/a -> x = y + bz/a

assert. no a.i=0 should have reached this point...

I perform some other optimizations here, by looking at the extent of the numerator, that may result in a constant after division by the denominator. For instance, x = y/a and 0 <= y < a would lead to x = 0, which is quite simpler... I need a hook from the callers of this function to retrieve the constant lower and upper bounds of each variable in order to perform this. ??? this optimizations should/could be perform earlier on the original system... but the implementation in a general context does not seems obvious to me...

use / instead of the provided idiv if operand >=0

final operation: MAX or MIN if more than one bound

and memory leak... (cons lost)

Parameters
varthe constraints of the bound
is_lowerthe index variable
dividelower or upper bound

Definition at line 374 of file system_to_code.c.

379 {
380  int len = 0, sign = is_lower? -1: +1;
382  list le = NIL;
383  Psysteme s;
384 
385  pips_debug(5, "computing %ser bound for variable %s\n",
386  (is_lower?"low":"upp"), entity_local_name((entity) var));
387 
388  ifdebug(6)
389  {
390  fprintf(stderr, "[constraints_to_loop_bound] constraints are:\n");
392  }
393 
394  message_assert("some constraints", !CONTRAINTE_UNDEFINED_P(c));
395 
396  /* the constraints are sorted first, to ensure a deterministic result
397  * ??? the sorting criterion is rather strange:-)
398  */
399  s = sc_make(NULL, contraintes_dup(c));
400  vect_sort(sc_base(s), compare_Pvecteur);
401  sc_sort_constraints(s, sc_base(s));
402 
403  /* each constraint is considered in turn to generate a bound
404  */
405  for(c=sc_inegalites(s); c; c=c->succ)
406  {
407  Value val = vect_coeff(var, c->vecteur), computed;
408  Pvecteur vdiv = vect_del_var(c->vecteur, var), vadd = VECTEUR_NUL, v;
409  expression ediv, eadd, e;
410 
411  message_assert("coherent value and sign", sign*value_sign(val)>0);
412 
413  if (value_pos_p(val))
414  vect_chg_sgn(vdiv);
415  else
416  /* ax+b <= 0 and a<0 => x >= (b+(-a-1))/(-a)
417  */
418  value_oppose(val),
419  vect_add_elem(&vdiv, TCST, value_minus(val,VALUE_ONE));
420 
421  if (value_one_p(val))
422  {
423  le = CONS(EXPRESSION, make_vecteur_expression(vdiv), le);
424  continue;
425  }
426 
427  /* extract coefficients that are dividable by val...
428  * x = (ay+bz)/a -> x = y + bz/a
429  */
430  for (v=vdiv; v; v=v->succ)
431  {
432  Variable va = var_of(v);
433  Value vl = val_of(v);
434 
435  if (value_zero_p(value_mod(vl,val)))
436  vect_add_elem(&vadd, va, value_div(vl,val));
437  }
438 
439  for (v=vadd; v; v=v->succ)
440  vect_erase_var(&vdiv, var_of(v));
441 
442  /* assert. no a.i=0 should have reached this point...
443  */
444  message_assert("some expression", vdiv || vadd);
445 
446  /* I perform some other optimizations here, by looking at
447  * the extent of the numerator, that may result in a constant after
448  * division by the denominator. For instance, x = y/a and 0 <= y < a
449  * would lead to x = 0, which is quite simpler... I need a hook
450  * from the callers of this function to retrieve the constant lower
451  * and upper bounds of each variable in order to perform this.
452  * ??? this optimizations should/could be perform earlier on
453  * the original system... but the implementation in a general context
454  * does not seems obvious to me...
455  */
456  if (evaluate_divide_if_possible(vdiv, val, &computed))
457  {
458  vect_rm(vdiv), vdiv=VECTEUR_NUL;
459  vect_add_elem(&vadd, TCST, computed);
460  }
461 
462  if (vdiv)
463  {
464  ediv = make_vecteur_expression(vdiv);
465 
466  /* use / instead of the provided idiv if operand >=0
467  */
470  divide, ediv, Value_to_expression(val));
471 
472  if (vadd)
473  {
474  eadd = make_vecteur_expression(vadd);
476  eadd, ediv);
477  }
478  else
479  e = ediv;
480  }
481  else
482  e = make_vecteur_expression(vadd);
483 
484  vect_rm(vdiv), vect_rm(vadd);
485  le = CONS(EXPRESSION, e, le);
486  }
487 
488  /* final operation: MAX or MIN if more than one bound
489  */
490  // Added an option to automatically take the constant value over the other expressions
491  // Should not affect the function unless the property is set to True (False by default)
492  len = gen_length(le); message_assert("some expressions", len!=0);
493 
494  if (len==1)
495  {
496  result = EXPRESSION(CAR(le)); /* and memory leak... (cons lost) */
497  gen_free_list(le);
498  }
499  else if (get_bool_property("PSYSTEME_TO_LOOPNEST_FOR_RSTREAM")) {
500  int nb_constant = 0;
501  FOREACH(expression, exp, le) {
502  if (expression_constant_p(exp)) {
503  result = exp;
504  nb_constant++;
505  }
506  }
507  gen_free_list(le);
508  pips_assert("More than one constant expression in loop bounds", nb_constant == 1);
509  }
510  else
511  {
514  int c = gen_length(le);
516  le = CONS(EXPRESSION, ce, le);
517  result = make_call_expression(operator, le);
518  }
519  else { // Fortran case
521  result = make_call_expression(operator, le);
522  }
523  }
524 
525  sc_rm(s);
526 
527  return result;
528 }
#define value_pos_p(val)
#define value_sign(v)
trian operators on values
#define value_oppose(ref)
#define value_one_p(val)
#define value_zero_p(val)
#define divide(a, b)
#define value_mod(v1, v2)
#define value_posz_p(val)
int compare_Pvecteur(Pvecteur *pv1, Pvecteur *pv2)
comparison function for Pvecteur in pips, to be used by qsort.
Definition: constraint.c:50
#define CONTRAINTE_UNDEFINED_P(c)
Pcontrainte contraintes_dup(Pcontrainte c_in)
Pcontrainte contraintes_dup(Pcontrainte c_in) a list of constraints is copied.
Definition: alloc.c:146
void inegalites_fprint(FILE *, Pcontrainte, char *(*)(Variable))
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
size_t gen_length(const list l)
Definition: list.c:150
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
Definition: newgen_list.h:179
bool expression_constant_p(expression)
HPFC module by Fabien COELHO.
Definition: expression.c:2453
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define message_assert(msg, ex)
Definition: newgen_assert.h:47
#define MAX_OPERATOR_NAME
#define PLUS_OPERATOR_NAME
#define PIPS_C_MAX_OPERATOR_NAME
#define DIVIDE_OPERATOR_NAME
#define PIPS_C_MIN_OPERATOR_NAME
PIPS run-time support for C code generation.
#define MIN_OPERATOR_NAME
const char * entity_local_name(entity e)
entity_local_name modified so that it does not core when used in vect_fprint, since someone thought t...
Definition: entity.c:453
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
Definition: entity.c:1292
expression make_vecteur_expression(Pvecteur pv)
make expression for vector (Pvecteur)
Definition: expression.c:1650
expression make_call_expression(entity e, list l)
Build an expression that call an function entity with an argument list.
Definition: expression.c:321
expression MakeBinaryCall(entity f, expression eg, expression ed)
Creates a call expression to a function with 2 arguments.
Definition: expression.c:354
expression int_to_expression(_int i)
transform an int into an expression and generate the corresponding entity if necessary; it is not cle...
Definition: expression.c:1188
expression Value_to_expression(Value v)
added interface for linear stuff.
Definition: expression.c:1251
bool c_language_module_p(entity m)
Definition: module.c:447
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define expression_undefined
Definition: ri.h:1223
Psysteme sc_make(Pcontrainte leg, Pcontrainte lineg)
Psysteme sc_make(Pcontrainte leg, Pcontrainte lineg): allocation et initialisation d'un systeme d'equ...
Definition: sc.c:78
void sc_rm(Psysteme ps)
void sc_rm(Psysteme ps): liberation de l'espace memoire occupe par le systeme de contraintes ps;
Definition: sc_alloc.c:277
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
Psysteme sc_sort_constraints(Psysteme ps, Pbase base_index)
void vect_chg_sgn(Pvecteur v)
void vect_chg_sgn(Pvecteur v): multiplie v par -1
Definition: scalaires.c:151
#define ifdebug(n)
Definition: sg.c:47
struct Scontrainte * succ
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
static Value vecteur_lower_bound(Pvecteur v)
returns v lower bound if found, or INT_MIN.
static bool evaluate_divide_if_possible(Pvecteur v, Value denominator, Value *result)
#define exp
Avoid some warnings from "gcc -Wshadow".
Definition: vasnprintf.c:207
#define VECTEUR_NUL
DEFINITION DU VECTEUR NUL.
char *(* get_variable_name_t)(Variable)
Definition: vecteur-local.h:62
void * Variable
arithmetique is a requirement for vecteur, but I do not want to inforce it in all pips files....
Definition: vecteur-local.h:60
void vect_erase_var(Pvecteur *ppv, Variable v)
void vect_erase_var(Pvecteur * ppv, Variable v): projection du vecteur *ppv selon la direction v (i....
Definition: unaires.c:106
Pvecteur vect_del_var(Pvecteur v_in, Variable var)
Pvecteur vect_del_var(Pvecteur v_in, Variable var): allocation d'un nouveau vecteur egal a la project...
Definition: unaires.c:206
Pvecteur vect_sort(Pvecteur v, int *compare)
Pvecteur vect_sort(v, compare) Pvecteur v; int (*compare)();.
Definition: unaires.c:335

References c_language_module_p(), CAR, compare_Pvecteur(), CONS, CONTRAINTE_UNDEFINED_P, contraintes_dup(), divide, DIVIDE_OPERATOR_NAME, entity_intrinsic(), entity_local_name(), evaluate_divide_if_possible(), exp, EXPRESSION, expression_constant_p(), expression_undefined, FOREACH, fprintf(), gen_free_list(), gen_length(), get_bool_property(), get_current_module_entity(), ifdebug, inegalites_fprint(), int_to_expression(), make_call_expression(), make_vecteur_expression(), MakeBinaryCall(), MAX_OPERATOR_NAME, message_assert, MIN_OPERATOR_NAME, NIL, pips_assert, PIPS_C_MAX_OPERATOR_NAME, PIPS_C_MIN_OPERATOR_NAME, pips_debug, PLUS_OPERATOR_NAME, sc_make(), sc_rm(), sc_sort_constraints(), Scontrainte::succ, Svecteur::succ, TCST, val_of, value_div, value_minus, value_mod, VALUE_ONE, value_one_p, value_oppose, value_pos_p, value_posz_p, value_sign, Value_to_expression(), value_zero_p, var_of, vect_add_elem(), vect_chg_sgn(), vect_coeff(), vect_del_var(), vect_erase_var(), vect_rm(), vect_sort(), Scontrainte::vecteur, vecteur_lower_bound(), and VECTEUR_NUL.

Referenced by do_array_expansion(), do_check_isolate_statement_preconditions_on_call(), do_isolate_statement_preconditions_satisified_p(), do_solve_hardware_constraints_on_nb_proc(), make_rectangular_area(), region_to_minimal_dimensions(), statement_insertion_fix_access(), systeme_to_loop_nest(), and variable_to_dimensions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ derive_new_basis()

void derive_new_basis ( Pbase  base_oldindex,
Pbase base_newindex,
entity(*)(entity new_entity 
)

Warning! Do not modify this file that is automatically generated!

Modify src/Libs/conversion/conversion-local.h instead, to add your own modifications. header file built by cproto conversion-local.h cproto-generated files change_of_Pbase.c

Warning! Do not modify this file that is automatically generated!

Parameters
base_oldindexase_oldindex
base_newindexase_newindex

Definition at line 48 of file change_of_Pbase.c.

49 {
50  Pbase pb;
51  entity new_name;
52 
53  for (pb=base_oldindex; pb!=NULL; pb=pb->succ)
54  {
55  new_name = new_entity((entity) pb->var);
56  base_add_dimension(base_newindex, (Variable) new_name);
57  }
58  *base_newindex = base_reversal(*base_newindex);
59 }
Pbase base_reversal(Pbase b_in)
Pbase base_reversal(Pbase b_in): produces a basis b_out, having the same basis vectors as b_in,...
Definition: base.c:221
Variable var
Definition: vecteur-local.h:90
struct Svecteur * succ
Definition: vecteur-local.h:92
#define base_add_dimension(b, v)

References base_add_dimension, base_reversal(), Svecteur::succ, and Svecteur::var.

Referenced by change_of_base_index(), parallel_tiling(), and tiling_transformation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expression_to_expression_newbase()

expression expression_to_expression_newbase ( expression  ,
Pvecteur  [],
Pbase   
)

◆ generate_optional_if()

statement generate_optional_if ( Psysteme  sc,
statement  stat 
)

statement generate_optional_if(sc, stat)

if sc is Z^n then no if is required, if sc is empty, then statement is nop, else an if is required

Parameters
scc
stattat

Definition at line 667 of file system_to_code.c.

670 {
671  if (sc_rn_p(sc)) return(stat);
672  if (sc_empty_p(sc)) return(make_empty_statement());
673 
675  CONS(STATEMENT, stat, NIL),
676  NIL);
677 }
statement st_make_nice_test(expression, list, list)
Definition: statement.c:1585
#define make_empty_statement
An alias for make_empty_block_statement.
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
bool sc_rn_p(Psysteme sc)
bool sc_rn_p(Psysteme sc): check if the set associated to sc is the whole space, rn
Definition: sc_alloc.c:369
bool sc_empty_p(Psysteme sc)
bool sc_empty_p(Psysteme sc): check if the set associated to sc is the constant sc_empty or not.
Definition: sc_alloc.c:350
expression Psysteme_to_expression(Psysteme systeme)
Standard includes.

References CONS, make_empty_statement, NIL, Psysteme_to_expression(), sc_empty_p(), sc_rn_p(), st_make_nice_test(), and STATEMENT.

Referenced by build_third_comb(), generate_io_statements_for_shared_arrays(), GENERATION(), processor_loop(), and verify_array_variable().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listexpres_to_listexpres_newbase()

cons* listexpres_to_listexpres_newbase ( cons ,
Pvecteur  [],
Pbase   
)

◆ look_for_inner_loops()

statement look_for_inner_loops ( loop  l,
list  sl,
statement(*)(list, bool(*)(statement))  loop_transformation,
bool(*)(statement loop_predicate 
)

FI: I do not understand how debug levels are managed...

They should be factored out.

check that i is a block

SG: added to cope with empty statements

i is an inner loop, append it to the list of loops

here are no more nested loops

FI: I do not understand this piece of code. I expect a look_for_nested_loop_statements().

Parameters
sll

Definition at line 166 of file look_for_nested_loops.c.

171 {
172  statement lb = loop_body(l);
174  statement ss;
176  unstructured unst;
177  loop li;
178  cons *b, *b1;
179  test tt;
180  statement true_s, false_s;
181 
182  /* check that i is a block */
183  switch (instruction_tag(i)) {
184 
185  case is_instruction_loop:
186 
187  li = instruction_loop(i);
188  sl = CONS(STATEMENT,lb,sl);
189  new_s = look_for_inner_loops(li,sl,loop_transformation, loop_predicate);
190  break;
191 
193 retry:
194  b = instruction_block(i);
195  ss = STATEMENT(CAR(b));
196  /* SG: added to cope with empty statements */
197  while(empty_statement_or_continue_p(ss) && !ENDP(CDR(b))) {
198  POP(b);
199  ss=STATEMENT(CAR(b));
200  }
201  i = statement_instruction(ss);
202  if (instruction_block_p(i))
203  goto retry;
204  if (instruction_loop_p(i)){
205  /* i is an inner loop, append it to the list of loops */
206  li = instruction_loop(i);
207  sl = CONS(STATEMENT,ss,sl);
208  new_s = look_for_inner_loops(li, sl, loop_transformation, loop_predicate);
209  }
210  else {
211  /*there are no more nested loops */
212 
213  look_for_nested_loop_statements(ss,loop_transformation, loop_predicate);
214  debug_on("ZERO_DEBUG_LEVEL");
215  new_s = (*loop_transformation)(sl,loop_predicate);
216  debug_off();
217  }
218 
219  for( b1=CDR(b); !ENDP(b1); b1 = CDR(b1) ) {
220  ss = STATEMENT(CAR(b1));
221  look_for_nested_loop_statements(ss,loop_transformation, loop_predicate);
222  }
223  break;
224 
225 
226  ␌
227  case is_instruction_test:
228 
229  tt = instruction_test(i);
230  true_s = test_true(tt);
231  false_s= test_false(tt);
232  look_for_nested_loop_statements(true_s,loop_transformation, loop_predicate);
233  look_for_nested_loop_statements(false_s,loop_transformation, loop_predicate);
234  debug_on("ZERO_DEBUG_LEVEL");
235  new_s = (*loop_transformation)(sl,loop_predicate);
236  debug_off();
237  break;
238 
241 
242  look_for_nested_loop_statements(body, loop_transformation, loop_predicate);
243  new_s = (*loop_transformation)(sl,loop_predicate);
244  break;
245  }
246 
247  case is_instruction_forloop: {
249 
250  look_for_nested_loop_statements(body, loop_transformation, loop_predicate);
251  new_s = (*loop_transformation)(sl,loop_predicate);
252  break;
253  }
254  case is_instruction_goto:
255 
256  pips_internal_error("unexpected goto");
257 
258  case is_instruction_call:
259  debug_on("ZERO_DEBUG_LEVEL");
260  new_s = (*loop_transformation)(sl,loop_predicate);
261  debug_off();
262 
263  break;
264 
266 
267  /* FI: I do not understand this piece of code. I expect a
268  look_for_nested_loop_statements(). */
269  unst =instruction_unstructured(i);
271  i = statement_instruction(ss);
272  if (instruction_loop_p(i)) {
273  li = instruction_loop(i);
274  sl = CONS(STATEMENT,ss,sl);
275  new_s = look_for_inner_loops(li,sl,loop_transformation, loop_predicate);
276  }
277  else {
278  debug_on("ZERO_DEBUG_LEVEL");
279  new_s = (*loop_transformation)(sl,loop_predicate);
280  debug_off();
281  break;
282  }
283  break;
284 
285  default:
286  pips_internal_error("unexpected tag %d",instruction_tag(i));
287  }
288 
289  return new_s;
290 }
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
#define POP(l)
Modify a list pointer to point on the next element of the list.
Definition: newgen_list.h:59
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
bool empty_statement_or_continue_p(statement)
Return true if the statement is an empty instruction block or a continue or a recursive combination o...
Definition: statement.c:474
statement look_for_inner_loops(loop l, list sl, statement(*loop_transformation)(list, bool(*)(statement)), bool(*loop_predicate)(statement))
FI: I do not understand how debug levels are managed...
void look_for_nested_loop_statements(statement s, statement(*loop_transformation)(list, bool(*)(statement)), bool(*loop_predicate)(statement))
Package generation (for the hyperplane transformation?)
#define debug_on(env)
Definition: misc-local.h:157
#define pips_internal_error
Definition: misc-local.h:149
#define debug_off()
Definition: misc-local.h:160
#define instruction_block_p(i)
#define unstructured_control
After the modification in Newgen: unstructured = entry:control x exit:control we have create a macro ...
#define is_instruction_block
soft block->sequence transition
#define instruction_block(i)
#define loop_body(x)
Definition: ri.h:1644
#define instruction_loop_p(x)
Definition: ri.h:1518
#define instruction_loop(x)
Definition: ri.h:1520
#define test_false(x)
Definition: ri.h:2837
@ is_instruction_goto
Definition: ri.h:1473
@ is_instruction_unstructured
Definition: ri.h:1475
@ is_instruction_whileloop
Definition: ri.h:1472
@ is_instruction_test
Definition: ri.h:1470
@ is_instruction_call
Definition: ri.h:1474
@ is_instruction_forloop
Definition: ri.h:1477
@ is_instruction_loop
Definition: ri.h:1471
#define instruction_tag(x)
Definition: ri.h:1511
#define test_true(x)
Definition: ri.h:2835
#define instruction_forloop(x)
Definition: ri.h:1538
#define instruction_whileloop(x)
Definition: ri.h:1523
#define whileloop_body(x)
Definition: ri.h:3162
#define statement_instruction(x)
Definition: ri.h:2458
#define control_statement(x)
Definition: ri.h:941
#define instruction_test(x)
Definition: ri.h:1517
#define forloop_body(x)
Definition: ri.h:1372
#define instruction_unstructured(x)
Definition: ri.h:1532
#define statement_undefined
Definition: ri.h:2419
Value b1
booleen indiquant quel membre est en cours d'analyse
Definition: sc_gram.c:105

References b1, CAR, CDR, CONS, control_statement, debug_off, debug_on, empty_statement_or_continue_p(), ENDP, forloop_body, instruction_block, instruction_block_p, instruction_forloop, instruction_loop, instruction_loop_p, instruction_tag, instruction_test, instruction_unstructured, instruction_whileloop, is_instruction_block, is_instruction_call, is_instruction_forloop, is_instruction_goto, is_instruction_loop, is_instruction_test, is_instruction_unstructured, is_instruction_whileloop, look_for_inner_loops(), look_for_nested_loop_statements(), loop_body, pips_internal_error, POP, STATEMENT, statement_instruction, statement_undefined, test_false, test_true, unstructured_control, and whileloop_body.

Referenced by look_for_inner_loops(), and look_for_nested_loop_statements().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ look_for_nested_loop_statements()

void look_for_nested_loop_statements ( statement  s,
statement(*)(list, bool(*)(statement))  loop_transformation,
bool(*)(statement loop_predicate 
)

look_for_nested_loops.c

look_for_nested_loops.c

void look_for_nested_loop_statements(statement s) search the nested loops in the statement s

ifdebug(9) {

pips_debug(9, "Before transformation:\n");

debug_on("ZERO_DEBUG_LEVEL");

print_statement(s);

debug_off();

}

debug_on("ZERO_DEBUG_LEVEL");

print_statement(new_s);

debug_off();

SG: added to cope with empty statements

Definition at line 56 of file look_for_nested_loops.c.

59 {
60  instruction i;
61  cons *b, *b1;
62  statement ss, new_s = statement_undefined;
63  loop l;
64  cons *list_loop_statement;
65  test tt;
66  statement true_s, false_s;
67 
68  i = statement_instruction(s);
69  switch (instruction_tag(i)) {
71  new_s = s;
72  l = instruction_loop(i);
73 
74  if ((*loop_predicate)(s)) {
75  list_loop_statement = CONS (STATEMENT,s,NIL);
76 
77  /* ifdebug(9) { */
78  /* pips_debug(9, "Before transformation:\n"); */
79  /* debug_on("ZERO_DEBUG_LEVEL"); */
80  /* print_statement(s); */
81  /* debug_off(); */
82  /* } */
83 
84  new_s = look_for_inner_loops(l,
85  list_loop_statement,
86  loop_transformation,
87  loop_predicate);
88 
89  ifdebug(9) {
90  pips_debug(9, "After transformation:\n");
91  pips_assert("look_for_nested_loop_statement", statement_consistent_p(new_s));
92  /* debug_on("ZERO_DEBUG_LEVEL"); */
93  /* print_statement(new_s); */
94  /* debug_off(); */
95  }
96  if (new_s != statement_undefined) {
97  i = statement_instruction(s);
98  instruction_loop(i) =
100  }
101  else look_for_nested_loop_statements(loop_body(l),loop_transformation,
102  loop_predicate);
103  break;
104 
106 
107  b = instruction_block(i);
108  if(ENDP(b)) break;
109  ss = STATEMENT(CAR(b));
110  /* SG: added to cope with empty statements */
111  while(empty_statement_or_continue_p(ss) && !ENDP(CDR(b))) {
112  POP(b);
113  ss=STATEMENT(CAR(b));
114  }
115  look_for_nested_loop_statements(ss, loop_transformation, loop_predicate);
116  for(b1 = CDR(b); !ENDP(b1); b1 = CDR(b1)) {
117  ss = STATEMENT(CAR(b1));
118  look_for_nested_loop_statements(ss, loop_transformation, loop_predicate);
119  }
120  break;
121 
122  case is_instruction_call:
123  break;
124 
125  case is_instruction_test:
126 
127  tt = instruction_test(i);
128  true_s = test_true(tt);
129  false_s= test_false(tt);
130  look_for_nested_loop_statements(true_s, loop_transformation, loop_predicate);
131  look_for_nested_loop_statements(false_s, loop_transformation, loop_predicate);
132  break;
133 
135 
137  statement body = whileloop_body(wl);
138 
139  look_for_nested_loop_statements(body, loop_transformation, loop_predicate);
140  break;
141  }
142 
143  case is_instruction_forloop: {
144 
146  statement body = forloop_body(fl);
147 
148  look_for_nested_loop_statements(body, loop_transformation, loop_predicate);
149  break;
150  }
151 
154  loop_transformation,
155  loop_predicate);
156  break;
157 
158  case is_instruction_goto:
159  pips_internal_error("unexpected goto in code");
160  default:
161  pips_internal_error("unexpected tag %d",instruction_tag(i));
162  }
163 }
bool statement_consistent_p(statement p)
Definition: ri.c:2195
void look_for_nested_loops_unstructured(unstructured u, statement(*loop_transformation)(list, bool(*)(statement)), bool(*loop_predicate)(statement))
oid look_for_nested_loops_unstructured(unstructured u) search the nested loops contained in the unstr...

References b1, CAR, CDR, CONS, empty_statement_or_continue_p(), ENDP, forloop_body, ifdebug, instruction_block, instruction_forloop, instruction_loop, instruction_tag, instruction_test, instruction_unstructured, instruction_whileloop, is_instruction_block, is_instruction_call, is_instruction_forloop, is_instruction_goto, is_instruction_loop, is_instruction_test, is_instruction_unstructured, is_instruction_whileloop, look_for_inner_loops(), look_for_nested_loop_statements(), look_for_nested_loops_unstructured(), loop_body, NIL, pips_assert, pips_debug, pips_internal_error, POP, STATEMENT, statement_consistent_p(), statement_instruction, statement_undefined, test_false, test_true, and whileloop_body.

Referenced by global_parallelization(), interactive_loop_transformation(), look_for_inner_loops(), look_for_nested_loop_statements(), look_for_nested_loops_unstructured(), and strip_mine().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ look_for_nested_loops_unstructured()

void look_for_nested_loops_unstructured ( unstructured  u,
statement(*)(list, bool(*)(statement))  loop_transformation,
bool(*)(statement loop_predicate 
)

oid look_for_nested_loops_unstructured(unstructured u) search the nested loops contained in the unstructured u

Definition at line 298 of file look_for_nested_loops.c.

301 {
302  cons *blocs = NIL;
304 
305  debug_on("GENERATION_DEBUG_LEVEL");
306  CONTROL_MAP(c, {
307  statement st = control_statement(c) ;
308  (void) look_for_nested_loop_statements(st,loop_transformation, loop_predicate);
309  }, ct, blocs) ;
310  gen_free_list(blocs);
311  debug_off();
312 }
#define CONTROL_MAP(ctl, code, c, list)
Macro to walk through all the controls reachable from a given control node of an unstructured.

References CONTROL_MAP, control_statement, debug_off, debug_on, gen_free_list(), look_for_nested_loop_statements(), NIL, and unstructured_control.

Referenced by look_for_nested_loop_statements().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loop_index_domaine_to_contrainte()

void loop_index_domaine_to_contrainte ( range  r,
entity  ind,
Psysteme  sc 
)

ake two constraints for the current index: I-vup<=0, -I+vlow<=0

build - new_var <= 0

build incr * new_var - vup + vlow <= 0

build ind == vlow + incr * new_var

Parameters
indnd
scc

Definition at line 86 of file loop_iteration_domaine_to_sc.c.

90 {
91  Pvecteur pv;
92  Pcontrainte pc;
93  Pvecteur
94  vlow = VECTEUR_NUL,
95  vup = VECTEUR_NUL,
96  pv_incr = VECTEUR_NUL;
97 
98  Value incr= VALUE_ONE;
99 
100  expression low = range_lower(r);
101  expression up = range_upper(r);
102  normalized low_norm = NORMALIZE_EXPRESSION(low);
103  normalized up_norm = NORMALIZE_EXPRESSION(up);
105 
106 
107  debug_on("CONVERSION_DEBUG_LEVEL");
108 
109  debug(8,"loop_index_domaine_to_contrainte", "begin\n");
110 
111  if (normalized_linear_p(low_norm) && normalized_linear_p(up_norm)){
112  vlow = (Pvecteur) normalized_linear(low_norm);
113  vup = (Pvecteur) normalized_linear(up_norm);
114 
115  }
116  else
117  user_error("loop_iteration_domaine_to_sc","untractable loop bound\n");
118 
119  if (normalized_linear_p(incr_norm))
120  pv_incr = (Pvecteur) normalized_linear(incr_norm);
121  if (vect_constant_p(pv_incr)) {
122  if (value_one_p(incr = vecteur_val(pv_incr))) {
123  /*make two constraints for the current index:
124  I-vup<=0, -I+vlow<=0 */
125  pv = vect_dup(vup);
126  vect_chg_sgn(pv);
127  vect_add_elem(&pv, (Variable) ind, VALUE_ONE);
128  pc = contrainte_make(pv);
129  sc_add_ineg(sc,pc);
130  pv = vect_dup(vlow);
131  vect_add_elem(&pv, (Variable) ind, VALUE_MONE);
132  pc = contrainte_make(pv);
133  sc_add_ineg(sc,pc);
134  }
135  else {
136  Variable new_var = creat_new_var(sc);
137  sc->dimension++;
138  sc->base = vect_add_variable(sc->base, (Variable) new_var);
139  /* build - new_var <= 0 */
140  pv = vect_new((Variable) ind, VALUE_MONE);
141  pc = contrainte_make(pv);
142  sc_add_ineg(sc,pc);
143  /* build incr * new_var - vup + vlow <= 0 */
144  pv = vect_dup(vup);
145  vect_chg_sgn(pv);
146  pv = vect_add(pv,vect_dup(vlow));
147  vect_add_elem(&pv, (Variable) new_var, incr);
148  pc = contrainte_make(pv);
149  sc_add_ineg(sc,pc);
150  /* build ind == vlow + incr * new_var */
151  pv = vect_dup(vlow);
152  vect_chg_sgn(pv);
153  pv = vect_add(pv,vect_new((Variable) ind, VALUE_ONE));
154  pv = vect_add(pv,vect_new((Variable) new_var, value_uminus(incr)));
155  pc = contrainte_make(pv);
156  sc_add_eg(sc,pc);
157  }
158  }
159 
160  debug(8,"loop_index_domaine_to_contrainte", "end\n");
161 
162  debug_off();
163 }
#define VALUE_MONE
Pbase vect_add_variable(Pbase b, Variable v)
package vecteur - routines sur les bases
Definition: base.c:61
Pcontrainte contrainte_make(Pvecteur pv)
Pcontrainte contrainte_make(Pvecteur pv): allocation et initialisation d'une contrainte avec un vecte...
Definition: alloc.c:73
bool vect_constant_p(Pvecteur)
bool vect_constant_p(Pvecteur v): v contains only a constant term, may be zero
Definition: predicats.c:211
#define user_error(fn,...)
Definition: misc-local.h:265
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189
#define NORMALIZE_EXPRESSION(e)
#define normalized_linear_p(x)
Definition: ri.h:1779
#define range_upper(x)
Definition: ri.h:2290
#define range_increment(x)
Definition: ri.h:2292
#define range_lower(x)
Definition: ri.h:2288
#define normalized_linear(x)
Definition: ri.h:1781
Variable creat_new_var(Psysteme ps)
char * noms_var(int i): cette fonction convertit un numero de variable en chaine de caracteres
Definition: sc_var.c:102
Pbase base
Definition: sc-local.h:75
int dimension
Definition: sc-local.h:74
#define vecteur_val(v)
struct Svecteur * Pvecteur
Pvecteur vect_new(Variable var, Value coeff)
Pvecteur vect_new(Variable var,Value coeff): allocation d'un vecteur colineaire au vecteur de base va...
Definition: alloc.c:110

References Ssysteme::base, contrainte_make(), creat_new_var(), debug(), debug_off, debug_on, Ssysteme::dimension, NORMALIZE_EXPRESSION, normalized_linear, normalized_linear_p, range_increment, range_lower, range_upper, user_error, VALUE_MONE, VALUE_ONE, value_one_p, value_uminus, vect_add(), vect_add_elem(), vect_add_variable(), vect_chg_sgn(), vect_constant_p(), vect_dup(), vect_new(), VECTEUR_NUL, and vecteur_val.

Referenced by loop_iteration_domaine_to_sc().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loop_iteration_domaine_to_sc()

Psysteme loop_iteration_domaine_to_sc ( list  lls,
Pbase baseindex 
)

loop_iteration_domaine_to_sc.c

loop_iteration_domaine_to_sc.c

Psysteme loop_iteration_domaine_to_sc(cons *lls , Pbase *baseindex) transform the iteration domain of the nested loops (contained lls) in a system of constraints (sc)

New loop indices are added at the head of the list baseindex. The field base of sc contains all the system variables. Variables are not in a specific order.

CA: Ajout du cas ou l'increment de boucle est different de 1 le 1/9/91

add the current index "ind" to the index basis

dd the constraints to sc

Parameters
llsls
baseindexaseindex

Definition at line 52 of file loop_iteration_domaine_to_sc.c.

54 {
55  Psysteme sc;
56 
57  debug_on("CONVERSION_DEBUG_LEVEL");
58 
59  pips_debug(8, "begin\n");
60 
61  sc = sc_new();
62  for (; lls != NIL; lls = CDR(lls)){
64  entity ind = loop_index(l);
65  range r = loop_range(l);
66 
67  /* add the current index "ind" to the index basis */
68  base_add_dimension(baseindex, (Variable) ind);
69 
70  /*add the constraints to sc*/
72  }
73  sc->nb_ineq = nb_elems_list(sc->inegalites);
74  sc_creer_base(sc);
75 
76  ifdebug(8) {
77  vect_fprint(stderr, *baseindex, (get_variable_name_t) entity_local_name);
78  }
79 
80  debug(8,"loop_iteration_domaine_to_sc", "end\n");
81 
82  debug_off();
83  return sc;
84 }
void vect_fprint(FILE *f, Pvecteur v, get_variable_name_t variable_name)
void vect_fprint(FILE * f, Pvecteur v, char * (*variable_name)()): impression d'un vecteur creux v su...
Definition: io.c:124
void loop_index_domaine_to_contrainte(range r, entity ind, Psysteme sc)
#define loop_range(x)
Definition: ri.h:1642
#define loop_index(x)
Definition: ri.h:1640
void sc_creer_base(Psysteme ps)
void sc_creer_base(Psysteme ps): initialisation des parametres dimension et base d'un systeme lineair...
Definition: sc_alloc.c:129
Psysteme sc_new(void)
Psysteme sc_new(): alloue un systeme vide, initialise tous les champs avec des valeurs nulles,...
Definition: sc_alloc.c:55
Pcontrainte inegalites
Definition: sc-local.h:71
int nb_ineq
Definition: sc-local.h:73

References base_add_dimension, CAR, CDR, debug(), debug_off, debug_on, entity_local_name(), ifdebug, Ssysteme::inegalites, instruction_loop, loop_index, loop_index_domaine_to_contrainte(), loop_range, nb_elems_list(), Ssysteme::nb_ineq, NIL, pips_debug, sc_creer_base(), sc_new(), STATEMENT, statement_instruction, and vect_fprint().

Referenced by compute_iteration_domain(), Hierarchical_tiling(), hyperplane(), parallel_tiling(), Tiling2_buffer(), Tiling_buffer_allocation(), tiling_transformation(), and unimodular().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_index_entity()

entity make_index_entity ( entity  old_index)
Parameters
old_indexld_index

Definition at line 77 of file change_of_Pbase.c.

78 {
79  return make_index_prime_entity(old_index);
80 }

References make_index_prime_entity().

+ Here is the call graph for this function:

◆ make_index_prime_entity()

entity make_index_prime_entity ( entity  old_index)
Parameters
old_indexld_index

Definition at line 72 of file change_of_Pbase.c.

73 {
74  return make_new_index_entity(old_index, "p");
75 }
entity make_new_index_entity(entity, string)
Definition: variable.c:1851

References make_new_index_entity().

Referenced by change_of_base_index(), and make_index_entity().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Pcontrainte_to_expression_list()

list Pcontrainte_to_expression_list ( Pcontrainte  constraint,
entity  operator 
)

a simple expression is generated.

a binary operator should be given, as eg, ne, lt, le, gt, ge.

Parameters
constraintonstraint
operatorperator

Definition at line 90 of file system_to_code.c.

93 {
94  list result = NIL;
95  Pcontrainte c = NULL;
96  Pvecteur vneg = VECTEUR_NUL, vpos = VECTEUR_NUL;
97 
98  for(c=constraint; c; c=c->succ)
99  if (entity_undefined_p(operator))
100 
101  /* a simple expression is generated.
102  */
103  result =
104  CONS(EXPRESSION,
106  result);
107  else
108 
109  /* a binary operator should be given, as eg, ne, lt, le, gt, ge.
110  */
112  result =
114  MakeBinaryCall(operator,
117  result),
118  vect_rm(vpos), vpos=VECTEUR_NUL,
119  vect_rm(vneg), vneg=VECTEUR_NUL;
120 
121  return result;
122 }
#define contrainte_vecteur(c)
passage au champ vecteur d'une contrainte "a la Newgen"
#define entity_undefined_p(x)
Definition: ri.h:2762
void Pvecteur_separate_on_sign(Pvecteur v, Pvecteur *pvpos, Pvecteur *pvneg)
void Pvecteur_separate_on_sign(v, pvpos, pvneg) Pvecteur v, *pvpos, *pvneg;
Definition: unaires.c:369

References CONS, contrainte_vecteur, entity_undefined_p, EXPRESSION, make_vecteur_expression(), MakeBinaryCall(), NIL, Pvecteur_separate_on_sign(), Scontrainte::succ, vect_rm(), and VECTEUR_NUL.

Referenced by Psysteme_to_expression().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Psysteme_to_expression()

expression Psysteme_to_expression ( Psysteme  systeme)

system_to_code.c

system_to_code.c

Psystems stuff Newgen stuff PIPS stuff expression Psysteme_to_expression(Psysteme systeme)

From a Psysteme, a logical expression that checks for the constraints is generated.

Parameters
systemeysteme

Definition at line 69 of file system_to_code.c.

71 {
72  entity
75  list conjonction;
76  expression result;
77 
78  conjonction =
79  gen_nconc
80  (Pcontrainte_to_expression_list(sc_egalites(systeme), equ),
81  Pcontrainte_to_expression_list(sc_inegalites(systeme), leq));
82 
83  result = expression_list_to_conjonction(conjonction);
84 
85  gen_free_list(conjonction);
86  return result;
87 }
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
#define EQUAL_OPERATOR_NAME
#define LESS_OR_EQUAL_OPERATOR_NAME
expression expression_list_to_conjonction(list l)
Definition: expression.c:1937
list Pcontrainte_to_expression_list(Pcontrainte constraint, entity operator)

References entity_intrinsic(), EQUAL_OPERATOR_NAME, expression_list_to_conjonction(), gen_free_list(), gen_nconc(), LESS_OR_EQUAL_OPERATOR_NAME, and Pcontrainte_to_expression_list().

Referenced by build_third_comb(), expression_less_than_in_context(), generate_optional_if(), and top_down_abc_dimension().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reset_information_for_code_optimizations()

void reset_information_for_code_optimizations ( void  )

Definition at line 254 of file system_to_code.c.

255 {
256  close_lowers();
257  close_uppers();
258 }

Referenced by generate_io_collect_or_update(), and hpf_remapping().

+ Here is the caller graph for this function:

◆ sc_change_baseindex()

Psysteme sc_change_baseindex ( Psysteme  sc,
Pbase  base_old,
Pbase  base_new 
)

Psysteme sc_change_baseindex(Psysteme sc, Pbase base_old, Pbase base_new) le changement de base d'indice pour sc.

Parameters
scc
base_oldase_old
base_newase_new

Definition at line 85 of file change_of_Pbase.c.

89 {
90  Pbase pb1, pb2;
91 
92  for(pb1=base_old,pb2=base_new;pb1!=NULL;pb1=pb1->succ,pb2=pb2->succ)
93  sc_variable_rename(sc,pb1->var,pb2->var);
94  return(sc);
95 }
Psysteme sc_variable_rename(Psysteme s, Variable v_old, Variable v_new)
Psysteme sc_variable_rename(Psysteme s, Variable v_old, Variable v_new): reecriture du systeme s remp...
Definition: sc.c:157

References sc_variable_rename(), Svecteur::succ, and Svecteur::var.

Referenced by hyperplane(), and unimodular().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ scanning_base_to_vect()

void scanning_base_to_vect ( matrice  ,
int  ,
Pbase  ,
Pvecteur  [] 
)

◆ set_information_for_code_optimizations()

void set_information_for_code_optimizations ( Psysteme  s)

I could keep the system for further optimizations...

Here, only direct lower and upper bounds are extracted and kept.

first look thru equalities

then thru inequalities

UPPER

LOWER

Definition at line 208 of file system_to_code.c.

210 {
211  Pcontrainte c;
212  Variable var;
213  Value coe, cst, val;
214 
215  init_lowers();
216  init_uppers();
217 
218  /* first look thru equalities
219  */
220  for (c=sc_egalites(s); c; c=c->succ)
221  {
222  if (vect_simple_definition_p(contrainte_vecteur(c), &var, &coe, &cst))
223  {
224  val = value_div(value_uminus(cst), coe);
225  store_an_upper((entity) var, VALUE_TO_INT(val));
226  store_a_lower((entity) var, VALUE_TO_INT(val));
227  }
228  }
229 
230  /* then thru inequalities
231  */
232  for (c=sc_inegalites(s); c; c=c->succ)
233  {
234  if (vect_simple_definition_p(contrainte_vecteur(c), &var, &coe, &cst))
235  {
236  if (value_pos_p(coe)) /* UPPER */
237  {
238  Value n = value_uminus(cst),
239  r = value_pdiv(n, coe);
241  }
242  else /* LOWER */
243  {
244  Value n = value_minus(cst,value_plus(coe,VALUE_ONE)),
245  d = value_uminus(coe),
246  r = value_pdiv(n,d);
247  store_a_lower((entity) var, VALUE_TO_INT(r));
248  }
249  }
250  }
251 }
#define VALUE_TO_INT(val)
#define value_pdiv(v1, v2)
#define value_plus(v1, v2)
binary operators on values
static bool vect_simple_definition_p(Pvecteur v, Variable *pvar, Value *pcoe, Value *pcst)
here I store simple bounds on variables appearing in the systems to allow the code generation phase t...
static void store_a_lower(entity var, int val)
static void store_an_upper(entity var, int val)

References contrainte_vecteur, store_a_lower(), store_an_upper(), Scontrainte::succ, value_div, value_minus, VALUE_ONE, value_pdiv, value_plus, value_pos_p, VALUE_TO_INT, value_uminus, and vect_simple_definition_p().

Referenced by generate_io_collect_or_update(), and hpf_remapping().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ statement_newbase()

void statement_newbase ( statement  ,
Pvecteur  [],
Pbase   
)

◆ systeme_to_loop_nest()

statement systeme_to_loop_nest ( Psysteme  sc,
list  vars,
statement  body,
entity  divide 
)

sc is used to generate the loop nest bounds for variables vars.

vars may be empty. the loop statement is returned.

sc is not touched... I have to give the divide entity to be called

duplicate sc

??? could do a better job with =

reverse the list of vars

VAR = LOWER body

DO VAR = LOWER, UPPER, 1 body ENDDO

Parameters
scc
varsof entity
bodyody
divideivide

Definition at line 578 of file system_to_code.c.

583 {
584  range rg;
585  Pcontrainte c, lower, upper;
586  list reverse;
587  statement assign, current = body;
588  Psysteme s;
589 
590  if (ENDP(vars)) return body;
591 
592  s = sc_dup(sc); /* duplicate sc*/
593  sc_transform_eg_in_ineg(s); /* ??? could do a better job with = */
594  c = sc_inegalites(s);
595 
596  reverse = gen_nreverse(gen_copy_seq(vars)); /* reverse the list of vars*/
597 
598  message_assert("no equalities, now", sc_nbre_egalites(s)==0);
599 
600  FOREACH(ENTITY,e,reverse)
601  {
602  Variable var = (Variable) e;
603 
604  pips_debug(5, "variable %s loop\n", entity_name((entity) var));
605 
606  constraints_for_bounds(var, &c, &lower, &upper);
607  if( !CONTRAINTE_UNDEFINED_P(lower) && !CONTRAINTE_UNDEFINED_P(upper) )
608  {
609 
610  if (bounds_equal_p(var, lower, upper))
611  {
612  /* VAR = LOWER
613  * body
614  */
615  assign =
617  constraints_to_loop_bound(lower, var,
618  true, divide));
619  current =
622  NIL)));
623 
624  }
625  else
626  {
627  /* DO VAR = LOWER, UPPER, 1
628  * body
629  * ENDDO
630  */
631  rg = make_range(constraints_to_loop_bound(lower, var,
632  true, divide),
633  constraints_to_loop_bound(upper, var,
634  false, divide),
635  int_to_expression(1));
636 
637  current =
641  make_loop((entity) var,
642  rg,
643  current,
646  NIL)));
647  }
648 
649  contraintes_free(lower);
650  contraintes_free(upper);
651  }
652  }
653 
654  gen_free_list(reverse);
655  sc_inegalites(s)=c, sc_rm(s);
656 
657  return current;
658 }
execution make_execution(enum execution_utype tag, void *val)
Definition: ri.c:838
loop make_loop(entity a1, range a2, statement a3, entity a4, execution a5, list a6)
Definition: ri.c:1301
instruction make_instruction(enum instruction_utype tag, void *val)
Definition: ri.c:1166
range make_range(expression a1, expression a2, expression a3)
Definition: ri.c:2041
Pcontrainte contraintes_free(Pcontrainte pc)
Pcontrainte contraintes_free(Pcontrainte pc): desallocation de toutes les contraintes de la liste pc.
Definition: alloc.c:226
void constraints_for_bounds(Variable, Pcontrainte *, Pcontrainte *, Pcontrainte *)
void constraints_for_bounds(var, pinit, plower, pupper) Variable var; Pcontrainte *pinit,...
Definition: unaires.c:176
statement make_block_statement(list)
Make a block statement from a list of statement.
Definition: statement.c:616
statement instruction_to_statement(instruction)
Build a statement from a give instruction.
Definition: statement.c:597
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
list gen_copy_seq(list l)
Copy a list structure.
Definition: list.c:501
statement make_assign_statement(expression, expression)
Definition: statement.c:583
#define UU
Definition: newgen_types.h:98
entity entity_empty_label(void)
Definition: entity.c:1105
expression entity_to_expression(entity e)
if v is a constant, returns a constant call.
Definition: expression.c:165
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define entity_name(x)
Definition: ri.h:2790
@ is_execution_sequential
Definition: ri.h:1189
Psysteme sc_dup(Psysteme ps)
Psysteme sc_dup(Psysteme ps): should becomes a link.
Definition: sc_alloc.c:176
void sc_transform_eg_in_ineg(Psysteme sc)
Package sc.
static size_t current
Definition: string.c:115
expression constraints_to_loop_bound(Pcontrainte c, Variable var, bool is_lower, entity divide)
expression constraints_to_loop_bound(c, var, is_lower)
bool bounds_equal_p(Variable var, Pcontrainte lower, Pcontrainte upper)
this function checks whether the lower and upper constraints are going to generate the same bound on ...

References bounds_equal_p(), CONS, constraints_for_bounds(), constraints_to_loop_bound(), CONTRAINTE_UNDEFINED_P, contraintes_free(), current, divide, ENDP, ENTITY, entity_empty_label(), entity_name, entity_to_expression(), FOREACH, gen_copy_seq(), gen_free_list(), gen_nreverse(), instruction_to_statement(), int_to_expression(), is_execution_sequential, is_instruction_loop, make_assign_statement(), make_block_statement(), make_execution(), make_instruction(), make_loop(), make_range(), message_assert, NIL, pips_debug, sc_dup(), sc_rm(), sc_transform_eg_in_ineg(), STATEMENT, and UU.

Referenced by broadcast(), copy_write_statement_with_cumulated_regions(), elements_loop(), generate_io_statements_for_shared_arrays(), GENERATION(), initialize_array_variable(), make_array_communication_statement(), processor_loop(), Psysteme_to_loop_nest(), and verify_array_variable().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vect_change_base()

Pvecteur vect_change_base ( Pvecteur  ,
Pbase  ,
Pvecteur  [] 
)