26 #include "pips_config.h"
58 bool replaced =
false;
101 pips_debug(1,
"Loop index %s renamed as %s\n",
154 pips_debug(1,
"Local variable %s is preserved because its initial value "
173 pips_debug(1,
"Initialize var %s with initial value of var %s: ",
187 pips_debug(1,
"Declaration for external variable \"%s\" moved.\n",
243 pips_debug(1,
"End. Local declarations %s.\n",
244 ENDP(ndecls)?
"removed" :
"updated");
293 pips_debug(5,
"Skipping the already processed variable \"%s\" \n",
298 if(strcmp(mn, vmn)!=0) {
315 bool redeclare_p =
false;
316 bool move_initialization_p =
false;
323 move_initialization_p =
true;
331 move_initialization_p =
true;
335 move_initialization_p =
false;
343 move_initialization_p =
false;
354 move_initialization_p =
true;
358 move_initialization_p =
false;
362 move_initialization_p =
false;
395 bool is_same_name =
false;
398 pips_debug(8,
"Entities found in declaration statement: ");
411 pips_debug(8,
"Skipping the variable \"%s\" we are working on\n",
420 "conflicts with references in declaration statement\n",
429 }
while (is_same_name);
516 bool renaming_p =
false;
531 int cs_se_l = strlen(cs_se);
532 if(cs_se_l>0 && cs_se_l<csl) {
584 pips_debug(2,
"Code flattening fails because the statement does"
585 " not contain any local declaration\n");
608 bool decl_stat_found =
false;
650 bool good_result_p =
true;
658 debug_on(
"FLATTEN_CODE_DEBUG_LEVEL");
673 good_result_p =
false;
678 " because of VLA type of variable \"%s\"\n",
721 return good_result_p;
745 bool good_result_p =
true;
752 debug_on(
"SPLIT_INITIALIZATIONS_DEBUG_LEVEL");
768 return (good_result_p);
781 bool has_pointer =
false;
838 debug_on(
"SPLIT_UPDATE_OPERATOR_DEBUG_LEVEL");
expression copy_expression(expression p)
EXPRESSION.
instruction make_instruction_sequence(sequence _field_)
void free_expression(expression p)
sequence make_sequence(list a)
struct _newgen_struct_entity_ * entity
struct _newgen_struct_expression_ * expression
bool entity_is_argument_p(entity e, cons *args)
bool clean_up_sequences(statement s)
Recursively clean up the statement sequences by fusing them if possible and by removing useless one.
struct _newgen_struct_statement_ * statement
const char * module_name(const char *s)
Return the module part of an entity name.
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
static void statement_purge_declarations_walker(sequence seq)
static void split_update_operator_statement_walker(statement s)
static void rename_loop_index(loop l, hash_table renamings)
gen_multi_recurse callback on exiting a loop: if loop index needs renaming, rename this occurrence.
struct redeclaration_context redeclaration_context_t
To generate the new variables, we need to know:
void statement_split_initializations(statement s)
Recurse through the statements of s and split local declarations.
bool split_initializations(const char *module_name)
Pipsmake 'split_initializations' phase.
void split_update_call(call c)
bool statement_flatten_declarations(entity module, statement s)
flatten_code.c
static void statement_purge_declarations(statement s)
static void unroll_loops_in_statement(statement s)
static void rename_statement_declarations(statement s, hash_table renamings)
gen_multi_recurse callback on exiting a statement: recompute the declaration list for statement s and...
static void compute_renamings(statement s, const char *sc, const char *mn, hash_table renamings)
FI: added to wrap up the use of redeclaration context...
static void redeclaration_exit_statement(statement s, redeclaration_context_t *rdcp)
Keep track of cycle exit in the hierarchical control flow graph.
bool split_update_operator(const char *module_name)
static bool redeclaration_enter_statement(statement s, redeclaration_context_t *rdcp)
This function makes the key decision about the renaming: should the variable be renamed?...
static void rename_variable_type(entity var, hash_table renamings)
If the type of variable var is a typedefed type, it may have been renamed and the symbol table must b...
bool flatten_code(const string module_name)
Pipsmake 'flatten_code' phase.
static void rename_reference(reference r, hash_table renamings)
Flatten code.
#define gen_chunk_undefined_p(c)
#define gen_context_recurse(start, ctxt, domain_number, flt, rwt)
#define gen_recurse(start, domain_number, flt, rwt)
union gen_chunk * gen_chunkp
statement instruction_to_statement(instruction)
Build a statement from a give instruction.
void reset_current_module_entity(void)
Reset the current module entity.
void reset_current_module_statement(void)
Reset the current module statement.
statement set_current_module_statement(statement)
Set the current module statement.
statement get_current_module_statement(void)
Get the current module statement.
entity set_current_module_entity(entity)
static.c
entity get_current_module_entity(void)
Get the entity of the current module.
void replace_entities(void *s, hash_table ht)
Recursively substitute a set of entities in a statement.
void gen_multi_recurse(void *o,...)
Multi recursion visitor function.
void gen_context_multi_recurse(void *o, void *context,...)
Multi-recursion with context function visitor.
gen_chunk * gen_get_ancestor(int, const void *)
return the first ancestor object found of the given type.
bool gen_true2(__attribute__((unused)) gen_chunk *u1, __attribute__((unused)) void *u2)
bool gen_true(__attribute__((unused)) gen_chunk *unused)
Return true and ignore the argument.
#define ENDP(l)
Test if a list is empty.
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.
#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
#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)
string db_get_memory_resource(const char *rname, const char *oname, bool pure)
Return the pointer to the resource, whatever it is.
#define DB_PUT_MEMORY_RESOURCE(res_name, own_name, res_val)
conform to old interface.
loop statement_loop(statement)
Get the loop of a statement.
bool statement_loop_p(statement)
statement make_assign_statement(expression, expression)
list statement_to_referenced_entities(statement)
Get a list of all variables referenced recursively within a statement:
list instruction_to_declarations(instruction)
Get a list of all variables declared recursively within an instruction.
bool statement_with_empty_comment_p(statement)
Return true if the statement has an empty statement:
bool declaration_statement_p(statement)
Had to be optimized according to Beatrice Creusillet.
void hash_table_fprintf(FILE *f, gen_string_func_t key_to_string, gen_string_func_t value_to_string, const hash_table htp)
This function prints the content of the hash_table pointed to by htp on file descriptor f,...
hash_table hash_table_make(hash_key_type key_type, size_t size)
void * hash_get(const hash_table htp, const void *key)
this function retrieves in the hash table pointed to by htp the couple whose key is equal to key.
void hash_table_free(hash_table htp)
this function deletes a hash table that is no longer useful.
bool hash_defined_p(const hash_table htp, const void *key)
true if key has e value in htp.
bool loop_fully_unrollable_p(loop l)
void full_loop_unroll(statement loop_statement)
get rid of the loop by body replication;
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
#define pips_user_warning
#define pips_internal_error
#define MODULE_SEP_STRING
string concatenate(const char *,...)
Return the concatenation of the given strings.
#define hash_put_or_update(h, k, v)
#define HASH_DEFAULT_SIZE
#define same_string_p(s1, s2)
string(* gen_string_func_t)(const void *)
void unnormalize_expression(void *st)
void unnormalize_expression(expression exp): puts all the normalized field of expressions in "st" to ...
void print_expression(expression e)
no file descriptor is passed to make is easier to use in a debugging stage.
void print_statements(list)
bool module_reorder(statement body)
Reorder a module and recompute order to statement if any.
#define binary_call_rhs(c)
#define MINUS_OPERATOR_NAME
#define PLUS_OPERATOR_NAME
#define statement_block_p(stat)
#define STATEMENT_NUMBER_UNDEFINED
default values
#define entity_declarations(e)
MISC: newgen shorthands.
#define ENTITY_PLUS_C_P(e)
#define ENTITY_MINUS_C_P(e)
#define binary_call_lhs(c)
#define ASSIGN_OPERATOR_NAME
void split_initializations_in_statement(statement s)
Transform a declaration with an initialization statement into 2 parts, a declaration statement and an...
const char * entity_user_name(entity e)
Since entity_local_name may contain PIPS special characters such as prefixes (label,...
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...
bool entity_formal_p(entity p)
is p a formal parameter?
entity update_operator_to_regular_operator(entity op)
Returns the binary operator associated to a C update operator such as +=.
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
string local_name_to_scope(const char *ln)
allocates a new string
void print_entities(list l)
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
entity make_entity_copy_with_new_name(entity e, string global_new_name, bool move_initialization_p)
Create a copy of an entity, with (almost) identical type, storage and initial value if move_initializ...
bool expression_is_C_rhs_p(expression exp)
Not all expressions can be used as right-hand side (rhs) in C assignments.
expression entity_to_expression(entity e)
if v is a constant, returns a constant call.
expression MakeBinaryCall(entity f, expression eg, expression ed)
Creates a call expression to a function with 2 arguments.
bool extended_expression_constant_p(expression exp)
Returns true if the value of the expression does not depend syntactically on the current store.
expression call_to_expression(call c)
Build an expression that call a function or procedure.
basic basic_of_expression(expression)
basic basic_of_expression(expression exp): Makes a basic of the same basic as the expression "exp".
bool dependent_type_p(type)
A type is dependent in many ways according to definitions given in Wikipedia.
bool entity_static_variable_p(entity)
return true if the entity is declared with the keyword static
void AddLocalEntityToDeclarations(entity, entity, statement)
Add the variable entity e to the list of variables of the function module.
bool enum_type_p(type)
Returns true if t is of type derived and if the derived type is a enum.
void RemoveLocalEntityFromDeclarations(entity, entity, statement)
bool union_type_p(type)
Returns true if t is of type derived and if the derived type is a union.
expression variable_initial_expression(entity)
Returns a copy of the initial (i.e.
bool struct_type_p(type)
Returns true if t is of type derived and if the derived type is a struct.
bool typedef_type_p(type)
Returns true if t is a typedefED type.
bool variable_static_p(entity)
true if v appears in a SAVE statement, or in a DATA statement, or is declared static i C.
#define value_undefined_p(x)
#define expression_domain
newgen_execution_domain_defined
#define instruction_sequence_p(x)
#define loop_execution(x)
#define instruction_loop_p(x)
#define reference_variable(x)
#define loop_domain
newgen_language_domain_defined
#define value_unknown_p(x)
#define basic_pointer_p(x)
#define statement_domain
newgen_sizeofexpression_domain_defined
#define code_declarations(x)
#define call_domain
newgen_callees_domain_defined
#define EXPRESSION(x)
EXPRESSION.
#define instruction_forloop_p(x)
#define entity_undefined_p(x)
#define reference_domain
newgen_range_domain_defined
#define sequence_statements(x)
#define instruction_unstructured_p(x)
#define expression_undefined_p(x)
#define statement_declarations(x)
#define statement_instruction(x)
#define statement_comments(x)
#define instruction_whileloop_p(x)
@ is_execution_sequential
#define call_arguments(x)
#define statement_number(x)
#define value_expression_p(x)
#define expression_syntax(x)
#define sequence_domain
newgen_reference_domain_defined
#define execution_parallel_p(x)
#define variable_basic(x)
#define STATEMENT(x)
STATEMENT.
#define entity_initial(x)
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
The structure used to build lists in NewGen.
To generate the new variables, we need to know:
statement declaration_statement
#define exp
Avoid some warnings from "gcc -Wshadow".