29 #include "pips_config.h"
192 bool linearized =
false;
221 bool free_it =
false;
323 if(!
param->use_pointers_p) {
345 if(!
param->use_pointers_p) {
352 else if(!
param->use_pointers_p && !
type_equal_p(type_at_call_site,type_in_func_prototype)) {
393 for(
list citer=callers,siter=callers_statement;!
ENDP(citer);
POP(citer),
POP(siter))
651 if(
param->use_pointers_p) {
664 if (
param->modify_call_site_p) {
875 }
else if(prev ==
NIL) {
933 debug_on(
"LINEARIZE_ARRAY_DEBUG_LEVEL");
937 param_t param = { .use_pointers_p =
false , .modify_call_site_p =
false, .cast_at_call_site_p =
false };
954 if(
param.use_pointers_p) {
964 else pips_user_warning(
"no pointers in fortran !,LINEARIZE_ARRAY_USE_POINTERS ignored\n");
cast make_cast(type a1, expression a2)
call make_call(entity a1, list a2)
bool parameter_consistent_p(parameter p)
value make_value_expression(expression _field_)
syntax make_syntax_call(call _field_)
expression make_expression(syntax a1, normalized a2)
type make_type_variable(variable _field_)
syntax make_syntax_sizeofexpression(sizeofexpression _field_)
type copy_type(type p)
TYPE.
basic make_basic_pointer(type _field_)
variable copy_variable(variable p)
VARIABLE.
expression copy_expression(expression p)
EXPRESSION.
reference make_reference(entity a1, list a2)
bool statement_consistent_p(statement p)
dimension make_dimension(expression a1, expression a2, list a3)
sizeofexpression make_sizeofexpression_type(type _field_)
variable make_variable(basic a1, list a2, list a3)
syntax copy_syntax(syntax p)
SYNTAX.
syntax make_syntax_cast(cast _field_)
void free_variable(variable p)
bool db_touch_resource(const char *rname, const char *oname)
touch logical time for resource[owner], possibly behind the back of pipsdbm.
static void do_array_to_pointer_type_aux(type *t)
static void do_linearize_patch_expressions(void *obj, hash_table ht)
static void do_linearize_array_reference(reference r)
bool do_convert_this_array_to_pointer_p(entity e)
array_to_pointer.c
static void do_linearize_array(entity m, statement s, param_t *param)
static void do_linearize_prepatch_subscript(subscript s)
subscripts of the form (*a)[n] are transformed into a[n] it is coherent with other transformations sc...
static void insert_statements_after_declarations(statement st, list stats)
initialization statements are added right after declarations
static bool do_linearize_type(type *t, bool *rr)
static void do_linearize_remove_dereferencment_walker(expression exp, entity e)
size_t type_dereferencement_depth(type t)
static list initialization_list_to_statements(entity e)
create a list of statements from entity declarations
static void do_array_to_pointer_patch_call_expr_rwt(expression e)
static void do_linearize_array_cast(cast c)
bool linearize_array_fortran(const char *module_name)
bool linearize_array(const char *module_name)
linearize accesses to an array, and use pointers if asked to
static void do_array_to_pointer(entity m, statement s, _UNUSED_ param_t *p)
transform each array type in module m with statement s
static void do_array_to_pointer_walker(void *obj)
converts arrays to pointer
static hash_table init_expression_is_pointer(void *obj)
static void do_array_to_pointer_walk_expression(expression exp)
static void do_linearize_pointer_is_expression(expression exp, hash_table ht)
static bool do_array_to_pointer_patch_call_expression(expression exp)
fix some strange constructs introduced by previous processing
static bool type_void_or_void_pointer_p(type t)
static void do_array_to_pointer_walk_cast(cast ct)
static void do_array_to_pointer_walk_call_and_patch(call c)
special ad-hoc handler for pointer to arrays
static void do_linearize_array_subscript(_UNUSED_ subscript s)
static void do_linearize_array_walker(void *obj)
static void do_linearize_array_init(value v)
static void do_linearize_expression_is_pointer(expression exp, hash_table ht)
static void do_linearize_prepatch_type(type t)
static void do_linearize_remove_dereferencment(statement s, entity e)
static bool do_array_to_pointer_type(type *t)
returns true if a dereferencment has been supressed
static void do_linearize_array_manage_callers(entity m, set linearized_param, param_t *param)
static void do_linearize_prepatch(entity m, _UNUSED_ statement s)
static void do_linearize_prepatch_subscripts(entity m, statement s)
transform some subscripts for generic handling later
bool linearize_array_generic(const char *module_name)
linearize accesses to an array, and use pointers if asked to
list callers_to_call_sites(list callers_statement, entity called_module)
given a list callers_statement of module statements returns a list of calls to module called_module
list callers_to_statements(list callers)
given a list callers of module name calling module called module return a list of their body
string compilation_unit_of_module(const char *)
The output is undefined if the module is referenced but not defined in the workspace,...
int dummy
A dummy file, to prevent empty libraries from breaking builds.
const char * module_name(const char *s)
Return the module part of an entity name.
void cleanup_subscripts(void *)
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 gen_recurse(start, 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.
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_multi_recurse(void *o,...)
Multi recursion visitor function.
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)
bool gen_true(__attribute__((unused)) gen_chunk *unused)
Return true and ignore the argument.
#define ENDP(l)
Test if a list is empty.
list gen_nreverse(list cp)
reverse a list in place
#define POP(l)
Modify a list pointer to point on the next element of the list.
#define REFCAR(pc)
Get the adress of the first element of a 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)
#define CAR(pcons)
Get the value of the first element of a 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.
list gen_append(list l1, const list l2)
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.
list statement_block(statement)
Get the list of block statements of a statement sequence.
statement make_assign_statement(expression, expression)
void insert_statement(statement, statement, bool)
This is the normal entry point.
bool declaration_statement_p(statement)
Had to be optimized according to Beatrice Creusillet.
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.
#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 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
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 *)
void print_type(type)
For debugging.
bool module_reorder(statement body)
Reorder a module and recompute order to statement if any.
#define ALLOCA_FUNCTION_NAME
#define MINUS_OPERATOR_NAME
#define ENTITY_DEREFERENCING_P(e)
#define PLUS_OPERATOR_NAME
#define DEREFERENCING_OPERATOR_NAME
#define ENTITY_BRACE_INTRINSIC_P(e)
C initialization expression.
#define entity_declarations(e)
MISC: newgen shorthands.
#define ENTITY_PLUS_C_P(e)
#define ADDRESS_OF_OPERATOR_NAME
#define entity_variable_p(e)
An entity_variable_p(e) may hide a typedef and hence a functional type.
#define ENTITY_ADDRESS_OF_P(e)
#define module_functional_parameters(func)
#define MULTIPLY_OPERATOR_NAME
#define PLUS_C_OPERATOR_NAME
bool entity_formal_p(entity p)
is p a formal parameter?
bool entity_array_p(entity e)
Is e a variable with an array type?
bool same_entity_p(entity e1, entity e2)
predicates on entities
bool local_entity_of_module_p(entity e, entity module)
This test shows that "e" has been declared in "module".
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 fortran_module_p(entity m)
Test if a module is in Fortran.
bool entity_variable_length_array_p(entity e)
bool entity_pointer_p(entity e)
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
expression add_integer_to_expression(expression exp, int val)
expression reference_to_expression(reference r)
bool expression_call_p(expression e)
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.
bool expression_brace_p(expression e)
predicates and short cut accessors on expressions
call expression_call(expression e)
void update_expression_syntax(expression e, syntax s)
frees expression syntax of e and replace it by the new syntax s
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 MakeUnaryCall(entity f, expression a)
Creates a call expression to a function with one argument.
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.
expression syntax_to_expression(syntax s)
generates an expression from a syntax
bool compilation_unit_entity_p(entity e)
Check if the given module entity is a compilation unit.
basic basic_of_expression(expression)
basic basic_of_expression(expression exp): Makes a basic of the same basic as the expression "exp".
bool fixed_length_array_type_p(type)
expression SizeOfDimensions(list)
computes the product of all dimensions in dims
type expression_to_type(expression)
For an array declared as int a[10][20], the type returned for a[i] is int [20].
bool type_equal_p(type, type)
void discard_module_declaration_text(entity)
Discard the decls_text string of the module code to make the prettyprinter ignoring the textual decla...
type pointed_type(type)
returns the type pointed by the input type if it is a pointer or an array of pointers
bool pointer_type_p(type)
Check for scalar pointers.
bool formal_parameter_p(entity)
string type_to_string(const type)
type.c
#define value_undefined_p(x)
#define dummy_identifier(x)
#define normalized_undefined
#define expression_domain
newgen_execution_domain_defined
#define parameter_dummy(x)
#define parameter_type(x)
#define cast_domain
newgen_call_domain_defined
#define callees_callees(x)
#define reference_variable(x)
#define value_unknown_p(x)
#define dimension_lower(x)
#define subscript_domain
newgen_storage_domain_defined
#define basic_pointer_p(x)
#define call_domain
newgen_callees_domain_defined
#define EXPRESSION(x)
EXPRESSION.
#define reference_domain
newgen_range_domain_defined
#define expression_undefined
#define PARAMETER(x)
PARAMETER.
#define reference_indices(x)
#define dimension_undefined
#define expression_undefined_p(x)
#define subscript_array(x)
#define variable_dimensions(x)
#define statement_declarations(x)
#define call_arguments(x)
#define value_expression_p(x)
#define expression_syntax(x)
#define dummy_identifier_p(x)
#define type_variable_p(x)
#define value_expression(x)
#define variable_basic(x)
#define STATEMENT(x)
STATEMENT.
#define entity_initial(x)
#define syntax_subscript_p(x)
FI: I do not understand why the type is duplicated at the set level.
The structure used to build lists in NewGen.
bool use_pointers_p
This bool is controlled by the "LINEARIZE_ARRAY_USE_POINTERS" property.
bool modify_call_site_p
This bool is controlled by the "LINEARIZE_ARRAY_MODIFY_CALL_SITE" property.
bool cast_at_call_site_p
This bool is controlled by the "LINEARIZE_ARRAY_CAST_AT_CALL_SITE" property Turning it on break furth...
#define exp
Avoid some warnings from "gcc -Wshadow".
void AddEntityToModuleCompilationUnit(entity e, entity module)