27 #ifdef BUILDER_FREEZE_VARIABLES
30 #include "pips_config.h"
51 typedef struct {
list old,
new; } entity_lists;
53 static bool rw_effect_on_variable_p(
list efs,
entity var,
bool b)
58 for( le =efs ; !
ENDP(le ) && !readeff ;
POP(le) ) {
70 static bool entity_in_call_arguments_p(
entity ent,
call c)
84 static void substitute_entity_in_call_arguments(
entity old,
entity new,
call c)
99 static void freeze_variables_in_statement(
statement s, entity_lists * el)
102 bool read_eff_on_var_already_seen =
false;
103 bool READ_EFF =
true;
104 list new_entl = el->new;
105 list old_entl = el->old;
108 bool st_to_insert_before=
false;
109 bool one_entity_in_args =
false;
116 for (; !
ENDP(old_entl) && !
ENDP(new_entl);
POP(old_entl),
POP(new_entl))
120 bool this_entity_in_args =
false;
126 " changed'",(
char *) NULL));
127 one_entity_in_args = one_entity_in_args ||
128 (this_entity_in_args =
129 entity_in_call_arguments_p(ent,
131 read_eff_on_var_already_seen=
false;
132 if (this_entity_in_args) {
145 if (read_eff_on_var_already_seen
146 || rw_effect_on_variable_p(efs,ent,READ_EFF)) {
154 st_to_insert_before =
true;
158 substitute_entity_in_call_arguments(ent, new_ent,c1);
174 else read_eff_on_var_already_seen =
true;
179 if (one_entity_in_args){
180 if (st_to_insert_before) {
194 static bool initialized_variable_p(
entity e)
206 bool WRITE_EFF =
false;
207 entity_lists new_le = {
NIL,
NIL};
225 rep =
user_request(
"Which variables do you want to freeze?\n",mod_name);
226 if (rep[0] ==
'\0') {
227 user_log(
"No variable to freeze\n");
235 if (rw_effect_on_variable_p(cumu_eff,ent,WRITE_EFF)) {
237 pips_assert(
"entity to freeze is a scalar variable",
241 user_log(
"Variable %s to freeze is not in a COMMON \n",
243 if (!initialized_variable_p(ent))
244 user_log(
"Variable %s to freeze is not present in a DATA \n",
256 if (!
ENDP(new_le.old))
261 pips_assert(
"Statement is consistent after FREEZING VARIABLES",
static hash_table seen
static function to store whether a module has been seen during the recursive generation of the daVinc...
void user_log(const char *format,...)
call make_call(entity a1, list a2)
expression make_expression(syntax a1, normalized a2)
reference make_reference(entity a1, list a2)
bool statement_consistent_p(statement p)
test make_test(expression a1, statement a2, statement a3)
reference copy_reference(reference p)
REFERENCE.
syntax make_syntax(enum syntax_utype tag, void *val)
struct _newgen_struct_statement_ * statement
list load_proper_rw_effects_list(statement)
void reset_proper_rw_effects(void)
void set_proper_rw_effects(statement_effects)
void set_cumulated_rw_effects(statement_effects)
list load_cumulated_rw_effects_list(statement)
void reset_cumulated_rw_effects(void)
#define effect_any_reference(e)
FI: cannot be used as a left hand side.
#define action_write_p(x)
#define gen_context_recurse(start, ctxt, domain_number, flt, rwt)
statement make_block_statement(list)
Make a block statement from a list of statement.
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.
const char * get_current_module_name(void)
Get the name of the current module.
statement set_current_module_statement(statement)
Set the current module statement.
entity set_current_module_entity(entity)
static.c
bool gen_true2(__attribute__((unused)) gen_chunk *u1, __attribute__((unused)) void *u2)
instruction make_assign_instruction(expression l, expression r)
#define ENDP(l)
Test if a list is empty.
#define POP(l)
Modify a list pointer to point on the next element of the list.
#define NIL
The empty list (nil in Lisp)
#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 CDR(pcons)
Get the list less its first element.
#define MAPL(_map_list_cp, _code, _l)
Apply some code on the addresses of all the elements of a list.
#define MAP(_map_CASTER, _map_item, _map_code, _map_list)
Apply/map an instruction block on all the elements of a list (old fashioned)
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.
bool statement_call_p(statement)
statement make_stop_statement(string)
This function returns a Fortran stop statement with an error message.
void insert_statement(statement, statement, bool)
This is the normal entry point.
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
string user_request(const char *,...)
string concatenate(const char *,...)
Return the concatenation of the given strings.
bool module_reorder(statement body)
Reorder a module and recompute order to statement if any.
#define make_expression_list(stats...)
#define test_to_statement(t)
#define NON_EQUAL_OPERATOR_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...
list string_to_entity_list(string module, string names)
of 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)
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
expression reference_to_expression(reference r)
expression substitute_entity_in_expression(entity old, entity new, expression e)
This function replaces all the occurences of an old entity in the expression exp by the new entity.
bool expression_reference_p(expression e)
Test if an expression is a reference.
reference expression_reference(expression e)
Short cut, meaningful only if expression_reference_p(e) holds.
entity make_new_scalar_variable(entity, basic)
bool variable_in_common_p(entity)
true if v is in a common.
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 normalized_undefined
#define reference_variable(x)
#define statement_domain
newgen_sizeofexpression_domain_defined
#define EXPRESSION(x)
EXPRESSION.
#define instruction_undefined
#define statement_label(x)
#define expression_undefined
#define variable_dimensions(x)
#define statement_instruction(x)
#define instruction_call(x)
#define call_arguments(x)
#define statement_undefined_p(x)
#define type_variable_p(x)
#define variable_basic(x)
#define statement_undefined
#define STATEMENT(x)
STATEMENT.
The structure used to build lists in NewGen.
#define exp
Avoid some warnings from "gcc -Wshadow".