PIPS
|
apply transformations required to generate terapix microcode More...
#include <ctype.h>
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "effects.h"
#include "ri-util.h"
#include "workspace-util.h"
#include "prettyprint.h"
#include "effects-util.h"
#include "text.h"
#include "pipsdbm.h"
#include "pipsmake.h"
#include "resources.h"
#include "properties.h"
#include "misc.h"
#include "control.h"
#include "effects-generic.h"
#include "effects-simple.h"
#include "alias-classes.h"
#include "effects-convex.h"
#include "expressions.h"
#include "callgraph.h"
#include "text-util.h"
#include "transformations.h"
#include "parser_private.h"
#include "accel-util.h"
Go to the source code of this file.
Data Structures | |
struct | entity_bool |
struct | terapix_loop_handler_param |
struct | context |
struct | tlo_context_t |
Macros | |
#define | TERAPIX_PTRARG_PREFIX "FIFO" |
#define | TERAPIX_LOOPARG_PREFIX "N" |
#define | TERAPIX_IMAGE_PREFIX "im" |
#define | TERAPIX_MASK_PREFIX "ma" |
#define | TERAPIX_REGISTER_PREFIX "re" |
#define | TERAPIX_ACC "P" |
Variables | |
static entity | tw_loop_index |
apply transformations required to generate terapix microcode
Definition in file terapixify.c.
#define TERAPIX_ACC "P" |
#define TERAPIX_IMAGE_PREFIX "im" |
Definition at line 130 of file terapixify.c.
#define TERAPIX_LOOPARG_PREFIX "N" |
Definition at line 129 of file terapixify.c.
#define TERAPIX_MASK_PREFIX "ma" |
Definition at line 131 of file terapixify.c.
#define TERAPIX_PTRARG_PREFIX "FIFO" |
Definition at line 128 of file terapixify.c.
#define TERAPIX_REGISTER_PREFIX "re" |
Definition at line 132 of file terapixify.c.
Definition at line 75 of file terapixify.c.
References call_constant_p, call_function, entity_initial, entity_user_name(), printf(), and value_intrinsic_p.
Referenced by normalize_microcode().
|
static |
Definition at line 86 of file terapixify.c.
References basic_int_p, basic_overloaded_p, basic_pointer, basic_pointer_p, basic_to_string(), expression_basic(), free(), gen_free_list(), printf(), type_variable, ultimate_type(), variable_basic, Words_Expression(), and words_to_string().
Referenced by normalize_microcode().
terapixify
Definition at line 68 of file terapixify.c.
References gen_chunk::i, and printf().
Referenced by normalize_microcode().
|
static |
Definition at line 300 of file terapixify.c.
References entity_storage, find_ith_formal_parameter(), formal_offset, get_current_module_entity(), intptr_t, storage_formal, TERAPIX_LOOPARG_PREFIX, and terapix_renamed_entity_p().
Referenced by normalize_microcode_parameter_orders().
|
static |
change parameter name and generate an assignment
we now have FIFOx in ne and will generate an assignment from ne to e we also have to change the storage for e ... and for images, add a dereferencing operator
to respect terapix asm, we also have to change the name of variable e
Definition at line 164 of file terapixify.c.
References AddEntityToCurrentModule(), asprintf, basic_pointer, CAR, code_declarations, copy_type(), DEREFERENCING_OPERATOR_NAME, entity_bool::e, ENDP, ENTITY, entity_basic(), entity_initial, entity_intrinsic(), entity_module_name(), entity_storage, entity_to_expression(), entity_type, entity_user_name(), free(), free_expression(), free_storage(), free_type(), get_current_module_entity(), get_current_module_statement(), insert_statement(), make_assign_statement(), make_entity_copy_with_new_name(), MakeUnaryCall(), MODULE_SEP_STRING, POP, replace_entity(), same_entity_p(), same_string_p, storage_undefined, substitute_expression(), TERAPIX_IMAGE_PREFIX, terapix_renamed_p(), and value_code.
Referenced by force_terapix_argument_handler(), and terapix_argument_handler().
|
static |
Definition at line 479 of file terapixify.c.
References binary_call_lhs, call_function, CONS, copy_expression(), ENTITY_DEREFERENCING_P, entity_intrinsic(), exp, EXPRESSION, expression_reference_p(), expression_to_entity(), gen_recurse_stop(), tlo_context_t::iterator, make_call(), make_syntax_call(), NIL, tlo_context_t::plus, PRE_DECREMENT_OPERATOR_NAME, PRE_INCREMENT_OPERATOR_NAME, same_entity_p(), tlo_context_t::success, and update_expression_syntax().
Referenced by terapix_loop_optimizer(), and terapixify_loops().
check that lhs only contains reference to mask
Definition at line 327 of file terapixify.c.
References binary_call_lhs, binary_call_rhs, call_function, ENTITY_ASSIGN_P, expression_pointer_p(), expression_reference(), gen_recurse_stop(), get_referenced_entities(), context::ref, reference_variable, context::res, same_entity_p(), SET_FOREACH, set_free(), and terapix_mask_entity_p().
Referenced by terapix_pointer_initialized_from_a_mask_p().
|
static |
Definition at line 1011 of file terapixify.c.
References binary_call_lhs, binary_call_rhs, call_arguments, call_function, DIVIDE_OPERATOR_NAME, ENTITY_DIVIDE_P, entity_intrinsic(), extended_expression_constant_p(), gen_free_list(), get_int_property(), int_to_expression(), LEFT_SHIFT_OPERATOR_NAME, make_expression_list, MakeBinaryCall(), MULTIPLY_OPERATOR_NAME, pips_user_error, and RIGHT_SHIFT_OPERATOR_NAME.
Referenced by terapix_remove_divide().
make sure s is of the form decl loop nest
and then assume each array is a 2+ dimensional array and make sure there is no constant in the first array index. That's all.
Definition at line 879 of file terapixify.c.
References CONS, declaration_statement_p(), do_terapix_warmup_patching(), ENTITY, entity_array_p(), entity_type, FOREACH, gen_context_recurse, gen_free_list(), gen_length(), gen_true2(), get_referenced_entities(), loop_body, loop_index, NIL, reference_domain, SET_FOREACH, set_free(), STATEMENT, statement_block(), statement_block_p, statement_loop(), statement_loop_p(), tw_loop_index, type_variable, and variable_dimensions.
Referenced by terapix_warmup().
Definition at line 839 of file terapixify.c.
References CAR, CDR, copy_expression(), DIMENSION, entity_intrinsic(), entity_type, expression_normalized, make_op_exp(), MakeBinaryCall(), MINUS_OPERATOR_NAME, MULTIPLY_OPERATOR_NAME, NORMALIZE_EXPRESSION, normalized_linear, normalized_linear_p, offset, PLUS_OPERATOR_NAME, Pvecteur_to_expression(), REFCAR, reference_indices, reference_variable, same_entity_p(), SizeOfDimension(), tw_loop_index, type_variable, VALUE_ZERO, variable_dimensions, vect_new(), vect_rm(), VECTEUR_NUL_P, vecteur_succ, vecteur_val, and vecteur_var.
Referenced by do_terapix_warmup().
Definition at line 121 of file terapixify.c.
References entity_bool::b, entity_bool::e, entity_used_in_loop_bound_walker(), gen_context_recurse, gen_true2(), get_current_module_statement(), and loop_domain.
Referenced by normalize_microcode().
|
static |
Definition at line 115 of file terapixify.c.
References entity_used_in_reference_walker(), gen_context_recurse, gen_true2(), loop_range, and reference_domain.
Referenced by entity_used_in_loop_bound_p().
|
static |
Definition at line 109 of file terapixify.c.
References entity_bool::b, entity_bool::e, reference_variable, and same_entity_p().
Referenced by entity_used_in_loop_bound_walker().
|
static |
Definition at line 220 of file terapixify.c.
References do_terapix_argument_handler(), and entity_bool::e.
Referenced by normalize_microcode().
prelude
validate
ostlude
module_name | odule_name |
Definition at line 991 of file terapixify.c.
References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, gen_recurse, gen_true(), get_current_module_statement(), module_name(), module_name_to_entity(), module_reorder(), reset_cumulated_rw_effects(), reset_current_module_entity(), reset_current_module_statement(), set_conflict_testing_properties(), set_cumulated_rw_effects(), set_current_module_entity(), set_current_module_statement(), statement_domain, and two_addresses_code_generator().
bool normalize_microcode | ( | char * | module_name | ) |
prelude
checks
make sure
unroll some loops with constant trip count
reorder some loops
detect initial array sizes
now, try to guess the goal of the parameters
reserve some register for internal use
it's a pointer
a rom array with only one element, outlining and isolate_statement where too smart :)
pips bonus step: the consistency
rename all declared entities using terasm convention
need a copy otherwise goes in infinite loop
it's a pointer
it's an int
reorder arguments to match terapix conventions
loops in terasm iterate over a given parameter, in the form DO I=1:N I is hidden to the user and N must be a parameter
normalize test
try some simple optimizations
validate
ostlude
module_name | odule_name |
Definition at line 626 of file terapixify.c.
References ADDRESS_OF_OPERATOR_NAME, basic_int_p, basic_pointer, basic_pointer_p, CALL, call_arguments, call_domain, callees_callees, callers_to_call_sites(), callers_to_statements(), can_terapixify_call_p(), can_terapixify_expression_p(), cannot_terapixify(), CAR, CDR, clean_up_sequences(), compilation_unit_of_module(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, db_touch_resource(), DEREFERENCING_OPERATOR_NAME, dummy_identifier, dummy_identifier_p, ENDP, ENTITY, entity_area_p(), entity_declarations, entity_intrinsic(), entity_scalar_p(), entity_storage, entity_to_expression(), entity_type, entity_used_in_loop_bound_p(), entity_user_name(), entity_variable_p, exp, expression_domain, force_terapix_argument_handler(), FOREACH, forloop_domain, formal_offset, formal_parameter_p(), free_expression(), gen_context_multi_recurse(), gen_context_recurse, gen_copy_seq(), gen_free_list(), gen_null(), gen_recurse, gen_true(), gen_true2(), get_current_module_entity(), get_current_module_name(), get_current_module_statement(), get_string_property(), HASH_DEFAULT_SIZE, hash_pointer, hash_table_make(), terapix_loop_handler_param::ht, intptr_t, make_basic_pointer(), make_type_variable(), make_variable(), MakeUnaryCall(), module_functional_parameters, module_name(), module_name_to_entity(), module_reorder(), NIL, normalize_microcode_anotate(), normalize_microcode_parameter_orders(), offset, PARAMETER, parameter_dummy, parameter_type, pips_assert, POP, prefix, printf(), REFCAR, replace_entity_by_expression(), reset_cumulated_rw_effects(), reset_current_module_entity(), reset_current_module_statement(), set_cumulated_rw_effects(), set_current_module_entity(), set_current_module_statement(), STATEMENT, statement_declarations, statement_domain, stmt_rm_useless_label_rwt(), storage_formal, STRING, terapix_argument_handler(), TERAPIX_IMAGE_PREFIX, terapix_loop_handler(), terapix_loop_optimizer(), TERAPIX_MASK_PREFIX, terapix_normalize_tests(), terapix_optimize_accumulator(), terapix_pointer_initialized_from_a_mask_p(), TERAPIX_PTRARG_PREFIX, TERAPIX_REGISTER_PREFIX, terapixify_loops(), type_variable, ultimate_type(), variable_basic, and whileloop_domain.
void normalize_microcode_anotate | ( | void | ) |
there should be only one caller
Eeny, meeny, miny, moe
get ready for annotation insertion
Definition at line 410 of file terapixify.c.
References add_pragma_str_to_statement(), asprintf, callees_callees, CAR, db_get_memory_resource(), DIMENSION, dimension_size(), entity_pointer_p(), entity_type, entity_undefined_p, entity_user_name(), FindEntityFromUserName(), FOREACH, free(), get_current_module_entity(), get_current_module_name(), get_current_module_statement(), module_formal_parameters(), pips_assert, STATEMENT, statement_block(), strdup(), STRING, type_variable, and variable_dimensions.
Referenced by normalize_microcode().
|
static |
Definition at line 318 of file terapixify.c.
References compare_formal_parameters(), module, and sort_parameters().
Referenced by normalize_microcode().
|
static |
Definition at line 621 of file terapixify.c.
References statement_remove_useless_label().
Referenced by normalize_microcode().
|
static |
Definition at line 217 of file terapixify.c.
References do_terapix_argument_handler(), and entity_bool::e.
Referenced by normalize_microcode().
|
static |
generate new entity if needed
use the reference , but we must rename it however !
patch loop
save change for futher processing
Definition at line 245 of file terapixify.c.
References AddEntityToCurrentModule(), asprintf, CAR, terapix_loop_handler_param::cnt, code_declarations, do_loop_to_while_loop(), ENDP, ENTITY, entity_initial, entity_to_expression(), entity_undefined, expression_reference(), expression_reference_p(), free(), free_constant(), free_expression(), get_current_module_entity(), get_current_module_name(), get_current_module_statement(), get_referenced_entities(), hash_put(), terapix_loop_handler_param::ht, is_value_expression, loop_body, loop_range, make_entity_copy_with_new_name(), make_scalar_integer_entity(), MODULE_SEP_STRING, new_loop_bound(), POP, range_to_expression(), range_to_nbiter, range_upper, reference_variable, replace_entity(), same_entity_p(), set_belong_p(), statement_loop(), statement_loop_p(), TERAPIX_LOOPARG_PREFIX, terapix_suitable_loop_bound_p(), value_code, value_constant, value_expression, and value_tag.
Referenced by normalize_microcode().
void terapix_loop_optimizer | ( | statement | st | ) |
look for iterators from the end
now try to hide the iteration in a pointer access somewhere
st | t |
Definition at line 498 of file terapixify.c.
References AddLocalEntityToDeclarations(), assignment_statement_p(), binary_call_lhs, binary_call_rhs, call_domain, call_function, CONS, copy_statement(), DEFAULT_INTEGER_TYPE_SIZE, do_terapix_loop_optimizer(), ENDP, entity_intrinsic(), ENTITY_MINUS_C_P, ENTITY_PLUS_C_P, expression_call(), expression_call_p(), expression_equal_p(), expression_integer_value(), expression_to_entity(), FOREACH, free_statement(), gen_context_recurse, gen_copy_seq(), gen_free_list(), gen_nreverse(), gen_null2(), gen_remove(), get_current_module_entity(), get_referenced_entities(), insert_statement(), intptr_t, loop_body, make_basic_int(), make_block_statement(), make_new_scalar_variable(), MINUS_C_OPERATOR_NAME, NIL, PLUS_C_OPERATOR_NAME, sequence_statements, set_belong_p(), set_free(), STATEMENT, statement_block(), statement_block_p, statement_call(), statement_loop(), statement_loop_p(), statement_sequence(), and tlo_context_t::success.
Referenced by normalize_microcode().
Definition at line 150 of file terapixify.c.
References entity_bool::e, TERAPIX_MASK_PREFIX, and terapix_renamed_entity_p().
Referenced by do_terapix_pointer_initialized_from_a_mask_p().
|
static |
a test is normalized when it is in the form a>0
Definition at line 362 of file terapixify.c.
References binary_call_lhs, binary_call_rhs, call_function, copy_expression(), copy_syntax(), ENTITY_CONDITIONAL_P, ENTITY_GREATER_THAN_P, entity_intrinsic(), ENTITY_LESS_THAN_P, expression_call(), expression_call_p(), expression_syntax, free_expression(), GREATER_THAN_OPERATOR_NAME, MakeBinaryCall(), MINUS_OPERATOR_NAME, pips_internal_error, and update_expression_syntax().
Referenced by normalize_microcode().
|
static |
if only one register is ever written by a sequence of assignment, take advantage of it
first ensure it's a sequence of assignment
then check that the written register is always the same
finally, rename this entity as the accumulator P
Definition at line 442 of file terapixify.c.
References AddEntityToCurrentModule(), assignment_statement_p(), binary_call_lhs, continue_statement_p(), DEFAULT_INTEGER_TYPE_SIZE, entity_undefined, entity_undefined_p, expression_int_scalar(), FindEntityFromUserName(), FOREACH, get_current_module_name(), make_basic_int(), make_scalar_entity(), replace_entity(), same_entity_p(), STATEMENT, statement_block(), statement_block_p, statement_call(), and TERAPIX_ACC.
Referenced by normalize_microcode().
Definition at line 354 of file terapixify.c.
References call_domain, do_terapix_pointer_initialized_from_a_mask_p(), gen_context_recurse, gen_true2(), get_current_module_statement(), context::ref, and context::res.
Referenced by normalize_microcode().
prelude
converts divide operator into multiply operator: a/cste = a* (1/b) ~= a * ( 128 / cste ) / 128
validate
ostlude
module_name | odule_name |
Definition at line 1045 of file terapixify.c.
References call_domain, db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, do_terapix_remove_divide(), gen_recurse, gen_true(), get_current_module_statement(), module_name(), module_name_to_entity(), reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), and set_current_module_statement().
Definition at line 147 of file terapixify.c.
References entity_bool::e, entity_local_name(), prefix, and terapix_renamed_local_p().
Referenced by compare_formal_parameters(), and terapix_mask_entity_p().
|
static |
Definition at line 135 of file terapixify.c.
References prefix.
Referenced by terapix_renamed_entity_p(), and terapix_renamed_p().
|
static |
Definition at line 154 of file terapixify.c.
References TERAPIX_IMAGE_PREFIX, TERAPIX_LOOPARG_PREFIX, TERAPIX_MASK_PREFIX, TERAPIX_PTRARG_PREFIX, TERAPIX_REGISTER_PREFIX, and terapix_renamed_local_p().
Referenced by do_terapix_argument_handler().
|
static |
Definition at line 231 of file terapixify.c.
References exp, gen_context_recurse, gen_null2(), reference_domain, and terapix_suitable_loop_bound_walker().
Referenced by terapix_loop_handler().
Definition at line 225 of file terapixify.c.
References formal_parameter_p(), and reference_variable.
Referenced by terapix_suitable_loop_bound_p().
bool terapix_warmup | ( | const char * | module_name | ) |
prelude
go go power rangers
validate
ostlude
module_name | odule_name |
Definition at line 908 of file terapixify.c.
References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, do_terapix_warmup(), get_current_module_statement(), module_name(), module_name_to_entity(), module_reorder(), reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), and set_current_module_statement().
Definition at line 399 of file terapixify.c.
References get_referenced_entities(), make_continue_instruction(), set_belong_p(), set_free(), statement_call_p(), and update_statement_instruction().
Referenced by terapixify_loops().
|
static |
look for iterators
now try to hide the iteration in a pointer access somewhere
be optimistic: even if we failed, remove the iterator
Definition at line 565 of file terapixify.c.
References assignment_statement_p(), binary_call_lhs, binary_call_rhs, call_domain, call_function, CAR, do_terapix_loop_optimizer(), ENDP, ENTITY_MINUS_C_P, ENTITY_PLUS_C_P, expression_call(), expression_call_p(), expression_constant_p(), expression_equal_p(), expression_integer_value(), expression_to_entity(), FOREACH, free_statement(), full_loop_unroll(), gen_context_recurse, gen_copy_seq(), gen_free_list(), gen_null2(), gen_remove(), gen_true2(), get_referenced_entities(), intptr_t, loop_index, loop_range, POP, range_increment, range_lower, range_upper, set_belong_p(), set_free(), STATEMENT, statement_block(), statement_block_p, statement_call(), statement_domain, statement_loop(), statement_loop_p(), tlo_context_t::success, and terapixify_loop_purge().
Referenced by normalize_microcode().
|
static |
a=b+c; -> (1) a=b; (2) a=a+c;
Definition at line 948 of file terapixify.c.
References call_arguments, call_function, call_undefined, CAR, CDR, copy_expression(), EFFECT, effects_may_conflict_p(), effects_write_effects(), end, ENTITY_ASSIGN_P, EXPRESSION, expression_call(), expression_call_p(), expression_equal_p(), FOREACH, gen_free_list(), gen_full_free_list(), insert_statement(), load_cumulated_rw_effects_list(), make_assign_statement(), proper_effects_of_expression(), statement_call(), statement_call_p(), two_addresses_code_generator_split_p(), and w_effects.
Referenced by generate_two_addresses_code().
|
static |
e |
Definition at line 935 of file terapixify.c.
References call_constant_p, call_function, ENTITY_DEREFERENCING_P, expression_call(), expression_call_p(), and get_bool_property().
Referenced by two_addresses_code_generator().
|
static |
Definition at line 838 of file terapixify.c.
Referenced by do_terapix_warmup(), and do_terapix_warmup_patching().