27 #if defined(BUILDER_VARIABLE_EXPANSION) || \
28 defined(BUILDER_REDUCTION_VARIABLE_EXPANSION)
31 #include "pips_config.h"
74 list loop_replacement ;
75 list loop_dimensions ;
77 entity expanded_variable_replacment ;
78 list processed_variables ;
79 } scalar_expansion_context;
80 #define DEFAULT_SCALAR_EXPANSION_CONTEXT { NIL,NIL,NIL,entity_undefined,entity_undefined,NIL }
82 static bool perform_reference_expansion(
reference r,scalar_expansion_context *ctxt)
107 perform_reference_expansion_in_loop(
instruction i,scalar_expansion_context *ctxt)
141 bool prepare_expansion(
loop l, scalar_expansion_context* ctxt)
186 pips_debug(9,
"Going down, local variables: ");
194 static void perform_expansion_and_unstack_index_and_dimension(
loop l,scalar_expansion_context* ctxt)
199 if(!
ENDP(ctxt->loop_indices)) {
231 new_entities =
CONS(
ENTITY, new_entity, new_entities);
235 ctxt->expanded_variable = lv;
236 ctxt->expanded_variable_replacment = new_entity;
248 ctxt->processed_variables =
gen_append(ctxt->processed_variables, evl);
251 gen_remove(&ctxt->loop_indices, (
void *) eli);
252 gen_remove(&ctxt->loop_replacement, (
void *) elr);
253 gen_remove(&ctxt->loop_dimensions, (
void *) d);
263 static bool scalar_expansion(
const char*
module_name)
268 debug_on(
"SCALAR_EXPANSION_DEBUG_LEVEL");
286 scalar_expansion_context ctxt = DEFAULT_SCALAR_EXPANSION_CONTEXT;
294 pips_assert(
"Supporting lists are both empty",
ENDP(ctxt.loop_indices));
295 pips_assert(
"Supporting lists are both empty",
ENDP(ctxt.loop_dimensions));
330 static void do_expand_reference(
reference r, er *e)
392 list trailing_statements =
NIL;
395 list newly_declared_entities =
NIL;
412 newly_declared_entities =
CONS(
ENTITY, new_entity, newly_declared_entities);
432 hash_put(new_entities,reduction_entity,new_entity);
484 if(!
ENDP(trailing_statements)) {
instruction make_instruction_loop(loop _field_)
range copy_range(range p)
RANGE.
loop make_loop(entity a1, range a2, statement a3, entity a4, execution a5, list a6)
basic copy_basic(basic p)
BASIC.
expression copy_expression(expression p)
EXPRESSION.
reference make_reference(entity a1, list a2)
dimension make_dimension(expression a1, expression a2, list a3)
dimension copy_dimension(dimension p)
DIMENSION.
execution make_execution_sequential(void)
void free_expression(expression p)
void free_dimension(dimension p)
reference copy_reference(reference p)
REFERENCE.
forloop make_forloop(expression a1, expression a2, expression a3, statement a4)
range make_range(expression a1, expression a2, expression a3)
struct _newgen_struct_statement_ * statement
bool effects_write_at_least_once_p(list)
list proper_effects_of_expression(expression)
const char * module_name(const char *s)
Return the module part of an entity name.
#define gen_context_recurse(start, ctxt, domain_number, flt, rwt)
void gen_full_free_list(list l)
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.
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.
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)
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
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(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.
size_t gen_length(const list l)
void gen_list_and_not(list *a, const list b)
Compute A = A inter non B:
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
#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
list gen_last(list l)
Return the last element of a list.
bool gen_in_list_p(const void *vo, const list lx)
tell whether vo belongs to lx
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
list gen_append(list l1, const list l2)
list gen_full_copy_list(list l)
Copy a list structure with element copy.
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.
statement make_assign_statement(expression, expression)
void insert_statement(statement, statement, bool)
This is the normal entry point.
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.
bool expression_constant_p(expression)
HPFC module by Fabien COELHO.
#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 HASH_UNDEFINED_VALUE
value returned by hash_get() when the key is not found; could also be called HASH_KEY_NOT_FOUND,...
#define HASH_DEFAULT_SIZE
entity reduction_operator_entity(reduction_operator op)
match a reduction operator against operator entity
void print_reference(reference r)
const char * get_string_property_or_ask(const char *, const char[])
void reset_cumulated_reductions(void)
void set_cumulated_reductions(pstatement_reductions)
reductions load_cumulated_reductions(statement)
#define REDUCTION(x)
REDUCTION.
#define reduction_reference(x)
#define reductions_list(x)
bool module_reorder(statement body)
Reorder a module and recompute order to statement if any.
#define make_expression_list(stats...)
#define MINUS_OPERATOR_NAME
#define PLUS_UPDATE_OPERATOR_NAME
#define LESS_OR_EQUAL_OPERATOR_NAME
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 same_entity_p(entity e1, entity e2)
predicates on entities
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
entity entity_empty_label(void)
basic entity_basic(entity e)
return the basic associated to entity e if it's a function/variable/constant basic_undefined otherwis...
static int init
Maximal value set for Fortran 77.
void print_entities(list l)
entity operator_neutral_element(entity op)
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
expression range_to_expression(range r, enum range_to_expression_mode mode)
computes the distance between the lower bound and the upper bound of the range
expression reference_to_expression(reference r)
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.
expression int_to_expression(_int i)
transform an int into an expression and generate the corresponding entity if necessary; it is not cle...
expression make_op_exp(char *op_name, expression exp1, expression exp2)
================================================================
expression make_ref_expr(entity ent, list args)
reference expression_reference(expression e)
Short cut, meaningful only if expression_reference_p(e) holds.
basic basic_of_expression(expression)
basic basic_of_expression(expression exp): Makes a basic of the same basic as the expression "exp".
void AddLocalEntityToDeclarations(entity, entity, statement)
Add the variable entity e to the list of variables of the function module.
entity make_new_array_variable_with_prefix(const char *, entity, basic, list)
J'ai ameliore la fonction make_new_scalar_variable_with_prefix
entity make_new_scalar_variable(entity, basic)
entity find_label_entity(const char *, const char *)
util.c
basic basic_of_reference(reference)
Retrieves the basic of a reference in a newly allocated basic object.
#define value_undefined_p(x)
#define instruction_loop_p(x)
#define reference_variable(x)
#define loop_domain
newgen_language_domain_defined
#define instruction_loop(x)
#define dimension_lower(x)
#define statement_domain
newgen_sizeofexpression_domain_defined
#define range_increment(x)
#define instruction_domain
newgen_functional_domain_defined
#define EXPRESSION(x)
EXPRESSION.
#define entity_undefined_p(x)
#define reference_domain
newgen_range_domain_defined
#define expression_undefined
#define instruction_tag(x)
#define dimension_upper(x)
#define reference_indices(x)
#define instruction_forloop(x)
#define variable_dimensions(x)
#define code_decls_text(x)
#define statement_declarations(x)
#define value_expression_p(x)
#define statement_undefined
#define STATEMENT(x)
STATEMENT.
#define entity_initial(x)
The structure used to build lists in NewGen.