PIPS
area.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "linear.h"
#include "genC.h"
#include "misc.h"
#include "ri.h"
#include "properties.h"
#include "ri-util.h"
#include "prettyprint.h"
+ Include dependency graph for area.c:

Go to the source code of this file.

Functions

static bool comparable_entity_in_list_p (entity common, entity v, list l)
 Functions closely related to the entity class, constructors, predicates,... More...
 
bool check_common_inclusion (entity common)
 check whether a common declaration can be simply included, that is it is declared with the same names, orders and types in all instances. More...
 

Function Documentation

◆ check_common_inclusion()

bool check_common_inclusion ( entity  common)

check whether a common declaration can be simply included, that is it is declared with the same names, orders and types in all instances.

area.c

of entity

empty common!

take the first function as the reference for the check.

SAME name, type, offset

Parameters
commonommon

Definition at line 107 of file area.c.

108 {
109  bool ok = true;
110  list /* of entity */ lv, lref;
111  entity ref;
112  pips_assert("entity is a common", entity_area_p(common));
113  lv = area_layout(type_area(entity_type(common)));
114 
115  if (!lv) return true; /* empty common! */
116 
117  /* take the first function as the reference for the check. */
119  lref = common_members_of_module(common, ref, false);
120 
121  /* SAME name, type, offset */
122  while (lv && ok)
123  {
124  entity v = ENTITY(CAR(lv));
126  ok = comparable_entity_in_list_p(common, v, lref);
127  POP(lv);
128  }
129 
130  gen_free_list(lref);
131  return ok;
132 }
static reference ref
Current stmt (an integer)
Definition: adg_read_paf.c:163
#define POP(l)
Modify a list pointer to point on the next element of the list.
Definition: newgen_list.h:59
#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 pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
static bool comparable_entity_in_list_p(entity common, entity v, list l)
Functions closely related to the entity class, constructors, predicates,...
Definition: area.c:46
bool entity_area_p(entity e)
Definition: area.c:149
list common_members_of_module(entity common, entity module, bool only_primary)
returns the list of entity to appear in the common declaration.
Definition: entity.c:1741
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define entity_storage(x)
Definition: ri.h:2794
#define area_layout(x)
Definition: ri.h:546
#define type_area(x)
Definition: ri.h:2946
#define storage_ram(x)
Definition: ri.h:2521
#define ram_function(x)
Definition: ri.h:2247
#define entity_type(x)
Definition: ri.h:2792
static bool ok
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References area_layout, CAR, common_members_of_module(), comparable_entity_in_list_p(), ENTITY, entity_area_p(), entity_storage, entity_type, gen_free_list(), ok, pips_assert, POP, ram_function, ref, storage_ram, and type_area.

Referenced by text_area_included().

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

◆ comparable_entity_in_list_p()

static bool comparable_entity_in_list_p ( entity  common,
entity  v,
list  l 
)
static

Functions closely related to the entity class, constructors, predicates,...

returns true if l contains an entity with same type, local name and offset.

first find an entity with the same NAME.

same OFFSET?

same TYPE?

SG we cannot rely on same_type_p or type_equal_p because we want a syntactic comparison, there used to be a hack in expression_equal_p to handle this particular case, I prefer to have the hack right here

temporary for CA

Definition at line 46 of file area.c.

47 {
49  bool ok, sn, so = false, st = false;
50 
51  /* first find an entity with the same NAME.
52  */
53  const char* nv = entity_local_name(v);
54  MAP(ENTITY, e,
55  {
57  {
58  ref = e;
59  break;
60  }
61  },
62  l);
63 
64  ok = sn = !entity_undefined_p(ref);
65 
66  pips_assert("v storage ram", storage_ram_p(entity_storage(v)));
67  if (ok) pips_assert("ref storage ram", storage_ram_p(entity_storage(ref)));
68 
69  /* same OFFSET?
70  */
71  if (ok) ok = so = (ram_offset(storage_ram(entity_storage(v))) ==
73 
74  /* same TYPE?
75  */
76  /* SG we cannot rely on same_type_p or type_equal_p because we want a syntactic comparison,
77  * there used to be a hack in expression_equal_p to handle this particular case, I prefer to have the hack right here
78  */
79  if( ok ) {
80  if(entity_undefined_p(ref)) ok = st =false;
81  else {
82  type tv = entity_type(v),
83  tref = entity_type(ref);
84  ok = st = same_type_name_p(tv,tref);
85  }
86  }
87 
88  pips_debug(4, "%s ~ %s? %d: n=%d,o=%d,t=%d\n", entity_name(v),
89  entity_undefined_p(ref)? "<undef>": entity_name(ref),
90  ok, sn, so, st);
91 
92  /* temporary for CA
93  */
94  if (!ok) {
95  pips_debug(1, "common /%s/: %s != %s (n=%d,o=%d,t=%d)\n",
96  entity_name(common), entity_name(v),
97  entity_undefined_p(ref)? "<undef>": entity_name(ref),
98  sn, so, st);
99  }
100 
101  return ok;
102 }
#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
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define same_string_p(s1, s2)
bool same_type_name_p(const type, const type)
For naming homogeneity: expression_to_string(), reference_to_string()...
Definition: type.c:74
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 storage_ram_p(x)
Definition: ri.h:2519
#define entity_undefined_p(x)
Definition: ri.h:2762
#define entity_undefined
Definition: ri.h:2761
#define entity_name(x)
Definition: ri.h:2790
#define ram_offset(x)
Definition: ri.h:2251

References ENTITY, entity_local_name(), entity_name, entity_storage, entity_type, entity_undefined, entity_undefined_p, MAP, ok, pips_assert, pips_debug, ram_offset, ref, same_string_p, same_type_name_p(), storage_ram, and storage_ram_p.

Referenced by check_common_inclusion().

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