PIPS
code_change_of_basis.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include "linear.h"
#include "genC.h"
#include "ri.h"
#include "ri-util.h"
#include "misc.h"
#include "boolean.h"
#include "vecteur.h"
#include "contrainte.h"
#include "sc.h"
#include "matrice.h"
#include "conversion.h"
+ Include dependency graph for code_change_of_basis.c:

Go to the source code of this file.

Functions

void scanning_base_to_vect (matrice G, int n, Pbase base, pvg)
 void scanning_base_to_vect(matrice G,int n,Pbase base,Pvecteur pvg[n]) compute G*base and put the result in a vector pvg[n] ex: 1 2 G = , base = (I, J) , alor pvg[2] = ((I+2J), (3I+4J)) More...
 
Pvecteur vect_change_base (Pvecteur pv_old, Pbase base_oldindex, pvg)
 Pvecteur vect_change_base(Pvecteur pv_old, Pvecteur pvg[], Pbase base_oldindex, Pbase base_newindex) compute the new vector in the new basis pvg[]. More...
 
conslistexpres_to_listexpres_newbase (cons *lex, pvg, Pbase base_oldindex)
 cons listexpres_to_listexpres_newbase(cons *lex, Pvecteur pvg[], Pbase base_oldindex) compute the new list of expressions (cons lex) in the new basis pvg[] More...
 
expression expression_to_expression_newbase (expression e_old, pvg, Pbase base_oldindex)
 expression expression_to_expression_newbase(expression e_old,Pvecteur pvg[], Pbase base_oldindex) compute the new expression for e_old in the new basis pvg[] More...
 
void statement_newbase (statement s, pvg, Pbase base_oldindex)
 statement_newbase(statement s, Pvecteur pvg[], Pbase base_oldindex) compute the new statement by performing the change of basis More...
 

Function Documentation

◆ expression_to_expression_newbase()

expression expression_to_expression_newbase ( expression  e_old,
pvg  ,
Pbase  base_oldindex 
)

expression expression_to_expression_newbase(expression e_old,Pvecteur pvg[], Pbase base_oldindex) compute the new expression for e_old in the new basis pvg[]

ifdebug(9) {

pips_debug(9, "considering expression %p:\n", e_old);

print_expression(e_old);

}

linear

complex

Definition at line 134 of file code_change_of_basis.c.

138 {
139  normalized e_old_norm;
140  syntax syn;
141  expression e_new;
142  reference ref;
143  call cal;
144  cons *l_ex;
145  cons *l_ex_new;
146  Pvecteur pve_old,pve_new;
147 
148  e_old_norm = NORMALIZE_EXPRESSION(e_old);
149 
150  pips_debug(8, "tag=%d\n", normalized_tag(e_old_norm));
151  /* ifdebug(9) { */
152  /* pips_debug(9, "considering expression %p:\n", e_old); */
153  /* print_expression(e_old); */
154  /* } */
155 
156  if (normalized_linear_p(e_old_norm))
157  { /* linear */
158  pve_old = (Pvecteur) normalized_linear(e_old_norm);
159  pve_new = vect_change_base(pve_old,base_oldindex,pvg);
160  e_new = make_vecteur_expression(pve_new);
161  return(e_new);
162  }
163  else
164  { /* complex */
165  syn = expression_syntax(e_old);
166  if (syntax_reference_p(syn)) {
167  ref = syntax_reference(syn);
168  l_ex = reference_indices(ref);
169  if (l_ex!=NULL){
171  l_ex,pvg,base_oldindex);
172  reference_indices(ref) = l_ex_new;
173  gen_free_list(l_ex);
174  }
175  }
176  else if (syntax_call_p(syn)) {
177  cal = syntax_call(syn);
178  l_ex = call_arguments(cal);
179  if (l_ex!=NULL){
181  l_ex,pvg,base_oldindex);
182  call_arguments(cal) = l_ex_new;
183  gen_free_list(l_ex);
184  }
185  }
186  return (e_old);
187  }
188 }
static reference ref
Current stmt (an integer)
Definition: adg_read_paf.c:163
Pvecteur vect_change_base(Pvecteur pv_old, Pbase base_oldindex, pvg)
Pvecteur vect_change_base(Pvecteur pv_old, Pvecteur pvg[], Pbase base_oldindex, Pbase base_newindex) ...
cons * listexpres_to_listexpres_newbase(cons *lex, pvg, Pbase base_oldindex)
cons listexpres_to_listexpres_newbase(cons *lex, Pvecteur pvg[], Pbase base_oldindex) compute the new...
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define NORMALIZE_EXPRESSION(e)
expression make_vecteur_expression(Pvecteur pv)
make expression for vector (Pvecteur)
Definition: expression.c:1650
#define syntax_reference_p(x)
Definition: ri.h:2728
#define syntax_reference(x)
Definition: ri.h:2730
#define normalized_linear_p(x)
Definition: ri.h:1779
#define syntax_call_p(x)
Definition: ri.h:2734
#define normalized_tag(x)
Definition: ri.h:1778
#define reference_indices(x)
Definition: ri.h:2328
#define syntax_call(x)
Definition: ri.h:2736
#define call_arguments(x)
Definition: ri.h:711
#define normalized_linear(x)
Definition: ri.h:1781
#define expression_syntax(x)
Definition: ri.h:1247
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

References call_arguments, expression_syntax, gen_free_list(), listexpres_to_listexpres_newbase(), make_vecteur_expression(), NORMALIZE_EXPRESSION, normalized_linear, normalized_linear_p, normalized_tag, pips_debug, ref, reference_indices, syntax_call, syntax_call_p, syntax_reference, syntax_reference_p, and vect_change_base().

Referenced by hyperplane(), listexpres_to_listexpres_newbase(), statement_newbase(), and unimodular().

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

◆ listexpres_to_listexpres_newbase()

cons* listexpres_to_listexpres_newbase ( cons lex,
pvg  ,
Pbase  base_oldindex 
)

cons listexpres_to_listexpres_newbase(cons *lex, Pvecteur pvg[], Pbase base_oldindex) compute the new list of expressions (cons lex) in the new basis pvg[]

f (ex_new != ex) free_expression(ex);

Definition at line 113 of file code_change_of_basis.c.

117 {
118  cons *l_new=NIL;
119  expression ex, ex_new;
120 
121  for (; lex!=NULL; lex=CDR(lex)) {
122  ex = EXPRESSION(CAR(lex));
123  ex_new = expression_to_expression_newbase(ex,pvg,base_oldindex);
124  /*if (ex_new != ex) free_expression(ex);*/
125  l_new = CONS(EXPRESSION,ex_new,l_new);
126  }
127  return(gen_nreverse(l_new));
128 }
expression expression_to_expression_newbase(expression e_old, pvg, Pbase base_oldindex)
expression expression_to_expression_newbase(expression e_old,Pvecteur pvg[], Pbase base_oldindex) com...
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
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h: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 EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217

References CAR, CDR, CONS, EXPRESSION, expression_to_expression_newbase(), gen_nreverse(), and NIL.

Referenced by expression_to_expression_newbase(), and statement_newbase().

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

◆ scanning_base_to_vect()

void scanning_base_to_vect ( matrice  G,
int  n,
Pbase  base,
pvg   
)

void scanning_base_to_vect(matrice G,int n,Pbase base,Pvecteur pvg[n]) compute G*base and put the result in a vector pvg[n] ex: 1 2 G = , base = (I, J) , alor pvg[2] = ((I+2J), (3I+4J))

3 4

Definition at line 52 of file code_change_of_basis.c.

57 {
58  int i,j;
59  Pbase pb;
60  Pvecteur pv;
61 
62  for (i=1; i<=n; i++) {
63  for (j=1,pb=base,pv=NULL; j<=n; j++,pb=pb->succ)
64  vect_add_elem(&pv,pb->var,ACCESS(G,n,i,j));
65  pvg[i] = pv;
66  }
67 }
bdt base
Current expression.
Definition: bdt_read_paf.c:100
#define ACCESS(matrix, column, i, j)
Macros d'acces aux elements d'une matrice.
Definition: matrice-local.h:86
#define G(j, a, b)
maybe most of them should be functions?
struct Svecteur * succ
Definition: vecteur-local.h:92
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 ACCESS, base, G, Svecteur::succ, Svecteur::var, and vect_add_elem().

Referenced by hyperplane(), local_tile_constraints(), tiling_transformation(), and unimodular().

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

◆ statement_newbase()

void statement_newbase ( statement  s,
pvg  ,
Pbase  base_oldindex 
)

statement_newbase(statement s, Pvecteur pvg[], Pbase base_oldindex) compute the new statement by performing the change of basis

Definition at line 195 of file code_change_of_basis.c.

199 {
200  instruction i;
201  statement s1;
202  test t;
203  expression e, e1;
204  loop l;
205  range r;
206  call c;
207  cons *ls;
208  cons *lex;
209 
210  i = statement_instruction(s);
211  switch (instruction_tag(i)) {
213  for (ls=instruction_block(i); ls!=NULL; ls=CDR(ls)) {
214  s1 = STATEMENT(CAR(ls));
215  statement_newbase(s1,pvg,base_oldindex);
216  }
217  break;
218  case is_instruction_test:
219  t = instruction_test(i);
220  e = test_condition(t);
221  e1 = expression_to_expression_newbase(e, pvg, base_oldindex);
222  if (e != e1){
223  test_condition(t) = e1;
224  free_expression(e);
225  }
226  statement_newbase(test_true(t),pvg,base_oldindex);
227  statement_newbase(test_false(t),pvg,base_oldindex);
228  break;
229  case is_instruction_loop:
230  l = instruction_loop(i);
231  r = loop_range(l);
232  e = range_lower(r);
233  e1 = expression_to_expression_newbase(e,pvg,base_oldindex);
234  if (e != e1) {
235  range_lower(r) = e1;
236  free_expression(e);
237  }
238  e = range_upper(r);
239  e1 = expression_to_expression_newbase(e,pvg,base_oldindex);
240  if (e != e1) {
241  range_upper(r) = e1;
242  free_expression(e);
243  }
244  e = range_increment(r);
245  e1 = expression_to_expression_newbase(e,pvg,base_oldindex);
246  if (e != e1) {
247  range_increment(r) = e1;
248  free_expression(e);
249  }
250  statement_newbase(loop_body(l),pvg,base_oldindex);
251  break;
253  {
255 
256  e = forloop_initialization(fl);
257  e1 = expression_to_expression_newbase(e,pvg,base_oldindex);
258  if (e != e1) {
259  forloop_initialization(fl) = e1;
260  free_expression(e);
261  }
262  e = forloop_condition(fl);
263  e1 = expression_to_expression_newbase(e,pvg,base_oldindex);
264  if (e != e1) {
265  forloop_condition(fl) = e1;
266  free_expression(e);
267  }
268  e = forloop_increment(fl);
269  e1 = expression_to_expression_newbase(e,pvg,base_oldindex);
270  if (e != e1) {
271  forloop_increment(fl) = e1;
272  free_expression(e);
273  }
274  statement_newbase(forloop_body(fl),pvg,base_oldindex);
275  break;
276  }
278  {
280  e = whileloop_condition(wl);
281  e1 = expression_to_expression_newbase(e,pvg,base_oldindex);
282  if (e != e1) {
283  whileloop_condition(wl) = e1;
284  free_expression(e);
285  }
286  statement_newbase(whileloop_body(wl),pvg,base_oldindex);
287  break;
288  }
289  case is_instruction_goto:
290  statement_newbase(instruction_goto(i),pvg,base_oldindex);
291  break;
292  case is_instruction_call:
293  c = instruction_call(i);
294  lex = call_arguments(c);
296  base_oldindex);
297  gen_free_list(lex);
298  break;
300  break;
301  default:
302  pips_internal_error("unexpected tag %d",instruction_tag(i));
303  }
304 }
void free_expression(expression p)
Definition: ri.c:853
void statement_newbase(statement s, pvg, Pbase base_oldindex)
statement_newbase(statement s, Pvecteur pvg[], Pbase base_oldindex) compute the new statement by perf...
#define pips_internal_error
Definition: misc-local.h:149
#define is_instruction_block
soft block->sequence transition
#define instruction_block(i)
#define loop_body(x)
Definition: ri.h:1644
#define forloop_initialization(x)
Definition: ri.h:1366
#define range_upper(x)
Definition: ri.h:2290
#define forloop_increment(x)
Definition: ri.h:1370
#define instruction_loop(x)
Definition: ri.h:1520
#define instruction_goto(x)
Definition: ri.h:1526
#define test_false(x)
Definition: ri.h:2837
#define range_increment(x)
Definition: ri.h:2292
@ is_instruction_goto
Definition: ri.h:1473
@ is_instruction_unstructured
Definition: ri.h:1475
@ is_instruction_whileloop
Definition: ri.h:1472
@ is_instruction_test
Definition: ri.h:1470
@ is_instruction_call
Definition: ri.h:1474
@ is_instruction_forloop
Definition: ri.h:1477
@ is_instruction_loop
Definition: ri.h:1471
#define instruction_tag(x)
Definition: ri.h:1511
#define test_true(x)
Definition: ri.h:2835
#define instruction_forloop(x)
Definition: ri.h:1538
#define test_condition(x)
Definition: ri.h:2833
#define instruction_whileloop(x)
Definition: ri.h:1523
#define range_lower(x)
Definition: ri.h:2288
#define whileloop_body(x)
Definition: ri.h:3162
#define statement_instruction(x)
Definition: ri.h:2458
#define instruction_call(x)
Definition: ri.h:1529
#define loop_range(x)
Definition: ri.h:1642
#define forloop_condition(x)
Definition: ri.h:1368
#define instruction_test(x)
Definition: ri.h:1517
#define whileloop_condition(x)
Definition: ri.h:3160
#define forloop_body(x)
Definition: ri.h:1372
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
s1
Definition: set.c:247

References call_arguments, CAR, CDR, expression_to_expression_newbase(), forloop_body, forloop_condition, forloop_increment, forloop_initialization, free_expression(), gen_free_list(), instruction_block, instruction_call, instruction_forloop, instruction_goto, instruction_loop, instruction_tag, instruction_test, instruction_whileloop, is_instruction_block, is_instruction_call, is_instruction_forloop, is_instruction_goto, is_instruction_loop, is_instruction_test, is_instruction_unstructured, is_instruction_whileloop, listexpres_to_listexpres_newbase(), loop_body, loop_range, pips_internal_error, range_increment, range_lower, range_upper, s1, STATEMENT, statement_instruction, test_condition, test_false, test_true, whileloop_body, and whileloop_condition.

Referenced by code_generation().

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

◆ vect_change_base()

Pvecteur vect_change_base ( Pvecteur  pv_old,
Pbase  base_oldindex,
pvg   
)

Pvecteur vect_change_base(Pvecteur pv_old, Pvecteur pvg[], Pbase base_oldindex, Pbase base_newindex) compute the new vector in the new basis pvg[].

var is in base_oldindex

on bousille tranquillement le vecteur sur lequel on itere;-)

vect_erase_var(&pv_old,pv->var);

clean vector

Definition at line 73 of file code_change_of_basis.c.

77 {
78  Pvecteur pv,pv1,pv2 = NULL;
79  Pbase to_erase = BASE_NULLE, b;
80  int r;
81 
82  for (pv=pv_old; pv!=NULL; pv=pv->succ)
83  {
85 
86  if (r != -1)
87  { /* var is in base_oldindex */
88  pv1 = vect_multiply(vect_dup(pvg[r]),pv->val);
89  pv2 = vect_add(pv2,pv1);
90 
91  /* on bousille tranquillement le vecteur sur lequel on itere;-) */
92  /* vect_erase_var(&pv_old,pv->var); */
93  to_erase = base_add_variable(to_erase, pv->var);
94  }
95  }
96 
97  /* clean vector
98  */
99  for(b=to_erase; b!=NULL; b=b->succ)
100  vect_erase_var(&pv_old, b->var);
101  base_rm(to_erase);
102 
103  pv2 = vect_add(pv2,pv_old);
104 
105  return pv2;
106 }
Pbase base_add_variable(Pbase b, Variable var)
Pbase base_add_variable(Pbase b, Variable v): add variable v as a new dimension to basis b at the end...
Definition: base.c:88
int base_find_variable_rank(Pbase b, Variable v, char *(*variable_name)(Variable))
int base_find_variable_rank(Pbase b, Variable v, char * (*variable_name)()): returns variable v's ran...
Definition: base.c:194
const char * entity_name_or_TCST(entity e)
Return a name valid for sorting variables in vectors and constraint systems.
Definition: entity.c:627
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
Value val
Definition: vecteur-local.h:91
Variable var
Definition: vecteur-local.h:90
char *(* get_variable_name_t)(Variable)
Definition: vecteur-local.h:62
#define base_rm(b)
#define BASE_NULLE
MACROS SUR LES BASES.
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_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

References base_add_variable(), base_find_variable_rank(), BASE_NULLE, base_rm, entity_name_or_TCST(), Svecteur::succ, Svecteur::val, Svecteur::var, vect_add(), vect_dup(), vect_erase_var(), and vect_multiply().

Referenced by expression_to_expression_newbase(), hyperplane(), and unimodular().

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