PIPS
loop_iteration_domaine_to_sc.c File Reference
#include <stdio.h>
#include "linear.h"
#include "genC.h"
#include "ri.h"
#include "ri-util.h"
#include "misc.h"
#include "conversion.h"
+ Include dependency graph for loop_iteration_domaine_to_sc.c:

Go to the source code of this file.

Functions

Psysteme loop_iteration_domaine_to_sc (list lls, Pbase *baseindex)
 package conversion More...
 
void loop_index_domaine_to_contrainte (range r, entity ind, Psysteme sc)
 

Function Documentation

◆ loop_index_domaine_to_contrainte()

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

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

build - new_var <= 0

build incr * new_var - vup + vlow <= 0

build ind == vlow + incr * new_var

Parameters
indnd
scc

Definition at line 86 of file loop_iteration_domaine_to_sc.c.

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

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

Referenced by loop_iteration_domaine_to_sc().

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

◆ loop_iteration_domaine_to_sc()

Psysteme loop_iteration_domaine_to_sc ( list  lls,
Pbase baseindex 
)

package conversion

loop_iteration_domaine_to_sc.c

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

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

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

add the current index "ind" to the index basis

dd the constraints to sc

Parameters
llsls
baseindexaseindex

Definition at line 52 of file loop_iteration_domaine_to_sc.c.

54 {
55  Psysteme sc;
56 
57  debug_on("CONVERSION_DEBUG_LEVEL");
58 
59  pips_debug(8, "begin\n");
60 
61  sc = sc_new();
62  for (; lls != NIL; lls = CDR(lls)){
64  entity ind = loop_index(l);
65  range r = loop_range(l);
66 
67  /* add the current index "ind" to the index basis */
68  base_add_dimension(baseindex, (Variable) ind);
69 
70  /*add the constraints to sc*/
72  }
73  sc->nb_ineq = nb_elems_list(sc->inegalites);
74  sc_creer_base(sc);
75 
76  ifdebug(8) {
77  vect_fprint(stderr, *baseindex, (get_variable_name_t) entity_local_name);
78  }
79 
80  debug(8,"loop_iteration_domaine_to_sc", "end\n");
81 
82  debug_off();
83  return sc;
84 }
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
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#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 vect_fprint(FILE *f, Pvecteur v, get_variable_name_t variable_name)
void vect_fprint(FILE * f, Pvecteur v, char * (*variable_name)()): impression d'un vecteur creux v su...
Definition: io.c:124
void loop_index_domaine_to_contrainte(range r, entity ind, Psysteme sc)
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
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
#define instruction_loop(x)
Definition: ri.h:1520
#define statement_instruction(x)
Definition: ri.h:2458
#define loop_range(x)
Definition: ri.h:1642
#define loop_index(x)
Definition: ri.h:1640
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
void sc_creer_base(Psysteme ps)
void sc_creer_base(Psysteme ps): initialisation des parametres dimension et base d'un systeme lineair...
Definition: sc_alloc.c:129
Psysteme sc_new(void)
Psysteme sc_new(): alloue un systeme vide, initialise tous les champs avec des valeurs nulles,...
Definition: sc_alloc.c:55
#define ifdebug(n)
Definition: sg.c:47
Pcontrainte inegalites
Definition: sc-local.h:71
int nb_ineq
Definition: sc-local.h:73
char *(* get_variable_name_t)(Variable)
Definition: vecteur-local.h:62
#define base_add_dimension(b, v)

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

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

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