PIPS
|
#include <ctype.h>
#include "genC.h"
#include "ri-util.h"
#include "effects.h"
#include "pipsdbm.h"
#include "workspace-util.h"
#include "pipsmake.h"
#include "properties.h"
#include "callgraph.h"
#include "misc.h"
#include "control.h"
#include "expressions.h"
#include "preprocessor.h"
#include "accel-util.h"
Go to the source code of this file.
Data Structures | |
struct | param_t |
transform each array type in module m
with statement s
step1: the statements
step2: the declarations
step3: insert the initialization statement just after declarations
pips bonus step: the consistency
Definition at line 892 of file array_to_pointer.c.
References do_array_to_pointer_type(), do_array_to_pointer_walker(), do_convert_this_array_to_pointer_p(), do_linearize_remove_dereferencment(), dummy_identifier, dummy_identifier_p, ENTITY, entity_declarations, entity_initial, entity_type, entity_variable_p, FOREACH, gen_append(), get_current_module_statement(), initialization_list_to_statements(), insert_statements_after_declarations(), module_functional_parameters, NIL, PARAMETER, parameter_consistent_p(), parameter_dummy, parameter_type, and pips_assert.
Referenced by linearize_array_generic().
|
static |
Definition at line 733 of file array_to_pointer.c.
References do_array_to_pointer_patch_call_expression().
Referenced by do_array_to_pointer_walker().
|
static |
fix some strange constructs introduced by previous processing
Definition at line 711 of file array_to_pointer.c.
References call_arguments, call_function, CAR, copy_syntax(), ENTITY_ADDRESS_OF_P, ENTITY_DEREFERENCING_P, exp, EXPRESSION, expression_call(), expression_call_p(), expression_syntax, syntax_undefined, and update_expression_syntax().
Referenced by do_array_to_pointer_patch_call_expr_rwt(), and do_array_to_pointer_walker().
returns true if a dereferencment has been supressed
Definition at line 268 of file array_to_pointer.c.
References array_type_p(), basic_pointer, do_array_to_pointer_type_aux(), free_type(), pointer_type_p(), type_undefined, type_variable, type_void_or_void_pointer_p(), and variable_basic.
Referenced by do_array_to_pointer(), do_array_to_pointer_walk_cast(), and do_linearize_array().
|
static |
Definition at line 251 of file array_to_pointer.c.
References basic_pointer, basic_pointer_p, DIMENSION, FOREACH, make_basic_pointer(), make_type_variable(), make_variable(), NIL, type_variable, variable_basic, and variable_dimensions.
Referenced by do_array_to_pointer_type().
|
static |
special ad-hoc handler for pointer to arrays
pointer to an array ...
Definition at line 739 of file array_to_pointer.c.
References ADDRESS_OF_OPERATOR_NAME, array_type_p(), basic_pointer, call_arguments, call_function, CAR, CONS, copy_expression(), ENTITY_DEREFERENCING_P, entity_intrinsic(), entity_pointer_p(), entity_type, exp, EXPRESSION, expression_reference(), expression_reference_p(), make_call(), make_syntax_call(), NIL, pointed_type(), reference_variable, type_variable, ultimate_type(), update_expression_syntax(), and variable_basic.
Referenced by do_array_to_pointer_walker().
|
static |
Definition at line 764 of file array_to_pointer.c.
References cast_type, and do_array_to_pointer_type().
Referenced by do_array_to_pointer_walker().
|
static |
Definition at line 677 of file array_to_pointer.c.
References DEREFERENCING_OPERATOR_NAME, do_convert_this_array_to_pointer_p(), ENDP, entity_intrinsic(), entity_to_expression(), exp, EXPRESSION, expression_reference(), expression_reference_p(), expression_syntax, expression_undefined, expression_undefined_p, FOREACH, gen_nreverse(), indices, MakeBinaryCall(), MakeUnaryCall(), NIL, pips_user_warning, PLUS_C_OPERATOR_NAME, reference_indices, reference_variable, syntax_subscript_p, syntax_undefined, and update_expression_syntax().
Referenced by do_array_to_pointer_walker().
|
static |
converts arrays to pointer
Definition at line 769 of file array_to_pointer.c.
References call_domain, cast_domain, do_array_to_pointer_patch_call_expr_rwt(), do_array_to_pointer_patch_call_expression(), do_array_to_pointer_walk_call_and_patch(), do_array_to_pointer_walk_cast(), do_array_to_pointer_walk_expression(), expression_domain, gen_multi_recurse(), gen_recurse, and gen_true().
Referenced by do_array_to_pointer().
Definition at line 68 of file array_to_pointer.c.
References entity_formal_p(), entity_initial, entity_variable_length_array_p(), expression_brace_p(), get_bool_property(), value_expression, value_expression_p, and value_undefined_p.
Referenced by do_array_to_pointer(), do_array_to_pointer_walk_expression(), and do_linearize_array().
step 0: remind all expressions types
step 0.25: hack some subscripts typically found in pips inputs
step 0.5: transform int (*a) [3] into int a[*][3]
step1: the statements
step2: the declarations
pips bonus step: the consistency
step3: change the caller to reflect the new types accordingly
final step: fix expressions if we have disturbed typing in the process
Definition at line 608 of file array_to_pointer.c.
References do_array_to_pointer_type(), do_convert_this_array_to_pointer_p(), do_linearize_array_init(), do_linearize_array_manage_callers(), do_linearize_array_walker(), do_linearize_patch_expressions(), do_linearize_prepatch(), do_linearize_prepatch_subscripts(), do_linearize_remove_dereferencment(), do_linearize_type(), dummy_identifier, dummy_identifier_p, ENTITY, entity_declarations, entity_initial, entity_name, entity_type, entity_variable_p, FOREACH, get_current_module_entity(), hash_table_free(), init_expression_is_pointer(), module_functional_parameters, PARAMETER, parameter_consistent_p(), parameter_dummy, parameter_type, pips_assert, pips_debug, set_add_element(), set_free(), set_make(), and set_pointer.
Referenced by linearize_array_generic().
|
static |
Definition at line 397 of file array_to_pointer.c.
References cast_type, and do_linearize_type().
Referenced by do_linearize_array_walker().
|
static |
Definition at line 455 of file array_to_pointer.c.
References call_arguments, call_function, CONS, copy_expression(), ENDP, ENTITY_BRACE_INTRINSIC_P, exp, EXPRESSION, expression_call(), expression_call_p(), gen_append(), gen_full_free_list(), gen_nreverse(), NIL, POP, REFCAR, value_expression, and value_expression_p.
Referenced by do_linearize_array().
|
static |
we may have to change the call sites, prepare iterators over call sites arguments here
Definition at line 288 of file array_to_pointer.c.
References ADDRESS_OF_OPERATOR_NAME, array_type_p(), basic_pointer, CALL, call_arguments, call_function, callees_callees, callers_to_call_sites(), callers_to_statements(), CAR, copy_type(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, DEREFERENCING_OPERATOR_NAME, ENDP, ENTITY_DEREFERENCING_P, entity_intrinsic(), expression_call(), expression_call_p(), expression_to_type(), fixed_length_array_type_p(), FOREACH, free_type(), make_basic_pointer(), make_cast(), make_expression(), make_syntax_cast(), make_type_variable(), make_variable(), MakeUnaryCall(), module_functional_parameters, module_local_name(), NIL, normalized_undefined, PARAMETER, parameter_type, pointer_type_p(), POP, REFCAR, set_belong_p(), STATEMENT, STRING, type_equal_p(), type_variable, and variable_basic.
Referenced by do_linearize_array().
|
static |
must first check the dimensions , then the pointer type
one dimension variable, nothing to do
merge all
better start with this than nothing
it's a pointer: pop type
Definition at line 107 of file array_to_pointer.c.
References add_integer_to_expression(), basic_pointer, basic_pointer_p, CAR, CDR, CONS, copy_expression(), DIMENSION, dimension_lower, ENDP, entity_type, entity_variable_p, EXPRESSION, expression_undefined, expression_undefined_p, fortran_module_p(), gen_full_free_list(), gen_nreverse(), get_current_module_entity(), indices, int_to_expression(), make_op_exp(), MINUS_OPERATOR_NAME, MULTIPLY_OPERATOR_NAME, NIL, PLUS_OPERATOR_NAME, POP, reference_indices, reference_variable, SizeOfDimensions(), type_variable, ultimate_type(), variable_basic, and variable_dimensions.
Referenced by do_linearize_array_walker().
Definition at line 177 of file array_to_pointer.c.
References pips_user_warning.
Referenced by do_linearize_array_walker().
|
static |
Definition at line 400 of file array_to_pointer.c.
References cast_domain, do_linearize_array_cast(), do_linearize_array_reference(), do_linearize_array_subscript(), gen_multi_recurse(), gen_null2(), gen_true2(), reference_domain, and subscript_domain.
Referenced by do_linearize_array().
|
static |
Definition at line 408 of file array_to_pointer.c.
References basic_of_expression(), basic_pointer_p, exp, free_basic(), hash_put(), and intptr_t.
Referenced by init_expression_is_pointer().
|
static |
Definition at line 447 of file array_to_pointer.c.
References do_linearize_pointer_is_expression(), ENTITY, entity_declarations, entity_initial, entity_variable_p, expression_domain, FOREACH, gen_context_recurse, gen_true2(), and get_current_module_entity().
Referenced by do_linearize_array().
|
static |
G: let us hope that by fixing only references, it will be enough
Definition at line 414 of file array_to_pointer.c.
References ADDRESS_OF_OPERATOR_NAME, basic_of_expression(), basic_pointer_p, CONS, entity_intrinsic(), exp, EXPRESSION, expression_reference_p(), expression_syntax, free_basic(), hash_get(), HASH_UNDEFINED_VALUE, intptr_t, make_call(), make_expression(), make_syntax_call(), NIL, normalized_undefined, syntax_undefined, and update_expression_syntax().
Referenced by do_linearize_patch_expressions().
Definition at line 585 of file array_to_pointer.c.
References do_linearize_prepatch_type(), dummy_identifier, dummy_identifier_p, ENTITY, entity_declarations, entity_initial, entity_pointer_p(), entity_type, entity_variable_p, FOREACH, free_value(), int_to_expression(), local_entity_of_module_p(), make_value_expression(), module_functional_parameters, PARAMETER, parameter_consistent_p(), parameter_dummy, parameter_type, pips_assert, and value_unknown_p.
Referenced by do_linearize_array().
|
static |
subscripts of the form (*a)[n] are transformed into a[n] it is coherent with other transformations scattered here and there in this file :p
Definition at line 550 of file array_to_pointer.c.
References array_type_p(), basic_pointer, call_arguments, call_function, CAR, CONS, copy_syntax(), ENTITY_DEREFERENCING_P, entity_pointer_p(), entity_type, exp, EXPRESSION, expression_call(), expression_call_p(), expression_reference(), expression_reference_p(), expression_syntax, int_to_expression(), pointed_type(), reference_indices, reference_variable, subscript_array, type_variable, ultimate_type(), update_expression_syntax(), and variable_basic.
Referenced by do_linearize_prepatch_subscripts().
transform some subscripts for generic handling later
Definition at line 573 of file array_to_pointer.c.
References cleanup_subscripts(), do_linearize_prepatch_subscript(), ENTITY, entity_declarations, entity_initial, entity_variable_p, FOREACH, gen_recurse, gen_true(), and subscript_domain.
Referenced by do_linearize_array().
|
static |
Definition at line 523 of file array_to_pointer.c.
References array_type_p(), basic_pointer, CONS, copy_variable(), DIMENSION, free_variable(), int_to_expression(), make_dimension(), NIL, pointer_type_p(), type_undefined, type_variable, ultimate_type(), variable_basic, and variable_dimensions.
Referenced by do_linearize_prepatch().
Definition at line 515 of file array_to_pointer.c.
References do_linearize_remove_dereferencment_walker(), ENTITY, entity_declarations, entity_initial, entity_variable_p, expression_domain, FOREACH, gen_context_recurse, gen_true2(), and get_current_module_entity().
Referenced by do_array_to_pointer(), and do_linearize_array().
|
static |
Definition at line 483 of file array_to_pointer.c.
References call_arguments, call_function, CAR, ENTITY_DEREFERENCING_P, ENTITY_PLUS_C_P, exp, EXPRESSION, expression_call(), expression_call_p(), expression_reference(), expression_reference_p(), expression_syntax, FOREACH, reference_variable, same_entity_p(), syntax_undefined, and update_expression_syntax().
Referenced by do_linearize_remove_dereferencment().
Definition at line 191 of file array_to_pointer.c.
References basic_pointer, basic_pointer_p, CONS, copy_type(), DIMENSION, dimension_undefined, fortran_module_p(), free_type(), gen_full_free_list(), gen_length(), get_current_module_entity(), int_to_expression(), make_dimension(), make_op_exp(), MINUS_OPERATOR_NAME, NIL, pips_assert, pips_debug, pips_user_warning, SizeOfDimensions(), type_to_string(), type_undefined, type_variable, type_variable_p, type_void_or_void_pointer_p(), ultimate_type(), variable_basic, and variable_dimensions.
Referenced by do_linearize_array(), and do_linearize_array_cast().
|
static |
Definition at line 437 of file array_to_pointer.c.
References do_linearize_expression_is_pointer(), ENTITY, entity_declarations, entity_initial, entity_variable_p, expression_domain, FOREACH, gen_context_recurse, gen_true2(), get_current_module_entity(), HASH_DEFAULT_SIZE, hash_int, and hash_table_make().
Referenced by do_linearize_array().
create a list of statements from entity declarations
we assume that we only have one level of braces, linearize_array should have done the previous job incomplete type are not handled ...
use alloca when converting array to pointers, to make sure everything is initialized correctly
Definition at line 781 of file array_to_pointer.c.
References AddEntityToModuleCompilationUnit(), ALLOCA_FUNCTION_NAME, array_type_p(), call_arguments, call_function, CAR, CONS, copy_expression(), copy_type(), DIMENSION, dimension_lower, entity_array_p(), ENTITY_BRACE_INTRINSIC_P, entity_initial, entity_intrinsic(), entity_type, exp, EXPRESSION, expression_call(), expression_call_p(), expression_syntax, FOREACH, formal_parameter_p(), free_value(), gen_nreverse(), get_current_module_entity(), int_to_expression(), make_assign_statement(), make_basic_pointer(), make_cast(), make_expression(), make_op_exp(), make_reference(), make_sizeofexpression_type(), make_syntax_cast(), make_syntax_sizeofexpression(), make_type_variable(), make_value_expression(), make_variable(), MakeUnaryCall(), NIL, normalized_undefined, PLUS_OPERATOR_NAME, POP, reference_to_expression(), STATEMENT, syntax_to_expression(), syntax_undefined, type_variable, ultimate_type(), value_expression, value_expression_p, and variable_dimensions.
Referenced by do_array_to_pointer().
initialization statements are added right after declarations
No declarations
Definition at line 866 of file array_to_pointer.c.
References CAR, CDR, declaration_statement_p(), ENDP, insert_statement(), make_block_statement(), NIL, POP, STATEMENT, statement_block(), and statement_declarations.
Referenced by do_array_to_pointer().
bool linearize_array | ( | const char * | module_name | ) |
linearize accesses to an array, and use pointers if asked to
module_name | odule_name |
Definition at line 987 of file array_to_pointer.c.
References linearize_array_generic(), and module_name().
bool linearize_array_fortran | ( | const char * | module_name | ) |
module_name | odule_name |
Definition at line 992 of file array_to_pointer.c.
References linearize_array_generic(), and module_name().
bool linearize_array_generic | ( | const char * | module_name | ) |
linearize accesses to an array, and use pointers if asked to
prelude
Do we have to cast the array at call site ?
it is too dangerous to perform this task on compilation unit, system variables may be changed
just linearize accesses and change signature from n-D arrays to 1-D arrays
additionally perform array-to-pointer conversion for c modules only
validate
ostlude
module_name | odule_name |
Definition at line 930 of file array_to_pointer.c.
References c_module_p(), cleanup_subscripts(), compilation_unit_entity_p(), compilation_unit_of_module(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, db_touch_resource(), debug_off, debug_on, discard_module_declaration_text(), do_array_to_pointer(), do_linearize_array(), ENTITY, entity_declarations, entity_initial, entity_variable_p, false, FOREACH, fortran_module_p(), get_bool_property(), get_current_module_entity(), get_current_module_statement(), module_name(), module_name_to_entity(), module_reorder(), pips_assert, pips_user_warning, reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), set_current_module_statement(), and statement_consistent_p().
Referenced by linearize_array(), and linearize_array_fortran().
t,counting | pointers as a dimension |
BEWARE: does not take structs and unions into account
Definition at line 89 of file array_to_pointer.c.
References basic_pointer, basic_pointer_p, gen_length(), ifdebug, pips_debug, print_type(), type_dereferencement_depth(), type_variable, type_variable_p, ultimate_type(), variable_basic, and variable_dimensions.
Referenced by type_dereferencement_depth().
Definition at line 181 of file array_to_pointer.c.
References basic_pointer, basic_pointer_p, type_variable, type_variable_p, type_void_p, ultimate_type(), and variable_basic.
Referenced by do_array_to_pointer_type(), and do_linearize_type().