PIPS
basic.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include "vecteur.h"
#include "contrainte.h"
#include "sc.h"
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "misc.h"
#include "ri-util.h"
#include "effects-util.h"
#include "transformer.h"
+ Include dependency graph for basic.c:

Go to the source code of this file.

Macros

#define TRANSFORMER_CONSISTENCY_P_DEBUG_LEVEL   0
 

Functions

transformer transformer_dup (transformer t_in)
 transformer package - basic routines More...
 
void transformer_free (transformer t)
 
void free_transformers (transformer t,...)
 
void old_transformer_free (transformer t)
 
transformer transformer_identity ()
 Allocate an identity transformer. More...
 
transformer transformer_empty ()
 Allocate an empty transformer. More...
 
transformer empty_transformer (transformer t)
 Do not allocate an empty transformer, but transform an allocated transformer into an empty_transformer. More...
 
bool transformer_identity_p (transformer t)
 Check that t is an identity function. More...
 
bool transformer_is_empty_p (transformer t)
 Check that transformer t is the canonical representation of an empty transformer. More...
 
bool transformer_is_rn_p (transformer t)
 Check that transformer t is the canonical representation of the whole afine space defined by its basis. More...
 
transformer transformer_add_sign_information (transformer tf, entity v, int v_sign)
 CHANGE THIS NAME: no loop index please, it's not directly linked to loops!!! More...
 
transformer transformer_add_variable_incrementation (transformer t, entity i, Pvecteur incr)
 transformer transformer_add_loop_index(transformer t, entity i, Pvecteur incr): add the index incrementation expression incr for loop index i to transformer t. More...
 
transformer transformer_add_variable_update (transformer t, entity v)
 Add an update of variable v into t. More...
 
transformer transformer_add_value_update (transformer t, entity v)
 Add an update of variable v to t (a value cannot be updated) More...
 
transformer transformer_add_variables_update (transformer t, list vl)
 
transformer transformer_constraint_add (transformer tf, Pvecteur i, bool equality)
 
transformer transformer_inequality_add (transformer tf, Pvecteur i)
 
transformer transformer_equality_add (transformer tf, Pvecteur i)
 
transformer transformer_equalities_add (transformer tf, Pcontrainte eqs)
 
transformer transformer_inequalities_add (transformer tf, Pcontrainte ineqs)
 Warning: More...
 
transformer transformer_add_identity (transformer tf, entity v)
 
transformer transformer_add_equality (transformer tf, entity v1, entity v2)
 Add an equality between two values (two variables?) More...
 
transformer transformer_add_equality_with_integer_constant (transformer tf, entity v, long long int cst)
 Add an equality between a value and an integer constant: v==cst. More...
 
transformer transformer_add_inequality (transformer tf, entity v1, entity v2, bool strict_p)
 Add the equality v1 <= v2 or v1 < v2. More...
 
transformer transformer_add_inequality_with_integer_constraint (transformer tf, entity v, long long int cst, bool less_than_p)
 Add the inequality v <= cst or v >= cst. More...
 
transformer transformer_add_inequality_with_affine_term (transformer tf, entity v, entity x, int a, int cst, bool less_than_p)
 Add the inequality v <= a x + cst or v >= a x + cst. More...
 
transformer transformer_add_equality_with_affine_term (transformer tf, entity v, entity x, int a, int cst)
 Add the equality v = a x + cst. More...
 
transformer transformer_add_inequality_with_linear_term (transformer tf, entity v, entity x, int a, bool less_than_p)
 Add the inequality v <= a x or v >= a x. More...
 
transformer transformer_add_3d_affine_constraint (transformer tf, int a1, entity v1, int a2, entity v2, int a3, entity v3, int cst, bool equation_p)
 Add the constraint a1 v1 + a2 v2 + a3 v3 + cst <= or == 0. More...
 
bool transformer_argument_consistency_p (transformer t)
 
bool transformer_argument_weak_consistency_p (transformer t)
 
bool transformer_argument_general_consistency_p (transformer t, bool is_weak)
 
bool transformer_consistency_p (transformer t)
 FI: I do not know if this procedure should always return or fail when an inconsistency is found. More...
 
bool transformers_consistency_p (list tl)
 
bool transformer_weak_consistency_p (transformer t)
 Interprocedural transformers do not meet all conditions. More...
 
bool transformer_general_consistency_p (transformer tf, bool is_weak)
 
bool transformer_internal_consistency_p (transformer t)
 Same as above but equivalenced variables should not appear in the argument list or in the predicate basis. More...
 
list transformer_projectable_values (transformer tf)
 
bool value_belongs_to_transformer_space (entity v, transformer tf)
 
void add_value_to_transformer_space (entity v, transformer tf)
 
transformer precondition_to_abstract_store (transformer pre)
 Get rid of all old values and arguments. More...
 
transformer transformer_add_modified_variable (transformer tf, entity var)
 FI: this function does not end up with a consistent transformer because the old value is not added to the basis of sc. More...
 
transformer transformer_add_modified_variable_entity (transformer tf, entity var)
 FI: like the previous function, but supposed to end up with a consistent transformer. More...
 
transformer move_transformer (transformer t1, transformer t2)
 Move arguments and predicate of t2 into t1, free old arguments and predicate of t1, free what's left of t2. More...
 
bool transformer_equations_constrain_variable_p (const transformer t, const entity v)
 Is value v used with a non-zero coefficient by the equations of transformer t? More...
 
bool transformer_inequalities_constrain_variable_p (const transformer t, const entity v)
 Is value v used with a non-zero coefficient by the inequalities of transformer t? More...
 

Macro Definition Documentation

◆ TRANSFORMER_CONSISTENCY_P_DEBUG_LEVEL

#define TRANSFORMER_CONSISTENCY_P_DEBUG_LEVEL   0

Function Documentation

◆ add_value_to_transformer_space()

void add_value_to_transformer_space ( entity  v,
transformer  tf 
)
Parameters
tff

Definition at line 859 of file basic.c.

860 {
863  return;
864 }
#define transformer_relation(x)
Definition: ri.h:2873
#define predicate_system(x)
Definition: ri.h:2069
void sc_base_add_variable(Psysteme sc, Variable var)
Definition: sc.c:248
void * Variable
arithmetique is a requirement for vecteur, but I do not want to inforce it in all pips files....
Definition: vecteur-local.h:60

References predicate_system, sc_base_add_variable(), and transformer_relation.

Referenced by transformer_add_variable_type_information().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ empty_transformer()

transformer empty_transformer ( transformer  t)

Do not allocate an empty transformer, but transform an allocated transformer into an empty_transformer.

Pretty dangerous because the predicate contained in t may have been deleted before empty_transformer is called. It is not clear that the predicate of t can be freed or not: it is up to the caller to be aware of the problem.

This function is risky to use. It can cause either a memory leak if the predicate is not freed, or a double free if the pointer in the transformer is already dangling. If the predicate has already been freed during some processing at the linear level, the caller must update the pointer transformer_relation(t) with:

transformer_relation(t) = relation_undefined;

before the call.

Definition at line 144 of file basic.c.

145 {
150  return t;
151 }
predicate make_predicate(Psysteme a1)
Definition: ri.c:1820
void free_predicate(predicate p)
Definition: ri.c:1787
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#define transformer_arguments(x)
Definition: ri.h:2871
Psysteme sc_empty(Pbase b)
Psysteme sc_empty(Pbase b): build a Psysteme with one unfeasible constraint to define the empty subsp...
Definition: sc_alloc.c:319
#define BASE_NULLE
MACROS SUR LES BASES.

References BASE_NULLE, free_predicate(), gen_free_list(), make_predicate(), NIL, sc_empty(), transformer_arguments, and transformer_relation.

Referenced by modulo_by_a_constant_to_transformer(), statement_to_postcondition(), transformer_combine(), transformer_convex_hulls(), transformer_projection_with_redundancy_elimination_and_check(), and whileloop_to_postcondition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ free_transformers()

void free_transformers ( transformer  t,
  ... 
)

Analyze in args the variadic arguments that may be after t:

Since a variadic function in C must have at least 1 non variadic argument (here the s), just skew the varargs analysis:

Get the next argument:

Release the variadic analyzis:

Definition at line 73 of file basic.c.

73  {
74  va_list args;
75 
76  /* Analyze in args the variadic arguments that may be after t: */
77  va_start(args, t);
78  /* Since a variadic function in C must have at least 1 non variadic
79  argument (here the s), just skew the varargs analysis: */
80  do {
82  /* Get the next argument: */
83  t = va_arg(args, transformer);
84  } while(t!=NULL);
85  /* Release the variadic analyzis: */
86  va_end(args);
87 }
void free_transformer(transformer p)
Definition: ri.c:2616

References free_transformer().

Referenced by loop_to_enter_transformer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ move_transformer()

transformer move_transformer ( transformer  t1,
transformer  t2 
)

Move arguments and predicate of t2 into t1, free old arguments and predicate of t1, free what's left of t2.

This is used to perform a side effect on an argument when a function allocates a new transformer to return a result. t2 should not be used after a call to move_transformer()

Parameters
t11
t22

Definition at line 939 of file basic.c.

940 {
941  pips_assert("t1 is consistent on entry", transformer_consistency_p(t1));
942  pips_assert("t2 is consistent on entry", transformer_consistency_p(t2));
943 
947 
951  predicate_system(transformer_relation(t2))= SC_UNDEFINED;
952 
953  free_transformer(t2);
954 
955  pips_assert("t1 is consistent on exit", transformer_consistency_p(t1));
956 
957  return t1;
958 }
void free_arguments(cons *args)
Definition: arguments.c:218
bool transformer_consistency_p(transformer t)
FI: I do not know if this procedure should always return or fail when an inconsistency is found.
Definition: basic.c:612
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
void sc_rm(Psysteme ps)
void sc_rm(Psysteme ps): liberation de l'espace memoire occupe par le systeme de contraintes ps;
Definition: sc_alloc.c:277

References free_arguments(), free_transformer(), NIL, pips_assert, predicate_system, sc_rm(), transformer_arguments, transformer_consistency_p(), and transformer_relation.

Referenced by transformer_domain_intersection().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ old_transformer_free()

void old_transformer_free ( transformer  t)

I should use gen_free directly but Psysteme is not yet properly interfaced with NewGen

gen_free should stop before trying to free a Psysteme and won't free entities in arguments because they are tabulated

commented out for DRET demo

end of DRET demo

Definition at line 89 of file basic.c.

90 {
91  /* I should use gen_free directly but Psysteme is not yet properly
92  interfaced with NewGen */
93  Psysteme s;
94 
95  pips_assert("transformer_free", t != transformer_undefined);
96 
98  sc_rm(s);
99  predicate_system_(transformer_relation(t)) = SC_UNDEFINED;
100  /* gen_free should stop before trying to free a Psysteme and
101  won't free entities in arguments because they are tabulated */
102  /* commented out for DRET demo */
103  /*
104  gen_free(t);
105  */
106  /* end of DRET demo */
107 }
#define transformer_undefined
Definition: ri.h:2847
#define predicate_system_(x)
Definition: ri.h:2068
struct Ssysteme * Psysteme

References pips_assert, predicate_system, predicate_system_, sc_rm(), transformer_relation, and transformer_undefined.

+ Here is the call graph for this function:

◆ precondition_to_abstract_store()

transformer precondition_to_abstract_store ( transformer  pre)

Get rid of all old values and arguments.

Argument pre is unchanged and result as is allocated. Should be a call to transformer_range(). Should not be in basic.c.

Project all old values

Redefine the arguments

Parameters
prere

Definition at line 871 of file basic.c.

872 {
873  transformer as = transformer_dup(pre);
874 
875  /* Project all old values */
877 
878  /* Redefine the arguments */
881 
882  return as;
883 }
transformer transformer_dup(transformer t_in)
transformer package - basic routines
Definition: basic.c:49
transformer transformer_projection(transformer t, list args)
values in args must be in t's base
Definition: transformer.c:1267

References gen_free_list(), NIL, transformer_arguments, transformer_dup(), and transformer_projection().

Referenced by test_to_transformer(), and test_to_transformer_list().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ transformer_add_3d_affine_constraint()

transformer transformer_add_3d_affine_constraint ( transformer  tf,
int  a1,
entity  v1,
int  a2,
entity  v2,
int  a3,
entity  v3,
int  cst,
bool  equation_p 
)

Add the constraint a1 v1 + a2 v2 + a3 v3 + cst <= or == 0.

Parameters
tff
a11
v11
a22
v22
a33
v33
cstst
equation_pquation_p

Definition at line 536 of file basic.c.

537 {
538  Pvecteur eq = vect_new((Variable) v1, (Value) a1);
539  vect_add_elem(&eq, (Variable) v2, (Value) a2);
540  vect_add_elem(&eq, (Variable) v3, (Value) a3);
541  vect_add_elem(&eq, TCST, (Value) cst);
542 
543  if(equation_p)
544  tf = transformer_equality_add(tf, eq);
545  else
546  tf = transformer_inequality_add(tf, eq);
547 
548  return tf;
549 }
int Value
transformer transformer_inequality_add(transformer tf, Pvecteur i)
Definition: basic.c:375
transformer transformer_equality_add(transformer tf, Pvecteur i)
Definition: basic.c:383
Pcontrainte eq
element du vecteur colonne du systeme donne par l'analyse
Definition: sc_gram.c:108
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
Pvecteur vect_new(Variable var, Value coeff)
Pvecteur vect_new(Variable var,Value coeff): allocation d'un vecteur colineaire au vecteur de base va...
Definition: alloc.c:110
void vect_add_elem(Pvecteur *pvect, Variable var, Value val)
void vect_add_elem(Pvecteur * pvect, Variable var, Value val): addition d'un vecteur colineaire au ve...
Definition: unaires.c:72

References eq, TCST, transformer_equality_add(), transformer_inequality_add(), vect_add_elem(), and vect_new().

Referenced by process_bounds_for_divide(), and update_cp_with_rhs_to_transformer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ transformer_add_equality()

transformer transformer_add_equality ( transformer  tf,
entity  v1,
entity  v2 
)

Add an equality between two values (two variables?)

Parameters
tff
v11
v22

Definition at line 436 of file basic.c.

437 {
438  Pvecteur eq = vect_new((Variable) v1, (Value) 1);
439 
440  //pips_assert("v1 has values", entity_has_values_p(v1));
441  //pips_assert("v2 has values", entity_has_values_p(v2));
442 
444  tf = transformer_equality_add(tf, eq);
445 
446  return tf;
447 }
#define VALUE_MONE

References eq, transformer_equality_add(), VALUE_MONE, vect_add_elem(), and vect_new().

Referenced by any_basic_update_operation_to_transformer(), assign_operation_to_transformer(), generic_abs_to_transformer(), generic_reference_to_transformer(), generic_unary_operation_to_transformer(), lhs_expression_to_transformer(), transformer_apply_field_assignments_or_equalities(), and update_operation_to_transformer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ transformer_add_equality_with_affine_term()

transformer transformer_add_equality_with_affine_term ( transformer  tf,
entity  v,
entity  x,
int  a,
int  cst 
)

Add the equality v = a x + cst.

Parameters
tff
cstst

Definition at line 517 of file basic.c.

518 {
520 
521  vect_add_elem(&eq, (Variable) x, (Value) -a);
522  vect_add_elem(&eq, TCST, (Value) -cst);
523 
524  tf = transformer_equality_add(tf, eq);
525 
526  return tf;
527 }
#define VALUE_ONE
static char * x
Definition: split_file.c:159

References eq, TCST, transformer_equality_add(), VALUE_ONE, vect_add_elem(), vect_new(), and x.

Referenced by generic_abs_to_transformer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ transformer_add_equality_with_integer_constant()

transformer transformer_add_equality_with_integer_constant ( transformer  tf,
entity  v,
long long int  cst 
)

Add an equality between a value and an integer constant: v==cst.

Parameters
tff
cstst

Definition at line 450 of file basic.c.

451 {
453 
454  //pips_assert("v1 has values", entity_has_values_p(v1));
455  //pips_assert("v2 has values", entity_has_values_p(v2));
456 
457  vect_add_elem(&eq, TCST, (Value) cst);
458  tf = transformer_equality_add(tf, eq);
459 
460  return tf;
461 }

References eq, TCST, transformer_equality_add(), VALUE_MONE, vect_add_elem(), and vect_new().

Referenced by add_type_information(), bitwise_xor_to_transformer(), constant_to_transformer(), generic_abs_to_transformer(), integer_expression_to_transformer(), integer_left_shift_to_transformer(), integer_power_to_transformer(), logical_binary_function_to_transformer(), logical_expression_to_transformer(), logical_not_to_transformer(), modulo_by_a_constant_to_transformer(), modulo_of_a_constant_to_transformer(), and transformer_add_condition_information_updown().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ transformer_add_identity()

transformer transformer_add_identity ( transformer  tf,
entity  v 
)
Parameters
tff

Definition at line 421 of file basic.c.

422 {
423  entity v_new = entity_to_new_value(v);
424  entity v_old = entity_to_old_value(v);
425  Pvecteur eq = vect_new((Variable) v_new, (Value) 1);
426 
427  vect_add_elem(&eq, (Variable) v_old, (Value) -1);
428  tf = transformer_equality_add(tf, eq);
431 
432  return tf;
433 }
cons * arguments_add_entity(cons *a, entity e)
Definition: arguments.c:85
entity entity_to_new_value(entity)
Definition: value.c:859
entity entity_to_old_value(entity)
Definition: value.c:869

References arguments_add_entity(), entity_to_new_value(), entity_to_old_value(), eq, transformer_arguments, transformer_equality_add(), vect_add_elem(), and vect_new().

+ Here is the call graph for this function:

◆ transformer_add_inequality()

transformer transformer_add_inequality ( transformer  tf,
entity  v1,
entity  v2,
bool  strict_p 
)

Add the equality v1 <= v2 or v1 < v2.

Parameters
tff
v11
v22
strict_ptrict_p

Definition at line 464 of file basic.c.

465 {
467 
469  if(strict_p)
471  tf = transformer_inequality_add(tf, eq);
472 
473  return tf;
474 }

References eq, TCST, transformer_inequality_add(), VALUE_MONE, VALUE_ONE, vect_add_elem(), and vect_new().

Referenced by add_index_bound_conditions(), integer_left_shift_to_transformer(), and integer_multiply_to_transformer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ transformer_add_inequality_with_affine_term()

transformer transformer_add_inequality_with_affine_term ( transformer  tf,
entity  v,
entity  x,
int  a,
int  cst,
bool  less_than_p 
)

Add the inequality v <= a x + cst or v >= a x + cst.

Parameters
tff
cstst
less_than_pess_than_p

Definition at line 496 of file basic.c.

497 {
499 
500  if(less_than_p) {
501  eq = vect_new((Variable) v, VALUE_ONE);
502  vect_add_elem(&eq, (Variable) x, (Value) -a);
503  vect_add_elem(&eq, TCST, (Value) -cst);
504  }
505  else {
506  eq = vect_new((Variable) v, VALUE_MONE);
507  vect_add_elem(&eq, TCST, (Value) cst);
508  vect_add_elem(&eq, (Variable) x, (Value) a);
509  }
510 
511  tf = transformer_inequality_add(tf, eq);
512 
513  return tf;
514 }
#define VECTEUR_NUL
DEFINITION DU VECTEUR NUL.

References eq, TCST, transformer_inequality_add(), VALUE_MONE, VALUE_ONE, vect_add_elem(), vect_new(), VECTEUR_NUL, and x.

Referenced by integer_left_shift_to_transformer(), integer_multiply_to_transformer(), and transformer_add_inequality_with_linear_term().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ transformer_add_inequality_with_integer_constraint()

transformer transformer_add_inequality_with_integer_constraint ( transformer  tf,
entity  v,
long long int  cst,
bool  less_than_p 
)

Add the inequality v <= cst or v >= cst.

Parameters
tff
cstst
less_than_pess_than_p

Definition at line 477 of file basic.c.

478 {
480 
481  if(less_than_p) {
482  eq = vect_new((Variable) v, VALUE_ONE);
483  vect_add_elem(&eq, TCST, (Value) -cst);
484  }
485  else {
486  eq = vect_new((Variable) v, VALUE_MONE);
487  vect_add_elem(&eq, TCST, (Value) cst);
488  }
489 
490  tf = transformer_inequality_add(tf, eq);
491 
492  return tf;
493 }

References eq, TCST, transformer_inequality_add(), VALUE_MONE, VALUE_ONE, vect_add_elem(), and vect_new().

Referenced by add_type_information(), integer_call_expression_to_transformer(), integer_left_shift_to_transformer(), integer_minmax_to_transformer(), integer_power_to_transformer(), logical_binary_function_to_transformer(), logical_not_to_transformer(), 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(), and modulo_to_transformer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ transformer_add_inequality_with_linear_term()

transformer transformer_add_inequality_with_linear_term ( transformer  tf,
entity  v,
entity  x,
int  a,
bool  less_than_p 
)

Add the inequality v <= a x or v >= a x.

Parameters
tff
less_than_pess_than_p

Definition at line 530 of file basic.c.

531 {
532  return transformer_add_inequality_with_affine_term(tf, v, x, a, VALUE_ZERO, less_than_p);
533 }
#define VALUE_ZERO
transformer transformer_add_inequality_with_affine_term(transformer tf, entity v, entity x, int a, int cst, bool less_than_p)
Add the inequality v <= a x + cst or v >= a x + cst.
Definition: basic.c:496

References transformer_add_inequality_with_affine_term(), VALUE_ZERO, and x.

Referenced by expression_multiply_sizeof_to_transformer(), integer_multiply_to_transformer(), and loop_to_enter_transformer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ transformer_add_modified_variable()

transformer transformer_add_modified_variable ( transformer  tf,
entity  var 
)

FI: this function does not end up with a consistent transformer because the old value is not added to the basis of sc.

Also, the variable should be transformed into a new value... See next function.

Should we check that var has values?

Parameters
tff
varar

Definition at line 889 of file basic.c.

892 {
893  /* Should we check that var has values? */
895  Pbase b = sc_base(sc);
896 
898  sc_base(sc) = vect_add_variable(b, (Variable) var);
899  sc_dimension(sc) = base_dimension(sc_base(sc));
900 
901  return tf;
902 }
Pbase vect_add_variable(Pbase b, Variable v)
package vecteur - routines sur les bases
Definition: base.c:61
#define base_dimension(b)

References arguments_add_entity(), base_dimension, predicate_system, transformer_arguments, transformer_relation, and vect_add_variable().

Referenced by any_assign_operation_to_transformer(), any_scalar_assign_to_transformer_list(), any_scalar_assign_to_transformer_without_effect(), transformer_apply_field_assignments_or_equalities(), and transformer_apply_unknown_field_assignments_or_equalities().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ transformer_add_modified_variable_entity()

transformer transformer_add_modified_variable_entity ( transformer  tf,
entity  var 
)

FI: like the previous function, but supposed to end up with a consistent transformer.

When the transformer is empty/unfeasible, the variable is not added to conform to rules about standard empty transformer: how could a variable be updated by a non-existing transition?

FI: it is not well specifived if the argument should be made of new values or of progtram variables because up to now the two are the same, except when printed out.

Parameters
tff
varar

Definition at line 909 of file basic.c.

911 {
912  if(!transformer_empty_p(tf)) {
914  Pbase b = sc_base(sc);
915 
916  if(entity_has_values_p(var)) {
917  entity v_new = entity_to_new_value(var);
918  entity v_old = entity_to_old_value(var);
919 
920  /* FI: it is not well specifived if the argument should be made
921  of new values or of progtram variables because up to now the
922  two are the same, except when printed out. */
924  sc_base(sc) = vect_add_variable(b, (Variable) v_new);
925  sc_base(sc) = vect_add_variable(sc_base(sc), (Variable) v_old);
926  sc_dimension(sc) = base_dimension(sc_base(sc));
927  }
928  else
929  pips_internal_error("Entity \"%s\" has no values.", entity_name(var));
930  }
931 
932  return tf;
933 }
#define pips_internal_error
Definition: misc-local.h:149
#define entity_name(x)
Definition: ri.h:2790
bool transformer_empty_p(transformer t)
If true is returned, the transformer certainly is empty.
Definition: transformer.c:2455
bool entity_has_values_p(entity)
This function could be made more robust by checking the storage of e.
Definition: value.c:911

References arguments_add_entity(), base_dimension, entity_has_values_p(), entity_name, entity_to_new_value(), entity_to_old_value(), pips_internal_error, predicate_system, transformer_arguments, transformer_empty_p(), transformer_relation, and vect_add_variable().

Referenced by safe_assigned_expression_to_transformer(), and safe_assigned_expression_to_transformer_list().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ transformer_add_sign_information()

transformer transformer_add_sign_information ( transformer  tf,
entity  v,
int  v_sign 
)

CHANGE THIS NAME: no loop index please, it's not directly linked to loops!!!

Add in tf the information that v is striclty positive, strictly negative or zero.

Assume that v is a value and tf is defined.

v_sign<0

v_sign==0

Parameters
tff
v_sign_sign

Definition at line 200 of file basic.c.

203 {
205 
206  ifdebug(1) {
207  pips_assert("Transformer tf is consistent on entrance",
209  }
210 
212 
213  psyst->base = base_add_variable(psyst->base, (Variable) v);
214  psyst->dimension = base_dimension(psyst->base);
215 
216  if(v_sign!=0) {
217  Pvecteur cv;
218  Pcontrainte ineq;
219  if(v_sign>0) {
220  cv = vect_new((Variable) v, VALUE_MONE);
222  }
223  else {
224  /* v_sign<0 */
225  cv = vect_new((Variable) v, VALUE_ONE);
227  }
228  ineq = contrainte_make(cv);
229  sc_add_inegalite(psyst, ineq);
230  }
231  else {
232  /* v_sign==0*/
233  Pvecteur cv = vect_new((Variable) v, VALUE_ONE);
235 
236  sc_add_egalite(psyst, eq);
237  }
238 
239  ifdebug(1) {
240  pips_assert("Transformer tf is consistent on exit",
242  }
243 
244  return tf;
245 }
Pbase base_add_variable(Pbase b, Variable var)
Pbase base_add_variable(Pbase b, Variable v): add variable v as a new dimension to basis b at the end...
Definition: base.c:88
Pcontrainte contrainte_make(Pvecteur pv)
Pcontrainte contrainte_make(Pvecteur pv): allocation et initialisation d'une contrainte avec un vecte...
Definition: alloc.c:73
void sc_add_egalite(Psysteme p, Pcontrainte e)
void sc_add_egalite(Psysteme p, Pcontrainte e): macro ajoutant une egalite e a un systeme p; la base ...
Definition: sc_alloc.c:389
void sc_add_inegalite(Psysteme p, Pcontrainte i)
void sc_add_inegalite(Psysteme p, Pcontrainte i): macro ajoutant une inegalite i a un systeme p; la b...
Definition: sc_alloc.c:406
#define ifdebug(n)
Definition: sg.c:47
Pbase base
Definition: sc-local.h:75
int dimension
Definition: sc-local.h:74
bool value_entity_p(entity)
Definition: value.c:976
bool local_temporary_value_entity_p(entity)
Definition: value.c:654

References Ssysteme::base, base_add_variable(), base_dimension, contrainte_make(), Ssysteme::dimension, eq, ifdebug, local_temporary_value_entity_p(), pips_assert, predicate_system, sc_add_egalite(), sc_add_inegalite(), TCST, transformer_consistency_p(), transformer_relation, value_entity_p(), VALUE_MONE, VALUE_ONE, vect_add_elem(), and vect_new().

Referenced by condition_to_transformer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ transformer_add_value_update()

transformer transformer_add_value_update ( transformer  t,
entity  v 
)

Add an update of variable v to t (a value cannot be updated)

Definition at line 321 of file basic.c.

322 {
323  entity nv = entity_to_new_value(v);
324  entity ov = entity_to_old_value(v);
325 
326  if(!transformer_empty_p(t)) {
328 
330  if(!base_contains_variable_p(psyst->base, (Variable) nv))
331  psyst->base = base_add_variable(psyst->base, (Variable) nv);
332  if(!base_contains_variable_p(psyst->base, (Variable) ov))
333  psyst->base = base_add_variable(psyst->base, (Variable) ov);
334  psyst->dimension = vect_size(psyst->base);
335  }
336 
337  return t;
338 }
bool base_contains_variable_p(Pbase b, Variable v)
bool base_contains_variable_p(Pbase b, Variable v): returns true if variable v is one of b's elements...
Definition: base.c:136
int vect_size(Pvecteur v)
package vecteur - reductions
Definition: reductions.c:47

References arguments_add_entity(), Ssysteme::base, base_add_variable(), base_contains_variable_p(), Ssysteme::dimension, entity_to_new_value(), entity_to_old_value(), predicate_system, transformer_arguments, transformer_empty_p(), transformer_relation, and vect_size().

Referenced by assigned_expression_to_transformer(), assigned_expression_to_transformer_list(), c_return_to_transformer(), and transformer_add_variables_update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ transformer_add_variable_incrementation()

transformer transformer_add_variable_incrementation ( transformer  t,
entity  i,
Pvecteur  incr 
)

transformer transformer_add_loop_index(transformer t, entity i, Pvecteur incr): add the index incrementation expression incr for loop index i to transformer t.

t = intersection(t, i::new = i::old + incr)

incr is supposed to be compatible with the value mappings

Pvecteur incr should not be used after a call to transformer_add_index because it is shared by t and modified

Psysteme * ps = &((Psysteme) predicate_system(transformer_relation(t)));

Parameters
incrncr

Definition at line 260 of file basic.c.

264 {
265  /* Psysteme * ps =
266  &((Psysteme) predicate_system(transformer_relation(t))); */
268  entity i_old = entity_to_old_value(i);
269  entity i_new = entity_to_new_value(i);
270  entity i_rep = value_to_variable(i_new);
271 
273  psyst->base = vect_add_variable(psyst->base, (Variable) i_new);
274  psyst->base = vect_add_variable(psyst->base, (Variable) i_old);
275  psyst->dimension = vect_size(psyst->base);
276  vect_chg_coeff(&incr, (Variable) i_new, -1);
277  vect_chg_coeff(&incr, (Variable) i_old, 1);
278  psyst = sc_equation_add(psyst, contrainte_make(incr));
279 
280  return t;
281 }
Psysteme sc_equation_add(Psysteme sc, Pcontrainte c)
The basis of the constraint system is updated.
Definition: sc_insert_eq.c:101
entity value_to_variable(entity)
Get the primitive variable associated to any value involved in a transformer.
Definition: value.c:1624
void vect_chg_coeff(Pvecteur *ppv, Variable var, Value val)
void vect_chg_coeff(Pvecteur *ppv, Variable var, Value val): mise de la coordonnee var du vecteur *pp...
Definition: unaires.c:143

References arguments_add_entity(), Ssysteme::base, contrainte_make(), Ssysteme::dimension, entity_to_new_value(), entity_to_old_value(), predicate_system, sc_equation_add(), transformer_arguments, transformer_relation, value_to_variable(), vect_add_variable(), vect_chg_coeff(), and vect_size().

Referenced by transformer_add_loop_index_incrementation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ transformer_add_variable_update()

transformer transformer_add_variable_update ( transformer  t,
entity  v 
)

Add an update of variable v into t.

NL : this function is not finish do the same thing than transformer_add_value_update for the moment TODO

Definition at line 289 of file basic.c.

290 {
292  entity v_new = entity_to_new_value(v);
293  entity v_old = entity_to_old_value(v);
294  entity v_rep = value_to_variable(v_new);
295 
297  if(!base_contains_variable_p(psyst->base, (Variable) v_new)) {
298  psyst->base = base_add_variable(psyst->base, (Variable) v_new);
299  }
300  if(!base_contains_variable_p(psyst->base, (Variable) v_old)) {
301  psyst->base = base_add_variable(psyst->base, (Variable) v_old);
302  }
303  psyst->dimension = vect_size(psyst->base);
304 
305 //
306 // pips_assert("before value substitution\n", transformer_consistency_p(t));
307 //// t = transformer_value_substitute(t, v_new, v_old);
308 //
309 // pips_debug(9, "before tes\nt");
310 // if(base_contains_variable_p(psyst->base, (Variable) v_new)) {
311 // if(!base_contains_variable_p(psyst->base, (Variable) v_old)) {
312 // pips_debug(9, "rename variable\n");
313 // (void) sc_variable_rename(psyst,(Variable) v_new, (Variable)v_old);
314 // }
315 // }
316 // pips_assert("after value substitution\n", transformer_consistency_p(t));
317  return t;
318 }

References arguments_add_entity(), Ssysteme::base, base_add_variable(), base_contains_variable_p(), Ssysteme::dimension, entity_to_new_value(), entity_to_old_value(), predicate_system, transformer_arguments, transformer_relation, value_to_variable(), and vect_size().

Referenced by apply_abstract_effect_to_transformer(), apply_array_effect_to_transformer(), apply_concrete_effect_to_transformer(), generic_apply_effect_to_transformer(), and generic_reference_to_transformer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ transformer_add_variables_update()

transformer transformer_add_variables_update ( transformer  t,
list  vl 
)
Parameters
vll

Definition at line 340 of file basic.c.

341 {
342  FOREACH(ENTITY, v, vl) {
344  }
345  return t;
346 }
transformer transformer_add_value_update(transformer t, entity v)
Add an update of variable v to t (a value cannot be updated)
Definition: basic.c:321
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
Definition: newgen_list.h:179
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755

References ENTITY, FOREACH, and transformer_add_value_update().

Referenced by c_user_call_to_transformer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ transformer_argument_consistency_p()

bool transformer_argument_consistency_p ( transformer  t)

Definition at line 551 of file basic.c.

552 {
554 }
bool transformer_argument_general_consistency_p(transformer t, bool is_weak)
Definition: basic.c:561

References transformer_argument_general_consistency_p().

Referenced by transformer_add_any_relation_information(), and transformer_general_consistency_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ transformer_argument_general_consistency_p()

bool transformer_argument_general_consistency_p ( transformer  t,
bool  is_weak 
)

If no final state can be reached, no variable can be changed in between

If a variable appears as argument, its new value must be in the basis See for instance, effects_to_transformer()

pips_user_warning("No value for argument %s in relation basis\n", entity_name(e));

Parameters
is_weaks_weak

Definition at line 561 of file basic.c.

562 {
563  list args = transformer_arguments(t);
564  bool consistent = true;
566  Pbase b = sc_base(sc);
567 
568  /* If no final state can be reached, no variable can be changed in between */
569  if(sc_empty_p(sc)) {
570  consistent = ENDP(args);
571  pips_assert("Empty transformer must have no arguments", consistent);
572  }
573  else if(!is_weak) {
574  /* If a variable appears as argument, its new value must be in the basis
575  * See for instance, effects_to_transformer()
576  */
577 
578  MAP(ENTITY, e, {
580  /*
581  pips_assert("Argument is in the basis", base_contains_variable_p(b, (Variable) v));
582  */
583  if(!base_contains_variable_p(b, (Variable) v)) {
584  /* pips_user_warning("No value for argument %s in relation basis\n",
585  entity_name(e)); */
586  pips_internal_error("No value for argument %s in relation basis",
587  entity_name(e));
588  consistent = false;
589  }
590  }, args);
591  pips_assert("Argument variables must have values in basis", consistent);
592  }
593 
594  return consistent;
595 }
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
#define MAP(_map_CASTER, _map_item, _map_code, _map_list)
Apply/map an instruction block on all the elements of a list (old fashioned)
Definition: newgen_list.h:226
bool sc_empty_p(Psysteme sc)
bool sc_empty_p(Psysteme sc): check if the set associated to sc is the constant sc_empty or not.
Definition: sc_alloc.c:350
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References base_contains_variable_p(), ENDP, ENTITY, entity_name, entity_to_new_value(), MAP, pips_assert, pips_internal_error, predicate_system, sc_empty_p(), transformer_arguments, and transformer_relation.

Referenced by transformer_argument_consistency_p(), and transformer_argument_weak_consistency_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ transformer_argument_weak_consistency_p()

bool transformer_argument_weak_consistency_p ( transformer  t)

Definition at line 556 of file basic.c.

557 {
559 }

References transformer_argument_general_consistency_p().

+ Here is the call graph for this function:

◆ transformer_consistency_p()

bool transformer_consistency_p ( transformer  t)

FI: I do not know if this procedure should always return or fail when an inconsistency is found.

For instance, summary transformers for callees are inconsistent with respect to the current module. FC/CA: help...

I do not understand why errors are reported only if the debug level is greater than 1. A demo effect? No, this routine is coded that way to save time on regular runs.

Also, since no precise information about the inconsistency is displayed, a core dump would be welcome to retrieve pieces of information with gdb. The returned value should always be tested and a call to pips_internal_error() should always be performed if an inconsistency is detected.

But, see final comment... In spite of it, I do not always return any longer.

Definition at line 612 of file basic.c.

613 {
614  return transformer_general_consistency_p(t, false);
615 }
bool transformer_general_consistency_p(transformer tf, bool is_weak)
Definition: basic.c:632

References transformer_general_consistency_p().

Referenced by block_to_transformer(), block_to_transformer_list(), call_to_transformer(), declarations_to_transformer(), declarations_to_transformer_list(), generic_module_name_to_transformers(), initial_precondition(), loop_to_total_precondition(), module_name_to_total_preconditions(), move_transformer(), node_to_path_transformer_or_postcondition(), print_cycle_head_to_fixpoint(), program_postcondition(), program_precondition(), propagate_preconditions_in_declarations(), safe_assigned_expression_to_transformer(), statement_to_postcondition(), statement_to_total_precondition(), statement_to_transformer(), statement_to_transformer_list(), store_control_fix_point(), store_control_postcondition(), transformer_add_loop_index_incrementation(), transformer_add_sign_information(), transformer_combine(), transformer_derivative_fix_point(), transformer_internal_consistency_p(), transformer_inverse_apply(), transformer_list_closure_to_precondition(), transformer_list_closure_to_precondition_depth_two(), transformer_list_generic_transitive_closure(), transformer_list_multiple_closure_to_precondition(), transformer_normalize(), unstructured_to_flow_sensitive_postconditions(), and unstructured_to_flow_sensitive_total_preconditions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ transformer_constraint_add()

transformer transformer_constraint_add ( transformer  tf,
Pvecteur  i,
bool  equality 
)
Parameters
tff
equalityquality

Definition at line 348 of file basic.c.

352 {
353  Pcontrainte c;
354  Psysteme sc;
355 
356  pips_assert("tf is defined", tf != transformer_undefined
357  && tf != (transformer) NULL);
358 
359  if(VECTEUR_NUL_P(i)) {
360  user_warning("transformer_constraint_add",
361  "trivial constraint 0 %s 0 found: code should be optimized\n",
362  (equality)? "==" : "<=");
363  return tf;
364  }
365 
366  c = contrainte_make(i);
368 
369  sc = sc_constraint_add(sc, c, equality);
370 
371  return tf;
372 }
#define user_warning(fn,...)
Definition: misc-local.h:262
Psysteme sc_constraint_add(Psysteme sc, Pcontrainte c, bool equality)
Definition: sc_insert_eq.c:115
#define VECTEUR_NUL_P(v)

References contrainte_make(), pips_assert, predicate_system, sc_constraint_add(), transformer_relation, transformer_undefined, user_warning, and VECTEUR_NUL_P.

Referenced by transformer_equalities_add(), transformer_equality_add(), transformer_inequalities_add(), and transformer_inequality_add().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ transformer_dup()

transformer transformer_dup ( transformer  t_in)

transformer package - basic routines

cproto-generated files

Francois Irigoin

FI: I do not reduce transformer_dup() to a macro calling copy_transformer() because I do not want to create problems with the link edit and because I want to keep the assertion

Parameters
t_in_in

Definition at line 49 of file basic.c.

50 {
51  /* FI: I do not reduce transformer_dup() to a macro calling
52  copy_transformer() because I do not want to create problems with
53  the link edit and because I want to keep the assertion */
54 
55  Psysteme sc = SC_UNDEFINED;
56  transformer t_out;
57 
58  pips_assert("transformer t_in is not undefined", t_in != transformer_undefined);
59 
61  pips_assert("transformer_dup", !SC_UNDEFINED_P(sc));
62  t_out = copy_transformer(t_in);
63 
64  return t_out;
65 }
transformer copy_transformer(transformer p)
TRANSFORMER.
Definition: ri.c:2613

References copy_transformer(), pips_assert, predicate_system, transformer_relation, and transformer_undefined.

Referenced by add_index_bound_conditions(), add_loop_index_exit_value(), any_transformer_to_k_closure(), block_to_postcondition(), block_to_total_precondition(), block_to_transformer(), call_site_to_module_precondition_text(), call_to_summary_precondition(), check_condition_wrt_precondition(), comp_regions_of_implied_do(), complete_loop_transformer(), complete_loop_transformer_list(), cycle_to_flow_sensitive_preconditions(), dag_to_flow_sensitive_preconditions(), declarations_to_transformer(), declarations_to_transformer_list(), eval_condition_wrt_precondition_p(), forloop_to_postcondition(), fortran_user_call_to_transformer(), generic_module_name_to_transformers(), generic_transformer_intra_to_inter(), integer_expression_and_precondition_to_integer_interval(), interprocedural_abc_arrays(), load_arc_precondition(), loop_to_postcondition(), loop_to_total_precondition(), loop_to_transformer(), module_name_to_total_preconditions(), old_complete_whileloop_transformer(), precondition_to_abstract_store(), process_call_for_summary_precondition(), process_ready_node(), program_precondition(), propagate_preconditions_in_declarations(), recompute_loop_transformer(), standard_whileloop_to_transformer(), test_to_postcondition(), test_to_transformer(), test_to_transformer_list(), transformer_add_anded_conditions_updown(), transformer_add_any_relation_information(), transformer_add_integer_relation_information(), transformer_add_ored_conditions_updown(), transformer_apply(), transformer_convex_hulls(), transformer_derivative_fix_point(), transformer_domain_intersection(), transformer_equality_fix_point(), transformer_halbwachs_fix_point(), transformer_inverse_apply(), transformer_pattern_fix_point(), transformer_range(), transformer_to_domain(), unstructured_continuation_conditions(), unstructured_to_postcondition(), unstructured_to_postconditions(), unstructured_to_total_precondition(), unstructured_to_transformer(), update_summary_precondition(), update_temporary_precondition(), and whileloop_to_postcondition().

+ Here is the call graph for this function:

◆ transformer_empty()

transformer transformer_empty ( void  )

Allocate an empty transformer.

Definition at line 120 of file basic.c.

121 {
122  return make_transformer(NIL,
124 }
transformer make_transformer(list a1, predicate a2)
Definition: ri.c:2649

References BASE_NULLE, make_predicate(), make_transformer(), NIL, and sc_empty().

Referenced by add_index_range_conditions(), block_continuation_conditions(), call_continuation_conditions(), complete_repeatloop_transformer_list(), dag_or_cycle_to_flow_sensitive_postconditions_or_transformers(), expression_multiply_sizeof_to_transformer(), generic_transformer_list_to_transformer(), get_control_precondition(), integer_binary_operation_to_transformer(), intrinsic_to_transformer(), intrinsic_to_transformer_list(), load_arc_precondition(), loop_continuation_conditions(), loop_to_postcondition(), loop_to_total_precondition(), module_summary_continuation_conditions(), modulo_of_a_constant_to_transformer(), modulo_to_transformer(), new_array_elements_backward_substitution_in_transformer(), new_array_elements_forward_substitution_in_transformer(), new_substitute_stubs_in_transformer(), ordinary_summary_precondition(), pointer_binary_operation_to_transformer(), points_to_unary_operation_to_transformer(), precondition_intra_to_inter(), process_bounds_for_divide(), process_unreachable_node(), ready_to_be_processed_p(), repeatloop_to_postcondition(), standard_whileloop_to_transformer(), statement_to_total_precondition(), summary_total_postcondition(), test_continuation_conditions(), transformer_add_call_condition_information_updown(), transformer_add_condition_information_updown(), transformer_general_intersection(), transformer_list_generic_transitive_closure(), unstructured_continuation_conditions(), unstructured_to_flow_insensitive_transformer(), unstructured_to_postconditions(), unstructured_to_transformer(), whileloop_to_postcondition(), and whileloop_to_total_precondition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ transformer_equalities_add()

transformer transformer_equalities_add ( transformer  tf,
Pcontrainte  eqs 
)

please, do not introduce any sharing at the Pcontrainte level you do not know how they have to be chained in diferent transformers; do not introduce any sharing at the Pvecteur level; I'm not sure it's so useful, but think of what would happen if one transformer is renamed...

Parameters
tff
eqsqs

Definition at line 391 of file basic.c.

394 {
395  /* please, do not introduce any sharing at the Pcontrainte level
396  you do not know how they have to be chained in diferent transformers;
397  do not introduce any sharing at the Pvecteur level; I'm not
398  sure it's so useful, but think of what would happen if one transformer
399  is renamed... */
400  for(;eqs!=CONTRAINTE_UNDEFINED; eqs = eqs->succ)
401  (void) transformer_constraint_add(tf,
403  true);
404  return tf;
405 }
transformer transformer_constraint_add(transformer tf, Pvecteur i, bool equality)
Definition: basic.c:348
#define contrainte_vecteur(c)
passage au champ vecteur d'une contrainte "a la Newgen"
#define CONTRAINTE_UNDEFINED
struct Scontrainte * succ
Pvecteur vect_dup(Pvecteur v_in)
Pvecteur vect_dup(Pvecteur v_in): duplication du vecteur v_in; allocation de et copie dans v_out;.
Definition: alloc.c:51

References CONTRAINTE_UNDEFINED, contrainte_vecteur, Scontrainte::succ, transformer_constraint_add(), and vect_dup().

Referenced by tf_equivalence_equalities_add().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ transformer_equality_add()

◆ transformer_equations_constrain_variable_p()

bool transformer_equations_constrain_variable_p ( const transformer  t,
const entity  v 
)

Is value v used with a non-zero coefficient by the equations of transformer t?

Definition at line 963 of file basic.c.

964 {
967 }
bool sc_equations_constrain_variable_p(Psysteme sc, Variable var)
Definition: sc_misc.c:190

References predicate_system, sc_equations_constrain_variable_p(), and transformer_relation.

+ Here is the call graph for this function:

◆ transformer_free()

◆ transformer_general_consistency_p()

bool transformer_general_consistency_p ( transformer  tf,
bool  is_weak 
)

the relation should be consistent and any variable corresponding to an old value should appear in the argument list since an old value cannot (should not) be introduced unless the variable is changed and since every changed variable is in the argument list.

Apparently, a variable may appear as an argument but its old value does not have to appear in the basis if it is not required by the constraints. This does not seem very safe to me (FI, 13 Nov. 95)

The NewGen data structure must be fully defined

The predicate must be weakly consistent. Every variable in the constraints must be in the basis (but not the other way round).

If an old value appears in the predicate, the corresponding variable should be an argument of the transformer

test aliasing between arguments and relations high cost testing

FI: the next test is not safe because val can be a global value not recognized in the current context. old_value_entity_p() returns true or FALSE or pips_error.

A general version of this routine is needed... The return value of a function is not recognized as a global value by old_value_entity_p

old_value_entity_p() is likely to core dump on interprocedural transformers and preconditions.

The constant term should not appear in the basis

The constant term should not be an argument

Check that the transformer is compatible with the current value mappings.

This is not always true as you may need to import the summary transformer of a callee. Before translation, this check will most likely fail.

Debugging step which does not return if an incompatibility is found.

Check that every argument has a value. This is not redundant with the printout procedure which uses entity_minimal_name() and not the value mappings.

Values returned by callees may appear in interprocedural transformers

FI: let the user react and print info before core dumping

pips_assert("transformer_consistency_p", consistent);

Parameters
tff
is_weaks_weak

Definition at line 632 of file basic.c.

633 {
634 #define TRANSFORMER_CONSISTENCY_P_DEBUG_LEVEL 0
635  /* the relation should be consistent
636  * and any variable corresponding to an old value
637  * should appear in the argument list since
638  * an old value cannot (should not) be
639  * introduced unless the variable is changed and
640  * since every changed variable is
641  * in the argument list.
642  *
643  * Apparently, a variable may appear as an argument but its old value
644  * does not have to appear in the basis if it is not required by
645  * the constraints. This does not seem very safe to me (FI, 13 Nov. 95)
646  */
648  list args = transformer_arguments(tf);
649  bool consistent = true;
650 
651  /* The NewGen data structure must be fully defined */
653  consistent = transformer_defined_p(tf);
654  else
655  consistent = true;
656  if(!consistent)
658  "transformer tf is not gen_defined\n");
659 
660  /* The predicate must be weakly consistent. Every variable
661  * in the constraints must be in the basis (but not the other
662  * way round).
663  */
664  consistent = consistent && sc_weak_consistent_p(sc);
665  if(!consistent)
667  "sc is not weakly consistent\n");
668 
669  /* If an old value appears in the predicate, the corresponding
670  * variable should be an argument of the transformer
671  */
672  if(consistent) {
673  Pbase b = sc_base(sc);
674  Pbase t = BASE_UNDEFINED;
675 
676  for( t = b; !BASE_UNDEFINED_P(t) && consistent; t = t->succ) {
677  entity val = (entity) vecteur_var(t);
678 
679  /* test aliasing between arguments and relations
680  high cost testing */
681  ifdebug(8) {
682  bool aliasing = false;
683  const char* emn = entity_module_name(val);
684  const char* eln = entity_local_name(val);
685  list lt = args;
686  entity e;
687  for (lt = args; lt && !aliasing ;POP(lt)) {
688  e = ENTITY(CAR(lt));
689  consistent = consistent &&
690  (same_string_p(entity_local_name(e), eln) ?
692  : true);
693  aliasing = aliasing && entities_may_conflict_p(e,val);
694  }
695 
696  if(!consistent)
697  pips_user_warning("different global variable names in "
698  "arguments and basis: \"%s\"\n", eln);
699  if (aliasing)
700  pips_internal_error("aliasing between arguments and basis: \"%s\" ",
701  entity_name(val));
702  }
703 
704  /* FI: the next test is not safe because val can be
705  * a global value not recognized in the current
706  * context. old_value_entity_p() returns true or FALSE
707  * or pips_error.
708  *
709  * A general version of this routine is needed... The
710  * return value of a function is not recognized as a
711  * global value by old_value_entity_p
712  *
713  * old_value_entity_p() is likely to core dump on
714  * interprocedural transformers and preconditions.
715  */
717  && old_value_entity_p(val)) {
718  entity var = value_to_variable(val);
719 
720  consistent = entity_is_argument_p(var, args);
721  if(!consistent) {
722  dump_transformer(tf);
724  "Old value of \"%s\" in sc but not in arguments of transformer tf, %p\n",
725  entity_name(var), tf);
726  }
727  }
728  /* The constant term should not appear in the basis */
729  if(consistent) {
730  consistent = consistent && !term_cst(t);
731  if(!consistent)
733  "TCST in sc basis\n");
734  }
735  }
736  }
737 
738  /* The constant term should not be an argument */
739  if(consistent) {
740  MAP(ENTITY, e, {
741  consistent = consistent && (e != (entity) TCST);
742  }, args);
743  if(!consistent)
745  "transformer_consistency_p", "TCST appears in arguments\n");
746  }
747 
748  /* Check that the transformer is compatible with the current value mappings.
749  *
750  * This is not always true as you may need to import the summary transformer
751  * of a callee. Before translation, this check will most likely fail.
752  *
753  * Debugging step which does not return if an incompatibility is found.
754  */
755 
756  /* Check that every argument has a value.
757  * This is not redundant with the printout procedure which uses
758  * entity_minimal_name() and not the value mappings.
759  */
760  FOREACH(ENTITY, e, args) {
761  /*
762  pips_assert("Argument entity appears in the value mappings",
763  entity_has_values_p(e));
764  */
765  if(!entity_has_values_p(e)) {
766  /* Values returned by callees may appear in interprocedural
767  transformers */
769  && !entity_stub_sink_p(e)
770  && !entity_in_formal_area_p(e)) {
771  pips_user_warning("No value for argument %s in value mappings\n",
772  entity_name(e));
773  if(!is_weak)
774  consistent = false;
775  }
776  }
777  }
778 
779  if(consistent && !is_weak)
780  consistent = transformer_argument_consistency_p(tf);
781 
782  /* FI: let the user react and print info before core dumping */
783  /* pips_assert("transformer_consistency_p", consistent); */
784 
785  return consistent;
786 }
bool transformer_defined_p(transformer p)
Definition: ri.c:2626
struct _newgen_struct_entity_ * entity
Definition: abc_private.h:14
bool entity_stub_sink_p(entity e)
test if an entity is a stub sink for a formal parameter e.g.
bool entity_is_argument_p(entity e, cons *args)
Definition: arguments.c:150
bool transformer_argument_consistency_p(transformer t)
Definition: basic.c:551
#define TRANSFORMER_CONSISTENCY_P_DEBUG_LEVEL
bool entities_may_conflict_p(entity e1, entity e2)
Check if two entities may conflict.
Definition: conflicts.c:984
#define POP(l)
Modify a list pointer to point on the next element of the list.
Definition: newgen_list.h:59
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define pips_user_warning
Definition: misc-local.h:146
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189
#define same_string_p(s1, s2)
#define true
Definition: newgen_types.h:81
#define dump_transformer(t)
Definition: print.c:355
const char * entity_local_name(entity e)
entity_local_name modified so that it does not core when used in vect_fprint, since someone thought t...
Definition: entity.c:453
bool entity_in_formal_area_p(entity e)
Formal parameters do not use the standard ram storage.
Definition: entity.c:3196
const char * entity_module_name(entity e)
See comments about module_name().
Definition: entity.c:1092
#define entity_storage(x)
Definition: ri.h:2794
#define storage_return_p(x)
Definition: ri.h:2516
bool sc_weak_consistent_p(Psysteme sc)
check that sc is well defined, that the numbers of equalities and inequalities are consistent with th...
Definition: sc.c:362
struct Svecteur * succ
Definition: vecteur-local.h:92
bool old_value_entity_p(entity)
Definition: value.c:936
#define vecteur_var(v)
#define BASE_UNDEFINED_P(b)
#define BASE_UNDEFINED
#define term_cst(varval)

References BASE_UNDEFINED, BASE_UNDEFINED_P, CAR, debug(), dump_transformer, entities_may_conflict_p(), ENTITY, entity_has_values_p(), entity_in_formal_area_p(), entity_is_argument_p(), entity_local_name(), entity_module_name(), entity_name, entity_storage, entity_stub_sink_p(), FOREACH, ifdebug, MAP, old_value_entity_p(), pips_debug, pips_internal_error, pips_user_warning, POP, predicate_system, same_string_p, sc_weak_consistent_p(), storage_return_p, Svecteur::succ, TCST, term_cst, transformer_argument_consistency_p(), transformer_arguments, TRANSFORMER_CONSISTENCY_P_DEBUG_LEVEL, transformer_defined_p(), transformer_relation, value_to_variable(), and vecteur_var.

Referenced by transformer_consistency_p(), transformer_weak_consistency_p(), and transformers_consistency_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ transformer_identity()

transformer transformer_identity ( void  )

Allocate an identity transformer.

return make_transformer(NIL, make_predicate(SC_RN));

en fait, on voudrait initialiser a "liste de contraintes vide"

Definition at line 110 of file basic.c.

111 {
112  /* return make_transformer(NIL, make_predicate(SC_RN)); */
113  /* en fait, on voudrait initialiser a "liste de contraintes vide" */
114  return make_transformer(NIL,
117 }
Psysteme sc_make(Pcontrainte leg, Pcontrainte lineg)
Psysteme sc_make(Pcontrainte leg, Pcontrainte lineg): allocation et initialisation d'un systeme d'equ...
Definition: sc.c:78

References CONTRAINTE_UNDEFINED, make_predicate(), make_transformer(), NIL, and sc_make().

Referenced by __attribute__(), addition_operation_to_transformer(), any_expression_to_transformer(), any_expressions_to_transformer(), any_user_call_site_to_transformer(), args_to_transformer(), bitwise_xor_to_transformer(), block_continuation_conditions(), block_to_transformer(), c_data_to_prec_for_variables(), c_return_to_transformer(), call_continuation_conditions(), call_to_transformer(), clean_up_transformer_list(), complete_loop_transformer(), complete_loop_transformer_list(), complete_repeatloop_transformer_list(), compute_postcondition(), condition_to_transformer(), constant_to_transformer(), dag_or_cycle_to_flow_sensitive_postconditions_or_transformers(), declaration_to_transformer(), declaration_to_transformer_list(), declarations_to_transformer(), declarations_to_transformer_list(), dimensions_to_transformer(), effects_to_transformer(), expression_multiply_sizeof_to_transformer(), expressions_to_transformer(), forloop_to_transformer(), fortran_data_to_prec_for_variables(), generic_abs_to_transformer(), generic_module_name_to_transformers(), generic_transformer_list_to_transformer(), iabs_to_transformer(), instruction_to_transformer(), integer_binary_operation_to_transformer(), integer_call_expression_to_transformer(), integer_expression_to_transformer(), integer_left_shift_to_transformer(), integer_minmax_to_transformer(), integer_multiply_to_transformer(), integer_power_to_transformer(), interprocedural_abc_arrays(), intrinsic_to_transformer(), load_completed_statement_transformer(), logical_binary_function_to_transformer(), logical_expression_to_transformer(), loop_continuation_conditions(), loop_to_continue_transformer(), loop_to_enter_transformer(), merge_transformer_lists(), module_name_to_total_preconditions(), module_summary_continuation_conditions(), 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(), modulo_to_transformer(), new_complete_whileloop_transformer_list(), new_whileloop_to_k_transformer(), new_whileloop_to_transformer(), old_complete_whileloop_transformer(), old_summary_precondition(), ordinary_summary_precondition(), pointer_unary_operation_to_transformer(), precondition_intra_to_inter(), program_postcondition(), program_precondition(), repeatloop_to_postcondition(), repeatloop_to_transformer(), safe_any_assign_operation_to_transformer(), safe_any_expression_to_transformer(), safe_assigned_expression_to_transformer(), safe_assigned_expression_to_transformer_list(), safe_expression_to_transformer(), sequence_dg(), standard_whileloop_to_transformer(), statement_continuation_conditions(), statement_to_transformer(), statement_to_transformer_list(), summary_total_postcondition(), test_continuation_conditions(), test_to_transformer(), test_to_transformer_list(), transformer_add_any_relation_information(), transformer_apply_field_assignments_or_equalities(), transformer_apply_unknown_field_assignments_or_equalities(), transformer_convex_hulls(), transformer_derivative_fix_point(), transformer_equality_fix_point(), transformer_general_intersection(), transformer_list_generic_transitive_closure(), transformer_safe_domain_intersection(), translate_to_module_frame(), unstructured_continuation_conditions(), unstructured_to_transformer(), and whileloop_to_postcondition().

+ Here is the call graph for this function:

◆ transformer_identity_p()

bool transformer_identity_p ( transformer  t)

Check that t is an identity function.

no variables are modified; no constraints exist on their values

Definition at line 154 of file basic.c.

155 {
156  /* no variables are modified; no constraints exist on their values */
157 
158  Psysteme s;
159 
160  pips_assert("transformer_identity_p", t != transformer_undefined);
162  return transformer_arguments(t) == NIL && sc_nbre_egalites(s) == 0
163  && sc_nbre_inegalites(s) == 0;
164 }

References NIL, pips_assert, predicate_system, transformer_arguments, transformer_relation, and transformer_undefined.

Referenced by add_module_call_site_precondition(), check_transformer_list(), clean_up_transformer_list(), merge_transformer_lists(), modulo_to_transformer(), process_call_for_summary_precondition(), and two_transformers_to_list().

+ Here is the caller graph for this function:

◆ transformer_inequalities_add()

transformer transformer_inequalities_add ( transformer  tf,
Pcontrainte  ineqs 
)

Warning:

Parameters
tff
ineqsneqs

Definition at line 409 of file basic.c.

410 {
412 
413  for(ineq = ineqs; !CONTRAINTE_UNDEFINED_P(ineq); ineq = contrainte_succ(ineq))
414  (void) transformer_constraint_add(tf,
415  contrainte_vecteur(ineq),
416  false);
417  return tf;
418 }
#define CONTRAINTE_UNDEFINED_P(c)
#define contrainte_succ(c)

References contrainte_succ, CONTRAINTE_UNDEFINED, CONTRAINTE_UNDEFINED_P, contrainte_vecteur, and transformer_constraint_add().

Referenced by generic_minmax_to_transformer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ transformer_inequalities_constrain_variable_p()

bool transformer_inequalities_constrain_variable_p ( const transformer  t,
const entity  v 
)

Is value v used with a non-zero coefficient by the inequalities of transformer t?

Definition at line 972 of file basic.c.

973 {
976 }
bool sc_inequalities_constrain_variable_p(Psysteme sc, Variable var)
Definition: sc_misc.c:195

References predicate_system, sc_inequalities_constrain_variable_p(), and transformer_relation.

+ Here is the call graph for this function:

◆ transformer_inequality_add()

◆ transformer_internal_consistency_p()

bool transformer_internal_consistency_p ( transformer  t)

Same as above but equivalenced variables should not appear in the argument list or in the predicate basis.

Definition at line 790 of file basic.c.

791 {
793  Pbase b = sc_base(sc);
794  Pbase e = BASE_UNDEFINED;
795  list args = transformer_arguments(t);
796  bool consistent = transformer_consistency_p(t);
797 
798  FOREACH(ENTITY, e, args) {
800 
801  if(v!=e) {
802  pips_user_warning("New value %s should be the same entity as variable %s"
803  " as long as equivalence equations are not added\n",
805  pips_assert("Argument must be a value", false);
806  }
807  }
808 
809  for(e=b; !BASE_NULLE_P(e); e = vecteur_succ(e)) {
810  entity val = (entity) vecteur_var(e);
811 
812  if(!(new_value_entity_p(val) || old_value_entity_p(val)
813  || intermediate_value_entity_p(val))) {
814  // Don't we need something else for sizeof variables ?
815  if(!entity_constant_p(val) && !entity_symbolic_p(val)
816  && !entity_null_locations_p(val)) {
817  pips_user_warning("Variable %s in basis should be an internal value",
818  entity_local_name(val));
819  pips_assert("Basis variables must be an internal value", false);
820  }
821  }
822  }
823 
824  return consistent;
825 }
bool entity_null_locations_p(entity e)
test if an entity is the NULL POINTER
#define entity_symbolic_p(e)
#define entity_constant_p(e)
bool intermediate_value_entity_p(entity)
Definition: value.c:955
bool new_value_entity_p(entity)
the following three functions are directly or indirectly relative to the current module and its value...
Definition: value.c:925
#define vecteur_succ(v)
#define BASE_NULLE_P(b)

References BASE_NULLE_P, BASE_UNDEFINED, ENTITY, entity_constant_p, entity_local_name(), entity_null_locations_p(), entity_symbolic_p, entity_to_new_value(), FOREACH, intermediate_value_entity_p(), new_value_entity_p(), old_value_entity_p(), pips_assert, pips_user_warning, predicate_system, transformer_arguments, transformer_consistency_p(), transformer_relation, vecteur_succ, and vecteur_var.

Referenced by recompute_loop_transformer(), statement_to_transformer(), statement_to_transformer_list(), transformer_add_integer_relation_information(), and unstructured_to_flow_insensitive_transformer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ transformer_is_empty_p()

bool transformer_is_empty_p ( transformer  t)

Check that transformer t is the canonical representation of an empty transformer.

See transformer_empty_p(), transformer_strongly_empty_p() if you need to check that a set of affine constraints is not feasible.

Definition at line 172 of file basic.c.

173 {
174  Psysteme s;
175 
176  pips_assert("transformer_identity_p", t != transformer_undefined);
178  return sc_empty_p(s) && ENDP(transformer_arguments(t));
179 }

References ENDP, pips_assert, predicate_system, sc_empty_p(), transformer_arguments, transformer_relation, and transformer_undefined.

Referenced by generic_apply_effects_to_transformer(), transformer_combine(), and transformer_normalize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ transformer_is_rn_p()

bool transformer_is_rn_p ( transformer  t)

Check that transformer t is the canonical representation of the whole afine space defined by its basis.

Definition at line 183 of file basic.c.

184 {
185  Psysteme s;
186 
187  pips_assert("transformer_identity_p", t != transformer_undefined);
189  return sc_nbre_egalites(s)==0 && sc_nbre_inegalites(s)==0;
190 }

References pips_assert, predicate_system, transformer_relation, and transformer_undefined.

Referenced by eval_linear_expression(), and transformer_combine().

+ Here is the caller graph for this function:

◆ transformer_projectable_values()

list transformer_projectable_values ( transformer  tf)
Parameters
tff

Definition at line 827 of file basic.c.

828 {
829  list proj = NIL;
831  Pbase b = BASE_UNDEFINED;
832 
833  for(b=sc_base(sc); !BASE_NULLE_P(b); b = vecteur_succ(b)) {
834  entity v = (entity) vecteur_var(b);
835 
836  proj = CONS(ENTITY, v, proj);
837  }
838 
839  return proj;
840 }
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150

References BASE_NULLE_P, BASE_UNDEFINED, CONS, ENTITY, NIL, predicate_system, transformer_relation, vecteur_succ, and vecteur_var.

Referenced by recompute_loop_transformer().

+ Here is the caller graph for this function:

◆ transformer_weak_consistency_p()

bool transformer_weak_consistency_p ( transformer  t)

Interprocedural transformers do not meet all conditions.

Definition at line 626 of file basic.c.

628 {
629  return transformer_general_consistency_p(t, true);
630 }

References transformer_general_consistency_p().

Referenced by c_user_call_to_transformer(), fortran_user_call_to_transformer(), transformer_filter(), transformer_formal_parameter_projection(), transformer_projection_with_redundancy_elimination_and_check(), and transformer_return_value_projection().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ transformers_consistency_p()

bool transformers_consistency_p ( list  tl)
Parameters
tll

Definition at line 616 of file basic.c.

617 {
618  bool consistent_p = true;
619  FOREACH(TRANSFORMER, t, tl) {
620  consistent_p = consistent_p && transformer_general_consistency_p(t, false);
621  }
622  return consistent_p;
623 }
#define TRANSFORMER(x)
TRANSFORMER.
Definition: ri.h:2841

References FOREACH, TRANSFORMER, and transformer_general_consistency_p().

Referenced by safe_assigned_expression_to_transformer_list().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ value_belongs_to_transformer_space()

bool value_belongs_to_transformer_space ( entity  v,
transformer  tf 
)
Parameters
tff

Definition at line 842 of file basic.c.

843 {
845  Pbase b = BASE_UNDEFINED;
846  bool found_p = false;
847 
848  for(b=sc_base(sc); !BASE_NULLE_P(b); b = vecteur_succ(b)) {
849  entity bv = (entity) vecteur_var(b);
850 
851  if(bv==v) {
852  found_p = true;
853  break;
854  }
855  }
856  return found_p;
857 }

References BASE_NULLE_P, BASE_UNDEFINED, predicate_system, transformer_relation, vecteur_succ, and vecteur_var.

Referenced by transformer_add_variable_type_information().

+ Here is the caller graph for this function: