PIPS
reindexing_utils.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.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 "union.h"
#include "matrix.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 "reindexing.h"
+ Include dependency graph for reindexing_utils.c:

Go to the source code of this file.

Macros

#define SUCC(cp)   (((cp) == NULL) ? NULL : (cp)->succ)
 

Typedefs

typedef dfg_vertex_label vertex_label
 Name : reindexing_utils.c Package : reindexing Author : Alexis Platonoff & Antoine Cloue Date : May 1994 Historic : More...
 
typedef dfg_arc_label arc_label
 

Functions

Psyslist reverse_psyslist (Psyslist l)
 ====================================================================== More...
 
expression psystem_to_expression (Psysteme ps)
 ====================================================================== More...
 
reference my_build_new_ref (int kind, int n, list subscripts, reference old_r)
 ======================================================================== More...
 
void my_lhs_subs_in_ins (instruction ins, string SA, int n, list subscripts)
 ======================================================================== More...
 
list ADD_LIST_TO_LIST (list l1, list l2)
 ======================================================================= More...
 
void fprint_list_of_ins (FILE *fp, list li)
 ======================================================================= More...
 
void fprint_loop (FILE *fp, loop lp)
 ======================================================================= More...
 
void fprint_call (FILE *fp, call ca)
 ======================================================================= More...
 
void print_detailed_ins (instruction ins)
 ====================================================================== More...
 
Psyslist add_sclist_to_sclist (Psyslist l1, Psyslist l2)
 ======================================================================= More...
 
Psysteme base_complete (Psysteme sys, list var_l, list par_l, list *new_l)
 ======================================================================= More...
 
Psysteme sc_add_egalite_at_end (Psysteme ps, Pcontrainte co)
 ======================================================================= More...
 
void matrix_coef_mult (Pmatrix A, Value nb)
 ======================================================================== More...
 
void my_constraints_with_sym_cst_to_matrices (Pcontrainte pc, Pbase index_base, Pbase const_base, Pmatrix A, Pmatrix B)
 ===================================================================== More...
 
void my_matrices_to_constraints_with_sym_cst (Pcontrainte *pc, Pbase new_base, Pbase index_base, Pbase const_base, Pmatrix A, Pmatrix B)
 ===================================================================== More...
 
void my_matrices_to_constraints_with_sym_cst_2 (Pcontrainte *pc, Pbase new_base, Pbase index_base, Pbase const_base, Pmatrix A, Pmatrix B)
 ===================================================================== More...
 
Psysteme matrix_to_system (Pmatrix A, Pbase b)
 ================================================================== More...
 
Psysteme sc_reverse_constraints (Psysteme ps)
 ======================================================================== More...
 
bool vars_in_vect_p (Pvecteur pv, list vars)
 ====================================================================== More...
 
expression merge_expressions (expression exp1, expression exp2, int max_or_min)
 =================================================================== More...
 
bool min_or_max_expression_p (expression exp)
 =================================================================== More...
 
list extract_bdt (bdt b, int cn)
 ======================================================================= More...
 
placement extract_plc (plc p, int cn)
 ======================================================================== More...
 
entity create_new_entity (int st, char *typ, int nb)
 ======================================================================== More...
 
Psysteme change_base_in_sc (Psysteme ps, list lvar, Psysteme lequ)
 ======================================================================== More...
 
list find_new_variables (list l1, list l2)
 ======================================================================== More...
 
Psysteme my_clean_ps (Psysteme ps)
 ======================================================================= More...
 
bool is_vect_constant_p (Pvecteur v)
 ======================================================================== More...
 
bool cst_vector_p (Pvecteur v, Pbase b)
 ======================================================================== More...
 
list remove_minmax (list le)
 ===================================================================== More...
 
bool array_ref_exp_p (expression e)
 ====================================================================== More...
 

Macro Definition Documentation

◆ SUCC

#define SUCC (   cp)    (((cp) == NULL) ? NULL : (cp)->succ)

Definition at line 94 of file reindexing_utils.c.

Typedef Documentation

◆ arc_label

Definition at line 92 of file reindexing_utils.c.

◆ vertex_label

Name : reindexing_utils.c Package : reindexing Author : Alexis Platonoff & Antoine Cloue Date : May 1994 Historic :

Documents: SOON Comments : contains some usefull functions. Ansi includes
Newgen includes
C3 includes
Pips includes
Macro functions
Internal variables
Local defines

Definition at line 91 of file reindexing_utils.c.

Function Documentation

◆ ADD_LIST_TO_LIST()

list ADD_LIST_TO_LIST ( list  l1,
list  l2 
)

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

list ADD_LIST_TO_LIST(l1, l2): add the list l2 at the end of the list l1

AC 94/06/07

Definition at line 312 of file reindexing_utils.c.

315 {
316  list l3, l4;
317 
318  if (l1 == NIL) return(l2);
319  if (l2 == NIL) return(l1);
320 
321  l3 = l1;
322 
323  while (l3 != NIL)
324  {
325  l4 = l3;
326  l3 = l3->cdr;
327  }
328  l4->cdr = l2;
329 
330  return(l1);
331 }
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
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

References cons::cdr, and NIL.

Referenced by build_first_comb(), and build_second_comb().

+ Here is the caller graph for this function:

◆ add_sclist_to_sclist()

Psyslist add_sclist_to_sclist ( Psyslist  l1,
Psyslist  l2 
)

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

Psyslist add_sclist_to_sclist(l1, l2): add the list of systems l2 at the end of the list of system l1.

Ac 94/05/05

Definition at line 498 of file reindexing_utils.c.

501 {
502  Psyslist l = l1, ls;
503 
504  if (l2 == NULL) return(l1);
505 
506  if (l != NULL)
507  {
508  ls = l->succ;
509  while (ls != NULL)
510  {
511  l = l->succ;
512  ls = l->succ;
513  }
514  l->succ = l2;
515  return(l1);
516  }
517  else return(l2);
518 }
Warning! Do not modify this file that is automatically generated!
Definition: union-local.h:3
struct Ssyslist * succ
Definition: union-local.h:5

References Ssyslist::succ.

Referenced by build_list_of_min().

+ Here is the caller graph for this function:

◆ array_ref_exp_p()

bool array_ref_exp_p ( expression  e)

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

bool array_ref_exp_p(e)

Tests if an expression is an array, that is we test the field "reference" of the expression which should not be empty.

AC 94/07/28

Never reached.

Definition at line 1370 of file reindexing_utils.c.

1372 {
1373  bool b = false;
1374 
1377  return(reference_indices(r) != NIL);
1378  }
1379  else
1380  pips_internal_error("expression syntax is not no reference !");
1381 
1382  /* Never reached. */
1383  return(b);
1384 }
#define pips_internal_error
Definition: misc-local.h:149
#define syntax_reference_p(x)
Definition: ri.h:2728
#define syntax_reference(x)
Definition: ri.h:2730
#define reference_indices(x)
Definition: ri.h:2328
#define expression_syntax(x)
Definition: ri.h:1247

References expression_syntax, NIL, pips_internal_error, reference_indices, syntax_reference, and syntax_reference_p.

Referenced by assignation_filter().

+ Here is the caller graph for this function:

◆ base_complete()

Psysteme base_complete ( Psysteme  sys,
list  var_l,
list  par_l,
list new_l 
)

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

Psysteme base_complete(Psysteme sys, list var_l, list par_l): "sys" gives a family of free vectors {V1, ..., Vs} represented by a linear combinations of indices from "var_l". This function wants to find the indices (I1, ..., Id) of "var_l" for which we have that {V1, ..., Vs, I1, ..., Id} is a family of free vectors. "par_l" gives the symbolic constants that may appear in "sys".

"s" is the number of equations of "sys" (its number of vectors). "d" is the number of vectors we have to find in order to get as much equations in "sys" as there are indices in "var_l".

Example: with "sys" equal to {i+j = 0, i-k+2j = 0}, and "var_l" equal to {i, j, k} we obtain the new system {i+j = 0, i-k+2j = 0, i = 0}

function written by Alexis in "utils.c". The difference is that it returns the list of new free vectors added. (AC 94/03/18)

Definition at line 539 of file reindexing_utils.c.

543 {
544  Psysteme ps = sc_dup(sys), new_ps = sc_new();
545  int dim = gen_length(var_l) - sys->nb_eq;
546  list l;
547 
548  for (l = var_l; (!ENDP(l)) && (new_ps->nb_eq < dim); POP(l))
549  {
550  entity var = ENTITY(CAR(l));
551  Pvecteur pv = vect_new((Variable) var, 1);
552  Psysteme aux_ps = sc_dup(ps);
553  Psysteme aux_new_ps = sc_dup(new_ps);
554 
555  sc_add_egalite(aux_new_ps, contrainte_make(pv));
556  aux_ps = append_eg(aux_ps, aux_new_ps);
557 
558  if (vecteurs_libres_p(aux_ps, list_to_base(var_l), list_to_base(par_l)))
559  {
560  new_ps = aux_new_ps;
561  ADD_ELEMENT_TO_LIST(*new_l, ENTITY, var);
562  }
563  else
564  sc_rm(aux_new_ps);
565  }
566 
567  ps = append_eg(ps, new_ps);
568  ps->base = NULL;
569  sc_creer_base(ps);
570 
571  return(ps);
572 }
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
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 ADD_ELEMENT_TO_LIST(_list, _type, _element)
Definition: icfg-local.h:50
Pbase list_to_base(list l)
Pbase list_to_base(list l): returns the Pbase that contains the variables of list "l",...
bool vecteurs_libres_p(Psysteme sys, Pbase v_base, Pbase c_base)
========================================================================
Definition: utils.c:903
Psysteme append_eg(Psysteme M1, Psysteme M2)
========================================================================
Definition: utils.c:946
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
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
void sc_rm(Psysteme ps)
void sc_rm(Psysteme ps): liberation de l'espace memoire occupe par le systeme de contraintes ps;
Definition: sc_alloc.c:277
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
Psysteme sc_dup(Psysteme ps)
Psysteme sc_dup(Psysteme ps): should becomes a link.
Definition: sc_alloc.c:176
Pbase base
Definition: sc-local.h:75
int nb_eq
Definition: sc-local.h:72
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
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_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

References ADD_ELEMENT_TO_LIST, append_eg(), Ssysteme::base, CAR, contrainte_make(), ENDP, ENTITY, gen_length(), list_to_base(), POP, sc_add_egalite(), sc_creer_base(), sc_dup(), sc_new(), sc_rm(), vect_new(), and vecteurs_libres_p().

Referenced by prepare_reindexing().

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

◆ change_base_in_sc()

Psysteme change_base_in_sc ( Psysteme  ps,
list  lvar,
Psysteme  lequ 
)

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

Psysteme change_base_in_sc(ps, lvar, lequ)

Change in the system ps all variables given by lvar by the corresponding equation of lequ. In fact, to each variable of lvar corresponds an equality of lequ which gives its value. We then substitute in ps each variable of lvar by its value given by lequ.

The system ps is modified and its new value is returned.

AC 94/03/22

There should be as many equalities in lequ as there are variables in lvar.

We have to substitute the occurrences of "cvar" in "ps" by its counterpart in "cequ->vecteur", which represents the following equality : cequ->vecteur = 0. We note it "vec" : val*cvar-vec=0, so we have : vec = -(cequ->vecteur-val*cvar)

Definition at line 1160 of file reindexing_utils.c.

1163 {
1164  entity cvar;
1165  Pcontrainte cequ;
1166  list le;
1167 
1168  /* There should be as many equalities in lequ as there are variables in
1169  * lvar.*/
1170  if (lequ->nb_eq != gen_length(lvar)) {
1171  if (get_debug_level() > 5) {
1172  fprintf(stderr,
1173  "\nErreur dans le nombre d'equations ds chg_base()!\n");
1174  fprintf(stderr,"\nnb eq = %d",lequ->nb_eq);
1175  fprintf(stderr,"\nlvar = %d", gen_length(lvar));
1176  }
1177  user_error("change_base_in_sc",
1178  "Erreur dans le nombre d'equations !\n");
1179  }
1180  else {
1181  cequ = lequ->egalites;
1182  for (le = lvar; le != NIL; POP(le), cequ = cequ->succ) {
1183  Value val;
1184  Pvecteur vec = vect_dup(cequ->vecteur);
1185 
1186  cvar = ENTITY(CAR(le));
1187 
1188  /* We have to substitute the occurrences of "cvar" in "ps" by its
1189  * counterpart in "cequ->vecteur", which represents the following
1190  * equality : cequ->vecteur = 0. We note it "vec" : val*cvar-vec=0,
1191  * so we have : vec = -(cequ->vecteur-val*cvar) */
1192  val = vect_coeff((Variable) cvar, vec);
1193  vect_erase_var(&vec, (Variable) cvar);
1194  vect_chg_sgn(vec);
1195  substitute_var_with_vec(ps, cvar, val, vec);
1196  }
1197  }
1198 
1199  ps->base = NULL;
1200  sc_creer_base(ps);
1201 
1202  return(ps);
1203 }
int Value
#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
void substitute_var_with_vec(Psysteme, entity, Value, Pvecteur)
===========================================================================
Definition: utils.c:1210
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
void vect_chg_sgn(Pvecteur v)
void vect_chg_sgn(Pvecteur v): multiplie v par -1
Definition: scalaires.c:151
Pvecteur vecteur
struct Scontrainte * succ
Pcontrainte egalites
Definition: sc-local.h:70
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_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
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 CAR, ENTITY, fprintf(), gen_length(), get_debug_level(), NIL, POP, sc_creer_base(), substitute_var_with_vec(), Scontrainte::succ, user_error, vect_chg_sgn(), vect_coeff(), vect_dup(), vect_erase_var(), and Scontrainte::vecteur.

Referenced by include_trans_on_LC_in_sc(), include_trans_on_LC_in_sc2(), and prepare_reindexing().

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

◆ create_new_entity()

entity create_new_entity ( int  st,
char *  typ,
int  nb 
)

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

entity create_new_entity(st, typ, nb): create a new entity with the following form : "STAT_SYMstTYPnb" where st is the statement number.

This new entity is put in the list of entities that have to be declared.

AC 94/03/15

AP 95/04/20: entities must have in their full name the current module name instead of RE_MODULE_NAME

Create the entity

f_name = concatenate(RE_MODULE_NAME, MODULE_SEP_STRING, name, NULL);

Declare the entity

Definition at line 1113 of file reindexing_utils.c.

1116 {
1117  entity ent, mod_entity;
1118  code mod_code;
1119  char *name;
1120  string f_name;
1121 
1122  /* Create the entity */
1123  name = (char*) malloc(32);
1124  sprintf(name,"%s%d%s%d", STAT_SYM, st, typ, nb);
1125 
1126  /* f_name = concatenate(RE_MODULE_NAME, MODULE_SEP_STRING, name, NULL); */
1128  MODULE_SEP_STRING, name, NULL);
1129  free(name);
1130 
1131  ent = make_entity(strdup(f_name),
1134  NIL)),
1137 
1138  /* Declare the entity */
1139  mod_entity = get_current_module_entity();
1140  mod_code = entity_code(mod_entity);
1141  code_declarations(mod_code) = gen_nconc(code_declarations(mod_code),
1142  CONS(ENTITY, ent, NIL));
1143 
1144  return(ent);
1145 }
basic make_basic(enum basic_utype tag, void *val)
Definition: ri.c:155
storage make_storage(enum storage_utype tag, void *val)
Definition: ri.c:2273
value make_value(enum value_utype tag, void *val)
Definition: ri.c:2832
variable make_variable(basic a1, list a2, list a3)
Definition: ri.c:2895
type make_type(enum type_utype tag, void *val)
Definition: ri.c:2706
string db_get_current_module_name(void)
Also used to check whether set...
Definition: database.c:1059
void * malloc(YYSIZE_T)
void free(void *)
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
#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 MODULE_SEP_STRING
Definition: naming-local.h:30
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
#define UU
Definition: newgen_types.h:98
#define STAT_SYM
#define make_entity(n, t, s, i)
code entity_code(entity e)
Definition: entity.c:1098
@ is_basic_int
Definition: ri.h:571
@ is_value_unknown
Definition: ri.h:3035
#define code_declarations(x)
Definition: ri.h:784
@ is_storage_rom
Definition: ri.h:2494
@ is_type_variable
Definition: ri.h:2900
char * strdup()

References code_declarations, concatenate(), CONS, db_get_current_module_name(), ENTITY, entity_code(), free(), gen_nconc(), get_current_module_entity(), is_basic_int, is_storage_rom, is_type_variable, is_value_unknown, make_basic(), make_entity, make_storage(), make_type(), make_value(), make_variable(), malloc(), MODULE_SEP_STRING, NIL, STAT_SYM, strdup(), and UU.

Referenced by get_time_ent(), prepare_reindexing(), and re_do_it().

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

◆ cst_vector_p()

bool cst_vector_p ( Pvecteur  v,
Pbase  b 
)

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

bool cst_vector_p(Pvecteur v, Pbase b)

Tests if a vector is constant, i.e. does not depend on one of the variables given in b.

AC 94/07/01

Definition at line 1296 of file reindexing_utils.c.

1299 {
1300  bool not_found = true;
1301  Pvecteur av;
1302 
1303  if (!VECTEUR_NUL_P(v)) {
1304  for(av = b; (av != NULL) && not_found; av = av->succ) {
1305  Variable cv = av->var;
1306  not_found = value_zero_p(vect_coeff(cv, v));
1307  }
1308  }
1309  return(not_found);
1310 }
#define value_zero_p(val)
Variable var
Definition: vecteur-local.h:90
struct Svecteur * succ
Definition: vecteur-local.h:92
#define VECTEUR_NUL_P(v)

References Svecteur::succ, value_zero_p, Svecteur::var, vect_coeff(), and VECTEUR_NUL_P.

Referenced by calculate_delay().

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

◆ extract_bdt()

list extract_bdt ( bdt  b,
int  cn 
)

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

list extract_bdt(b, cn):extract in the global bdt b the bdt of the instruction of statement cn.

AC 94/03/15

Definition at line 1060 of file reindexing_utils.c.

1063 {
1064  list lc = NIL, ba = bdt_schedules(b);
1065  schedule sched;
1066 
1067  for (; !ENDP(ba); POP(ba)) {
1068  sched = SCHEDULE(CAR(ba));
1069  if (cn == schedule_statement(sched))
1070  ADD_ELEMENT_TO_LIST(lc, SCHEDULE, sched);
1071  }
1072 
1073  return(lc);
1074 }
#define SCHEDULE(x)
SCHEDULE.
Definition: paf_ri.h:682
#define bdt_schedules(x)
Definition: paf_ri.h:226
#define schedule_statement(x)
Definition: paf_ri.h:713

References ADD_ELEMENT_TO_LIST, bdt_schedules, CAR, ENDP, NIL, POP, SCHEDULE, and schedule_statement.

Referenced by cmf_layout_align(), craft_layout_align(), and prepare_reindexing().

+ Here is the caller graph for this function:

◆ extract_plc()

placement extract_plc ( plc  p,
int  cn 
)

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

placement extract_plc(p, cn): extract in the global distribution p, the placement function of statement "cn".

AC 94/03/15

Definition at line 1083 of file reindexing_utils.c.

1086 {
1087  list pa = plc_placements(p);
1089 
1090  for (; !ENDP(pa); POP(pa)) {
1091  pla = PLACEMENT(CAR(pa));
1092  if (cn == placement_statement(pla)) break;
1093  }
1094 
1095  if(pla == placement_undefined)
1096  user_error("extract_plc", "A plc is undefined\n");
1097 
1098  return(pla);
1099 }
#define plc_placements(x)
Definition: paf_ri.h:557
#define placement_undefined
Definition: paf_ri.h:499
#define PLACEMENT(x)
PLACEMENT.
Definition: paf_ri.h:493
#define placement_statement(x)
Definition: paf_ri.h:523

References CAR, ENDP, PLACEMENT, placement_statement, placement_undefined, plc_placements, POP, and user_error.

Referenced by prepare_reindexing().

+ Here is the caller graph for this function:

◆ find_new_variables()

list find_new_variables ( list  l1,
list  l2 
)

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

list find_new_variables(l1, l2): replace the n first variables of list l1 by those of list l2 (gen_length(l2) = n).

AC 93/03/31

Definition at line 1212 of file reindexing_utils.c.

1214 {
1215  int n;
1216  entity e;
1217 
1218  n = gen_length(l2);
1219 
1220  while (n != 0) {
1221  l1 = CDR(l1);
1222  n--;
1223  }
1224 
1225  while (l1 != NIL) {
1226  e = ENTITY(CAR(l1));
1227  ADD_ELEMENT_TO_LIST(l2, ENTITY, e);
1228  l1 = CDR(l1);
1229  }
1230 
1231  return(l2);
1232 }
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111

References ADD_ELEMENT_TO_LIST, CAR, CDR, ENTITY, gen_length(), and NIL.

Referenced by prepare_reindexing().

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

◆ fprint_call()

void fprint_call ( FILE *  fp,
call  ca 
)

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

void fprint_call(fp, ca): print a call.

AC 94/06/07

Definition at line 395 of file reindexing_utils.c.

399 {
400  expression exp1, exp2;
401 
402  exp1 = EXPRESSION(CAR(call_arguments(ca)));
403  exp2 = EXPRESSION(CAR((call_arguments(ca))->cdr));
404  fprintf(fp, "\nCall : ");
405  fprint_list_of_exp(fp, CONS(EXPRESSION, exp1, NIL));
406  fprintf(fp, " %s ", entity_local_name(call_function(ca)));
407  fprint_list_of_exp(fp, CONS(EXPRESSION, exp2, NIL));
408 }
void fprint_list_of_exp(FILE *fp, list exp_l)
void fprint_list_of_exp(FILE *fp, list exp_l): prints in the file "fp" the list of expression "exp_l"...
Definition: expression.c:229
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 call_function(x)
Definition: ri.h:709
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define call_arguments(x)
Definition: ri.h:711

References call_arguments, call_function, CAR, CONS, entity_local_name(), EXPRESSION, fprint_list_of_exp(), fprintf(), and NIL.

Referenced by print_detailed_ins().

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

◆ fprint_list_of_ins()

void fprint_list_of_ins ( FILE *  fp,
list  li 
)

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

void fprint_list_of_ins(fp, li): print a list of instruction.

AC 94/06/07

Definition at line 339 of file reindexing_utils.c.

343 {
344  int i = 1;
345 
346  fprintf(fp,"\nListe of instruction:");
347  fprintf(fp,"\n=====================");
348 
349  for (; li != NIL; li = CDR(li))
350  {
351  fprintf(fp, "\nInstruction n. %d:\n", i);
352  sa_print_ins(fp, INSTRUCTION(CAR(li)));
353  i++;
354  }
355 }
#define INSTRUCTION(x)
INSTRUCTION.
Definition: ri.h:1448
void sa_print_ins(FILE *fp, instruction i)
=========================================================================

References CAR, CDR, fprintf(), INSTRUCTION, NIL, and sa_print_ins().

+ Here is the call graph for this function:

◆ fprint_loop()

void fprint_loop ( FILE *  fp,
loop  lp 
)

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

void fprint_loop(fp, lp): print a loop.

AC 94/06/07

Definition at line 363 of file reindexing_utils.c.

367 {
368  fprintf(fp,"\nIndice de boucle :");
370  fprintf(fp,"\nDomaine (lower, upper, inc):");
373  fprint_list_of_exp(fp,
375  fprint_list_of_exp(fp,
377  fprintf(fp,"\nCorps de boucle :");
379  fprintf(fp,"\nLabel:");
381  fprintf(fp,"\nType d'execution");
383  fprintf(fp," ->sequentiel");
384  else fprintf(fp, "->parallele");
385  fprintf(fp, "\nLocals : ");
387 }
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 loop_body(x)
Definition: ri.h:1644
#define loop_execution(x)
Definition: ri.h:1648
#define range_upper(x)
Definition: ri.h:2290
#define range_increment(x)
Definition: ri.h:2292
#define execution_sequential_p(x)
Definition: ri.h:1208
#define loop_label(x)
Definition: ri.h:1646
#define loop_locals(x)
Definition: ri.h:1650
#define range_lower(x)
Definition: ri.h:2288
#define statement_instruction(x)
Definition: ri.h:2458
#define loop_range(x)
Definition: ri.h:1642
#define loop_index(x)
Definition: ri.h:1640

References CONS, ENTITY, execution_sequential_p, EXPRESSION, fprint_entity_list(), fprint_list_of_exp(), fprintf(), loop_body, loop_execution, loop_index, loop_label, loop_locals, loop_range, NIL, range_increment, range_lower, range_upper, sa_print_ins(), and statement_instruction.

Referenced by print_detailed_ins().

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

◆ is_vect_constant_p()

bool is_vect_constant_p ( Pvecteur  v)

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

bool is_vect_constant_p(v): test if a vecteur is constant.

AC 94/07/01

Definition at line 1275 of file reindexing_utils.c.

1277 {
1278  if (VECTEUR_NUL_P(v))
1279  return(true);
1280  else {
1281  if ((v->var == TCST)&&(v->succ == NULL))
1282  return(true);
1283  else
1284  return(false);
1285  }
1286 }
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.

References TCST, and VECTEUR_NUL_P.

Referenced by calculate_delay().

+ Here is the caller graph for this function:

◆ matrix_coef_mult()

void matrix_coef_mult ( Pmatrix  A,
Value  nb 
)

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

void matrix_coef_mult(A, nb):multiply all elements of matrix A by the number nb.

AC 94/03/21 also elsewehre...

Definition at line 605 of file reindexing_utils.c.

609 {
610  int i, j;
611 
612  for (i = 1; i <= MATRIX_NB_LINES(A); i++)
613  for (j = 1; j <= MATRIX_NB_COLUMNS(A); j++)
614  value_product(MATRIX_ELEM(A,i,j), nb);
615 }
#define value_product(v, w)
#define MATRIX_NB_LINES(matrix)
Definition: matrix-local.h:87
#define MATRIX_NB_COLUMNS(matrix)
Definition: matrix-local.h:88
#define MATRIX_ELEM(matrix, i, j)
Macros d'acces aux elements d'une matrice.
Definition: matrix-local.h:80
Definition: pip__tab.h:25

References MATRIX_ELEM, MATRIX_NB_COLUMNS, MATRIX_NB_LINES, and value_product.

Referenced by prepare_reindexing().

+ Here is the caller graph for this function:

◆ matrix_to_system()

Psysteme matrix_to_system ( Pmatrix  A,
Pbase  b 
)

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

Psysteme matrix_to_system(A, b): transform a Pmatrix in a system following the variables in Pbase b.

AC 94/05/15

Definition at line 892 of file reindexing_utils.c.

896 {
897  Psysteme p = sc_new();
898  list l, lb = base_to_list(b);
899  int i, j;
900  Pvecteur vect, nvect;
901 
902  for (i = 1; i <= MATRIX_NB_LINES(A); i++)
903  {
904  l = lb;
905  vect = VECTEUR_NUL;
906 
907  for (j = 1; j <= MATRIX_NB_COLUMNS(A); j++)
908  {
909  nvect = vect_new((Variable) ENTITY(CAR(l)), MATRIX_ELEM(A,i,j));
910  vect = vect_add(vect, nvect);
911  l = CDR(l);
912  }
914  }
915 
916  if (get_debug_level() > 5)
917  {
918  fprintf(stderr,"\nmatrcix_to_ps");
919  fprint_psysteme(stderr,p);
920  }
921 
922  p->base = vect_dup(b);
923 
924  return(p);
925 }
list base_to_list(Pbase base)
Most includes are centralized here.
void fprint_psysteme(FILE *, Psysteme)
===========================================================================
Definition: print.c:302
Psysteme sc_add_egalite_at_end(Psysteme ps, Pcontrainte co)
=======================================================================
#define VECTEUR_NUL
DEFINITION DU VECTEUR NUL.
Pvecteur vect_add(Pvecteur v1, Pvecteur v2)
package vecteur - operations binaires
Definition: binaires.c:53

References Ssysteme::base, base_to_list(), CAR, CDR, contrainte_make(), ENTITY, fprint_psysteme(), fprintf(), get_debug_level(), MATRIX_ELEM, MATRIX_NB_COLUMNS, MATRIX_NB_LINES, sc_add_egalite_at_end(), sc_new(), vect_add(), vect_dup(), vect_new(), and VECTEUR_NUL.

Referenced by build_contraction_matrices().

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

◆ merge_expressions()

expression merge_expressions ( expression  exp1,
expression  exp2,
int  max_or_min 
)

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

expression merge_expressions(expression exp1, exp2, int max_or_min):

Merges two expression into one using the MAX or MIN function

For example, with expressions (N-1) and (M+2), and IS_MIN, we obtain the following expression : MIN(N-1, M+2).

Note : should be modified in order to avoid the MAX or MIN call when the result can be known (AP)

Definition at line 999 of file reindexing_utils.c.

1002 {
1003  expression exp;
1004  entity op_ent = entity_undefined;
1005 
1006  if(max_or_min == IS_MAX)
1007  op_ent = entity_intrinsic("MAX");
1008  else if(max_or_min == IS_MIN)
1009  op_ent = entity_intrinsic("MIN");
1010  else
1011  user_error("merge_expressions", "Bad max or min tag\n");
1012 
1013  if(exp1 == expression_undefined)
1014  exp = exp2;
1015  else if(exp2 == expression_undefined)
1016  exp = exp1;
1017  else
1019  make_call(op_ent,
1020  CONS(EXPRESSION, exp1,
1021  CONS(EXPRESSION,
1022  exp2, NIL)))),
1024  return(exp);
1025 }
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 IS_MIN
#define IS_MAX
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
@ is_syntax_call
Definition: ri.h:2693
#define entity_undefined
Definition: ri.h:2761
#define expression_undefined
Definition: ri.h:1223
#define exp
Avoid some warnings from "gcc -Wshadow".
Definition: vasnprintf.c:207

References CONS, entity_intrinsic(), entity_undefined, exp, EXPRESSION, expression_undefined, IS_MAX, IS_MIN, is_syntax_call, make_call(), make_expression(), make_syntax(), NIL, normalized_undefined, and user_error.

Referenced by bound_compute(), and prepare_array_bounds().

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

◆ min_or_max_expression_p()

bool min_or_max_expression_p ( expression  exp)

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

Definition at line 1035 of file reindexing_utils.c.

1037 {
1038  syntax sy;
1039  call ca;
1040  entity func;
1041 
1042  sy = expression_syntax(exp);
1043  if(syntax_tag(sy) != is_syntax_call)
1044  return(false);
1045 
1046  ca = syntax_call(sy);
1047  func = call_function(ca);
1048 
1049  return(ENTITY_MIN_OR_MAX_P(func));
1050 }
#define ENTITY_MIN_OR_MAX_P(e)
#define syntax_tag(x)
Definition: ri.h:2727
#define syntax_call(x)
Definition: ri.h:2736

References call_function, ENTITY_MIN_OR_MAX_P, exp, expression_syntax, is_syntax_call, syntax_call, and syntax_tag.

Referenced by constraint_to_bound().

+ Here is the caller graph for this function:

◆ my_build_new_ref()

reference my_build_new_ref ( int  kind,
int  n,
list  subscripts,
reference  old_r 
)

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

reference build_new_ref(int kind,int n,list subscripts,reference old_r)

builds a new array reference. Its entity name depends on "kind": kind == IS_TEMP => name is : SATn kind == IS_NEW_ARRAY => name is : SAIn We first test if this entity does not exist yet. If not, we have create it with a type_variable with the same basic as the one of the entity of "old_ref" and a dimension depending again on kind: kind == IS_TEMP => dimension is: empty kind == IS_NEW_ARRAY => dimension is: dimension of the loop nest of statement number n

Its indices of the new reference are "subscripts".

"subscripts" is a list of affine expressions. If "subscripts" is empty, then this is a scalar. AC : function that comes from single_assign.c but we have modified it to include the new parameter BASE_NODE_NUMBER.

we duplicate this list

Declare the entity

Definition at line 206 of file reindexing_utils.c.

212 {
213  list sl;
214  entity ent;
215  string num, name = (string) NULL;
216  entity mod_entity;
217  code mod_code;
218 
219  /* we duplicate this list */
220  sl = subscripts;
221 
222  num = atoi(n-BASE_NODE_NUMBER);
223  if(kind == IS_TEMP)
225  SAT, num, (char *) NULL));
226  else if(kind == IS_NEW_ARRAY)
228  SAI, num, (char *) NULL));
229  else
230  pips_internal_error("Bad value for kind");
231 
232  ent = gen_find_tabulated(name, entity_domain);
233  if(ent == entity_undefined) {
234  list dims = NIL;
235 
236  if(kind == IS_NEW_ARRAY)
237  dims = dims_of_nest(n);
238  else
239  pips_internal_error("Bad value for kind");
240 
241  ent = create_entity(name, make_variable(basic_of_reference(old_r), dims));
242 
243  /* Declare the entity */
244  mod_entity = get_current_module_entity();
245  mod_code = entity_code(mod_entity);
246  code_declarations(mod_code) = gen_nconc(code_declarations(mod_code),
247  CONS(ENTITY, ent, NIL));
248 
249  if (get_debug_level() > 6) {
250  if(kind == IS_NEW_ARRAY)
251  fprintf(stderr, "\n***\nCreate an ARRAY ENTITY : %s, %s\n",
252  entity_local_name(ent), name);
253  }
254  }
255 
256  return(make_reference(ent, sl));
257 }
reference make_reference(entity a1, list a2)
Definition: ri.c:2083
static int num
Definition: bourdoncle.c:137
void * gen_find_tabulated(const char *, int)
Definition: tabulated.c:218
char * string
STRING.
Definition: newgen_types.h:39
#define BASE_NODE_NUMBER
#define SA_MODULE_NAME
#define SAT
#define IS_NEW_ARRAY
#define SAI
#define IS_TEMP
basic basic_of_reference(reference)
Retrieves the basic of a reference in a newly allocated basic object.
Definition: type.c:1459
#define entity_domain
newgen_syntax_domain_defined
Definition: ri.h:410
list dims_of_nest(int n)
=========================================================================
entity create_entity(string name, variable v)
=========================================================================

References BASE_NODE_NUMBER, basic_of_reference(), code_declarations, concatenate(), CONS, create_entity(), dims_of_nest(), ENTITY, entity_code(), entity_domain, entity_local_name(), entity_undefined, fprintf(), gen_find_tabulated(), gen_nconc(), get_current_module_entity(), get_debug_level(), IS_NEW_ARRAY, IS_TEMP, make_reference(), make_variable(), MODULE_SEP_STRING, NIL, num, pips_internal_error, SA_MODULE_NAME, SAI, SAT, and strdup().

Referenced by make_reindex(), and my_lhs_subs_in_ins().

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

◆ my_clean_ps()

Psysteme my_clean_ps ( Psysteme  ps)

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

Psysteme my_clean_ps(ps):

put nb_eq and nb_ineq at the rigth value.

AC 94/05/09

Definition at line 1243 of file reindexing_utils.c.

1245 {
1246  int count;
1247  Pcontrainte cont;
1248 
1249  count = 0;
1250  cont = ps->egalites;
1251  while (cont != NULL) {
1252  count++;
1253  cont = cont->succ;
1254  }
1255  ps->nb_eq = count;
1256 
1257  count = 0;
1258  cont = ps->inegalites;
1259  while (cont != NULL) {
1260  count++;
1261  cont = cont->succ;
1262  }
1263  ps->nb_ineq = count;
1264 
1265  return(ps);
1266 }
static int count
Definition: SDG.c:519
Pcontrainte inegalites
Definition: sc-local.h:71
int nb_ineq
Definition: sc-local.h:73

References count, and Scontrainte::succ.

Referenced by build_list_of_min().

+ Here is the caller graph for this function:

◆ my_constraints_with_sym_cst_to_matrices()

void my_constraints_with_sym_cst_to_matrices ( Pcontrainte  pc,
Pbase  index_base,
Pbase  const_base,
Pmatrix  A,
Pmatrix  B 
)

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

void constraints_with_sym_cst_to_matrices(Pcontrainte pc, Pbase index_base const_base, matrice A B, int n m1 m2):

constructs the matrices "A" and "B" corresponding to the linear constraints "pc", so: A.ib + B1.cb + B2 = 0 <=> pc(ib, cb) = 0:

 B = ( B1 | B2 ), B2 of dimension (n,1).

The basis "ib" gives the variables of the linear system. The basis "cb" gives the symbolic constants of the linear system.

The matrices "A" and "B" are supposed to have been already allocated in memory, respectively of dimension (n, m1) and (n, m2).

"n" must be the exact number of constraints in "pc". "m1" must be the exact number of variables in "ib". "m2" must be equal to the number of symbolic constants (in "cb") PLUS ONE (the actual constant).

CHANGE HERE !!!

Definition at line 637 of file reindexing_utils.c.

642 {
643  int i,j;
644  Pcontrainte eq;
645  Pvecteur pv;
646  int n = 0;
647  int m2 = vect_size(const_base) + 1; /* CHANGE HERE !!! */
648 
649  for (eq = pc; !CONTRAINTE_UNDEFINED_P(eq); eq=eq->succ,n++);
650  matrix_nulle(B);
651  matrix_nulle(A);
652 
653  for (eq = pc,i=1; !CONTRAINTE_UNDEFINED_P(eq); eq=eq->succ,i++)
654  {
655  for(pv = index_base, j=1; pv != NULL; pv = pv->succ, j++)
656  { MATRIX_ELEM(A,i,j) = vect_coeff(vecteur_var(pv),eq->vecteur);}
657 
658  for(pv = const_base, j=1; pv != NULL; pv = pv->succ, j++)
659  { MATRIX_ELEM(B,i,j) = vect_coeff(vecteur_var(pv),eq->vecteur);}
660 
662  }
663 }
#define CONTRAINTE_UNDEFINED_P(c)
#define B(A)
Definition: iabrev.h:61
int vect_size(Pvecteur v)
package vecteur - reductions
Definition: reductions.c:47
void matrix_nulle(Pmatrix Z)
void matrix_nulle(Pmatrix Z): Initialisation de la matrice Z a la valeur matrice nulle
Definition: matrix.c:293
Pcontrainte eq
element du vecteur colonne du systeme donne par l'analyse
Definition: sc_gram.c:108
#define vecteur_var(v)

References B, CONTRAINTE_UNDEFINED_P, eq, MATRIX_ELEM, matrix_nulle(), Scontrainte::succ, Svecteur::succ, TCST, vect_coeff(), vect_size(), Scontrainte::vecteur, and vecteur_var.

Referenced by build_contraction_matrices(), make_reindex(), and prepare_reindexing().

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

◆ my_lhs_subs_in_ins()

void my_lhs_subs_in_ins ( instruction  ins,
string  SA,
int  n,
list  subscripts 
)

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

void lhs_subs_in_ins(instruction ins, string SA, int n, list subscripts)

Substitutes to the lhs (left Hand Side) reference of "ins" the array reference SAn[subscripts], cf. build_new_ref().

"subscripts" is a list of entity, so we have transform it into a list of expression.

Note: "ins" must be an assign call

Definition at line 271 of file reindexing_utils.c.

277 {
278  switch(instruction_tag(ins))
279  {
280  case is_instruction_call : {
281  call c = instruction_call(ins);
283  expression lhs_exp = EXPRESSION(CAR(call_arguments(c)));
284  syntax sy = expression_syntax(lhs_exp);
285  if(syntax_reference_p(sy)) {
286  reference lhs = syntax_reference(sy);
287  list exp_subs = entities_to_expressions(subscripts);
289  exp_subs, lhs);
290 
291  }
292  else pips_internal_error("Lhs is not a reference");
293  }
294  else pips_internal_error("Instruction is not an assign call");
295  break;
296  }
297  case is_instruction_block :
298  case is_instruction_test :
299  case is_instruction_loop :
300  case is_instruction_goto :
302  default : pips_internal_error("Instruction is not an assign call");
303  }
304 }
reference my_build_new_ref(int kind, int n, list subscripts, reference old_r)
========================================================================
#define ENTITY_ASSIGN_P(e)
#define is_instruction_block
soft block->sequence transition
list entities_to_expressions(list l_ent)
build a list of expressions from a list of entities
Definition: entity.c:2703
@ is_instruction_goto
Definition: ri.h:1473
@ is_instruction_unstructured
Definition: ri.h:1475
@ is_instruction_test
Definition: ri.h:1470
@ is_instruction_call
Definition: ri.h:1474
@ is_instruction_loop
Definition: ri.h:1471
#define instruction_tag(x)
Definition: ri.h:1511
#define instruction_call(x)
Definition: ri.h:1529

References call_arguments, call_function, CAR, entities_to_expressions(), ENTITY_ASSIGN_P, EXPRESSION, expression_syntax, instruction_call, instruction_tag, is_instruction_block, is_instruction_call, is_instruction_goto, is_instruction_loop, is_instruction_test, is_instruction_unstructured, IS_NEW_ARRAY, my_build_new_ref(), pips_internal_error, syntax_reference, and syntax_reference_p.

Referenced by build_first_comb().

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

◆ my_matrices_to_constraints_with_sym_cst()

void my_matrices_to_constraints_with_sym_cst ( Pcontrainte pc,
Pbase  new_base,
Pbase  index_base,
Pbase  const_base,
Pmatrix  A,
Pmatrix  B 
)

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

void my_matrices_to_constraints_with_sym_cst(Pcontrainte *pc, Pbase index_base const_base, matrice A B,int n m1 m2):

constructs the constraints "pc" corresponding to the matrices "A" and "B" so: A.ib + B1.cb + B2 = nb <=> pc(nb, ib, cb) = 0, with:

 B = ( B1 | B2 ), B2 of dimension (n,1).

The basis "ib" gives the variables of the linear system. The basis "cb" gives the symbolic constants of the linear system. The basis "nb" gives the new variables of the linear system.

The matrices "A" and "B" are respectively of dimension (n, m1) and (n,m2).

"n" will be the exact number of constraints in "pc". "m1" must be the exact number of variables in "ib". "m2" must be equal to the number of symbolic constants (in "cb") PLUS ONE (the actual constant).

Note: the formal parameter pc is a "Pcontrainte *". Instead, the resulting Pcontrainte could have been returned as the result of this function.

TAKE CARE : new_base should be well ordered !!

AC 94/03/30

build the constant terme if it exists

build a new vecteur if there is not constant term

build a new vecteur if there is not constant term

Definition at line 693 of file reindexing_utils.c.

699 {
700  Pvecteur vect, pv = NULL;
701  Pcontrainte cp, newpc = NULL;
702  int i, j;
703  Value cst, coeff, dena, denb, ppc;
704  bool found;
705  list lnew = gen_nreverse(base_to_list(new_base));
706  entity ent;
707 
708  int n= MATRIX_NB_LINES(A);
709  int m1 = MATRIX_NB_COLUMNS(A);
710  int m2 = MATRIX_NB_COLUMNS(B);
711  dena = MATRIX_DENOMINATOR(A);
712  denb = MATRIX_DENOMINATOR(B);
713 
714  ppc = ppcm(dena, denb);
715 
716  for (i = n; i >= 1; i--)
717  {
718  found = false;
719  cp = contrainte_new();
720 
721  /* build the constant terme if it exists */
722  if (value_notzero_p(cst = MATRIX_ELEM(B,i,m2)))
723  {
724  Value x = value_mult(ppc,cst);
725  value_division(x, denb);
726  pv = vect_new(TCST, x);
727  found = true;
728  }
729 
730  vect = index_base;
731  for (j = 1; j <= m1; vect = vect->succ, j++)
732  {
733  if (value_notzero_p(coeff = MATRIX_ELEM(A,i,j)))
734  {
735  Value x = value_div(ppc,dena);
736  value_product(x,coeff);
737  if (found)
738  vect_chg_coeff(&pv, vecteur_var(vect), x);
739  else
740  {
741  /* build a new vecteur if there is not constant term */
742  pv = vect_new(vecteur_var(vect), x);
743  found = true;
744  }
745  }
746  }
747 
748  vect = const_base;
749  for (j = 1; j <= m2-1; vect = vect->succ, j++)
750  {
751  if (value_notzero_p(coeff = MATRIX_ELEM(B,i,j)))
752  {
753  Value x = value_div(ppc,denb);
754  value_product(x,coeff);
755  if (found)
756  vect_chg_coeff(&pv, vecteur_var(vect), x);
757  else
758  {
759  /* build a new vecteur if there is not constant term */
760  pv = vect_new(vecteur_var(vect), x);
761  found = true;
762  }
763  }
764  }
765 
766  ent = ENTITY(CAR(lnew));
767  pv = vect_substract(pv, vect_new((Variable) ent, ppc));
768  lnew = CDR(lnew);
769 
770  cp->vecteur = pv;
771  cp->succ = newpc;
772  newpc = cp;
773  }
774 
775  *pc = newpc;
776 }
#define value_notzero_p(val)
#define value_division(ref, val)
#define value_mult(v, w)
whether the default is protected or not this define makes no sense any more...
#define value_div(v1, v2)
Value ppcm(Value, Value)
ppcm.c
Definition: ppcm.c:42
Pcontrainte contrainte_new(void)
package contrainte - allocations et desallocations
Definition: alloc.c:47
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
#define MATRIX_DENOMINATOR(matrix)
int MATRIX_DENONIMATOR(matrix): acces au denominateur global d'une matrice matrix
Definition: matrix-local.h:86
Pvecteur cp
pointeur sur l'egalite ou l'inegalite courante
Definition: sc_read.c:87
static char * x
Definition: split_file.c:159
Pvecteur vect_substract(Pvecteur v1, Pvecteur v2)
Pvecteur vect_substract(Pvecteur v1, Pvecteur v2): allocation d'un vecteur v dont la valeur est la di...
Definition: binaires.c:75
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 B, base_to_list(), CAR, CDR, contrainte_new(), cp, ENTITY, gen_nreverse(), MATRIX_DENOMINATOR, MATRIX_ELEM, MATRIX_NB_COLUMNS, MATRIX_NB_LINES, ppcm(), Svecteur::succ, TCST, value_div, value_division, value_mult, value_notzero_p, value_product, vect_chg_coeff(), vect_new(), vect_substract(), vecteur_var, and x.

Referenced by build_third_comb(), include_trans_on_LC_in_ref(), include_trans_on_LC_in_sc(), include_trans_on_LC_in_sc2(), and prepare_reindexing().

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

◆ my_matrices_to_constraints_with_sym_cst_2()

void my_matrices_to_constraints_with_sym_cst_2 ( Pcontrainte pc,
Pbase  new_base,
Pbase  index_base,
Pbase  const_base,
Pmatrix  A,
Pmatrix  B 
)

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

void my_matrices_to_constraints_with_sym_cst_2(Pcontrainte *pc, Pbase index_base const_base, matrice A B,int n m1 m2):

constructs the constraints "pc" corresponding to the matrices "A" and "B" so: A.ib + B1.cb + B2 = nb <=> pc(nb, ib, cb) = 0, with:

 B = ( B1 | B2 ), B2 of dimension (n,1).

The basis "ib" gives the variables of the linear system. The basis "cb" gives the symbolic constants of the linear system. The basis "nb" gives the new variables of the linear system.

The matrices "A" and "B" are respectively of dimension (n, m1) and (n,m2).

"n" will be the exact number of constraints in "pc". "m1" must be the exact number of variables in "ib". "m2" must be equal to the number of symbolic constants (in "cb") PLUS ONE (the actual constant).

Note: the formal parameter pc is a "Pcontrainte *". Instead, the resulting Pcontrainte could have been returned as the result of this function.

TAKE CARE : new_base should be well ordered !!

AC 94/03/30

build the constant terme if it exists

build a new vecteur if there is not constant term

build a new vecteur if there is not constant term

Definition at line 806 of file reindexing_utils.c.

812 {
813  Pvecteur vect, pv = NULL;
814  Pcontrainte cp, newpc = NULL;
815  int i, j;
816  Value cst, coeff, dena, denb, ppc;
817  bool found;
818 
819  int n= MATRIX_NB_LINES(A);
820  int m1 = MATRIX_NB_COLUMNS(A);
821  int m2 = MATRIX_NB_COLUMNS(B);
822  dena = MATRIX_DENOMINATOR(A);
823  denb = MATRIX_DENOMINATOR(B);
824 
825  ppc = ppcm(dena, denb);
826 
827  for (i = n; i >= 1; i--)
828  {
829  found = false;
830  cp = contrainte_new();
831 
832  /* build the constant terme if it exists */
833  if (value_notzero_p(cst = MATRIX_ELEM(B,i,m2)))
834  {
835  Value x = value_div(ppc,denb);
836  value_product(x, cst);
837  pv = vect_new(TCST, x);
838  found = true;
839  }
840 
841  vect = index_base;
842  for (j = 1; j <= m1; vect = vect->succ, j++)
843  {
844  if (value_notzero_p(coeff = MATRIX_ELEM(A,i,j)))
845  {
846  Value x = value_div(ppc,dena);
847  value_product(x,coeff);
848  if (found)
849  vect_chg_coeff(&pv, vecteur_var(vect), x);
850  else
851  {
852  /* build a new vecteur if there is not constant term */
853  pv = vect_new(vecteur_var(vect), x);
854  found = true;
855  }
856  }
857  }
858 
859  vect = const_base;
860  for (j = 1; j <= m2-1; vect = vect->succ, j++)
861  {
862  if (value_notzero_p(coeff = MATRIX_ELEM(B,i,j)))
863  {
864  Value x = value_div(ppc,denb);
865  value_product(x,coeff);
866  if (found)
867  vect_chg_coeff(&pv, vecteur_var(vect), x);
868  else
869  {
870  /* build a new vecteur if there is not constant term */
871  pv = vect_new(vecteur_var(vect), x);
872  found = true;
873  }
874  }
875  }
876 
877  cp->vecteur = pv;
878  cp->succ = newpc;
879  newpc = cp;
880  }
881 
882  *pc = newpc;
883 }

References B, contrainte_new(), cp, MATRIX_DENOMINATOR, MATRIX_ELEM, MATRIX_NB_COLUMNS, MATRIX_NB_LINES, ppcm(), Svecteur::succ, TCST, value_div, value_notzero_p, value_product, vect_chg_coeff(), vect_new(), vecteur_var, and x.

Referenced by make_reindex().

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

◆ print_detailed_ins()

void print_detailed_ins ( instruction  ins)

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

void print_detailed_ins(): the instruction is either a test or an unstructured.

AC 01/06/94

loop_normalize_of_unstructured(instruction_unstructured(ins));

Definition at line 417 of file reindexing_utils.c.

420 {
421  list l;
422  statement stat;
423  loop lp;
424 
425  switch (instruction_tag(ins))
426  {
428  {
429  fprintf(stderr,"\nC'est un block de statement :");
430  for (l = instruction_block(ins); l != NIL; l = CDR(l))
431  {
432  stat = STATEMENT(CAR(l));
434  }
435  fprintf(stderr,"\nFin du block");
436  break;
437  }
438 
439  case is_instruction_test:
440  {
441  fprintf(stderr,"\nC'est un test :");
442  fprintf(stderr,"\nTrue statement :");
444  test_true(instruction_test(ins))));
445  fprintf(stderr, "\nFin de la branche True");
446  fprintf(stderr,"\nFalse statement :");
449  fprintf(stderr,"\nFin du test.");
450  break;
451  }
452 
453  case is_instruction_loop:
454  {
455  fprintf(stderr,"\nC'est une boucle :");
456  lp = instruction_loop(ins);
457  fprint_loop(stderr, lp);
458  fprintf(stderr,"\nFin de boucle.");
459  break;
460  }
461 
462  case is_instruction_goto:
463  {
464  fprintf(stderr, "\nC'est une instruction goto ");
466  fprintf(stderr,"\nFin du goto");
467  break;
468  }
469 
470  case is_instruction_call:
471  {
472  fprintf(stderr, "\nC'est un call ");
473  fprint_call(stderr, instruction_call(ins));
474  fprintf(stderr, "\nFin du call");
475  break;
476  }
477 
479  {
480  fprintf(stderr,"\nC'est un unstructured ;");
481 /* loop_normalize_of_unstructured(instruction_unstructured(ins));*/
484  instruction_unstructured(ins))));
485  fprintf(stderr, "\nFin du unstructured");
486  break;
487  }
488  }
489 }
void fprint_call(FILE *fp, call ca)
=======================================================================
void fprint_loop(FILE *fp, loop lp)
=======================================================================
void print_detailed_ins(instruction ins)
======================================================================
#define unstructured_control
After the modification in Newgen: unstructured = entry:control x exit:control we have create a macro ...
#define instruction_block(i)
#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 test_true(x)
Definition: ri.h:2835
#define control_statement(x)
Definition: ri.h:941
#define instruction_test(x)
Definition: ri.h:1517
#define instruction_unstructured(x)
Definition: ri.h:1532
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413

References CAR, CDR, control_statement, fprint_call(), fprint_loop(), fprintf(), instruction_block, instruction_call, instruction_goto, instruction_loop, instruction_tag, instruction_test, instruction_unstructured, is_instruction_block, is_instruction_call, is_instruction_goto, is_instruction_loop, is_instruction_test, is_instruction_unstructured, NIL, sa_print_ins(), STATEMENT, statement_instruction, test_false, test_true, and unstructured_control.

Referenced by re_do_it().

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

◆ psystem_to_expression()

expression psystem_to_expression ( Psysteme  ps)

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

expression psystem_to_expression(predicate pred): function that transforms a predicate into an expression. Function that comes from single_assign.c but I have modified it to include the case where pred is NULL.

AC 94/06/24

Definition at line 134 of file reindexing_utils.c.

136 {
137  entity and_ent, leq_ent, equ_ent;
138  expression exp1 = expression_undefined, exp2;
139  Pcontrainte pc;
140 
141  if (SC_UNDEFINED_P(ps))
142  return(int_to_expression(0));
143  else {
146  entity_domain);
149  entity_domain);
152  entity_domain);
153 
154  if( (and_ent == entity_undefined) || (leq_ent == entity_undefined) ||
155  (equ_ent == entity_undefined) ) {
156  pips_internal_error("There is no entity for operators");
157  }
158 
159  for(pc = ps->inegalites; pc!=NULL; pc = pc->succ) {
160  Pvecteur pv = pc->vecteur;
162  exp2 = MakeBinaryCall(leq_ent, exp, int_to_expression(0));
163 
164  if(exp1 == expression_undefined) exp1 = exp2;
165  else exp1 = MakeBinaryCall(and_ent, exp1, exp2);
166  }
167 
168  for(pc = ps->egalites; pc!=NULL; pc = pc->succ) {
169  Pvecteur pv = pc->vecteur;
170  exp2 = MakeBinaryCall(equ_ent, make_vecteur_expression(pv),
171  int_to_expression(0));
172  if(exp1 == expression_undefined) exp1 = exp2;
173  else exp1 = MakeBinaryCall(and_ent, exp1, exp2);
174  }
175 
176  if (get_debug_level() > 7) {
177  fprintf(stderr, "\t[predicate_to_expression] Result: %s\n",
178  expression_to_string(exp1));
179  }
180 
181  return(exp1);
182  }
183 }
string make_entity_fullname(const char *module_name, const char *local_name)
END_EOLE.
Definition: entity_names.c:230
#define TOP_LEVEL_MODULE_NAME
Module containing the global variables in Fortran and C.
Definition: naming-local.h:101
string expression_to_string(expression e)
Definition: expression.c:77
#define EQUAL_OPERATOR_NAME
#define AND_OPERATOR_NAME
FI: intrinsics are defined at a third place after bootstrap and effects! I guess the name should be d...
#define LESS_OR_EQUAL_OPERATOR_NAME
expression make_vecteur_expression(Pvecteur pv)
make expression for vector (Pvecteur)
Definition: expression.c:1650
expression MakeBinaryCall(entity f, expression eg, expression ed)
Creates a call expression to a function with 2 arguments.
Definition: expression.c:354
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

References AND_OPERATOR_NAME, entity_domain, entity_undefined, EQUAL_OPERATOR_NAME, exp, expression_to_string(), expression_undefined, fprintf(), gen_find_tabulated(), get_debug_level(), int_to_expression(), LESS_OR_EQUAL_OPERATOR_NAME, make_entity_fullname(), make_vecteur_expression(), MakeBinaryCall(), pips_internal_error, Scontrainte::succ, TOP_LEVEL_MODULE_NAME, and Scontrainte::vecteur.

+ Here is the call graph for this function:

◆ remove_minmax()

list remove_minmax ( list  le)

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

list remove_minmax(list le)

Parameters:

Result:

AP 95/02/1

Definition at line 1322 of file reindexing_utils.c.

1324 {
1325  list res_l = NIL, lle;
1326 
1327  for(lle = le; !ENDP(lle); POP(lle)) {
1328  expression exp = EXPRESSION(CAR(lle));
1329  normalized nor;
1330 
1331  ifdebug(9) {
1332  pips_debug(9, "considering expression:\n");
1334  }
1335 
1336  nor = NORMALIZE_EXPRESSION(exp);
1337 
1340 
1341  if(syntax_tag(sy) == is_syntax_call) {
1342 
1343  call ca = syntax_call(sy);
1345  res_l = remove_minmax(call_arguments(ca));
1346  else
1347  pips_internal_error("A complex exp is not a call to MIN or MAX: %s",
1348  expressio`n_to_string(exp));
1349  }
1350  else
1351  pips_internal_error("A complex exp is not a call : %s",
1353  }
1354  else
1356  }
1357 
1358  return(res_l);
1359 }
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
void print_expression(expression e)
no file descriptor is passed to make is easier to use in a debugging stage.
Definition: expression.c:58
list remove_minmax(list le)
=====================================================================
#define NORMALIZE_EXPRESSION(e)
#define normalized_tag(x)
Definition: ri.h:1778
@ is_normalized_complex
Definition: ri.h:1761
#define ifdebug(n)
Definition: sg.c:47

References ADD_ELEMENT_TO_LIST, call_arguments, call_function, CAR, ENDP, ENTITY_MIN_OR_MAX_P, exp, EXPRESSION, expression_syntax, expression_to_string(), ifdebug, is_normalized_complex, is_syntax_call, NIL, NORMALIZE_EXPRESSION, normalized_tag, pips_debug, pips_internal_error, POP, print_expression(), syntax_call, and syntax_tag.

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

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

◆ reverse_psyslist()

Psyslist reverse_psyslist ( Psyslist  l)

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

Psyslist reverse_psyslist(l): reverse the psyslist l.

AC 94/06/29

Definition at line 103 of file reindexing_utils.c.

106 {
107  Psyslist next, next_next;
108 
109  if( l == NULL || l->succ == NULL ) return(l) ;
110 
111  next = l->succ;
112  l->succ = NULL ;
113  next_next = SUCC(next);
114 
115  for( ; next != NULL ; )
116  {
117  next->succ = l;
118  l = next ;
119  next = next_next ;
120  next_next = SUCC(next_next);
121  }
122 
123  return(l) ;
124 }
#define SUCC(cp)

References Ssyslist::succ, and SUCC.

Referenced by separate_variables_2().

+ Here is the caller graph for this function:

◆ sc_add_egalite_at_end()

Psysteme sc_add_egalite_at_end ( Psysteme  ps,
Pcontrainte  co 
)

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

Psysteme sc_add_egalite_at_end(ps, co): idem "sc_add_egalite()" except that it puts the new constraint at the end of the list of constraints.

The system basis is not updated. ps may be inconsistent on return.

AC 94/03/17

Definition at line 582 of file reindexing_utils.c.

583 {
584  Pcontrainte co_aux;
585 
586  if (ps->egalites == NULL) ps->egalites = co;
587  else
588  {
589  for (co_aux = ps->egalites; co_aux->succ != NULL; co_aux = co_aux->succ) ;
590  co_aux->succ = co;
591  }
592  ps->nb_eq++;
593 
594  return ps;
595 }

References Ssysteme::egalites, Ssysteme::nb_eq, and Scontrainte::succ.

Referenced by build_list_of_min(), make_reindex(), matrix_to_system(), and prepare_reindexing().

+ Here is the caller graph for this function:

◆ sc_reverse_constraints()

Psysteme sc_reverse_constraints ( Psysteme  ps)

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

Psysteme sc_reverse_constraints(ps): reverse the list of equalities and inequalities in the system ps.

AC 94/03/17

Definition at line 934 of file reindexing_utils.c.

937 {
938  Pcontrainte pc1, pc2;
939 
940  pc2 = NULL;
941 
942  while (ps->egalites != NULL)
943  {
944  pc1 = ps->egalites;
945  ps->egalites = (ps->egalites)->succ;
946  pc1->succ = pc2;
947  pc2 = pc1;
948  }
949  ps->egalites = pc2;
950  pc2 = NULL;
951 
952  while (ps->inegalites != NULL)
953  {
954  pc1 = ps->inegalites;
955  ps->inegalites = (ps->inegalites)->succ;
956  pc1->succ = pc2;
957  pc2 = pc1;
958  }
959  ps->inegalites = pc2;
960 
961  return(ps);
962 }

References Scontrainte::succ.

Referenced by prepare_reindexing().

+ Here is the caller graph for this function:

◆ vars_in_vect_p()

bool vars_in_vect_p ( Pvecteur  pv,
list  vars 
)

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

bool vars_in_vect_p(Pvecteur pv, list vars):

returns true if the vector "vec" contains at least one of the variables of "vars". Else, returns FALSE.

Definition at line 970 of file reindexing_utils.c.

973 {
974  bool no_var = true;
975  list lv;
976 
977  if(!VECTEUR_NUL_P(pv)) {
978  for(lv = vars; !ENDP(lv) && no_var; POP(lv)) {
979  entity cv = ENTITY(CAR(lv));
980 
981  if(value_notzero_p(vect_coeff((Variable) cv, pv)))
982  no_var = false;
983  }
984  }
985  return(! no_var);
986 }

References CAR, ENDP, ENTITY, POP, value_notzero_p, vect_coeff(), and VECTEUR_NUL_P.

Referenced by cmf_layout_align(), craft_layout_align(), and prepare_reindexing().

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