PIPS
sav_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 "database.h"
#include "ri-util.h"
#include "effects-util.h"
#include "constants.h"
#include "misc.h"
#include "text.h"
#include "boolean.h"
#include "vecteur.h"
#include "contrainte.h"
#include "sc.h"
#include "sommet.h"
#include "ray_dte.h"
#include "sg.h"
#include "polyedre.h"
#include "union.h"
#include "effects-generic.h"
#include "effects-simple.h"
#include "effects-convex.h"
#include "semantics.h"
#include "transformer.h"
#include "pipsdbm.h"
#include "resources.h"
+ Include dependency graph for sav_alias_lists.c:

Go to the source code of this file.

Macros

#define BACKWARD   TRUE
 
#define FORWARD   FALSE
 

Functions

bool same_reg_ignore_action (region reg1, region reg2)
 put reg in list of one element for call to alias_pairs More...
 
static bool member (region reg, list reg_list)
 tests if reg and any member of reg_list are same_reg_ignore_action More...
 
list append_reg_if_not_present (list reg_list, region reg)
 adds reg as final element on the end of reg_list unless reg is already present in reg_list More...
 
static bool add_pair_to_existing_list (list alias_pair)
 GLOBAL IN: l_alias_lists GLOBAL OUT: l_alias_lists. More...
 
bool alias_lists (const char *module_name)
 GLOBAL OUT: l_alias_lists. More...
 

Variables

static list l_alias_lists = NIL
 

Macro Definition Documentation

◆ BACKWARD

#define BACKWARD   TRUE

Definition at line 64 of file sav_alias_lists.c.

◆ FORWARD

#define FORWARD   FALSE

Definition at line 65 of file sav_alias_lists.c.

Function Documentation

◆ add_pair_to_existing_list()

static bool add_pair_to_existing_list ( list  alias_pair)
static

GLOBAL IN: l_alias_lists GLOBAL OUT: l_alias_lists.

Definition at line 332 of file sav_alias_lists.c.

333 {
334  list rest_alias_lists, alias_list;
335  region formal_reg_pair, formal_reg_list, actual_reg_pair;
336  bool result = false;
337 
338  pips_debug(4,"begin\n");
339 
340  formal_reg_pair = EFFECT( CAR(alias_pair) );
341 
342  ifdebug(9)
343  {
345  pips_debug(9,"compare:\n\t");
346  print_region(formal_reg_pair);
347  }
348 
349  rest_alias_lists = l_alias_lists;
350  if (l_alias_lists != NIL)
351  do {
352  alias_list = LIST( CAR(rest_alias_lists) );
353  formal_reg_list = EFFECT( CAR(alias_list) );
354 
355  ifdebug(9)
356  {
357  pips_debug(9,"with:\n\t");
358  print_region(formal_reg_list);
359  }
360 
361  if ( same_reg_ignore_action(formal_reg_pair,formal_reg_list) )
362  {
363  result = true;
364  actual_reg_pair = EFFECT(CAR(CDR(alias_pair)));
365  ifdebug(9)
366  {
367  pips_debug(9,"add:\n\t");
368  print_region(actual_reg_pair);
369  pips_debug(9,"to:\n\t");
370  print_inout_regions(alias_list);
371  }
372  alias_list =
373  append_reg_if_not_present(alias_list,actual_reg_pair);
374  }
375  rest_alias_lists = CDR(rest_alias_lists);
376  } while (rest_alias_lists != NIL && result == false);
377 
378  ifdebug(9)
379  {
381  }
382  pips_debug(4,"end\n");
383 
384  return result;
385 }
#define region
simulation of the type region
void print_inout_regions(list)
#define ACTION_IN
#define ACTION_OUT
void reset_action_interpretation(void)
void set_action_interpretation(string, string)
prettyprint.c
#define EFFECT(x)
EFFECT.
Definition: effects.h:608
#define LIST(x)
Definition: genC.h:93
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define print_region(x)
Definition: print.c:343
static list l_alias_lists
list append_reg_if_not_present(list reg_list, region reg)
adds reg as final element on the end of reg_list unless reg is already present in reg_list
bool same_reg_ignore_action(region reg1, region reg2)
put reg in list of one element for call to alias_pairs
#define ifdebug(n)
Definition: sg.c:47
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References ACTION_IN, ACTION_OUT, append_reg_if_not_present(), CAR, CDR, EFFECT, ifdebug, l_alias_lists, LIST, NIL, pips_debug, print_inout_regions(), print_region, region, reset_action_interpretation(), same_reg_ignore_action(), and set_action_interpretation().

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 char *  module_name)

GLOBAL OUT: l_alias_lists.

list in_alias_pairs, out_alias_pairs, in_alias_pair, out_alias_pair;

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));

seems right but didn't work (gets 2nd element of each pair only):

MAP(EFFECTS, alias_pair_effects, { list alias_pair = effects_effects(alias_pair_effects);

make alias lists from the OUT_alias_pairs

check all callees for sub-regions of existing aliases

make_alias_lists_for_sub_regions(module_name);

Definition at line 389 of file sav_alias_lists.c.

390  {
391 /* list in_alias_pairs, out_alias_pairs, in_alias_pair, out_alias_pair; */
393  entity module;
394 
395  l_alias_lists = NIL;
396 
397  debug_on("ALIAS_LISTS_DEBUG_LEVEL");
398  pips_debug(4,"begin for module %s\n",module_name);
399 
400  ifdebug(9)
401  {
402  /* ATTENTION: we have to do ALL this
403  * just to call print_inout_regions for debug !!
404  */
409  db_get_memory_resource(DBR_CODE,
410  module_name,
411  true) );
414  DBR_CUMULATED_EFFECTS,
415  module_name,
416  true));
419  DBR_PROPER_EFFECTS,
420  module_name,
421  true));
423  /* that's it, but we musn't forget to reset everything below */
424  }
425 
426  /* make alias lists from the IN_alias_pairs */
427 
428  /* DBR_IN_ALIAS_PAIRS is a newgen structure of type effects_classes
429  * which has one field called classes
430  * which is a list of newgen structures of type effects
431  * (and each newgen structure of type effects
432  * has one field called effects which is a list of elements
433  * of type effect)
434  */
435 
438  db_get_memory_resource(DBR_IN_ALIAS_PAIRS,
439  module_name,
440  true));
441 
442 
443 /* wrong but did work:
444 
445  in_alias_pairs =
446  effects_to_list((effects)
447  db_get_memory_resource(DBR_IN_ALIAS_PAIRS,
448  module_name,
449  true));
450 */
451 
452 /* seems right but didn't work (gets 2nd element of each pair only):
453 
454  MAP(EFFECTS, alias_pair_effects,
455  {
456  list alias_pair = effects_effects(alias_pair_effects);
457 
458 */
459 
460  MAP(LIST, alias_pair,
461  {
462  list in_alias_pair = regions_dup(alias_pair);
463 
464  ifdebug(9)
465  {
466  pips_debug(9,"IN alias pair : \n");
467  print_inout_regions(in_alias_pair);
468  }
469 
470  if ( ! add_pair_to_existing_list(in_alias_pair) )
471  l_alias_lists =
472  gen_nconc(l_alias_lists,CONS(LIST,in_alias_pair,NIL));
473 
474  pips_debug(9,"IN pair added\n");
475  },
477 
478  /* make alias lists from the OUT_alias_pairs */
481  db_get_memory_resource(DBR_OUT_ALIAS_PAIRS,
482  module_name,
483  true));
484 
485  MAP(LIST, alias_pair,
486  {
487  list out_alias_pair = regions_dup(alias_pair);
488 
489  ifdebug(9)
490  {
491  pips_debug(9,"OUT alias pair : \n");
492  print_inout_regions(out_alias_pair);
493  }
494 
495  if ( ! add_pair_to_existing_list(out_alias_pair) )
496  l_alias_lists =
497  gen_nconc(l_alias_lists,CONS(LIST,out_alias_pair,NIL));
498 
499  pips_debug(9,"OUT pair added\n");
500  },
502 
503  /* check all callees for sub-regions of existing aliases */
504 /* make_alias_lists_for_sub_regions(module_name); */
505 
506  DB_PUT_MEMORY_RESOURCE(DBR_ALIAS_LISTS,
509 
510  ifdebug(9)
511  {
517  }
518  pips_debug(4,"end\n");
519  debug_off();
520 
521  return(true);
522 }
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
list regions_dup(list)
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)
#define effects_classes_classes(x)
Definition: effects.h:678
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
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 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 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 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
static bool add_pair_to_existing_list(list alias_pair)
GLOBAL IN: l_alias_lists GLOBAL OUT: l_alias_lists.
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_pair_to_existing_list(), CONS, db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, effects_classes_classes, free_value_mappings(), gen_nconc(), get_current_module_entity(), ifdebug, in_alias_pairs(), l_alias_lists, LIST, local_name_to_top_level_entity(), make_effects_classes(), MAP, module, module_name(), module_to_value_mappings(), NIL, out_alias_pairs(), pips_debug, print_inout_regions(), regions_dup(), 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(), and strdup().

+ Here is the call graph for this function:

◆ append_reg_if_not_present()

list append_reg_if_not_present ( list  reg_list,
region  reg 
)

adds reg as final element on the end of reg_list unless reg is already present in reg_list

Definition at line 299 of file sav_alias_lists.c.

300 {
301  list new_reg_list;
302 
303  pips_debug(4,"begin\n");
304 
305 
306 /*
307  ifdebug(9)
308  {
309  pips_debug(9,"add:\n\t");
310  print_region(reg);
311  pips_debug(9,"to:\n\t");
312  print_inout_regions(reg_list);
313  }
314 */
315 
316  if (!member(reg,reg_list))
317  new_reg_list = gen_nconc(reg_list,
318  CONS(EFFECT,region_dup(reg),NIL));
319  else
320  new_reg_list = reg_list;
321 
322  pips_debug(4,"end\n");
323 
324  return new_reg_list;
325 }
effect region_dup(effect)
static bool member(region reg, list reg_list)
tests if reg and any member of reg_list are same_reg_ignore_action

References CONS, EFFECT, gen_nconc(), member(), NIL, pips_debug, and region_dup().

Referenced by add_pair_to_existing_list(), and append_all_not_present().

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

◆ member()

static bool member ( region  reg,
list  reg_list 
)
static

tests if reg and any member of reg_list are same_reg_ignore_action

Definition at line 257 of file sav_alias_lists.c.

258  {
259  region elem;
260  list rest_list;
261  bool result = false;
262 
263  pips_debug(4,"begin\n");
264 
265 /*
266  ifdebug(9)
267  {
268  pips_debug(9,"test if:\n\t");
269  print_region(reg);
270  pips_debug(9,"is in:\n\t");
271  print_inout_regions(reg_list);
272  }
273  */
274 
275  rest_list = reg_list;
276 
277  if (reg_list != NIL)
278 
279  do{
280  elem = EFFECT(CAR(rest_list));
281  if (same_reg_ignore_action(elem,reg))
282  {
283  result = true;
284 
285  pips_debug(4,"is member\n");
286  }
287 
289  }while (rest_list != NIL && result == false);
290 
291  pips_debug(4,"end\n");
292 
293  return result;
294  }
static list rest_list
Definition: alias_classes.c:55

References CAR, CDR, EFFECT, NIL, pips_debug, region, rest_list, and same_reg_ignore_action().

Referenced by append_reg_if_not_present().

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

◆ same_reg_ignore_action()

bool same_reg_ignore_action ( region  reg1,
region  reg2 
)

put reg in list of one element for call to alias_pairs

l_pairs = alias_pairs( module_name, CONS(EFFECT,reg,NIL) ); turn list_pairs into an alias list alias_list = CONS(EFFECT,reg,NIL); MAP(EFFECTS,alias_pair, { alias_list = gen_nconc(alias_list,CDR(alias_pair)); }, l_pairs); l_alias_lists = gen_nconc(l_alias_lists,CONS(LIST,alias_list,NIL)); } if there is no alias for reg in this module if ( no_alias_for(reg) ) { for each alias_list=[alias_reg|list_trans_alias_reg] of this module,... MAP(LIST,alias_list, { alias_reg = EFFECT( CAR(alias_list) ); ... except for COMMON region alias_lists, do if ( ! storage_ram_p( entity_storage(region_entity(alias_reg)) )) { see if reg is properly included in alias_reg if ( effects_same_action_p(alias_reg,reg) ) { reg_sys = region_system(reg); alias_reg_sys = region_system(alias_reg); if (sc_inclusion_p_ofl(reg_sys,alias_reg_sys) && ! sc_inclusion_p_ofl(alias_reg_sys,reg_sys) ) and, if so, add alias list for reg to this module make_alias_list_sub_region(reg,module_name);

} } }, l_alias_lists); } } we need the callees of the current module
module_callees = (callees) db_get_memory_resource(DBR_CALLEES, module_name, true); for each callee do MAP(STRING, callee_name, { callee_alias_lists = (list) db_get_memory_resource(DBR_ALIAS_LISTS, callee_name, true); for each alias list do MAP(EFFECTS, alias_list_effects, { list callee_alias_list = regions_dup(effects_to_list(alias_list_effects)); don't treat COMMON regions if ( ! storage_ram_p( entity_storage(region_entity(EFFECT(CAR(callee_alias_list)))) )) { for any alias in this module do MAP(EFFECT, trans_reg, { if ( module_entity == region_entity(trans_reg) ) if it is a sub-region of an IN or OUT region of this module then make an alias list for it in this module make_alias_list_if_sub_region(trans_reg, module_name); }, CDR(callee_alias_list)); }
}, callee_alias_lists); }, callees_callees(module_callees)); } tests if reg1 and reg2 are the same, ignoring their action_tags (read/write) but checking their precision (may/exact)

Definition at line 213 of file sav_alias_lists.c.

214  {
215  Psysteme reg1_sys, reg2_sys;
216  bool result = false;
217 
218  pips_debug(4,"begin\n");
219 
220 /*
221  ifdebug(9)
222  {
223  pips_debug(9,"compare:\n\t");
224  print_region(reg1);
225  pips_debug(9,"with:\n\t");
226  print_region(reg2);
227  }
228  */
229 
230  if (effect_undefined_p(reg1) || effect_undefined_p(reg2)) return result;
231 
232  if (effect_entity(reg1) == effect_entity(reg2))
233  {
234  if (effect_approximation_tag(reg1) ==
236  {
237  reg1_sys = region_system(reg1);
238  reg2_sys = region_system(reg2);
239  if ( sc_equal_p_ofl(reg1_sys,reg2_sys) )
240  {
241  result = true;
242 
243  pips_debug(4,"same region\n");
244  }
245  }
246  }
247  pips_debug(4,"end\n");
248 
249  return result;
250  }
#define region_system(reg)
#define effect_approximation_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 effect_approximation_tag, effect_entity(), effect_undefined_p, pips_debug, region_system, and sc_equal_p_ofl.

Referenced by add_pair_to_existing_list(), compare_other_list(), match_this_callee_class_elem(), and member().

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

Variable Documentation

◆ l_alias_lists

list l_alias_lists = NIL
static

Definition at line 67 of file sav_alias_lists.c.

Referenced by add_pair_to_existing_list(), and alias_lists().