PIPS
complex_bound_generation.c File Reference
#include <stdio.h>
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "ri-util.h"
#include "constants.h"
#include "boolean.h"
#include "arithmetique.h"
#include "vecteur.h"
#include "misc.h"
#include "contrainte.h"
#include "sc.h"
#include "matrice.h"
#include "matrix.h"
#include "sparse_sc.h"
#include "tiling.h"
#include "movements.h"
+ Include dependency graph for complex_bound_generation.c:

Go to the source code of this file.

Functions

expression complex_bound_generation (Value coeff1, Value coeff2, Value coeff3, Pvecteur exp1, Variable __attribute__((unused)) var1, Pvecteur exp2, Variable __attribute__((unused)) var2)
 Print the complex expression [coeff1 * (exp1 / coeff2) + exp2 ] / coeff3. More...
 
expression complex_bound_computation (Psysteme __attribute__((unused)) sc, Pbase index_base, Pcontrainte ineq1, Pcontrainte ineq2, int rank)
 Compute the complex bounds associated to the variable of higher rank, after the variable "el_var" of rank "rank". More...
 

Function Documentation

◆ complex_bound_computation()

expression complex_bound_computation ( Psysteme __attribute__((unused))  sc,
Pbase  index_base,
Pcontrainte  ineq1,
Pcontrainte  ineq2,
int  rank 
)

Compute the complex bounds associated to the variable of higher rank, after the variable "el_var" of rank "rank".

variable "el_var" is eliminated from the two inequations ineq1 and ineq2. Bound expression of the higher variable belonging to ineq1 or ineq2 is then computed.

the right_exp is assigned to the inequation where the coefficient of the variable "el_var" is positive. the left_exp is assigned to the inequation where the coefficient of the variable "el_var" is negative.

computation of the bound expression of the variable of higher rank, after el_var, when this variable belongs to left_exp

??? bug? was sign

computation of the bound expression of the variable of higher rank, after el_var, when this variable belongs to right_exp

??? was sign

Definition at line 119 of file complex_bound_generation.c.

123  {
124 
125  Variable right_var,left_var;
126  Value right_coeff,left_coeff;
127  int right_rank,left_rank;
128  Value coeff_l=VALUE_ZERO, coeff_r=VALUE_ZERO;
129  Variable el_var= variable_of_rank(index_base,rank);
130  Pvecteur right_exp,left_exp;
131  expression expr;
132  Value coeff=VALUE_ZERO;
133  int sign =0;
134 
135  debug_on("MOVEMENT_DEBUG_LEVEL");
136  debug(8,"complex_bound_computation","begin\n");
137 
138  constraint_integer_combination(index_base,ineq1,ineq2,rank,
139  &right_var,&right_rank,&right_coeff,
140  &left_var,&left_rank,&left_coeff);
141 
142  /* the right_exp is assigned to the inequation where the
143  coefficient of the variable "el_var" is positive.
144  the left_exp is assigned to the inequation where the
145  coefficient of the variable "el_var" is negative.
146  */
147 
148  if (value_pos_p(coeff = vect_coeff(el_var,ineq1->vecteur))) {
149  right_exp=vect_dup(ineq1->vecteur);
150  left_exp=vect_dup(ineq2->vecteur); }
151  else {
152  if (value_pos_p(coeff = vect_coeff(el_var,ineq2->vecteur))) {
153  right_exp=vect_dup(ineq2->vecteur);
154  left_exp=vect_dup(ineq1->vecteur);
155  }
156  }
157  if (value_pos_p(coeff)) {
158  coeff_r = vect_coeff(el_var,right_exp);
159  coeff_l= vect_coeff(el_var,left_exp);
160  }
161  vect_chg_coeff(&right_exp,el_var,VALUE_ZERO);
162  vect_chg_coeff(&left_exp,el_var,VALUE_ZERO);
163 
164  if (left_rank > right_rank) {
165  /* computation of the bound expression of the variable of
166  higher rank, after el_var, when this variable
167  belongs to left_exp */
168 
169  vect_chg_coeff(&left_exp,left_var,VALUE_ZERO);
170  sign = value_sign(left_coeff);
171  if (sign==1) { /* ??? bug? was sign */
172  vect_chg_sgn(left_exp);
173  vect_chg_sgn(right_exp);
174  }
175  else
176  vect_add_elem(&left_exp,TCST,
177  value_uminus(value_plus(left_coeff,VALUE_ONE)));
179  value_uminus(coeff_l),coeff_r,
180  value_abs(left_coeff),
181  right_exp,el_var,left_exp,el_var);
182  }
183  else {
184  /* computation of the bound expression of the variable of
185  higher rank, after el_var, when this variable
186  belongs to right_exp */
187  vect_add_elem(&left_exp,TCST,
188  value_uminus(value_plus(coeff_l,VALUE_ONE)));
189  vect_chg_coeff(&right_exp,right_var,VALUE_ZERO);
190  sign = value_sign(right_coeff);
191  if (sign==1) /* ??? was sign */
192  vect_chg_sgn(right_exp);
193  else
194  vect_add_elem(&right_exp,TCST,
195  value_uminus(value_plus(right_coeff,VALUE_ONE)));
196  Value nsv = int_to_value(-sign), sv = int_to_value(sign);
198  value_mult(nsv, coeff_r),
199  value_uminus(coeff_l),
200  value_mult(sv,right_coeff),
201  left_exp,el_var,right_exp,el_var);
202  }
203 
204  debug(8,"complex_bound_computation","end\n");
205  debug_off();
206  return (expr);
207 }
#define value_pos_p(val)
#define VALUE_ZERO
#define value_sign(v)
trian operators on values
#define int_to_value(i)
end LINEAR_VALUE_IS_INT
#define value_uminus(val)
unary operators on values
int Value
#define value_plus(v1, v2)
binary operators on values
#define VALUE_ONE
#define value_abs(val)
#define value_mult(v, w)
whether the default is protected or not this define makes no sense any more...
expression complex_bound_generation(Value coeff1, Value coeff2, Value coeff3, Pvecteur exp1, Variable __attribute__((unused)) var1, Pvecteur exp2, Variable __attribute__((unused)) var2)
Print the complex expression [coeff1 * (exp1 / coeff2) + exp2 ] / coeff3.
#define debug_on(env)
Definition: misc-local.h:157
#define debug_off()
Definition: misc-local.h:160
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189
static entity rank
Variable variable_of_rank()
void constraint_integer_combination(Pbase index_base, Pcontrainte ineq1, Pcontrainte ineq2, int rank, Variable *right_var, int *right_rank, Value *right_coeff, Variable *left_var, int *left_rank, Value *left_coeff)
This function computes the coefficients of the constraint resulting from the elimination of the varia...
void vect_chg_sgn(Pvecteur v)
void vect_chg_sgn(Pvecteur v): multiplie v par -1
Definition: scalaires.c:151
Pvecteur vecteur
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
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
void vect_add_elem(Pvecteur *pvect, Variable var, Value val)
void vect_add_elem(Pvecteur * pvect, Variable var, Value val): addition d'un vecteur colineaire au ve...
Definition: unaires.c:72
Value vect_coeff(Variable var, Pvecteur vect)
Variable vect_coeff(Variable var, Pvecteur vect): coefficient de coordonnee var du vecteur vect —> So...
Definition: unaires.c:228
void vect_chg_coeff(Pvecteur *ppv, Variable var, Value val)
void vect_chg_coeff(Pvecteur *ppv, Variable var, Value val): mise de la coordonnee var du vecteur *pp...
Definition: unaires.c:143

References complex_bound_generation(), constraint_integer_combination(), debug(), debug_off, debug_on, int_to_value, rank, TCST, value_abs, value_mult, VALUE_ONE, value_plus, value_pos_p, value_sign, value_uminus, VALUE_ZERO, variable_of_rank(), vect_add_elem(), vect_chg_coeff(), vect_chg_sgn(), vect_coeff(), vect_dup(), and Scontrainte::vecteur.

Referenced by lower_bound_generation(), and upper_bound_generation().

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

◆ complex_bound_generation()

expression complex_bound_generation ( Value  coeff1,
Value  coeff2,
Value  coeff3,
Pvecteur  exp1,
Variable __attribute__((unused))  var1,
Pvecteur  exp2,
Variable __attribute__((unused))  var2 
)

Print the complex expression [coeff1 * (exp1 / coeff2) + exp2 ] / coeff3.

where exp(s) are Pvecteur(s) corresponding to parts of complex bound

Definition at line 62 of file complex_bound_generation.c.

69 {
70  expression ex1,ex2,ex4,ex5,ex6,expr,expr1,expr2;
72  entity operateur_multi = gen_find_tabulated("TOP-LEVEL:*",entity_domain);
73  entity operateur_add = gen_find_tabulated(
77  cons * lex2;
78  debug_on("MOVEMENT_DEBUG_LEVEL");
79  debug(8,"complex_bound_generation","begin\n");
80  expr1 = make_vecteur_expression(exp1);
81  expr2 = make_vecteur_expression(exp2);
82  ex1 = int_to_expression(
83  VALUE_TO_INT(value_abs(coeff1)));
84  ex2 = int_to_expression(
85  VALUE_TO_INT(value_abs(coeff2)));
86  if (value_notone_p(coeff3))
87  ex3 = int_to_expression(
88  VALUE_TO_INT(value_abs(coeff3)));
89  lex2 = CONS(EXPRESSION,ex2,NIL);
90  ex4 = make_div_expression(expr1,lex2);
91  lex2 = CONS(EXPRESSION,ex4,NIL);
92 
93  ex5 = make_op_expression(operateur_multi
94  ,CONS(EXPRESSION,ex1,lex2));
95  lex2 = CONS(EXPRESSION,expr2,NIL);
96 
97  expr = ex6 = make_op_expression(operateur_add,
98  CONS(EXPRESSION,ex5,lex2));
99  if (value_notone_p(coeff3)) {
100  lex2 = CONS(EXPRESSION,ex3,NIL);
101  expr= make_div_expression(ex6,lex2);
102  }
103 
104  debug(8,"complex_bound_generation","end\n");
105  debug_off();
106  return(expr);
107 }
#define VALUE_TO_INT(val)
#define value_notone_p(val)
string make_entity_fullname(const char *module_name, const char *local_name)
END_EOLE.
Definition: entity_names.c:230
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
expression make_div_expression(expression, cons *)
operation.c
Definition: operation.c:42
expression make_op_expression(entity, cons *)
Definition: operation.c:55
#define TOP_LEVEL_MODULE_NAME
Module containing the global variables in Fortran and C.
Definition: naming-local.h:101
void * gen_find_tabulated(const char *, int)
Definition: tabulated.c:218
#define PLUS_OPERATOR_NAME
expression make_vecteur_expression(Pvecteur pv)
make expression for vector (Pvecteur)
Definition: expression.c:1650
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
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define expression_undefined
Definition: ri.h:1223
#define entity_domain
newgen_syntax_domain_defined
Definition: ri.h:410
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References CONS, debug(), debug_off, debug_on, entity_domain, EXPRESSION, expression_undefined, gen_find_tabulated(), int_to_expression(), make_div_expression(), make_entity_fullname(), make_op_expression(), make_vecteur_expression(), NIL, PLUS_OPERATOR_NAME, TOP_LEVEL_MODULE_NAME, value_abs, value_notone_p, and VALUE_TO_INT.

Referenced by complex_bound_computation().

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