25 #include "pips_config.h"
57 #include "constants.h"
73 #include "resources.h"
82 #define PHI_FIRST true
83 #define NOT_PHI_FIRST false
88 #define min(a,b) (((a)<(b))?(a):(b))
89 #define max(a,b) (((a)>(b))?(a):(b))
240 pips_debug(4,
"translation regions for %s\n", func_name);
277 pips_debug(4,
"translation regions for %s\n", func_name);
417 list real_args, func_regions;
420 list real_regions =
NIL, r_args;
425 for (r_args = real_args, arg_num = 1; r_args !=
NIL;
426 r_args =
CDR(r_args), arg_num++)
456 if (!
ENDP(real_inds))
483 return(real_regions);
505 return(real_regions);
534 pips_debug(8,
"begin for real arg %s, of type %s and effects :\n",
537 (*effects_prettyprint_func)(l_sum_eff);
561 pips_debug(8,
"pointer type real arg reference\n");
566 pips_debug(8,
"effect on the pointed area : \n");
571 real_eff = (*reference_to_effect_func)
583 bool exact_translation_p;
588 effect init_eff = (*effect_dup_func)(eff);
600 &n_eff_ref, &n_eff_d,
601 &exact_translation_p);
614 pips_debug(8,
"real arg reference is not a pointer and is not a partially indexed array -> NIL \n");
621 pips_debug(8,
"Subscript not supported yet -> anywhere");
622 bool read_p =
false, write_p =
false;
659 (arg1, &l_eff_real,
true);
683 effect eff_init = (*effect_dup_func)(eff);
698 &output_ref, &output_desc,
729 pips_debug(6,
"dereferencing operator case \n");
745 (real_arg, &l_real_eff,
true);
761 bool exact_translation_p;
766 effect init_eff = (*effect_dup_func)(eff);
778 &n_eff_ref, &n_eff_d,
779 &exact_translation_p);
795 pips_debug(8,
"real arg reference is not a pointer and is not a partially indexed array -> NIL \n");
805 pips_debug(6,
"point_to or field operator\n");
807 (real_arg, &l_eff_real,
true);
816 effect eff_formal = (*effect_dup_func)(eff);
827 new_eff = (*effect_dup_func)(eff_real);
886 (l_sum_eff, cast_exp,
context));
888 else if (!
ENDP(l_sum_eff))
893 bool read_p =
false, write_p =
false;
899 tag t = write_p ? (read_p ?
'x' :
'w') :
'r';
919 bool read_p =
false, write_p =
false;
948 (*effects_precondition_composition_op)(l_eff,
context,
false);
982 list real_args, l_reg;
986 list l_form_reg, l_common_reg;
998 (func, real_args, l_reg,
context);
1047 list real_args, l_reg;
1053 list r_args = real_args;
1065 for (arg_num = 1; !
ENDP(r_args); r_args =
CDR(r_args), arg_num++)
1086 reg, caller, real_ref,
1105 pips_debug(8,
"real argument is a complex expression \n"
1106 "\tit can not correspond to a written formal parameter.\n");
1108 if (!
ENDP(l_real_exp))
1160 return(func_regions);
1188 pips_user_warning(
"Nested function calls are ignored. Consider splitting the code before running PIPS\n");
1211 bool general_case =
true;
1224 (arg1, &l_eff_real,
true);
1256 pips_debug(5,
"array element or sub-array case\n");
1257 general_case =
false;
1260 sc_nb_phi_real =
sc_new();
1285 (arg1, &l_eff_real,
true);
1298 (void)
sc_free(sc_nb_phi_real);
1319 effect eff_formal = (*effect_dup_func)(eff_orig);
1324 pips_debug(5,
"the original effect does not correspond to the actual argument \n");
1337 int i, min_phi, min_i;
1339 pips_debug_effect(5,
"matching access paths, considered effect is : \n", eff_formal);
1351 for(i = 1; i <= nb_phi_real; i++)
1372 "adding phi_nb_phi_real == psi_nb_phi_real - exp_nb_phi_real \n");
1383 pips_debug_effect(5,
"eff_formal before removing psi variables: \n", eff_formal);
1385 pips_debug_effect(5,
"eff_formal after renaming common dimensions: \n", eff_formal);
1393 min_phi = general_case? 2:1;
1394 min_i = general_case ? nb_phi_real+1 : nb_phi_real;
1397 pips_debug(8,
"nb_phi_real: %d, min_i: %d, min_phi: %d\n", nb_phi_real, min_i, min_phi);
1398 for(i = min_i; i <= nb_phi_orig; i++)
1400 pips_debug(8,
"renaming %d-th index into %d-th\n", i, i-min_i+min_phi);
1408 pips_assert(
"index expression of an effect must be a reference",
1431 for(i=min_phi; i<= nb_phi_orig-min_i+min_phi; i++)
1469 pips_debug(5,
"Other intrinsic case : entering general case \n");
1496 (real_exp, &l_eff_real,
true);
1498 if (!
ENDP(l_eff_real))
1518 && nb_phi_orig >= nb_phi_real)
1520 effect eff_orig_dup = (*effect_dup_func)(eff_orig);
1525 pips_debug(5,
"the original effect does not correspond to the actual argument \n");
1536 pips_debug_effect(5,
"matching access paths, considered effect is : \n", eff_orig_dup);
1542 bool exact_translation_p;
1548 &n_eff_ref, &n_eff_d,
1549 &exact_translation_p);
1664 entity entity_target_func = target_func;
1666 list l_tmp, l_com_ent;
1667 int reg_ent_size, total_size, reg_ent_begin_offset, reg_ent_end_offset;
1690 return(new_regions);
1697 pips_debug(5,
"target function: %s (local name: %s)\n",
1713 for( l_tmp = l_com_ent; !
ENDP(l_tmp) && !found; l_tmp =
CDR(l_tmp) )
1730 entity_target_func =
1734 pips_debug(6,
"common not declared in caller,\n"
1735 "\t using %s declarations instead\n",
1743 reg_ent_end_offset = reg_ent_begin_offset + reg_ent_size - 1;
1746 "\n\treg_ent: size = %d, offset_begin = %d, offset_end = %d\n",
1747 reg_ent_size, reg_ent_begin_offset, reg_ent_end_offset);
1754 for(; !
ENDP(l_com_ent) && (total_size < reg_ent_size);
1755 l_com_ent =
CDR(l_com_ent))
1765 int new_ent_begin_offset =
1767 int new_ent_end_offset = new_ent_begin_offset + new_ent_size - 1;
1770 "offset_begin = %d, offset_end = %d \n",
1771 new_ent_size, new_ent_begin_offset, new_ent_end_offset);
1773 if ((new_ent_begin_offset <= reg_ent_end_offset) &&
1774 (reg_ent_begin_offset <= new_ent_end_offset ))
1777 int offset = reg_ent_begin_offset - new_ent_begin_offset;
1786 total_size +=
min (reg_ent_begin_offset,new_ent_end_offset)
1787 -
max(reg_ent_begin_offset, new_ent_begin_offset) + 1;
1797 return(new_regions);
cell make_cell_reference(reference _field_)
action copy_action(action p)
ACTION.
void free_effect(effect p)
void free_action(action p)
approximation copy_approximation(approximation p)
APPROXIMATION.
approximation make_approximation_may(void)
effect make_effect(cell a1, action a2, approximation a3, descriptor a4)
void free_reference(reference p)
expression copy_expression(expression p)
EXPRESSION.
reference make_reference(entity a1, list a2)
void free_expression(expression p)
reference copy_reference(reference p)
REFERENCE.
static const char * caller_name
bool entity_all_locations_p(entity e)
test if an entity is the top of the lattice
void const char const char const int
struct _newgen_struct_statement_ * statement
Pcontrainte contrainte_make(Pvecteur pv)
Pcontrainte contrainte_make(Pvecteur pv): allocation et initialisation d'une contrainte avec un vecte...
#define region_entity(reg)
#define region_system(reg)
#define region
simulation of the type region
list RegionsMustUnion(list l1, list l2, bool(*union_combinable_p)(effect, effect))
list RegionsMustUnion(list l1, list l2, union_combinable_p) input : two lists of regions output : a l...
list RegionsMayUnion(list l1, list l2, bool(*union_combinable_p)(effect, effect))
list RegionsMayUnion(list l1, list l2, union_combinable_p) input : two lists of regions output : a li...
list RegionsIntersection(list l1, list l2, bool(*intersection_combinable_p)(effect, effect))
list RegionsIntersection(list l1,l2, bool (*intersection_combinable_p)(effect, effect)) input : outpu...
void reset_out_summary_regions_list()
static list common_region_translation(entity func, region reg, bool backward)
static list common_region_translation(entity func, region reg, bool backward) input : func is the cal...
void out_regions_from_call_site_to_callee(call c)
void out_regions_from_call_site_to_callee(call c) input : a potential call site for current_callee.
list regions_of_external(entity func, list real_args, transformer context, bool proper)
list regions_of_external(entity func, list real_args, transformer context) input : an external functi...
list c_convex_effects_on_formal_parameter_backward_translation(list l_sum_eff, expression real_arg, transformer context)
static statement current_stmt
void update_out_summary_regions_list(list l_out)
list regions_forward_translation(entity func, list real_args, list l_reg, transformer context)
list regions_forward_translation(entity func, list real_args, l_reg, transformer context input : the ...
void convex_regions_translation_end()
static list l_sum_out_reg
static bool stmt_filter(statement s)
list regions_backward_translation(entity func, list real_args, list func_regions, transformer context, bool proper)
list regions_backward_tranlation(entity func, list real_args, list func_regions, transformer context)...
static list common_regions_backward_translation(entity func, list func_regions)
list get_out_summary_regions_list()
static list formal_regions_backward_translation(entity func, list real_args, list func_regions, transformer context)
static list formal_regions_backward_translation(entity func, list real_args, func_regions,...
list convex_regions_forward_translation(entity callee, list real_args, list l_reg, transformer context)
of effects
static entity current_callee
list out_regions_from_caller_to_callee(entity caller, entity callee)
list in_regions_of_external(entity func, list real_args, transformer context)
list in_regions_of_external(entity func, list real_args, transformer context) input : an external fun...
list convex_regions_backward_translation(entity func, list real_args, list l_reg, transformer context)
of effects
list c_convex_effects_on_actual_parameter_forward_translation(entity callee, expression real_exp, entity formal_ent, list l_reg, transformer context)
#define IS_EG
package regions : Alexis Platonoff, 22 Aout 1990, Be'atrice Creusillet 10/94
static list real_regions_forward_translation(entity func, list real_args, list l_reg, transformer context)
static list real_regions_forward_translation(entity func, list real_args, l_reg, transformer context)...
static list common_regions_forward_translation(entity func, list real_regions)
static list common_regions_forward_translation (entity func, list real_regions) input : the called fu...
void convex_regions_translation_init(entity callee, list real_args, bool backward_p)
jmp_buf overflow_error;
void convex_region_descriptor_translation(effect)
entity make_phi_entity(int)
void set_backward_arguments_to_eliminate(entity)
effect make_reference_region(reference, action)
void convex_cell_reference_with_address_of_cell_reference_translation(reference, descriptor, reference, descriptor, int, reference *, descriptor *, bool *)
list regions_of_expression(expression, transformer)
void region_sc_append_and_normalize(effect, Psysteme, int)
void convex_cell_reference_with_value_of_cell_reference_translation(reference, descriptor, reference, descriptor, int, reference *, descriptor *, bool *)
void set_forward_arguments_to_eliminate(void)
effect region_append(effect, effect)
void set_interprocedural_translation_context_sc(entity, list)
void reset_arguments_to_eliminate(void)
bool sc_add_phi_equation(Psysteme *, expression, int, bool, bool)
effect reference_whole_region(reference, action)
list proper_regions_of_expressions(list, transformer)
expression make_phi_expression(int)
list regions_add_context(list, transformer)
void region_exact_projection_along_variable(effect, entity)
string region_to_string(effect)
void set_methods_for_convex_in_out_effects(void)
void init_convex_inout_prettyprint(const char *)
void region_remove_psi_variables(effect)
reference make_regions_reference(entity)
effect region_translation(effect, entity, reference, entity, entity, reference, Value, bool)
bool in_out_methods_p(void)
void set_methods_for_convex_rw_effects(void)
entity make_psi_entity(int)
list regions_add_region(list, effect)
void reset_translation_context_sc(void)
#define pips_debug_effects(level, message, l_eff)
#define pips_debug_effect(level, message, eff)
for debug
list generic_proper_effects_of_complex_address_expression(expression, list *, int)
effect make_anywhere_effect(action)
list generic_c_effects_forward_translation(entity, list, list, transformer)
void reset_out_effects(void)
void reset_proper_rw_effects(void)
void set_proper_rw_effects(statement_effects)
void set_cumulated_rw_effects(statement_effects)
void set_out_effects(statement_effects)
void effect_to_may_effect(effect)
type simple_effect_reference_type(reference)
list generic_proper_effects_of_expression(expression)
list load_statement_out_regions(statement)
list c_actual_argument_to_may_summary_effects(expression, tag)
void reset_cumulated_rw_effects(void)
bool effects_same_action_p(effect, effect)
bool path_preceding_p(effect, effect, transformer, bool, bool *)
void set_methods_for_proper_simple_effects(void)
#define effect_any_reference(e)
FI: cannot be used as a left hand side.
#define effect_approximation_tag(eff)
#define effect_write_p(eff)
#define effect_action_tag(eff)
bool basic_concrete_types_compatible_for_effects_interprocedural_translation_p(type, type)
tests if the actual argument type and the formal argument type are compatible with the current state ...
action make_action_write_memory(void)
To ease the extension of action with action_kind.
bool store_effect_p(effect)
list effects_to_list(effects)
bool anywhere_effect_p(effect)
Is it an anywhere effect? ANYMMODULE:ANYWHERE
action make_action_read_memory(void)
bool types_compatible_for_effects_interprocedural_translation_p(type, type)
tests if the actual argument type and the formal argument type are compatible with the current state ...
#define cell_reference(x)
#define effect_undefined_p(x)
#define effect_descriptor(x)
#define effect_approximation(x)
void gen_full_free_list(list l)
static int array_size(dim)
ARRAY_SIZE returns the number of elements in the array whose dimension list is DIM.
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.
entity set_current_module_entity(entity)
static.c
entity get_current_module_entity(void)
Get the entity of the current module.
void gen_multi_recurse(void *o,...)
Multi recursion visitor function.
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
#define ENDP(l)
Test if a list is empty.
#define list_undefined_p(c)
Return if a list is undefined.
#define POP(l)
Modify a list pointer to point on the next element of the list.
#define NIL
The empty list (nil in Lisp)
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
#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.
gen_chunk gen_nth(int n, const list l)
to be used as ENTITY(gen_nth(3, l))...
#define list_undefined
Undefined list definition :-)
#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 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
string expression_to_string(expression e)
#define ENTITY_ASSIGN_P(e)
#define ENTITY_DEREFERENCING_P(e)
#define NORMALIZE_EXPRESSION(e)
#define ENTITY_POINT_TO_P(e)
#define ENTITY_FIELD_P(e)
C data structure and pointer management.
#define ENTITY_MALLOC_SYSTEM_P(e)
#define ENTITY_ADDRESS_OF_P(e)
bool dynamic_area_p(entity aire)
bool stack_area_p(entity aire)
bool heap_area_p(entity aire)
bool rand_effects_entity_p(entity e)
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.
bool entity_field_p(entity e)
e is the field of a structure
const char * module_local_name(entity e)
Returns the module local user name.
bool io_entity_p(entity e)
Several implicit entities are declared to define the implicit effects of IO statements.
bool fortran_module_p(entity m)
Test if a module is in Fortran.
bool entity_module_p(entity e)
bool top_level_entity_p(entity e)
Check if the scope of entity e is global.
entity find_ith_formal_parameter(entity the_fnct, int rank)
This function gives back the ith formal parameter, which is found in the declarations of a call or a ...
const char * entity_module_name(entity e)
See comments about module_name().
expression entity_to_expression(entity e)
if v is a constant, returns a constant call.
expression int_to_expression(_int i)
transform an int into an expression and generate the corresponding entity if necessary; it is not cle...
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.
type expression_to_type(expression)
For an array declared as int a[10][20], the type returned for a[i] is int [20].
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.
size_t type_depth(type)
Number of steps to access the lowest leave of type t without dereferencing.
bool ith_parameter_p(entity, entity, int)
returns true if v is the ith formal parameter of function f
string type_to_string(const type)
type.c
#define type_functional_p(x)
#define syntax_reference_p(x)
#define transformer_undefined
#define transformer_undefined_p(x)
#define syntax_reference(x)
#define reference_undefined
#define normalized_linear_p(x)
#define reference_variable(x)
#define entity_storage(x)
#define statement_domain
newgen_sizeofexpression_domain_defined
@ is_syntax_sizeofexpression
#define call_domain
newgen_callees_domain_defined
#define EXPRESSION(x)
EXPRESSION.
#define cast_expression(x)
#define type_undefined_p(x)
#define expression_undefined
#define reference_indices(x)
#define expression_undefined_p(x)
#define variable_dimensions(x)
#define call_arguments(x)
#define statement_number(x)
#define normalized_linear(x)
#define expression_syntax(x)
#define type_variable_p(x)
#define statement_undefined
#define entity_initial(x)
Psysteme sc_variable_rename(Psysteme s, Variable v_old, Variable v_new)
Psysteme sc_variable_rename(Psysteme s, Variable v_old, Variable v_new): reecriture du systeme s remp...
Psysteme sc_new(void)
Psysteme sc_new(): alloue un systeme vide, initialise tous les champs avec des valeurs nulles,...
bool sc_empty_p(Psysteme sc)
bool sc_empty_p(Psysteme sc): check if the set associated to sc is the constant sc_empty or not.
Psysteme sc_constraint_add(Psysteme sc, Pcontrainte c, bool equality)
Psysteme sc_free(Psysteme in_ps)
Psysteme sc_free( in_ps ) AL 30/05/94 Free of in_ps.
void module_to_value_mappings(entity m)
void module_to_value_mappings(entity m): build hash tables between variables and values (old,...
transformer load_statement_precondition(statement)
void reset_precondition_map(void)
void set_precondition_map(statement_mapping)
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
The structure used to build lists in NewGen.
void * Variable
arithmetique is a requirement for vecteur, but I do not want to inforce it in all pips files....
Pbase vect_copy(Pvecteur b)
direct duplication.
Pvecteur vect_new(Variable var, Value coeff)
Pvecteur vect_new(Variable var,Value coeff): allocation d'un vecteur colineaire au vecteur de base va...
void vect_rm(Pvecteur v)
void vect_rm(Pvecteur v): desallocation des couples de v;
Pvecteur vect_add(Pvecteur v1, Pvecteur v2)
package vecteur - operations binaires
Pvecteur vect_substract(Pvecteur v1, Pvecteur v2)
Pvecteur vect_substract(Pvecteur v1, Pvecteur v2): allocation d'un vecteur v dont la valeur est la di...