26 #if defined(BUILDER_PRIVATIZE_MODULE) || \
27 defined(BUILDER_PRIVATIZE_MODULE_EVEN_GLOBALS) || \
28 defined(BUILDER_LOCALIZE_DECLARATIONS)
31 #include "pips_config.h"
79 bool used_through_external_calls;
82 static bool loop_in(
loop l, privatizable_ctxt *ctxt)
85 ctxt->loop_index_p =
true;
86 return ctxt->loop_index_p;
89 static bool call_in(
call c, privatizable_ctxt *ctxt)
103 list func_eff = (*db_get_summary_rw_effects_func)(func_name);
106 if (!
ENDP(l_conflicts))
108 ctxt->used_through_external_calls =
true;
117 pips_debug(4,
"function called through pointer -> assume worst case\n");
118 ctxt->used_through_external_calls =
true;
121 return (!ctxt->used_through_external_calls);
125 static bool entity_privatizable_in_loop_statement_p(
156 if (result && even_globals
168 if (
ENDP(l_conflicts_out) &&
ENDP(l_conflicts_in))
170 privatizable_ctxt ctxt = {e,
false,
false};
175 result = !ctxt.used_through_external_calls;
191 privatizable_ctxt ctxt = {e,
false,
false};
194 result = ctxt.loop_index_p;
238 && entity_privatizable_in_loop_statement_p( e, s, even_globals)
257 scan_statement( b, new_loops, even_globals ) ;
272 scan_statement(b,
loops, even_globals ) ;
278 scan_statement(b,
loops, even_globals ) ;
323 pips_debug(1,
"Variable %s is removed from locals of statement %td\n",
328 pips_debug(1,
"ls is empty, end of recursion\n");
332 pips_assert(
"The first statements in prefix and in ls are the same statement",
371 pips_debug(1,
"Trying to privatize %s in loop statement %td (ordering %03zd) with local(s) ",
376 pips_debug(1,
"Trying to privatize %s in statement %td\n",
434 pips_assert(
"Both effects sc and sk are of the same kind",
449 pips_debug(5,
"Conflict for %s between statements %td and %td\n",
462 pips_debug(5,
"remove %s from locals in non common enclosing loops\n",
468 update_locals(
prefix, ls, e ) ;
469 update_locals(
prefix, succ_ls, e ) ;
482 static bool generic_privatize_module(
string mod_name,
bool even_globals)
515 pips_debug(1,
"\n begin for module %s\n\n", mod_name);
550 try_privatize( v, st,
f, e ) ;
581 return generic_privatize_module(mod_name,
false);
586 return generic_privatize_module(mod_name,
true);
595 static void do_gather_loop_indices(
loop l,
set s) {
599 static set gather_loop_indices(
void *v) {
608 #define MAX_DEPTH 100
611 int scope_numbers[MAX_DEPTH];
618 static localize_ctx make_localize_ctx() {
621 memset(ctx.scope_numbers, -1, MAX_DEPTH*
sizeof(ctx.scope_numbers[0]));
630 static bool localize_track_scope_in(
statement s, localize_ctx *ctx) {
632 pips_assert(
"depth is in acceptable range\n", ctx->depth<MAX_DEPTH);
634 ctx->scope_numbers[ctx->depth]++;
642 static void localize_track_scope_out(
statement s, localize_ctx *ctx) {
652 static entity make_localized_entity(
entity e, localize_ctx *ctx) {
654 string build_localized_name =
strdup(
"");
655 for(
int i=1;i<=ctx->depth;i++) {
658 free(build_localized_name);
659 build_localized_name = new_name;
661 string localized_name;
663 free(build_localized_name);
665 string unique_name =
strdup(localized_name);
672 free(localized_name);
709 static void localize_declaration_walker(
statement s, localize_ctx *ctx) {
743 set li = gather_loop_indices(s);
744 bool skip_loop_indices =
get_bool_property(
"LOCALIZE_DECLARATION_SKIP_LOOP_INDICES");
747 localize_track_scope_in(s,ctx);
748 pips_debug(1,
"Handling a loop with scope (%d,%d)",ctx->depth,ctx->scope_numbers[ctx->depth]);
756 entity new_entity = make_localized_entity(e,ctx);
762 list previous_replacements =
hash_get(ctx->old_entity_to_new,e);
766 hash_put(ctx->old_entity_to_new,e,previous_replacements);
774 localize_track_scope_out(s,ctx);
781 localize_track_scope_out(s, ctx);
796 debug_on(
"LOCALIZE_DECLARATION_DEBUG_LEVEL");
797 pips_debug(1,
"begin localize_declaration ...\n");
806 pips_debug(1,
"The statement before we create block statement:\n");
814 localize_ctx ctx = make_localize_ctx();
820 pips_debug(1,
"The statement before we convert loop_locals "
821 "to local declarations:\n");
829 pips_debug(1,
"The statement after conversion:\n");
840 debug_on(
"CLEAN_DECLARATIONS_DEBUG_LEVEL");
value make_value_unknown(void)
type copy_type(type p)
TYPE.
storage make_storage(enum storage_utype tag, void *val)
ram make_ram(entity a1, entity a2, intptr_t a3, list a4)
dg_vertex_label vertex_label
bool clean_up_sequences(statement s)
Recursively clean up the statement sequences by fusing them if possible and by removing useless one.
#define dg_vertex_label_statement(x)
struct _newgen_struct_dg_arc_label_ * dg_arc_label
#define CONFLICT(x)
CONFLICT.
#define dg_arc_label_conflicts(x)
#define conflict_source(x)
struct _newgen_struct_dg_vertex_label_ * dg_vertex_label
void set_live_in_paths(statement_effects)
void reset_live_out_paths(void)
list load_live_out_paths_list(statement)
statement_effects(* db_get_live_in_paths_func)(const char *)
list load_live_in_paths_list(statement)
statement_effects(* db_get_live_out_paths_func)(const char *)
list load_proper_rw_effects_list(statement)
void set_live_out_paths(statement_effects)
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_live_in_paths(void)
void set_pointer_info_kind(pointer_info_val)
methods.c
void reset_cumulated_rw_effects(void)
void set_constant_paths_p(bool)
void set_methods_for_simple_effects(void)
bool is_implied_do_index(entity, instruction)
void set_methods_for_live_paths(const char *)
entity effect_entity(effect)
cproto-generated files
bool store_effect_p(effect)
bool anywhere_effect_p(effect)
Is it an anywhere effect? ANYMMODULE:ANYWHERE
#define action_write_p(x)
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....
#define gen_context_recurse(start, ctxt, domain_number, flt, rwt)
#define successor_vertex(x)
#define successor_arc_label(x)
struct _newgen_struct_graph_ * graph
#define vertex_vertex_label(x)
#define vertex_successors(x)
#define SUCCESSOR(x)
SUCCESSOR.
#define graph_vertices(x)
bool entities_may_conflict_p(entity e1, entity e2)
Check if two entities may conflict.
list effects_entities_which_may_conflict_with_scalar_entity(list fx, entity e)
statement instruction_to_statement(instruction)
Build a statement from a give instruction.
#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.
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.
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_entity(void *s, entity old, entity new)
per variable version of replace_entities.
void gen_context_multi_recurse(void *o, void *context,...)
Multi-recursion with context function visitor.
void gen_null2(__attribute__((unused)) void *u1, __attribute__((unused)) void *u2)
idem with 2 args, to please overpeaky compiler checks
bool gen_true2(__attribute__((unused)) gen_chunk *u1, __attribute__((unused)) void *u2)
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
instruction make_instruction_block(list statements)
Build an instruction block from a list of statements.
void clean_enclosing_loops(void)
void sort_all_loop_locals(statement s)
#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)
list gen_copy_seq(list l)
Copy a list structure.
list gen_common_prefix(const list l1, const list l2)
return the common list prefix of lists l1 and l2.
#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)
#define MAPL(_map_list_cp, _code, _l)
Apply some code on the addresses of all the elements of a list.
#define list_undefined
Undefined list definition :-)
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.
#define DB_PUT_FILE_RESOURCE
Put a file resource into the current workspace database.
loop statement_loop(statement)
Get the loop of a statement.
bool statement_loop_p(statement)
list statement_to_declarations(void *)
Get a list of all variables declared recursively within a statement.
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_put(hash_table htp, const void *key, const void *val)
This functions stores a couple (key,val) in the hash table pointed to by htp.
void hash_table_free(hash_table htp)
this function deletes a hash table that is no longer useful.
void * hash_del(hash_table htp, const void *key)
this function removes from the hash table pointed to by htp the couple whose key is equal to key.
static statement mod_stat
We want to keep track of the current statement inside the recurse.
void set_prettyprint_language_from_property(enum language_utype native)
set the prettyprint language according to the property PRETTYPRINT_LANGUAGE @description If the prope...
void * memset(void *str, int c, size_t len)
memset.c – set an area of memory to a given value Copyright (C) 1991, 2003, 2009-2011 Free Software F...
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
#define pips_internal_error
#define DYNAMIC_AREA_LOCAL_NAME
#define BLOCK_SEP_STRING
Scope separator.
#define MAKE_STATEMENT_MAPPING()
string bool_to_string(bool)
#define HASH_UNDEFINED_VALUE
value returned by hash_get() when the key is not found; could also be called HASH_KEY_NOT_FOUND,...
#define hash_table_undefined
Value of an undefined hash_table.
#define HASH_DEFAULT_SIZE
bool set_belong_p(const set, const void *)
set set_make(set_type)
Create an empty set of any type but hash_private.
set set_add_element(set, const set, const void *)
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
hash_table set_ordering_to_statement(statement s)
To be used instead of initialize_ordering_to_statement() to make sure that the hash table ots is in s...
statement ordering_to_statement(int o)
Get the statement associated to a given ordering.
void reset_ordering_to_statement(void)
Reset the mapping from ordering to statement.
void print_statement(statement)
Print a statement on stderr.
static const char * prefix
bool module_reorder(statement body)
Reorder a module and recompute order to statement if any.
#define statement_block_p(stat)
#define unstructured_control
After the modification in Newgen: unstructured = entry:control x exit:control we have create a macro ...
#define is_instruction_block
soft block->sequence transition
#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 static_area_p(entity aire)
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 entity_in_list_p(entity ent, list ent_l)
look for ent in ent_l
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.
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
string storage_to_string(storage s)
const char * module_local_name(entity e)
Returns the module local user name.
void print_entities(list l)
bool top_level_entity_p(entity e)
Check if the scope of entity e is global.
bool parameter_passing_by_value_p(entity f)
list load_statement_enclosing_loops(statement)
void AddLocalEntityToDeclarations(entity, entity, statement)
Add the variable entity e to the list of variables of the function module.
bool entity_scalar_p(entity)
The concrete type of e is a scalar type.
int add_C_variable_to_area(entity, entity)
void store_statement_enclosing_loops(statement, list)
statement_mapping get_enclosing_loops_map(void)
int add_variable_to_area(entity, entity)
void set_enclosing_loops_map(statement_mapping)
#define type_functional_p(x)
#define storage_formal_p(x)
#define instruction_loop_p(x)
#define loop_domain
newgen_language_domain_defined
#define instruction_loop(x)
#define statement_ordering(x)
#define entity_storage(x)
#define statement_domain
newgen_sizeofexpression_domain_defined
#define call_domain
newgen_callees_domain_defined
#define statement_label(x)
#define entity_undefined_p(x)
@ is_instruction_unstructured
@ is_instruction_whileloop
@ is_instruction_expression
#define instruction_tag(x)
#define statement_extensions(x)
#define instruction_forloop(x)
#define instruction_whileloop(x)
#define whileloop_body(x)
#define statement_declarations(x)
#define statement_instruction(x)
#define statement_comments(x)
#define control_statement(x)
#define instruction_test(x)
#define statement_number(x)
#define type_variable_p(x)
#define instruction_unstructured(x)
#define variable_basic(x)
#define STATEMENT(x)
STATEMENT.
#define entity_initial(x)
FI: I do not understand why the type is duplicated at the set level.
The structure used to build lists in NewGen.
static int depth
la sequence de nids