PIPS
phrase_remove_dependences.c File Reference
#include <stdio.h>
#include <ctype.h>
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "effects.h"
#include "resources.h"
#include "misc.h"
#include "ri-util.h"
#include "prettyprint.h"
#include "effects-util.h"
#include "pipsdbm.h"
#include "text-util.h"
#include "ray_dte.h"
#include "sommet.h"
#include "sg.h"
#include "polyedre.h"
#include "control.h"
#include "phrase_tools.h"
#include "effects-generic.h"
#include "effects-simple.h"
#include "effects-convex.h"
#include "phrase_distribution.h"
#include "comEngine.h"
#include "phrase.h"
+ Include dependency graph for phrase_remove_dependences.c:

Go to the source code of this file.

Functions

static bool vect_same_variables_p (Pvecteur v1, Pvecteur v2)
 
static bool loop_index_in_several_indices (entity index, reference ref)
 
static int get_const_off (entity index, reference ref)
 
static int get_const_diff (Pvecteur vect1, Pvecteur vect2)
 
static bool write_conf_on_ref (reference ref)
 
static void phrase_check_reference (reference ref)
 
static list create_new_ent_list (int minOff, int maxOff, entity oldEnt)
 
static void replace_ref_by_ent (list lRef, list lNewEnt, entity index, int max)
 
static list make_lInitStats (list lInitStats, reference maxOffRef, list lNewEnt, entity loopInd, expression indInit)
 
static list make_lSwitchStats (list lSwitchStats, reference maxOffRef, list lNewEnt, int diff, entity loopInd)
 
static list remove_write_ref (list lRef)
 
static void phrase_remove_dependences_rwt (statement stat)
 
bool phrase_remove_dependences (const char *module_name)
 phrase_remove_dependences.c More...
 

Variables

static hash_table gRefTolRef
 
static entity gIndex
 
static statement gBody
 
static list gLConflicts
 

Function Documentation

◆ create_new_ent_list()

static list create_new_ent_list ( int  minOff,
int  maxOff,
entity  oldEnt 
)
static

Definition at line 329 of file phrase_remove_dependences.c.

331 {
332  list lNewEnt = NIL;
333  int i;
334 
335  for(i = minOff; i <= maxOff; i++)
336  {
337  entity keyEnt = oldEnt;
338 
339  entity newEnt =
342  entity_basic(keyEnt));
343  AddEntityToCurrentModule(newEnt);
344 
345  lNewEnt = gen_nconc(lNewEnt, CONS(ENTITY, newEnt, NIL));
346  }
347 
348  return lNewEnt;
349 }
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
#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
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
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
basic entity_basic(entity e)
return the basic associated to entity e if it's a function/variable/constant basic_undefined otherwis...
Definition: entity.c:1380
void AddEntityToCurrentModule(entity)
Add a variable entity to the current module declarations.
Definition: variable.c:260
entity make_new_scalar_variable_with_prefix(const char *, entity, basic)
Create a new scalar variable of type b in the given module.
Definition: variable.c:592
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References AddEntityToCurrentModule(), CONS, ENTITY, entity_basic(), entity_local_name(), gen_nconc(), get_current_module_entity(), make_new_scalar_variable_with_prefix(), and NIL.

Referenced by phrase_remove_dependences_rwt().

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

◆ get_const_diff()

static int get_const_diff ( Pvecteur  vect1,
Pvecteur  vect2 
)
static

Definition at line 155 of file phrase_remove_dependences.c.

156 {
157  int coeff1 = vect_coeff((Variable) TCST, vect1);
158  int coeff2 = vect_coeff((Variable) TCST, vect2);
159 
160  return (coeff2 - coeff1);
161 }
#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
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 TCST, and vect_coeff().

Referenced by phrase_check_reference().

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

◆ get_const_off()

static int get_const_off ( entity  index,
reference  ref 
)
static

Definition at line 131 of file phrase_remove_dependences.c.

132 {
133  MAP(EXPRESSION, ind,
134  {
136 
138  {
140 
141  int coeff = vect_coeff((Variable) index, vect);
142 
143  if(coeff != 0)
144  {
145  return vect_coeff((Variable) TCST, vect);
146  }
147 
148  }
149 
150  }, reference_indices(ref));
151 
152  return 0;
153 }
static reference ref
Current stmt (an integer)
Definition: adg_read_paf.c:163
#define MAP(_map_CASTER, _map_item, _map_code, _map_list)
Apply/map an instruction block on all the elements of a list (old fashioned)
Definition: newgen_list.h:226
static void norm(struct rproblem *RR)
cette procedure normalise la fonction cout, calcule les valeurs des seconds membres resultant d'une n...
Definition: r1.c:271
#define NORMALIZE_EXPRESSION(e)
#define normalized_linear_p(x)
Definition: ri.h:1779
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define reference_indices(x)
Definition: ri.h:2328
#define normalized_linear(x)
Definition: ri.h:1781
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89

References EXPRESSION, MAP, norm(), NORMALIZE_EXPRESSION, normalized_linear, normalized_linear_p, ref, reference_indices, TCST, and vect_coeff().

Referenced by phrase_check_reference(), phrase_remove_dependences_rwt(), and replace_ref_by_ent().

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

◆ loop_index_in_several_indices()

static bool loop_index_in_several_indices ( entity  index,
reference  ref 
)
static

Definition at line 95 of file phrase_remove_dependences.c.

96 {
97  bool loopIndFound = false;
98 
99  MAP(EXPRESSION, ind,
100  {
102 
104  {
106 
107  int coeff = vect_coeff((Variable) index, vect);
108 
109  if((coeff != 0) &&
110  (!loopIndFound))
111  {
112  loopIndFound = true;
113  }
114  else if((coeff != 0) &&
115  loopIndFound)
116  {
117  return true;
118  }
119 
120  }
121  else
122  {
123  return true;
124  }
125 
126  }, reference_indices(ref));
127 
128  return false;
129 }

References EXPRESSION, MAP, norm(), NORMALIZE_EXPRESSION, normalized_linear, normalized_linear_p, ref, reference_indices, and vect_coeff().

Referenced by phrase_check_reference().

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

◆ make_lInitStats()

static list make_lInitStats ( list  lInitStats,
reference  maxOffRef,
list  lNewEnt,
entity  loopInd,
expression  indInit 
)
static

Definition at line 391 of file phrase_remove_dependences.c.

393 {
394  int count = 0;
395 
396  printf("maxOffRef\n");
397  print_reference(maxOffRef); printf("\n");
398 
399  MAP(ENTITY, newEnt,
400  {
403 
406  copy_expression(indInit),
407  NULL);
408 
410  addArg));
411 
413  make_reference(loopInd, NIL),
414  addExp);
415 
416  print_statement(newStat);
417 
418  lInitStats = gen_nconc(lInitStats, CONS(STATEMENT, newStat, NIL));
419 
420  count--;
421  }, lNewEnt);
422 
423  return lInitStats;
424 }
call make_call(entity a1, list a2)
Definition: ri.c:269
expression copy_expression(expression p)
EXPRESSION.
Definition: ri.c:850
reference make_reference(entity a1, list a2)
Definition: ri.c:2083
reference copy_reference(reference p)
REFERENCE.
Definition: ri.c:2047
static int count
Definition: SDG.c:519
void comEngine_replace_reference_in_stat(statement stat, reference ref, expression new)
list gen_make_list(int domain,...)
Definition: list.c:851
statement make_assign_statement(expression, expression)
Definition: statement.c:583
void print_reference(reference r)
Definition: expression.c:142
void print_statement(statement)
Print a statement on stderr.
Definition: statement.c:98
#define PLUS_OPERATOR_NAME
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
Definition: entity.c:1292
expression reference_to_expression(reference r)
Definition: expression.c:196
expression entity_to_expression(entity e)
if v is a constant, returns a constant call.
Definition: expression.c:165
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
expression call_to_expression(call c)
Build an expression that call a function or procedure.
Definition: expression.c:309
#define expression_domain
newgen_execution_domain_defined
Definition: ri.h:154
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
int printf()

References call_to_expression(), comEngine_replace_reference_in_stat(), CONS, copy_expression(), copy_reference(), count, ENTITY, entity_intrinsic(), entity_to_expression(), expression_domain, gen_make_list(), gen_nconc(), int_to_expression(), make_assign_statement(), make_call(), make_reference(), MAP, NIL, PLUS_OPERATOR_NAME, print_reference(), print_statement(), printf(), reference_to_expression(), and STATEMENT.

Referenced by phrase_remove_dependences_rwt().

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

◆ make_lSwitchStats()

static list make_lSwitchStats ( list  lSwitchStats,
reference  maxOffRef,
list  lNewEnt,
int  diff,
entity  loopInd 
)
static

Definition at line 426 of file phrase_remove_dependences.c.

428 {
429  int i;
430 
431  printf("maxOffRef\n");
432  print_reference(maxOffRef); printf("\n");
433 
434  for(i = diff; i > 0; i--)
435  {
436  entity newEnt1 = ENTITY(gen_nth(i, lNewEnt));
437  entity newEnt2 = ENTITY(gen_nth(i - 1, lNewEnt));
438 
440  entity_to_expression(newEnt2));
441 
442  print_statement(newStat);
443 
444  lSwitchStats = gen_nconc(lSwitchStats, CONS(STATEMENT, newStat, NIL));
445 
446  }
447 
450 
452  entity_to_expression(loopInd),
454  NULL);
455 
457  addArg));
458 
460  make_reference(loopInd, NIL),
461  addExp);
462 
463  print_statement(newStat);
464 
465  lSwitchStats = gen_nconc(lSwitchStats, CONS(STATEMENT, newStat, NIL));
466 
467  return lSwitchStats;
468 }
gen_chunk gen_nth(int n, const list l)
to be used as ENTITY(gen_nth(3, l))...
Definition: list.c:710

References call_to_expression(), comEngine_replace_reference_in_stat(), CONS, copy_reference(), ENTITY, entity_intrinsic(), entity_to_expression(), expression_domain, gen_make_list(), gen_nconc(), gen_nth(), int_to_expression(), make_assign_statement(), make_call(), make_reference(), NIL, PLUS_OPERATOR_NAME, print_reference(), print_statement(), printf(), reference_to_expression(), and STATEMENT.

Referenced by phrase_remove_dependences_rwt().

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

◆ phrase_check_reference()

static void phrase_check_reference ( reference  ref)
static

Definition at line 190 of file phrase_remove_dependences.c.

191 {
192  if(gen_length(reference_indices(ref)) == 0)
193  {
194  return;
195  }
196 
197  bool bRefPut = false;
198 
200 
201  MAP(REFERENCE, indRef,
202  {
203  if(code_has_write_eff_ref_p(indRef, gBody))
204  {
205  gen_free_list(lIndRef);
206  return;
207  }
208 
209  }, lIndRef);
210 
211  gen_free_list(lIndRef);
212 
214  {
215  return;
216  }
217 
218  bool bReplaceKeyRef = false;
219 
220  HASH_MAP(par1, par2,
221  {
222  reference keyRef = (reference) par1;
223  list lRef = (list) par2;
224 
225  if(!same_entity_p(reference_variable(keyRef),
227  {
228  continue;
229  }
230 
231  bool success = true;
232 
233  list pInd2 = reference_indices(ref);
234  expression ind2;
235 
236  MAP(EXPRESSION, ind1,
237  {
238  ind2 = EXPRESSION(CAR(pInd2));
239 
240  normalized norm1 = NORMALIZE_EXPRESSION(ind1);
241  normalized norm2 = NORMALIZE_EXPRESSION(ind2);
242 
243  if(normalized_linear_p(norm1) &&
244  normalized_linear_p(norm2))
245  {
246  Pvecteur vect1 = normalized_linear(norm1);
247  Pvecteur vect2 = normalized_linear(norm2);
248 
249  if(vect_same_variables_p(vect1, vect2))
250  {
251  int diff = get_const_diff(vect1, vect2);
252 
253  if(diff > 0)
254  {
255  bReplaceKeyRef = true;
256  }
257 
258  if((diff >= 10) ||
259  (diff <= -10))
260  {
261  success = false;
262  break;
263  }
264  }
265  else
266  {
267  success = false;
268  break;
269  }
270  }
271  else
272  {
273  success = false;
274  break;
275  }
276 
277  pInd2 = CDR(pInd2);
278 
279  }, reference_indices(keyRef));
280 
281  if(success)
282  {
283  int refOff = get_const_off(gIndex, ref);
284 
285  bool refPut = false;
286 
287  MAP(REFERENCE, curRef,
288  {
289  int curOff = get_const_off(gIndex, curRef);
290 
291  if(refOff > curOff)
292  {
293  lRef = gen_insert_before(ref, curRef, lRef);
294  refPut = true;
295  break;
296  }
297 
298  }, lRef);
299 
300  if(!refPut)
301  {
302  lRef = gen_nconc(lRef, CONS(REFERENCE, ref, NIL));
303  }
304 
305  if(!bReplaceKeyRef)
306  {
307  hash_put(gRefTolRef, keyRef, lRef);
308  }
309  else
310  {
311  hash_del(gRefTolRef, keyRef);
312 
313  hash_put(gRefTolRef, ref, lRef);
314  }
315 
316  bRefPut = true;
317 
318  break;
319  }
320 
321  }, gRefTolRef);
322 
323  if(!bRefPut)
324  {
326  }
327 }
list reference_indices_entity_list(reference ref)
bool code_has_write_eff_ref_p(reference ref, statement stat)
struct _newgen_struct_reference_ * reference
Definition: compsec.h:14
bool success
Definition: gpips-local.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
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
list gen_insert_before(const void *no, const void *o, list l)
Definition: list.c:238
void hash_put(hash_table htp, const void *key, const void *val)
This functions stores a couple (key,val) in the hash table pointed to by htp.
Definition: hash.c:364
void * hash_del(hash_table htp, const void *key)
this function removes from the hash table pointed to by htp the couple whose key is equal to key.
Definition: hash.c:439
#define HASH_MAP(k, v, code, ht)
Definition: newgen_hash.h:60
struct cons * list
Definition: newgen_types.h:106
static bool loop_index_in_several_indices(entity index, reference ref)
static statement gBody
static entity gIndex
static int get_const_diff(Pvecteur vect1, Pvecteur vect2)
static int get_const_off(entity index, reference ref)
static bool vect_same_variables_p(Pvecteur v1, Pvecteur v2)
static hash_table gRefTolRef
bool same_entity_p(entity e1, entity e2)
predicates on entities
Definition: entity.c:1321
#define REFERENCE(x)
REFERENCE.
Definition: ri.h:2296
#define reference_variable(x)
Definition: ri.h:2326

References CAR, CDR, code_has_write_eff_ref_p(), CONS, EXPRESSION, gBody, gen_free_list(), gen_insert_before(), gen_length(), gen_nconc(), get_const_diff(), get_const_off(), gIndex, gRefTolRef, hash_del(), HASH_MAP, hash_put(), loop_index_in_several_indices(), MAP, NIL, NORMALIZE_EXPRESSION, normalized_linear, normalized_linear_p, ref, REFERENCE, reference_indices, reference_indices_entity_list(), reference_variable, same_entity_p(), and vect_same_variables_p().

Referenced by phrase_remove_dependences_rwt().

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

◆ phrase_remove_dependences()

bool phrase_remove_dependences ( const char *  module_name)

phrase_remove_dependences.c

Get the code of the module.

Parameters
module_nameodule_name

Definition at line 603 of file phrase_remove_dependences.c.

604 {
605  statement module_stat;
606 
607  /* Get the code of the module. */
610  db_get_memory_resource(DBR_CODE, module_name, true) );
611  module_stat = get_current_module_statement();
613  db_get_memory_resource(DBR_CUMULATED_EFFECTS, module_name, true));
614 
615  debug_on("SIMD_LOOP_CONST_ELIM_SCALAR_EXPANSION_DEBUG_LEVEL");
616 
617  graph dg = (graph) db_get_memory_resource(DBR_DG, module_name, true);
618 
619  gLConflicts = NIL;
620 
621  MAP(VERTEX, a_vertex,
622  {
623  MAP(SUCCESSOR, suc,
624  {
625  MAP(CONFLICT, c,
626  {
627 
629 
631 
632  }, vertex_successors(a_vertex));
633 
634  },graph_vertices(dg));
635 
637 
638  // Go through all the statements
639  gen_recurse(module_stat, statement_domain,
641 
643 
644  pips_assert("Statement is consistent after SIMD_SCALAR_EXPANSION",
645  statement_consistent_p(module_stat));
646 
647  module_reorder(module_stat);
648  DB_PUT_MEMORY_RESOURCE(DBR_CODE, module_name, module_stat);
649 
650  debug_off();
651 
655 
656  return true;
657 }
bool statement_consistent_p(statement p)
Definition: ri.c:2195
static graph dg
dg is the dependency graph ; FIXME : should not be static global ?
Definition: chains.c:124
#define CONFLICT(x)
CONFLICT.
Definition: dg.h:134
#define dg_arc_label_conflicts(x)
Definition: dg.h:201
void set_cumulated_rw_effects(statement_effects)
void reset_cumulated_rw_effects(void)
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
#define gen_recurse(start, domain_number, flt, rwt)
Definition: genC.h:283
#define successor_arc_label(x)
Definition: graph.h:116
struct _newgen_struct_graph_ * graph
Definition: graph.h:31
#define vertex_successors(x)
Definition: graph.h:154
#define SUCCESSOR(x)
SUCCESSOR.
Definition: graph.h:86
#define graph_vertices(x)
Definition: graph.h:82
#define VERTEX(x)
VERTEX.
Definition: graph.h:122
void reset_current_module_entity(void)
Reset the current module entity.
Definition: static.c:97
void reset_current_module_statement(void)
Reset the current module statement.
Definition: static.c:221
statement set_current_module_statement(statement)
Set the current module statement.
Definition: static.c:165
statement get_current_module_statement(void)
Get the current module statement.
Definition: static.c:208
entity set_current_module_entity(entity)
static.c
Definition: static.c:66
bool gen_true(__attribute__((unused)) gen_chunk *unused)
Return true and ignore the argument.
Definition: genClib.c:2780
string db_get_memory_resource(const char *rname, const char *oname, bool pure)
Return the pointer to the resource, whatever it is.
Definition: database.c:755
#define DB_PUT_MEMORY_RESOURCE(res_name, own_name, res_val)
conform to old interface.
Definition: pipsdbm-local.h:66
void hash_dont_warn_on_redefinition(void)
Definition: hash.c:188
void hash_warn_on_redefinition(void)
these function set the variable should_i_warn_on_redefinition to the value true or false
Definition: hash.c:183
#define debug_on(env)
Definition: misc-local.h:157
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define debug_off()
Definition: misc-local.h:160
static void phrase_remove_dependences_rwt(statement stat)
static list gLConflicts
bool module_reorder(statement body)
Reorder a module and recompute order to statement if any.
Definition: reorder.c:244
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
Definition: entity.c:1479
#define statement_domain
newgen_sizeofexpression_domain_defined
Definition: ri.h:362

References CONFLICT, CONS, db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, dg, dg_arc_label_conflicts, gen_recurse, gen_true(), get_current_module_statement(), gLConflicts, graph_vertices, hash_dont_warn_on_redefinition(), hash_warn_on_redefinition(), MAP, module_name(), module_name_to_entity(), module_reorder(), NIL, phrase_remove_dependences_rwt(), pips_assert, reset_cumulated_rw_effects(), reset_current_module_entity(), reset_current_module_statement(), set_cumulated_rw_effects(), set_current_module_entity(), set_current_module_statement(), statement_consistent_p(), statement_domain, SUCCESSOR, successor_arc_label, VERTEX, and vertex_successors.

+ Here is the call graph for this function:

◆ phrase_remove_dependences_rwt()

static void phrase_remove_dependences_rwt ( statement  stat)
static

Definition at line 489 of file phrase_remove_dependences.c.

490 {
491  print_statement(stat);
492  if((statement_comments(stat) != string_undefined) &&
493  (statement_comments(stat) != NULL))
494  {
495  printf("%s", statement_comments(stat));
496  }
497  if(!statement_loop_p(stat))
498  {
499  return;
500  }
501 
502  printf("loop\n");
503  print_statement(stat);
504 
506 
507  loop curLoop = statement_loop(stat);
508 
509  entity loopInd = loop_index(curLoop);
510  statement body = loop_body(curLoop);
511  expression indInit = range_lower(loop_range(curLoop));
512 
513  gIndex = loopInd;
514  gBody = body;
515 
517 
518  list lInitStats = NIL;
519  list lSwitchStats = NIL;
520 
521  HASH_MAP(par1, par2,
522  {
523  reference keyRef = (reference) par1;
524  list lRef = (list) par2;
525 
526  list lNewEnt = NIL;
527 
528  int maxBefOff = get_const_off(loopInd, REFERENCE(CAR(lRef)));
529 
530  lRef = remove_write_ref(lRef);
531 
532  if(lRef == NIL)
533  {
534  continue;
535  }
536 
537  int maxOff = get_const_off(loopInd, REFERENCE(CAR(lRef)));
538 
539  int minOff = get_const_off(loopInd,
540  REFERENCE(CAR(gen_last(lRef))));
541 
542  if(minOff == maxBefOff)
543  {
544  gen_free_list(lRef);
545  continue;
546  }
547 
548  reference saveRef = copy_reference(REFERENCE(CAR(lRef)));
549 
550  printf("maxOff: %d\n", maxOff);
551  printf("minOff: %d\n", minOff);
552 
553  MAP(REFERENCE, curRef,
554  {
555  print_reference(curRef);printf("\n");
556  }, lRef);
557  printf("end\n");
558  lNewEnt = create_new_ent_list(minOff, maxOff,
559  reference_variable(keyRef));
560 
561  replace_ref_by_ent(lRef, lNewEnt, loopInd, maxOff);
562 
563  lInitStats = make_lInitStats(lInitStats, saveRef, lNewEnt,
564  loopInd, indInit);
565 
566  lSwitchStats = make_lSwitchStats(lSwitchStats, saveRef, lNewEnt,
567  (maxOff - minOff), loopInd);
568 
569  gen_free_list(lRef);
570 
571  }, gRefTolRef);
572 
573  HASH_MAP(par1, par2,
574  {
575  list lRef = (list) par2;
576 
577  gen_free_list(lRef);
578 
579  }, gRefTolRef);
580 
582 
584  lSwitchStats));
585 
586  loop_body(curLoop) = newBody;
587 
588  list lStats = gen_nconc(lInitStats, CONS(STATEMENT, copy_statement(stat), NIL));
589 
590  instruction newInstr = make_instruction_block(lStats);
591 
593 
595  {
596  free(statement_comments(stat));
598  }
599 
600  statement_instruction(stat) = newInstr;
601 }
statement copy_statement(statement p)
STATEMENT.
Definition: ri.c:2186
void free_instruction(instruction p)
Definition: ri.c:1118
void free(void *)
statement make_block_statement(list)
Make a block statement from a list of statement.
Definition: statement.c:616
instruction make_instruction_block(list statements)
Build an instruction block from a list of statements.
Definition: instruction.c:106
list gen_last(list l)
Return the last element of a list.
Definition: list.c:578
loop statement_loop(statement)
Get the loop of a statement.
Definition: statement.c:1374
bool statement_loop_p(statement)
Definition: statement.c:349
hash_table hash_table_make(hash_key_type key_type, size_t size)
Definition: hash.c:294
void hash_table_free(hash_table htp)
this function deletes a hash table that is no longer useful.
Definition: hash.c:327
@ hash_pointer
Definition: newgen_hash.h:32
#define string_undefined
Definition: newgen_types.h:40
static list make_lSwitchStats(list lSwitchStats, reference maxOffRef, list lNewEnt, int diff, entity loopInd)
static list create_new_ent_list(int minOff, int maxOff, entity oldEnt)
static list make_lInitStats(list lInitStats, reference maxOffRef, list lNewEnt, entity loopInd, expression indInit)
static list remove_write_ref(list lRef)
static void phrase_check_reference(reference ref)
static void replace_ref_by_ent(list lRef, list lNewEnt, entity index, int max)
#define loop_body(x)
Definition: ri.h:1644
#define reference_domain
newgen_range_domain_defined
Definition: ri.h:338
#define range_lower(x)
Definition: ri.h:2288
#define statement_instruction(x)
Definition: ri.h:2458
#define statement_comments(x)
Definition: ri.h:2456
#define loop_range(x)
Definition: ri.h:1642
#define loop_index(x)
Definition: ri.h:1640

References CAR, CONS, copy_reference(), copy_statement(), create_new_ent_list(), free(), free_instruction(), gBody, gen_free_list(), gen_last(), gen_nconc(), gen_recurse, gen_true(), get_const_off(), gIndex, gRefTolRef, HASH_MAP, hash_pointer, hash_table_free(), hash_table_make(), loop_body, loop_index, loop_range, make_block_statement(), make_instruction_block(), make_lInitStats(), make_lSwitchStats(), MAP, NIL, phrase_check_reference(), print_reference(), print_statement(), printf(), range_lower, REFERENCE, reference_domain, reference_variable, remove_write_ref(), replace_ref_by_ent(), STATEMENT, statement_comments, statement_instruction, statement_loop(), statement_loop_p(), and string_undefined.

Referenced by phrase_remove_dependences().

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

◆ remove_write_ref()

static list remove_write_ref ( list  lRef)
static

Definition at line 470 of file phrase_remove_dependences.c.

471 {
472  list lOut = NIL;
473 
474  MAP(REFERENCE, curRef,
475  {
476  if(write_conf_on_ref(curRef))
477  {
478  continue;
479  }
480  printf("adddddddddddddddddddddddddddddd\n");
481  print_reference(curRef);printf("\n");
482  lOut = gen_nconc(lOut, CONS(REFERENCE, curRef, NIL));
483 
484  }, lRef);
485  printf("remove_write_ref done\n");
486  return lOut;
487 }
static bool write_conf_on_ref(reference ref)

References CONS, gen_nconc(), MAP, NIL, print_reference(), printf(), REFERENCE, and write_conf_on_ref().

Referenced by phrase_remove_dependences_rwt().

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

◆ replace_ref_by_ent()

static void replace_ref_by_ent ( list  lRef,
list  lNewEnt,
entity  index,
int  max 
)
static

Definition at line 351 of file phrase_remove_dependences.c.

353 {
354  list pCurRef = lRef;
355  int count = max;
356 
357  MAP(ENTITY, newEnt,
358  {
359  reference curRef = REFERENCE(CAR(pCurRef));
360 
361  int curOff = get_const_off(index, curRef);
362 
363  if(count == curOff)
364  {
365  MAPL(pSameRef,
366  {
367  reference sameRef = REFERENCE(CAR(pSameRef));
368 
369  int sameOff = get_const_off(index, sameRef);
370 
371  if(sameOff != curOff)
372  {
373  pCurRef = pSameRef;
374  break;
375  }
376 
378 
379  reference_indices(sameRef) = NIL;
380 
381  reference_variable(sameRef) = newEnt;
382 
383  }, pCurRef);
384 
385  }
386 
387  count--;
388  }, lNewEnt);
389 }
#define max(a, b)
#define MAPL(_map_list_cp, _code, _l)
Apply some code on the addresses of all the elements of a list.
Definition: newgen_list.h:203

References CAR, count, ENTITY, gen_free_list(), get_const_off(), MAP, MAPL, max, NIL, REFERENCE, reference_indices, and reference_variable.

Referenced by phrase_remove_dependences_rwt().

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

◆ vect_same_variables_p()

static bool vect_same_variables_p ( Pvecteur  v1,
Pvecteur  v2 
)
static

Definition at line 68 of file phrase_remove_dependences.c.

69 {
70  Pvecteur ev;
71 
72  bool sameVars = true;
73 
74  for(ev = v1; !VECTEUR_NUL_P(ev); ev = ev->succ)
75  {
76  if(vecteur_var(ev) == TCST)
77  continue;
78 
80  sameVars = false;
81  }
82 
83  for(ev = v2; !VECTEUR_NUL_P(ev); ev = ev->succ)
84  {
85  if(vecteur_var(ev) == TCST)
86  continue;
87 
89  sameVars = false;
90  }
91 
92  return sameVars;
93 }
struct Svecteur * succ
Definition: vecteur-local.h:92
#define vecteur_var(v)
#define VECTEUR_NUL_P(v)
bool vect_contains_variable_p(Pvecteur v, Variable var)
bool vect_contains_variable_p(Pvecteur v, Variable var) BA 19/05/94 input : a vector and a variable o...
Definition: unaires.c:415

References Svecteur::succ, TCST, vect_contains_variable_p(), VECTEUR_NUL_P, and vecteur_var.

Referenced by phrase_check_reference().

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

◆ write_conf_on_ref()

static bool write_conf_on_ref ( reference  ref)
static

Definition at line 163 of file phrase_remove_dependences.c.

164 {
165  printf("ref\n");
166  print_reference(ref);printf("\n");
167  MAP(CONFLICT, conf,
168  {
169  effect sourceEff = conflict_source(conf);
170  effect sinkEff = conflict_sink(conf);
171 
172  reference sourceRef = effect_any_reference(sourceEff);
173  reference sinkRef = effect_any_reference(sinkEff);
174 
175  if((effect_write_p(sourceEff) &&
176  sourceRef == ref) ||
177  (effect_write_p(sinkEff) &&
178  sinkRef == ref))
179  {
180  printf("write ref\n");
181  return true;
182  }
183 
184  }, gLConflicts);
185 
186  printf("not write ref\n");
187  return false;
188 }
#define conflict_sink(x)
Definition: dg.h:167
#define conflict_source(x)
Definition: dg.h:165
#define effect_any_reference(e)
FI: cannot be used as a left hand side.
#define effect_write_p(eff)

References CONFLICT, conflict_sink, conflict_source, effect_any_reference, effect_write_p, gLConflicts, MAP, print_reference(), printf(), and ref.

Referenced by remove_write_ref().

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

Variable Documentation

◆ gBody

statement gBody
static

◆ gIndex

entity gIndex
static

◆ gLConflicts

list gLConflicts
static

Definition at line 66 of file phrase_remove_dependences.c.

Referenced by phrase_remove_dependences(), and write_conf_on_ref().

◆ gRefTolRef

hash_table gRefTolRef
static