PIPS
alias_lists.c File Reference
#include <stdio.h>
#include <string.h>
#include <setjmp.h>
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "effects.h"
#include "ri-util.h"
#include "effects-util.h"
#include "misc.h"
#include "effects-generic.h"
#include "effects-convex.h"
#include "semantics.h"
#include "transformer.h"
#include "pipsdbm.h"
+ Include dependency graph for alias_lists.c:

Go to the source code of this file.

Functions

static bool same_reg (region reg1, region reg2)
 tests if reg1 and reg2 are the same, including same action_tags (IN/OUT) and precision (may/exact) More...
 
static void add_unmatched_alias_pairs ()
 global variables IN: unmatched_alias_pairs, l_alias_lists modifies global variable: l_alias_lists More...
 
static bool compare_matched_alias_pairs (bool result, region alias_list_reg, list callee_alias_list)
 global variables IN: matched_alias_pairs, l_alias_lists modifies global variable: l_alias_lists More...
 
static bool compare_unmatched_alias_pairs (region alias_list_reg, list callee_alias_list)
 global variables IN: matched_alias_pairs, unmatched_alias_pairs, l_alias_lists modifies global variables: matched_alias_pairs, unmatched_alias_pairs, l_alias_lists More...
 
static void add_alias_lists_callee (string callee_name)
 global variables IN: matched_alias_pairs, unmatched_alias_pairs, l_alias_lists modifies global variables: matched_alias_pairs, unmatched_alias_pairs, l_alias_lists More...
 
static void add_alias_lists_callees (const char *module_name)
 global variables IN: unmatched_alias_pairs, l_alias_lists modifies global variables: matched_alias_pairs, unmatched_alias_pairs, l_alias_lists More...
 
bool alias_lists (const string module_name)
 modifies global variables: matched_alias_pairs, unmatched_alias_pairs, l_alias_lists More...
 

Variables

static list l_alias_lists
 
static list unmatched_alias_pairs
 
static list matched_alias_pairs
 

Function Documentation

◆ add_alias_lists_callee()

static void add_alias_lists_callee ( string  callee_name)
static

global variables IN: matched_alias_pairs, unmatched_alias_pairs, l_alias_lists modifies global variables: matched_alias_pairs, unmatched_alias_pairs, l_alias_lists

Definition at line 250 of file alias_lists.c.

251 {
252  list callee_alias_lists;
253  bool result;
254  region alias_list_reg;
255 
256  pips_debug(4,"begin for callee %s\n",callee_name);
257 
258  callee_alias_lists =
260  db_get_memory_resource(DBR_ALIAS_LISTS,
261  callee_name,
262  true));
263  MAP(EFFECTS,callee_alias_list_effects,
264  {
265  list callee_alias_list =
266  effects_effects(callee_alias_list_effects);
267 
268  ifdebug(9)
269  {
270  pips_debug(9,"add list:\n");
271  print_inout_regions(callee_alias_list);
272  }
273 
274  if (callee_alias_list != NIL)
275  {
276  alias_list_reg = EFFECT(CAR(gen_last(callee_alias_list)));
277  result =
278  compare_unmatched_alias_pairs(alias_list_reg,
279  callee_alias_list);
280  result =
282  alias_list_reg,
283  callee_alias_list);
284  if (result == false)
285  l_alias_lists =
286  CONS(EFFECTS,
287  make_effects(regions_dup(callee_alias_list)),
288  l_alias_lists);
289  }
290  },callee_alias_lists);
291 
292  pips_debug(4,"end\n");
293 }
effects make_effects(list a)
Definition: effects.c:568
static list l_alias_lists
Definition: alias_lists.c:49
static bool compare_matched_alias_pairs(bool result, region alias_list_reg, list callee_alias_list)
global variables IN: matched_alias_pairs, l_alias_lists modifies global variable: l_alias_lists
Definition: alias_lists.c:135
static bool compare_unmatched_alias_pairs(region alias_list_reg, list callee_alias_list)
global variables IN: matched_alias_pairs, unmatched_alias_pairs, l_alias_lists modifies global variab...
Definition: alias_lists.c:186
#define region
simulation of the type region
list regions_dup(list)
void print_inout_regions(list)
#define EFFECTS(x)
EFFECTS.
Definition: effects.h:682
#define effects_effects(x)
Definition: effects.h:710
#define effects_classes_classes(x)
Definition: effects.h:678
#define EFFECT(x)
EFFECT.
Definition: effects.h:608
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
list gen_last(list l)
Return the last element of a list.
Definition: list.c:578
#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
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 pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define ifdebug(n)
Definition: sg.c:47
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References CAR, compare_matched_alias_pairs(), compare_unmatched_alias_pairs(), CONS, db_get_memory_resource(), EFFECT, EFFECTS, effects_classes_classes, effects_effects, gen_last(), ifdebug, l_alias_lists, make_effects(), MAP, NIL, pips_debug, print_inout_regions(), region, and regions_dup().

Referenced by add_alias_lists_callees().

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

◆ add_alias_lists_callees()

static void add_alias_lists_callees ( const char *  module_name)
static

global variables IN: unmatched_alias_pairs, l_alias_lists modifies global variables: matched_alias_pairs, unmatched_alias_pairs, l_alias_lists

Definition at line 303 of file alias_lists.c.

304 {
305  callees l_callees;
306 
307  pips_debug(4,"begin\n");
308 
310 
311  l_callees = (callees) db_get_memory_resource(DBR_CALLEES,
312  module_name,
313  true);
314 
315  MAP(STRING, callee_name,
316  {
317  add_alias_lists_callee(callee_name);
318  },callees_callees(l_callees));
319 
320  pips_debug(4,"end\n");
321 }
static void add_alias_lists_callee(string callee_name)
global variables IN: matched_alias_pairs, unmatched_alias_pairs, l_alias_lists modifies global variab...
Definition: alias_lists.c:250
static list matched_alias_pairs
Definition: alias_lists.c:51
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
#define STRING(x)
Definition: genC.h:87
struct _newgen_struct_callees_ * callees
Definition: ri.h:55
#define callees_callees(x)
Definition: ri.h:675

References add_alias_lists_callee(), callees_callees, db_get_memory_resource(), MAP, matched_alias_pairs, module_name(), NIL, pips_debug, and STRING.

Referenced by alias_lists().

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

◆ add_unmatched_alias_pairs()

static void add_unmatched_alias_pairs ( )
static

global variables IN: unmatched_alias_pairs, l_alias_lists modifies global variable: l_alias_lists

Definition at line 115 of file alias_lists.c.

116 {
117  pips_debug(4,"begin\n");
118 
119  MAP(LIST,alias_pair,
120  {
121  l_alias_lists =
122  CONS(EFFECTS,
123  make_effects(regions_dup(alias_pair)),
124  l_alias_lists);
126 
127  pips_debug(4,"end\n");
128 }
static list unmatched_alias_pairs
Definition: alias_lists.c:50
#define LIST(x)
Definition: genC.h:93

References CONS, EFFECTS, l_alias_lists, LIST, make_effects(), MAP, pips_debug, regions_dup(), and unmatched_alias_pairs.

Referenced by alias_lists().

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

◆ alias_lists()

bool alias_lists ( const string  module_name)

modifies global variables: matched_alias_pairs, unmatched_alias_pairs, l_alias_lists

alias_lists.c

ATTENTION: we have to do ALL this just to call print_inout_regions for debug !!

that's it, but we musn't forget to reset everything below

make alias lists from the IN_alias_pairs

DBR_IN_ALIAS_PAIRS is a newgen structure of type effects_classes which has one field called classes which is a list of newgen structures of type effects (and each newgen structure of type effects has one field called effects which is a list of elements of type effect)

wrong but did work:

in_alias_pairs = effects_to_list((effects) db_get_memory_resource(DBR_IN_ALIAS_PAIRS, module_name, true));

MAP(LIST, alias_pair, { list in_alias_pair = regions_dup(alias_pair);

make alias lists from the OUT_alias_pairs

MAP(LIST, alias_pair, { list out_alias_pair = regions_dup(alias_pair);

Parameters
module_nameodule_name

Definition at line 328 of file alias_lists.c.

329  {
331  entity module;
332 
333  l_alias_lists = NIL;
335 
336  debug_on("ALIAS_LISTS_DEBUG_LEVEL");
337  pips_debug(4,"begin for module %s\n",module_name);
338 
339  ifdebug(1)
340  {
341  /* ATTENTION: we have to do ALL this
342  * just to call print_inout_regions for debug !!
343  */
348  db_get_memory_resource(DBR_CODE,
349  module_name,
350  true) );
353  DBR_CUMULATED_EFFECTS,
354  module_name,
355  true));
358  DBR_CUMULATED_EFFECTS,
359  module_name,
360  true));
362  /* that's it, but we musn't forget to reset everything below */
363  }
364 
365  /* make alias lists from the IN_alias_pairs */
366 
367  /* DBR_IN_ALIAS_PAIRS is a newgen structure of type effects_classes
368  * which has one field called classes
369  * which is a list of newgen structures of type effects
370  * (and each newgen structure of type effects
371  * has one field called effects which is a list of elements
372  * of type effect)
373  */
374 
377  db_get_memory_resource(DBR_IN_ALIAS_PAIRS,
378  module_name,
379  true));
380 
381 
382 /* wrong but did work:
383 
384  in_alias_pairs =
385  effects_to_list((effects)
386  db_get_memory_resource(DBR_IN_ALIAS_PAIRS,
387  module_name,
388  true));
389 */
390 
391 /* MAP(LIST, alias_pair,
392  {
393  list in_alias_pair = regions_dup(alias_pair);
394  */
395 
396  MAP(EFFECTS, alias_pair_effects,
397  {
398  list alias_pair = effects_effects(alias_pair_effects);
399 
400  ifdebug(9)
401  {
402  pips_debug(9,"IN alias pair : \n");
403  print_inout_regions(alias_pair);
404  }
406  CONS(LIST,alias_pair,unmatched_alias_pairs);
407  },in_alias_pairs);
408 
409  /* make alias lists from the OUT_alias_pairs */
412  db_get_memory_resource(DBR_OUT_ALIAS_PAIRS,
413  module_name,
414  true));
415 
416 /* MAP(LIST, alias_pair,
417  {
418  list out_alias_pair = regions_dup(alias_pair);*/
419 
420  MAP(EFFECTS, alias_pair_effects,
421  {
422  list alias_pair = effects_effects(alias_pair_effects);
423 
424  ifdebug(9)
425  {
426  pips_debug(9,"OUT alias pair : \n");
427  print_inout_regions(alias_pair);
428  }
429 
431  CONS(LIST,alias_pair,unmatched_alias_pairs);
432  },out_alias_pairs);
433 
434  ifdebug(9)
435  {
436  pips_debug(9,"unmatched_alias_pairs:\n");
437  MAP(LIST,alias_pair,
438  {
439  print_inout_regions(alias_pair);
440  pips_debug(9,"---\n");
442  }
443 
445 
446  ifdebug(9)
447  {
448  pips_debug(9,"l_alias_lists:\n");
449  MAP(EFFECTS,alias_list,
450  {
452  pips_debug(9,"---\n");
453  },l_alias_lists);
454  pips_debug(9,"matched_alias_pairs:\n");
455  MAP(LIST,alias_pair,
456  {
457  print_inout_regions(alias_pair);
458  pips_debug(9,"---\n");
460  pips_debug(9,"unmatched_alias_pairs:\n");
461  MAP(LIST,alias_pair,
462  {
463  print_inout_regions(alias_pair);
464  pips_debug(9,"---\n");
466  }
467 
469 
470  ifdebug(9)
471  {
472  pips_debug(9,"l_alias_lists:\n");
473  MAP(EFFECTS,alias_list,
474  {
476  pips_debug(9,"---\n");
477  },l_alias_lists);
478  }
479 
480  DB_PUT_MEMORY_RESOURCE(DBR_ALIAS_LISTS,
483 
484  ifdebug(1)
485  {
491  }
492  pips_debug(4,"end\n");
493  debug_off();
494 
495  return(true);
496 }
effects_classes make_effects_classes(list a)
Definition: effects.c:526
bool in_alias_pairs(const string)
cproto-generated files
Definition: alias_pairs.c:587
bool out_alias_pairs(const char *)
top-level creation of pairs of aliases of OUT regions of the module modifies global vars callee,...
Definition: alias_pairs.c:623
static void add_alias_lists_callees(const char *module_name)
global variables IN: unmatched_alias_pairs, l_alias_lists modifies global variables: matched_alias_pa...
Definition: alias_lists.c:303
static void add_unmatched_alias_pairs()
global variables IN: unmatched_alias_pairs, l_alias_lists modifies global variable: l_alias_lists
Definition: alias_lists.c:115
void reset_proper_rw_effects(void)
void set_proper_rw_effects(statement_effects)
void set_cumulated_rw_effects(statement_effects)
void reset_cumulated_rw_effects(void)
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
entity set_current_module_entity(entity)
static.c
Definition: static.c:66
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
#define DB_PUT_MEMORY_RESOURCE(res_name, own_name, res_val)
conform to old interface.
Definition: pipsdbm-local.h:66
#define debug_on(env)
Definition: misc-local.h:157
#define debug_off()
Definition: misc-local.h:160
static char * module
Definition: pips.c:74
entity local_name_to_top_level_entity(const char *n)
This function try to find a top-level entity from a local name.
Definition: entity.c:1450
char * strdup()
void module_to_value_mappings(entity m)
void module_to_value_mappings(entity m): build hash tables between variables and values (old,...
Definition: mappings.c:624
void free_value_mappings(void)
Normal call to free the mappings.
Definition: value.c:1212

References add_alias_lists_callees(), add_unmatched_alias_pairs(), CONS, db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, EFFECTS, effects_classes_classes, effects_effects, free_value_mappings(), get_current_module_entity(), ifdebug, in_alias_pairs(), l_alias_lists, LIST, local_name_to_top_level_entity(), make_effects_classes(), MAP, matched_alias_pairs, module, module_name(), module_to_value_mappings(), NIL, out_alias_pairs(), pips_debug, print_inout_regions(), reset_cumulated_rw_effects(), reset_current_module_entity(), reset_current_module_statement(), reset_proper_rw_effects(), set_cumulated_rw_effects(), set_current_module_entity(), set_current_module_statement(), set_proper_rw_effects(), strdup(), and unmatched_alias_pairs.

Referenced by alias_classes(), and aliases_text().

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

◆ compare_matched_alias_pairs()

static bool compare_matched_alias_pairs ( bool  result,
region  alias_list_reg,
list  callee_alias_list 
)
static

global variables IN: matched_alias_pairs, l_alias_lists modifies global variable: l_alias_lists

must take the action of the regions into account here because we are checking whether formal_reg is the result of the propagation of alias_list_reg

Definition at line 135 of file alias_lists.c.

138 {
139  region formal_reg;
140 
141  pips_debug(4,"begin\n");
142 
143  MAP(LIST,alias_pair,
144  {
145  formal_reg = EFFECT(CAR(alias_pair));
146 
147  ifdebug(9)
148  {
150  pips_debug(9,"compare to:\n");
151  print_region(formal_reg);
153  }
154 
155 /* must take the action of the regions into account here because
156  * we are checking whether formal_reg is the result of the
157  * propagation of alias_list_reg
158  */
159  if ( same_reg(formal_reg,alias_list_reg) )
160  {
161  pips_debug(9,"match\n");
162 
163  l_alias_lists =
164  CONS(EFFECTS,
165  make_effects(gen_nconc(regions_dup(callee_alias_list),
166  regions_dup(CDR(alias_pair)))),
167  l_alias_lists);
168  result = true;
169  }
171 
172  pips_debug(4,"end\n");
173 
174  return result;
175 }
static bool same_reg(region reg1, region reg2)
tests if reg1 and reg2 are the same, including same action_tags (IN/OUT) and precision (may/exact)
Definition: alias_lists.c:59
#define ACTION_IN
#define ACTION_OUT
void reset_action_interpretation(void)
void set_action_interpretation(string, string)
prettyprint.c
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
#define print_region(x)
Definition: print.c:343

References ACTION_IN, ACTION_OUT, CAR, CDR, CONS, EFFECT, EFFECTS, gen_nconc(), ifdebug, l_alias_lists, LIST, make_effects(), MAP, matched_alias_pairs, pips_debug, print_region, region, regions_dup(), reset_action_interpretation(), same_reg(), and set_action_interpretation().

Referenced by add_alias_lists_callee().

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

◆ compare_unmatched_alias_pairs()

static bool compare_unmatched_alias_pairs ( region  alias_list_reg,
list  callee_alias_list 
)
static

global variables IN: matched_alias_pairs, unmatched_alias_pairs, l_alias_lists modifies global variables: matched_alias_pairs, unmatched_alias_pairs, l_alias_lists

must take the action of the regions into account here because we are checking whether formal_reg is the result of the propagation of alias_list_reg

Definition at line 186 of file alias_lists.c.

187 {
188  region formal_reg;
189  list rest_unmatched_alias_pairs = unmatched_alias_pairs;
190  bool result = false;
191 
192  ifdebug(4)
193  {
195  pips_debug(4,"begin for alias_list_reg:\n");
196  print_region(alias_list_reg);
198  }
199 
201 
202  MAP(LIST,alias_pair,
203  {
204  formal_reg = EFFECT(CAR(alias_pair));
205 
206  ifdebug(9)
207  {
209  pips_debug(9,"compare to:\n");
210  print_region(formal_reg);
212  }
213 
214 /* must take the action of the regions into account here because
215  * we are checking whether formal_reg is the result of the
216  * propagation of alias_list_reg
217  */
218  if ( same_reg(formal_reg,alias_list_reg) )
219  {
220  pips_debug(9,"match\n");
221 
222  l_alias_lists =
223  CONS(EFFECTS,
224  make_effects(gen_nconc(regions_dup(callee_alias_list),
225  regions_dup(CDR(alias_pair)))),
226  l_alias_lists);
228  CONS(LIST,alias_pair,matched_alias_pairs);
229  result = true;
230  }
231  else
233  CONS(LIST,alias_pair,unmatched_alias_pairs);
234  },rest_unmatched_alias_pairs);
235 
236  pips_debug(4,"end\n");
237 
238  return result;
239 }

References ACTION_IN, ACTION_OUT, CAR, CDR, CONS, EFFECT, EFFECTS, gen_nconc(), ifdebug, l_alias_lists, LIST, make_effects(), MAP, matched_alias_pairs, NIL, pips_debug, print_region, region, regions_dup(), reset_action_interpretation(), same_reg(), set_action_interpretation(), and unmatched_alias_pairs.

Referenced by add_alias_lists_callee().

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

◆ same_reg()

static bool same_reg ( region  reg1,
region  reg2 
)
static

tests if reg1 and reg2 are the same, including same action_tags (IN/OUT) and precision (may/exact)

pips_debug(1,"same entity\n");

pips_debug(1,"same approx\n");

pips_debug(1,"same action\n");

Definition at line 59 of file alias_lists.c.

60  {
61  Psysteme reg1_sys, reg2_sys;
62  bool result = false;
63 
64  pips_debug(4,"begin\n");
65 
66  if (effect_undefined_p(reg1) || effect_undefined_p(reg2)) return result;
67 
68  if (effect_entity(reg1) == effect_entity(reg2))
69  {
70 /* pips_debug(1,"same entity\n"); */
71 
72  if (effect_approximation_tag(reg1) ==
74  {
75 /* pips_debug(1,"same approx\n"); */
76 
77  if (effect_action_tag(reg1) ==
78  effect_action_tag(reg2))
79  {
80 /* pips_debug(1,"same action\n"); */
81 
82  ifdebug(1)
83  {
85  pips_debug(1,"compare:\n\t");
86  print_region(reg1);
87  pips_debug(1,"with:\n\t");
88  print_region(reg2);
90  }
91 
92  reg1_sys = region_system(reg1);
93  reg2_sys = region_system(reg2);
94  if ( sc_equal_p_ofl(reg1_sys,reg2_sys) )
95  {
96  result = true;
97 
98  pips_debug(1,"same region\n");
99  }
100  else
101  pips_debug(1,"not same region\n");
102  }
103  }
104  }
105  pips_debug(4,"end\n");
106 
107  return result;
108  }
#define region_system(reg)
#define effect_approximation_tag(eff)
#define effect_action_tag(eff)
entity effect_entity(effect)
cproto-generated files
Definition: effects.c:52
#define effect_undefined_p(x)
Definition: effects.h:615
#define sc_equal_p_ofl(ps1, ps2)
Definition: union-local.h:84

References ACTION_IN, ACTION_OUT, effect_action_tag, effect_approximation_tag, effect_entity(), effect_undefined_p, ifdebug, pips_debug, print_region, region_system, reset_action_interpretation(), sc_equal_p_ofl, and set_action_interpretation().

Referenced by compare_matched_alias_pairs(), and compare_unmatched_alias_pairs().

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

Variable Documentation

◆ l_alias_lists

◆ matched_alias_pairs

list matched_alias_pairs
static

◆ unmatched_alias_pairs

list unmatched_alias_pairs
static