PIPS
bounds.c File Reference
#include <stdio.h>
#include "genC.h"
#include "boolean.h"
#include "arithmetique.h"
#include "vecteur.h"
#include "contrainte.h"
#include "ray_dte.h"
#include "sommet.h"
#include "sg.h"
#include "sc.h"
#include "polyedre.h"
#include "matrice.h"
#include "union.h"
#include "matrix.h"
#include "sparse_sc.h"
#include "ri.h"
#include "constants.h"
#include "ri-util.h"
#include "misc.h"
#include "complexity_ri.h"
#include "database.h"
#include "graph.h"
#include "dg.h"
#include "paf_ri.h"
#include "parser_private.h"
#include "property.h"
#include "reduction.h"
#include "text.h"
#include "text-util.h"
#include "tiling.h"
#include "pipsdbm.h"
#include "resources.h"
#include "static_controlize.h"
#include "paf-util.h"
#include "pip.h"
#include "array_dfg.h"
#include "prgm_mapping.h"
#include "conversion.h"
#include "scheduling.h"
#include "reindexing.h"
+ Include dependency graph for bounds.c:

Go to the source code of this file.

Macros

#define IS_LOWER   0
 
#define IS_UPPER   1
 

Functions

void set_array_declaration (entity var_to_decl, list lrange)
 Name : bounds.c Package : reindexing Author : Alexis Platonoff Date : March 1995 Historic : More...
 
expression constraint_to_bound (Pcontrainte pc, entity ent, list lvar, list lrange, int lower_or_upper, int array_or_loop)
 =================================================================== More...
 
expression bound_compute (Psysteme sc, entity ent, list lvar, list lrange, int lower_or_upper, int array_or_loop)
 =================================================================== More...
 
range make_bounds (Psysteme ps, entity ent, int array_or_loop, list lvar, list lrange)
 ===================================================================== More...
 
void get_bounds_expression (Psyslist sys, list lt, list *lb, list *ub)
 ===================================================================== More...
 
Psyslist separate_variables (Psysteme ps, list l, Psysteme *sp, int c)
 ======================================================================== More...
 
Psyslist separate_variables_2 (Psysteme ps, list l, Psysteme *sp, int c)
 ======================================================================== More...
 

Macro Definition Documentation

◆ IS_LOWER

#define IS_LOWER   0

Definition at line 123 of file bounds.c.

◆ IS_UPPER

#define IS_UPPER   1

Definition at line 124 of file bounds.c.

Function Documentation

◆ bound_compute()

expression bound_compute ( Psysteme  sc,
entity  ent,
list  lvar,
list  lrange,
int  lower_or_upper,
int  array_or_loop 
)

===================================================================

Definition at line 356 of file bounds.c.

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 }
#define IS_LOWER
Definition: bounds.c:123
expression constraint_to_bound(Pcontrainte pc, entity ent, list lvar, list lrange, int lower_or_upper, int array_or_loop)
===================================================================
Definition: bounds.c:154
#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
expression merge_expressions(expression exp1, expression exp2, int max_or_min)
===================================================================
#define expression_undefined
Definition: ri.h:1223
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
struct Scontrainte * succ
Pcontrainte inegalites
Definition: sc-local.h:71

References constraint_to_bound(), expression_undefined, fprintf(), get_debug_level(), IS_LOWER, IS_MAX, IS_MIN, merge_expressions(), Scontrainte::succ, and user_error.

Referenced by make_bounds().

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

◆ constraint_to_bound()

expression constraint_to_bound ( Pcontrainte  pc,
entity  ent,
list  lvar,
list  lrange,
int  lower_or_upper,
int  array_or_loop 
)

===================================================================

"val" corresponds to the absolute value of the coefficient of "e" in the constraint.

"vect" represents the term of the constraints that does not contains "e". We have : (e+vect <= 0) or (-e+vect <= 0), whether it is a lower or upper bound.

In the case of the upper bound, we have to change the sign of "vect" in order to have a positive coefficient for "e".

We build this Pcontrainte which will be used as a list of Pvecteur.

In the case of ARRAY BOUNDS, we substitute in "vect" all the var of "lvar" that have a non zero coeff by their min or max value, which is given by "lrange".

We replace the current var by whether its lower or upper bound, it depends on the sign of its coefficient. It also depends on the kind of bound we have to build.

lower_or_upper == IS_UPPER

This expression by which we replace the current var can be of two forms. The first, a single linear expression, is just substitute. The second, a MAX or MIN expression has to be switch in as many expressions as there are linear expressions in this expression.

We apply the substitution on all the vectors of our list.

For each vector of our list, we duplicate it in order to take into account all the arguments of this MIN or MAX function.

We walk through all these arguments.

This "arg" is not the last one, so we duplicate our vector before substituting.

This is not the last argument, so the successor is our current vector which has been just duplicated.

We now build the expression that represent the bound of our variable "e". This expression is a single linear one if "lvect" contains only one vector, otherwise, it is a MIN or MAX expression, depending on whether it is a lower or upper bound.

lower_or_upper == IS_UPPER

Definition at line 154 of file bounds.c.

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 }
call make_call(entity a1, list a2)
Definition: ri.c:269
expression make_expression(syntax a1, normalized a2)
Definition: ri.c:886
syntax make_syntax(enum syntax_utype tag, void *val)
Definition: ri.c:2491
#define value_sign(v)
trian operators on values
#define value_absolute(ref)
#define value_notzero_p(val)
int Value
#define IS_UPPER
Definition: bounds.c:124
Pcontrainte contrainte_make(Pvecteur pv)
Pcontrainte contrainte_make(Pvecteur pv): allocation et initialisation d'une contrainte avec un vecte...
Definition: alloc.c:73
#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 NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
size_t gen_length(const list l)
Definition: list.c:150
#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
#define ADD_ELEMENT_TO_LIST(_list, _type, _element)
Definition: icfg-local.h:50
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
#define IS_ARRAY_BOUNDS
bool min_or_max_expression_p(expression exp)
===================================================================
#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
#define normalized_undefined
Definition: ri.h:1745
#define range_upper(x)
Definition: ri.h:2290
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
@ is_syntax_call
Definition: ri.h:2693
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#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 call_arguments(x)
Definition: ri.h:711
#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 vect_chg_sgn(Pvecteur v)
void vect_chg_sgn(Pvecteur v): multiplie v par -1
Definition: scalaires.c:151
static list lvect
Pvecteur vecteur
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 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

References ADD_ELEMENT_TO_LIST, call_arguments, CAR, CDR, contrainte_make(), ENDP, ENTITY, entity_intrinsic(), entity_local_name(), EXPRESSION, expression_syntax, expression_to_string(), expression_undefined, fprint_psysteme(), fprintf(), gen_length(), get_debug_level(), IS_ARRAY_BOUNDS, IS_LOWER, is_normalized_linear, is_syntax_call, IS_UPPER, lvect, make_call(), make_expression(), make_rational_exp(), make_syntax(), min_or_max_expression_p(), NIL, NORMALIZE_EXPRESSION, normalized_linear, normalized_tag, normalized_undefined, POP, pu_variable_name(), pu_vect_fprint(), RANGE, range_lower, range_upper, sc_make(), Scontrainte::succ, syntax_call, user_error, value_absolute, value_notzero_p, value_sign, vect_chg_sgn(), vect_coeff(), vect_del_var(), vect_dup(), vect_var_subst(), Scontrainte::vecteur, and vecteur_fprint().

Referenced by bound_compute().

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

◆ get_bounds_expression()

void get_bounds_expression ( Psyslist  sys,
list  lt,
list lb,
list ub 
)

=====================================================================

void get_bounds_expression(sys, lt, lb, ub)

From the list of Psysteme psys, we determine the value of each lower and upper bound of the local time.

Lower bounds are in the inequalities of "sys" ; upper bounds are in the equalities.

AC 94/06/13

Lower and upper bounds are now in the inequalities. So, first, we have to sort these ineq in two groups, one for the lower bound and one for the upper bound.

AP 95/01/30

Sort the inequalities

Only one lower bound

More than one lower bound, build a max

Only one upper bound

More than one upper bound, build a min

Definition at line 497 of file bounds.c.

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 }
#define value_posz_p(val)
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 CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
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
#define ifdebug(n)
Definition: sg.c:47
Warning! Do not modify this file that is automatically generated!
Definition: union-local.h:3
Psysteme psys
Definition: union-local.h:4
int nb_ineq
Definition: sc-local.h:73
struct cons * cdr
The pointer to the next element.
Definition: newgen_list.h:43

References ADD_ELEMENT_TO_LIST, CAR, cons::cdr, CONS, contrainte_dup(), ENTITY, entity_intrinsic(), EXPRESSION, expression_to_string(), expression_undefined, fprint_psysteme(), fprintf(), get_debug_level(), ifdebug, Ssysteme::inegalites, is_syntax_call, make_call(), make_expression(), make_rational_exp(), make_syntax(), Ssysteme::nb_ineq, NIL, normalized_undefined, Ssyslist::psys, sc_add_inegalite(), sc_new(), Scontrainte::succ, user_error, value_absolute, value_posz_p, vect_chg_sgn(), vect_coeff(), vect_del_var(), vect_dup(), and Scontrainte::vecteur.

Referenced by build_third_comb().

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

◆ make_bounds()

range make_bounds ( Psysteme  ps,
entity  ent,
int  array_or_loop,
list  lvar,
list  lrange 
)

=====================================================================

range make_bounds(ps, ent, array_or_loop, list lvar, list lrange)

Builds the bounds of variable "ent" from the psysteme "ps". "array_or_loop" gives which kind of bounds we want: IS_LOOP_BOUNDS or IS_ARRAY_BOUNDS. For the first, these bounds will be used in a loop, so we just have to get the constraints of "ps" and use them to build these bounds (in the bounds of a given loop may appear other loop indices from englobing loops). On the contrary, for the second, these bounds will be used in an array dimension declaration, so we first have to eliminate the other variables (in "lvar") using their bounds (in "lrange") before building these bounds.

AP 95/01/20

the psysteme should have two constraints, one for the lb and the other for the ub, but we don't know which one is what. In fact, it may have more constraints, in which case the lower or/and upper bounds are expressed by MIN or MAX functions.

We compute these lower and upper bounds.

Definition at line 413 of file bounds.c.

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 }
range make_range(expression a1, expression a2, expression a3)
Definition: ri.c:2041
expression bound_compute(Psysteme sc, entity ent, list lvar, list lrange, int lower_or_upper, int array_or_loop)
===================================================================
Definition: bounds.c:356
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
list words_range(range obj, list *ppdl)
Definition: misc.c:538
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
string words_to_string(cons *lw)
Definition: print.c:211

References bound_compute(), CAR, contrainte_dup(), ENDP, entity_local_name(), expression_to_string(), fprint_entity_list(), fprint_psysteme(), fprintf(), get_debug_level(), ifdebug, int_to_expression(), IS_LOWER, IS_UPPER, make_range(), POP, RANGE, sc_add_inegalite(), sc_new(), Scontrainte::succ, user_error, value_posz_p, vect_coeff(), Scontrainte::vecteur, words_range(), and words_to_string().

Referenced by build_first_comb(), build_third_comb(), and prepare_array_bounds().

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

◆ separate_variables()

Psyslist separate_variables ( Psysteme  ps,
list  l,
Psysteme sp,
int  c 
)

========================================================================

Psyslist separate_variables(ps, l)

We have a psystem ps containing all variables in l, and we want to have a list of psystem where each system is containing the variable of its rank.

Ex: variable t1, t2, p1. => we will have 3 systems, ps1, ps2, ps3. ps1 = f(n, t1) (n structure parameters); ps2 = f(t1, n, t2); ps3 = f(p1, t1, t2);

We also separate the bounds and put the constraints on the upper bound in the equalities and the constraints on the lower bound in the inequalities.

AC 94/04/05

add inequalities on the max

Definition at line 622 of file bounds.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 }
#define value_neg_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
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
Psyslist add_sc_to_sclist(Psysteme sc, Psyslist lsys)
=================================================================
Definition: makebdt.c:1985
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_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
Psysteme sc_normalize(Psysteme ps)
Psysteme sc_normalize(Psysteme ps): normalisation d'un systeme d'equation et d'inequations lineaires ...
struct Ssyslist * succ
Definition: union-local.h:5
Pcontrainte egalites
Definition: sc-local.h:70
#define VECTEUR_NUL
DEFINITION DU VECTEUR NUL.

References add_sc_to_sclist(), base_contains_variable_p(), CAR, cons::cdr, contrainte_dup(), contrainte_make(), Ssysteme::egalites, ENTITY, entity_local_name(), fprintf(), gen_nreverse(), get_debug_level(), NIL, sc_add_egalite(), sc_add_inegalite(), sc_append(), sc_dup(), sc_new(), sc_normalize(), sl_fprint(), Scontrainte::succ, Ssyslist::succ, value_neg_p, vect_chg_sgn(), vect_coeff(), vect_dup(), Scontrainte::vecteur, and VECTEUR_NUL.

Referenced by build_third_comb(), and prepare_reindexing().

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

◆ separate_variables_2()

Psyslist separate_variables_2 ( Psysteme  ps,
list  l,
Psysteme sp,
int  c 
)

========================================================================

Psyslist separate_variables_2(ps, l): we have a psystem ps containing all variables in l, and we want to have a list of psystem where each system is containing the variable of its rank. Ex: variable t1, t2, p1. => we will have 3 systems, ps1, ps2, ps3. ps1 = f(n, t1) (n structure parameters); ps2 = f(t1, n, t2); ps3 = f(p1, t1, t2);

same function as above but we do not distinguish the min from the max.

AC 94/04/05

add inequalities on the max

add inequalities on the max

Definition at line 711 of file bounds.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 }
Psyslist reverse_psyslist(Psyslist l)
======================================================================

References add_sc_to_sclist(), base_contains_variable_p(), CAR, cons::cdr, contrainte_dup(), Ssysteme::egalites, ENTITY, entity_local_name(), fprintf(), gen_nreverse(), get_debug_level(), NIL, reverse_psyslist(), sc_add_inegalite(), sc_append(), sc_dup(), sc_new(), sc_normalize(), sl_fprint(), Scontrainte::succ, Ssyslist::succ, Scontrainte::vecteur, and VECTEUR_NUL.

Referenced by prepare_reindexing().

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

◆ set_array_declaration()

void set_array_declaration ( entity  var_to_decl,
list  lrange 
)

Name : bounds.c Package : reindexing Author : Alexis Platonoff Date : March 1995 Historic :

Documents: SOON Comments : This file contains the functions dealing with the bounds of the variables and the loops. Ansi includes
Newgen includes
C3 includes
Pips includes
=================================================================== void set_array_declaration(entity var_to_decl, list lrange)

Set the dimensions of entity "var_to_decl" with the ranges of "lrange".

Definition at line 95 of file bounds.c.

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 }
dimension make_dimension(expression a1, expression a2, list a3)
Definition: ri.c:565
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
bool expression_equal_integer_p(expression exp, int i)
================================================================
Definition: expression.c:1977
#define type_variable(x)
Definition: ri.h:2949
#define range_increment(x)
Definition: ri.h:2292
#define variable_dimensions(x)
Definition: ri.h:3122
#define entity_type(x)
Definition: ri.h:2792

References CAR, CONS, DIMENSION, ENDP, entity_type, expression_equal_integer_p(), gen_nconc(), make_dimension(), NIL, POP, RANGE, range_increment, range_lower, range_upper, type_variable, user_error, and variable_dimensions.

Referenced by make_array_bounds().

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