PIPS
|
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include "linear.h"
#include "genC.h"
#include "ri.h"
#include "effects.h"
#include "misc.h"
#include "ri-util.h"
#include "effects-util.h"
#include "effects-generic.h"
#include "effects-convex.h"
#include "properties.h"
#include "conversion.h"
Go to the source code of this file.
Functions | |
expression | Psysteme_to_expression (Psysteme systeme) |
Standard includes. More... | |
list | Pcontrainte_to_expression_list (Pcontrainte constraint, entity operator) |
static bool | vect_simple_definition_p (Pvecteur v, Variable *pvar, Value *pcoe, Value *pcst) |
here I store simple bounds on variables appearing in the systems to allow the code generation phase to use them to improve the code. More... | |
static void | store_an_upper (entity var, int val) |
static void | store_a_lower (entity var, int val) |
void | set_information_for_code_optimizations (Psysteme s) |
I could keep the system for further optimizations... More... | |
void | reset_information_for_code_optimizations () |
static bool | range_of_variable (Variable var, Value *lb, Value *ub) |
this functions returns bounds for variable var if both are available. More... | |
static Value | vecteur_lower_bound (Pvecteur v) |
returns v lower bound if found, or INT_MIN. More... | |
static bool | evaluate_divide_if_possible (Pvecteur v, Value denominator, Value *result) |
expression | constraints_to_loop_bound (Pcontrainte c, Variable var, bool is_lower, entity divide) |
expression constraints_to_loop_bound(c, var, is_lower) More... | |
bool | bounds_equal_p (Variable var, Pcontrainte lower, Pcontrainte upper) |
this function checks whether the lower and upper constraints are going to generate the same bound on variable var. More... | |
statement | systeme_to_loop_nest (Psysteme sc, list vars, statement body, entity divide) |
sc is used to generate the loop nest bounds for variables vars. More... | |
statement | generate_optional_if (Psysteme sc, statement stat) |
statement generate_optional_if(sc, stat) More... | |
bool bounds_equal_p | ( | Variable | var, |
Pcontrainte | lower, | ||
Pcontrainte | upper | ||
) |
this function checks whether the lower and upper constraints are going to generate the same bound on variable var.
oeff for var in the constraint
??? the arithmetic ppcm version is on int instead of values
var | ar |
lower | ower |
upper | pper |
Definition at line 534 of file system_to_code.c.
References nb_elems_list(), ppcm(), sum(), TCST, val_of, value_div, value_minus, VALUE_ONE, value_uminus, var_of, vect_add(), vect_add_elem(), vect_coeff(), vect_dup(), vect_multiply(), vect_normalize(), vect_rm(), Scontrainte::vecteur, and VECTEUR_NUL_P.
Referenced by region_to_minimal_dimensions(), and systeme_to_loop_nest().
expression constraints_to_loop_bound | ( | Pcontrainte | c, |
Variable | var, | ||
bool | is_lower, | ||
entity | divide | ||
) |
expression constraints_to_loop_bound(c, var, is_lower)
the is_lower (lower/upper) loop bound for variable var relative to Pcontrainte c is generated. All the constraints in c are used, and they must be ok.
see also make_bound_expression in ri-util/bound_generation.c maybe move this function in ri-util/bound_generation.c? integer division to be called
the constraints are sorted first, to ensure a deterministic result ??? the sorting criterion is rather strange:-)
each constraint is considered in turn to generate a bound
ax+b <= 0 and a<0 => x >= (b+(-a-1))/(-a)
extract coefficients that are dividable by val... x = (ay+bz)/a -> x = y + bz/a
assert. no a.i=0 should have reached this point...
I perform some other optimizations here, by looking at the extent of the numerator, that may result in a constant after division by the denominator. For instance, x = y/a and 0 <= y < a would lead to x = 0, which is quite simpler... I need a hook from the callers of this function to retrieve the constant lower and upper bounds of each variable in order to perform this. ??? this optimizations should/could be perform earlier on the original system... but the implementation in a general context does not seems obvious to me...
use / instead of the provided idiv if operand >=0
final operation: MAX or MIN if more than one bound
and memory leak... (cons lost)
var | the constraints of the bound |
is_lower | the index variable |
divide | lower or upper bound |
Definition at line 374 of file system_to_code.c.
References c_language_module_p(), CAR, compare_Pvecteur(), CONS, CONTRAINTE_UNDEFINED_P, contraintes_dup(), divide, DIVIDE_OPERATOR_NAME, entity_intrinsic(), entity_local_name(), evaluate_divide_if_possible(), exp, EXPRESSION, expression_constant_p(), expression_undefined, FOREACH, fprintf(), gen_free_list(), gen_length(), get_bool_property(), get_current_module_entity(), ifdebug, inegalites_fprint(), int_to_expression(), make_call_expression(), make_vecteur_expression(), MakeBinaryCall(), MAX_OPERATOR_NAME, message_assert, MIN_OPERATOR_NAME, NIL, pips_assert, PIPS_C_MAX_OPERATOR_NAME, PIPS_C_MIN_OPERATOR_NAME, pips_debug, PLUS_OPERATOR_NAME, sc_make(), sc_rm(), sc_sort_constraints(), Scontrainte::succ, Svecteur::succ, TCST, val_of, value_div, value_minus, value_mod, VALUE_ONE, value_one_p, value_oppose, value_pos_p, value_posz_p, value_sign, Value_to_expression(), value_zero_p, var_of, vect_add_elem(), vect_chg_sgn(), vect_coeff(), vect_del_var(), vect_erase_var(), vect_rm(), vect_sort(), Scontrainte::vecteur, vecteur_lower_bound(), and VECTEUR_NUL.
Referenced by do_array_expansion(), do_check_isolate_statement_preconditions_on_call(), do_isolate_statement_preconditions_satisified_p(), do_solve_hardware_constraints_on_nb_proc(), make_rectangular_area(), region_to_minimal_dimensions(), statement_insertion_fix_access(), systeme_to_loop_nest(), and variable_to_dimensions().
Definition at line 328 of file system_to_code.c.
References max, min, range_of_variable(), Svecteur::succ, TCST, val_of, value_addto, value_eq, value_mult, value_pdivision, value_pos_p, and var_of.
Referenced by constraints_to_loop_bound().
statement generate_optional_if(sc, stat)
if sc is Z^n then no if is required, if sc is empty, then statement is nop, else an if is required
sc | c |
stat | tat |
Definition at line 667 of file system_to_code.c.
References CONS, make_empty_statement, NIL, Psysteme_to_expression(), sc_empty_p(), sc_rn_p(), st_make_nice_test(), and STATEMENT.
Referenced by build_third_comb(), generate_io_statements_for_shared_arrays(), GENERATION(), processor_loop(), and verify_array_variable().
list Pcontrainte_to_expression_list | ( | Pcontrainte | constraint, |
entity | operator | ||
) |
a simple expression is generated.
a binary operator should be given, as eg, ne, lt, le, gt, ge.
constraint | onstraint |
operator | perator |
Definition at line 90 of file system_to_code.c.
References CONS, contrainte_vecteur, entity_undefined_p, EXPRESSION, make_vecteur_expression(), MakeBinaryCall(), NIL, Pvecteur_separate_on_sign(), Scontrainte::succ, vect_rm(), and VECTEUR_NUL.
Referenced by Psysteme_to_expression().
expression Psysteme_to_expression | ( | Psysteme | systeme | ) |
Standard includes.
Psystems stuff Newgen stuff PIPS stuff expression Psysteme_to_expression(Psysteme systeme)
From a Psysteme, a logical expression that checks for the constraints is generated.
systeme | ysteme |
Definition at line 69 of file system_to_code.c.
References entity_intrinsic(), EQUAL_OPERATOR_NAME, expression_list_to_conjonction(), gen_free_list(), gen_nconc(), LESS_OR_EQUAL_OPERATOR_NAME, and Pcontrainte_to_expression_list().
Referenced by build_third_comb(), expression_less_than_in_context(), generate_optional_if(), and top_down_abc_dimension().
this functions returns bounds for variable var if both are available.
whether bounds were found Upper Bound
no information available, that's for sure
lb | the VARiable |
ub | Lower Bound |
Definition at line 264 of file system_to_code.c.
References int_to_value.
Referenced by evaluate_divide_if_possible().
void reset_information_for_code_optimizations | ( | void | ) |
Definition at line 254 of file system_to_code.c.
Referenced by generate_io_collect_or_update(), and hpf_remapping().
void set_information_for_code_optimizations | ( | Psysteme | s | ) |
I could keep the system for further optimizations...
Here, only direct lower and upper bounds are extracted and kept.
first look thru equalities
then thru inequalities
UPPER
LOWER
Definition at line 208 of file system_to_code.c.
References contrainte_vecteur, store_a_lower(), store_an_upper(), Scontrainte::succ, value_div, value_minus, VALUE_ONE, value_pdiv, value_plus, value_pos_p, VALUE_TO_INT, value_uminus, and vect_simple_definition_p().
Referenced by generate_io_collect_or_update(), and hpf_remapping().
Definition at line 189 of file system_to_code.c.
References entity_local_name(), and pips_debug.
Referenced by set_information_for_code_optimizations().
Definition at line 173 of file system_to_code.c.
References entity_local_name(), and pips_debug.
Referenced by set_information_for_code_optimizations().
sc is used to generate the loop nest bounds for variables vars.
vars may be empty. the loop statement is returned.
sc is not touched... I have to give the divide entity to be called
duplicate sc
??? could do a better job with =
reverse the list of vars
VAR = LOWER body
DO VAR = LOWER, UPPER, 1 body ENDDO
sc | c |
vars | of entity |
body | ody |
divide | ivide |
Definition at line 578 of file system_to_code.c.
References bounds_equal_p(), CONS, constraints_for_bounds(), constraints_to_loop_bound(), CONTRAINTE_UNDEFINED_P, contraintes_free(), current, divide, ENDP, ENTITY, entity_empty_label(), entity_name, entity_to_expression(), FOREACH, gen_copy_seq(), gen_free_list(), gen_nreverse(), instruction_to_statement(), int_to_expression(), is_execution_sequential, is_instruction_loop, make_assign_statement(), make_block_statement(), make_execution(), make_instruction(), make_loop(), make_range(), message_assert, NIL, pips_debug, sc_dup(), sc_rm(), sc_transform_eg_in_ineg(), STATEMENT, and UU.
Referenced by broadcast(), copy_write_statement_with_cumulated_regions(), elements_loop(), generate_io_statements_for_shared_arrays(), GENERATION(), initialize_array_variable(), make_array_communication_statement(), processor_loop(), Psysteme_to_loop_nest(), and verify_array_variable().
|
static |
here I store simple bounds on variables appearing in the systems to allow the code generation phase to use them to improve the code.
returns the lower and upper bounds of var if available the concept could be transfered to SC ?
size == 2
Definition at line 133 of file system_to_code.c.
References Svecteur::succ, TCST, val_of, var_of, and vect_size().
Referenced by set_information_for_code_optimizations().
returns v lower bound if found, or INT_MIN.
no information available, that's for sure
val < 0, I guess
Definition at line 283 of file system_to_code.c.
References int_to_value, Svecteur::succ, TCST, val_of, value_addto, VALUE_MIN, value_mult, value_pos_p, and var_of.
Referenced by constraints_to_loop_bound().