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

Go to the source code of this file.

Macros

#define DEFAULT_INT_PREFIX   "I_"
 Default prefixes. More...
 
#define DEFAULT_FLOAT_PREFIX   "F_"
 
#define DEFAULT_LOGICAL_PREFIX   "L_"
 
#define DEFAULT_COMPLEX_PREFIX   "C_"
 
#define DEFAULT_STRING_PREFIX   "S_"
 
#define DEFAULT_POINTER_PREFIX   "P_"
 
#define DEFAULT_STRUCT_PREFIX   "ST_"
 
#define DEFAULT_UNION_PREFIX   "U_"
 
#define DEFAULT_ENUM_PREFIX   "E_"
 
#define DEFAULT_DERIVED_STRUCT_PREFIX   "DS_"
 
#define DEFAULT_DERIVED_UNION_PREFIX   "DU_"
 
#define DEFAULT_DERIVED_ENUM_PREFIX   "DE_"
 
#define PLACE_HOLDER_PREFIX_STRING   "PLACE__HOLDER_"
 Generate special variables to represent declarations such as "struct s;". More...
 

Functions

static bool unique_entity_name_p (const char *name, entity in_module)
 Handling of entity as program variables (see also entity.c for generic entities) More...
 
bool variable_entity_p (entity e)
 See also macro entity_variable_p()... More...
 
bool symbolic_constant_entity_p (entity e)
 BEGIN_EOLE. More...
 
void AddEntityToDeclarations (entity e, entity module)
 END_EOLE. More...
 
void RemoveLocalEntityFromDeclarations (entity e, entity module, statement s)
 
static void GenericAddLocalEntityToDeclarations (entity e, entity module, statement s, bool add_declaration_statement_p)
 See the two user interfaces below. More...
 
void AddLocalEntityToDeclarations (entity e, entity module, statement s)
 Add the variable entity e to the list of variables of the function module. More...
 
void AddLocalEntityToDeclarationsOnly (entity e, entity module, statement s)
 Add the variable entity e to the list of variables of the function module. More...
 
void AddEntityToCurrentModule (entity e)
 Add a variable entity to the current module declarations. More...
 
void AddEntityToCurrentModuleWithoutDeclaration (entity e)
 Add a variable entity to the current module declarations. More...
 
entity make_global_entity_from_local (entity local)
 
entity make_stderr_variable ()
 If the parser has not (yet) encountered "stderr", a PIPS transformation or instrumentation phase may need "stderr" to generate AST code. More...
 
entity make_scalar_entity (const char *name, const char *module_name, basic base)
 entity make_scalar_entity(name, module_name, base) More...
 
entity make_derived_entity (const char *name, const char *module_name, type t)
 
void reset_unique_variable_numbers ()
 
entity generate_variable_with_unique_name_to_module (const char *seed_name, const char *prefix, const char *suffix, entity module)
 Generate a new variable name from a seed name to a module. More...
 
entity generic_clone_variable_with_unique_name (entity old_variable, statement declaration_statement, string prefix, string suffix, entity module, bool insert_p)
 clone a variable with a new name. More...
 
entity clone_variable_with_unique_name (entity old_variable, statement declaration_statement, string prefix, string suffix, entity module)
 Clone a variable with a new user name. More...
 
entity make_new_scalar_variable_with_prefix (const char *prefix, entity module, basic b)
 Create a new scalar variable of type b in the given module. More...
 
entity make_new_derived_entity_with_prefix (const char *prefix, entity module, type t)
 derived from make_new_scalar_variable_with_prefix More...
 
entity make_new_scalar_variable (entity module, basic b)
 
static entity make_array_entity (const char *name, const char *module_name, basic base, list dimensions)
 Create an array entity. More...
 
entity make_new_array_variable_with_prefix (const char *prefix, entity module, basic b, list dimensions)
 J'ai ameliore la fonction make_new_scalar_variable_with_prefix
More...
 
entity make_new_array_variable (entity module, basic b, list dimensions)
 
entity make_temporary_pointer_to_array_entity_with_prefix (char *prefix, entity efrom, entity module, expression from)
 
entity make_temporary_pointer_to_array_entity (entity efrom, expression from, entity module)
 
entity make_new_module_variable (entity module, int d)
 Make a new module integer variable of name X<d>. More...
 
entity make_new_entity (basic ba, int kind)
 
entity find_or_create_scalar_entity (const char *name, const char *module_name, tag base)
 Looks for an entity which should be a scalar of the specified basic. More...
 
entity find_or_create_typed_entity (string name, const char *module_name, tag base)
 Looks for an entity of the specified basic. More...
 
entity make_scalar_integer_entity (const char *name, const char *module_name)
 Create an integer variable of name "name" in module of name "module_name". More...
 
bool entity_scalar_p (entity e)
 The concrete type of e is a scalar type. More...
 
bool entity_integer_scalar_p (entity e)
 for variables (like I), not constants (like 1)! use integer_constant_p() for constants More...
 
bool integer_scalar_entity_p (entity e)
 integer_scalar_entity_p() is obsolete; use entity_integer_scalar_p() More...
 
bool entity_static_variable_p (entity e)
 return true if the entity is declared with the keyword static More...
 
bool entity_atomic_reference_p (entity e)
 Any reference r such that reference_variable(r)==e accesses all bytes (or bits) allocated to variable e. More...
 
bool entity_non_pointer_scalar_p (entity e)
 
dimension entity_ith_dimension (entity e, int i)
 Another semantics would be: is this reference r to e a kill for e? In general, this cannot be answered at the entity level only (see previous function) and the reference itself must be passed as an argument. More...
 
bool entity_unbounded_p (entity e)
 bool entity_unbounded_p(entity e) input : an array entity output : true if the last dimension of the array is unbounded (*), false otherwise. More...
 
bool array_with_numerical_bounds_p (entity a)
 bool array_with_numerical_bounds_p(entity a) input : an array entity output : true if all bounds of all dimensions are numerical false otherwise (adjustable arrays, formal parameters). More...
 
int variable_entity_dimension (entity v)
 variable_entity_dimension(entity v): returns the dimension of variable v; scalar have dimension 0. More...
 
void remove_variable_entity (entity v)
 
entity make_integer_constant_entity (_int c)
 entity make_integer_constant_entity(int c) make entity for integer constant c More...
 
int add_variable_to_area (entity a, entity v)
 
int add_C_variable_to_area (entity a, entity v)
 
int add_any_variable_to_area (entity a, entity v, bool is_fortran_p)
 
int new_add_any_variable_to_area (entity a, entity v, bool is_fortran_p)
 
bool formal_parameter_p (entity v)
 
bool static_global_variable_p (entity v)
 Is v a global variable declared local to a C file such "static int i;". More...
 
bool global_variable_p (entity v)
 Is v a global variable such as "int i;". More...
 
bool variable_return_p (entity v)
 True if a variable is the pseudo-variable used to store value returned by a function: More...
 
bool formal_context_variable_p (entity v)
 Such pseudo-variables are generated by the points-to analysis. More...
 
bool variable_is_a_module_formal_parameter_p (entity a_variable, entity a_module)
 
bool variable_in_common_p (entity v)
 true if v is in a common. More...
 
bool variable_static_p (entity v)
 true if v appears in a SAVE statement, or in a DATA statement, or is declared static i C. More...
 
bool variable_dynamic_p (entity v)
 
bool variable_stack_p (entity v)
 
bool variable_heap_p (entity v)
 
bool variable_in_module_p (entity v, entity m)
 This test can only be applied to variables, not to functions, subroutines or commons visible from a module. More...
 
bool variable_in_list_p (entity e, list l)
 
bool entity_volatile_variable_p (entity v)
 
bool volatile_variable_p (variable v)
 
bool qualified_variable_p (entity v, unsigned int is_qualified)
 The variable may turn out to be a function. More...
 
bool const_variable_p (entity v)
 
void discard_module_declaration_text (entity a_module)
 Discard the decls_text string of the module code to make the prettyprinter ignoring the textual declaration and remake all from the declarations without touching the corresponding property (PRETTYPRINT_ALL_DECLARATIONS). More...
 
entity get_ith_dummy (string prefix, string suffix, int i)
 Returns a numbered entity the name of which is suffix + number, the module of which is prefix. More...
 
expression generate_string_for_alternate_return_argument (string i)
 
entity generate_pseudo_formal_variable_for_formal_label (const char *p, int l)
 
bool formal_label_replacement_p (entity fp)
 
bool actual_label_replacement_p (expression eap)
 Assumes that eap is a call. More...
 
bool call_contains_alternate_returns_p (call c)
 
entity make_new_index_entity (entity old_index, string suffix)
 
bool implicit_c_variable_p (entity v)
 
expression variable_initial_expression (entity v)
 Returns a copy of the initial (i.e. More...
 
bool self_initialization_p (entity v)
 Check if a variable is initialized by itself as "int a = a;" is legal C code according to gcc. More...
 
bool same_scalar_location_p (entity e1, entity e2)
 FI: transferred from semantics (should be used for effect translation as well) More...
 
list struct_variable_to_fields (entity v)
 Assume that v is declared as a struct. More...
 
entity make_place_holder_variable (entity de)
 
bool place_holder_variable_p (entity ph)
 

Variables

static int unique_integer_number = 0
 
static int unique_float_number = 0
 
static int unique_logical_number = 0
 
static int unique_complex_number = 0
 
static int unique_string_number = 0
 
static int count_tmp = 0
 These globals variables count the number of temporary and auxiliary entities. More...
 
static int count_aux = 0
 
list integer_entities = list_undefined
 Make a new variable entity which name is one letter prefix + one incrementing number. More...
 
list real_entities = list_undefined
 
list logical_entities = list_undefined
 
list complex_entities = list_undefined
 
list double_entities = list_undefined
 
list char_entities = list_undefined
 

Macro Definition Documentation

◆ DEFAULT_COMPLEX_PREFIX

#define DEFAULT_COMPLEX_PREFIX   "C_"

Definition at line 433 of file variable.c.

◆ DEFAULT_DERIVED_ENUM_PREFIX

#define DEFAULT_DERIVED_ENUM_PREFIX   "DE_"

Definition at line 441 of file variable.c.

◆ DEFAULT_DERIVED_STRUCT_PREFIX

#define DEFAULT_DERIVED_STRUCT_PREFIX   "DS_"

Definition at line 439 of file variable.c.

◆ DEFAULT_DERIVED_UNION_PREFIX

#define DEFAULT_DERIVED_UNION_PREFIX   "DU_"

Definition at line 440 of file variable.c.

◆ DEFAULT_ENUM_PREFIX

#define DEFAULT_ENUM_PREFIX   "E_"

Definition at line 438 of file variable.c.

◆ DEFAULT_FLOAT_PREFIX

#define DEFAULT_FLOAT_PREFIX   "F_"

Definition at line 431 of file variable.c.

◆ DEFAULT_INT_PREFIX

#define DEFAULT_INT_PREFIX   "I_"

Default prefixes.

Definition at line 430 of file variable.c.

◆ DEFAULT_LOGICAL_PREFIX

#define DEFAULT_LOGICAL_PREFIX   "L_"

Definition at line 432 of file variable.c.

◆ DEFAULT_POINTER_PREFIX

#define DEFAULT_POINTER_PREFIX   "P_"

Definition at line 435 of file variable.c.

◆ DEFAULT_STRING_PREFIX

#define DEFAULT_STRING_PREFIX   "S_"

Definition at line 434 of file variable.c.

◆ DEFAULT_STRUCT_PREFIX

#define DEFAULT_STRUCT_PREFIX   "ST_"

Definition at line 436 of file variable.c.

◆ DEFAULT_UNION_PREFIX

#define DEFAULT_UNION_PREFIX   "U_"

Definition at line 437 of file variable.c.

◆ PLACE_HOLDER_PREFIX_STRING

#define PLACE_HOLDER_PREFIX_STRING   "PLACE__HOLDER_"

Generate special variables to represent declarations such as "struct s;".

This special character string does not have to be exported, except to make sure it is unique

Definition at line 2057 of file variable.c.

Function Documentation

◆ actual_label_replacement_p()

bool actual_label_replacement_p ( expression  eap)

Assumes that eap is a call.

Parameters
eapap

Definition at line 1811 of file variable.c.

1812 {
1813  bool replacement_p = false;
1814  if (expression_call_p(eap))
1815  {
1816  const char * ls = entity_user_name(call_function(syntax_call(expression_syntax(eap))));
1817  const char * p = ls+1;
1818 
1819  replacement_p = (strlen(ls) >= 4
1820  && *ls=='"' && *(ls+1)=='*' && *(ls+strlen(ls)-1)=='"');
1821 
1822  if(replacement_p) {
1823  for(p=ls+2; p<ls+strlen(ls)-1; p++) {
1824  if(*p<'0'||*p>'9') {
1825  replacement_p =false;
1826  break;
1827  }
1828  }
1829  }
1830  }
1831 
1832  return replacement_p;
1833 }
const char * entity_user_name(entity e)
Since entity_local_name may contain PIPS special characters such as prefixes (label,...
Definition: entity.c:487
bool expression_call_p(expression e)
Definition: expression.c:415
#define call_function(x)
Definition: ri.h:709
#define syntax_call(x)
Definition: ri.h:2736
#define expression_syntax(x)
Definition: ri.h:1247

References call_function, entity_user_name(), expression_call_p(), expression_syntax, and syntax_call.

Referenced by call_contains_alternate_returns_p(), and words_regular_call().

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

◆ add_any_variable_to_area()

int add_any_variable_to_area ( entity  a,
entity  v,
bool  is_fortran_p 
)

COMMONs are supposed to have the same layout in each routine

the local areas are StaticArea and DynamicArea in fortran

the areas are localStaticArea, localDynamicArea, moduleStaticArea, globalStaticArea in C; but we also mange the stack for variable of dependent types, the heap area to model dynamic allocation and the formal area to model the formal context in C.

FI: I have a (temporary?) problem with some stub functional variables generated by the points-to analysis. In fact, the should be declared as pointers to functions, not as functions. I also have problem with overloaded stubs...

Parameters
is_fortran_ps_fortran_p

Definition at line 1386 of file variable.c.

1387 {
1388  int OldOffset=-1;
1389  type ta = entity_type(a);
1390  area aa = type_area(ta);
1391 
1392  if(top_level_entity_p(a) && is_fortran_p ) {
1393  /* COMMONs are supposed to have the same layout in each routine */
1394  pips_internal_error("COMMONs should not be modified");
1395  }
1396  else {
1397  /* the local areas are StaticArea and DynamicArea in fortran */
1398  /* the areas are localStaticArea, localDynamicArea,
1399  moduleStaticArea, globalStaticArea in C; but we also mange the
1400  stack for variable of dependent types, the heap area to model
1401  dynamic allocation and the formal area to model the formal
1402  context in C. */
1403  int s = 0;
1404  OldOffset = area_size(aa);
1405  /* FI: I have a (temporary?) problem with some stub functional
1406  variables generated by the points-to analysis. In fact, the
1407  should be declared as pointers to functions, not as
1408  functions. I also have problem with overloaded stubs... */
1409  type uet = ultimate_type(entity_type(v));
1410  if(!type_variable_p(uet)
1411  || overloaded_type_p(uet)
1412  || !SizeOfArray(v, &s)) {
1413  if(is_fortran_p)
1414  return DYNAMIC_RAM_OFFSET;
1415  else {
1416  if(!gen_in_list_p(v, area_layout(aa)))
1417  area_layout(aa) = gen_nconc(area_layout(aa), CONS(ENTITY, v, NIL));
1418  }
1419  }
1420 
1421  if(is_fortran_p)
1422  {
1423  area_layout(aa) = gen_nconc(area_layout(aa), CONS(ENTITY, v, NIL));
1424  area_size(aa) = OldOffset+s;
1425  }
1426  else
1427  {
1428  if(!gen_in_list_p(v, area_layout(aa)))
1429  area_layout(aa) = gen_nconc(area_layout(aa), CONS(ENTITY, v, NIL));
1430  area_size(aa) = OldOffset+s;
1431  }
1432  }
1433  return(OldOffset);
1434 }
#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
bool gen_in_list_p(const void *vo, const list lx)
tell whether vo belongs to lx
Definition: list.c:734
#define pips_internal_error
Definition: misc-local.h:149
#define DYNAMIC_RAM_OFFSET
FI: I would have assumed that it is used for the stack area, but I must be wrong.....
bool top_level_entity_p(entity e)
Check if the scope of entity e is global.
Definition: entity.c:1130
type ultimate_type(type)
Definition: type.c:3466
bool SizeOfArray(entity, int *)
This function computes the total size of a variable in bytes, ie.
Definition: size.c:87
bool overloaded_type_p(type)
Returns true if t is a variable type with a basic overloaded.
Definition: type.c:2666
#define area_size(x)
Definition: ri.h:544
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define area_layout(x)
Definition: ri.h:546
#define type_area(x)
Definition: ri.h:2946
#define entity_type(x)
Definition: ri.h:2792
#define type_variable_p(x)
Definition: ri.h:2947

References area_layout, area_size, CONS, DYNAMIC_RAM_OFFSET, ENTITY, entity_type, gen_in_list_p(), gen_nconc(), NIL, overloaded_type_p(), pips_internal_error, SizeOfArray(), top_level_entity_p(), type_area, type_variable_p, and ultimate_type().

Referenced by add_C_variable_to_area(), add_variable_to_area(), make_global_entity_from_local(), and make_scalar_integer_entity().

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

◆ add_C_variable_to_area()

int add_C_variable_to_area ( entity  a,
entity  v 
)

Definition at line 1381 of file variable.c.

1382 {
1383  return(add_any_variable_to_area(a, v, false));
1384 }
int add_any_variable_to_area(entity a, entity v, bool is_fortran_p)
Definition: variable.c:1386

References add_any_variable_to_area().

Referenced by CCompilationUnitMemoryAllocations(), CModuleMemoryAllocation(), create_stub_entity(), entity_flow_or_context_sentitive_heap_location(), generic_make_entity_copy_with_new_name(), make_scalar_entity(), outliner_patch_parameters(), and step_parameter().

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

◆ add_variable_to_area()

◆ AddEntityToCurrentModule()

void AddEntityToCurrentModule ( entity  e)

Add a variable entity to the current module declarations.

There is no declaration local to a statement in Fortran:

Definition at line 260 of file variable.c.

260  {
261  entity module_e = get_current_module_entity();
262  /* There is no declaration local to a statement in Fortran: */
263  statement module_s = c_module_p(module_e) ? get_current_module_statement()
265 
266  AddLocalEntityToDeclarations(e, module_e, module_s);
267 }
statement get_current_module_statement(void)
Get the current module statement.
Definition: static.c:208
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
void AddLocalEntityToDeclarations(entity e, entity module, statement s)
Add the variable entity e to the list of variables of the function module.
Definition: variable.c:233
bool c_module_p(entity m)
Test if a module "m" is written in C.
Definition: entity.c:2777
#define statement_undefined
Definition: ri.h:2419

References AddLocalEntityToDeclarations(), c_module_p(), get_current_module_entity(), get_current_module_statement(), and statement_undefined.

Referenced by atomize_this_expression(), comEngine_make_new_scalar_variable(), complexity_sigma(), create_counter(), create_new_ent_list(), do_atomize_call(), do_loop_expansion(), do_loop_nest_unswitching(), do_loop_unroll_with_prologue(), do_scalar_renaming_in_vertex(), do_split_structure_parameter(), do_symbolic_tiling(), do_terapix_argument_handler(), find_or_create_newInd(), fix_loop_index_sign(), generate_optimized_code_for_loop_nest(), generate_scalar_variables(), generate_scalar_variables_from_list(), hpfc_new_variable(), inline_expression_call(), loop_to_complexity(), make_loadsave_statement(), make_new_entity(), make_new_index_entity(), make_new_simd_vector_with_prefix(), make_shuffle_statement(), process_true_call_stat(), regenerate_toggles(), sesamify(), set_the_i(), simd_atomize_this_expression(), simd_loop_unroll(), simplify_subscript(), st_compute_ith_local_index(), terapix_loop_handler(), and terapix_optimize_accumulator().

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

◆ AddEntityToCurrentModuleWithoutDeclaration()

void AddEntityToCurrentModuleWithoutDeclaration ( entity  e)

Add a variable entity to the current module declarations.

There is no declaration local to a statement in Fortran:

Definition at line 271 of file variable.c.

271  {
272  entity module_e = get_current_module_entity();
273  /* There is no declaration local to a statement in Fortran: */
274  statement module_s = c_module_p(module_e) ? get_current_module_statement()
276 
277  AddLocalEntityToDeclarationsOnly(e, module_e, module_s);
278 }
void AddLocalEntityToDeclarationsOnly(entity e, entity module, statement s)
Add the variable entity e to the list of variables of the function module.
Definition: variable.c:253

References AddLocalEntityToDeclarationsOnly(), c_module_p(), get_current_module_entity(), get_current_module_statement(), and statement_undefined.

+ Here is the call graph for this function:

◆ AddEntityToDeclarations()

void AddEntityToDeclarations ( entity  e,
entity  module 
)

END_EOLE.

Add a global variable e to the variable declarations of a module.

It does nothing if e is already in the list.

In the general case you should use AddLocalEntityToDeclarations() or AddEntityToCurrentModule() instead.

Since in C, variables should be added to the statement declarations too, only use this function for special stuff like compilation unit and special area delarations in the module bootstrapping.

Add the variable to the module declarations

Add the declaration only if not already here:

Parameters
moduleodule

Definition at line 108 of file variable.c.

108  {
109  pips_assert("module is fine",entity_consistent_p(module));
110  pips_assert("entity is fine",entity_consistent_p(e));
111  /* Add the variable to the module declarations */
112  list l =
114  /* Add the declaration only if not already here: */
117 }
bool entity_consistent_p(entity p)
Definition: ri.c:2530
#define gen_chunk_undefined_p(c)
Definition: genC.h:75
void * gen_find_eq(const void *item, const list seq)
Definition: list.c:422
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
static char * module
Definition: pips.c:74
code EntityCode(entity e)
this function checks that e has an initial value code.
Definition: entity.c:301
#define code_declarations(x)
Definition: ri.h:784
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References code_declarations, CONS, ENTITY, entity_consistent_p(), EntityCode(), gen_chunk_undefined_p, gen_find_eq(), module, and pips_assert.

Referenced by add_entity_to_declarations(), AddCommonToModule(), AddEntityToHostAndNodeModules(), AddEntityToModule(), array_scalar_access_to_bank_communication(), array_scalar_access_to_compute_communication(), build_new_variable(), clone_variable_with_new_name(), create_bound_entity(), create_local_index(), create_local_index2(), create_new_common_variable(), create_private_integer_variable_for_new_module(), create_state_variable(), create_stub_entity(), declare_common_variables_in_module(), DeclareIntrinsic(), DeclareVariable(), entity_flow_or_context_sentitive_heap_location(), find_entity(), generic_make_entity_copy_with_new_name(), GenericAddLocalEntityToDeclarations(), gfc2pips_namespace(), init_c_areas(), init_c_implicit_variables(), init_host_and_node_entities(), InitAreas(), inline_expression_call(), insert_run_time_communications(), loop_strip_mine(), make_common_entity(), make_empty_module(), make_emulated_shared_variable(), make_new_local_variables(), MakeCommon(), MakeCurrentFunction(), MakeDerivedEntity(), MakeExternalFunction(), module_to_wp65_modules(), new_synonym(), reference_conversion_computation(), and ScanFormalParameters().

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

◆ AddLocalEntityToDeclarations()

void AddLocalEntityToDeclarations ( entity  e,
entity  module,
statement  s 
)

Add the variable entity e to the list of variables of the function module.

For a C module, the variable is also added as local to the given statement s. A global variable to a module should be added to the global statement module (given by get_current_module_statement() for example. The consistency of the internal representation is maintained.

Parameters
evariable entity to add
moduleentity
sstatement where entity must be added. A new declaraton statement for e is added. It can be statement_undefined in the case of a Fortran module
Parameters
moduleodule

Definition at line 233 of file variable.c.

233  {
235 }
static void GenericAddLocalEntityToDeclarations(entity e, entity module, statement s, bool add_declaration_statement_p)
See the two user interfaces below.
Definition: variable.c:152

References GenericAddLocalEntityToDeclarations(), and module.

Referenced by AddEntityToCompilationUnit(), AddEntityToCurrentModule(), do_clone_entity(), do_group_constants_terapix(), do_kernelize(), do_split_structures(), effects_to_dma(), FixCReturnStatements(), generic_clone_variable_with_unique_name(), inline_expression_call(), make_new_simd_vector_with_prefix(), make_reduction_vector_entity(), mpi_initialize(), outliner_parameters(), outliner_scan(), redeclaration_enter_statement(), sac_make_new_variable(), statements_localize_declarations(), step_RT_set_local_declarations(), and terapix_loop_optimizer().

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

◆ AddLocalEntityToDeclarationsOnly()

void AddLocalEntityToDeclarationsOnly ( entity  e,
entity  module,
statement  s 
)

Add the variable entity e to the list of variables of the function module.

For a C module, the variable is also added as local to the given statement s. A global variable to a module should be added to the global statement module (given by get_current_module_statement() for example. The consistency of the internal representation is not maintained, but this is useful for the controlizer.

Parameters
evariable entity to add
moduleentity
sstatement where entity must be added. No new declaration ststement is added. It can be statement_undefined in the case of a Fortran module
Parameters
moduleodule

Definition at line 253 of file variable.c.

253  {
255 }

References GenericAddLocalEntityToDeclarations(), and module.

Referenced by AddEntityToCurrentModuleWithoutDeclaration(), clean_up_sequences_rewrite(), copy_write_statement_with_cumulated_regions(), and generic_clone_variable_with_unique_name().

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

◆ array_with_numerical_bounds_p()

bool array_with_numerical_bounds_p ( entity  a)

bool array_with_numerical_bounds_p(entity a) input : an array entity output : true if all bounds of all dimensions are numerical false otherwise (adjustable arrays, formal parameters).

modifies : nothing comment :

Definition at line 1266 of file variable.c.

1267 {
1268  int nb_dim = NumberOfDimension(a);
1269  int d;
1270  bool numerical_bounds_p = true;
1271 
1272  for(d=1; d <= nb_dim && numerical_bounds_p; d++) {
1273  dimension dd = entity_ith_dimension(a, nb_dim);
1274  expression l = dimension_lower(dd);
1275  expression u = dimension_upper(dd);
1276 
1277  numerical_bounds_p = expression_with_constant_signed_integer_value_p(l)
1279  }
1280 
1281  return numerical_bounds_p;
1282 }
dimension entity_ith_dimension(entity e, int i)
Another semantics would be: is this reference r to e a kill for e? In general, this cannot be answere...
Definition: variable.c:1228
bool expression_with_constant_signed_integer_value_p(expression e)
The expression may be complicated but all its leaves are constants or parameters.
Definition: expression.c:960
int NumberOfDimension(entity)
Definition: size.c:588
#define dimension_lower(x)
Definition: ri.h:980
#define dimension_upper(x)
Definition: ri.h:982

References dimension_lower, dimension_upper, entity_ith_dimension(), expression_with_constant_signed_integer_value_p(), and NumberOfDimension().

Referenced by MakeEquivAtom().

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

◆ call_contains_alternate_returns_p()

bool call_contains_alternate_returns_p ( call  c)

Definition at line 1835 of file variable.c.

1836 {
1837  bool contains_p = false;
1838 
1840  if((contains_p = actual_label_replacement_p(arg)))
1841  break;
1842 
1843  return contains_p;
1844 }
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
Definition: newgen_list.h:179
bool actual_label_replacement_p(expression eap)
Assumes that eap is a call.
Definition: variable.c:1811
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define call_arguments(x)
Definition: ri.h:711

References actual_label_replacement_p(), call_arguments, EXPRESSION, and FOREACH.

Referenced by text_test().

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

◆ clone_variable_with_unique_name()

entity clone_variable_with_unique_name ( entity  old_variable,
statement  declaration_statement,
string  prefix,
string  suffix,
entity  module 
)

Clone a variable with a new user name.

Parameters
old_variableis the variable to clone
declaration_statementis the enclosing sequence (block) defining the scope where the new variable is visible. It must be a statement of kind sequence.
prefixis the prefix to prepend to the variable name
suffixis the suffix to append to the variable name
moduleis the entity of the module the variable will belong to

Is there is already a variable with this name, new names are tried with numerical suffixes.

Returns
the entity of the new variable. Its fields are copies from the old one. That means that there may be some aliasing since the old one and the new one have the same offset (in the sense of IR RAM) and that use-def chains and dependence graphs are going to be wrong.

The clone variable is added to the declaration list of "statement_declaration" and to the code declarations of module "module". A new declaration statement is inserted in the sequence of "declaration_statement". This maintains the consistency of PIPS internal representation for C and Fortran code.

Parameters
old_variableld_variable
declaration_statementeclaration_statement
prefixrefix
suffixuffix
moduleodule

Definition at line 562 of file variable.c.

566  {
568  declaration_statement,
569  prefix,
570  suffix,
571  module,
572  true);
573 }
static entity old_variable
void propagate_synonym(s, old, new) statement s; entity old, new;
Definition: dynamic.c:859
entity generic_clone_variable_with_unique_name(entity old_variable, statement declaration_statement, string prefix, string suffix, entity module, bool insert_p)
clone a variable with a new name.
Definition: variable.c:509
static const char * prefix

References generic_clone_variable_with_unique_name(), module, old_variable, and prefix.

Referenced by move_declaration_control_node_declarations_to_statement().

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

◆ const_variable_p()

bool const_variable_p ( entity  v)

Definition at line 1687 of file variable.c.

1688 {
1690 }
bool qualified_variable_p(entity v, unsigned int is_qualified)
The variable may turn out to be a function.
Definition: variable.c:1666
@ is_qualifier_const
Definition: ri.h:2127

References is_qualifier_const, and qualified_variable_p().

Referenced by EvalSyntax(), expression_constant(), extended_expression_constant_p(), global_source_to_sinks(), and reference_dependence_variable_check_and_add().

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

◆ discard_module_declaration_text()

void discard_module_declaration_text ( entity  a_module)

Discard the decls_text string of the module code to make the prettyprinter ignoring the textual declaration and remake all from the declarations without touching the corresponding property (PRETTYPRINT_ALL_DECLARATIONS).

RK, 31/05/1994.

Parameters
a_module_module

Definition at line 1696 of file variable.c.

1697 {
1698  code c = entity_code(a_module);
1699  string s = code_decls_text(c);
1700 
1701  free(s);
1702  code_decls_text(c) = strdup("");
1703 }
void free(void *)
code entity_code(entity e)
Definition: entity.c:1098
#define code_decls_text(x)
Definition: ri.h:786
char * strdup()

References code_decls_text, entity_code(), free(), and strdup().

Referenced by add_entity_to_declarations(), atomizer(), and linearize_array_generic().

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

◆ entity_atomic_reference_p()

bool entity_atomic_reference_p ( entity  e)

Any reference r such that reference_variable(r)==e accesses all bytes (or bits) allocated to variable e.

In other words, any write of e is a kill. At least, if the reference indices are NIL in the case of pointers.

The Newgen type of e must be "variable".

FI: This function is much too naive because array dimensions may be hidden anywhere in a chain of typdef types. It might be much better to use type_depth() or to write a more specific function. Well, for some unknown reason, type_depth is not the answer.

Kludge to work in case the dimension is part of the typedef or part of the type.

if(ENDP(variable_dimensions(uvt)) && ENDP(variable_dimensions(vt))) {

The property is not true for overloaded, string, derived (typedef is impossible here)

Definition at line 1163 of file variable.c.

1164 {
1165  type t = entity_type(e);
1166  //variable vt = type_variable(t);
1167  type ut = ultimate_type(entity_type(e));
1168  variable uvt = type_variable(ut);
1169  bool atomic_p = false;
1170 
1171  pips_assert("entity e is a variable", type_variable_p(ut));
1172 
1173  /* Kludge to work in case the dimension is part of the typedef or
1174  part of the type. */
1175  /* if(ENDP(variable_dimensions(uvt)) &&
1176  ENDP(variable_dimensions(vt))) {*/
1177  if(type_depth(t)==0) {
1178  /* The property is not true for overloaded, string, derived
1179  (typedef is impossible here) */
1180  basic ubt = variable_basic(uvt);
1181  atomic_p = basic_int_p(ubt) || basic_float_p(ubt) || basic_logical_p(ubt)
1182  || basic_complex_p(ubt) || basic_bit_p(ubt) || basic_pointer_p(ubt);
1183  }
1184 
1185  return atomic_p;
1186 }
size_t type_depth(type)
Number of steps to access the lowest leave of type t without dereferencing.
Definition: type.c:4880
#define basic_complex_p(x)
Definition: ri.h:626
#define basic_int_p(x)
Definition: ri.h:614
#define type_variable(x)
Definition: ri.h:2949
#define basic_pointer_p(x)
Definition: ri.h:635
#define basic_bit_p(x)
Definition: ri.h:632
#define variable_basic(x)
Definition: ri.h:3120
#define basic_logical_p(x)
Definition: ri.h:620
#define basic_float_p(x)
Definition: ri.h:617

References basic_bit_p, basic_complex_p, basic_float_p, basic_int_p, basic_logical_p, basic_pointer_p, entity_type, pips_assert, type_depth(), type_variable, type_variable_p, ultimate_type(), and variable_basic.

Referenced by impact_check_in_path(), and TestCoupleOfReferences().

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

◆ entity_integer_scalar_p()

bool entity_integer_scalar_p ( entity  e)

for variables (like I), not constants (like 1)! use integer_constant_p() for constants

The integer type may be signed or unsigned.

Definition at line 1130 of file variable.c.

1131 {
1132  return(entity_scalar_p(e) &&
1134 }
bool entity_scalar_p(entity e)
The concrete type of e is a scalar type.
Definition: variable.c:1113

References basic_int_p, entity_scalar_p(), entity_type, type_variable, ultimate_type(), and variable_basic.

Referenced by entity_to_formal_integer_parameters(), evaluate_var_to_complexity(), expression_int_scalar(), hpfc_overlap_kill_unused_scalars_rewrite(), loop_variant_list(), normalize_reference(), NormalizeReference(), sc_entity_to_formal_integer_parameters(), and scalar_written_in_call().

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

◆ entity_ith_dimension()

dimension entity_ith_dimension ( entity  e,
int  i 
)

Another semantics would be: is this reference r to e a kill for e? In general, this cannot be answered at the entity level only (see previous function) and the reference itself must be passed as an argument.

FI: I'm not sure of the best location for this function in ri-util (no file reference.c).

Definition at line 1228 of file variable.c.

1229 {
1230  cons *pd;
1231  type t = entity_type(e);
1232 
1233  pips_assert("entity_ith_dimension", type_variable_p(t));
1234 
1236 
1237  while (pd != NIL && --i > 0)
1238  pd = CDR(pd);
1239 
1240  pips_assert("entity_ith_dimension", pd != NIL);
1241 
1242  return(DIMENSION(CAR(pd)));
1243 }
#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 variable_dimensions(x)
Definition: ri.h:3122

References CAR, CDR, DIMENSION, entity_type, NIL, pips_assert, type_variable, type_variable_p, and variable_dimensions.

Referenced by array_with_numerical_bounds_p(), create_init_common_param_for_arrays(), declaration_with_overlaps(), entity_ith_bounds(), entity_unbounded_p(), expr_compute_local_index(), get_entity_dimensions(), get_ith_dim_new_declaration(), hpfc_compute_distribute_constraints(), and hpfc_compute_unicity_constraints().

+ Here is the caller graph for this function:

◆ entity_non_pointer_scalar_p()

bool entity_non_pointer_scalar_p ( entity  e)
Returns
true if the entity is a scalar but not a pointer, false otherwise. (takes care of typedefs).

The property is not true for overloaded, string, derived

Definition at line 1193 of file variable.c.

1194 {
1195  bool atomic_p = false;
1197  if(type_variable_p(ct)) {
1198  variable vt = type_variable(ct);
1199 
1200  //pips_assert("entity e is a variable", type_variable_p(ct));
1201  //entity can be a functional in C too
1202 
1203  if(ENDP(variable_dimensions(vt)))
1204  {
1205  /* The property is not true for overloaded, string, derived
1206  */
1207  basic bt = variable_basic(vt);
1208  atomic_p = basic_int_p(bt) || basic_float_p(bt) || basic_logical_p(bt)
1209  || basic_complex_p(bt) || basic_bit_p(bt);
1210  }
1211 
1212  }
1213  return atomic_p;
1214 }
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
type entity_basic_concrete_type(entity)
retrieves or computes and then returns the basic concrete type of an entity
Definition: type.c:3677

References basic_bit_p, basic_complex_p, basic_float_p, basic_int_p, basic_logical_p, ENDP, entity_basic_concrete_type(), type_variable, type_variable_p, variable_basic, and variable_dimensions.

+ Here is the call graph for this function:

◆ entity_scalar_p()

bool entity_scalar_p ( entity  e)

The concrete type of e is a scalar type.

The programmer cannot index this variable.

Note: variable e may appear indexed somewhere in the PIPS internal representation if this is linked to some semantics.

Definition at line 1113 of file variable.c.

1114 {
1115  bool return_value = false;
1116 
1117  type t = ultimate_type(entity_type(e));
1118  if(type_variable_p(t)) {
1119  return_value = ENDP(variable_dimensions(type_variable(t)))
1120  && ! pointer_type_p(t);
1121  }
1122  return return_value;
1123 }
bool pointer_type_p(type)
Check for scalar pointers.
Definition: type.c:2993

References ENDP, entity_type, pointer_type_p(), type_variable, type_variable_p, ultimate_type(), and variable_dimensions.

Referenced by address_of_scalar(), alias_check_in_caller(), alias_check_in_module(), AnalyzeData(), append_declaration_sc_if_exact_without_constraints(), array_bound_check_instrumentation(), assign_tmp_to_exp(), atomizer_of_loop(), call_STEP_subroutine3(), check_fortran_declaration_dependencies(), comp_regions_of_read(), comp_regions_of_write(), create_step_regions(), dimensions_to_dma(), do_clone_entity(), do_group_constants_terapix(), do_group_count_elements_reduce(), do_scalar_renaming(), do_split_structure(), effects_to_dma(), entities_maymust_conflict_p(), entity_integer_scalar_p(), entity_local_variable_p(), expression_reference_number(), expression_to_polynome(), find_or_create_scalar_entity(), find_tmp_of_exp(), generate_call_init_regionArray(), generic_effects_maymust_read_or_write_scalar_entity_p(), get_entity_step_commsize(), heap_intrinsic_to_post_pv(), icm_loop_rwt(), InitCompDesc(), initialize_and_verify_common_variable(), initialize_and_verify_local_variable(), inline_expression_call(), insert_initialization(), make_fields_assignment_instruction(), normalize_microcode(), other_cool_enough_for_a_last_substitution(), points_to_reference_to_type(), process_static_initialization(), promote_local_entities(), reference_scalar_p(), region_translation(), remove_unread_variables(), set_add_scalars(), simd_vector_entity_p(), simplify_dg(), store_expression(), store_initial_value(), text_comp_regions(), verify_used_before_set_expression(), and verify_used_before_set_statement_flt().

+ Here is the call graph for this function:

◆ entity_static_variable_p()

bool entity_static_variable_p ( entity  e)

return true if the entity is declared with the keyword static

Definition at line 1146 of file variable.c.

1146  {
1147  storage s = entity_storage(e);
1149 }
bool static_area_p(entity aire)
Definition: area.c:77
#define entity_storage(x)
Definition: ri.h:2794
#define storage_ram_p(x)
Definition: ri.h:2519
#define ram_section(x)
Definition: ri.h:2249
#define storage_ram(x)
Definition: ri.h:2521

References entity_storage, ram_section, static_area_p(), storage_ram, and storage_ram_p.

Referenced by cumul_and_update_effects_of_statement(), declaration_to_post_pv(), do_scalar_renaming(), module_to_value_mappings(), move_declaration_control_node_declarations_to_statement(), redeclaration_enter_statement(), split_initializations_in_statement(), xml_Chain_Graph(), xml_Compute_and_Need(), and xml_Region_Parameter().

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

◆ entity_unbounded_p()

bool entity_unbounded_p ( entity  e)

bool entity_unbounded_p(entity e) input : an array entity output : true if the last dimension of the array is unbounded (*), false otherwise.

modifies : nothing comment :

Definition at line 1252 of file variable.c.

1253 {
1254  int nb_dim = NumberOfDimension(e);
1255 
1256  return(unbounded_dimension_p(entity_ith_dimension(e, nb_dim)));
1257 }
bool unbounded_dimension_p(dimension dim)
bool unbounded_dimension_p(dim) input : a dimension of an array entity.
Definition: expression.c:1130

References entity_ith_dimension(), NumberOfDimension(), and unbounded_dimension_p().

+ Here is the call graph for this function:

◆ entity_volatile_variable_p()

bool entity_volatile_variable_p ( entity  v)
Returns
whether entity is a "volatile" variable

See also entity_register_p()

Definition at line 1637 of file variable.c.

1638 {
1639  type t = entity_type(v);
1640  pips_assert("the entity must have type variable", type_variable_p(t));
1641 
1643 }
bool volatile_variable_p(variable v)
Definition: variable.c:1649

References entity_type, pips_assert, type_variable, type_variable_p, and volatile_variable_p().

+ Here is the call graph for this function:

◆ find_or_create_scalar_entity()

entity find_or_create_scalar_entity ( const char *  name,
const char *  module_name,
tag  base 
)

Looks for an entity which should be a scalar of the specified basic.

If found, returns it, else one is created.

If the entity is not a scalar, it aborts.

Parameters
nameame
module_nameodule_name
basease

Definition at line 1025 of file variable.c.

1026 {
1028  string nom = concatenate(module_name, MODULE_SEP_STRING, name, NULL);
1029 
1031  {
1032  pips_assert("find_or_create_scalar_entity",
1033  (entity_scalar_p(e) && entity_basic_p(e, base)));
1034 
1035  return(e);
1036  }
1037 
1038  return(make_scalar_entity(name, module_name, MakeBasic(base)));
1039 }
bdt base
Current expression.
Definition: bdt_read_paf.c:100
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
#define MODULE_SEP_STRING
Definition: naming-local.h:30
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
void * gen_find_tabulated(const char *, int)
Definition: tabulated.c:218
entity make_scalar_entity(const char *name, const char *module_name, basic base)
entity make_scalar_entity(name, module_name, base)
Definition: variable.c:331
bool entity_basic_p(entity e, enum basic_utype basictag)
return true if the basic associated with entity e matchs the passed tag
Definition: entity.c:1405
basic MakeBasic(int)
END_EOLE.
Definition: type.c:128
#define entity_undefined
Definition: ri.h:2761
#define entity_domain
newgen_syntax_domain_defined
Definition: ri.h:410

References base, concatenate(), entity_basic_p(), entity_domain, entity_scalar_p(), entity_undefined, gen_find_tabulated(), make_scalar_entity(), MakeBasic(), module_name(), MODULE_SEP_STRING, and pips_assert.

Referenced by create_state_variable(), get_ith_dummy(), make_host_and_node_modules(), and region_entity_variable_to_new_declare_entity().

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

◆ find_or_create_typed_entity()

entity find_or_create_typed_entity ( string  name,
const char *  module_name,
tag  base 
)

Looks for an entity of the specified basic.

If found, returns it, else one is created.

Parameters
nameame
module_nameodule_name
basease

Definition at line 1046 of file variable.c.

1050 {
1052  string nom = concatenate(module_name, MODULE_SEP_STRING, name, NULL);
1053 
1055  {
1056  pips_assert("type is okay", entity_basic_p(e, base));
1057 
1058  return(e);
1059  }
1060 
1061  return(make_scalar_entity(name, module_name, MakeBasic(base)));
1062 }

References base, concatenate(), entity_basic_p(), entity_domain, entity_undefined, gen_find_tabulated(), make_scalar_entity(), MakeBasic(), module_name(), MODULE_SEP_STRING, and pips_assert.

Referenced by argument_bound_entity(), and hpfc_init_run_time_entities().

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

◆ formal_context_variable_p()

bool formal_context_variable_p ( entity  v)

Such pseudo-variables are generated by the points-to analysis.

See also entity_in_formal_area_p()

Definition at line 1535 of file variable.c.

1536 {
1537  bool formal_p = false;
1538  storage s = entity_storage(v);
1539  if(storage_ram_p(s)) {
1540  ram r = storage_ram(s);
1541  entity s = ram_section(r);
1542  formal_p = formal_area_p(s);
1543  }
1544  return formal_p;
1545 }
bool formal_area_p(entity aire)
Definition: area.c:95

References entity_storage, formal_area_p(), ram_section, storage_ram, and storage_ram_p.

Referenced by create_values_for_simple_effect().

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

◆ formal_label_replacement_p()

bool formal_label_replacement_p ( entity  fp)

string lsp = "FORMAL_RETURN_LABEL_";

Parameters
fpp

Definition at line 1797 of file variable.c.

1798 {
1799  bool replacement_p = false;
1800 
1801  const char* fpn = entity_local_name(fp);
1802  const char* lsp = get_string_property("PARSER_FORMAL_LABEL_SUBSTITUTE_PREFIX");
1803  /* string lsp = "FORMAL_RETURN_LABEL_"; */
1804 
1805  replacement_p = (strstr(fpn, lsp)==fpn);
1806 
1807  return replacement_p;
1808 }
char * get_string_property(const char *)
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

References entity_local_name(), and get_string_property().

Referenced by DeclareVariable(), MakeFormalParameter(), text_entity_declaration(), and words_parameters().

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

◆ formal_parameter_p()

bool formal_parameter_p ( entity  v)

Definition at line 1489 of file variable.c.

1490 {
1491  storage s = entity_storage(v);
1492  bool formal_p = storage_formal_p(s);
1493 
1494  return formal_p;
1495 }
#define storage_formal_p(x)
Definition: ri.h:2522

References entity_storage, and storage_formal_p.

Referenced by alias_propagation(), array_bound_check_instrumentation(), compute_points_to_gen_set(), compute_points_to_kill_set(), create_pointer_to_array_stub_points_to(), create_stub_entity(), dag_compute_outputs(), do_array_expansion(), do_check_isolate_statement_preconditions_on_call(), do_gpu_qualify_pointers(), do_slightly_rename_entities(), do_split_structure(), do_split_structure_return_hook(), entity_formal_p(), entity_may_conflict_with_a_formal_parameter_p(), entity_to_declaring_statement(), expand_points_to_domain(), formal_parameter_points_to_cell_p(), freia_cleanup_sequence_rec(), generic_points_to_cells_translation(), generic_transformer_intra_to_inter(), init_dynamic_check_list(), init_points_to_analysis(), initialization_list_to_statements(), initialize_dynamic_check_list(), inline_expression_call(), interprocedural_abc_call(), make_loadsave_statement(), MakeEquivAtom(), new_local_image_variable(), normalize_microcode(), offset_in_caller(), points_to_cells_parameters(), points_to_function_projection(), points_to_set_block_projection(), potential_out_effects_p(), promote_local_entities(), reference_to_points_to(), retype_formal_parameters(), source_to_sinks(), split_structures(), statement_insertion_fix_access(), statements_localize_declarations(), terapix_suitable_loop_bound_walker(), update_unstructured_declarations(), UpdateEntity(), used_before_set(), variable_to_abstract_location(), verify_formal_and_common_variables(), and wipeout_entity().

◆ generate_pseudo_formal_variable_for_formal_label()

entity generate_pseudo_formal_variable_for_formal_label ( const char *  p,
int  l 
)

string lsp = "FORMAL_RETURN_LABEL_";

let's assume that there are fewer than 999 formal label arguments

Generate a variable of type CHARACTER*(*). See gram.y, "lg_fortran_type:". It is postponed to MakeFormalParameter

fs may already exists if a ParserError occured or if an edit of the source file occured

Not so sure because CleanUpEntities() is called later, not before. This function is cvalled by the parser before the module declaration rule is reduced.

Too bad for the memory leaks: they should not occur frequently

Too early because the current_module_entity is not yet fully defined.

AddEntityToDeclarations(fs, get_current_module_entity());

Definition at line 1744 of file variable.c.

1745 {
1746  entity fs = entity_undefined;
1747  const char* lsp = get_string_property("PARSER_FORMAL_LABEL_SUBSTITUTE_PREFIX");
1748  /* string lsp = "FORMAL_RETURN_LABEL_"; */
1749  /* let's assume that there are fewer than 999 formal label arguments */
1750  char buffer[4];
1751  string sn = &buffer[0];
1752  string full_name = string_undefined;
1753 
1754  pips_assert("No more than 999 alternate returns", 0 <= l && l < 999);
1755 
1756  sprintf(buffer, "%d", l);
1757 
1758  /* Generate a variable of type CHARACTER*(*). See gram.y,
1759  "lg_fortran_type:". It is postponed to MakeFormalParameter */
1760  full_name = strdup(concatenate(p, MODULE_SEP_STRING, lsp, sn, NULL));
1762  fs = make_entity(full_name,
1765  value_undefined);
1766  }
1767  else {
1768  /* fs may already exists if a ParserError occured or if an edit of the
1769  source file occured */
1770  free(full_name);
1772 
1773  /* Not so sure because CleanUpEntities() is called later, not
1774  before. This function is cvalled by the parser before the module
1775  declaration rule is reduced. */
1776  /*
1777  pips_assert("The type, storage and value are undefined\n",
1778  type_undefined_p(entity_type(fs))
1779  && storage_undefined_p(entity_storage(fs))
1780  && value_undefined_p(entity_initial(fs)));
1781  */
1782  /* Too bad for the memory leaks: they should not occur frequently */
1786  }
1787 
1788  /* Too early because the current_module_entity is not yet fully defined. */
1789  /* AddEntityToDeclarations(fs, get_current_module_entity()); */
1790 
1791  pips_debug(8, "Generated replacement for formal return label: %s\n",
1792  entity_name(fs));
1793 
1794  return fs;
1795 }
#define full_name(dir, name)
Definition: compile.c:414
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define string_undefined
Definition: newgen_types.h:40
#define make_entity(n, t, s, i)
#define value_undefined
Definition: ri.h:3016
#define entity_name(x)
Definition: ri.h:2790
#define type_undefined
Definition: ri.h:2883
#define storage_undefined
Definition: ri.h:2476
#define entity_initial(x)
Definition: ri.h:2796
static string buffer
Definition: string.c:113

References buffer, concatenate(), entity_domain, entity_initial, entity_name, entity_storage, entity_type, entity_undefined, free(), full_name, gen_find_tabulated(), get_string_property(), make_entity, MODULE_SEP_STRING, pips_assert, pips_debug, storage_undefined, strdup(), string_undefined, type_undefined, and value_undefined.

+ Here is the call graph for this function:

◆ generate_string_for_alternate_return_argument()

expression generate_string_for_alternate_return_argument ( string  i)

Definition at line 1721 of file variable.c.

1722 {
1724  char buffer[9];
1725 
1726  pips_assert("A label cannot be more than 5 character long", strlen(i)<=5);
1727  buffer[0]='"';
1728  buffer[1]='*';
1729  buffer[2]=0;
1730 
1731  strcat(&buffer[0], i);
1732 
1733  buffer[strlen(i)+2]='"';
1734  buffer[strlen(i)+3]=0;
1735 
1737 
1738  return e;
1739 }
expression MakeCharacterConstantExpression(string s)
END_EOLE.
Definition: constant.c:573
#define expression_undefined
Definition: ri.h:1223

References buffer, expression_undefined, MakeCharacterConstantExpression(), pips_assert, and strdup().

+ Here is the call graph for this function:

◆ generate_variable_with_unique_name_to_module()

entity generate_variable_with_unique_name_to_module ( const char *  seed_name,
const char *  prefix,
const char *  suffix,
entity  module 
)

Generate a new variable name from a seed name to a module.

Parameters
seed_nameis the main name of the variable name to generate
prefixis the prefix to prepend to the variable name
suffixis the suffix to append to the variable name
moduleis the entity of the module the variable will belong to

Is there is already a variable with this name, a new one is tried with some numerical suffixes.

Returns
the entity of the new variable. Its fields are to be filled later before use.

First try a basic name without numeric suffix:

Free the old name since it was already used:

And try a new one with a number suffix:

Parameters
seed_nameeed_name
prefixrefix
suffixuffix
moduleodule

Definition at line 460 of file variable.c.

463  {
464  const char* format = fortran_module_p(module) ?
465  "%s "MODULE_SEP_STRING "%s%s%s":
466  "%s "MODULE_SEP_STRING "0" BLOCK_SEP_STRING "%s%s%s";
467 
468  const char* format_num = fortran_module_p(module) ?
469  "%s "MODULE_SEP_STRING "%s%s%s%d":
470  "%s "MODULE_SEP_STRING "0" BLOCK_SEP_STRING "%s%s%s%d";
471 
472  const char* module_name = module_local_name(module);
473  string variable_name;
474  int number = 0;
475 
476  /* First try a basic name without numeric suffix: */
477  asprintf(&variable_name, format, module_name, prefix, seed_name, suffix);
479  {
480  /* Free the old name since it was already used: */
482  /* And try a new one with a number suffix: */
483  asprintf(&variable_name, format_num, module_name, prefix, seed_name, suffix, number++);
484  };
485 
490  return e;
491 }
#define asprintf
Definition: misc-local.h:225
#define BLOCK_SEP_STRING
Scope separator.
Definition: naming-local.h:50
static bool unique_entity_name_p(const char *name, entity in_module)
Handling of entity as program variables (see also entity.c for generic entities)
Definition: variable.c:49
const char * module_local_name(entity e)
Returns the module local user name.
Definition: entity.c:582
bool fortran_module_p(entity m)
Test if a module is in Fortran.
Definition: entity.c:2799
char * variable_name(Variable v)
polynome_ri.c
Definition: polynome_ri.c:73

References asprintf, BLOCK_SEP_STRING, fortran_module_p(), free(), make_entity, module, module_local_name(), module_name(), MODULE_SEP_STRING, prefix, storage_undefined, type_undefined, unique_entity_name_p(), value_undefined, and variable_name().

Referenced by generic_clone_variable_with_unique_name().

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

◆ generic_clone_variable_with_unique_name()

entity generic_clone_variable_with_unique_name ( entity  old_variable,
statement  declaration_statement,
string  prefix,
string  suffix,
entity  module,
bool  insert_p 
)

clone a variable with a new name.

The new variable is added in the different declaration lists.

Parameters
insert_pIf true, for C code, a new declaration statement is inserted in "declaration_statement" to maintain the internal representation consistency. Else, no new declaration statement is inserted and the internal representation is no longer consistent for C code.
Returns
the new cloned entity

See useful interface below

Clone the attributes of the old variable into the new one:

Parameters
old_variableld_variable
declaration_statementeclaration_statement
prefixrefix
suffixuffix
moduleodule
insert_pnsert_p

Definition at line 509 of file variable.c.

514  {
515  const char * seed_name = entity_user_name(old_variable);
517  prefix,
518  suffix,
519  module);
520 
521  /* Clone the attributes of the old variable into the new one: */
525 
526  if(insert_p)
527  AddLocalEntityToDeclarations(new_variable, module, declaration_statement);
528  else
529  AddLocalEntityToDeclarationsOnly(new_variable, module, declaration_statement);
530 
531  return new_variable;
532 }
type copy_type(type p)
TYPE.
Definition: ri.c:2655
value copy_value(value p)
VALUE.
Definition: ri.c:2784
storage copy_storage(storage p)
STORAGE.
Definition: ri.c:2228
static entity new_variable
entity to be replaced, the primary?
Definition: dynamic.c:860
entity generate_variable_with_unique_name_to_module(const char *seed_name, const char *prefix, const char *suffix, entity module)
Generate a new variable name from a seed name to a module.
Definition: variable.c:460

References AddLocalEntityToDeclarations(), AddLocalEntityToDeclarationsOnly(), copy_storage(), copy_type(), copy_value(), entity_initial, entity_storage, entity_type, entity_user_name(), generate_variable_with_unique_name_to_module(), module, new_variable, old_variable, and prefix.

Referenced by clone_variable_with_unique_name(), and move_declaration_control_node_declarations_to_statement().

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

◆ GenericAddLocalEntityToDeclarations()

static void GenericAddLocalEntityToDeclarations ( entity  e,
entity  module,
statement  s,
bool  add_declaration_statement_p 
)
static

See the two user interfaces below.

SG: fix the entity storage if undefined it basically recompute the offset of a scalar variable I have not found how to do it for a variable size array, so I just dropped the case -> a variable size array must be allocated in a different area, STACK_AREA, where offsets are not computed

current_offset_of_area fails if SizeOfArray is not computable because e is a varying length array

The variable e should be allocated in the Stack area

Both in C and Fortran, all variables and useful entities are stored in code_declarations, in the symbol table.

In C, the variables, but the formal parameters, are local to a statement

If undeclared in s, variable e is added in the statement_declarations field.

The entity may have already been declared... This could be an assert but Serge seems to redeclare several times the same variables when performing inlining

The C prettyprinter is not based on code_declarations or statement_declarations but on declaration statements, which happen to be continue statement for the time being.

To preserve the source layout, declarations are statements

Definition at line 152 of file variable.c.

153  {
154  /* SG: fix the entity storage if undefined
155  * it basically recompute the offset of a scalar variable
156  * I have not found how to do it for a variable size array, so I
157  * just dropped the case -> a variable size array must be allocated
158  * in a different area, STACK_AREA, where offsets are not computed
159  */
161  {
164  int tmp;
165  /* current_offset_of_area fails if SizeOfArray is not computable
166  * because e is a varying length array
167  */
168  if(SizeOfArray(e,&tmp)) {
171  dynamic_area,
173  NIL)
174  );
175  }
176  else {
177  /* The variable e should be allocated in the Stack area */
178  pips_user_warning("Varying size for array \"%s\"\n", entity_name(e));
179  pips_user_warning("Not yet supported properly by PIPS\n");
180  }
181  }
182 
183  /* Both in C and Fortran, all variables and useful entities are
184  stored in code_declarations, in the symbol table. */
186 
187  /* In C, the variables, but the formal parameters, are local to a
188  statement */
189  if (c_module_p(module)) {
190  /* If undeclared in s, variable e is added in the
191  statement_declarations field. */
192  if(!statement_block_p(s))
194  pips_assert("add declarations to statement block",statement_block_p(s));
195 
197  pips_assert("Calling AddLocalEntityToDeclarations from c_module "
198  "with valid statement", !statement_undefined_p(s) );
199 
200  /* The entity may have already been declared... This could be an
201  assert but Serge seems to redeclare several times the same
202  variables when performing inlining */
205 
206  /* The C prettyprinter is not based on code_declarations or
207  statement_declarations but on declaration statements, which
208  happen to be continue statement for the time being. */
209  if(!declaration_statement_p(s) && add_declaration_statement_p) {
210  /* To preserve the source layout, declarations are
211  statements */
213  }
214  }
215  }
216 }
ram make_ram(entity a1, entity a2, intptr_t a3, list a4)
Definition: ri.c:1999
storage make_storage_ram(ram _field_)
Definition: ri.c:2279
void insert_statement(statement, statement, bool)
This is the normal entry point.
Definition: statement.c:2570
statement make_continue_statement(entity)
Definition: statement.c:953
statement add_declaration_statement(statement, entity)
Definition: statement.c:2790
bool declaration_statement_p(statement)
Had to be optimized according to Beatrice Creusillet.
Definition: statement.c:224
#define pips_user_warning
Definition: misc-local.h:146
#define DYNAMIC_AREA_LOCAL_NAME
Definition: naming-local.h:69
static entity dynamic_area
void AddEntityToDeclarations(entity e, entity module)
END_EOLE.
Definition: variable.c:108
#define statement_block_p(stat)
#define entity_variable_p(e)
An entity_variable_p(e) may hide a typedef and hence a functional type.
int current_offset_of_area(entity a, entity v)
Definition: area.c:174
entity FindEntity(const char *package, const char *name)
Retrieve an entity from its package/module name and its local name.
Definition: entity.c:1503
entity entity_empty_label(void)
Definition: entity.c:1105
#define statement_declarations(x)
Definition: ri.h:2460
#define statement_undefined_p(x)
Definition: ri.h:2420
#define storage_undefined_p(x)
Definition: ri.h:2477

References add_declaration_statement(), AddEntityToDeclarations(), c_module_p(), CONS, current_offset_of_area(), declaration_statement_p(), dynamic_area, DYNAMIC_AREA_LOCAL_NAME, ENTITY, entity_empty_label(), entity_name, entity_storage, entity_variable_p, FindEntity(), gen_chunk_undefined_p, gen_find_eq(), gen_nconc(), insert_statement(), make_continue_statement(), make_ram(), make_storage_ram(), module, module_local_name(), NIL, pips_assert, pips_user_warning, SizeOfArray(), statement_block_p, statement_declarations, statement_undefined_p, and storage_undefined_p.

Referenced by AddLocalEntityToDeclarations(), and AddLocalEntityToDeclarationsOnly().

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

◆ get_ith_dummy()

entity get_ith_dummy ( string  prefix,
string  suffix,
int  i 
)

Returns a numbered entity the name of which is suffix + number, the module of which is prefix.

Used by some macros to return dummy and primed variables for system of constraints.

moved to ri-util from hpfc on BC's request. FC 08/09/95

Parameters
prefixrefix
suffixuffix

Definition at line 1711 of file variable.c.

1712 {
1713  char buffer[100];
1714  assert(i>=1 && i<=7);
1715  (void) sprintf(buffer, "%s%d", suffix, i);
1716 
1718 }
#define assert(ex)
Definition: newgen_assert.h:41
entity find_or_create_scalar_entity(const char *name, const char *module_name, tag base)
Looks for an entity which should be a scalar of the specified basic.
Definition: variable.c:1025
@ is_basic_int
Definition: ri.h:571

References assert, buffer, find_or_create_scalar_entity(), is_basic_int, and prefix.

Referenced by compute_entity_to_declaration_constraints().

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

◆ global_variable_p()

bool global_variable_p ( entity  v)

Is v a global variable such as "int i;".

This is OK for C, but Fortran deals with commons.

Definition at line 1510 of file variable.c.

1511 {
1512  // static global variables are decared in a compilation unit
1513  bool global_variable_p =
1514  (strcmp(entity_module_name(v), TOP_LEVEL_MODULE_NAME)==0);
1515 
1516  return global_variable_p;
1517 }
#define TOP_LEVEL_MODULE_NAME
Module containing the global variables in Fortran and C.
Definition: naming-local.h:101
bool global_variable_p(entity v)
Is v a global variable such as "int i;".
Definition: variable.c:1510
const char * entity_module_name(entity e)
See comments about module_name().
Definition: entity.c:1092

References entity_module_name(), global_variable_p(), and TOP_LEVEL_MODULE_NAME.

Referenced by create_values_for_simple_effect(), filter_formal_context_according_to_actual_context(), generic_transformer_intra_to_inter(), global_variable_p(), and new_filter_formal_context_according_to_actual_context().

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

◆ implicit_c_variable_p()

bool implicit_c_variable_p ( entity  v)

Definition at line 1877 of file variable.c.

1878 {
1879  const char * vn = entity_user_name(v);
1880 
1881 
1882  // return string_equal_p(vn, IMPLICIT_VARIABLE_NAME_1)
1883  //|| string_equal_p(vn, IMPLICIT_VARIABLE_NAME_2);
1884 
1885  return strcmp(vn, IMPLICIT_VARIABLE_NAME_1) == 0
1886  || strcmp(vn, IMPLICIT_VARIABLE_NAME_2) == 0;
1887 
1888 }
#define IMPLICIT_VARIABLE_NAME_1
Implicit variable names for C.
#define IMPLICIT_VARIABLE_NAME_2

References entity_user_name(), IMPLICIT_VARIABLE_NAME_1, and IMPLICIT_VARIABLE_NAME_2.

Referenced by c_text_entities(), inline_expression_call(), and solve_name_clashes().

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

◆ integer_scalar_entity_p()

bool integer_scalar_entity_p ( entity  e)

integer_scalar_entity_p() is obsolete; use entity_integer_scalar_p()

Definition at line 1137 of file variable.c.

1138 {
1139  type ct = ultimate_type(entity_type(e));
1140  return type_variable_p(entity_type(e)) &&
1143 }

References basic_int_p, entity_type, NIL, type_variable, type_variable_p, ultimate_type(), variable_basic, and variable_dimensions.

Referenced by allocate_module_value_mappings().

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

◆ make_array_entity()

static entity make_array_entity ( const char *  name,
const char *  module_name,
basic  base,
list  dimensions 
)
static

Create an array entity.

Parameters
module_nameis the name of the module part of the entity name
nameis the user name of the entity
baseis the basic type for the array
dimensionsis the list of dimensions for the array

Definition at line 752 of file variable.c.

755  {
756  string full_name;
757  entity e, f, a;
758  basic b = base;
760  pips_debug(8, "name %s\n", full_name);
761  int n =0;
763  free(full_name);
764  asprintf(&full_name,"%s"MODULE_SEP_STRING"%s%d",module_name,name,n++);
765  }
767 
768  entity_type(e) = (type) MakeTypeVariable(b, dimensions);
771  entity_storage(e) =
773  make_ram(f, a,
775  (add_variable_to_area(a, e)):(0),
776  NIL));
778  return(e);
779 }
value make_value_unknown(void)
Definition: ri.c:2847
storage make_storage(enum storage_utype tag, void *val)
Definition: ri.c:2273
struct _newgen_struct_type_ * type
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
int add_variable_to_area(entity a, entity v)
Definition: variable.c:1376
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
type MakeTypeVariable(basic, cons *)
BEGIN_EOLE.
Definition: type.c:116
@ is_basic_overloaded
Definition: ri.h:574
#define basic_tag(x)
Definition: ri.h:613
@ is_storage_ram
Definition: ri.h:2492
#define entity_undefined_p(x)
Definition: ri.h:2762

References add_variable_to_area(), asprintf, base, basic_tag, DYNAMIC_AREA_LOCAL_NAME, entity_domain, entity_initial, entity_storage, entity_type, entity_undefined_p, f(), FindEntity(), free(), full_name, gen_find_tabulated(), is_basic_overloaded, is_storage_ram, local_name_to_top_level_entity(), make_entity, make_ram(), make_storage(), make_value_unknown(), MakeTypeVariable(), module_name(), MODULE_SEP_STRING, NIL, pips_debug, storage_undefined, type_undefined, and value_undefined.

Referenced by make_new_array_variable_with_prefix().

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

◆ make_derived_entity()

entity make_derived_entity ( const char *  name,
const char *  module_name,
type  t 
)
Parameters
nameame
module_nameodule_name

Definition at line 378 of file variable.c.

381 {
382  string full_name;
383  entity e;
384 
385  full_name =
387 
388  pips_debug(8, "name %s\n", full_name);
389 
390  message_assert("not already defined",
392 
395 
396  entity_type(e) = copy_type(t);
397 
399 
401 
402  return(e);
403 }
storage make_storage_rom(void)
Definition: ri.c:2285
#define message_assert(msg, ex)
Definition: newgen_assert.h:47

References concatenate(), copy_type(), entity_domain, entity_initial, entity_storage, entity_type, entity_undefined, full_name, gen_find_tabulated(), make_entity, make_storage_rom(), make_value_unknown(), message_assert, module_name(), MODULE_SEP_STRING, pips_debug, storage_undefined, strdup(), type_undefined, and value_undefined.

Referenced by make_new_derived_entity_with_prefix().

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

◆ make_global_entity_from_local()

entity make_global_entity_from_local ( entity  local)
Parameters
localocal

Definition at line 281 of file variable.c.

281  {
282  const char* seed = entity_local_name(local);
283  int counter=0;
284  entity new = entity_undefined;
285  string eln= strdup(seed);
287  asprintf(&eln,"%s%d",seed,counter++);
288  }
290  free(eln);
291  entity_type(new)=copy_type(entity_type(local));
296  return new;
297 }
entity FindOrCreateEntity(const char *package, const char *local_name)
Problem: A functional global entity may be referenced without parenthesis or CALL keyword in a functi...
Definition: entity.c:1586
entity entity_to_module_entity(entity e)
Find the enclosing module of an entity.
Definition: entity.c:2053

References add_any_variable_to_area(), asprintf, copy_type(), copy_value(), DYNAMIC_AREA_LOCAL_NAME, entity_initial, entity_local_name(), entity_storage, entity_to_module_entity(), entity_type, entity_undefined, entity_undefined_p, f(), FindEntity(), FindOrCreateEntity(), fortran_module_p(), free(), local_name_to_top_level_entity(), make_ram(), make_storage_ram(), NIL, strdup(), and TOP_LEVEL_MODULE_NAME.

Referenced by inline_expression_call().

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

◆ make_integer_constant_entity()

entity make_integer_constant_entity ( _int  c)

entity make_integer_constant_entity(int c) make entity for integer constant c

WARNING : the basic integer size is fixed to sizeof(_int)

64 bits numbers are printed in decimal in 20 digits, so with - and \0 32 is enough.

make entity for the constant c

Definition at line 1345 of file variable.c.

1345  {
1346  entity ce;
1347  /* 64 bits numbers are printed in decimal in 20 digits, so with - and \0
1348  32 is enough. */
1349  char num[32];
1350  string cn;
1351 
1352  sprintf(num, "%td", c);
1355  if (ce==entity_undefined) { /* make entity for the constant c */
1356  functional cf =
1359  make_variable(make_basic(is_basic_int, (void*)sizeof(int)),
1360  NIL,NIL)));
1361  type ct = make_type(is_type_functional, cf);
1362  ce = make_entity(strdup(cn), ct, make_storage_rom(),
1364  make_constant(is_constant_int, (void*)c)));
1365  }
1366  return(ce);
1367 }
functional make_functional(list a1, type a2)
Definition: ri.c:1109
constant make_constant(enum constant_utype tag, void *val)
Definition: ri.c:406
basic make_basic(enum basic_utype tag, void *val)
Definition: ri.c:155
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
static int num
Definition: bourdoncle.c:137
@ is_constant_int
Definition: ri.h:817
@ is_value_constant
Definition: ri.h:3033
@ is_type_functional
Definition: ri.h:2901
@ is_type_variable
Definition: ri.h:2900

References concatenate(), entity_domain, entity_undefined, gen_find_tabulated(), is_basic_int, is_constant_int, is_type_functional, is_type_variable, is_value_constant, make_basic(), make_constant(), make_entity, make_functional(), make_storage_rom(), make_type(), make_value(), make_variable(), MODULE_SEP_STRING, NIL, num, strdup(), and TOP_LEVEL_MODULE_NAME.

Referenced by add_pragma_to_sequence(), operator_neutral_element(), regions_to_loops(), remove_simple_scalar_pointers(), scalar_to_array(), and verify_used_before_set_call().

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

◆ make_new_array_variable()

entity make_new_array_variable ( entity  module,
basic  b,
list  dimensions 
)
Parameters
moduleodule
dimensionsimensions

Definition at line 793 of file variable.c.

793  {
794  return make_new_array_variable_with_prefix("", module,b,dimensions);
795 }
entity make_new_array_variable_with_prefix(const char *prefix, entity module, basic b, list dimensions)
J'ai ameliore la fonction make_new_scalar_variable_with_prefix
Definition: variable.c:785

References make_new_array_variable_with_prefix(), and module.

Referenced by effects_to_dma().

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

◆ make_new_array_variable_with_prefix()

entity make_new_array_variable_with_prefix ( const char *  prefix,
entity  module,
basic  b,
list  dimensions 
)

J'ai ameliore la fonction make_new_scalar_variable_with_prefix

afin de l'etendre a des tableau

Parameters
prefixrefix
moduleodule
dimensionsimensions

Definition at line 785 of file variable.c.

786 {
787  const char* module_name = module_local_name(module);
788  entity e;
789  e = make_array_entity(prefix, module_name, b, dimensions);
790  return e;
791 }
static entity make_array_entity(const char *name, const char *module_name, basic base, list dimensions)
Create an array entity.
Definition: variable.c:752

References make_array_entity(), module, module_local_name(), module_name(), and prefix.

Referenced by do_clone_entity(), do_group_constants_terapix(), inline_expression_call(), internal_make_new_array_variable(), make_new_array_variable(), make_reduction_vector_entity(), outliner_smart_references_computation(), and promote_local_entities().

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

◆ make_new_derived_entity_with_prefix()

entity make_new_derived_entity_with_prefix ( const char *  prefix,
entity  module,
type  t 
)

derived from make_new_scalar_variable_with_prefix

declare the entity at the highest scope

Find the first matching non-already existent variable name:

Free the already allocated name in the previous iteration that was conflicting:

Use a default type-dependent variable name since the programmer gave none:

Parameters
prefixrefix
moduleodule

Definition at line 685 of file variable.c.

688 {
689  const char* module_name = module_local_name(module);
690  string ep = strdup(prefix);
691  entity e;
692  char * variable_name = NULL;
693  int number = 0;
694  bool empty_prefix = (strlen(prefix) == 0);
695  /* declare the entity at the highest scope */
696  const string format = "0" BLOCK_SEP_STRING "%s%d";
697 
698  /* Find the first matching non-already existent variable name: */
699  do {
700  if (variable_name != NULL)
701  /* Free the already allocated name in the previous iteration that
702  was conflicting: */
704 
705  if (empty_prefix) {
706  /* Use a default type-dependent variable name since the programmer
707  gave none: */
708  switch(type_tag(t)) {
709  case is_type_struct:
712  break;
713  case is_type_union:
716  break;
717  case is_type_enum:
720  break;
721  default:
722  pips_internal_error("unexpected type kind: %d",
723  type_tag(t));
724  break;
725  }
726  }
727  else
728  asprintf(&variable_name, format, ep, number++);
729  }
731 
732  pips_debug(9, "var %s, tag %d\n", variable_name, type_tag(t));
733 
736  free(ep);
737 
738  return e;
739 }
#define DEFAULT_DERIVED_ENUM_PREFIX
Definition: variable.c:441
static int unique_float_number
Definition: variable.c:415
static int unique_integer_number
Definition: variable.c:414
entity make_derived_entity(const char *name, const char *module_name, type t)
Definition: variable.c:378
static int unique_logical_number
Definition: variable.c:416
#define DEFAULT_DERIVED_UNION_PREFIX
Definition: variable.c:440
#define DEFAULT_DERIVED_STRUCT_PREFIX
Definition: variable.c:439
#define type_tag(x)
Definition: ri.h:2940
@ is_type_enum
Definition: ri.h:2907
@ is_type_union
Definition: ri.h:2906
@ is_type_struct
Definition: ri.h:2905

References asprintf, BLOCK_SEP_STRING, DEFAULT_DERIVED_ENUM_PREFIX, DEFAULT_DERIVED_STRUCT_PREFIX, DEFAULT_DERIVED_UNION_PREFIX, free(), is_type_enum, is_type_struct, is_type_union, make_derived_entity(), module, module_local_name(), module_name(), pips_debug, pips_internal_error, prefix, strdup(), type_tag, unique_entity_name_p(), unique_float_number, unique_integer_number, unique_logical_number, and variable_name().

Referenced by do_clone_entity().

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

◆ make_new_entity()

entity make_new_entity ( basic  ba,
int  kind 
)

The first letter of the local name depends on the basic: int --> I real --> F (float single precision) others --> O

The three following letters are whether "TMP", for temporaries or "AUX" for auxiliary variables.

The first part of the full name is the concatenation of the define constant ATOMIZER_MODULE_NAME and the local name of the module entity.

ATOMIZER_MODULE_NAME discarded : it is a bug ! RK, 31/05/1994. name = strdup(concatenate(ATOMIZER_MODULE_NAME, entity_local_name(mod_ent), MODULE_SEP_STRING, prefix, num, (char *) NULL));

Create a true dynamic variable. RK, 31/05/1994 :

Is the following useless :

The new entity is stored in the list of entities of the same type.

Parameters
baa
kindind

Definition at line 898 of file variable.c.

899 {
900  entity new_ent, mod_ent;
901  // prefix+1 (line#820) must hold 3 characters
902  char prefix[5], *name;
903  int number = 0;
905 
906  /* The first letter of the local name depends on the basic:
907  * int --> I
908  * real --> F (float single precision)
909  * others --> O
910  */
911  switch(basic_tag(ba))
912  {
913  case is_basic_int: { (void) sprintf(prefix, "I"); break;}
914  case is_basic_float:
915  {
917  (void) sprintf(prefix, "O");
918  else
919  (void) sprintf(prefix, "F");
920  break;
921  }
922  default: (void) sprintf(prefix, "O");
923  }
924 
925  /* The three following letters are whether "TMP", for temporaries
926  * or "AUX" for auxiliary variables.
927  */
928  switch(kind)
929  {
930  case TMP_ENT:
931  {
932  number = (++count_tmp);
933  (void) sprintf(prefix+1, "TMP");
934  break;
935  }
936  case AUX_ENT:
937  {
938  number = (++count_aux);
939  (void) sprintf(prefix+1, "AUX");
940  break;
941  }
942  default: user_error("make_new_entity", "Bad kind of entity: %d", kind);
943  }
944 
946 
947  /* The first part of the full name is the concatenation of the define
948  * constant ATOMIZER_MODULE_NAME and the local name of the module
949  * entity.
950  */
951  /* ATOMIZER_MODULE_NAME discarded : it is a bug ! RK, 31/05/1994.
952  name = strdup(concatenate(ATOMIZER_MODULE_NAME, entity_local_name(mod_ent),
953  MODULE_SEP_STRING, prefix, num, (char *) NULL));
954  */
955  asprintf(&name,"%s" MODULE_SEP_STRING "%s%d",entity_local_name(mod_ent),prefix,number);
956  /*
957  new_ent = make_entity(name,
958  make_type(is_type_variable,
959  make_variable(ba,
960  NIL,NIL)),
961  make_storage(is_storage_rom, UU),
962  make_value(is_value_unknown, UU));
963  */
964  /* Create a true dynamic variable. RK, 31/05/1994 : */
965  new_ent = make_entity(name,
967  make_variable(ba,
968  NIL,NIL)),
975  dynamic_area,
977  NIL));
978  AddEntityToCurrentModule(new_ent);
979 
980  /* Is the following useless : */
981 
982  /* The new entity is stored in the list of entities of the same type. */
983  switch(basic_tag(ba))
984  {
985  case is_basic_int:
986  {
988  break;
989  }
990  case is_basic_float:
991  {
994  else
995  real_entities = CONS(ENTITY, new_ent, real_entities);
996  break;
997  }
998  case is_basic_logical:
999  {
1001  break;
1002  }
1003  case is_basic_complex:
1004  {
1006  break;
1007  }
1008  case is_basic_string:
1009  {
1010  char_entities = CONS(ENTITY, new_ent, char_entities);
1011  break;
1012  }
1013  default:break;
1014  }
1015 
1016  return new_ent;
1017 }
static entity mod_ent
#define DOUBLE_PRECISION_SIZE
#define AUX_ENT
#define TMP_ENT
#define user_error(fn,...)
Definition: misc-local.h:265
#define UU
Definition: newgen_types.h:98
list double_entities
Definition: variable.c:895
list real_entities
Definition: variable.c:892
static int count_tmp
These globals variables count the number of temporary and auxiliary entities.
Definition: variable.c:864
list complex_entities
Definition: variable.c:894
static int count_aux
Definition: variable.c:865
list logical_entities
Definition: variable.c:893
list char_entities
Definition: variable.c:896
void AddEntityToCurrentModule(entity e)
Add a variable entity to the current module declarations.
Definition: variable.c:260
list integer_entities
Make a new variable entity which name is one letter prefix + one incrementing number.
Definition: variable.c:891
@ is_basic_string
Definition: ri.h:576
@ is_basic_float
Definition: ri.h:572
@ is_basic_logical
Definition: ri.h:573
@ is_basic_complex
Definition: ri.h:575
@ is_value_unknown
Definition: ri.h:3035
#define basic_float(x)
Definition: ri.h:619

References add_variable_to_area(), AddEntityToCurrentModule(), asprintf, AUX_ENT, basic_float, basic_tag, char_entities, complex_entities, CONS, count_aux, count_tmp, double_entities, DOUBLE_PRECISION_SIZE, dynamic_area, DYNAMIC_AREA_LOCAL_NAME, ENTITY, entity_local_name(), entity_storage, FindEntity(), get_current_module_entity(), integer_entities, is_basic_complex, is_basic_float, is_basic_int, is_basic_logical, is_basic_string, is_storage_ram, is_type_variable, is_value_unknown, logical_entities, make_entity, make_ram(), make_storage(), make_type(), make_value(), make_variable(), mod_ent, module_local_name(), MODULE_SEP_STRING, NIL, prefix, real_entities, storage_undefined, TMP_ENT, user_error, and UU.

Referenced by assign_tmp_to_exp(), and atomizer_of_external().

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

◆ make_new_index_entity()

entity make_new_index_entity ( entity  old_index,
string  suffix 
)

add a terminal suffix till a new name is found.

Parameters
old_indexld_index
suffixuffix

Definition at line 1851 of file variable.c.

1852 {
1853  entity new_index;
1854  string old_name;
1855  char *new_name=NULL;
1857 
1858  old_name = entity_name(old_index);
1859 
1860  /* add a terminal suffix till a new name is found. */
1861  for (asprintf(&new_name, "%s%s", old_name, suffix); !unique_entity_name_p(global_name_to_user_name(new_name),module); old_name = new_name) {
1862  char *tmp = new_name;
1863  asprintf(&new_name, "%s%s", old_name, suffix);
1864  free(tmp);
1865  }
1866 
1867  // FI: copy_storage() cree de l'aliasing entre new_index et old_index
1868  // Is this the right place to fix the problem?
1869  new_index = make_entity(new_name,
1870  copy_type(entity_type(old_index)),
1872  copy_value(entity_initial(old_index)));
1873  AddEntityToCurrentModule(new_index);
1874  return(new_index);
1875 }
const char * global_name_to_user_name(const char *global_name)
functions on strings for entity names
Definition: entity_names.c:136
static const char * old_name(entity module, entity obj)
old name of obj while in module now.
Definition: compile.c:354
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
Definition: entity.c:1479

References AddEntityToCurrentModule(), asprintf, copy_type(), copy_value(), entity_initial, entity_module_name(), entity_name, entity_type, free(), global_name_to_user_name(), make_entity, module, module_name_to_entity(), old_name(), storage_undefined, and unique_entity_name_p().

Referenced by loop_strip_mine(), make_index_prime_entity(), make_local_tile_index_entity(), make_tile_index_entity(), and simd_loop_unroll().

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

◆ make_new_module_variable()

entity make_new_module_variable ( entity  module,
int  d 
)

Make a new module integer variable of name X<d>.

Parameters
moduleodule

Definition at line 830 of file variable.c.

831 {
832 
833  string name;
835  static int num = 1;
836  if (d != 0) {
837  (void)asprintf(&name,"X%d",d);
838  num = d;
839  }
840  else { (void) asprintf(&name,"X%d",num);
841  num++;}
842 
843  while(!unique_entity_name_p(name,module))
844  {
845  string tmp = name;
846  (void)asprintf(&name,"X%d",num);
847  num++;
848  free(tmp);
849  }
850  ent1 = make_scalar_integer_entity(name,
852  return ent1;
853 }
entity make_scalar_integer_entity(const char *name, const char *module_name)
Create an integer variable of name "name" in module of name "module_name".
Definition: variable.c:1068

References asprintf, entity_undefined, free(), make_scalar_integer_entity(), module, module_local_name(), num, and unique_entity_name_p().

Referenced by array_scalar_access_to_bank_communication(), array_scalar_access_to_compute_communication(), build_new_variable(), insert_run_time_communications(), reference_conversion_computation(), and regions_to_loops().

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

◆ make_new_scalar_variable()

◆ make_new_scalar_variable_with_prefix()

entity make_new_scalar_variable_with_prefix ( const char *  prefix,
entity  module,
basic  b 
)

Create a new scalar variable of type b in the given module.

The variable name is constructed with "<prefix><number>" If the given prefix is the empty string, some standard prefixes are used, based on the type.

In Fortran, the prefix is forced to upper case to be consistent with PIPS Fortran internal representation. All the default prefixes are assumed to be uppercase strings.

In C this function is added to current module only.

Returns
the variable entity.

It is not clear why the default prefix is (re)computed in the repeat until loop rather than before entering it.

Find the first matching non-already existent variable name:

Free the already allocated name in the previous iteration that was conflicting:

Use a default type-dependent variable name since the programmer gave none:

Parameters
prefixrefix
moduleodule

Definition at line 592 of file variable.c.

595 {
596  const char* module_name = module_local_name(module);
597  string ep = strdup(prefix);
598  entity e;
599  char * variable_name = NULL;
600  int number = 0;
601  bool empty_prefix = (strlen(prefix) == 0);
602  const string format = fortran_module_p(module)?"%s%d":"0" BLOCK_SEP_STRING "%s%d";
603  ep = fortran_module_p(module)? strupper(ep,ep) : ep;
604 
605  /* Find the first matching non-already existent variable name: */
606  do {
607  if (variable_name != NULL)
608  /* Free the already allocated name in the previous iteration that
609  was conflicting: */
611 
612  if (empty_prefix) {
613  /* Use a default type-dependent variable name since the programmer
614  gave none: */
615  basic ub = basic_ultimate(b);
616  switch(basic_tag(ub)) {
617  case is_basic_int:
620  break;
621  case is_basic_float:
624  break;
625  case is_basic_logical:
628  break;
629  case is_basic_complex:
632  break;
633  case is_basic_string:
636  break;
637  case is_basic_pointer:
640  break;
641  case is_basic_derived: {
642  entity de = basic_derived(ub);
643  type dt = ultimate_type(entity_type(de));
644 
645  if(type_struct_p(dt)) {
648  }
649  else if(type_union_p(dt)) {
652  }
653  else if(type_enum_p(dt)) {
656  }
657  else {
658  pips_internal_error("Not implemented for type tag: %d",
659  type_tag(dt));
660  }
661  break;
662  }
663  default:
664  pips_internal_error("unknown basic tag: %d",
665  basic_tag(ub));
666  break;
667  }
668  }
669  else
670  asprintf(&variable_name, format, ep, number++);
671  }
673 
674  pips_debug(9, "var %s, tag %d\n", variable_name, basic_tag(b));
675 
678  free(ep);
679 
680  return e;
681 }
string strupper(string, const char *)
Definition: string.c:213
static int unique_string_number
Definition: variable.c:418
#define DEFAULT_POINTER_PREFIX
Definition: variable.c:435
#define DEFAULT_COMPLEX_PREFIX
Definition: variable.c:433
#define DEFAULT_FLOAT_PREFIX
Definition: variable.c:431
#define DEFAULT_STRUCT_PREFIX
Definition: variable.c:436
#define DEFAULT_LOGICAL_PREFIX
Definition: variable.c:432
#define DEFAULT_STRING_PREFIX
Definition: variable.c:434
#define DEFAULT_INT_PREFIX
Default prefixes.
Definition: variable.c:430
static int unique_complex_number
Definition: variable.c:417
#define DEFAULT_ENUM_PREFIX
Definition: variable.c:438
#define DEFAULT_UNION_PREFIX
Definition: variable.c:437
basic basic_ultimate(basic)
get the ultimate basic from a basic typedef
Definition: type.c:1806
#define type_enum_p(x)
Definition: ri.h:2968
@ is_basic_derived
Definition: ri.h:579
@ is_basic_pointer
Definition: ri.h:578
#define type_struct_p(x)
Definition: ri.h:2962
#define basic_derived(x)
Definition: ri.h:640
#define type_union_p(x)
Definition: ri.h:2965

References asprintf, basic_derived, basic_tag, basic_ultimate(), BLOCK_SEP_STRING, DEFAULT_COMPLEX_PREFIX, DEFAULT_ENUM_PREFIX, DEFAULT_FLOAT_PREFIX, DEFAULT_INT_PREFIX, DEFAULT_LOGICAL_PREFIX, DEFAULT_POINTER_PREFIX, DEFAULT_STRING_PREFIX, DEFAULT_STRUCT_PREFIX, DEFAULT_UNION_PREFIX, entity_type, fortran_module_p(), free(), is_basic_complex, is_basic_derived, is_basic_float, is_basic_int, is_basic_logical, is_basic_pointer, is_basic_string, make_scalar_entity(), module, module_local_name(), module_name(), pips_debug, pips_internal_error, prefix, strdup(), strupper(), type_enum_p, type_struct_p, type_tag, type_union_p, ultimate_type(), unique_complex_number, unique_entity_name_p(), unique_float_number, unique_integer_number, unique_logical_number, unique_string_number, and variable_name().

Referenced by comEngine_make_new_scalar_variable(), complexity_sigma(), create_counter(), create_new_ent_list(), do_clone_entity(), do_group_constants_terapix(), do_loop_unroll_with_prologue(), do_scalar_renaming_in_vertex(), find_or_create_newInd(), fix_loop_index_sign(), generate_scalar_variables(), generate_scalar_variables_from_list(), inline_expression_call(), loop_to_complexity(), make_complexity_unknown(), make_loadsave_statement(), make_new_scalar_variable(), make_new_simd_vector_with_prefix(), make_place_holder_variable(), make_temporary_pointer_to_array_entity_with_prefix(), MakeAssignedOrComputedGotoInst(), MakeDoInst(), mpi_initialize(), mpi_make_ctx(), outliner_smart_references_computation(), process_true_call_stat(), promote_local_entities(), set_the_i(), and statements_localize_declarations().

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

◆ make_place_holder_variable()

entity make_place_holder_variable ( entity  de)
Parameters
dee

Definition at line 2059 of file variable.c.

2060 {
2062  basic b = make_basic_derived(de);
2063  entity ph = entity_undefined;
2064  if(!entity_undefined_p(m))
2066  return ph;
2067 }
basic make_basic_derived(entity _field_)
Definition: ri.c:182
#define PLACE_HOLDER_PREFIX_STRING
Generate special variables to represent declarations such as "struct s;".
Definition: variable.c:2057

References entity_undefined, entity_undefined_p, get_current_module_entity(), make_basic_derived(), make_new_scalar_variable_with_prefix(), and PLACE_HOLDER_PREFIX_STRING.

+ Here is the call graph for this function:

◆ make_scalar_entity()

entity make_scalar_entity ( const char *  name,
const char *  module_name,
basic  base 
)

entity make_scalar_entity(name, module_name, base)

FI: this creates an inconsistency between the module declarations and the content of the DYNAMIC area.

FI: I would have expected is_value_unknown, especially with a RAM storage!

Parameters
nameame
module_nameodule_name
basease

Definition at line 331 of file variable.c.

334 {
335  string full_name;
336  entity e, f, a;
337  basic b = base;
338 
339  full_name =
341 
342  pips_debug(8, "name %s\n", full_name);
343 
344  message_assert("not already defined",
346 
349 
353 
354  int offset = 0;
355  /* FI: this creates an inconsistency between the module declarations
356  * and the content of the *DYNAMIC* area.
357  */
358  if(!place_holder_variable_p(e)) {
361  (add_C_variable_to_area(a, e)):(0);
362  else
364  (add_variable_to_area(a, e)):(0);
365  }
366 
367  entity_storage(e) =
369  make_ram(f, a,
370  offset,
371  NIL));
372 
373  /* FI: I would have expected is_value_unknown, especially with a RAM storage! */
375 
376  return(e);
377 }
static Value offset
Definition: translation.c:283
bool place_holder_variable_p(entity ph)
Definition: variable.c:2069
int add_C_variable_to_area(entity a, entity v)
Definition: variable.c:1381

References add_C_variable_to_area(), add_variable_to_area(), base, basic_tag, c_module_p(), concatenate(), DYNAMIC_AREA_LOCAL_NAME, entity_domain, entity_initial, entity_storage, entity_type, entity_undefined, f(), FindEntity(), full_name, gen_find_tabulated(), is_basic_overloaded, is_storage_ram, local_name_to_top_level_entity(), make_entity, make_ram(), make_storage(), make_value_unknown(), MakeTypeVariable(), message_assert, module_name(), module_name_to_entity(), MODULE_SEP_STRING, NIL, offset, pips_debug, place_holder_variable_p(), storage_undefined, strdup(), type_undefined, and value_undefined.

Referenced by alloc_instrumentation(), find_or_create_scalar_entity(), find_or_create_typed_entity(), make_new_scalar_variable_with_prefix(), old_array_bound_check_instrumentation(), sprintf_check_expression(), terapix_optimize_accumulator(), and Tiling_buffer_allocation().

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

◆ make_scalar_integer_entity()

entity make_scalar_integer_entity ( const char *  name,
const char *  module_name 
)

Create an integer variable of name "name" in module of name "module_name".

Parameters
nameame
module_nameodule_name

Definition at line 1068 of file variable.c.

1069 {
1070  string full_name;
1071  entity e, f, a ;
1072  basic b ;
1073 
1074  pips_debug(8, "begin name=%s, module_name=%s\n", name, module_name);
1075 
1081  value_undefined);
1082 
1083  b = make_basic(is_basic_int, (void*) 4);
1084 
1085  entity_type(e) = (type) MakeTypeVariable(b, NIL);
1086 
1089  pips_assert("make_scalar_integer_entity",
1091 
1092  entity_storage(e)
1094  (make_ram(f, a,
1096  NIL)));
1097 
1100 
1101  pips_debug(8, "end\n");
1102 
1103  return(e);
1104 }
constant make_constant_litteral(void)
Definition: ri.c:418
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

References add_any_variable_to_area(), concatenate(), DYNAMIC_AREA_LOCAL_NAME, entity_initial, entity_storage, entity_type, entity_undefined_p, f(), FindEntity(), fortran_module_p(), full_name, hash_warn_on_redefinition(), is_basic_int, is_storage_ram, is_value_constant, local_name_to_top_level_entity(), make_basic(), make_constant_litteral(), make_entity, make_ram(), make_storage(), make_value(), MakeTypeVariable(), module_name(), MODULE_SEP_STRING, NIL, pips_assert, pips_debug, storage_undefined, strdup(), type_undefined, and value_undefined.

Referenced by create_local_index(), create_local_index2(), create_tile_basis(), find_entity(), make_new_module_variable(), module_to_wp65_modules(), sc_add_new_variable_name(), and terapix_loop_handler().

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

◆ make_stderr_variable()

entity make_stderr_variable ( void  )

If the parser has not (yet) encountered "stderr", a PIPS transformation or instrumentation phase may need "stderr" to generate AST code.

This happens with array_bound_check at least.

It's a global variable

Unfortunately, I do not have an unknown basic to use... It should be a FILE * pointer...

Its type is variable, scalar,

its storage must be the static area of top-level

Its initial value is unknown

Definition at line 302 of file variable.c.

303 {
304  /* It's a global variable */
306  STDERR_NAME);
307  /* Unfortunately, I do not have an unknown basic to use... It
308  should be a FILE * pointer... */
314 
315  pips_assert("f & a are defined", !entity_undefined_p(f)
316  && !entity_undefined_p(a));
317 
318  /* Its type is variable, scalar, */
320 
321  /* its storage must be the static area of top-level */
323 
324  /* Its initial value is unknown */
326  return v;
327 }
basic make_basic_int(intptr_t _field_)
Definition: ri.c:158
#define STATIC_AREA_LOCAL_NAME
Definition: naming-local.h:70
#define STDERR_NAME
#define DEFAULT_INTEGER_TYPE_SIZE
#define UNKNOWN_RAM_OFFSET

References DEFAULT_INTEGER_TYPE_SIZE, entity_initial, entity_storage, entity_type, entity_undefined_p, f(), FindEntity(), FindOrCreateEntity(), make_basic_int(), make_ram(), make_storage_ram(), make_value_unknown(), MakeTypeVariable(), NIL, pips_assert, STATIC_AREA_LOCAL_NAME, STDERR_NAME, TOP_LEVEL_MODULE_NAME, and UNKNOWN_RAM_OFFSET.

Referenced by make_C_print_statement().

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

◆ make_temporary_pointer_to_array_entity()

entity make_temporary_pointer_to_array_entity ( entity  efrom,
expression  from,
entity  module 
)
Parameters
efromfrom
fromrom
moduleodule

Definition at line 819 of file variable.c.

819  {
821 }
entity make_temporary_pointer_to_array_entity_with_prefix(char *prefix, entity efrom, entity module, expression from)
Definition: variable.c:801

References make_temporary_pointer_to_array_entity_with_prefix(), and module.

Referenced by inline_expression_call().

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

◆ make_temporary_pointer_to_array_entity_with_prefix()

entity make_temporary_pointer_to_array_entity_with_prefix ( char *  prefix,
entity  efrom,
entity  module,
expression  from 
)

Make the pointer type

Create the variable as a pointer

Set its initial

Parameters
prefixrefix
efromfrom
moduleodule
fromrom

Definition at line 801 of file variable.c.

802  {
805 
806  /* Make the pointer type */
808  dims,
809  NIL)));
810  /* Create the variable as a pointer */
812  module, pointer);
813  /* Set its initial */
816  return new;
817 }
cast make_cast(type a1, expression a2)
Definition: ri.c:311
value make_value_expression(expression _field_)
Definition: ri.c:2850
expression make_expression(syntax a1, normalized a2)
Definition: ri.c:886
type make_type_variable(variable _field_)
Definition: ri.c:2715
basic copy_basic(basic p)
BASIC.
Definition: ri.c:104
basic make_basic_pointer(type _field_)
Definition: ri.c:179
expression copy_expression(expression p)
EXPRESSION.
Definition: ri.c:850
syntax make_syntax_cast(cast _field_)
Definition: ri.c:2503
list gen_full_copy_list(list l)
Copy a list structure with element copy.
Definition: list.c:535
#define normalized_undefined
Definition: ri.h:1745
#define expression_undefined_p(x)
Definition: ri.h:1224

References copy_basic(), copy_expression(), entity_initial, entity_type, expression_undefined_p, gen_full_copy_list(), make_basic_pointer(), make_cast(), make_expression(), make_new_scalar_variable_with_prefix(), make_syntax_cast(), make_type_variable(), make_value_expression(), make_value_unknown(), make_variable(), module, NIL, normalized_undefined, prefix, type_variable, variable_basic, and variable_dimensions.

Referenced by effects_to_dma(), and make_temporary_pointer_to_array_entity().

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

◆ new_add_any_variable_to_area()

int new_add_any_variable_to_area ( entity  a,
entity  v,
bool  is_fortran_p 
)

COMMONs are supposed to havethe same layout in each routine

the local areas are StaticArea and DynamicArea in fortran

the areas are localStaticArea, localDynamicArea, moduleStaticArea, globalStaticArea in C

FI: should only happens with stack_area_p(a)...

C language

By definition of the stack area, the offset is unknown because the size of the cariables is unknown statically. E.g. dependent types. This may happen in C99 or in Fortran 77 extensions.

FI: the points-to analysis is going to modify the symbol table under some properties... Maybe it would be better not to track buckets and abstract buckets declared in the heap?

Parameters
is_fortran_ps_fortran_p

Definition at line 1436 of file variable.c.

1437 {
1438  int OldOffset=-1;
1439  type ta = entity_type(a);
1440  area aa = type_area(ta);
1441 
1442  if(top_level_entity_p(a) && is_fortran_p ) {
1443  /* COMMONs are supposed to havethe same layout in each routine */
1444  pips_internal_error("COMMONs should not be modified.");
1445  }
1446  else if(static_area_p(a) || dynamic_area_p(a)) {
1447  /* the local areas are StaticArea and DynamicArea in fortran */
1448  /* the areas are localStaticArea, localDynamicArea,
1449  moduleStaticArea, globalStaticArea in C*/
1450  int s = 0;
1451  OldOffset = area_size(aa);
1452  if(!SizeOfArray(v, &s)) {
1453  /* FI: should only happens with stack_area_p(a)... */
1454  return DYNAMIC_RAM_OFFSET;
1455  }
1456 
1457  if(is_fortran_p) {
1458  area_layout(aa) = gen_nconc(area_layout(aa), CONS(ENTITY, v, NIL));
1459  area_size(aa) = OldOffset+s;
1460  }
1461  else { /* C language */
1462  if(!gen_in_list_p(v, area_layout(aa)))
1463  area_layout(aa) = gen_nconc(area_layout(aa), CONS(ENTITY, v, NIL));
1464  area_size(aa) = OldOffset+s;
1465  }
1466  }
1467  else if(stack_area_p(a)) {
1468  /* By definition of the stack area, the offset is unknown because
1469  the size of the cariables is unknown statically. E.g. dependent
1470  types. This may happen in C99 or in Fortran 77 extensions. */
1471  if(!gen_in_list_p(v, area_layout(aa)))
1472  area_layout(aa) = gen_nconc(area_layout(aa), CONS(ENTITY, v, NIL));
1473  }
1474  else if(heap_area_p(a)) {
1475  /* FI: the points-to analysis is going to modify the symbol table
1476  under some properties... Maybe it would be better not to track
1477  buckets and abstract buckets declared in the heap? */
1478  pips_assert("Not possible for Fortran code", !is_fortran_p);
1479  if(!gen_in_list_p(v, area_layout(aa)))
1480  area_layout(aa) = gen_nconc(area_layout(aa), CONS(ENTITY, v, NIL));
1481  }
1482  else {
1483  pips_internal_error("Unexpected area kind: \"%s\".",
1484  entity_name(a));
1485  }
1486  return(OldOffset);
1487 }
bool dynamic_area_p(entity aire)
Definition: area.c:68
bool stack_area_p(entity aire)
Definition: area.c:104
bool heap_area_p(entity aire)
Definition: area.c:86

References area_layout, area_size, CONS, dynamic_area_p(), DYNAMIC_RAM_OFFSET, ENTITY, entity_name, entity_type, gen_in_list_p(), gen_nconc(), heap_area_p(), NIL, pips_assert, pips_internal_error, SizeOfArray(), stack_area_p(), static_area_p(), top_level_entity_p(), and type_area.

+ Here is the call graph for this function:

◆ place_holder_variable_p()

bool place_holder_variable_p ( entity  ph)
Parameters
phh

Definition at line 2069 of file variable.c.

2070 {
2071  const char * n = entity_local_name(ph);
2072  string f = strstr(n, PLACE_HOLDER_PREFIX_STRING);
2073  return f!=NULL;
2074 }

References entity_local_name(), f(), and PLACE_HOLDER_PREFIX_STRING.

Referenced by analyzable_scalar_entity_p(), c_text_related_entities(), CCompilationUnitMemoryAllocations(), CModuleMemoryAllocation(), create_values_for_simple_effect(), dump_common_layout(), make_declarations_statement(), make_scalar_entity(), module_to_value_mappings(), and words_variable_or_function().

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

◆ qualified_variable_p()

bool qualified_variable_p ( entity  v,
unsigned int  is_qualified 
)

The variable may turn out to be a function.

Parameters
is_qualifieds_qualified

Definition at line 1666 of file variable.c.

1667 {
1668  bool qualified_p = false;
1669  type t = entity_type(v);
1670  if(type_variable_p(t)) {
1671  // ifdebug(1) pips_assert("the entity must have type variable",
1672  // type_variable_p(t));
1673  // FI: no idea if volatile can he hidden in a typedef...
1674  variable vt = type_variable(t);
1675  list ql = variable_qualifiers(vt);
1676 
1677  FOREACH(QUALIFIER, q, ql) {
1678  if(qualifier_tag(q)==is_qualified) {
1679  qualified_p = true;
1680  break;
1681  }
1682  }
1683  }
1684  return qualified_p;
1685 }
#define qualifier_tag(x)
Definition: ri.h:2175
#define QUALIFIER(x)
QUALIFIER.
Definition: ri.h:2106
#define variable_qualifiers(x)
Definition: ri.h:3124

References entity_type, FOREACH, QUALIFIER, qualifier_tag, type_variable, type_variable_p, and variable_qualifiers.

Referenced by const_variable_p().

+ Here is the caller graph for this function:

◆ remove_variable_entity()

void remove_variable_entity ( entity  v)

FI: this is pretty dangerous as it may leave tons of dangling pointers; I use it to correct early declarations of types functions as variables; I assume that no pointers to v exist in statements because we are still in the declaration phasis.

Memory leaks: I do not know if NewGen free_entity() is recursive.

Definition at line 1306 of file variable.c.

1307 {
1308  /* FI: this is pretty dangerous as it may leave tons of dangling pointers;
1309  * I use it to correct early declarations of types functions as variables;
1310  * I assume that no pointers to v exist in statements because we are still
1311  * in the declaration phasis.
1312  *
1313  * Memory leaks: I do not know if NewGen free_entity() is recursive.
1314  */
1315  storage s = entity_storage(v);
1317  code c = code_undefined;
1318 
1319  if(storage_undefined_p(s)) {
1320  const char* fn = entity_module_name(v);
1322  }
1323  else if(storage_ram_p(s)) {
1324  f = ram_function(storage_ram(s));
1325  }
1326  else if(storage_rom_p(s)) {
1327  f = entity_undefined;
1328  }
1329  else {
1330  pips_internal_error("unexpected storage %d", storage_tag(s));
1331  }
1332 
1333  if(!entity_undefined_p(f)) {
1334  pips_assert("remove_variable_entity", entity_module_p(f));
1335  c = value_code(entity_initial(f));
1336  gen_remove(&code_declarations(c), v);
1337  }
1338  free_entity(v);
1339 }
void free_entity(entity p)
Definition: ri.c:2524
void gen_remove(list *cpp, const void *o)
remove all occurences of item o from list *cpp, which is thus modified.
Definition: list.c:685
bool entity_module_p(entity e)
Definition: entity.c:683
#define code_undefined
Definition: ri.h:757
#define storage_tag(x)
Definition: ri.h:2515
#define value_code(x)
Definition: ri.h:3067
#define ram_function(x)
Definition: ri.h:2247
#define storage_rom_p(x)
Definition: ri.h:2525

References code_declarations, code_undefined, entity_initial, entity_module_name(), entity_module_p(), entity_storage, entity_undefined, entity_undefined_p, f(), free_entity(), gen_remove(), local_name_to_top_level_entity(), pips_assert, pips_internal_error, ram_function, storage_ram, storage_ram_p, storage_rom_p, storage_tag, storage_undefined_p, and value_code.

Referenced by remove_ghost_variable_entities().

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

◆ RemoveLocalEntityFromDeclarations()

void RemoveLocalEntityFromDeclarations ( entity  e,
entity  module,
statement  s 
)

this take care of removing useless declaration statements

Parameters
moduleodule

Definition at line 120 of file variable.c.

121 {
124  if(!statement_undefined_p(s))
125  {
128  if(statement_block_p(s))
129  {
130  // iterate over a copy because FOREACH does not
131  // support inplace modification
132  list theblock = gen_copy_seq(statement_block(s));
133  FOREACH(STATEMENT,stat,theblock)
134  {
135  bool decl_stat = declaration_statement_p(stat);
137  /* this take care of removing useless declaration statements*/
138  if(ENDP(statement_declarations(stat)) && decl_stat)
139  {
141  free_statement(stat);
142  }
143  }
144  gen_free_list(theblock);
145  }
146  }
147 
148 }
void free_statement(statement p)
Definition: ri.c:2189
void gen_remove_once(list *pl, const void *o)
Remove the first occurence of o in list pl:
Definition: list.c:691
list gen_copy_seq(list l)
Copy a list structure.
Definition: list.c:501
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
list statement_block(statement)
Get the list of block statements of a statement sequence.
Definition: statement.c:1338
void RemoveLocalEntityFromDeclarations(entity e, entity module, statement s)
Definition: variable.c:120
#define entity_declarations(e)
MISC: newgen shorthands.
#define instruction_block(i)
#define statement_instruction(x)
Definition: ri.h:2458
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413

References declaration_statement_p(), ENDP, entity_declarations, FOREACH, free_statement(), gen_copy_seq(), gen_free_list(), gen_remove(), gen_remove_once(), instruction_block, module, RemoveLocalEntityFromDeclarations(), STATEMENT, statement_block(), statement_block_p, statement_declarations, statement_instruction, and statement_undefined_p.

Referenced by do_kernelize(), do_reduction_detection(), promote_local_entities(), RemoveLocalEntityFromDeclarations(), rename_statement_declarations(), and statement_clean_declarations_helper().

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

◆ reset_unique_variable_numbers()

void reset_unique_variable_numbers ( void  )

Definition at line 421 of file variable.c.

422 {
427 }

References unique_complex_number, unique_float_number, unique_integer_number, and unique_logical_number.

Referenced by open_module(), and set_resources_for_module().

+ Here is the caller graph for this function:

◆ same_scalar_location_p()

bool same_scalar_location_p ( entity  e1,
entity  e2 
)

FI: transferred from semantics (should be used for effect translation as well)

e1 or e2 may be a formal parameter as shown by the benchmark m from CEA and the call to SOURCE by the MAIN, parameter NPBF (FI, 13/1/93)

I do not understand why I should return false since they actually have the same location for this call site. However, there is no need for a translate_global_value() since the usual formal/actual binding must be enough.

Parameters
e11
e22

Definition at line 1992 of file variable.c.

1993 {
1994  storage st1 = entity_storage(e1);
1995  storage st2 = entity_storage(e2);
1997  entity s2 = entity_undefined;
1998  ram r1 = ram_undefined;
1999  ram r2 = ram_undefined;
2000  bool same = false;
2001 
2002  /* e1 or e2 may be a formal parameter as shown by the benchmark m from CEA
2003  * and the call to SOURCE by the MAIN, parameter NPBF (FI, 13/1/93)
2004  *
2005  * I do not understand why I should return false since they actually have
2006  * the same location for this call site. However, there is no need for
2007  * a translate_global_value() since the usual formal/actual binding
2008  * must be enough.
2009  */
2010  /*
2011  * pips_assert("same_scalar_location_p", storage_ram_p(st1) && storage_ram_p(st2));
2012  */
2013  if(!(storage_ram_p(st1) && storage_ram_p(st2)))
2014  return false;
2015 
2016  r1 = storage_ram(entity_storage(e1));
2017  s1 = ram_section(r1);
2018  r2 = storage_ram(entity_storage(e2));
2019  s2 = ram_section(r2);
2020 
2021  if(s1 == s2) {
2022  if(ram_offset(r1) == ram_offset(r2))
2023  same = true;
2024  else {
2025  pips_debug(7,
2026  "Different offsets %td for %s in section %s and %td for %s in section %s\n",
2027  ram_offset(r1), entity_name(e1), entity_name(s1),
2028  ram_offset(r2), entity_name(e2), entity_name(s2));
2029  }
2030  }
2031  else {
2032  pips_debug(7,
2033  "Disjoint entitites %s in section %s and %s in section %s\n",
2034  entity_name(e1), entity_name(s1),
2035  entity_name(e2), entity_name(s2));
2036  }
2037 
2038  return same;
2039 }
#define ram_undefined
Definition: ri.h:2221
#define ram_offset(x)
Definition: ri.h:2251
s1
Definition: set.c:247

References entity_name, entity_storage, entity_undefined, pips_debug, ram_offset, ram_section, ram_undefined, s1, storage_ram, and storage_ram_p.

Referenced by expression_equal_in_context_p(), translate_global_value(), and translate_to_module_frame().

+ Here is the caller graph for this function:

◆ self_initialization_p()

bool self_initialization_p ( entity  v)

Check if a variable is initialized by itself as "int a = a;" is legal C code according to gcc.

sd v referenced in e?

Definition at line 1966 of file variable.c.

1967 {
1968  bool self_p = false;
1969 
1971 
1972  if(expression_undefined_p(e))
1973  self_p = false;
1974  else {
1975  /* sd v referenced in e? */
1977 
1978  FOREACH(REFERENCE, r, lr) {
1979  entity rv = reference_variable(r);
1980  if(v==rv) {
1981  self_p = true;
1982  break;
1983  }
1984  }
1985  gen_free_list(lr);
1986  }
1987  return self_p;
1988 }
expression variable_initial_expression(entity v)
Returns a copy of the initial (i.e.
Definition: variable.c:1899
list expression_to_reference_list(expression e, list lr)
conversion of an expression into a list of references; references are appended to list lr as they are...
Definition: expression.c:1263
#define REFERENCE(x)
REFERENCE.
Definition: ri.h:2296
#define reference_variable(x)
Definition: ri.h:2326

References expression_to_reference_list(), expression_undefined_p, FOREACH, gen_free_list(), NIL, REFERENCE, reference_variable, and variable_initial_expression().

+ Here is the call graph for this function:

◆ static_global_variable_p()

bool static_global_variable_p ( entity  v)

Is v a global variable declared local to a C file such "static int i;".

Definition at line 1498 of file variable.c.

1499 {
1500  // static global variables are decared in a compilation unit
1502 
1503  return static_global_variable_p;
1504 }
bool compilation_unit_p(const char *module_name)
The names of PIPS entities carry information about their nature.
Definition: entity_names.c:56
bool static_global_variable_p(entity v)
Is v a global variable declared local to a C file such "static int i;".
Definition: variable.c:1498

References compilation_unit_p(), entity_module_name(), and static_global_variable_p().

Referenced by create_stub_entity(), filter_formal_context_according_to_actual_context(), new_filter_formal_context_according_to_actual_context(), source_to_sinks(), and static_global_variable_p().

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

◆ struct_variable_to_fields()

list struct_variable_to_fields ( entity  v)

Assume that v is declared as a struct.

Return the list of its fields.

Apart from a possible assert, the same function should work for a union.

Definition at line 2045 of file variable.c.

2046 {
2048  list fl = derived_type_to_fields(c_t);
2049  return fl;
2050 }
list derived_type_to_fields(type)
Definition: type.c:5381

References derived_type_to_fields(), and entity_basic_concrete_type().

Referenced by analyzed_struct_p(), and struct_initialization_to_points_to().

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

◆ symbolic_constant_entity_p()

bool symbolic_constant_entity_p ( entity  e)

BEGIN_EOLE.

  • please do not remove this line Lines between BEGIN_EOLE and END_EOLE tags are automatically included in the EOLE project (JZ - 11/98)

Definition at line 83 of file variable.c.

84 {
89 
90  return symbolic_constant;
91 }
#define symbolic_constant(x)
Definition: ri.h:2599
#define value_symbolic_p(x)
Definition: ri.h:3068

References entity_initial, entity_storage, storage_rom_p, storage_undefined, symbolic_constant, value_symbolic_p, and value_undefined.

Referenced by constant_expression_supporting_references(), and generic_constant_expression_supporting_entities().

+ Here is the caller graph for this function:

◆ unique_entity_name_p()

static bool unique_entity_name_p ( const char *  name,
entity  in_module 
)
static

Handling of entity as program variables (see also entity.c for generic entities)

Check that "name" can be used as a new variable name in module "in_module". Should work for C and for Fortran. Apparently, should work whether name is already a global name or not, hence the derivation of user_name

Of course, not really debugged for Fortran:-(.

first recover a user_name from global_name

first check in entity declaration, where all entities are added At least AddEntityToDeclarations keep this information up to date

everything seems ok, do a last check with gen_fin_tabulated

Definition at line 49 of file variable.c.

50 {
51  /* first recover a user_name from global_name */
52  const char *user_name=
53  strchr(name,BLOCK_SEP_CHAR)?global_name_to_user_name(name):name;
54  /* first check in entity declaration, where all entities are added
55  * At least AddEntityToDeclarations keep this information up to date
56  */
57  FOREACH(ENTITY,e,entity_declarations(in_module))
58  {
59  if(same_string_p(entity_user_name(e),user_name))
60  return false;
61  }
62  /* everything seems ok, do a last check with gen_fin_tabulated */
63  if(strstr(name,MODULE_SEP_STRING))
65  else
67 }
#define BLOCK_SEP_CHAR
Definition: naming-local.h:51
#define same_string_p(s1, s2)

References BLOCK_SEP_CHAR, concatenate(), ENTITY, entity_declarations, entity_domain, entity_user_name(), FOREACH, gen_chunk_undefined_p, gen_find_tabulated(), global_name_to_user_name(), module_local_name(), MODULE_SEP_STRING, and same_string_p.

Referenced by generate_variable_with_unique_name_to_module(), make_new_derived_entity_with_prefix(), make_new_index_entity(), make_new_module_variable(), and make_new_scalar_variable_with_prefix().

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

◆ variable_dynamic_p()

bool variable_dynamic_p ( entity  v)

Definition at line 1586 of file variable.c.

1587 {
1588  return(type_variable_p(entity_type(v)) &&
1591 }

References dynamic_area_p(), entity_storage, entity_type, ram_section, storage_ram, storage_ram_p, and type_variable_p.

Referenced by deal_with_similars(), and dynamic_variables_to_values().

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

◆ variable_entity_dimension()

int variable_entity_dimension ( entity  v)

variable_entity_dimension(entity v): returns the dimension of variable v; scalar have dimension 0.

This is not necessarily the dimensions because of typedefs. Another function is able to collect dimensions hidden in typedefs, but also via fields: see type_depth().

Definition at line 1293 of file variable.c.

1294 {
1295  int d = 0;
1296 
1297  pips_assert("variable_entity_dimension", type_variable_p(entity_type(v)));
1298 
1300  d++;
1301 
1302  return d;
1303 }

References DIMENSION, entity_type, FOREACH, pips_assert, type_variable, type_variable_p, and variable_dimensions.

Referenced by deal_with_similars(), declaration_with_overlaps(), generate_remapping_system(), hpfc_unstutter_dummies(), prepare_context(), remapping_variables(), struct_variable_to_pointer_locations(), vertex_partially_invariant_p(), xml_Argument(), xml_AssignArgument(), xml_declarations(), xml_FormalVariables(), xml_GlobalVariables(), xml_LocalVariables(), and xml_ParameterUseToArrayBound().

+ Here is the caller graph for this function:

◆ variable_entity_p()

bool variable_entity_p ( entity  e)

See also macro entity_variable_p()...

variable.c

Definition at line 70 of file variable.c.

71 {
72  bool variable =
75 
76  return variable;
77 }
struct _newgen_struct_variable_ * variable
Definition: ri.h:463

References entity_storage, storage_ram_p, and storage_undefined.

Referenced by entities_maymust_conflict_p(), inline_expression_call(), partial_eval_declarations(), referencenodeclfilter(), retype_formal_parameters(), and value_alias().

+ Here is the caller graph for this function:

◆ variable_heap_p()

bool variable_heap_p ( entity  v)

Definition at line 1600 of file variable.c.

1601 {
1602  return(type_variable_p(entity_type(v)) &&
1605 }

References entity_storage, entity_type, heap_area_p(), ram_section, storage_ram, storage_ram_p, and type_variable_p.

Referenced by xml_Chain_Graph(), xml_Compute_and_Need(), xml_GlobalVariables(), xml_Region_Parameter(), xml_TaskParameters(), and xml_Type_Entity().

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

◆ variable_in_common_p()

◆ variable_in_list_p()

bool variable_in_list_p ( entity  e,
list  l 
)

Definition at line 1623 of file variable.c.

1624 {
1625  // FI: should be a call to gen_in_list_p()
1626  bool is_in_list = false;
1627  for( ; (l != NIL) && (! is_in_list); l = CDR(l))
1628  if(same_entity_p(e, ENTITY(CAR(l))))
1629  is_in_list = true;
1630  return(is_in_list);
1631 }
bool same_entity_p(entity e1, entity e2)
predicates on entities
Definition: entity.c:1321

References CAR, CDR, ENTITY, NIL, and same_entity_p().

Referenced by add_aliases_for_current_call_site(), and text_equivalences().

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

◆ variable_in_module_p()

bool variable_in_module_p ( entity  v,
entity  m 
)

This test can only be applied to variables, not to functions, subroutines or commons visible from a module.

Definition at line 1610 of file variable.c.

1612 {
1613  bool in_module_1 =
1614  strcmp(module_local_name(m), entity_module_name(v)) == 0;
1615  bool in_module_2 =
1617 
1618  pips_assert ("Module declaration consistency", in_module_1==in_module_2);
1619 
1620  return in_module_1;
1621 }
bool entity_is_argument_p(entity e, cons *args)
Definition: arguments.c:150

References code_declarations, entity_initial, entity_is_argument_p(), entity_module_name(), module_local_name(), pips_assert, and value_code.

Referenced by external_value_name(), and update_common_layout().

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

◆ variable_initial_expression()

expression variable_initial_expression ( entity  v)

Returns a copy of the initial (i.e.

initialization) expression of variable v. If v's inital value is a constants or a code block, it is converted to the corresponding expression.

Could have been called entity_to_initialization_expression(), or entity_to_initial_expression(), but it only makes sense for variables.

FI: not sure this is used in C; also, the constant field could be used as well.

Definition at line 1899 of file variable.c.

1900 {
1901  value val = entity_initial(v);
1903 
1904  if (value_undefined_p(val))
1905  {
1906  // FC: this seems to occur on from initial preconditions on a field
1907  // within a struct. The actual initial value should be "0" in that case.
1908  // see Semantics/struct04.c
1909  pips_user_warning("undefined initial value on %s... ignoring",
1910  entity_name(v));
1911  return expression_undefined;
1912  }
1913 
1914  if (value_expression_p(val)) {
1916  }
1917  else if(value_constant_p(val)) {
1918  constant c = value_constant(val);
1919  if (constant_int_p(c)) {
1921  }
1922  else {
1923  pips_internal_error("Not Yet Implemented.");
1924  }
1925  }
1926  else if(value_code_p(val)) {
1929 
1930  if(!ENDP(il)) {
1931  statement is = STATEMENT(CAR(il));
1933 
1934  pips_assert("A pointer initialization is made of one instruction expression",
1935  gen_length(il)==1 && instruction_expression(ii));
1936 
1938  }
1939  }
1940  }
1941  else if(value_unknown_p(val)) {
1943  }
1944  else if(value_intrinsic_p(val)) {
1946  }
1947  else if(value_reference_p(val)) {
1948  // FI: the initial value of a location entity is a reference to itself
1950  }
1951  else if(value_symbolic_p(val)) {
1952  symbolic s = value_symbolic(val);
1953  /* FI: not sure this is used in C; also, the constant field could be
1954  used as well. */
1956  }
1957  else {
1958  pips_internal_error("Unexpected value tag %d.", value_tag(val));
1959  }
1960 
1961  return exp;
1962 }
size_t gen_length(const list l)
Definition: list.c:150
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
#define value_tag(x)
Definition: ri.h:3064
#define value_undefined_p(x)
Definition: ri.h:3017
#define value_code_p(x)
Definition: ri.h:3065
#define value_constant(x)
Definition: ri.h:3073
#define value_intrinsic_p(x)
Definition: ri.h:3074
#define constant_int(x)
Definition: ri.h:850
#define value_unknown_p(x)
Definition: ri.h:3077
#define value_constant_p(x)
Definition: ri.h:3071
#define value_symbolic(x)
Definition: ri.h:3070
#define constant_int_p(x)
Definition: ri.h:848
#define code_initializations(x)
Definition: ri.h:788
#define sequence_statements(x)
Definition: ri.h:2360
#define instruction_expression(x)
Definition: ri.h:1541
#define value_reference_p(x)
Definition: ri.h:3083
#define value_expression_p(x)
Definition: ri.h:3080
#define symbolic_expression(x)
Definition: ri.h:2597
#define value_expression(x)
Definition: ri.h:3082
#define exp
Avoid some warnings from "gcc -Wshadow".
Definition: vasnprintf.c:207

References CAR, code_initializations, constant_int, constant_int_p, copy_expression(), ENDP, entity_initial, entity_name, entity_type, exp, expression_undefined, gen_length(), instruction_expression, int_to_expression(), pips_assert, pips_internal_error, pips_user_warning, pointer_type_p(), sequence_statements, STATEMENT, statement_instruction, symbolic_expression, ultimate_type(), value_code, value_code_p, value_constant, value_constant_p, value_expression, value_expression_p, value_intrinsic_p, value_reference_p, value_symbolic, value_symbolic_p, value_tag, value_undefined_p, and value_unknown_p.

Referenced by c_data_to_prec_for_variables(), declaration_statement_to_points_to(), declaration_to_transformer(), declaration_to_transformer_list(), global_source_to_sinks(), move_declaration_control_node_declarations_to_statement(), partial_eval_declaration(), propagate_preconditions_in_declarations(), redeclaration_enter_statement(), rename_statement_declarations(), self_initialization_p(), and split_initializations_in_statement().

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

◆ variable_is_a_module_formal_parameter_p()

bool variable_is_a_module_formal_parameter_p ( entity  a_variable,
entity  a_module 
)

Well, the variable is a formal parameter of the module:

The variable is in the declaration of the module but is not a formal parameter:

The variable is not in the declaration of the module:

Parameters
a_variable_variable
a_module_module

Definition at line 1547 of file variable.c.

1549 {
1551  {
1552  storage s = entity_storage(e);
1553  if (e == a_variable) {
1554  if (storage_formal_p(s))
1555  /* Well, the variable is a formal parameter of the
1556  module: */
1557  return true;
1558  else
1559  /* The variable is in the declaration of the module
1560  but is not a formal parameter: */
1561  return false;
1562  }
1563  }
1564 
1565  /* The variable is not in the declaration of the module: */
1566  return false;
1567 }
static entity a_variable

References a_variable, code_declarations, ENTITY, entity_initial, entity_storage, FOREACH, storage_formal_p, and value_code.

Referenced by create_values_for_simple_effect(), statement_has_a_module_formal_argument_write_effect_p(), and translate_to_module_frame().

+ Here is the caller graph for this function:

◆ variable_return_p()

bool variable_return_p ( entity  v)

True if a variable is the pseudo-variable used to store value returned by a function:

Definition at line 1522 of file variable.c.

1523 {
1524  storage s = entity_storage(v);
1525  bool return_p = storage_return_p(s);
1526 
1527  return return_p;
1528 }
#define storage_return_p(x)
Definition: ri.h:2516

References entity_storage, and storage_return_p.

Referenced by entities_maymust_conflict_p(), statement_has_a_module_formal_argument_write_effect_p(), transformer_filter_subsumed_variables(), and variable_to_abstract_location().

+ Here is the caller graph for this function:

◆ variable_stack_p()

bool variable_stack_p ( entity  v)

Definition at line 1593 of file variable.c.

1594 {
1595  return(type_variable_p(entity_type(v)) &&
1598 }

References entity_storage, entity_type, ram_section, stack_area_p(), storage_ram, storage_ram_p, and type_variable_p.

Referenced by dynamic_variables_to_values().

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

◆ variable_static_p()

◆ volatile_variable_p()

bool volatile_variable_p ( variable  v)
Returns
whether variable is a "volatile" variable

See also entity_register_p()

Definition at line 1649 of file variable.c.

1650 {
1651  bool volatile_p = false;
1652 
1653  // FI: no idea if volatile can he hidden in a typedef...
1654  list ql = variable_qualifiers(v);
1655 
1656  FOREACH(QUALIFIER, q, ql) {
1657  if(qualifier_volatile_p(q)) {
1658  volatile_p = true;
1659  break;
1660  }
1661  }
1662  return volatile_p;
1663 }
#define qualifier_volatile_p(x)
Definition: ri.h:2182

References FOREACH, QUALIFIER, qualifier_volatile_p, and variable_qualifiers.

Referenced by analyzed_type_p(), entity_volatile_variable_p(), and pointer_expression_to_transformer().

+ Here is the caller graph for this function:

Variable Documentation

◆ char_entities

list char_entities = list_undefined

Definition at line 896 of file variable.c.

Referenced by make_new_entity().

◆ complex_entities

list complex_entities = list_undefined

Definition at line 894 of file variable.c.

Referenced by make_new_entity().

◆ count_aux

int count_aux = 0
static

Definition at line 865 of file variable.c.

Referenced by make_new_entity().

◆ count_tmp

int count_tmp = 0
static

These globals variables count the number of temporary and auxiliary entities.

Each time such a variable is created, the corresponding counter is incremented.

FI: this must be wrong. A function to reset count_tmp and count_aux is needed if tpips or wpips are to work in a consistent way! gcc complains that they are not used... but they are defined!

Definition at line 864 of file variable.c.

Referenced by make_new_entity().

◆ double_entities

list double_entities = list_undefined

Definition at line 895 of file variable.c.

Referenced by make_new_entity().

◆ integer_entities

list integer_entities = list_undefined

Make a new variable entity which name is one letter prefix + one incrementing number.

The function name should be changed. Useless function according to previous ones ?

This entity is either a new temporary or a new auxiliary variable. The parameter "kind" gives the kind of entity to produce. "ba" gives the basic (ie the type) of the entity to create.

The number of the temporaries is given by a global variable named "count_tmp". The number of the auxiliary variables is given by a global variable named "count_aux". These lists memorize all the new created entities of each type. They are used for the declarations of these new variables : temporaries and auxiliaries.

Definition at line 891 of file variable.c.

Referenced by initialize_global_variables(), insert_new_declarations(), make_new_entity(), and reset_global_variables().

◆ logical_entities

list logical_entities = list_undefined

Definition at line 893 of file variable.c.

Referenced by make_new_entity().

◆ real_entities

list real_entities = list_undefined

Definition at line 892 of file variable.c.

Referenced by make_new_entity().

◆ unique_complex_number

int unique_complex_number = 0
static

◆ unique_float_number

int unique_float_number = 0
static

◆ unique_integer_number

int unique_integer_number = 0
static

New Temporary Variables MANAGEMENT

Definition at line 414 of file variable.c.

Referenced by make_new_derived_entity_with_prefix(), make_new_scalar_variable_with_prefix(), and reset_unique_variable_numbers().

◆ unique_logical_number

int unique_logical_number = 0
static

◆ unique_string_number

int unique_string_number = 0
static

Definition at line 418 of file variable.c.

Referenced by make_new_scalar_variable_with_prefix().