PIPS
type.c File Reference
#include "genC.h"
#include "linear.h"
#include "misc.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"
+ Include dependency graph for type.c:

Go to the source code of this file.

Macros

#define unsigned_char   11
 
#define unsigned_short_int   12
 
#define unsigned_int   14
 
#define unsigned_long_int   16
 
#define unsigned_long_long_int   18
 

Functions

static void add_type_information (transformer tf)
 Add some of the constraints linked to the type of a variable. More...
 
void transformer_add_type_information (transformer tf)
 type.c More...
 
void transformer_add_variable_type_information (transformer tf, entity v)
 

Macro Definition Documentation

◆ unsigned_char

#define unsigned_char   11

Definition at line 54 of file type.c.

◆ unsigned_int

#define unsigned_int   14

Definition at line 56 of file type.c.

◆ unsigned_long_int

#define unsigned_long_int   16

Definition at line 57 of file type.c.

◆ unsigned_long_long_int

#define unsigned_long_long_int   18

Definition at line 58 of file type.c.

◆ unsigned_short_int

#define unsigned_short_int   12

Definition at line 55 of file type.c.

Function Documentation

◆ add_type_information()

static void add_type_information ( transformer  tf)
static

Add some of the constraints linked to the type of a variable.

lb = 0

We assume exists lambda s.t. e = ep + period*lambda

Compute the value of lambda

Now we must get rid of lambda and e and possibly e's old value

Transformer projection removes variables from the argument list as well as from the contraint system.

Now we must substitute ep by e

Definition at line 61 of file type.c.

62 {
64  Pbase b = vect_copy(sc_base(ps)); // FI: the basis may evolve when
65  // new constraints are added
66  Pbase cb = BASE_NULLE;
67 
68  for(cb=b; !BASE_NULLE_P(cb); cb = vecteur_succ(cb)) {
69  Variable v = vecteur_var(cb);
70  //entity ev = (entity) v;
71  if(v!=TCST && !local_old_value_entity_p(v)) { // FI: TCST check should be useless in a basis
74  if(unsigned_type_p(t)) {
76  int s = basic_int(tb);
77  // FI: the lower bound, lb, could also be defined, e.g. for "char"
78  long long int ub = -1/*, lb = 0*/;
79  long long int period = 0;
80  switch(s) {
81  case unsigned_char:
82  ub = 256-1, period = 256;
83  break;
84  case unsigned_short_int:
85  ub = 256*256-1, period = 256*256;
86  break;
87  case unsigned_int:
88  // We go straight to the overflows!
89  // ub = 256L*256L*256L*256L-1;
90  ub = 0, period = 256L*256L*256L*256L;
91  break;
92  case unsigned_long_int:
93  // We go straight to the overflows!
94  // ub = 256L*256L*256L*256L-1;
95  ub = 0, period = 256L*256L*256L*256L;
96  break;
98  // We go straight to the overflows!
99  //ub = 256*256*256*256*256*256*256*256-1;
100  //ub = 0; // FI: too dangerous
101  break;
102  default:
103  ub=-1; // do nothing
104  break;
105  }
106  if(ub>=0) {
107  /* We assume exists lambda s.t. e = ep + period*lambda */
111  if(ub>0) {
112  // Without this dangerous upperbound, we lose information
113  // but avoid giving wrong results.
114  // FI: The upperbound is dangerous because linear does not
115  // expect such large constants, especially my bounded normalization
116  // that should be itself bounded! See
117  // check_coefficient_reduction() and the stack allocation
118  // of arrays a, b and c!
120  }
121  Pvecteur eq =
123  ep, VALUE_ONE,
124  lambda, (Value) period, TCST, VALUE_ZERO, NULL);
125  tf = transformer_equality_add(tf, eq);
126  /* Compute the value of lambda */
127  Value pmin, pmax;
128  if(precondition_minmax_of_value(lambda, tf, (intptr_t*) &pmin, (intptr_t*) &pmax)) {
129  if(pmin==pmax)
130  tf = transformer_add_equality_with_integer_constant(tf, lambda, pmin);
131  }
132  /* Now we must get rid of lambda and e and possibly e's old value */
133  list p =
134  CONS(ENTITY, e, CONS(ENTITY, lambda, NIL));
135  pips_assert("ep is in tf basis",
136  base_contains_variable_p(sc_base(ps), ep));
137  pips_assert("lambda is in tf basis",
138  base_contains_variable_p(sc_base(ps), lambda));
140  entity old_e = entity_to_old_value(e);
141  p = CONS(ENTITY, old_e, p);
142  pips_assert("old_e is in tf basis",
143  base_contains_variable_p(sc_base(ps), ep));
144  }
145  /* Transformer projection removes variables from the
146  argument list as well as from the contraint system. */
148  tf = safe_transformer_projection(tf, p);
150  transformer_arguments(tf) = args;
151  gen_free_list(p);
152  /* Now we must substitute ep by e */
153  tf = transformer_value_substitute(tf, ep, e);
154  }
155  }
156  }
157  }
158  vect_rm(b);
159  return;
160 }
bool entity_is_argument_p(entity e, cons *args)
Definition: arguments.c:150
#define VALUE_ZERO
#define VALUE_MONE
int Value
#define VALUE_ONE
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
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.
Definition: basic.c:477
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.
Definition: basic.c:450
transformer transformer_equality_add(transformer tf, Pvecteur i)
Definition: basic.c:383
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
list gen_copy_seq(list l)
Copy a list structure.
Definition: list.c:501
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
bool unsigned_type_p(type t)
Predicates on types.
Definition: type.c:2821
type entity_basic_concrete_type(entity e)
retrieves or computes and then returns the basic concrete type of an entity
Definition: type.c:3677
#define basic_int(x)
Definition: ri.h:616
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define type_variable(x)
Definition: ri.h:2949
#define transformer_relation(x)
Definition: ri.h:2873
#define transformer_arguments(x)
Definition: ri.h:2871
#define predicate_system(x)
Definition: ri.h:2069
#define variable_basic(x)
Definition: ri.h:3120
Pcontrainte eq
element du vecteur colonne du systeme donne par l'analyse
Definition: sc_gram.c:108
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 !
Definition: expression.c:5790
#define unsigned_long_int
Definition: type.c:57
#define unsigned_int
Definition: type.c:56
#define unsigned_long_long_int
Definition: type.c:58
#define unsigned_short_int
Definition: type.c:55
#define unsigned_char
Definition: type.c:54
#define intptr_t
Definition: stdint.in.h:294
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
transformer safe_transformer_projection(transformer t, list args)
t may be undefined, args may contain values unrelated to t
Definition: transformer.c:1187
transformer transformer_value_substitute(transformer t, entity e1, entity e2)
transformer transformer_value_substitute(transformer t, entity e1, entity e2): if e2 does not appear ...
Definition: transformer.c:1993
entity make_local_temporary_value_entity(type)
Definition: value.c:605
entity make_local_temporary_integer_value_entity(void)
Definition: value.c:629
bool local_old_value_entity_p(entity)
Return true if an entity is a local old value (such as "o#0" for a global value "i#init"....
Definition: value.c:642
entity entity_to_old_value(entity)
Definition: value.c:869
entity value_to_variable(entity)
Get the primitive variable associated to any value involved in a transformer.
Definition: value.c:1624
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
#define vecteur_var(v)
#define vecteur_succ(v)
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
#define BASE_NULLE
MACROS SUR LES BASES.
#define BASE_NULLE_P(b)
Pvecteur vect_make(Pvecteur v, Variable var, Value val,...)
Pvecteur vect_make(v, [var, val,]* 0, val) Pvecteur v; // may be NULL, use assigne anyway Variable va...
Definition: alloc.c:165
Pbase vect_copy(Pvecteur b)
direct duplication.
Definition: alloc.c:240
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_rm(Pvecteur v)
void vect_rm(Pvecteur v): desallocation des couples de v;
Definition: alloc.c:78

References base_contains_variable_p(), BASE_NULLE, BASE_NULLE_P, basic_int, CONS, ENTITY, entity_basic_concrete_type(), entity_is_argument_p(), entity_to_old_value(), eq, gen_copy_seq(), gen_free_list(), intptr_t, local_old_value_entity_p(), make_local_temporary_integer_value_entity(), make_local_temporary_value_entity(), NIL, pips_assert, precondition_minmax_of_value(), predicate_system, safe_transformer_projection(), TCST, transformer_add_equality_with_integer_constant(), transformer_add_inequality_with_integer_constraint(), transformer_arguments, transformer_equality_add(), transformer_relation, transformer_value_substitute(), type_variable, unsigned_char, unsigned_int, unsigned_long_int, unsigned_long_long_int, unsigned_short_int, unsigned_type_p(), VALUE_MONE, VALUE_ONE, value_to_variable(), VALUE_ZERO, variable_basic, vect_copy(), vect_make(), vect_new(), vect_rm(), vecteur_succ, and vecteur_var.

Referenced by transformer_add_type_information().

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

◆ transformer_add_type_information()

void transformer_add_type_information ( transformer  tf)

type.c

Parameters
tff

Definition at line 162 of file type.c.

163 {
165  return;
166 }
static void add_type_information(transformer tf)
Add some of the constraints linked to the type of a variable.
Definition: type.c:61

References add_type_information().

Referenced by module_name_to_preconditions(), precondition_add_type_information(), statement_to_postcondition(), statement_to_transformer(), and transformer_add_variable_type_information().

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

◆ transformer_add_variable_type_information()

void transformer_add_variable_type_information ( transformer  tf,
entity  v 
)
Parameters
tff

Definition at line 168 of file type.c.

169 {
170  pips_assert("entity has values", entity_has_values_p(v));
171  entity vv = entity_to_new_value(v);
175  return;
176 }
bool value_belongs_to_transformer_space(entity v, transformer tf)
Definition: basic.c:842
void add_value_to_transformer_space(entity v, transformer tf)
Definition: basic.c:859
void transformer_add_type_information(transformer tf)
type.c
Definition: type.c:162
entity entity_to_new_value(entity)
Definition: value.c:859
bool entity_has_values_p(entity)
This function could be made more robust by checking the storage of e.
Definition: value.c:911

References add_value_to_transformer_space(), entity_has_values_p(), entity_to_new_value(), pips_assert, transformer_add_type_information(), and value_belongs_to_transformer_space().

Referenced by declaration_to_transformer().

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