25 #include "pips_config.h"
52 const char *user_name=
153 bool add_declaration_statement_p) {
197 pips_assert(
"Calling AddLocalEntityToDeclarations from c_module "
287 asprintf(&eln,
"%s%d",seed,counter++);
430 #define DEFAULT_INT_PREFIX "I_"
431 #define DEFAULT_FLOAT_PREFIX "F_"
432 #define DEFAULT_LOGICAL_PREFIX "L_"
433 #define DEFAULT_COMPLEX_PREFIX "C_"
434 #define DEFAULT_STRING_PREFIX "S_"
435 #define DEFAULT_POINTER_PREFIX "P_"
436 #define DEFAULT_STRUCT_PREFIX "ST_"
437 #define DEFAULT_UNION_PREFIX "U_"
438 #define DEFAULT_ENUM_PREFIX "E_"
439 #define DEFAULT_DERIVED_STRUCT_PREFIX "DS_"
440 #define DEFAULT_DERIVED_UNION_PREFIX "DU_"
441 #define DEFAULT_DERIVED_ENUM_PREFIX "DE_"
568 declaration_statement,
601 bool empty_prefix = (strlen(
prefix) == 0);
694 bool empty_prefix = (strlen(
prefix) == 0);
917 (
void) sprintf(
prefix,
"O");
919 (
void) sprintf(
prefix,
"F");
922 default: (void) sprintf(
prefix,
"O");
933 (void) sprintf(
prefix+1,
"TMP");
939 (void) sprintf(
prefix+1,
"AUX");
942 default:
user_error(
"make_new_entity",
"Bad kind of entity: %d", kind);
1115 bool return_value =
false;
1122 return return_value;
1169 bool atomic_p =
false;
1195 bool atomic_p =
false;
1237 while (pd !=
NIL && --i > 0)
1270 bool numerical_bounds_p =
true;
1272 for(d=1; d <= nb_dim && numerical_bounds_p; d++) {
1281 return numerical_bounds_p;
1352 sprintf(
num,
"%td", c);
1478 pips_assert(
"Not possible for Fortran code", !is_fortran_p);
1537 bool formal_p =
false;
1618 pips_assert (
"Module declaration consistency", in_module_1==in_module_2);
1626 bool is_in_list =
false;
1627 for( ; (l !=
NIL) && (! is_in_list); l =
CDR(l))
1651 bool volatile_p =
false;
1668 bool qualified_p =
false;
1715 (void) sprintf(
buffer,
"%s%d", suffix, i);
1726 pips_assert(
"A label cannot be more than 5 character long", strlen(i)<=5);
1754 pips_assert(
"No more than 999 alternate returns", 0 <= l && l < 999);
1756 sprintf(
buffer,
"%d", l);
1791 pips_debug(8,
"Generated replacement for formal return label: %s\n",
1799 bool replacement_p =
false;
1805 replacement_p = (strstr(fpn, lsp)==fpn);
1807 return replacement_p;
1813 bool replacement_p =
false;
1817 const char * p = ls+1;
1819 replacement_p = (strlen(ls) >= 4
1820 && *ls==
'"' && *(ls+1)==
'*' && *(ls+strlen(ls)-1)==
'"');
1823 for(p=ls+2; p<ls+strlen(ls)-1; p++) {
1824 if(*p<'0'||*p>
'9') {
1825 replacement_p =
false;
1832 return replacement_p;
1837 bool contains_p =
false;
1855 char *new_name=NULL;
1862 char *tmp = new_name;
1934 pips_assert(
"A pointer initialization is made of one instruction expression",
1968 bool self_p =
false;
2026 "Different offsets %td for %s in section %s and %td for %s in section %s\n",
2033 "Disjoint entitites %s in section %s and %s in section %s\n",
2057 #define PLACE_HOLDER_PREFIX_STRING "PLACE__HOLDER_"
functional make_functional(list a1, type a2)
cast make_cast(type a1, expression a2)
constant make_constant(enum constant_utype tag, void *val)
value make_value_unknown(void)
basic make_basic_derived(entity _field_)
value make_value_expression(expression _field_)
expression make_expression(syntax a1, normalized a2)
type make_type_variable(variable _field_)
basic make_basic(enum basic_utype tag, void *val)
storage make_storage_rom(void)
void free_entity(entity p)
type copy_type(type p)
TYPE.
basic copy_basic(basic p)
BASIC.
storage make_storage(enum storage_utype tag, void *val)
basic make_basic_int(intptr_t _field_)
ram make_ram(entity a1, entity a2, intptr_t a3, list a4)
basic make_basic_pointer(type _field_)
expression copy_expression(expression p)
EXPRESSION.
value make_value(enum value_utype tag, void *val)
variable make_variable(basic a1, list a2, list a3)
value copy_value(value p)
VALUE.
storage copy_storage(storage p)
STORAGE.
syntax make_syntax_cast(cast _field_)
constant make_constant_litteral(void)
storage make_storage_ram(ram _field_)
void free_statement(statement p)
bool entity_consistent_p(entity p)
type make_type(enum type_utype tag, void *val)
bool entity_is_argument_p(entity e, cons *args)
#define DOUBLE_PRECISION_SIZE
bdt base
Current expression.
struct _newgen_struct_type_ * type
expression MakeCharacterConstantExpression(string s)
END_EOLE.
static entity new_variable
entity to be replaced, the primary?
static entity old_variable
void propagate_synonym(s, old, new) statement s; entity old, new;
const char * global_name_to_user_name(const char *global_name)
functions on strings for entity names
bool compilation_unit_p(const char *module_name)
The names of PIPS entities carry information about their nature.
const char * module_name(const char *s)
Return the module part of an entity name.
char * get_string_property(const char *)
#define gen_chunk_undefined_p(c)
statement get_current_module_statement(void)
Get the current module statement.
entity get_current_module_entity(void)
Get the entity of the current module.
#define ENDP(l)
Test if a list is empty.
void gen_remove(list *cpp, const void *o)
remove all occurences of item o from list *cpp, which is thus modified.
void gen_remove_once(list *pl, const void *o)
Remove the first occurence of o in list pl:
#define NIL
The empty list (nil in Lisp)
list gen_copy_seq(list l)
Copy a list structure.
size_t gen_length(const list l)
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
#define CAR(pcons)
Get the value of the first element of a list.
void gen_free_list(list l)
free the spine of the list
bool gen_in_list_p(const void *vo, const list lx)
tell whether vo belongs to lx
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
#define CDR(pcons)
Get the list less its first element.
void * gen_find_eq(const void *item, const list seq)
#define list_undefined
Undefined list definition :-)
list gen_full_copy_list(list l)
Copy a list structure with element copy.
list statement_block(statement)
Get the list of block statements of a statement sequence.
void insert_statement(statement, statement, bool)
This is the normal entry point.
statement make_continue_statement(entity)
statement add_declaration_statement(statement, entity)
bool declaration_statement_p(statement)
Had to be optimized according to Beatrice Creusillet.
void hash_warn_on_redefinition(void)
these function set the variable should_i_warn_on_redefinition to the value true or false
#define full_name(dir, name)
static const char * old_name(entity module, entity obj)
old name of obj while in module now.
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
#define pips_user_warning
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
#define pips_internal_error
#define user_error(fn,...)
#define DYNAMIC_AREA_LOCAL_NAME
#define TOP_LEVEL_MODULE_NAME
Module containing the global variables in Fortran and C.
#define STATIC_AREA_LOCAL_NAME
#define MODULE_SEP_STRING
#define BLOCK_SEP_STRING
Scope separator.
#define message_assert(msg, ex)
string strupper(string, const char *)
string concatenate(const char *,...)
Return the concatenation of the given strings.
#define same_string_p(s1, s2)
void * gen_find_tabulated(const char *, int)
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
static entity dynamic_area
int add_any_variable_to_area(entity a, entity v, bool is_fortran_p)
entity make_scalar_entity(const char *name, const char *module_name, basic base)
entity make_scalar_entity(name, module_name, base)
entity make_place_holder_variable(entity de)
entity make_integer_constant_entity(_int c)
entity make_integer_constant_entity(int c) make entity for integer constant c
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.
void AddEntityToDeclarations(entity e, entity module)
END_EOLE.
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...
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.
static int unique_string_number
#define DEFAULT_DERIVED_ENUM_PREFIX
entity generate_pseudo_formal_variable_for_formal_label(const char *p, int l)
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.
bool integer_scalar_entity_p(entity e)
integer_scalar_entity_p() is obsolete; use entity_integer_scalar_p()
bool const_variable_p(entity v)
static void GenericAddLocalEntityToDeclarations(entity e, entity module, statement s, bool add_declaration_statement_p)
See the two user interfaces below.
entity make_new_entity(basic ba, int kind)
bool variable_in_common_p(entity v)
true if v is in a common.
bool variable_return_p(entity v)
True if a variable is the pseudo-variable used to store value returned by a function:
entity make_new_index_entity(entity old_index, string suffix)
static int count_tmp
These globals variables count the number of temporary and auxiliary entities.
void reset_unique_variable_numbers()
int add_variable_to_area(entity a, entity v)
#define DEFAULT_POINTER_PREFIX
entity find_or_create_typed_entity(string name, const char *module_name, tag base)
Looks for an entity of the specified basic.
bool entity_atomic_reference_p(entity e)
Any reference r such that reference_variable(r)==e accesses all bytes (or bits) allocated to variable...
bool variable_dynamic_p(entity v)
static int unique_float_number
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 a...
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.
expression generate_string_for_alternate_return_argument(string i)
bool entity_scalar_p(entity e)
The concrete type of e is a scalar type.
bool place_holder_variable_p(entity ph)
bool variable_stack_p(entity v)
#define DEFAULT_COMPLEX_PREFIX
bool global_variable_p(entity v)
Is v a global variable such as "int i;".
void AddEntityToCurrentModuleWithoutDeclaration(entity e)
Add a variable entity to the current module declarations.
bool variable_in_list_p(entity e, list l)
bool implicit_c_variable_p(entity v)
bool same_scalar_location_p(entity e1, entity e2)
FI: transferred from semantics (should be used for effect translation as well)
int add_C_variable_to_area(entity a, entity v)
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.
bool entity_static_variable_p(entity e)
return true if the entity is declared with the keyword static
void RemoveLocalEntityFromDeclarations(entity e, entity module, statement s)
static int unique_integer_number
bool formal_label_replacement_p(entity fp)
static entity make_array_entity(const char *name, const char *module_name, basic base, list dimensions)
Create an array entity.
entity make_global_entity_from_local(entity local)
entity make_new_module_variable(entity module, int d)
Make a new module integer variable of name X<d>.
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".
entity make_derived_entity(const char *name, const char *module_name, type t)
bool symbolic_constant_entity_p(entity e)
BEGIN_EOLE.
bool volatile_variable_p(variable v)
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.
bool entity_unbounded_p(entity e)
bool entity_unbounded_p(entity e) input : an array entity output : true if the last dimension of the ...
int new_add_any_variable_to_area(entity a, entity v, bool is_fortran_p)
#define DEFAULT_FLOAT_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
entity make_new_array_variable(entity module, basic b, list dimensions)
bool static_global_variable_p(entity v)
Is v a global variable declared local to a C file such "static int i;".
bool qualified_variable_p(entity v, unsigned int is_qualified)
The variable may turn out to be a function.
bool formal_parameter_p(entity v)
void AddEntityToCurrentModule(entity e)
Add a variable entity to the current module declarations.
bool actual_label_replacement_p(expression eap)
Assumes that eap is a call.
static int unique_logical_number
#define DEFAULT_DERIVED_UNION_PREFIX
#define DEFAULT_STRUCT_PREFIX
#define DEFAULT_LOGICAL_PREFIX
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.
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)
bool entity_volatile_variable_p(entity v)
bool entity_non_pointer_scalar_p(entity e)
entity make_new_scalar_variable(entity module, basic b)
void AddLocalEntityToDeclarations(entity e, entity module, statement s)
Add the variable entity e to the list of variables of the function module.
bool call_contains_alternate_returns_p(call c)
list integer_entities
Make a new variable entity which name is one letter prefix + one incrementing number.
#define PLACE_HOLDER_PREFIX_STRING
Generate special variables to represent declarations such as "struct s;".
bool entity_integer_scalar_p(entity e)
for variables (like I), not constants (like 1)! use integer_constant_p() for constants
bool variable_is_a_module_formal_parameter_p(entity a_variable, entity a_module)
#define DEFAULT_STRING_PREFIX
entity make_stderr_variable()
If the parser has not (yet) encountered "stderr", a PIPS transformation or instrumentation phase may ...
bool formal_context_variable_p(entity v)
Such pseudo-variables are generated by the points-to analysis.
#define DEFAULT_DERIVED_STRUCT_PREFIX
entity make_temporary_pointer_to_array_entity(entity efrom, expression from, entity module)
entity make_new_derived_entity_with_prefix(const char *prefix, entity module, type t)
derived from make_new_scalar_variable_with_prefix
void remove_variable_entity(entity v)
#define DEFAULT_INT_PREFIX
Default prefixes.
static int unique_complex_number
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 m...
#define DEFAULT_ENUM_PREFIX
entity make_temporary_pointer_to_array_entity_with_prefix(char *prefix, entity efrom, entity module, expression from)
list struct_variable_to_fields(entity v)
Assume that v is declared as a struct.
int variable_entity_dimension(entity v)
variable_entity_dimension(entity v): returns the dimension of variable v; scalar have dimension 0.
bool variable_entity_p(entity e)
See also macro entity_variable_p()...
expression variable_initial_expression(entity v)
Returns a copy of the initial (i.e.
#define DEFAULT_UNION_PREFIX
void AddLocalEntityToDeclarationsOnly(entity e, entity module, statement s)
Add the variable entity e to the list of variables of the function module.
bool variable_heap_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 decla...
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.
static const char * prefix
#define DEFAULT_INTEGER_TYPE_SIZE
#define statement_block_p(stat)
#define make_entity(n, t, s, i)
#define DYNAMIC_RAM_OFFSET
FI: I would have assumed that it is used for the stack area, but I must be wrong.....
#define IMPLICIT_VARIABLE_NAME_1
Implicit variable names for C.
#define UNKNOWN_RAM_OFFSET
#define entity_declarations(e)
MISC: newgen shorthands.
#define IMPLICIT_VARIABLE_NAME_2
#define entity_variable_p(e)
An entity_variable_p(e) may hide a typedef and hence a functional type.
#define instruction_block(i)
bool dynamic_area_p(entity aire)
bool stack_area_p(entity aire)
bool heap_area_p(entity aire)
int current_offset_of_area(entity a, entity v)
bool formal_area_p(entity aire)
bool static_area_p(entity aire)
bool entity_special_area_p(entity e)
const char * entity_user_name(entity e)
Since entity_local_name may contain PIPS special characters such as prefixes (label,...
entity FindEntity(const char *package, const char *name)
Retrieve an entity from its package/module name and its local name.
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...
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...
bool same_entity_p(entity e1, entity e2)
predicates on entities
entity local_name_to_top_level_entity(const char *n)
This function try to find a top-level entity from a local name.
bool c_module_p(entity m)
Test if a module "m" is written in C.
code entity_code(entity e)
entity entity_to_module_entity(entity e)
Find the enclosing module of an entity.
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
entity entity_empty_label(void)
const char * module_local_name(entity e)
Returns the module local user name.
code EntityCode(entity e)
this function checks that e has an initial value code.
bool fortran_module_p(entity m)
Test if a module is in Fortran.
bool entity_basic_p(entity e, enum basic_utype basictag)
return true if the basic associated with entity e matchs the passed tag
bool entity_module_p(entity e)
bool top_level_entity_p(entity e)
Check if the scope of entity e is global.
const char * entity_module_name(entity e)
See comments about module_name().
bool expression_call_p(expression e)
expression int_to_expression(_int i)
transform an int into an expression and generate the corresponding entity if necessary; it is not cle...
bool unbounded_dimension_p(dimension dim)
bool unbounded_dimension_p(dim) input : a dimension of an array entity.
bool expression_with_constant_signed_integer_value_p(expression e)
The expression may be complicated but all its leaves are constants or parameters.
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...
bool SizeOfArray(entity, int *)
This function computes the total size of a variable in bytes, ie.
basic MakeBasic(int)
END_EOLE.
type entity_basic_concrete_type(entity)
retrieves or computes and then returns the basic concrete type of an entity
bool pointer_type_p(type)
Check for scalar pointers.
list derived_type_to_fields(type)
size_t type_depth(type)
Number of steps to access the lowest leave of type t without dereferencing.
int NumberOfDimension(entity)
bool overloaded_type_p(type)
Returns true if t is a variable type with a basic overloaded.
basic basic_ultimate(basic)
get the ultimate basic from a basic typedef
type MakeTypeVariable(basic, cons *)
BEGIN_EOLE.
#define value_undefined_p(x)
#define normalized_undefined
#define REFERENCE(x)
REFERENCE.
#define storage_formal_p(x)
#define basic_complex_p(x)
#define value_constant(x)
#define QUALIFIER(x)
QUALIFIER.
#define reference_variable(x)
#define value_intrinsic_p(x)
#define symbolic_constant(x)
#define value_unknown_p(x)
#define qualifier_volatile_p(x)
#define dimension_lower(x)
#define basic_pointer_p(x)
#define entity_storage(x)
#define code_declarations(x)
#define value_constant_p(x)
#define value_symbolic(x)
#define EXPRESSION(x)
EXPRESSION.
#define entity_undefined_p(x)
#define constant_int_p(x)
#define expression_undefined
#define value_symbolic_p(x)
#define code_initializations(x)
#define sequence_statements(x)
#define dimension_upper(x)
#define variable_qualifiers(x)
#define instruction_expression(x)
#define expression_undefined_p(x)
#define value_reference_p(x)
#define variable_dimensions(x)
#define code_decls_text(x)
#define statement_declarations(x)
#define statement_instruction(x)
#define call_arguments(x)
#define statement_undefined_p(x)
#define value_expression_p(x)
#define expression_syntax(x)
#define storage_return_p(x)
#define type_variable_p(x)
#define symbolic_expression(x)
#define value_expression(x)
#define storage_undefined_p(x)
#define entity_domain
newgen_syntax_domain_defined
#define variable_basic(x)
#define statement_undefined
#define basic_logical_p(x)
struct _newgen_struct_variable_ * variable
#define STATEMENT(x)
STATEMENT.
#define storage_undefined
#define entity_initial(x)
char * variable_name(Variable v)
polynome_ri.c
The structure used to build lists in NewGen.
#define exp
Avoid some warnings from "gcc -Wshadow".