25 #include "pips_config.h"
65 bool memory_effects_only;
66 bool memory_in_out_effects_only;
71 static void init_in_effects_context(in_effects_context *ctxt,
75 ctxt->memory_in_out_effects_only =
get_bool_property(
"MEMORY_IN_OUT_EFFECTS_ONLY");
77 if (! ctxt->memory_effects_only
78 && ctxt->memory_in_out_effects_only)
85 ctxt->representation = representation;
88 static void reset_in_effects_context(in_effects_context *ctxt)
90 if (! ctxt->memory_effects_only
91 && ctxt->memory_in_out_effects_only)
100 if (!ctxt->memory_effects_only
101 && ctxt->memory_in_out_effects_only)
110 if (!ctxt->memory_effects_only
111 && ctxt->memory_in_out_effects_only)
156 l_glob = (*effects_local_to_global_translation_op)(l_loc);
158 (*db_put_summary_in_effects_func)(
module_name, l_glob);
187 #define debug_consistent(l)
189 static bool in_effects_stmt_filter(
198 static void in_effects_of_statement(
202 debug_consistent(
NIL);
218 static list in_effects_of_declarations(
220 in_effects_context *ctxt)
223 list lin_after_first_decl =
NIL;
230 lin_after_first_decl = in_effects_of_declarations(lin_after_decls,
CDR(l_decl), ctxt);
232 lin_after_first_decl = lin_after_decls;
241 pips_debug(8,
"dealing with entity : %s with type %s\n",
277 if (!
ENDP(l_w_exp_init))
290 lin_before_decls = (*effects_union_op)(
292 (*effects_sup_difference_op)(lin_after_first_decl,
302 lin_before_decls = lin_after_first_decl;
307 lin_before_decls = lin_after_first_decl;
311 lin_before_decls = lin_after_decls;
317 list l_tmp = lin_before_decls;
322 return lin_before_decls;
333 static list r_in_effects_of_sequence(
list l_inst, in_effects_context *ctxt)
350 pips_debug(3,
" first statement is (ordering %03zd): \n",
357 if (!
ENDP(remaining_block))
361 rb_lin = r_in_effects_of_sequence(remaining_block, ctxt);
365 pips_debug(6,
" in effects for remaining block:\n");
366 (*effects_prettyprint_func)(rb_lin);
371 t1 = (*load_completed_transformer_func)(first_statement);
390 (*effects_transformer_composition_op)(rb_lin, t1);
395 pips_debug(6,
" rw effects for first statement:\n");
396 (*effects_prettyprint_func)(s1_lrw);
401 pips_debug(6,
" in effects for first statement:\n");
402 (*effects_prettyprint_func)(s1_lin);
419 l_cumul_in = (*effects_union_op)(
439 (*effects_prettyprint_func)(l_cumul_in);
440 debug_consistent(l_cumul_in);
452 pips_debug(5,
"first statement is a declaration statement\n");
454 l_in = in_effects_of_declarations(rb_lin, l_decl, ctxt);
465 in_effects_of_sequence(
sequence block, in_effects_context *ctxt)
471 pips_debug(2,
"Effects for statement %03zd:\n",
481 l_in = r_in_effects_of_sequence(
l_inst, ctxt);
486 pips_debug(2,
"IN effects for statement%03zd:\n",
488 (*effects_prettyprint_func)(l_in);
493 debug_consistent(l_in);
499 in_effects_of_test(
test t, in_effects_context *ctxt)
505 pips_debug(2,
"Effects for statement %03zd:\n",
546 pips_debug(2,
"IN effects for statement %03zd:\n",
548 (*effects_prettyprint_func)(l_in);
553 debug_consistent(l_in);
558 static void in_effects_of_forloop(
forloop f, in_effects_context *ctxt)
562 pips_debug(1,
"considering for loop 0x%p\n", (
void *)
f);
576 static void in_effects_of_whileloop(
whileloop w, in_effects_context *ctxt)
581 pips_debug(1,
"considering while loop 0x%p\n", (
void *) w);
616 l_in = (*effects_union_op)(l_in,
634 static void in_effects_of_loop(
loop l, in_effects_context *ctxt)
639 list global_in, global_in_read_only;
641 list l_prop, l_prop_read, l_prop_write;
677 debug_consistent(lbody_in);
691 loop_trans = (*load_transformer_func)(current_stat);
700 (*effects_transformer_composition_op)(global_in, loop_trans);
711 global_in_read_only =
722 if (!
ENDP(global_in))
728 (*loop_range_in_effect_func)(l, &global_in, &global_write,
737 global_in_read_only =
738 (*effects_union_over_range_op)(global_in_read_only,
loop_index(l),
741 global_in =
gen_nconc(global_in, global_in_read_only);
748 l_in = (*effects_sup_difference_op)(
760 debug_consistent(l_in);
767 in_effects_of_external(
entity func,
list real_args)
773 pips_debug(4,
"translating effects for %s\n", func_name);
785 func_eff = (*db_get_summary_in_effects_func)(func_name);
787 context = (*load_context_func)(current_stat);
789 (func, real_args, func_eff,
context);
794 static bool written_before_read_p(
entity ent,
list args)
823 in_effects_of_call(
call c, in_effects_context *ctxt)
847 l_in = in_effects_of_external(e, pc);
848 debug_consistent(l_in);
850 debug_consistent(l_in);
855 debug_consistent(l_in);
857 debug_consistent(l_rw);
860 (*effects_prettyprint_func)(l_rw);
885 debug_consistent(l_in);
895 (*effects_prettyprint_func)(l_in);
899 debug_consistent(l_in);
909 static void in_effects_of_expression_instruction(
instruction i, in_effects_context *ctxt)
914 pips_debug(2,
"begin for expression instruction in statement%03zd\n",
926 pips_debug(2,
"end for expression instruction in statement%03zd\n",
952 transformer t_unst = (*load_transformer_func)(current_stat);
960 l_in = (*effects_test_union_op) (l_in,
effects_dup(l_tmp),
969 (*effects_transformer_composition_op)(l_in, t_unst);
976 debug_consistent(l_in);
982 in_effects_of_module_statement(
statement module_stat, in_effects_context *ctxt)
1036 debug_on(
"IN_EFFECTS_DEBUG_LEVEL");
1050 in_effects_context ctxt;
1051 init_in_effects_context(&ctxt, representation);
1052 in_effects_of_module_statement(module_stat, &ctxt);
1053 reset_in_effects_context(&ctxt);
1056 (*db_put_in_effects_func)
1058 (*db_put_invariant_in_effects_func)
1060 (*db_put_cumulated_in_effects_func)
static reference ref
Current stmt (an integer)
list l_inst
The list "first" is a truncated list from the first to the current statement (not included).
#define pips_debug_effects(level, message, l_eff)
effects_representation_val
void free_effects_private_current_context_stack(void)
list effects_store_effects(list)
list load_invariant_rw_effects_list(statement)
void set_rw_effects(statement_effects)
void reset_invariant_in_effects(void)
void effects_to_may_effects(list)
list effects_read_effects_dup(list)
void make_effects_private_current_context_stack(void)
void init_cumulated_in_effects(void)
transformer(* load_context_func)(statement)
void make_effects_private_current_stmt_stack(void)
utils.c
bool in_effects_engine(const char *, effects_representation_val)
void store_in_effects_list(statement, list)
list proper_to_summary_effects(list)
void init_invariant_in_effects(void)
list effects_read_effects(list)
void reset_cumulated_in_effects(void)
statement_effects(* db_get_invariant_rw_effects_func)(const char *)
list effects_write_effects_dup(list)
bool summary_in_effects_engine(const char *)
in_effects_engine.c
list load_proper_rw_effects_list(statement)
statement_effects get_cumulated_in_effects(void)
transformer transformer_remove_variable_and_dup(transformer, entity)
statement effects_private_current_stmt_pop(void)
list effects_entities_inf_difference(list, list, bool(*)(effect, effect))
void store_invariant_in_effects_list(statement, list)
statement_effects get_invariant_in_effects(void)
void reset_proper_rw_effects(void)
void free_effects_private_current_stmt_stack(void)
void set_proper_rw_effects(statement_effects)
list generic_effects_backward_translation(entity, list, list, transformer)
list load_in_effects_list(statement)
statement effects_private_current_stmt_head(void)
void effects_private_current_stmt_push(statement)
void set_in_effects(statement_effects)
void reset_in_effects(void)
list filter_effects_with_declaration(list, entity)
list load_rw_effects_list(statement)
list effects_entities_intersection(list, list, bool(*)(effect, effect))
bool get_constant_paths_p(void)
statement_effects get_in_effects(void)
void store_cumulated_in_effects_list(statement, list)
list effects_write_effects(list)
list generic_proper_effects_of_expression(expression)
void reset_invariant_rw_effects(void)
statement_effects(* db_get_in_effects_func)(const char *)
transformer effects_private_current_context_pop(void)
bool r_w_combinable_p(effect, effect)
void effects_private_current_context_push(transformer)
list effects_dup_without_variables(list, list)
list pointer_effects_to_constant_path_effects(list)
void set_invariant_rw_effects(statement_effects)
statement_effects(* db_get_proper_rw_effects_func)(const char *)
void reset_rw_effects(void)
void init_in_effects(void)
bool effects_same_action_p(effect, effect)
void update_invariant_in_effects_list(statement, list)
statement_effects(* db_get_rw_effects_func)(const char *)
entity effect_entity(effect)
cproto-generated files
#define descriptor_undefined
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....
void gen_full_free_list(list l)
#define CONTROL_MAP(ctl, code, c, list)
Macro to walk through all the controls reachable from a given control node of an unstructured.
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 gen_context_multi_recurse(void *o, void *context,...)
Multi-recursion with context function visitor.
bool gen_false(__attribute__((unused)) gen_chunk *unused)
Return false and ignore the argument.
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
bool gen_true(__attribute__((unused)) gen_chunk *unused)
Return true and ignore the argument.
bool loop_parallel_p(loop l)
Test if a loop is parallel.
#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.
#define NIL
The empty list (nil in Lisp)
size_t gen_length(const list l)
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 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.
bool declaration_statement_p(statement)
Had to be optimized according to Beatrice Creusillet.
static void reset_converted_rw_effects(list *lrw, live_paths_analysis_context *ctxt)
static list convert_rw_effects(list lrw, live_paths_analysis_context *ctxt)
#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
const char * entity_minimal_name(entity e)
Do preserve scope informations.
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
string string_of_type(const type)
void print_statement(statement)
Print a statement on stderr.
void set_bool_property(const char *, bool)
#define READ_FUNCTION_NAME
#define unstructured_control
After the modification in Newgen: unstructured = entry:control x exit:control we have create a macro ...
bool static_area_p(entity aire)
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 same_entity_p(entity e1, entity e2)
predicates on entities
bool c_module_p(entity m)
Test if a module "m" is written in C.
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
const char * module_local_name(entity e)
Returns the module local user name.
bool entity_module_p(entity e)
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.
bool reference_scalar_p(reference r)
This function returns true if Reference r is scalar.
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 entity_scalar_p(entity)
The concrete type of e is a scalar type.
type entity_basic_concrete_type(entity)
retrieves or computes and then returns the basic concrete type of an entity
void free_statement_global_stack(void)
void make_statement_global_stack(void)
#define forloop_domain
newgen_extensions_domain_defined
#define test_domain
newgen_entity_domain_defined
#define expression_domain
newgen_execution_domain_defined
#define transformer_undefined
#define REFERENCE(x)
REFERENCE.
#define unstructured_domain
newgen_type_domain_defined
#define reference_variable(x)
#define loop_domain
newgen_language_domain_defined
#define control_predecessors(x)
#define statement_ordering(x)
#define whileloop_evaluation(x)
#define entity_storage(x)
#define statement_domain
newgen_sizeofexpression_domain_defined
#define instruction_domain
newgen_functional_domain_defined
#define call_domain
newgen_callees_domain_defined
#define EXPRESSION(x)
EXPRESSION.
#define expression_undefined
#define sequence_statements(x)
#define control_successors(x)
#define expression_undefined_p(x)
#define whileloop_domain
newgen_variable_domain_defined
#define statement_declarations(x)
#define call_arguments(x)
#define control_statement(x)
#define value_expression_p(x)
#define sequence_domain
newgen_reference_domain_defined
#define evaluation_before_p(x)
#define type_variable_p(x)
#define value_expression(x)
#define instruction_expression_p(x)
#define STATEMENT(x)
STATEMENT.
#define entity_initial(x)
The structure used to build lists in NewGen.
#define exp
Avoid some warnings from "gcc -Wshadow".