PIPS
|
#include <stdio.h>
#include <string.h>
#include "genC.h"
#include "linear.h"
#include "misc.h"
#include "properties.h"
#include "ri.h"
#include "effects.h"
#include "ri-util.h"
#include "prettyprint.h"
#include "effects-util.h"
#include "text-util.h"
#include "effects-simple.h"
#include "pips-libs.h"
#include "transformer.h"
#include "semantics.h"
Go to the source code of this file.
Data Structures | |
struct | interval_product |
Macros | |
#define | DEBUG_TRANSFORMER_ADD_CONDITION_INFORMATION_UPDOWN 7 |
HANDLING OF CONDITIONS. More... | |
#define | DEBUG_TRANSFORMER_ADD_RELATION_INFORMATION 7 |
#define DEBUG_TRANSFORMER_ADD_CONDITION_INFORMATION_UPDOWN 7 |
HANDLING OF CONDITIONS.
Definition at line 716 of file expression.c.
#define DEBUG_TRANSFORMER_ADD_RELATION_INFORMATION 7 |
|
static |
Type independent.
Most of it should be factored out for binary operations. v = e1 + e2 or v = e1 - e2
sub-expressions are not necessarily integer? Then the expression should not be integer?
Too early: you are projecting v and loosing all useful information within an expression!
tf = transformer_temporary_value_projection(tf);
Definition at line 438 of file expression.c.
References dump_transformer, entity_type, free_transformer(), ifdebug, make_local_temporary_value_entity(), pips_debug, safe_any_expression_to_transformer(), simple_addition_to_transformer(), transformer_apply(), transformer_identity(), transformer_range(), transformer_safe_combine_with_warnings(), transformer_safe_image_intersection(), transformer_undefined, and transformer_undefined_p.
Referenced by float_binary_operation_to_transformer(), integer_binary_operation_to_transformer(), and pointer_binary_operation_to_transformer().
transformer affine_increment_to_transformer | ( | entity | e, |
Pvecteur | a | ||
) |
Definition at line 1269 of file expression.c.
References affine_to_transformer(), and transformer_undefined.
Referenced by add_loop_index_exit_value().
transformer affine_to_transformer | ( | entity | e, |
Pvecteur | a, | ||
bool | assignment | ||
) |
must be duplicated right now because it will be renamed and checked at the same time by value_mappings_compatible_vector_p()
assignment | ssignment |
Definition at line 1212 of file expression.c.
References CONS, contrainte_make(), CONTRAINTE_UNDEFINED, ENTITY, entity_to_new_value(), entity_to_old_value(), eq, ifdebug, make_predicate(), make_transformer(), NIL, pips_debug, sc_make(), transformer_undefined, value_mappings_compatible_vector_p(), VALUE_ONE, vect_add_elem(), vect_dump(), vect_dup(), vect_new(), vect_rm(), vect_substract(), vect_variable_rename(), and VECTEUR_NUL.
Referenced by affine_increment_to_transformer().
transformer any_assign_operation_to_transformer | ( | entity | tmp, |
list | args, | ||
transformer | pre, | ||
bool is_internal | __attribute__(unused) | ||
) |
Similar to any_assign_to_transformer(), which is a simpler case.
Here, we cope with expression such as the lhs of j = (i=1);
The lhs must be a scalar reference to perform an interesting analysis
Is it standard compliant? The assigned variable is modified by the rhs.
Take care of aliasing
tf = transformer_value_substitute(tf, v_new, v_old);
pre | arguments for assign |
__attribute__ | precondition |
Definition at line 499 of file expression.c.
References any_expression_to_transformer(), CAR, CDR, dump_transformer, ENDP, entity_has_values_p(), entity_is_argument_p(), entity_local_name(), entity_to_new_value(), entity_to_old_value(), entity_type, entity_user_name(), EXPRESSION, expression_syntax, expression_to_string(), free(), free_transformer(), ifdebug, make_local_temporary_value_entity(), NIL, pips_assert, pips_debug, print_transformer, reference_indices, reference_variable, semantics_user_warning, simple_equality_to_transformer(), syntax_reference, syntax_reference_p, transformer_add_modified_variable(), transformer_arguments, transformer_combine(), transformer_undefined, transformer_undefined_p, transformer_value_substitute(), and value_to_variable().
Referenced by any_basic_update_operation_to_transformer(), safe_any_assign_operation_to_transformer(), and update_operation_to_transformer().
transformer any_basic_update_operation_to_transformer | ( | entity | tmp, |
entity | v, | ||
entity | op | ||
) |
See also any_basic_update_to_transformer(), which should be based on this function.
FI: why
tmp | mp |
op | p |
Definition at line 317 of file expression.c.
References any_assign_operation_to_transformer(), CONS, dump_transformer, entity_intrinsic(), ENTITY_POST_DECREMENT_P, ENTITY_POST_INCREMENT_P, ENTITY_PRE_INCREMENT_P, entity_to_expression(), entity_to_old_value(), EXPRESSION, expression_undefined, gen_full_free_list(), ifdebug, int_to_expression(), list_undefined, MakeBinaryCall(), NIL, pips_debug, PLUS_C_OPERATOR_NAME, transformer_add_equality(), and transformer_undefined.
Referenced by generic_unary_operation_to_transformer(), and pointer_unary_operation_to_transformer().
transformer any_conditional_to_transformer | ( | entity | v, |
list | args, | ||
transformer | pre | ||
) |
Take care of the returned value.
About a cut-and-paste of previous function, conditional_to_transformer().
args | rgs |
pre | re |
Definition at line 5524 of file expression.c.
References CAR, CDR, condition_to_transformer(), EXPRESSION, free_transformer(), safe_any_expression_to_transformer(), transformer_apply(), transformer_combine(), transformer_convex_hull(), transformer_range(), and transformer_undefined.
Referenced by integer_call_expression_to_transformer(), and pointer_call_expression_to_transformer().
transformer any_expression_side_effects_to_transformer | ( | expression | e, |
transformer | p, | ||
bool is_internal | __attribute__(unused) | ||
) |
The value of the expression is irrelevant, but its sub-expressions may generate a transformer.
FI: use Newgen to reimplement this using abstract transformers to simplify the recursion ?
Definition at line 4845 of file expression.c.
References any_expressions_side_effects_to_transformer(), application_arguments, application_function, call_arguments, cast_expression, expression_syntax, expressions_to_transformer(), free_transformer(), is_syntax_application, is_syntax_call, is_syntax_cast, is_syntax_range, is_syntax_reference, is_syntax_sizeofexpression, is_syntax_subscript, is_syntax_va_arg, pips_internal_error, reference_indices, sizeofexpression_expression, sizeofexpression_expression_p, subscript_array, subscript_indices, syntax_application, syntax_call, syntax_cast, syntax_reference, syntax_sizeofexpression, syntax_subscript, syntax_tag, transformer_combine(), and transformer_undefined.
Referenced by any_expressions_side_effects_to_transformer(), and safe_any_expression_side_effects_to_transformer().
transformer any_expression_to_transformer | ( | entity | v, |
expression | expr, | ||
transformer | pre, | ||
bool | is_internal | ||
) |
A set of functions to compute the transformer associated to an expression evaluated in a given context.
The choices are:
Keyword: "any" implies that the expression value is needed
Keyword: "safe" implies that effects are used and that no undefined transformer is returned.
Suggested keyword: "light"
Should basic of expression take care of this?
Assume v is a value
If we are here, it should be an enum type...
Constants, at least, could be typed coerced
Redundant with explicit type coercion also available in PIPS
To be done later
PIPS does not represent negative constants: call to unary_minus
PIPS does not represent complex constants: call to CMPLX
Only constant string are processed
The overloading is supposed to have been lifted by basic_of_expression()
enum type are analyzed like int
This function is called from the region analysis, with extended expressions such as "*", the unbounded expression.
It might be interesting to go further in case the comma operator is used
No need to link the returned value as it must be cast to the proper type.
tf may be transformer_undefined when no information is derived
expr | xpr |
pre | re |
is_internal | s_internal |
Definition at line 4993 of file expression.c.
References basic_derived, basic_derived_p, basic_float_p, basic_int_p, basic_logical_p, basic_of_expression(), basic_overloaded_p, basic_pointer_p, basic_tag, basic_to_string(), basic_typedef, basic_typedef_p, boolean_analyzed_p(), call_arguments, call_function, comma_expression_p(), copy_basic(), ENTITY_CONTINUE_P, entity_local_name(), entity_type, entity_user_name(), expression_call(), expression_call_p(), expression_syntax, expression_to_string(), expressions_to_transformer(), float_analyzed_p(), float_expression_to_transformer(), free_basic(), ifdebug, integer_analyzed_p(), integer_expression_to_transformer(), is_basic_complex, is_basic_derived, is_basic_float, is_basic_int, is_basic_logical, is_basic_overloaded, is_basic_pointer, is_basic_string, is_basic_typedef, logical_expression_to_transformer(), pips_assert, pips_debug, pips_internal_error, pointer_analyzed_p(), pointer_expression_to_transformer(), print_expression(), semantics_user_warning, string_analyzed_p(), string_expression_to_transformer(), syntax_call, transformer_identity(), transformer_undefined, transformer_undefined_p, type_enum_p, type_variable, type_variable_p, ultimate_type(), unbounded_expression_p(), and variable_basic.
Referenced by add_formal_to_actual_bindings(), any_assign_operation_to_transformer(), any_scalar_assign_to_transformer_list(), any_scalar_assign_to_transformer_without_effect(), assigned_expression_to_transformer(), assigned_expression_to_transformer_list(), c_data_to_prec_for_variables(), c_return_to_transformer(), expression_to_transformer(), fortran_user_call_to_transformer(), generic_abs_to_transformer(), generic_minmax_to_transformer(), loop_bound_evaluation_to_transformer(), safe_any_expression_to_transformer(), and unary_minus_operation_to_transformer().
transformer any_expressions_side_effects_to_transformer | ( | list | el, |
transformer | p, | ||
bool | is_internal | ||
) |
same as any_expression_side_effects_to_transformer() but for a list of expressions
el | l |
is_internal | s_internal |
Definition at line 4921 of file expression.c.
References any_expression_side_effects_to_transformer(), EXPRESSION, FOREACH, free_transformer(), transformer_combine(), transformer_undefined, and transformer_undefined_p.
Referenced by any_expression_side_effects_to_transformer().
transformer any_expressions_to_transformer | ( | entity | v, |
list | expl, | ||
transformer | pre | ||
) |
Compute the transformer associated to a list of expressions such as "i=0, j = 1;".
The value returned is linked to v.
To be merged with the previous function.
el is an over-appoximation; should be replaced by a safe_expression_to_transformer() taking care of computing the precise effects of exp instead of using the effects of expl.
expl | xpl |
pre | re |
Definition at line 5754 of file expression.c.
References CAR, exp, EXPRESSION, FOREACH, free_transformer(), gen_last(), safe_any_expression_to_transformer(), safe_expression_to_transformer(), transformer_apply(), transformer_combine(), transformer_identity(), transformer_normalize(), transformer_range(), transformer_undefined, and transformer_undefined_p.
Referenced by integer_call_expression_to_transformer(), and pointer_call_expression_to_transformer().
transformer assign_operation_to_transformer | ( | entity | val, |
expression | lhs, | ||
expression | rhs, | ||
transformer | pre | ||
) |
Returns an undefined transformer in case of failure.
&& integer_scalar_entity_p(e)
val | al |
lhs | hs |
rhs | hs |
pre | re |
Definition at line 2737 of file expression.c.
References assigned_expression_to_transformer(), dump_transformer, entity_has_values_p(), entity_to_new_value(), expression_reference_p(), expression_syntax, ifdebug, pips_debug, reference_variable, syntax_reference, transformer_add_equality(), transformer_undefined, and transformer_undefined_p.
Referenced by float_binary_operation_to_transformer(), integer_binary_operation_to_transformer(), logical_binary_function_to_transformer(), and pointer_binary_operation_to_transformer().
transformer bitwise_xor_to_transformer | ( | entity | v, |
list | args, | ||
transformer | pre | ||
) |
returns the transformer associated to a C bitwise xor, ^, applied to two integer argument, when meaningful, and transformer_undefined otherwise.
Effects must be used at a higher level to fall back on a legal transformer.
v | is the value associated to the expression |
args | is assumed to have only one expression element of type int negated by ! |
pre | is the current precondition |
Something can be done when both arguments have values in [0,1], when both arguments have known numerical values, when both arguments have the same value,... However, all this tests imply lots time consuming projections for a limited result... Unless somebody uses XOR to flip-flop between arrays... for instance to bother Sven Verdoolaege:-). A logical not might be more useful for this:-).
The two values are know at compile time
The two values can be interpreted as booleans
Code about cut-and-pasted from logical_binary_operation_to_transformer()
The two arguments may be equal because they are the same expression and the xor is used to generate a zero or because they have the same value.
Since the difference is zero the two values are equal
args | rgs |
pre | re |
Definition at line 5619 of file expression.c.
References CAR, CDR, eq, EXPRESSION, expression_equal_p(), free_transformer(), intptr_t, make_local_temporary_integer_value_entity(), precondition_minmax_of_value(), safe_any_expression_to_transformer(), TCST, transformer_add_equality_with_integer_constant(), transformer_apply(), transformer_equality_add(), transformer_identity(), transformer_inequality_add(), transformer_intersection(), transformer_range(), transformer_undefined, transformer_undefined_p, VALUE_MONE, VALUE_ONE, vect_add_elem(), and vect_new().
Referenced by integer_call_expression_to_transformer().
transformer condition_to_transformer | ( | expression | cond, |
transformer | pre, | ||
bool | veracity | ||
) |
To capture side effects and to add C twist for numerical conditions.
Argument pre may be undefined.
Beware of tricky conditions using the comma or the conditional operator, although they should be handled as the default case, using effects.
upwards should be set to false when computing preconditions (but we have no way to know) or when computing tramsformers in context. And set to true in other cases. upwards is a way to gain execution time at the expense of precision. This speed/accuracy tradeoff has evolved with CPU technology.
If a comma operator is used, the test is the last expression
FI: quid of a conditional operator? e.g. "x>0?1<m:1<n"
FI: quid of assignment operator? e.g. "i = j = k = 1"
FI: we probably need a function tcond = expression_to_condition(cond)
C comparison operators return an integer value
FI: not good when side effects in cond
In case, there are side-effects in the condition. This is very unlikely for standard code and should be simplified with a test to transformer_identity_p(tf)
Make sure you can handle this kind of variable.
This test is added for Semantics-New/transformer01.c which tests a pointer. The underlying bug may still be there when pointers are analyzed by PIPS.
tmpv != 0
tmpv==0
Not yet? We may be in a = c? x : y; or in e1, e2,...; Does it matter?
May be dangerous if this routine is called internally to another routine using temporary variables...
reset_temporary_value_counter();
cond | ond |
pre | re |
veracity | eracity |
Definition at line 5348 of file expression.c.
References analyzed_basic_p(), basic_logical_p, basic_of_expression(), call_arguments, call_function, CAR, cast_expression, copy_transformer(), dump_transformer, effects_to_transformer(), ENTITY_COMMA_P, ENTITY_LOGICAL_OPERATOR_P, EXPRESSION, expression_call_p(), expression_cast(), expression_cast_p(), expression_syntax, expression_to_proper_constant_path_effects(), fprintf(), free_basic(), free_transformer(), gen_full_free_list(), gen_last(), ifdebug, make_local_temporary_value_entity_with_basic(), safe_any_expression_to_transformer(), safe_expression_to_transformer(), syntax_call, transformer_add_condition_information_updown(), transformer_add_sign_information(), transformer_apply(), transformer_combine(), transformer_convex_hull(), transformer_identity(), transformer_normalize(), transformer_range(), transformer_temporary_value_projection(), transformer_undefined, and transformer_undefined_p.
Referenced by any_conditional_to_transformer(), complete_forloop_transformer(), complete_forloop_transformer_list(), complete_repeatloop_transformer_list(), conditional_to_transformer(), forloop_to_postcondition(), forloop_to_transformer(), intrinsic_to_transformer(), intrinsic_to_transformer_list(), new_complete_whileloop_transformer_list(), new_whileloop_to_k_transformer(), new_whileloop_to_transformer(), repeatloop_to_postcondition(), repeatloop_to_transformer(), simplify_boolean_expression_with_precondition(), test_to_postcondition(), test_to_transformer(), test_to_transformer_list(), and whileloop_to_postcondition().
transformer conditional_to_transformer | ( | expression | cond, |
expression | te, | ||
expression | fe, | ||
transformer | pre, | ||
list | ef | ||
) |
FI: not too smart to start with the special case with no value returned, just side-effects...
cond | ond |
te | e |
fe | e |
pre | re |
ef | f |
Definition at line 5488 of file expression.c.
References condition_to_transformer(), effects_to_transformer(), free_transformer(), safe_expression_to_transformer(), transformer_apply(), transformer_combine(), transformer_convex_hull(), transformer_range(), transformer_undefined, and transformer_undefined_p.
Referenced by intrinsic_to_transformer(), and intrinsic_to_transformer_list().
|
static |
the rhs is a call to a constant function
Implicitly sufficient length or implicit padding with SPACEs
Take the prefix of the constant. Expect problems with PIPS quotes...
This is not a constant string
Definition at line 645 of file expression.c.
References basic_string_p, call_function, entity_basic(), entity_constant_p, entity_local_name(), entity_undefined, expression_syntax, f(), float_constant_p(), float_constant_to_double(), integer_constant_p(), is_basic_string, make_constant_entity(), malloc(), module_local_name(), pips_assert, pips_debug, pips_user_error, simple_equality_to_transformer(), string_type_size(), syntax_call, syntax_call_p, transformer_add_equality_with_integer_constant(), transformer_identity(), and transformer_undefined.
Referenced by float_call_expression_to_transformer(), and string_expression_to_transformer().
bool eval_condition_wrt_precondition_p | ( | expression | c, |
transformer | pre, | ||
bool | veracity | ||
) |
pre | re |
veracity | eracity |
Definition at line 5909 of file expression.c.
References f(), precondition_add_condition_information(), transformer_dup(), and transformer_empty_p().
Referenced by false_condition_wrt_precondition_p(), and true_condition_wrt_precondition_p().
transformer expression_effects_to_transformer | ( | expression | expr | ) |
expr | xpr |
Definition at line 3465 of file expression.c.
References effects_to_transformer(), expression_to_proper_constant_path_effects(), and gen_full_free_list().
Referenced by integer_expression_to_transformer(), safe_any_expression_side_effects_to_transformer(), safe_assigned_expression_to_transformer(), safe_integer_expression_to_transformer(), transformer_add_call_condition_information_updown(), and transformer_add_condition_information_updown().
|
static |
cut-and-pasted and adapted from multiply_to_transformer();
FI: I had to switch the arguments to satisfy a reasonnable assert in image_intersection(), but the switch may be detrimental to memory allocation.
The numerical value of expression e1 is known: v = lb1*v2
Definition at line 2169 of file expression.c.
References add_sizeof_value(), basic_pointer, basic_pointer_p, dump_transformer, entity_to_expression(), entity_type, free_expression(), free_transformer(), ifdebug, integer_expression_and_precondition_to_integer_interval(), make_local_temporary_value_entity(), pips_debug, safe_integer_expression_to_transformer(), TCST, transformer_add_inequality_with_linear_term(), transformer_apply(), transformer_empty(), transformer_equality_add(), transformer_identity(), transformer_inequality_add(), transformer_intersection(), transformer_normalize(), transformer_range(), transformer_safe_apply(), transformer_undefined, transformer_undefined_p, type_to_sizeof_value(), type_undefined, type_undefined_p, type_variable, type_variable_p, VALUE_MONE, VALUE_ONE, variable_basic, vect_add_elem(), and vect_new().
Referenced by pointer_binary_operation_to_transformer(), pointer_call_expression_to_transformer(), and pointer_expression_to_transformer().
|
static |
Definition at line 100 of file expression.c.
References NIL, and pips_internal_error.
Referenced by equal_condition_to_points_to(), freed_pointer_to_points_to(), internal_pointer_assignment_to_points_to(), intrinsic_call_condition_to_points_to(), intrinsic_call_to_points_to(), non_equal_condition_to_points_to(), null_equal_condition_to_points_to(), null_non_equal_condition_to_points_to(), and order_condition_to_points_to().
|
static |
Definition at line 108 of file expression.c.
References NIL, and pips_internal_error.
Referenced by equal_condition_to_points_to(), freed_pointer_to_points_to(), internal_pointer_assignment_to_points_to(), intrinsic_call_to_points_to(), non_equal_condition_to_points_to(), null_equal_condition_to_points_to(), null_non_equal_condition_to_points_to(), order_condition_to_points_to(), pointer_arithmetic_to_points_to(), struct_assignment_to_points_to(), and struct_initialization_to_points_to().
transformer expression_to_transformer | ( | expression | exp, |
transformer | pre, | ||
list | el | ||
) |
Just to capture side effects as the returned value is ignored.
Example: "(void) inc(&i);".
Or to capture the return of a struct, which cannot be expressed with an atomic return value.
FI: I assume this implies a cast to (void) but I'm wrong for any call to a void function.
FI: I do not remember the meaning of the last parameter
Must be a call to a void function
Wait till it happpens...
FI: is_internal_p has an impact on renaming in simple_affine_to_transformer().
FI: there may be (many) other exceptions with intrinsics...
Fortran intrinsics, such as IOs, are not taken into account because these code should not be executed for Fortran code.
If everything else has failed.
exp | xp |
pre | re |
el | l |
Definition at line 5190 of file expression.c.
References analyzed_type_p(), any_expression_to_transformer(), application_arguments, application_function, base, call_arguments, call_function, call_to_transformer(), CAR, cast_expression, compute_basic_concrete_type(), effects_to_transformer(), ENTITY_FIELD_P, entity_module_p(), ENTITY_POINT_TO_P, entity_undefined, exp, EXPRESSION, expression_application(), expression_application_p(), expression_call(), expression_call_p(), expression_cast(), expression_cast_p(), expression_reference(), expression_reference_p(), expression_sizeofexpression(), expression_sizeofexpression_p(), expression_subscript(), expression_subscript_p(), expression_syntax, expression_to_proper_constant_path_effects(), expression_to_type(), expressions_to_transformer(), f(), free_transformer(), free_type(), generic_reference_to_transformer(), make_local_temporary_value_entity(), pips_internal_error, safe_expression_to_transformer(), sizeofexpression_expression, sizeofexpression_expression_p, subscript_array, subscript_indices, syntax_call, syntax_call_p, syntax_cast, syntax_cast_p, transformer_combine(), transformer_temporary_value_projection(), transformer_undefined, transformer_undefined_p, type_void_p, and user_call_to_transformer().
Referenced by expression_to_postcondition(), instruction_to_transformer(), and safe_expression_to_transformer().
transformer expressions_to_transformer | ( | list | expl, |
transformer | pre | ||
) |
Compute the transformer associated to a list of expressions such as "i=0, j = 1;".
The value returned is ignored.
el is an over-appoximation; should be replaced by a safe_expression_to_transformer() taking care of computing the precise effects of exp instead of using the effects of expl.
expl | xpl |
pre | re |
Definition at line 5722 of file expression.c.
References copy_transformer(), exp, EXPRESSION, FOREACH, free_transformer(), safe_expression_to_transformer(), transformer_apply(), transformer_combine(), transformer_identity(), transformer_normalize(), transformer_range(), transformer_undefined, and transformer_undefined_p.
Referenced by any_expression_side_effects_to_transformer(), any_expression_to_transformer(), expression_to_transformer(), generic_reference_to_transformer(), intrinsic_to_transformer(), and intrinsic_to_transformer_list().
bool false_condition_wrt_precondition_p | ( | expression | c, |
transformer | pre | ||
) |
pre | re |
Definition at line 5891 of file expression.c.
References eval_condition_wrt_precondition_p().
Referenced by whileloop_to_postcondition(), and whileloop_to_total_precondition().
|
static |
Definition at line 4074 of file expression.c.
References addition_operation_to_transformer(), assign_operation_to_transformer(), ENTITY_ASSIGN_P, ENTITY_MINUS_P, ENTITY_PLUS_P, and transformer_undefined.
Referenced by float_call_expression_to_transformer().
|
static |
Just in case some integer variables were modified by the function call, e.g. the count of its dynamic calls.
tf = constant_to_transformer(v, call_function(syntax_call(srhs)));
min, max,...
pre | needed to compute effects for user calls |
Definition at line 4095 of file expression.c.
References call_arguments, call_function, CAR, CDR, constant_to_transformer(), ENTITY_AMAX1_P, ENTITY_AMIN1_P, ENTITY_C_MIN_P, ENTITY_DMAX1_P, ENTITY_DMIN1_P, entity_initial, ENTITY_MAX_P, ENTITY_MIN_P, entity_name, EXPRESSION, expression_syntax, float_binary_operation_to_transformer(), float_unary_operation_to_transformer(), gen_length(), generic_minmax_to_transformer(), get_bool_property(), SEMANTICS_INTERPROCEDURAL, semantics_user_warning, syntax_call, transformer_undefined, user_function_call_to_transformer(), and value_code_p.
Referenced by float_expression_to_transformer().
transformer float_expression_to_transformer | ( | entity | v, |
expression | rhs, | ||
transformer | pre, | ||
bool | is_internal | ||
) |
pre can be used if some integer variables with constant values have to be promoted to float.
pips_assert("Precondition is undefined", transformer_undefined_p(pre));
rhs | hs |
pre | re |
is_internal | s_internal |
Definition at line 4153 of file expression.c.
References expression_syntax, float_call_expression_to_transformer(), generic_reference_to_transformer(), is_syntax_call, is_syntax_range, is_syntax_reference, pips_internal_error, syntax_reference, syntax_tag, and transformer_undefined.
Referenced by any_expression_to_transformer().
|
static |
Definition at line 4054 of file expression.c.
References generic_unary_operation_to_transformer(), transformer_undefined, and transformer_undefined_p.
Referenced by float_call_expression_to_transformer().
|
static |
forward declaration
Copy of iabs_to_transformer(), which is probably never called anymore.
Expression expr may be of a type different from v's type because abs maybe generic and because type conversions may be implicit
expr | assumed to be a value |
Definition at line 1725 of file expression.c.
References abs, any_expression_to_transformer(), dump_transformer, entity_type, expression_to_type(), free_transformer(), free_type(), ifdebug, integer_expression_and_precondition_to_integer_interval(), integer_type_p(), make_local_temporary_value_entity(), pips_debug, transformer_add_equality(), transformer_add_equality_with_affine_term(), transformer_add_equality_with_integer_constant(), transformer_identity(), transformer_inequality_add(), transformer_safe_image_intersection(), VALUE_MONE, VALUE_ONE, VALUE_ZERO, vect_add_elem(), and vect_new().
Referenced by generic_unary_operation_to_transformer().
|
static |
pips_assert("Precondition is unused", transformer_undefined_p(pre));
memory leak!
A miracle occurs and the proper basis is derived from the constraints ( I do not understand why the new and the old value of e both appear... so it may not be necessary for the consistency check... I'm lost, FI, 6 Jan. 1999)
cl could be kept but would be always projected later
Definition at line 214 of file expression.c.
References any_expression_to_transformer(), base_add_variable(), BASE_NULLE, CAR, contrainte_make(), CONTRAINTE_NULLE_P, CONTRAINTE_UNDEFINED, CONTRAINTE_UNDEFINED_P, contraintes_free(), dump_transformer, ENDP, entity_type, EXPRESSION, gen_length(), ifdebug, make_local_temporary_value_entity(), make_predicate(), make_transformer(), NIL, pips_assert, pips_debug, POP, sc_make(), Scontrainte::succ, transformer_inequalities_add(), transformer_safe_image_intersection(), transformer_undefined, transformer_undefined_p, VALUE_MONE, VALUE_ONE, vect_add_elem(), vect_multiply(), and vect_new().
Referenced by float_call_expression_to_transformer().
transformer generic_reference_to_transformer | ( | entity | v, |
reference | r, | ||
transformer | pre, | ||
bool | is_internal | ||
) |
TYPE INDEPENDENT OPERATIONS.
expression.c
May return an undefined transformer
If you are dealing with a C array reference, find transformers for each subscript expression in case of side effects.
pre | re |
is_internal | s_internal |
Definition at line 126 of file expression.c.
References analyzable_scalar_entity_p(), analyzed_type_p(), array_type_p(), c_language_module_p(), CONS, constant_memory_access_path_to_location_entity(), ENDP, ENTITY, entity_basic_concrete_type(), entity_has_values_p(), entity_initial, entity_to_new_value(), entity_undefined_p, EXPRESSION, expressions_to_transformer(), external_entity_to_new_value(), FOREACH, free_transformer(), get_bool_property(), get_current_module_entity(), location_entity_p(), make_reference(), make_zero_expression(), modified_variables_with_values(), NIL, points_to_reference_to_concrete_type(), reference_indices, reference_variable, references_may_conflict_p(), simple_equality_to_transformer(), store_independent_reference_p(), transformer_add_equality(), transformer_add_variable_update(), transformer_intersection(), transformer_undefined, transformer_undefined_p, and value_reference.
Referenced by assign_rhs_to_reflhs_to_transformer(), expression_to_transformer(), float_expression_to_transformer(), integer_expression_to_transformer(), pointer_expression_to_transformer(), and points_to_unary_operation_to_transformer().
|
static |
FI: Oops, the precondition is lost here! See any_basic_update_to_transformer()
And loop over the possible source locations
A very similar loop is used in lhs_expression_to_transformer() and in struct_refrence_assignment_to_transformer()...
Definition at line 356 of file expression.c.
References any_basic_update_operation_to_transformer(), CELL, cell_any_reference(), constant_memory_access_path_to_location_entity(), copy_transformer(), cp, ENTITY_ABS_P, ENTITY_C_ABS_P, ENTITY_C_CABS_P, ENTITY_CABS_P, ENTITY_CABSF_P, ENTITY_CABSL_P, ENTITY_DABS_P, ENTITY_DEREFERENCING_P, ENTITY_FABS_P, ENTITY_FABSF_P, ENTITY_FABSL_P, entity_has_values_p(), ENTITY_IABS_P, ENTITY_IMAXABS_P, ENTITY_LABS_P, ENTITY_LLABS_P, ENTITY_POST_DECREMENT_P, ENTITY_POST_INCREMENT_P, ENTITY_PRE_DECREMENT_P, ENTITY_PRE_INCREMENT_P, ENTITY_UNARY_MINUS_P, entity_undefined_p, expression_syntax, FOREACH, free_transformer(), gen_length(), generic_abs_to_transformer(), int, reference_variable, s1, semantics_expression_to_points_to_sinks(), semantics_usable_points_to_reference_p(), syntax_reference, transformer_add_equality(), transformer_combine(), transformer_convex_hull(), transformer_range(), transformer_undefined, transformer_undefined_p, and unary_minus_operation_to_transformer().
Referenced by float_unary_operation_to_transformer(), integer_unary_operation_to_transformer(), logical_unary_operation_to_transformer(), and pointer_unary_operation_to_transformer().
|
static |
semantic analysis: processing of expressions, with or without preconditions.
Expressions in Fortran were assumed to be side effect free most of the time and transformers were assumed to be linked to statements only. This is not true in C, where many constructs have side effects: Consider for instance the following three statements
n++; j = k = 2; i = j, k = i;
which may also appear as conditions, initializations or incrementations in compound statements (while, for, if).
Most functions here may return transformer_undefined when no interesting polyhedral approximation exists because the problem was fixed later at the statement level by using effects. For C, we need new functions which always succeed. So we need effects at the expression level although they are not stored in the PIPS database.
Moreover, temporary values are used to combine subexpressions. These temporary values must be projected when a significant transformer has been obtained, but not earlier. The temporary value counter cannot be reset before all temporary variables have been projected (eliminated). So functions which are called recursively cannot project temporary values and reset the temporary value counter. We can use wrapping functions and/or an additional argument, is_internal, to know whether temporary variables should be eliminated or not when returning the transformer.
Note that since expressions have side effects, preconditions must be updated along the left-to-right expression abstraction process. For example:
j = 2; i = j + (j = 0) + j;
but such a case is forbidden by the C99 standard. The result of the evaluation of such an expression is undefined.
Definition at line 93 of file expression.c.
References pips_internal_error.
|
static |
POINTER EXPRESSION.
Maybe move in ri-util/expression.c or in effect-util/pointer_values.c
search in an arithmetic pointer expression if the pointer NULL is present
expr | arithmetic expression to scan |
Definition at line 4198 of file expression.c.
References basic_pointer_p, call_arguments, call_function, CAR, CDR, compute_basic_concrete_type(), ENTITY_MINUS_C_P, ENTITY_MINUS_P, ENTITY_MULTIPLY_P, entity_name, ENTITY_PLUS_C_P, ENTITY_PLUS_P, entity_type, EXPRESSION, expression_constant_p(), expression_null_p(), expression_syntax, expression_to_string(), is_syntax_call, is_syntax_reference, NIL, null_pointer_value_entity_p(), pips_assert, pips_internal_error, reference_variable, semantics_user_warning, syntax_call, syntax_reference, syntax_tag, type_variable, and variable_basic.
Referenced by pointer_binary_operation_to_transformer().
|
static |
Maybe move in ri-util/expression.c or in effect-util/pointer_values.c.
search in an arithmetic pointer expression if the pointer NULL is present
expr | arithmetic expression to scan |
Definition at line 4268 of file expression.c.
References call_arguments, call_function, CAR, CDR, ENTITY_MULTIPLY_P, EXPRESSION, expression_syntax, expression_to_string(), is_syntax_call, is_syntax_reference, NIL, pips_assert, pips_internal_error, reference_variable, sizeof_value_entity_p(), syntax_call, syntax_reference, and syntax_tag.
Referenced by pointer_binary_operation_to_transformer().
|
static |
expr | assumed to be a value |
Definition at line 1693 of file expression.c.
References dump_transformer, entity_type, free_transformer(), ifdebug, integer_expression_to_transformer(), make_local_temporary_value_entity(), pips_debug, transformer_identity(), transformer_inequality_add(), transformer_safe_image_intersection(), VALUE_MONE, VALUE_ONE, vect_add_elem(), and vect_new().
Referenced by integer_unary_operation_to_transformer().
|
static |
Prologue more or less necessary for all non affine operators
post1 == pre2...
Case disjunction to use only positive intervals + sign information
either t1 or t2 is undefined: so tf is most likely undefined
Old function call
Definition at line 3274 of file expression.c.
References addition_operation_to_transformer(), assign_operation_to_transformer(), copy_transformer(), ENTITY_ASSIGN_P, ENTITY_C_MODULO_P, ENTITY_DIVIDE_P, ENTITY_LEFT_SHIFT_P, ENTITY_MINUS_C_P, ENTITY_MINUS_P, ENTITY_MINUS_UPDATE_P, ENTITY_MODULO_P, ENTITY_MULTIPLY_P, ENTITY_PLUS_C_P, ENTITY_PLUS_P, ENTITY_PLUS_UPDATE_P, ENTITY_POWER_P, ENTITY_RIGHT_SHIFT_P, entity_type, get_bool_property(), integer_divide_to_transformer(), integer_left_shift_to_transformer(), integer_multiply_to_transformer(), integer_power_to_transformer(), integer_right_shift_to_transformer(), integer_value_and_precondition_to_integer_interval(), make_local_temporary_value_entity(), modulo_to_transformer(), pips_debug, process_bounds_for_divide(), safe_integer_expression_to_transformer(), transformer_apply(), transformer_combine(), transformer_empty(), transformer_empty_p(), transformer_identity(), transformer_range(), transformer_safe_apply(), transformer_undefined, transformer_undefined_p, and update_operation_to_transformer().
Referenced by integer_call_expression_to_transformer(), and logical_binary_function_to_transformer().
|
static |
tests are organized to trap 0-ary user-defined functions as well as binary min and max
FI: should only happen for C code because int are often used as bool since there was no other way before C99. Quite time consuming here because it is applied to an int and not a bool argument.
FI: it might be useful to handle here the bit wise XOR as in logical_binary_operation_to_transformer().
No need to use effects here. It will be done at a higher level
integer constant must have been detected earlier as linear (affine) expressions but there might be nullary intrinsic such as rand()
pre | needed to compute effects for user calls |
is_internal | Predicate on current store assumed not modified by expr's side effects |
Definition at line 3361 of file expression.c.
References any_conditional_to_transformer(), any_expressions_to_transformer(), bitwise_xor_to_transformer(), call_arguments, call_function, CAR, CDR, constant_path_analyzed_p(), ENTITY_BITWISE_XOR_P, ENTITY_C_MAX_P, ENTITY_C_MIN_P, ENTITY_C_MODULO_P, ENTITY_COMMA_P, ENTITY_CONDITIONAL_P, ENTITY_FIELD_P, entity_initial, ENTITY_MAX0_P, ENTITY_MAX_P, ENTITY_MIN0_P, ENTITY_MIN_P, ENTITY_MODULO_P, ENTITY_NOT_P, ENTITY_POINT_TO_P, ENTITY_RAND_P, EXPRESSION, expression_syntax, f(), gen_length(), get_bool_property(), integer_binary_operation_to_transformer(), integer_nullary_operation_to_transformer(), integer_unary_operation_to_transformer(), lhs_expression_to_transformer(), logical_not_to_transformer(), max0_to_transformer(), min0_to_transformer(), modulo_to_transformer(), pips_debug, SEMANTICS_INTERPROCEDURAL, syntax_call, transformer_add_inequality_with_integer_constraint(), transformer_identity(), transformer_undefined, user_function_call_to_transformer(), value_code_p, and VALUE_ZERO.
Referenced by integer_expression_to_transformer().
|
static |
More could be done along the line of integer_multiply_to_transformer()...
when need arises.
pips_assert("Precondition is unused", transformer_undefined_p(pre));
must be duplicated right now because it will be renamed and checked at the same time by value_mappings_compatible_vector_p()
Definition at line 1780 of file expression.c.
References bool_to_string(), contrainte_make(), CONTRAINTE_UNDEFINED, dump_transformer, ifdebug, int_to_value, integer_constant_expression_p(), integer_constant_expression_value(), make_predicate(), make_transformer(), NIL, NORMALIZE_EXPRESSION, normalized_linear, normalized_linear_p, pips_assert, pips_debug, sc_make(), Scontrainte::succ, TCST, transformer_undefined, value_mappings_compatible_vector_p(), VALUE_MONE, vect_add_elem(), vect_dup(), and vect_multiply().
Referenced by integer_binary_operation_to_transformer().
transformer integer_expression_to_transformer | ( | entity | v, |
expression | expr, | ||
transformer | pre, | ||
bool | is_internal | ||
) |
Do check wrt to value mappings...
if you are not dealing with interprocedural issues
Assume: e is a value
Is it really useful to keep using this function which does not take the precondition into acount?
vect_rm(ve);
expr | xpr |
pre | re |
is_internal | s_internal |
Definition at line 3476 of file expression.c.
References cast_expression, cast_type, constant_int, constant_int_p, copy_transformer(), EvalSizeofexpression(), expression_effects_to_transformer(), expression_syntax, expression_to_type(), free_transformer(), free_type(), generic_reference_to_transformer(), get_bool_property(), ifdebug, integer_call_expression_to_transformer(), NORMALIZE_EXPRESSION, normalized_linear, normalized_linear_p, pips_debug, print_expression(), simple_affine_to_transformer(), syntax_call_p, syntax_cast, syntax_cast_p, syntax_reference, syntax_reference_p, syntax_sizeofexpression, syntax_sizeofexpression_p, transformer_add_equality_with_integer_constant(), transformer_combine(), transformer_identity(), transformer_undefined, transformer_undefined_p, type_equal_p(), value_constant, and value_constant_p.
Referenced by any_expression_to_transformer(), iabs_to_transformer(), integer_expression_and_precondition_to_integer_interval(), integer_minmax_to_transformer(), and safe_integer_expression_to_transformer().
|
static |
Assumes that e1 and e2 are integer expressions, i.e.
explicit casting is supposed to be used.
This piece of code has been copied and pasted from integer_multiply_to_transformer(). Common issues like evaluating the intervals for the values of the arguments should be factored out.
FI: I had to switch the arguments to satisfy a reasonnable assert in image_intersection(), but the switch may be detrimental to memory allocation.
The numerical value of expression e2 is known: v = v1*2^lb2
lb2<0
The value of v belongs to a bounded interval
Definition at line 2303 of file expression.c.
References dump_transformer, entity_type, free_transformer(), ifdebug, intptr_t, make_local_temporary_value_entity(), pips_debug, precondition_minmax_of_value(), safe_integer_expression_to_transformer(), transformer_add_equality_with_integer_constant(), transformer_add_inequality(), transformer_add_inequality_with_affine_term(), transformer_add_inequality_with_integer_constraint(), transformer_apply(), transformer_equality_add(), transformer_identity(), transformer_inequality_add(), transformer_range(), transformer_safe_apply(), transformer_undefined, transformer_undefined_p, value_lshift, VALUE_MONE, VALUE_ONE, vect_add_elem(), and vect_new().
Referenced by integer_binary_operation_to_transformer().
|
static |
args | alue for minmax |
Definition at line 2655 of file expression.c.
References CAR, dump_transformer, ENDP, entity_type, EXPRESSION, free_transformer(), ifdebug, int, integer_expression_to_transformer(), intptr_t, is_min, make_local_temporary_value_entity(), MAX, MIN, pips_debug, POP, precondition_minmax_of_expression(), transformer_add_inequality_with_integer_constraint(), transformer_identity(), transformer_inequality_add(), transformer_safe_image_intersection(), VALUE_MONE, VALUE_ONE, vect_add_elem(), vect_multiply(), and vect_new().
Referenced by max0_to_transformer(), and min0_to_transformer().
|
static |
Assumes that e1 and e2 are integer expressions, i.e.
explicit casting is supposed to be used Better results might be obtained when e1 is an affine function of e2 or vice-versa as can occur when convex hulls generate coupling between variables. See non_linear11.f, 22L1=9L2+40, 1<=L1<=10. The smallest possible value is -2 and not -20.
FI: I had to switch the arguments to satisfy a reasonnable assert in image_intersection(), but the switch may be detrimental to memory allocation.
The numerical value of expression e1 is known: v = lb1*v2
The numerical value of expression e2 is known: v = lb2*v1
FI: This should now be obsolete... but it is not when the signs are unknown
Do we have range information?
let's try to exploit some properties of squaring, but the detection is poor. For instance 2*i*i won't be identified as a square.
let's assume no impact from side effects
v is greater than v1 and -v1. This makes v>=0 redundant
Memory leak with tf...
The result is always positive: v>=0
v is less than v1 and -v1. This makes v<=0 redundant
Memory leak with tf...
The result is always negative: v<=0
The result is always positive: v>=0
The result is always negative: v<=0
Definition at line 1880 of file expression.c.
References copy_transformer(), dump_transformer, entity_type, expression_equal_p(), expression_opposite_p(), free_transformer(), ifdebug, integer_value_and_precondition_to_integer_interval(), make_local_temporary_value_entity(), pips_debug, safe_integer_expression_to_transformer(), TCST, transformer_add_inequality(), transformer_add_inequality_with_affine_term(), transformer_add_inequality_with_linear_term(), transformer_apply(), transformer_combine(), transformer_empty_p(), transformer_equality_add(), transformer_identity(), transformer_inequality_add(), transformer_intersection(), transformer_normalize(), transformer_range(), transformer_safe_apply(), transformer_undefined, transformer_undefined_p, VALUE_MONE, VALUE_ONE, VALUE_ZERO, vect_add_elem(), and vect_new().
Referenced by integer_binary_operation_to_transformer(), and pointer_binary_operation_to_transformer().
|
static |
FI: this function is no longer useful (11 August 2013)
rand() returns an integer between 0 and RAND_MAX. See Semantics/rand01.c
How do you make sure that RAND_MAX is the same for the analyzed code and for the analyzer?
NL already parse by the function which call him (integer_call_expression_to_transformer) if (ENTITY_RAND_P(f)) { tf = transformer_add_inequality_with_integer_constraint(transformer_identity(), e, 0, true); }
Definition at line 2856 of file expression.c.
References transformer_undefined.
Referenced by integer_call_expression_to_transformer().
|
static |
Should be rewritten using expression_to_transformer and expression evaluation as in integer_multiply_to_transformer
pips_assert("Precondition is unused", transformer_undefined_p(pre));
Is arg1 bounded? constant?
Is arg2 bounded? constant?
1 is assigned unless arg1 equals 0... which is neglected
Does not work because unary minus is not seen as part of a constant
The expression value must be greater or equal to arg2 and positive
must be duplicated right now because it will be renamed and checked at the same time by value_mappings_compatible_vector_p()
d is negative and even
d is negative, arg1 cannot be 0, expression value is -1, 0 or 1
0 or 1 is assigned unless arg2 equals 0... which is neglected
e >= d^lb2
e <= d^lb2
the assigned value is positive
The assigned value is 1 or -1
Definition at line 2444 of file expression.c.
References contrainte_make(), CONTRAINTE_UNDEFINED, dump_transformer, exponentiate(), free_transformer(), ifdebug, int, int_to_value, intptr_t, make_predicate(), make_transformer(), NIL, NORMALIZE_EXPRESSION, normalized_linear, normalized_linear_p, pips_assert, pips_debug, precondition_minmax_of_expression(), sc_make(), Scontrainte::succ, TCST, transformer_add_equality_with_integer_constant(), transformer_add_inequality_with_integer_constraint(), transformer_identity(), transformer_inequality_add(), transformer_range(), transformer_undefined, transformer_undefined_p, VALUE_MONE, VALUE_ONE, vect_add_elem(), vect_dup(), vect_multiply(), and vect_new().
Referenced by integer_binary_operation_to_transformer().
|
static |
More could be done along the line of integer_left_shift_to_transformer()...
when need arises.
pips_assert("Precondition is unused", transformer_undefined_p(pre));
must be duplicated right now because it will be renamed and checked at the same time by value_mappings_compatible_vector_p()
Definition at line 1827 of file expression.c.
References bool_to_string(), contrainte_make(), CONTRAINTE_UNDEFINED, dump_transformer, ifdebug, integer_constant_expression_p(), integer_constant_expression_value(), make_predicate(), make_transformer(), NIL, NORMALIZE_EXPRESSION, normalized_linear, normalized_linear_p, pips_assert, pips_debug, sc_make(), Scontrainte::succ, TCST, transformer_undefined, value_lshift, value_mappings_compatible_vector_p(), VALUE_MONE, VALUE_ONE, vect_add_elem(), vect_dup(), and vect_multiply().
Referenced by integer_binary_operation_to_transformer().
|
static |
Definition at line 2880 of file expression.c.
References ENTITY_C_ABS_P, ENTITY_IABS_P, ENTITY_LABS_P, ENTITY_LLABS_P, generic_unary_operation_to_transformer(), iabs_to_transformer(), transformer_undefined, and transformer_undefined_p.
Referenced by integer_call_expression_to_transformer().
transformer lhs_expression_to_transformer | ( | entity | e, |
expression | lhs, | ||
transformer | pre | ||
) |
This function deals with e1.e2 and e1->e2, not with simple references such as x or a[i].
This piece of code has mainly been retrieved from any_assign_to_transformer().
FI: I am not sure how to factorize it out because entity e corresponds to some memory location and is modified in an assignement environment. Here, e is likely to be a temporary value. It is not updated. It should not appear among the transformer arguments
lhs | hs |
pre | re |
Definition at line 6262 of file expression.c.
References analyzed_reference_p(), CELL, cell_any_reference(), constant_memory_access_path_to_location_entity(), constant_path_analyzed_p(), copy_transformer(), cp, entity_undefined_p, expression_syntax, FOREACH, free_transformer(), gen_length(), int, pips_internal_error, pt_to_list_undefined_p(), semantics_expression_to_points_to_sources(), semantics_usable_points_to_reference_p(), syntax_call_p, transformer_add_equality(), transformer_convex_hull(), transformer_undefined, and transformer_undefined_p.
Referenced by integer_call_expression_to_transformer().
|
static |
FI: slight signature mismatch: no need to propagate the call once you know it is a binary operator...
Non internal overloaded functions such as EQ, NEQ, GE, GT, LE, LT,...
if the transformer is not feasible, return false
if the transformer is not feasible, return true
general case due to C convention about integers equal to 0 or not.
if v is in [0..1], v can be used as such. else if v>0, return 1 else if v<0, return 1 else 0<=v<=1
Definition at line 3769 of file expression.c.
References assign_operation_to_transformer(), b1, b2, basic_logical_p, basic_of_expression(), call_arguments, call_function, CAR, CDR, contrainte_make(), CONTRAINTE_UNDEFINED, copy_transformer(), ENTITY_AND_P, ENTITY_ASSIGN_P, ENTITY_BITWISE_AND_P, ENTITY_BITWISE_OR_P, ENTITY_BITWISE_XOR_P, ENTITY_EQUAL_P, ENTITY_NON_EQUAL_P, ENTITY_OR_P, ENTITY_RELATIONAL_OPERATOR_P, eq, EXPRESSION, free_basic(), free_transformer(), integer_binary_operation_to_transformer(), intptr_t, logical_binary_operation_to_transformer(), make_predicate(), make_transformer(), NIL, precondition_minmax_of_value(), sc_make(), TCST, transformer_add_any_relation_information(), transformer_add_equality_with_integer_constant(), transformer_add_inequality_with_integer_constraint(), transformer_empty_p(), transformer_identity(), transformer_normalize(), transformer_undefined, transformer_undefined_p, VALUE_MONE, VALUE_ONE, vect_add_elem(), and vect_new().
Referenced by logical_intrinsic_to_transformer().
|
static |
v <= tmp1, v <= tmp2, v >= tmp1+tmp2-1
v >= tmp1, v>= tmp2, v <= tmp1+tmp2
v >= 1-tmp1-tmp2, v >= tmp1+tmp2-1, i.e. -v -tmp1 -tmp2 + 1 <= 0, -v+tmp1+tmp2-1<=0 v <= 1-tmp1+tmp2, v <= 1+tmp1-tmp2, i.e. v + tmp1 - tmp2 - 1 <= 0, v - tmp1 + tmp2 - 1 <=0
v <= tmp1+tmp2, v <= 2-tmp1-tmp2, i.e. v - tmp 1 - tmp 2 <= 0, v -tmp1-tmp2 -2 <= 0 v >= tmp1 - tmp2, v >= -tmp1+tmp2, i.e. -v + tmp1 - tmp2 <=0, -v - tmp1 + tmp2 <=0
Definition at line 3641 of file expression.c.
References call_arguments, call_function, CAR, CDR, dump_transformer, ENTITY_AND_P, ENTITY_BITWISE_XOR_P, ENTITY_EQUAL_P, entity_name, ENTITY_NON_EQUAL_P, ENTITY_OR_P, entity_type, EXPRESSION, free_transformer(), ifdebug, logical_expression_to_transformer(), make_local_temporary_value_entity(), pips_debug, pips_internal_error, TCST, transformer_inequality_add(), transformer_logical_inequalities_add(), transformer_safe_intersection(), transformer_undefined_p, VALUE_MONE, VALUE_ONE, vect_add_elem(), vect_new(), VECTEUR_NUL, and VECTEUR_NUL_P.
Referenced by logical_binary_function_to_transformer().
|
static |
Definition at line 3583 of file expression.c.
References contrainte_make(), CONTRAINTE_UNDEFINED, ENTITY_FALSE_P, entity_name, ENTITY_ONE_P, ENTITY_TRUE_P, ENTITY_ZERO_P, eq, f(), make_predicate(), make_transformer(), NIL, pips_internal_error, sc_make(), TCST, transformer_undefined, VALUE_MONE, VALUE_ONE, vect_add_elem(), and vect_new().
Referenced by logical_intrinsic_to_transformer().
transformer logical_expression_to_transformer | ( | entity | v, |
expression | rhs, | ||
transformer | pre, | ||
bool | is_internal | ||
) |
Could be used to compute preconditions too.
v is assumed to be a new value or a temporary value.
Is likely to be handled as a nullary intrinsics
rhs | hs |
pre | re |
is_internal | s_internal |
Definition at line 3938 of file expression.c.
References call_constant_p(), call_function, expression_syntax, f(), integer_constant_p(), intrinsic_entity_p(), is_syntax_call, is_syntax_range, is_syntax_reference, logical_constant_p(), logical_intrinsic_to_transformer(), logical_reference_to_transformer(), pips_internal_error, reference_variable, syntax_call, syntax_reference, syntax_tag, transformer_add_equality_with_integer_constant(), transformer_identity(), transformer_intersection(), transformer_undefined, transformer_undefined_p, and user_function_call_to_transformer().
Referenced by any_expression_to_transformer(), logical_binary_operation_to_transformer(), and logical_unary_operation_to_transformer().
transformer logical_intrinsic_to_transformer | ( | entity | v, |
call | c, | ||
transformer | pre, | ||
bool | is_internal | ||
) |
pre | re |
is_internal | s_internal |
Definition at line 3911 of file expression.c.
References call_arguments, call_function, entity_name, gen_length(), logical_binary_function_to_transformer(), logical_constant_to_transformer(), logical_unary_operation_to_transformer(), pips_internal_error, and transformer_undefined.
Referenced by logical_expression_to_transformer().
transformer logical_not_to_transformer | ( | entity | v, |
list | args, | ||
transformer | pre | ||
) |
returns the transformer associated to a C logical not, !, applied to an integer argument, when meaningful, and transformer_undefined otherwise.
Effects must be used at a higher level to fall back on a legal transformer.
v | is the value associated to the expression |
args | is assumed to have only one expression element of type int or enum negated by ! |
pre | is the current precondition |
args | rgs |
pre | re |
Definition at line 5571 of file expression.c.
References CAR, EXPRESSION, free_transformer(), intptr_t, make_local_temporary_integer_value_entity(), precondition_minmax_of_value(), safe_any_expression_to_transformer(), transformer_add_equality_with_integer_constant(), transformer_add_inequality_with_integer_constraint(), transformer_range(), and transformer_undefined.
Referenced by integer_call_expression_to_transformer().
|
static |
v is assumed to be a temporary value and r a logical program variable
Definition at line 3894 of file expression.c.
References entity_has_values_p(), entity_to_new_value(), external_entity_to_new_value(), simple_equality_to_transformer(), transformer_logical_inequalities_add(), and transformer_undefined.
Referenced by logical_expression_to_transformer().
|
static |
pips_assert("A unique argument", ENDP(CDR(call_arguments(c))));
Definition at line 3607 of file expression.c.
References call_arguments, call_function, CAR, ENTITY_NOT_P, entity_type, eq, EXPRESSION, generic_unary_operation_to_transformer(), logical_expression_to_transformer(), make_local_temporary_value_entity(), semantics_user_warning, TCST, transformer_equality_add(), transformer_logical_inequalities_add(), transformer_undefined, transformer_undefined_p, VALUE_MONE, VALUE_ONE, vect_add_elem(), and vect_new().
Referenced by logical_intrinsic_to_transformer().
|
static |
Definition at line 2728 of file expression.c.
References integer_minmax_to_transformer().
Referenced by integer_call_expression_to_transformer(), and pointer_call_expression_to_transformer().
|
static |
Definition at line 2720 of file expression.c.
References integer_minmax_to_transformer().
Referenced by integer_call_expression_to_transformer(), and pointer_call_expression_to_transformer().
transformer modulo_by_a_constant_to_transformer | ( | entity | v1, |
transformer | prec, | ||
entity | v2, | ||
int | k | ||
) |
Analyze v2 % k, with v2 constrainted by tf, assuming tf is a precondition.
See if exist a set v_i such that v2 = sum_i a_i v_i + c. Then v2 can be rewritten as v2 = gcd_i(a_i) lambda + c.
if k divides gcd(a_i) then v2>0 ? v1 = v2 % k = c % k : v1 = v2 % k = ck-k
If the sign of v2 is unknown, ck-k<=v1<=ck
v1 | 1 |
prec | rec |
v2 | 2 |
Definition at line 1481 of file expression.c.
References empty_transformer(), intptr_t, precondition_minmax_of_value(), transformer_add_equality_with_integer_constant(), transformer_add_inequality_with_integer_constraint(), transformer_identity(), and transformer_to_1D_lattice().
Referenced by modulo_to_transformer().
|
static |
Since arg1 is a constant, ub1=lb1
The first argument is numerically known
r == 0 not matter what
A floating point exception is going to be raised
The result is known: r = lb1 % lb2 if lb2!=0
The second argument is negative: lb1>0? r>=0, r<= ub1, r<=-lb2-1 : r<=0, -ub1<=r, r>= lb2+1
the modulo has no impact r=ub1=lb1
r>=0, r<= ub1, r<=-lb2-1
the modulo has no impact r=ub1=lb1
r<=0, -ub1<=r, r>= lb2+1
The second argument is positive: lb1>0? r>=0, r<= ub1, r<=ub2-1 : r<=0, -ub1<=r, -ub2+1<=r
the modulo has no impact r=ub1=lb1
r>=0, r<= ub1, r<=-lb2-1
r>=0, r<= ub1, r<=ub2-1
the modulo has no impact r=ub1=lb1
r<=0, -ub1<=r, -ub2+1<=r
no information is available on the second argument: the sign of the first argument is preserved
Definition at line 1278 of file expression.c.
References semantics_user_warning, transformer_add_equality_with_integer_constant(), transformer_add_inequality_with_integer_constraint(), transformer_empty(), transformer_identity(), and transformer_undefined.
Referenced by modulo_to_transformer().
|
static |
e = [lb1,ub1] % [lb2,ub2] with ub1<=0
arg1 is negative, hence r is always negative: r<=0
the modulo is the identity: lb1<=r<=ub1
arg2 is negative: r>=arg2, r>= lb2+1
the modulo is the identity: lb1<=r<=ub1
arg2 is positive: r<=-arg2+1, r<= -lb2+1
No information is available on arg2: r<=0
Definition at line 1374 of file expression.c.
References transformer_add_inequality_with_integer_constraint(), transformer_identity(), and transformer_undefined.
Referenced by modulo_to_transformer().
|
static |
arg1 is positive, hence r is always positive: r>=0
the modulo is the identity: lb1<=r<=ub1
arg2 is negative: 0<=r<=-arg2+1, 0<=r<= -ub2+1
the modulo is the identity: lb1<=r<=ub1
arg2 is positive: 0<=r<=arg2-1, 0<=r<= ub2-1
No information is available on arg2: r>=0
Definition at line 1424 of file expression.c.
References transformer_add_inequality_with_integer_constraint(), transformer_identity(), and transformer_undefined.
Referenced by modulo_to_transformer().
|
static |
Modulo and integer division.
Apparently identical in both C and Fortran
C Fortran
a b mod div mod div 3 2 1 1 1 -3 2 -1 -1 -1 3 -2 1 -1 1 -3 -2 -1 1 -1
FI: only implemented for positive dividends. Same for integer division, I believe. Side effects are probably ignored.
FI: to be improved by using expression_to_transformer() and the precondition pre.
FI: to be improved by using the lattice information in the equations of the precondition.
cut-and-pasted and adapted from multiply_to_transformer(); also useful for divide; the side effects of the two arguments and the derivation of the preconditions and the computation of the numerical bounds should be factorized in one function.
Let's get rid of the exception case right away
A floating point exception is going to be raised
No sign information available about arg1
arg2 is positive: -ub2+1<=r<=ub2-1
arg2 is negative: lb2+1<=r<=-lb2-1
Might be as good to leave it undefined... for the time being. Information about either arg1 or arg2 could be used
Take care of side effects: tf = tf1 o tf2 o tf3
arg1 | assumed to be an integer value |
__attribute__ | not used yet |
Definition at line 1580 of file expression.c.
References dump_transformer, entity_to_expression(), expression_and_precondition_to_integer_interval(), free_expression(), free_transformer(), ifdebug, make_local_temporary_integer_value_entity(), modulo_by_a_constant_to_transformer(), modulo_of_a_constant_to_transformer(), modulo_of_a_negative_value_to_transformer(), modulo_of_a_positive_value_to_transformer(), pips_debug, safe_any_expression_to_transformer(), semantics_user_warning, transformer_add_inequality_with_integer_constraint(), transformer_apply(), transformer_combine(), transformer_empty(), transformer_identity(), transformer_identity_p(), transformer_range(), transformer_undefined, and transformer_undefined_p.
Referenced by integer_binary_operation_to_transformer(), and integer_call_expression_to_transformer().
|
static |
Definition at line 4415 of file expression.c.
References addition_operation_to_transformer(), assign_operation_to_transformer(), call_arguments, call_function, CAR, CDR, ENTITY_ASSIGN_P, ENTITY_MINUS_C_P, ENTITY_MINUS_P, ENTITY_MINUS_UPDATE_P, ENTITY_MULTIPLY_P, entity_name, ENTITY_PLUS_C_P, ENTITY_PLUS_P, ENTITY_PLUS_UPDATE_P, EXPRESSION, expression_multiply_sizeof_to_transformer(), expression_syntax, expression_to_string(), have_null_value_in_pointer_expression_p(), have_sizeof_value_in_multiply_pointer_expression_p(), integer_multiply_to_transformer(), pips_debug, pips_user_error, semantics_user_warning, syntax_call, transformer_empty(), and transformer_undefined.
Referenced by pointer_call_expression_to_transformer().
|
static |
tests are organized to trap 0-ary user-defined functions as well as binary min and max
pre | needed to compute effects for user calls |
is_internal | Predicate on current store assumed not modified by expr's side effects |
Definition at line 4495 of file expression.c.
References any_conditional_to_transformer(), any_expressions_to_transformer(), call_arguments, call_function, CAR, CDR, ENTITY_C_MIN_P, ENTITY_COMMA_P, ENTITY_CONDITIONAL_P, entity_initial, ENTITY_MAX0_P, ENTITY_MAX_P, ENTITY_MIN0_P, ENTITY_MIN_P, entity_name, EXPRESSION, expression_multiply_sizeof_to_transformer(), expression_syntax, f(), gen_length(), get_bool_property(), max0_to_transformer(), min0_to_transformer(), pips_debug, pointer_binary_operation_to_transformer(), pointer_unary_operation_to_transformer(), SEMANTICS_INTERPROCEDURAL, semantics_user_warning, syntax_call, transformer_undefined, user_function_call_to_transformer(), and value_code_p.
Referenced by pointer_expression_to_transformer().
transformer pointer_expression_to_transformer | ( | entity | v, |
expression | expr, | ||
transformer | pre, | ||
bool | is_internal | ||
) |
This function may return an undefined transformers if it fails to capture the semantics of expr in the polyhedral framework. cf any_expression_to_transformer which call it
v | value of the expression |
expr | pointer expression |
pre | transformer, no side effect |
is_internal | ?? use in generic_reference_to_transformer |
Assume: v is a value
expr | xpr |
pre | re |
is_internal | s_internal |
Definition at line 4582 of file expression.c.
References basic_pointer_p, cast_expression, cast_type, compute_basic_concrete_type(), ENDP, entity_type, expression_multiply_sizeof_to_transformer(), expression_null_p(), expression_syntax, expression_to_type(), free_transformer(), free_type(), generic_reference_to_transformer(), ifdebug, is_syntax_call, is_syntax_cast, is_syntax_reference, null_pointer_value_entity(), pips_debug, pointer_call_expression_to_transformer(), print_expression(), reference_variable, semantics_user_warning, simple_equality_to_transformer(), syntax_cast, syntax_reference, syntax_tag, transformer_intersection(), transformer_undefined, transformer_undefined_p, type_equal_p(), type_variable, type_variable_p, variable_basic, variable_dimensions, and volatile_variable_p().
Referenced by any_expression_to_transformer().
|
static |
FI: Oops, the precondition is lost here! See any_basic_update_to_transformer()
is_internal | Predicate on current store assumed not modified by expr's side effects |
Definition at line 4316 of file expression.c.
References any_basic_update_operation_to_transformer(), call_function, constant_memory_access_path_to_location_entity(), ENTITY_ADDRESS_OF_P, ENTITY_DEREFERENCING_P, ENTITY_FIELD_P, entity_has_values_p(), entity_name, ENTITY_POINT_TO_P, ENTITY_POST_DECREMENT_P, ENTITY_POST_INCREMENT_P, ENTITY_PRE_DECREMENT_P, ENTITY_PRE_INCREMENT_P, ENTITY_UNARY_MINUS_P, entity_undefined_p, expression_syntax, free_transformer(), generic_unary_operation_to_transformer(), pips_internal_error, reference_variable, s1, simple_equality_to_transformer(), syntax_call, syntax_call_p, syntax_reference, syntax_reference_p, syntax_tag, transformer_combine(), transformer_identity(), transformer_intersection(), transformer_range(), transformer_undefined, transformer_undefined_p, and unary_minus_operation_to_transformer().
Referenced by pointer_call_expression_to_transformer().
transformer points_to_unary_operation_to_transformer | ( | entity | e, |
entity | op, | ||
expression | e1, | ||
transformer | pre, | ||
bool | is_internal, | ||
bool | is_pointer | ||
) |
This function is redundant with generic_unary_operation_to_transformer() except for its use of parameter is_pointer.
op | p |
e1 | 1 |
pre | re |
is_internal | s_internal |
is_pointer | s_pointer |
Definition at line 2770 of file expression.c.
References active_phase_p(), analyzed_reference_p(), CELL, cell_preference, cell_preference_p, cell_reference, cp, dump_transformer, ENTITY_DEREFERENCING_P, ENTITY_FIELD_P, entity_null_locations_p(), ENTITY_POINT_TO_P, entity_typed_nowhere_locations_p(), expression_to_string(), FOREACH, free_transformer(), gen_length(), generic_reference_to_transformer(), get_bool_property(), ifdebug, pips_debug, pips_user_error, preference_reference, pt_to_list_undefined_p(), reference_to_string(), reference_variable, semantics_expression_to_points_to_sinks(), semantics_user_warning, test_warning_counters(), transformer_convex_hull(), transformer_empty(), transformer_undefined, and transformer_undefined_p.
transformer precondition_add_condition_information | ( | transformer | pre, |
expression | c, | ||
transformer | context, | ||
bool | veracity | ||
) |
context might be derivable from pre as transformer_range(pre) but this is sometimes very computationally intensive, e.g.
in ocean.
pre | re |
context | ontext |
veracity | eracity |
Definition at line 1111 of file expression.c.
References ENDP, free_transformer(), reset_temporary_value_counter(), transformer_add_condition_information_updown(), transformer_arguments, transformer_range(), transformer_temporary_value_projection(), transformer_undefined, and transformer_undefined_p.
Referenced by dag_to_flow_sensitive_preconditions(), eval_condition_wrt_precondition_p(), load_arc_precondition(), process_ready_node(), standard_whileloop_to_transformer(), transformer_add_range_condition(), unstructured_to_postconditions(), whileloop_to_postcondition(), and whileloop_to_total_precondition().
bool precondition_minmax_of_expression | ( | expression | exp, |
transformer | tr, | ||
intptr_t * | pmin, | ||
intptr_t * | pmax | ||
) |
compute integer bounds pmax
, pmin
of expression exp
under preconditions tr
require value mappings set !
create a temporary value
compute its preconditions
tidy & return
exp | xp |
tr | r |
pmin | min |
pmax | max |
Definition at line 5818 of file expression.c.
References basic_of_expression(), exp, free_basic(), free_entity(), free_transformer(), make_local_temporary_value_entity_with_basic(), precondition_minmax_of_value(), predicate_system, safe_any_expression_to_transformer(), transformer_apply(), and transformer_relation.
Referenced by bounds_of_expression(), integer_minmax_to_transformer(), integer_power_to_transformer(), partial_eval_min_or_max_operator(), and simplify_minmax_expression().
bool precondition_minmax_of_value | ( | entity | val, |
transformer | tr, | ||
intptr_t * | pmin, | ||
intptr_t * | pmax | ||
) |
compute integer bounds pmax
, pmin
of value val
under preconditions tr
require value mappings set !
retrieve the associated psysteme
compute min / max bounds
special case to handle VMIN and VMAX in 32 bits
val | al |
tr | r |
pmin | min |
pmax | max |
Definition at line 5790 of file expression.c.
References intptr_t, pips_assert, predicate_system, sc_dup(), sc_minmax_of_variable(), transformer_relation, VALUE_MAX, and VALUE_MIN.
Referenced by add_type_information(), bitwise_xor_to_transformer(), integer_left_shift_to_transformer(), logical_binary_function_to_transformer(), logical_not_to_transformer(), modulo_by_a_constant_to_transformer(), and precondition_minmax_of_expression().
|
static |
Auxiliary function for non-affine operators such as divide, multiply, modulo...
Returns an equivalent set of interval products whose bounds are always positive plus some information about the global sign for the result. For instance, [-3,4] x [-5,6] is broken down into four products:
For division, 0 is excluded and the positive intervals start at 1 instead of 0.
Intervals may be empty: [1,0]. DEAD CODE static void break_intervals_into_positive_intervals(int lb1, int ub1, int lb2, int ub2, struct interval_product cases[4], int * pncase, bool exclude_zero_p) { We need a pair of macros to process -MAX_INT and -MIN_INT, MINUS_UPPER_BOUND and MINUS_LOWER_BOUND, because of the disymetry in the encoding of integers
int nlb = exclude_zero_p? 1 : 0; if(false) { pncase = 0; if(lb1>=0) { The first interval is positive if(lb2>=0) { pncase = 1; cases[0].lb1 = lb1, cases[0].ub1 = ub1, cases[0].lb2 = lb2, cases[0].ub2 = ub2, cases[0].positive_p = true; } else if(ub2<=0) { pncase = 1; cases[0].lb1 = lb1, cases[0].ub1 = ub1, cases[0].lb2 = -ub2, cases[0].ub2 = -lb2, cases[0].positive_p = false; } else { The second interval must be broken into two sub-intervals pncase = 2; cases[0].lb1 = lb1, cases[0].ub1 = ub1, cases[0].lb2 = 1, cases[0].ub2 = -lb2, cases[0].positive_p = false; cases[1].lb1 = lb1, cases[1].ub1 = ub1, cases[1].lb2 = nlb, cases[1].ub2 = ub2, cases[1].positive_p = true; } } else if(ub1<=0) { The first interval is negative if(lb2>=0) { pncase = 1; cases[0].lb1 = -ub1, cases[0].ub1 = -lb1, cases[0].lb2 = lb2, cases[0].ub2 = ub2, cases[0].positive_p = false; } else if(ub2<=0) { pncase = 1; cases[0].lb1 = -ub1, cases[0].ub1 = -lb1, cases[0].lb2 = -ub2, cases[0].ub2 = -lb2, cases[0].positive_p = true; } else { The second interval must be broken into two sub-intervals pncase = 2; cases[0].lb1 = -ub1, cases[0].ub1 = -lb1, cases[0].lb2 = 1, cases[0].ub2 = -lb2, cases[0].positive_p = true; cases[1].lb1 = -ub1, cases[1].ub1 = -lb1, cases[1].lb2 = nlb, cases[0].ub2 = ub2, cases[1].positive_p = false; } } else { The first interval must be broken into two sub-intervals if(lb2>=0) { pncase = 2; cases[0].lb1 = 1, cases[0].ub1 = -lb1, cases[0].lb2 = lb2, cases[0].ub2 = ub2, cases[0].positive_p = false; cases[1].lb1 = nlb, cases[1].ub1 = ub1, cases[1].lb2 = lb2, cases[1].ub2 = ub2, cases[1].positive_p = true; } else if(ub2<=0) { pncase = 2; cases[0].lb1 = 1, cases[0].ub1 = -lb1, cases[0].lb2 = -ub2, cases[0].ub2 = -lb2, cases[0].positive_p = true; cases[1].lb1 = 1, cases[1].ub1 = ub1, cases[1].lb2 = -ub2, cases[1].ub2 = -lb2, cases[1].positive_p = false; } else { The second interval must be broken into two sub-intervals pncase = 4; cases[0].lb1 = 1, cases[0].ub1 = -lb1, cases[0].lb2 = 1, cases[0].ub2 = -lb2, cases[0].positive_p = true; cases[1].lb1 = nlb, cases[1].ub1 = ub1, cases[1].lb2 = 1, cases[1].ub2 = -lb2, cases[1].positive_p = false; cases[2].lb1 = 1, cases[2].ub1 = -lb1, cases[2].lb2 = nlb, cases[2].ub2 = ub2, cases[2].positive_p = false; cases[3].lb1 = nlb, cases[3].ub1 = ub1, cases[3].lb2 = nlb, cases[3].ub2 = ub2, cases[3].positive_p = true; } } } else { if(lb2>=0) { pncase = 1; cases[0].lb1 = 1, cases[0].ub1 = 1, cases[0].lb2 = lb2, cases[0].ub2 = ub2, cases[0].positive_p = true; } else if(ub2<=0) { pncase = 1; cases[0].lb1 = 1, cases[0].ub1 = 1, cases[0].lb2 = -ub2, cases[0].ub2 = -lb2, cases[0].positive_p = false; } else { The v2 interval must be broken into two sub-intervals pncase = 2; cases[0].lb1 = 1, cases[0].ub1 = 1, cases[0].lb2 = 1, cases[0].ub2 = -lb2, cases[0].positive_p = false; cases[1].lb1 = 1, cases[1].ub1 = 1, cases[1].lb2 = nlb, cases[1].ub2 = ub2, cases[1].positive_p = true; } } } Equation v = v1/v2 for v1>=0 and v2>=0: v1-v2+1 <= v2 v <= v1
We know positive bounds [lb1,ub1] for v1 and [lb2,ub2] for v2. What do we know about v?
v1-v2+1 <= v2 v <= v1
The only non-affine term is v2 v:
v1-v2+1 <= ub2 v => -ub2 v + v1 - v2 + 1 <= 0 lb2 v <= v1 => lb2 v -v1 <= 0
If -v must be used instead of v:
v1-v2+1 <= -ub2 v => ub2 v <= v2-v1-1 => ub2 v + v1 - v2 + 1 <= 0 -lb2 v <= v1 => lb2 v >= v1 => -lb2 v -v1 <= 0
Else, we can also eliminate v1 and v2 everywhere. Substitute v1 thanks to lb1 <= v1 <= ub1: lb1-v2+1 <= v2 v <= ub1 Substitue the left v2 in the same way: lb1-ub2+1 <= v2 v <= ub1 If lb2==ub2, v2 v is an affine term. Else substitue the central v2 for each inequality: lb2 v <= ub1 => v<= ub1/lb2 lb1-ub2+1 <=ub2 v => v>= lb1/ub2
if the positive flag is not set, v must be replaced by -v: -ub2 v <= ub1 => v>=-ub1/lb2 lb1-ub2+1<=-lb2 v => v<=-lb1/ub2 DEAD CODE static transformer process_interval_for_divide( entity v, entity v1, entity v2, struct interval_product one_case) { long long int lb1 = one_case.lb1; long long int ub1 = one_case.ub1; long long int lb2 = one_case.lb2; long long int ub2 = one_case.ub2; bool positive_p = one_case.positive_p; Two possible options: true and false bool full_elimination = false; transformer itf = transformer_identity(); // no information at first
if(full_elimination) { if(ub1 != INT_MAX && lb2 != INT_MAX) { if(positive_p) itf = transformer_add_inequality_with_integer_constraint(itf, v, ub1/lb2, true); else itf = transformer_add_inequality_with_integer_constraint(itf, v, -(ub1/lb2), false); }
if(lb1 != INT_MAX && ub2 != INT_MAX && lb2 != INT_MAX) { if(positive_p) itf = transformer_add_inequality_with_integer_constraint(itf, v, lb1/ub2, false); else itf = transformer_add_inequality_with_integer_constraint(itf, v, -(lb1/ub2), true); } } else { Minimize the number of substitutions:
If v is positive because v1>=0 and v2 >=0
v1 = v2 v + x ^ 0<=x<=v2-1 if v1 >= 0 && v2 >= 0 v1 <= v2 v + v2 -1 ^ v1>= v2 v ^ lb2 <= v2 <= ub2 v1-v2+1 <= ub2 v => -ub2 v + v1 - v2 + 1 <= 0 lb2 v <= v1 => lb2 v -v1 <= 0
If v is negative because v1 <=0 and v2 >=0:
v1 = v2 v + x ^ -v2+1<=x<=0 if v1 <= 0 && v2 >= 0 v1 <= v2 v ^ v1>= v2 v - v2 + 1 v1 <= lb2 v => -lb2 v + v1 <= 0 ub2 v -v2 +1 <= v1 => ub2 v -v1 -v2 + 1 <= 0
If v2 <= 0, use -v2 and -v1? if(positive_p) { itf = transformer_add_3d_affine_constraint(itf, -ub2, v, 1, v1, -1, v2, 1, false); itf = transformer_add_3d_affine_constraint(itf, lb2, v, -1, v1, 0, v2, 0, false); } else { itf = transformer_add_3d_affine_constraint(itf, ub2, v, 1, v1, -1, v2, 1, false); itf = transformer_add_3d_affine_constraint(itf, -lb2, v, -1, v1, 0, v2, 0, false); } }
return itf; }
static transformer process_intervals_for_divide( transformer tf, entity v, entity v1, entity v2, struct interval_product cases[4], int ncase) { int i; transformer dtf = transformer_empty();
if(false) { Perform the convex hull before the intersection is faster but less accurate in general, maybe not when v1 and v2 have been fully eliminated. for(i=0; i<ncase; i++) { transformer itf = process_interval_for_divide(v, v1, v2, cases[i]); dtf = transformer_convex_hull(dtf, itf); } To be checked for functionality and memory leaks tf = transformer_image_intersection(tf, dtf); } else { for(i=0; i<ncase; i++) { transformer itf = process_interval_for_divide(v, v1, v2, cases[i]); transformer ctf = transformer_combine(copy_transformer(tf), itf); free_transformer(itf); memory leak transformer ndtf = transformer_convex_hull(dtf, ctf); free_transformer(dtf); free_transformer(ctf); dtf = ndtf; } To be checked for functionality and memory leaks tf = dtf; }
return tf; } The equation v1 = v2 v + r is always true. But we need to eliminate the remainder r which is implicit and to linearize the product v2 v to obtain affine constraints of v, v1, v2, using constant lb1, ub1, lb2 and ub2, with lb1 <= v1 <= ub1 and lb2 <= v2 <=ub2.
v2 is positive and r is positive: 0 <= r <= v2 - 1 v1 = v2 v + r v1 <= v2 v + v2 - 1 v1 >= v2 v lb2 <= v2 <= ub2 => lb2 v <= v2 v <= ub2 v => v1 <= ub2 v + v2 -1 => -ub2 v + v1 - v2 + 1 <= 0 => v1 >= lb2 v => lb2 v - v1 <=0
v2 is positive and r is negative: -v2 + 1 <= r <= 0 v1 = v2 v + r v1 <= v2 v
v1 >= v2 v - v2 + 1 lb2 <= v2 <= ub2 => ub2 v <= v2 v <= lb2 v => v1 <= lb2 v => -lb2 v + v1 <= 0 => v1 >= ub2 v -v2 + 1 => ub2 v - v1 -v2 + 1 <=0
v2 is positive and r is bounded: -v2 + 1 <= r <= v2 - 1 v1 = v2 v + r v1 <= v2 v + v2 - 1 v1 >= v2 v - v2 + 1 I do not know how to linearize v2 v, unless v2 is a constant, but v1/v2 can be bounded: lb1 <= v1 <= ub1 => lb1/v2 <= v1/v2 <= ub1/v2 => lb1/lb2 <= v <= ub1/lb2
Also, when v2 is a numerical constant, if exists x s.t. v1 == v2 x, then v == x. This is not exploited here.
v2 is negative and r is positive: 0 <= r <= -v2 - 1 v1 = v2 v + r v1 <= v2 v - v2 - 1 v1 >= v2 v lb2 <= v2 <= ub2 => ub2 v <= v2 v <= lb2 v (since v is negative) => v1 <= lb2 v - v2 -1 => -lb2 v + v1 + v2 + 1 <= 0 => v1 >= ub2 v => ub2 v - v1 <=0
v2 is negative and r is negative: v2 + 1 <= r <= 0 v1 = v2 v + r v1 <= v2 v
v1 >= v2 v + v2 + 1 lb2 <= v2 <= ub2 => lb2 v <= v2 v <= ub2 v (since v is positive) => v1 <= ub2 v => -ub2 v + v1 <= 0 => v1 >= lb2 v + v2 + 1 => lb2 v - v1 + v2 + 1 <=0
v2 is negative and r is bounded: v2 + 1 <= r <= -v2 - 1 v1 = v2 v + r v1 <= v2 v - v2 - 1 => -v2 v + v1 + v2 + 1 <= 0 v1 >= v2 v + v2 + 1 => v2 v - v1 + v2 + 1 <=0 I do not know how to linearize v2 v, but v1/v2 can be bounded: lb1 <= v1 <= ub1 => lb1/v2 >= v1/v2 >= ub1/v2 => ub1/ub2 <= v <= lb1/ub2
We are left with dividing interval [lb1, ub1] by interval [lb2, ub2] knowing that lb1 and lb2 are negative and ub1 and ub2 positive. Since 1 and -1 belongs to [lb2, ub2], the upper bound is max(ub1, -lb1) and the lower bound is min(-ub1, lb1).
Definition at line 3141 of file expression.c.
References free_transformer(), semantics_user_warning, transformer_add_3d_affine_constraint(), and transformer_empty().
Referenced by integer_binary_operation_to_transformer().
transformer safe_any_assign_operation_to_transformer | ( | entity | tmp, |
list | args, | ||
transformer | pre, | ||
bool | is_internal | ||
) |
tmp | mp |
args | rgs |
pre | arguments for assign |
is_internal | precondition |
Definition at line 575 of file expression.c.
References any_assign_operation_to_transformer(), transformer_identity(), and transformer_undefined_p.
transformer safe_any_expression_side_effects_to_transformer | ( | expression | e, |
transformer | p, | ||
bool | is_internal | ||
) |
Same as any_expression_side_effects_to_transformer() but effects are used to always generate a transformer.
FI: I do not know how effects should be used. It might be useful to allow special transformers using location abstraction to simplify the recurrence. Currently, effects are used or not. It might be necessary to use only some of them at a given time in the evaluation process as variables can be assigned almost anywhere in C.
is_internal | s_internal |
Definition at line 4947 of file expression.c.
References any_expression_side_effects_to_transformer(), expression_effects_to_transformer(), and transformer_undefined_p.
transformer safe_any_expression_to_transformer | ( | entity | v, |
expression | expr, | ||
transformer | pre, | ||
bool | is_internal | ||
) |
Always return a usable transformer.
Use effects if no better transformer can be found
expr | xpr |
pre | re |
is_internal | s_internal |
Definition at line 5156 of file expression.c.
References any_expression_to_transformer(), copy_transformer(), effect_list_can_be_safely_full_freed_p(), effects_to_transformer(), expression_to_proper_constant_path_effects(), free_transformer(), gen_full_free_list(), transformer_identity(), and transformer_undefined_p.
Referenced by add_index_bound_conditions(), addition_operation_to_transformer(), any_conditional_to_transformer(), any_expressions_to_transformer(), any_user_call_site_to_transformer(), bitwise_xor_to_transformer(), condition_to_transformer(), fortran_data_to_prec_for_variables(), logical_not_to_transformer(), modulo_to_transformer(), precondition_minmax_of_expression(), transformer_add_any_relation_information(), and update_cp_with_rhs_to_transformer().
transformer safe_expression_to_transformer | ( | expression | exp, |
transformer | pre | ||
) |
This simple function does not take points-to information into account. Furthermore, precise points-to information is not available when side effects occur as in comma expressions.
FI: I do not see a simple way out. I can try to fix partly the problem in statement_to_transformer where the effects are known... Or I can play safer and use an effect function that replaces dereferencements by anywhere effects.
See anywhere03.c as an example of the issue.
exp | xp |
pre | re |
Definition at line 5307 of file expression.c.
References entity_field_p(), exp, expression_reference(), expression_reference_p(), expression_to_proper_constant_path_effects(), expression_to_transformer(), gen_full_free_list(), reference_variable, transformer_identity(), transformer_undefined, and transformer_undefined_p.
Referenced by any_assign_to_transformer(), any_expressions_to_transformer(), assign_rhs_to_reflhs_to_transformer(), complete_forloop_transformer(), complete_forloop_transformer_list(), condition_to_transformer(), conditional_to_transformer(), dimensions_to_transformer(), expression_to_transformer(), expressions_to_transformer(), forloop_to_postcondition(), forloop_to_transformer(), and struct_reference_assignment_or_equality_to_transformer().
transformer safe_integer_expression_to_transformer | ( | entity | v, |
expression | expr, | ||
transformer | pre, | ||
bool | is_internal | ||
) |
Always return a defined transformer, using effects in case a more precise analysis fails.
Do check wrt to value mappings... if you are not dealing with interprocedural issues
expr | xpr |
pre | re |
is_internal | s_internal |
Definition at line 3552 of file expression.c.
References expression_effects_to_transformer(), integer_expression_to_transformer(), and transformer_undefined_p.
Referenced by expression_multiply_sizeof_to_transformer(), integer_binary_operation_to_transformer(), integer_left_shift_to_transformer(), integer_multiply_to_transformer(), loop_to_enter_transformer(), and transformer_add_condition_information_updown().
Assimilate enum and logical to int (used when they appear in logical operations)
FI: Might be useful quite often in semantics... but forces the programmer to use tags of basic instead of basic variables.
Definition at line 4670 of file expression.c.
References basic_derived, basic_tag, entity_type, is_basic_derived, is_basic_int, is_basic_logical, and type_enum_p.
Referenced by transformer_add_any_relation_information().
bool semantics_usable_points_to_reference_p | ( | reference | rlhs, |
expression | lhs, | ||
int | n | ||
) |
See if references rlhs is usable and process null, undefined and anywhere locations defined by rlhs.
Expression lhs is passed to clarify the error and warning messages.
n is the number of alternative references. It is used to check the severity of unusable references. If n=1, a NULL rlhs implies a bug. If n>1, the points-to analysis could not determine precisely the target location.
This function is designed to check constant references in a loop over a list of references returned by the points-to analysis.
A heap location may represent several locations. p==heap ^ q==heap does not imply p==q
An anywhere location may represent several locations. p==heap ^ q==heap does not imply p==q
rlhs | lhs |
lhs | hs |
Definition at line 6194 of file expression.c.
References analyzed_type_p(), entity_anywhere_locations_p(), entity_heap_location_p(), entity_null_locations_p(), entity_typed_anywhere_locations_p(), entity_typed_nowhere_locations_p(), expression_to_string(), expression_undefined_p, ifdebug, pips_debug, pips_user_error, points_to_reference_to_concrete_type(), reference_to_string(), reference_variable, semantics_user_warning, type_struct_variable_p(), and type_variable_p.
Referenced by any_assign_to_transformer(), generic_unary_operation_to_transformer(), lhs_expression_to_transformer(), new_array_elements_backward_substitution_in_transformer(), new_array_elements_forward_substitution_in_transformer(), and struct_reference_assignment_or_equality_to_transformer().
transformer simple_affine_to_transformer | ( | entity | e, |
Pvecteur | a, | ||
bool | is_internal | ||
) |
INTEGER EXPRESSIONS.
FI: I do no longer understand the semantics of "is_internal"... although I designed it. The intent was probably to manage temporary values: they should be preserved as long as the analysis is internal and else projected.
Furthermore, this function is no longer very useful as normalization can be performed dynamically again and again at a low cost.
The renaming from variables in a to new values in ve and vexpr is performed as a side-effect by value_mappings_compatible_vector_p() which fails when a renaming fails.
This is very dangerous when is_internal==false
is_internal | s_internal |
Definition at line 1167 of file expression.c.
References bool_to_string(), contrainte_make(), CONTRAINTE_UNDEFINED, dump_transformer, eq, ifdebug, make_predicate(), make_transformer(), NIL, pips_debug, sc_make(), transformer_undefined, value_mappings_compatible_vector_p(), VALUE_ONE, vect_dump(), vect_dup(), vect_new(), vect_rm(), vect_substract(), and VECTEUR_NUL.
Referenced by integer_expression_to_transformer().
int simplify_boolean_expression_with_precondition | ( | expression | e, |
transformer | p | ||
) |
Simplification of bool expressions with precondition.
Expression e is modified, if necessary, by side effect.
The value returned is 1 if the expression e is always true (never false) under condition p, 0 if is the expression is always false (never true), and -1 otherwise.
This function is not used within the semantics library. It is exported for partial_eval and suppress_dead_code or similar passes.
Because of C flexibility, all kinds of "boolean" expressions may arise. Think of the conditional and comma operators, think of all kinds of side effects, think of integer expressions,...
FI: In the short term, I only need to deal with bool operators and, or and not.
Definition at line 6080 of file expression.c.
References call_arguments, call_function, CAR, CDR, condition_to_transformer(), copy_expression(), ENTITY_AND_P, ENTITY_NOT_P, ENTITY_OR_P, EXPRESSION, expression_syntax, logical_operator_expression_p(), make_false_expression(), make_true_expression(), replace_expression_content(), syntax_call, and transformer_empty_p().
void simplify_minmax_expression | ( | expression | e, |
transformer | tr | ||
) |
tries hard to simplify expression e
if it is a min or a max operator, by evaluating it under preconditions tr
.
Two approaches are tested: check bounds of lhs-rhs, or compare bounds of lhs and rhs
tr | r |
Definition at line 5849 of file expression.c.
References binary_call_lhs, binary_call_rhs, call_function, copy_expression(), ENTITY_MAX_P, expression_call(), expression_minmax_p(), intptr_t, is_max, local_assign_expression(), make_op_exp(), MINUS_OPERATOR_NAME, and precondition_minmax_of_expression().
Referenced by do_array_expansion(), do_solve_hardware_constraints_on_nb_proc(), and region_to_minimal_dimensions().
transformer string_expression_to_transformer | ( | entity | v, |
expression | rhs | ||
) |
tf = constant_to_transformer(v, call_function(syntax_call(srhs)));
rhs | hs |
Definition at line 3994 of file expression.c.
References basic_string_p, basic_to_string(), call_arguments, call_function, constant_to_transformer(), entity_has_values_p(), entity_name, entity_to_new_value(), entity_type, expression_syntax, gen_length(), is_syntax_call, is_syntax_range, is_syntax_reference, pips_internal_error, pips_user_error, reference_variable, simple_equality_to_transformer(), string_type_size(), syntax_call, syntax_reference, syntax_tag, transformer_undefined, type_variable, and variable_basic.
Referenced by any_expression_to_transformer().
|
static |
FI: this is a bit confusing because of aliasing conditions. The second condition is added after the first one was analyzed and the "and" effect is enforced by side effect
This is equivalent to allocating copies of pre and then computing their intersection.
This is useful when computing transformers in context
use precondition pre and hope than the convex hull won't destroy all information
compute !(c1&&c2) as !c1 || !c2
might be possible to add a convex hull on the initial values as in !upwards
Definition at line 727 of file expression.c.
References bool_to_string(), DEBUG_TRANSFORMER_ADD_CONDITION_INFORMATION_UPDOWN, dump_transformer, free_transformer(), ifdebug, pips_debug, transformer_add_condition_information_updown(), transformer_convex_hull(), transformer_dup(), and transformer_undefined.
Referenced by transformer_add_call_condition_information_updown().
transformer transformer_add_any_relation_information | ( | transformer | pre, |
entity | op, | ||
expression | e1, | ||
expression | e2, | ||
transformer | context, | ||
bool | veracity, | ||
bool | upwards | ||
) |
compute transformer or precondition
This is not satisfactory: when going upwards you might nevertheless benefit from some precondition information. But you would then need to pass two transformers as argument: a context transformer and a to-be-modified transformer
context = upwards? transformer_undefined : pre;
context = transformer_range(pre);
Logical are represented by integer values
PIPS does not represent negative constants: call to unary_minus
PIPS does not represent complex constants: call to CMPLX
Only constant string are processed
Pointer analysis
This is not correct if side effects occur in e1 or e2
This is very complicated to add constraints from tf1, tf2 and rel in pre!
tf1 may modify the initial context. See w10.f
tf1 disappears into cond
try to break rel it into two convex components
pre disappears into newpre2
pre disappears into newpre
newpre stays undefined or newpre is pre
free_transformer(tf1); already gone
Nothing to be done with struct and union
pre may be unchanged when no information is derived
pre | re |
op | precondition |
e1 | 1 |
e2 | 2 |
context | ontext |
veracity | eracity |
upwards | the relation is true or not |
Definition at line 4686 of file expression.c.
References b1, b2, basic_of_expression(), basic_tag, ENTITY_EQUAL_P, entity_name, ENTITY_NON_EQUAL_P, free_basic(), free_transformer(), GREATER_THAN_OPERATOR_NAME, is_basic_bit, is_basic_complex, is_basic_derived, is_basic_float, is_basic_int, is_basic_logical, is_basic_overloaded, is_basic_pointer, is_basic_string, is_basic_typedef, LESS_THAN_OPERATOR_NAME, local_name_to_top_level_entity(), make_local_temporary_value_entity_with_basic(), pips_assert, pips_debug, pips_internal_error, relation_to_transformer(), safe_any_expression_to_transformer(), semantics_basic_tag(), semantics_user_warning, transformer_apply(), transformer_argument_consistency_p(), transformer_combine(), transformer_convex_hull(), transformer_dup(), transformer_free(), transformer_identity(), transformer_normalize(), transformer_range(), transformer_safe_combine_with_warnings(), transformer_safe_image_intersection(), transformer_undefined, and transformer_undefined_p.
Referenced by logical_binary_function_to_transformer(), and transformer_add_call_condition_information_updown().
|
static |
do not know what to do with other logical operators, for the time being! keep pre unmodified
FI: two problems, you can bump into arithmetic operators and you can have side effects as in i++
Minimal service: use effects
Definition at line 882 of file expression.c.
References bool_to_string(), CAR, CDR, dump_transformer, ENDP, ENTITY_AND_P, ENTITY_FALSE_P, ENTITY_NOT_P, ENTITY_ONE_P, ENTITY_OR_P, ENTITY_RELATIONAL_OPERATOR_P, ENTITY_TRUE_P, ENTITY_ZERO_P, EXPRESSION, expression_effects_to_transformer(), expression_undefined, FOREACH, free_transformer(), ifdebug, module_local_name(), pips_debug, transformer_add_anded_conditions_updown(), transformer_add_any_relation_information(), transformer_add_condition_information_updown(), transformer_add_ored_conditions_updown(), transformer_combine(), transformer_empty(), and transformer_undefined.
Referenced by transformer_add_condition_information_updown().
transformer transformer_add_condition_information | ( | transformer | pre, |
expression | c, | ||
transformer | context, | ||
bool | veracity | ||
) |
pre | re |
context | ontext |
veracity | eracity |
Definition at line 1092 of file expression.c.
References reset_temporary_value_counter(), transformer_add_condition_information_updown(), and transformer_temporary_value_projection().
Referenced by check_condition_wrt_precondition(), old_complete_whileloop_transformer(), and transformer_add_domain_condition().
|
static |
call transformer_add_condition_information_updown() recursively on both sub-expressions if veracity == true; else try your best...
Non-convex information can be made convex when moving postcondition downwards because some of the parts introducing non-convexity may be made empty by the pre-existing precondition.
This is not true for transformers computed upwards, although conditions on initial values could also be added. Let's wait for a case which would prove this useful.
Argument pre is modified and may or not be returned as newpre. It may also be freed and newpre allocated. In other words, argument "pre" should not be used after a call to this function and the returned value alswayd used.
default option: no condition can be added
A logical variable must be referenced in Fortran. Any variable can be referenced in C.
information may be lost
ignore cast (should be a boolean cast...)
Definition at line 961 of file expression.c.
References basic_int_p, basic_logical_p, basic_overloaded_p, bool_to_string(), call_arguments, call_function, cast_expression, copy_basic(), DEBUG_TRANSFORMER_ADD_CONDITION_INFORMATION_UPDOWN, dump_transformer, ENTITY_FALSE_P, entity_has_values_p(), ENTITY_LOGICAL_OPERATOR_P, ENTITY_ONE_P, entity_to_new_value(), ENTITY_TRUE_P, entity_type, ENTITY_ZERO_P, eq, expression_effects_to_transformer(), expression_syntax, expression_to_type(), f(), fprintf(), free_basic(), free_transformer(), functional_result, ifdebug, is_syntax_call, is_syntax_cast, is_syntax_range, is_syntax_reference, is_syntax_subscript, make_local_temporary_integer_value_entity(), pips_debug, pips_internal_error, print_expression(), reference_variable, safe_integer_expression_to_transformer(), syntax_call, syntax_cast, syntax_reference, syntax_tag, TCST, transformer_add_call_condition_information_updown(), transformer_add_equality_with_integer_constant(), transformer_apply(), transformer_empty(), transformer_equality_add(), transformer_inequality_add(), type_functional, type_variable, ultimate_type(), VALUE_MONE, VALUE_ONE, variable_basic, vect_add_elem(), vect_multiply(), and vect_new().
Referenced by condition_to_transformer(), precondition_add_condition_information(), transformer_add_anded_conditions_updown(), transformer_add_call_condition_information_updown(), transformer_add_condition_information(), and transformer_add_ored_conditions_updown().
transformer transformer_add_domain_condition | ( | transformer | tf, |
expression | c, | ||
transformer | context, | ||
bool | veracity | ||
) |
tf | f |
context | ontext |
veracity | eracity |
Definition at line 1138 of file expression.c.
References transformer_add_condition_information().
Referenced by test_to_total_precondition().
transformer transformer_add_integer_relation_information | ( | transformer | pre, |
entity | relop, | ||
expression | e1, | ||
expression | e2, | ||
bool | veracity, | ||
bool | upwards | ||
) |
It is supposed to be obsolete but is still called.
Maybe, it's only partly obsolete... If upwards is false, it is worth performing more convex hulls because the precondition on entry may restrain the space. upwards = transformer, !upwards = precondition
default: no change
both expressions e1 and e2 must be affine
Make sure that new values only are used in v1 and v2
v1 - v2 == 0
v2 - v1 + 1 <= 0 ou v1 - v2 + 1 <= 0
FI: I do not know if this is valid when your are moving upwards variables in v2 and v1 may have to be renamed as init values (i.e. old values)
FI: I think that this should be programmed (see comment above) but I'm waiting for a bug to occur... (6 July 1993)
FI: Well, the bug was eventually seen:-) (8 November 1995)
free_transformer(prea);
free_transformer(preb);
v2 - v1 + 1 <= 0
v1 - v2 <= 0
v2 - v1 <= 0
v1 - v2 + 1 <= 0
do nothing... although Malik may have tried harder!
do nothing, although MODULO and INTEGER DIVIDE could be handled
pre | re |
relop | elop |
e1 | 1 |
e2 | 2 |
veracity | eracity |
upwards | pwards |
Definition at line 5929 of file expression.c.
References bool_to_string(), DEBUG_TRANSFORMER_ADD_RELATION_INFORMATION, ENTITY_EQUAL_P, ENTITY_GREATER_OR_EQUAL_P, ENTITY_GREATER_THAN_P, ENTITY_LESS_OR_EQUAL_P, ENTITY_LESS_THAN_P, entity_local_name(), ENTITY_NON_EQUAL_P, fprintf(), ifdebug, NORMALIZE_EXPRESSION, normalized_linear, normalized_linear_p, pips_assert, pips_debug, print_expression(), print_transformer, TCST, transformer_convex_hull(), transformer_dup(), transformer_equality_add(), transformer_inequality_add(), transformer_internal_consistency_p(), upwards_vect_rename(), value_mappings_compatible_vector_p(), VALUE_ONE, variables_to_new_values(), vect_add_elem(), vect_dup(), vect_rm(), and vect_substract().
|
static |
call transformer_add_condition_information_updown() recursively on both sub-expressions if veracity == false; else try to do your best...
Should be fused with the .AND. case?!? Careful with veracity...
compute !(c1||c2) as !c1 && !c2
compute (c1||c2) as such
might be possible to add a convex hull on the initial values as in !upwards
Definition at line 820 of file expression.c.
References bool_to_string(), DEBUG_TRANSFORMER_ADD_CONDITION_INFORMATION_UPDOWN, dump_transformer, free_transformer(), ifdebug, pips_debug, transformer_add_condition_information_updown(), transformer_convex_hull(), transformer_dup(), and transformer_undefined.
Referenced by transformer_add_call_condition_information_updown().
transformer transformer_add_range_condition | ( | transformer | tf, |
expression | c, | ||
transformer | context, | ||
bool | veracity | ||
) |
tf | f |
context | ontext |
veracity | eracity |
Definition at line 1147 of file expression.c.
References precondition_add_condition_information().
transformer transformer_logical_inequalities_add | ( | transformer | tf, |
entity | v | ||
) |
PROCESSING OF LOGICAL EXPRESSIONS.
the values of v are between 0 and 1
tf | f |
Definition at line 3569 of file expression.c.
References TCST, transformer_inequality_add(), VALUE_MONE, VALUE_ONE, vect_add_elem(), and vect_new().
Referenced by logical_binary_operation_to_transformer(), logical_reference_to_transformer(), and logical_unary_operation_to_transformer().
bool true_condition_wrt_precondition_p | ( | expression | c, |
transformer | pre | ||
) |
pre | re |
Definition at line 5900 of file expression.c.
References eval_condition_wrt_precondition_p().
Referenced by whileloop_to_postcondition(), and whileloop_to_total_precondition().
|
static |
Type independent.
Most of it should be factored out for unary operations.
sub-expressions are not necessarily integer? Then the expression should not be integer?
Much too early: you are in between recursive calls!
tf = transformer_temporary_value_projection(tf);
Definition at line 288 of file expression.c.
References any_expression_to_transformer(), dump_transformer, entity_local_name(), entity_type, free_transformer(), ifdebug, make_local_temporary_value_entity(), pips_debug, simple_unary_minus_to_transformer(), transformer_safe_intersection(), and transformer_undefined.
Referenced by generic_unary_operation_to_transformer(), and pointer_unary_operation_to_transformer().
|
static |
v = (e1 = e1 op e2) ; e1 must be a reference; does not compute information for dereferenced pointers such as in "*p += 2;"
sub-expressions are not necessarily integer? Then the expression should not be integer?
We assume that the update operation is syntactically correct
Effects are used at a higher level
ef,
Too early: you are projecting v and loosing all useful information within an expression!
tf = transformer_temporary_value_projection(tf);
Definition at line 590 of file expression.c.
References any_assign_operation_to_transformer(), CONS, copy_expression(), dump_transformer, entity_local_name(), entity_type, EXPRESSION, expression_reference_p(), expression_syntax, free_expression(), gen_free_list(), ifdebug, make_local_temporary_value_entity(), MakeBinaryCall(), NIL, pips_debug, reference_variable, syntax_reference, transformer_add_equality(), transformer_undefined, transformer_undefined_p, and update_operator_to_regular_operator().
Referenced by integer_binary_operation_to_transformer().