PIPS
system_to_code.c
Go to the documentation of this file.
1 /*
2 
3  $Id: system_to_code.c 23065 2016-03-02 09:05:50Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of PIPS.
8 
9  PIPS is free software: you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 #ifdef HAVE_CONFIG_H
25  #include "pips_config.h"
26 #endif
27 /*
28  * HPFC module by Fabien COELHO,
29  * moved to conversion on 15 May 94
30  */
31 
32 /* Standard includes
33  */
34 
35 #include <stdio.h>
36 #include <string.h>
37 #include <limits.h>
38 
39 /* Psystems stuff
40  */
41 
42 #include "linear.h"
43 
44 /* Newgen stuff
45  */
46 #include "genC.h"
47 #include "ri.h"
48 #include "effects.h"
49 /* PIPS stuff
50  */
51 
52 #include "misc.h"
53 #include "ri-util.h"
54 #include "effects-util.h"
55 #include "effects-generic.h"
56 #include "effects-convex.h"
57 #include "properties.h"
58 
59 #include "conversion.h"
60 
61 /********************************************************** TEST GENERATION */
62 
63 /* expression Psysteme_to_expression(Psysteme systeme)
64  *
65  * From a Psysteme, a logical expression that checks for
66  * the constraints is generated.
67  */
70  Psysteme systeme)
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 }
88 
89 list
91  Pcontrainte constraint,
92  entity operator)
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 }
123 
124 /************************************************ BOUNDS FOR OPTIMIZATIONS */
125 
126 /* here I store simple bounds on variables appearing in the systems
127  * to allow the code generation phase to use them to improve the code.
128  */
129 /* returns the lower and upper bounds of var if available
130  * the concept could be transfered to SC ?
131  */
132 static bool
134  Pvecteur v,
135  Variable *pvar,
136  Value *pcoe,
137  Value *pcst)
138 {
139  Variable var;
140  int size = vect_size(v);
141  if (size>2 || size<1) return false;
142 
143  var = var_of(v);
144  if (var==TCST && size<=1) return false;
145 
146  if (var==TCST) /* size == 2 */
147  {
148  *pvar = var_of(v->succ);
149  *pcoe = val_of(v->succ);
150  *pcst = val_of(v);
151  return true;
152  }
153  else
154  {
155  *pvar = var;
156  *pcoe = val_of(v);
157  if (!v->succ)
158  {
159  *pcst = 0;
160  return true;
161  }
162 
163  if (var_of(v->succ)!=TCST) return false;
164  *pcst = val_of(v->succ);
165  return true;
166  }
167 }
168 
171 
172 static void
174  entity var,
175  int val)
176 {
177  pips_debug(9, "%s <= %d\n", entity_local_name(var), val);
178 
179  if (bound_uppers_p(var))
180  {
181  int old = load_uppers(var);
182  if (old>val) update_uppers(var, val);
183  }
184  else
185  store_uppers(var, val);
186 }
187 
188 static void
190  entity var,
191  int val)
192 {
193  pips_debug(9, "%s >= %d\n", entity_local_name(var), val);
194 
195  if (bound_lowers_p(var))
196  {
197  int old = load_lowers(var);
198  if (old<val) update_lowers(var, val);
199  }
200  else
201  store_lowers(var, val);
202 }
203 
204 /* I could keep the system for further optimizations...
205  * Here, only direct lower and upper bounds are extracted and kept.
206  */
207 void
209  Psysteme s)
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 }
252 
253 void
255 {
256  close_lowers();
257  close_uppers();
258 }
259 
260 
261 /* this functions returns bounds for variable var if both are available.
262  */
263 static bool /* whether bounds were found */
265  Variable var, /* the VARiable */
266  Value * lb, /* Lower Bound */
267  Value * ub) /* Upper Bound */
268 {
269  if (lowers_undefined_p() || uppers_undefined_p())
270  return false; /* no information available, that's for sure */
271 
272  if (!bound_lowers_p((entity) var) || !bound_uppers_p((entity) var))
273  return false;
274 
275  *lb = int_to_value(load_lowers((entity) var));
276  *ub = int_to_value(load_uppers((entity) var));
277 
278  return true;
279 }
280 
281 /* returns v lower bound if found, or INT_MIN.
282  */
284  Pvecteur v)
285 {
286  Value bound = 0, val;
287  Variable var;
288 
289  if (lowers_undefined_p() || uppers_undefined_p())
290  return VALUE_MIN; /* no information available, that's for sure */
291 
292  for(; v; v=v->succ)
293  {
294  var = var_of(v);
295  val = val_of(v);
296 
297  if (var==TCST)
298  value_addto(bound,val) ;
299  else
300  {
301  int il;
302  Value vl,p;
303  if (value_pos_p(val))
304  {
305  if (!bound_lowers_p((entity) var))
306  return VALUE_MIN;
307  else
308  il = load_lowers((entity) var);
309  }
310  else /* val < 0, I guess */
311  {
312  if (!bound_uppers_p((entity) var))
313  return VALUE_MIN;
314  else
315  il = load_uppers((entity) var);
316  }
317 
318  vl = int_to_value(il);
319  p = value_mult(val,vl);
320  value_addto(bound,p);
321  }
322  }
323 
324  return bound;
325 }
326 
327 static bool
329  Pvecteur v,
330  Value denominator,
331  Value *result)
332 {
333  Value min=0, max=0;
334 
335  for(; v; v=v->succ)
336  {
337  Variable var = var_of(v);
338  Value coef = val_of(v), lb, ub;
339 
340  if (var==TCST)
341  value_addto(min,coef), value_addto(max,coef);
342  else
343  {
344  Value cu,cl;
345  if (!range_of_variable(var, &lb, &ub))
346  return false;
347  cu = value_mult(coef,ub);
348  cl = value_mult(coef,lb);
349 
350  if (value_pos_p(coef))
351  value_addto(min,cl), value_addto(max,cu);
352  else
353  value_addto(min,cu), value_addto(max,cl);
354  }
355  }
356 
357  value_pdivision(min, denominator);
358  value_pdivision(max, denominator);
359 
360  *result = min;
361  return value_eq(min,max);
362 }
363 
364 /* expression constraints_to_loop_bound(c, var, is_lower)
365  *
366  * the is_lower (lower/upper) loop bound for variable var relative
367  * to Pcontrainte c is generated. All the constraints in c are used,
368  * and they must be ok.
369  *
370  * see also make_bound_expression in ri-util/bound_generation.c
371  * maybe move this function in ri-util/bound_generation.c?
372  */
373 expression
375  Pcontrainte c, /* the constraints of the bound */
376  Variable var, /* the index variable */
377  bool is_lower, /* lower or upper bound */
378  entity divide) /* integer division to be called */
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 }
529 
530 /* this function checks whether the lower and upper constraints
531  * are going to generate the same bound on variable var.
532  */
533 bool
535  Variable var,
536  Pcontrainte lower,
537  Pcontrainte upper)
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 }
571 
572 /* sc is used to generate the loop nest bounds for variables vars.
573  * vars may be empty. the loop statement is returned.
574  *
575  * sc is not touched...
576  */
577 statement
579  Psysteme sc,
580  list /* of entity */ vars,
581  statement body,
582  entity divide) /* I have to give the divide entity to be called */
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 }
659 
660 /* statement generate_optional_if(sc, stat)
661  *
662  * if sc is Z^n then no if is required,
663  * if sc is empty, then statement is nop,
664  * else an if is required
665  */
666 statement
668  Psysteme sc,
669  statement stat)
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 }
678 
679 /* that is all
680  */
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
#define value_pos_p(val)
#define value_sign(v)
trian operators on values
#define int_to_value(i)
end LINEAR_VALUE_IS_INT
#define value_minus(v1, v2)
#define VALUE_TO_INT(val)
#define value_oppose(ref)
#define value_pdiv(v1, v2)
#define value_uminus(val)
unary operators on values
#define value_one_p(val)
#define VALUE_MIN
#define value_zero_p(val)
int Value
#define value_addto(ref, val)
#define value_eq(v1, v2)
bool operators on values
#define divide(a, b)
#define value_plus(v1, v2)
binary operators on values
#define VALUE_ONE
#define value_mult(v, w)
whether the default is protected or not this define makes no sense any more...
#define value_mod(v1, v2)
#define value_pdivision(ref, val)
#define value_div(v1, v2)
#define value_posz_p(val)
Value ppcm(Value, Value)
ppcm.c
Definition: ppcm.c:42
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)
#define contrainte_vecteur(c)
passage au champ vecteur d'une contrainte "a la Newgen"
Pcontrainte contraintes_free(Pcontrainte pc)
Pcontrainte contraintes_free(Pcontrainte pc): desallocation de toutes les contraintes de la liste pc.
Definition: alloc.c:226
Pcontrainte contraintes_dup(Pcontrainte c_in)
Pcontrainte contraintes_dup(Pcontrainte c_in) a list of constraints is copied.
Definition: alloc.c:146
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
void constraints_for_bounds(Variable, Pcontrainte *, Pcontrainte *, Pcontrainte *)
void constraints_for_bounds(var, pinit, plower, pupper) Variable var; Pcontrainte *pinit,...
Definition: unaires.c:176
void inegalites_fprint(FILE *, Pcontrainte, char *(*)(Variable))
#define min(a, b)
#define max(a, b)
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
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
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
list gen_copy_seq(list l)
Copy a list structure.
Definition: list.c:501
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
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
#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
statement make_assign_statement(expression, expression)
Definition: statement.c:583
statement st_make_nice_test(expression, list, list)
Definition: statement.c:1585
bool expression_constant_p(expression)
HPFC module by Fabien COELHO.
Definition: expression.c:2453
int vect_size(Pvecteur v)
package vecteur - reductions
Definition: reductions.c:47
#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 UU
Definition: newgen_types.h:98
#define MAX_OPERATOR_NAME
#define PLUS_OPERATOR_NAME
#define EQUAL_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 LESS_OR_EQUAL_OPERATOR_NAME
#define make_empty_statement
An alias for make_empty_block_statement.
#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_empty_label(void)
Definition: entity.c:1105
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 entity_to_expression(entity e)
if v is a constant, returns a constant call.
Definition: expression.c:165
expression MakeBinaryCall(entity f, expression eg, expression ed)
Creates a call expression to a function with 2 arguments.
Definition: expression.c:354
expression expression_list_to_conjonction(list l)
Definition: expression.c:1937
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 ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define entity_undefined_p(x)
Definition: ri.h:2762
#define expression_undefined
Definition: ri.h:1223
@ is_instruction_loop
Definition: ri.h:1471
#define entity_name(x)
Definition: ri.h:2790
@ is_execution_sequential
Definition: ri.h:1189
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
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
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
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
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
Psysteme sc_dup(Psysteme ps)
Psysteme sc_dup(Psysteme ps): should becomes a link.
Definition: sc_alloc.c:176
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
void sc_transform_eg_in_ineg(Psysteme sc)
Package sc.
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
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
#define ifdebug(n)
Definition: sg.c:47
t_real sum(int n1, int n2, int n3, t_real u[n1][n2][n3])
Definition: stencil.c:57
GENERIC_LOCAL_FUNCTION(directives, step_directives)
Copyright 2007, 2008, 2009 Alain Muller, Frederique Silber-Chaussumier.
static size_t current
Definition: string.c:115
Pvecteur vecteur
struct Scontrainte * succ
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
struct Svecteur * succ
Definition: vecteur-local.h:92
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
static bool range_of_variable(Variable var, Value *lb, Value *ub)
this functions returns bounds for variable var if both are available.
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)
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.
void set_information_for_code_optimizations(Psysteme s)
I could keep the system for further optimizations...
statement generate_optional_if(Psysteme sc, statement stat)
statement generate_optional_if(sc, stat)
expression constraints_to_loop_bound(Pcontrainte c, Variable var, bool is_lower, entity divide)
expression constraints_to_loop_bound(c, var, is_lower)
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...
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 ...
static void store_a_lower(entity var, int val)
static void store_an_upper(entity var, int val)
list Pcontrainte_to_expression_list(Pcontrainte constraint, entity operator)
expression Psysteme_to_expression(Psysteme systeme)
Standard includes.
void reset_information_for_code_optimizations()
#define exp
Avoid some warnings from "gcc -Wshadow".
Definition: vasnprintf.c:207
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
#define val_of(varval)
#define VECTEUR_NUL
DEFINITION DU VECTEUR NUL.
char *(* get_variable_name_t)(Variable)
Definition: vecteur-local.h:62
#define VECTEUR_NUL_P(v)
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
#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_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
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
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
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 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
Pvecteur vect_sort(Pvecteur v, int *compare)
Pvecteur vect_sort(v, compare) Pvecteur v; int (*compare)();.
Definition: unaires.c:335
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