PIPS
|
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "effects.h"
#include "resources.h"
#include "misc.h"
#include "ri-util.h"
#include "prettyprint.h"
#include "effects-util.h"
#include "effects-generic.h"
#include "text-util.h"
#include "effects-simple.h"
#include "sac.h"
#include "patterns.h"
#include "properties.h"
#include <ctype.h>
#include <stdlib.h>
Go to the source code of this file.
Macros | |
#define | MAX_PACK 16 |
#define | VECTOR_POSTFIX "vec" |
#define | SAC_ALIGNED_VECTOR_NAME "pdata" |
Variables | |
static float | gSimdCost |
static hash_table | vector_to_expressions = hash_table_undefined |
|
static |
Definition at line 463 of file codegen.c.
References basic_of_expression(), distance_between_expression(), expression_integer_value(), expression_to_string(), expression_undefined_p, free_basic(), free_expression(), intptr_t, NORMALIZE_EXPRESSION, pips_debug, and SizeOfElements().
Referenced by make_loadsave_statement().
|
static |
Definition at line 404 of file codegen.c.
References entity_field_p(), expression_undefined, int_to_expression(), make_op_exp(), MINUS_OPERATOR_NAME, offset_of_struct(), same_entity_p(), and same_struct_entity_p().
Referenced by distance_between_expression().
expression distance_between_expression | ( | const expression | exp0, |
const expression | exp1 | ||
) |
computes the distance betwwen two expression
reference with different variables have an infinite distance
exp0 | xp0 |
exp1 | xp1 |
Definition at line 419 of file codegen.c.
References basic_of_reference(), binary_call_lhs, binary_call_rhs, distance_between_entity(), expression_call(), expression_field_p(), expression_reference(), expression_reference_p(), expression_undefined, expression_undefined_p, free_basic(), get_bool_property(), int_to_expression(), make_op_exp(), MINUS_OPERATOR_NAME, MULTIPLY_OPERATOR_NAME, PLUS_OPERATOR_NAME, reference_variable, set_bool_property(), simplify_expression(), SizeOfElements(), and sreference_offset().
Referenced by comparable_statements_on_distance_p(), compare_statements_on_distance_to_origin(), conflict_is_a_real_conflict_p(), consecutive_expression_p(), and do_simdizer_init().
Definition at line 71 of file codegen.c.
References entity_undefined, expression_equal_p(), gen_equals(), hash_table_scan(), and vector_to_expressions.
Referenced by expressions_to_vector(), and try_all_permutations().
bool expression_reference_or_field_p | ( | expression | e | ) |
Definition at line 192 of file codegen.c.
References expression_field_p(), and expression_reference_p().
Referenced by do_simdizer_init(), get_optimal_opcode(), and sac_statement_to_expressions_gather().
try all possible permutations, well only invert from now on
give up if there are two may permutations to try out
Definition at line 146 of file codegen.c.
References do_expressions_to_vector(), entity_undefined, entity_undefined_p, gen_length(), NIL, out, shuffle(), and try_all_permutations().
Referenced by generate_load_statement().
|
static |
Definition at line 1249 of file codegen.c.
References CONS, entity_to_expression(), EXPRESSION, gSimdCost, make_exec_statement_from_opcode(), NIL, opcode_cost, simdstatement_nbArgs, simdstatement_opcode, and simdstatement_vectors.
Referenced by generate_simd_code().
|
static |
Definition at line 1267 of file codegen.c.
References CONS, entity_to_expression(), entity_undefined_p, EXPRESSION, expressions_to_vector(), line, make_load_statement(), NIL, offset, opcode_vectorSize, shuffle(), simdstatement_arguments, simdstatement_opcode, simdstatement_vectors, and statement_undefined.
Referenced by generate_simd_code().
auto-guess vector size
name | ame |
types | ypes |
cost | ost |
Definition at line 276 of file codegen.c.
References gen_length(), get_int_property(), get_subwordSize_from_opcode(), intptr_t, make_opcode(), opcode_vectorSize, and pips_user_warning.
|
static |
Definition at line 1300 of file codegen.c.
References CONS, entity_to_expression(), EXPRESSION, make_save_statement(), NIL, offset, opcode_vectorSize, simdstatement_arguments, simdstatement_nbArgs, simdstatement_opcode, and simdstatement_vectors.
Referenced by generate_simd_code().
list generate_simd_code | ( | simdstatement | ssi, |
float * | simdCost | ||
) |
this is the classical generation process: several load, an exec and a store
the order is reversed, but we use it
ssi | si |
simdCost | imdCost |
Definition at line 1325 of file codegen.c.
References CONS, generate_exec_statement(), generate_load_statement(), generate_save_statement(), gSimdCost, NIL, out, pips_debug, save, simdstatement_nbArgs, STATEMENT, and statement_undefined_p.
Referenced by simdize_simple_statements_pass2().
|
static |
Definition at line 210 of file codegen.c.
References expression_syntax, reference_variable, simd_vector_entity_p(), syntax_reference, and syntax_reference_p.
Referenced by get_optimal_opcode(), and make_simd_statement().
|
static |
Computes the optimal opcode for simdizing 'argc' statements of the 'kind' operation, applied to the 'args' arguments it is a greedy matching, so it supposes the list of args is in the best order for us.
Based on the available implementations of the operation, decide how many statements to pack together
& !(bas_pattern == is_basic_float && basic_int_p(bas))
allow the promotion of an int to a float
Definition at line 297 of file codegen.c.
References basic_of_expression(), basic_overloaded_p, basic_tag, count, EXPRESSION, expression_reference_or_field_p(), FOREACH, free_basic(), get_basic_from_opcode(), get_int_property(), get_subwordSize_from_opcode(), OPCODE, opcode_undefined, opcode_vectorSize, opcodeClass_opcodes, and SizeOfElements().
Referenced by make_simd_statements().
switch to upper cases...
Definition at line 494 of file codegen.c.
References basic_typedef, basic_typedef_p, entity_name, entity_type, exp, EXPRESSION, expression_syntax, FOREACH, pips_assert, reference_variable, strdup(), strupper(), syntax_reference, type_variable, type_variable_p, and variable_basic.
Referenced by loadstore_type_conversion_string(), and make_loadsave_statement().
oc | c |
argNum | rgNum |
Definition at line 246 of file codegen.c.
References DC_REF_TOK, DF_REF_TOK, DI_REF_TOK, gen_nth(), HI_REF_TOK, INT, opcode_argType, pips_internal_error, QI_REF_TOK, SC_REF_TOK, SF_REF_TOK, and SI_REF_TOK.
Referenced by compute_parallelism_factor(), generate_opcode(), get_optimal_opcode(), and make_simd_statement().
Definition at line 629 of file codegen.c.
References entity_initial, entity_storage, entity_type, entity_undefined_p, FindEntity(), FindOrCreateEntity(), make_basic_typedef(), make_storage_rom(), make_type_variable(), make_value_unknown(), make_variable(), NIL, and TOP_LEVEL_MODULE_NAME.
Referenced by make_loadsave_statement(), and make_new_simd_vector_with_prefix().
switch to upper cases...
Definition at line 524 of file codegen.c.
References basic_of_expressions(), basic_tag, free_basic(), is_basic_complex, is_basic_float, is_basic_int, is_basic_logical, pips_internal_error, prefix, SizeOfElements(), strdup(), and strupper().
Referenced by loadstore_type_conversion_string(), make_loadsave_statement(), and make_shuffle_statement().
void init_vector_to_expressions | ( | void | ) |
codegen.c
Definition at line 59 of file codegen.c.
References HASH_DEFAULT_SIZE, hash_pointer, hash_table_make(), hash_table_undefined_p, pips_assert, and vector_to_expressions.
Referenced by simdize_simple_statements_pass2().
void invalidate_expressions_in_statement | ( | statement | s | ) |
Definition at line 162 of file codegen.c.
References CONS, EFFECT, effect_any_reference, ENTITY, EXPRESSION, expression_reference(), expression_reference_p(), expression_undefined_p, FOREACH, gen_free_list(), gen_full_free_list(), hash_del(), hash_table_scan(), load_proper_rw_effects_list(), NIL, references_may_conflict_p(), and vector_to_expressions.
Referenced by simdize_simple_statements_pass2().
|
static |
This function change the "load/store type" to XX_TO_XX if a conversion is needed.
It returns true if a change is made, and the pointer *lsType must be freed after being used.
we can handle this situation :p
Definition at line 742 of file codegen.c.
References asprintf, basic_tag, basic_type_size(), CAR, CDR, copy_value(), DIMENSION, dimension_size(), entity_initial, entity_type, entity_undefined, entity_undefined_p, entity_user_name(), exp, EXPRESSION, expression_reference(), expression_reference_p(), FOREACH, free_value(), get_simd_vector_type(), get_vect_name_from_data(), local_name(), make_new_simd_vector_with_prefix(), reference_variable, replace_entity(), SAC_ALIGNED_VECTOR_NAME, same_entity_p(), same_string_p, type_variable, ultimate_type(), variable_basic, and variable_dimensions.
Referenced by make_loadsave_statement().
SG: ugly patch to make sure fortran's parameter passing and c's are respected
Definition at line 602 of file codegen.c.
References asprintf, c_module_p(), call_to_statement, CAR, EXPRESSION, FOREACH, free(), get_string_property(), make_call(), module_name_to_runtime_entity(), replace_subscript(), SIMD_BROADCAST_SUFFIX, and SIMD_GENERIC_SUFFIX.
Referenced by make_exec_statement_from_opcode(), and make_loadsave_statement().
Definition at line 624 of file codegen.c.
References make_exec_statement_from_name(), and opcode_name.
Referenced by generate_exec_statement().
Definition at line 1112 of file codegen.c.
References make_loadsave_statement().
Referenced by generate_load_statement().
the function should not be called with an empty arguments list
first, find out if the arguments are:
classify according to the second element (first one should be the SIMD vector)
and not real_exp !
now verify the estimation on the first element is correct, and update parameters needed later
eventually, we have four times the same reference loaded. In that case, use a broadcast call
first pass of analysis is done we may have found that we have no consecutive references but a set of scalar if so, we should replace those scalars by appropriate array
rray
no support for array inital value in fortran
manage replacements in the end, otherwise it disturbs the whole process
Now that the analyze is done, we can generate an "optimized" load instruction.
make the new binding available to everybody
Definition at line 795 of file codegen.c.
References AddEntityToCurrentModule(), asprintf, assert, basic_of_expressions(), binary_call_rhs, BRACE_INTRINSIC, BROADCAST, call_to_expression(), CAR, CDR, CONS, consecutive_expression_p(), CONSTANT, copy_expression(), DIMENSION, ENDP, ENTITY, entity_initial, entity_intrinsic(), exp, EXPRESSION, expression_call(), expression_constant_p(), expression_field_p(), expression_reference(), expression_reference_p(), expression_scalar_p, expression_to_entity(), expression_undefined, expression_undefined_p, formal_parameter_p(), fortran_module_p(), free(), free_value(), gen_cons(), gen_free_list(), gen_full_copy_list(), gen_length(), gen_nreverse(), get_bool_property(), get_current_module_entity(), get_current_module_statement(), get_simd_vector_type(), get_string_property(), get_typedefed_array(), get_vect_name_from_data(), gSimdCost, insert_statement(), int_to_expression(), loadstore_type_conversion_string(), local_name(), make_assign_statement(), make_block_statement(), make_call(), make_dimension(), make_entity_expression(), make_exec_statement_from_name(), make_expression_list, make_new_scalar_variable_with_prefix(), make_reference(), make_value_expression(), new_statements, NIL, pips_assert, POP, REFCAR, reference_to_expression(), reference_variable, replace_entity_by_expression(), sac_aligned_expression_p(), SAC_ALIGNED_VECTOR_NAME, sac_real_current_instruction, same_expression_p(), SIMD_BROADCAST_SUFFIX, SIMD_CONSTANT_SUFFIX, SIMD_GENERIC_SUFFIX, SIMD_MASKED_SUFFIX, STATEMENT, strdup(), strlower(), and update_vector_to_expressions().
Referenced by make_load_statement(), and make_save_statement().
|
static |
Definition at line 734 of file codegen.c.
References make_new_simd_vector_with_prefix(), and VECTOR_POSTFIX.
Referenced by make_simd_statement().
|
static |
build the variable prefix code, which is in fact also the type
Definition at line 663 of file codegen.c.
References AddEntityToCurrentModule(), AddLocalEntityToDeclarations(), concatenate(), CONS, DIMENSION, entity_local_name(), entity_type, FindOrCreateEntity(), get_current_module_entity(), get_typedefed_array(), int_to_expression(), is_basic_float, is_basic_int, make_basic_float(), make_basic_int(), make_dimension(), make_new_scalar_variable_with_prefix(), make_type_variable(), make_variable(), mod_ent, NIL, num, pips_assert, prefix, sac_current_block, same_string_p, strdup(), and VECTOR_POSTFIX.
Referenced by loadstore_type_conversion_string(), and make_new_simd_vector().
This function will create the permutations indexes that will allow the creation of exp_final from exp_loaded with a shuffle.
Definition at line 105 of file codegen.c.
References EXPRESSION, expression_equal_p(), and FOREACH.
Referenced by try_all_permutations().
Definition at line 1117 of file codegen.c.
References make_loadsave_statement().
Referenced by generate_save_statement().
If the permutation indexes are equivalent to an invertion, generate an SIMD_INVERT function (useful for some MIS).
from | rom |
expressions | xpressions |
perms | erms |
Definition at line 1068 of file codegen.c.
References _, AddEntityToCurrentModule(), asprintf, CONS, entity_to_expression(), EXPRESSION, FOREACH, gen_length(), gen_nreverse(), get_vect_name_from_data(), instruction_to_statement(), int_to_expression(), make_call(), make_entity_copy(), make_instruction_call(), module_name_to_runtime_entity(), NIL, out, and shuffle().
Referenced by try_all_permutations().
|
static |
find out the number of arguments needed
allocate memory
create the simd vector entities
Fill the matrix of arguments
Definition at line 1128 of file codegen.c.
References CAR, CDR, entity_undefined, entity_undefined_p, exp, EXPRESSION, expression_equal_p(), expression_to_entity(), FOREACH, gen_length(), get_basic_from_opcode(), get_subwordSize_from_opcode(), HASH_DEFAULT_SIZE, hash_pointer, hash_put(), hash_table_free(), hash_table_make(), hash_table_scan(), make_new_simd_vector(), make_simdstatement(), malloc(), opcode_vectorSize, opcodeClass_nbArgs, pips_assert, simdstatement_arguments, and simdstatement_vectors.
Referenced by make_simd_statements().
simdstatement make_simd_statements | ( | set | opkinds, |
list | statements | ||
) |
there should be a better order than this
get the variables
compute the opcode to use
update the pointer to the next statement to be processed
generate the statement information
opkinds | pkinds |
statements | tatements |
Definition at line 1193 of file codegen.c.
References CAR, CDR, gen_last(), get_optimal_opcode(), get_statement_match_of_kind(), make_simd_statement(), match_args, MAX_PACK, opcode_undefined_p, opcode_vectorSize, OPCODECLASS, pips_debug, set_to_list(), simdstatement_undefined, and STATEMENT.
Referenced by simdize_simple_statements_pass2().
|
static |
Definition at line 386 of file codegen.c.
References copy_expression(), copy_type(), ENTITY, entity_field_to_entity_struct(), entity_type, FOREACH, int_to_expression(), make_expression(), make_op_exp(), make_sizeofexpression_type(), make_syntax_sizeofexpression(), normalized_undefined, offset, PLUS_OPERATOR_NAME, same_entity_p(), and type_struct.
Referenced by distance_between_entity().
|
static |
Definition at line 580 of file codegen.c.
References ADDRESS_OF_OPERATOR_NAME, entity_intrinsic(), expression_call_p(), expression_constant_p(), expression_field_p(), expression_syntax, make_call(), make_expression(), make_expression_list, make_syntax_call(), normalized_undefined, simd_vector_expression_p(), syntax_undefined, and update_expression_syntax().
Referenced by make_exec_statement_from_name().
void reset_vector_to_expressions | ( | void | ) |
Definition at line 64 of file codegen.c.
References hash_table_free(), hash_table_undefined, hash_table_undefined_p, pips_assert, and vector_to_expressions.
Referenced by simdize_simple_statements_pass2().
Definition at line 646 of file codegen.c.
References entity_user_name(), SAC_ALIGNED_VECTOR_NAME, and same_stringn_p.
Referenced by sac_aligned_expression_p(), and sac_commenter().
|
static |
Definition at line 651 of file codegen.c.
References expression_reference(), expression_reference_p(), reference_variable, and sac_aligned_entity_p().
Referenced by make_loadsave_statement().
Definition at line 197 of file codegen.c.
References entity_scalar_p(), entity_type, entity_user_name(), type_variable_p, and VECTOR_POSTFIX.
Referenced by get_basic_from_opcode(), and sac_commenter().
|
static |
expression is an simd vector if it is a reference array containing VECTOR_POSTFIX in its name
Definition at line 210 of file codegen.c.
Referenced by replace_subscript().
|
static |
computes the offset between an entity and its reference
r |
Definition at line 373 of file codegen.c.
References copy_reference(), free_reference(), gen_nreverse(), get_bool_property(), out, reference_indices, and reference_offset().
Referenced by distance_between_expression().
|
static |
Definition at line 121 of file codegen.c.
References CONS, do_expressions_to_vector(), ENDP, entity_undefined, entity_undefined_p, exp, EXPRESSION, FOREACH, gen_copy_seq(), gen_free_list(), gen_remove_once(), make_permutations_indexes(), make_shuffle_statement(), out, remainder, and shuffle().
Referenced by expressions_to_vector().
create the enw vector
remove the old ones
invalidate
Definition at line 83 of file codegen.c.
References ENDP, entity_consistent_p(), exp, EXPRESSION, expression_consistent_p(), expression_equal_p(), expression_undefined, FOREACH, free_expression(), gen_full_copy_list(), HASH_FOREACH, hash_put_or_update, pips_assert, POP, REFCAR, and vector_to_expressions.
Referenced by make_loadsave_statement().
|
static |
Definition at line 56 of file codegen.c.
Referenced by generate_exec_statement(), generate_simd_code(), and make_loadsave_statement().
|
static |
Definition at line 58 of file codegen.c.
Referenced by do_expressions_to_vector(), init_vector_to_expressions(), invalidate_expressions_in_statement(), reset_vector_to_expressions(), and update_vector_to_expressions().