PIPS
bounds.c
Go to the documentation of this file.
1 /*
2 
3  $Id: bounds.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 /* Name : bounds.c
29  * Package : reindexing
30  * Author : Alexis Platonoff
31  * Date : March 1995
32  * Historic :
33  *
34  * Documents: SOON
35  * Comments : This file contains the functions dealing with the bounds of
36  * the variables and the loops.
37  */
38 
39 /* Ansi includes */
40 #include <stdio.h>
41 
42 /* Newgen includes */
43 #include "genC.h"
44 
45 /* C3 includes */
46 #include "boolean.h"
47 #include "arithmetique.h"
48 #include "vecteur.h"
49 #include "contrainte.h"
50 #include "ray_dte.h"
51 #include "sommet.h"
52 #include "sg.h"
53 #include "sc.h"
54 #include "polyedre.h"
55 #include "matrice.h"
56 #include"union.h"
57 #include "matrix.h"
58 #include "sparse_sc.h"
59 
60 /* Pips includes */
61 #include "boolean.h"
62 #include "ri.h"
63 #include "constants.h"
64 #include "ri-util.h"
65 #include "misc.h"
66 #include "complexity_ri.h"
67 #include "database.h"
68 #include "graph.h"
69 #include "dg.h"
70 #include "paf_ri.h"
71 #include "parser_private.h"
72 #include "property.h"
73 #include "reduction.h"
74 #include "text.h"
75 #include "text-util.h"
76 #include "tiling.h"
77 #include "text-util.h"
78 #include "pipsdbm.h"
79 #include "resources.h"
80 #include "static_controlize.h"
81 #include "paf-util.h"
82 #include "pip.h"
83 #include "array_dfg.h"
84 #include "prgm_mapping.h"
85 #include "conversion.h"
86 #include "scheduling.h"
87 #include "reindexing.h"
88 
89 /*====================================================================*/
90 /* void set_array_declaration(entity var_to_decl, list lrange)
91  *
92  * Set the dimensions of entity "var_to_decl" with the ranges of
93  * "lrange". */
94 
95 void set_array_declaration(var_to_decl, lrange)
96 entity var_to_decl;
97 list lrange;
98 {
99  list lr, ldims;
100  variable var;
101 
102  var = type_variable(entity_type(var_to_decl));
103  ldims = NIL;
104 
105  for(lr = lrange; !ENDP(lr); POP(lr)) {
106  expression lb, ub, st;
107  range ra = RANGE(CAR(lr));
108 
109  lb = range_lower(ra);
110  ub = range_upper(ra);
111  st = range_increment(ra);
112 
113  if(!expression_equal_integer_p(st, 1))
114  user_error("set_array_declaration", "\n Increment diff de 1\n");
115 
116  ldims = gen_nconc(ldims, CONS(DIMENSION, make_dimension(lb, ub, NIL),
117  NIL));
118  }
119  variable_dimensions(var) = ldims;
120 }
121 
122 
123 #define IS_LOWER 0
124 #define IS_UPPER 1
125 
126 /*====================================================================*/
127 /*
128  * expression constraint_to_bound(Pcontrainte pc, entity ent, list lvar,
129  * list lrange, int lower_or_upper,
130  * int array_or_loop)
131  *
132  * Build a bound of the variable "ent" (named "e" in the following) from a
133  * constraint "pc".
134  *
135  * This constraint may contains other variables from the list "lvar" which
136  * have to be eliminated if we are in the case of ARRAY BOUNDS
137  * ("array_or_loop") using their bounds (in "lrange"). See make_bounds(),
138  * below.
139  *
140  * The nature (lower or upper) of the bound to compute is given by
141  * "lower_or_upper" (lower: 0, upper: 1).
142  *
143  * For example, let us compute the lower bound of e with the constraint
144  * (e-i+n-2 <= 0), knowing that (1 <= i <= MAX(n,m)). The elimination of i
145  * is done by replacing it by n. We obtain the following lower bound : e
146  * <= 2
147  *
148  * If the bound of a variable that have to be substitute is expressed via
149  * a MIN or MAX function, we have to make a bound that will have as many
150  * expressions as there are arguments in this MIN or MAX function. This
151  * variable is then successively replaced by each of these arguments.
152  *
153  * */
154 expression constraint_to_bound(pc, ent, lvar, lrange, lower_or_upper,
155  array_or_loop)
156 Pcontrainte pc;
157 entity ent;
158 list lvar, lrange;
159 int lower_or_upper, array_or_loop;
160 {
162  Pvecteur vect;
163  Value val;
164  list llv, llr;
166 
167  vect = vect_dup(pc->vecteur);
168 
169  /* "val" corresponds to the absolute value of the coefficient of "e" in
170  * the constraint. */
171  val = vect_coeff((Variable) ent, vect);
172  value_absolute(val);
173 
174  /* "vect" represents the term of the constraints that does not contains
175  * "e". We have : (e+vect <= 0) or (-e+vect <= 0), whether it is a lower
176  * or upper bound. */
177  vect = vect_del_var(vect, (Variable) ent);
178 
179  /* In the case of the upper bound, we have to change the sign of "vect"
180  * in order to have a positive coefficient for "e". */
181  if(lower_or_upper == IS_UPPER)
182  vect_chg_sgn(vect);
183 
184  /* We build this Pcontrainte which will be used as a list of
185  * Pvecteur. */
186  lvect = contrainte_make(vect);
187 
188  if (get_debug_level() > 6) {
189  fprintf(stderr, "\nlvect :");
191  fprintf(stderr, "\n");
192  }
193 
194  /* In the case of ARRAY BOUNDS, we substitute in "vect" all the var of
195  * "lvar" that have a non zero coeff by their min or max value, which is
196  * given by "lrange". */
197  if(array_or_loop == IS_ARRAY_BOUNDS) {
198  for(llv = lvar, llr = lrange; (!ENDP(llv)) && (!ENDP(llr));
199  POP(llv), POP(llr)) {
200  entity var = ENTITY(CAR(llv));
201  range cr = RANGE(CAR(llr));
202  Value coeff;
203 
204  if(value_notzero_p(coeff = vect_coeff((Variable) var, vect))) {
205  Pvecteur new_vect;
206  expression cexp;
207  normalized new_nor;
208  int sign = value_sign(coeff);
209 
210  /* We replace the current var by whether its lower or upper bound,
211  * it depends on the sign of its coefficient. It also depends on the
212  * kind of bound we have to build. */
213  if(lower_or_upper == IS_LOWER) {
214  if(sign ==1)
215  cexp = range_lower(cr);
216  else
217  cexp = range_upper(cr);
218  }
219  else /* lower_or_upper == IS_UPPER */ {
220  if(sign==-1)
221  cexp = range_lower(cr);
222  else
223  cexp = range_upper(cr);
224  }
225 
226  if (get_debug_level() > 6) {
227  fprintf(stderr, "Subs of %s by %s\n",
228  entity_local_name(var),
229  expression_to_string(cexp));
230  }
231 
232  /* This expression by which we replace the current var can be of two
233  * forms. The first, a single linear expression, is just
234  * substitute. The second, a MAX or MIN expression has to be switch
235  * in as many expressions as there are linear expressions in this
236  * expression.
237  * */
238  new_nor = NORMALIZE_EXPRESSION(cexp);
239  if(normalized_tag(new_nor) == is_normalized_linear) {
240 
241  if (get_debug_level() > 6) {
242  fprintf(stderr, "SINGLE expression\n");
243  }
244 
245  /* We apply the substitution on all the vectors of our list. */
246  new_vect = (Pvecteur) normalized_linear(new_nor);
247  for(pc = lvect; pc != NULL; pc = pc->succ) {
248  pc->vecteur = vect_var_subst(pc->vecteur, (Variable) var,
249  vect_dup(new_vect));
250  }
251 
252  }
253  else {
254  if(min_or_max_expression_p(cexp)) {
255  list args, la;
256 
258 
259  if (get_debug_level() > 6) {
260  fprintf(stderr, "MAX or MIN expression of %d args\n",
261  gen_length(args));
262  }
263 
264  /* For each vector of our list, we duplicate it in order to take
265  * into account all the arguments of this MIN or MAX
266  * function. */
267  for(pc = lvect; pc != NULL; pc = pc->succ) {
268  Pvecteur pcv = pc->vecteur;
269  Pcontrainte pcsucc = pc->succ;
270 
271  if (get_debug_level() > 6) {
272  fprintf(stderr, "Subs in:\n");
273  pu_vect_fprint(stderr, pcv);
274  }
275 
276  /* We walk through all these arguments. */
277  for(la = args; !ENDP(la); POP(la)) {
278  expression arg = EXPRESSION(CAR(la));
279  new_nor = NORMALIZE_EXPRESSION(arg);
280  new_vect = (Pvecteur) normalized_linear(new_nor);
281 
282  /* This "arg" is not the last one, so we duplicate our
283  * vector before substituting. */
284  pcv = pc->vecteur;
285  if(CDR(la) != NIL) {
287  pc->succ = npc;
288  npc->succ = pcsucc;
289  }
290  pc->vecteur = vect_var_subst(pcv, (Variable) var,
291  vect_dup(new_vect));
292 
293  if (get_debug_level() > 6) {
294  Psysteme aux_ps = sc_make(lvect, NULL);
295 
296  fprintf(stderr, "Subs with %s gives:\n",
297  expression_to_string(arg));
298  pu_vect_fprint(stderr, pc->vecteur);
299 
300  fprintf(stderr, "\tlvect : \n");
301  fprint_psysteme(stderr, aux_ps);
302  fprintf(stderr, "\n");
303  }
304 
305  /* This is not the last argument, so the successor is our
306  * current vector which has been just duplicated. */
307  if(CDR(la) != NIL)
308  pc = pc->succ;
309  }
310  }
311  }
312  else
313  user_error("constraint_to_bound",
314  "\nWe want a linear bound\n");
315  }
316  }
317  }
318  }
319 
320  /* We now build the expression that represent the bound of our variable
321  * "e". This expression is a single linear one if "lvect" contains only
322  * one vector, otherwise, it is a MIN or MAX expression, depending on
323  * whether it is a lower or upper bound. */
324  if(lvect->succ == NULL)
325  bound = make_rational_exp(lvect->vecteur, val);
326  else {
327  call ca;
328  list args = NIL;
329 
330  for(pc = lvect; pc != NULL; pc = pc->succ)
332  make_rational_exp(pc->vecteur, val));
333  if(lower_or_upper == IS_LOWER)
334  ca = make_call(entity_intrinsic("MIN"), args);
335  else /* lower_or_upper == IS_UPPER */
336  ca = make_call(entity_intrinsic("MAX"), args);
339  }
340  return(bound);
341 }
342 
343 /*====================================================================*/
344 /*
345  * expression bound_compute(Psysteme sc, entity ent, list lvar,
346  * list lrange, int lower_or_upper
347  * int array_or_loop)
348  *
349  * Computes the lower or upper bound of a given variable "ent" from a
350  * system of constraints "sc". Each constraint should contains a reference
351  * to this variable and is treated separatly with constraint_to_bound(),
352  * see above.
353  *
354  */
355 
356 expression bound_compute(sc, ent, lvar, lrange, lower_or_upper, array_or_loop)
357 Psysteme sc;
358 entity ent;
359 list lvar, lrange;
360 int lower_or_upper, array_or_loop;
361 {
363  Pcontrainte inequ;
364 
365  if (get_debug_level() > 6) {
366  if(lower_or_upper == IS_LOWER)
367  fprintf(stderr, "\nIN LOWER\n");
368  else
369  fprintf(stderr, "\nIN UPPER\n");
370  }
371 
372  if(SC_UNDEFINED_P(sc))
373  user_error("bound_compute", "Undefined systeme\n");
374 
375  for(inequ = sc->inegalites; inequ != NULL; inequ = inequ->succ) {
376  if(bound == expression_undefined)
377  bound = constraint_to_bound(inequ, ent, lvar, lrange,
378  lower_or_upper, array_or_loop);
379  else {
380  int min_or_max;
381  if(lower_or_upper == IS_LOWER)
382  min_or_max = IS_MAX;
383  else
384  min_or_max = IS_MIN;
385  bound = merge_expressions(bound,
386  constraint_to_bound(inequ, ent, lvar,
387  lrange,
388  lower_or_upper,
389  array_or_loop),
390  min_or_max);
391  }
392  }
393 
394  return(bound);
395 }
396 
397 
398 /*======================================================================*/
399 /* range make_bounds(ps, ent, array_or_loop, list lvar, list lrange)
400  *
401  * Builds the bounds of variable "ent" from the psysteme
402  * "ps". "array_or_loop" gives which kind of bounds we want:
403  * IS_LOOP_BOUNDS or IS_ARRAY_BOUNDS. For the first, these bounds will be
404  * used in a loop, so we just have to get the constraints of "ps" and use
405  * them to build these bounds (in the bounds of a given loop may appear
406  * other loop indices from englobing loops). On the contrary, for the
407  * second, these bounds will be used in an array dimension declaration, so
408  * we first have to eliminate the other variables (in "lvar") using their
409  * bounds (in "lrange") before building these bounds.
410  *
411  * AP 95/01/20 */
412 
413 range make_bounds(ps, ent, array_or_loop, lvar, lrange)
414 Psysteme ps;
415 entity ent;
416 int array_or_loop;
417 list lvar, lrange;
418 {
419  Pcontrainte cont;
420  expression upper, lower, incr;
421  Psysteme sc_upper = sc_new(), sc_lower = sc_new();
422  list llr;
423 
424  if (get_debug_level() > 5) {
425  fprintf(stderr,"\nBEGIN make_bounds : %s", entity_local_name(ent));
426  fprintf(stderr,"\n\tKind : %d", array_or_loop);
427  fprint_psysteme(stderr, ps);
428  fprintf(stderr, "List of vars : ");
429  fprint_entity_list(stderr, lvar);
430  fprintf(stderr, "\nList of ranges :\n");
431  for(llr = lrange; !ENDP(llr); POP(llr)) {
432  fprintf(stderr, "\t%s\n",
434  }
435  }
436 
437  if (SC_UNDEFINED_P(ps))
438  user_error("make_bounds", "\nUndefined system\n");
439 
440  /* the psysteme should have two constraints, one for the lb and the
441  * other for the ub, but we don't know which one is what. In fact, it
442  * may have more constraints, in which case the lower or/and upper
443  * bounds are expressed by MIN or MAX functions. */
444  cont = ps->inegalites;
445  while (cont != NULL) {
446  if (value_posz_p(vect_coeff((Variable) ent, cont->vecteur)))
447  { sc_add_inegalite(sc_upper, contrainte_dup(cont)); }
448  else
449  { sc_add_inegalite(sc_lower, contrainte_dup(cont)); }
450  cont = cont->succ;
451  }
452 
453  if (get_debug_level() > 6) {
454  fprintf(stderr, "\n LOWER ps\n");
455  fprint_psysteme(stderr, sc_lower);
456  fprintf(stderr, "\n UPPER ps\n");
457  fprint_psysteme(stderr, sc_upper);
458  }
459 
460  /* We compute these lower and upper bounds. */
461  lower = bound_compute(sc_lower, ent, lvar, lrange, IS_LOWER,
462  array_or_loop);
463  upper = bound_compute(sc_upper, ent, lvar, lrange, IS_UPPER,
464  array_or_loop);
465 
466  ifdebug(7) {
467  fprintf(stderr, "\nEND make_bounds : %s\n", entity_local_name(ent));
468  fprintf(stderr, " Lower bound : %s\n",
469  expression_to_string(lower));
470  fprintf(stderr, " Upper bound : %s\n\n",
471  expression_to_string(upper));
472  }
473 
474  incr = int_to_expression(1);
475 
476  return(make_range(lower, upper, incr));
477 }
478 
479 
480 /*======================================================================*/
481 /* void get_bounds_expression(sys, lt, lb, ub)
482  *
483  * From the list of Psysteme psys, we determine the value of each lower
484  * and upper bound of the local time.
485  *
486  * Lower bounds are in the inequalities of "sys" ; upper bounds are in the
487  * equalities.
488  *
489  * AC 94/06/13
490  *
491  * Lower and upper bounds are now in the inequalities. So, first, we have
492  * to sort these ineq in two groups, one for the lower bound and one for
493  * the upper bound.
494  *
495  * AP 95/01/30 */
496 
497 void get_bounds_expression(sys, lt, lb, ub)
498 
499  Psyslist sys;
500  list lt, *lb, *ub;
501 {
502  Psyslist p = sys;
503  Psysteme sc, sc_lower = sc_new(), sc_upper = sc_new();
504  Pcontrainte cont;
505  Pvecteur vect;
507  Value val;
508  list l = lt;
509  entity ent;
510 
511  for (l = lt; l != NIL; l = l->cdr)
512  {
513  sc = p->psys;
514  ent = ENTITY(CAR(l));
515 
516  if (get_debug_level() > 6) {
517  fprintf(stderr,"\nSysteme :");
518  fprint_psysteme(stderr, sc);
519  }
520 
521  /* Sort the inequalities */
522  cont = sc->inegalites;
523  while (cont != NULL) {
524  if (value_posz_p(vect_coeff((Variable) ent, cont->vecteur)))
525  { sc_add_inegalite(sc_upper, contrainte_dup(cont)); }
526  else
527  { sc_add_inegalite(sc_lower, contrainte_dup(cont)); }
528  cont = cont->succ;
529  }
530 
531  if (sc_lower->nb_ineq == 1)
532  /* Only one lower bound */
533  {
534  vect = vect_dup((sc_lower->inegalites)->vecteur);
535  val = vect_coeff((Variable) ent, vect);
536  value_absolute(val);
537  vect = vect_del_var(vect, (Variable) ent);
538  lower = make_rational_exp(vect, val);
539  }
540  else if (sc_lower->nb_ineq > 1) {
541  /* More than one lower bound, build a max */
542  list llower = NIL;
543  for (cont = sc_lower->inegalites; cont != NULL; cont = cont->succ) {
544  vect = vect_dup(cont->vecteur);
545  val = vect_coeff((Variable) ent, vect);
546  value_absolute(val);
547  vect = vect_del_var(vect, (Variable) ent);
548  llower = CONS(EXPRESSION, make_rational_exp(vect, val),
549  llower);
550  }
553  llower)),
555  }
556  else
557  user_error("get_bounds_expression", "\n No lower bound\n");
558 
559  if (sc_upper->nb_ineq == 1) {
560  /* Only one upper bound */
561  vect = vect_dup((sc_upper->inegalites)->vecteur);
562  val = vect_coeff((Variable) ent, vect);
563  value_absolute(val);
564  vect = vect_del_var(vect, (Variable) ent);
565  vect_chg_sgn(vect);
566  upper = make_rational_exp(vect, val);
567  }
568  else if(sc_upper->nb_ineq > 1) {
569  /* More than one upper bound, build a min */
570  list lupper = NIL;
571  for (cont = sc_upper->inegalites; cont != NULL; cont = cont->succ) {
572  vect = vect_dup(cont->vecteur);
573  val = vect_coeff((Variable) ent, vect);
574  value_absolute(val);
575  vect = vect_del_var(vect, (Variable) ent);
576  vect_chg_sgn(vect);
577  lupper = CONS(EXPRESSION,
578  make_rational_exp(vect, val), lupper);
579  }
582  lupper)),
584  }
585  else
586  {
587  user_error("get_bounds_expression", "\n No upper bound\n");
588  }
589  ADD_ELEMENT_TO_LIST((*lb), EXPRESSION, lower);
590  ADD_ELEMENT_TO_LIST((*ub), EXPRESSION, upper);
591 
592  ifdebug(7) {
593  fprintf(stderr,
594  "\nNew lb and ub expressions :\n\tLB: %s\n\tUB: %s\n",
595  expression_to_string(lower),
596  expression_to_string(upper));
597  }
598 
599  }
600 }
601 
602 
603 /*=========================================================================*/
604 /* Psyslist separate_variables(ps, l)
605  *
606  * We have a psystem ps containing all variables in l, and we want to have
607  * a list of psystem where each system is containing the variable of its
608  * rank.
609  *
610  * Ex: variable t1, t2, p1.
611  * => we will have 3 systems, ps1, ps2, ps3.
612  * ps1 = f(n, t1) (n structure parameters);
613  * ps2 = f(t1, n, t2);
614  * ps3 = f(p1, t1, t2);
615  *
616  * We also separate the bounds and put the constraints on the upper bound
617  * in the equalities and the constraints on the lower bound in the
618  * inequalities.
619  *
620  * AC 94/04/05 */
621 
623 Psysteme ps, *sp;
624 list l;
625 int c;
626 {
627  list lp, lr = gen_nreverse(l);
628  Psyslist lsys = NULL, lsys_aux;
629  entity ent;
630  Pcontrainte cont;
631  int i;
632  Psysteme ps_aux;
633 
634  (*sp) = SC_UNDEFINED;
635 
636  if(l != NIL) {
637  for (lp = lr; lp != NIL; lp = lp->cdr) {
638  Psysteme cps = sc_new();
639  ent = ENTITY(CAR(lp));
640  for (cont = ps->inegalites; cont != NULL; cont = cont->succ) {
641  if (base_contains_variable_p(cont->vecteur, (Variable) ent)) {
642  if (value_neg_p(vect_coeff((Variable) ent, cont->vecteur)))
643  { sc_add_inegalite(cps, contrainte_dup(cont)); }
644  else
645  { sc_add_egalite(cps, contrainte_dup(cont)); }
646  cont->vecteur = VECTEUR_NUL;
647  }
648  }
649  for (cont = ps->egalites; cont != NULL; cont = cont->succ) {
650  Pvecteur pv = cont->vecteur;
651  if (base_contains_variable_p(pv, (Variable) ent)) {
652  if (value_neg_p(vect_coeff((Variable) ent, pv))) {
654  vect_chg_sgn(pv);
656  }
657  else {
659  vect_chg_sgn(pv);
661  }
662  cont->vecteur = VECTEUR_NUL;
663  }
664  }
665  sc_normalize(cps);
666  lsys = add_sc_to_sclist(cps, lsys);
667  }
668 
669  if (get_debug_level() > 5) {
670  fprintf(stderr,"\nListe de psystemes construite :");
671  sl_fprint(stderr,lsys,entity_local_name);
672  }
673 
674  lsys_aux = lsys;
675  for (i = 1; i <= c; i++) {
676  lsys_aux = lsys_aux->succ;
677  }
678 
679  for (; lsys_aux != NULL; lsys_aux = lsys_aux->succ) {
680  ps_aux = lsys_aux->psys;
681 
682  /* add inequalities on the max */
683  while (ps_aux->egalites != NULL) {
684  cont = ps_aux->egalites;
685  ps_aux->egalites = (ps_aux->egalites)->succ;
686  cont->succ = NULL;
687  sc_add_inegalite(ps_aux, cont);
688  }
689  (*sp) = sc_append(*sp, sc_dup(ps_aux));
690  }
691  }
692 
693  return(lsys);
694 }
695 
696 /*=========================================================================*/
697 /* Psyslist separate_variables_2(ps, l): we have a psystem ps containing all
698  * variables in l, and we want to have a list of psystem where each system
699  * is containing the variable of its rank.
700  * Ex: variable t1, t2, p1.
701  * => we will have 3 systems, ps1, ps2, ps3.
702  * ps1 = f(n, t1) (n structure parameters);
703  * ps2 = f(t1, n, t2);
704  * ps3 = f(p1, t1, t2);
705  *
706  * same function as above but we do not distinguish the min from the max.
707  *
708  * AC 94/04/05
709  */
710 
712 
713  Psysteme ps, *sp;
714  list l;
715  int c;
716 {
717  list lp, lr = gen_nreverse(l);
718  Psyslist lsys = NULL, lsys_aux, lsys_aux2;
719  entity ent;
720  Pcontrainte cont;
721  int i;
722  Psysteme ps_aux;
723 
724  (*sp) = SC_UNDEFINED;
725 
726  for (lp = lr; lp != NIL; lp = lp->cdr)
727  {
728  Psysteme cps = sc_new();
729  ent = ENTITY(CAR(lp));
730  for (cont = ps->inegalites; cont != NULL; cont = cont->succ)
731  {
732  if (base_contains_variable_p(cont->vecteur, (Variable) ent))
733  {
734  sc_add_inegalite(cps, contrainte_dup(cont));
735  cont->vecteur = VECTEUR_NUL;
736  }
737  }
738  sc_normalize(cps);
739  lsys = add_sc_to_sclist(cps, lsys);
740  }
741 
742  if (get_debug_level() > 5)
743  {
744  fprintf(stderr,"\nListe de psystemes construite 2:");
745  sl_fprint(stderr,lsys,entity_local_name);
746  }
747 
748  if (c == 1)
749  {
750  lsys_aux = lsys->succ;
751 
752  for (; lsys_aux != NULL; lsys_aux = lsys_aux->succ)
753  {
754  ps_aux = lsys_aux->psys;
755 
756  /* add inequalities on the max */
757  while (ps_aux->egalites != NULL)
758  {
759  cont = ps_aux->egalites;
760  ps_aux->egalites = (ps_aux->egalites)->succ;
761  cont->succ = NULL;
762  sc_add_inegalite(ps_aux, cont);
763  }
764  (*sp) = sc_append(*sp, sc_dup(ps_aux));
765  }
766  }
767  else
768  {
769  lsys_aux = lsys->succ;
770  lsys_aux2 = lsys;
771  for (i = 2; i <= c; i++)
772  {
773  lsys_aux = lsys_aux->succ;
774  lsys_aux2 = lsys_aux2->succ;
775  }
776 
777  for (; lsys_aux != NULL; lsys_aux = lsys_aux->succ)
778  {
779  ps_aux = lsys_aux->psys;
780  /* add inequalities on the max */
781  while (ps_aux->egalites != NULL)
782  {
783  cont = ps_aux->egalites;
784  ps_aux->egalites = (ps_aux->egalites)->succ;
785  cont->succ = NULL;
786  sc_add_inegalite(ps_aux, cont);
787  }
788  (*sp) = sc_append(*sp, sc_dup(ps_aux));
789  }
790  }
791 
792  if (get_debug_level() > 5)
793  {
794  fprintf(stderr,"\nListe de psystemes construite en final 2:");
795  sl_fprint(stderr,lsys,entity_local_name);
796  }
797 
798  return(reverse_psyslist(lsys));
799 }
call make_call(entity a1, list a2)
Definition: ri.c:269
expression make_expression(syntax a1, normalized a2)
Definition: ri.c:886
dimension make_dimension(expression a1, expression a2, list a3)
Definition: ri.c:565
syntax make_syntax(enum syntax_utype tag, void *val)
Definition: ri.c:2491
range make_range(expression a1, expression a2, expression a3)
Definition: ri.c:2041
#define value_sign(v)
trian operators on values
#define value_absolute(ref)
#define value_notzero_p(val)
int Value
#define value_neg_p(val)
#define value_posz_p(val)
bool base_contains_variable_p(Pbase b, Variable v)
bool base_contains_variable_p(Pbase b, Variable v): returns true if variable v is one of b's elements...
Definition: base.c:136
#define IS_LOWER
Definition: bounds.c:123
range make_bounds(Psysteme ps, entity ent, int array_or_loop, list lvar, list lrange)
=====================================================================
Definition: bounds.c:413
void set_array_declaration(entity var_to_decl, list lrange)
Name : bounds.c Package : reindexing Author : Alexis Platonoff Date : March 1995 Historic :
Definition: bounds.c:95
void get_bounds_expression(Psyslist sys, list lt, list *lb, list *ub)
=====================================================================
Definition: bounds.c:497
#define IS_UPPER
Definition: bounds.c:124
expression constraint_to_bound(Pcontrainte pc, entity ent, list lvar, list lrange, int lower_or_upper, int array_or_loop)
===================================================================
Definition: bounds.c:154
Psyslist separate_variables(Psysteme ps, list l, Psysteme *sp, int c)
========================================================================
Definition: bounds.c:622
Psyslist separate_variables_2(Psysteme ps, list l, Psysteme *sp, int c)
========================================================================
Definition: bounds.c:711
expression bound_compute(Psysteme sc, entity ent, list lvar, list lrange, int lower_or_upper, int array_or_loop)
===================================================================
Definition: bounds.c:356
Pcontrainte contrainte_make(Pvecteur pv)
Pcontrainte contrainte_make(Pvecteur pv): allocation et initialisation d'une contrainte avec un vecte...
Definition: alloc.c:73
Pcontrainte contrainte_dup(Pcontrainte c_in)
Pcontrainte contrainte_dup(Pcontrainte c_in): allocation d'une contrainte c_out prenant la valeur de ...
Definition: alloc.c:132
#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 POP(l)
Modify a list pointer to point on the next element of the list.
Definition: newgen_list.h:59
#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
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
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
void fprint_entity_list(FILE *fp, list l)
void fprint_entity_list(FILE *fp,list l): prints a list of entities on file fp.
Definition: entity.c:3188
#define ADD_ELEMENT_TO_LIST(_list, _type, _element)
Definition: icfg-local.h:50
Psyslist add_sc_to_sclist(Psysteme sc, Psyslist lsys)
=================================================================
Definition: makebdt.c:1985
#define user_error(fn,...)
Definition: misc-local.h:265
int get_debug_level(void)
GET_DEBUG_LEVEL returns the current debugging level.
Definition: debug.c:67
#define IS_MIN
#define IS_MAX
const char * pu_variable_name(Variable)
package mapping : Alexis Platonoff, april 1993
Definition: print.c:421
void vecteur_fprint(FILE *, Pcontrainte, const char *(*)(entity))
void pu_vect_fprint(FILE *, Pvecteur)
===========================================================================
Definition: print.c:446
expression make_rational_exp(Pvecteur, Value)
=====================================================================
Definition: utils.c:2446
void fprint_psysteme(FILE *, Psysteme)
===========================================================================
Definition: print.c:302
Pvecteur vect_var_subst(Pvecteur, Variable, Pvecteur)
=================================================================
Definition: utils.c:1948
string expression_to_string(expression e)
Definition: expression.c:77
list words_range(range obj, list *ppdl)
Definition: misc.c:538
#define IS_ARRAY_BOUNDS
Psyslist reverse_psyslist(Psyslist l)
======================================================================
bool min_or_max_expression_p(expression exp)
===================================================================
expression merge_expressions(expression exp1, expression exp2, int max_or_min)
===================================================================
#define NORMALIZE_EXPRESSION(e)
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 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
bool expression_equal_integer_p(expression exp, int i)
================================================================
Definition: expression.c:1977
#define normalized_undefined
Definition: ri.h:1745
#define range_upper(x)
Definition: ri.h:2290
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define type_variable(x)
Definition: ri.h:2949
@ is_syntax_call
Definition: ri.h:2693
#define range_increment(x)
Definition: ri.h:2292
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define expression_undefined
Definition: ri.h:1223
#define RANGE(x)
RANGE.
Definition: ri.h:2257
#define normalized_tag(x)
Definition: ri.h:1778
#define syntax_call(x)
Definition: ri.h:2736
#define range_lower(x)
Definition: ri.h:2288
#define variable_dimensions(x)
Definition: ri.h:3122
#define call_arguments(x)
Definition: ri.h:711
#define entity_type(x)
Definition: ri.h:2792
#define normalized_linear(x)
Definition: ri.h:1781
#define expression_syntax(x)
Definition: ri.h:1247
@ is_normalized_linear
Definition: ri.h:1760
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_add_egalite(Psysteme p, Pcontrainte e)
void sc_add_egalite(Psysteme p, Pcontrainte e): macro ajoutant une egalite e a un systeme p; la base ...
Definition: sc_alloc.c:389
Psysteme sc_new(void)
Psysteme sc_new(): alloue un systeme vide, initialise tous les champs avec des valeurs nulles,...
Definition: sc_alloc.c:55
void sc_add_inegalite(Psysteme p, Pcontrainte i)
void sc_add_inegalite(Psysteme p, Pcontrainte i): macro ajoutant une inegalite i a un systeme p; la b...
Definition: sc_alloc.c:406
Psysteme sc_dup(Psysteme ps)
Psysteme sc_dup(Psysteme ps): should becomes a link.
Definition: sc_alloc.c:176
Psysteme sc_append(Psysteme s1, Psysteme s2)
Psysteme sc_append(Psysteme s1, Psysteme s2): calcul de l'intersection des polyedres definis par s1 e...
void sl_fprint(in_fi, in_sl, char *(*in_fu)())
Definition: sc_list.c:447
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
Psysteme sc_normalize(Psysteme ps)
Psysteme sc_normalize(Psysteme ps): normalisation d'un systeme d'equation et d'inequations lineaires ...
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
static list lvect
Pvecteur vecteur
struct Scontrainte * succ
Warning! Do not modify this file that is automatically generated!
Definition: union-local.h:3
Psysteme psys
Definition: union-local.h:4
struct Ssyslist * succ
Definition: union-local.h:5
Pcontrainte inegalites
Definition: sc-local.h:71
Pcontrainte egalites
Definition: sc-local.h:70
int nb_ineq
Definition: sc-local.h:73
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
struct cons * cdr
The pointer to the next element.
Definition: newgen_list.h:43
string words_to_string(cons *lw)
Definition: print.c:211
#define VECTEUR_NUL
DEFINITION DU VECTEUR NUL.
struct Svecteur * Pvecteur
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
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
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