PIPS
pointer_values.c
Go to the documentation of this file.
1 /*
2 
3  $Id: pointer_values.c 23065 2016-03-02 09:05:50Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6  Copyright 2010 HPC Project
7 
8  This file is part of PIPS.
9 
10  PIPS is free software: you can redistribute it and/or modify it
11  under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  any later version.
14 
15  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
16  WARRANTY; without even the implied warranty of MERCHANTABILITY or
17  FITNESS FOR A PARTICULAR PURPOSE.
18 
19  See the GNU General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
23 */
24 
25 #ifdef HAVE_CONFIG_H
26  #include "pips_config.h"
27 #endif
28 
29 #include <stdio.h>
30 #include <string.h>
31 
32 #include "genC.h"
33 #include "linear.h"
34 #include "ri.h"
35 #include "ri-util.h"
36 #include "effects.h"
37 #include "effects-util.h"
38 #include "misc.h"
39 
40 /***************** ABSTRACT VALUES */
41 
43 {
45  string u_name = strdup(concatenate(ANY_MODULE_NAME,
48  NULL));
49  u = gen_find_tabulated(u_name, entity_domain);
50  if(entity_undefined_p(u)) {
51  type tv = make_type_void(NIL);
53  type t = make_type_variable(v);
54  u = make_entity(u_name,
57  }
58  return u;
59 }
60 
61 
63 {
66 }
67 
69 {
70  bool res;
73  return res;
74 }
75 
77 {
78  reference r;
79  if (cell_gap_p(c)) return false;
80  else if (cell_reference_p(c))
81  r = cell_reference(c);
82  else
85 }
86 
88 {
89  return entity_null_locations();
90 }
91 
92 
94 {
97 }
98 
100 {
101  return entity_null_locations_p(e);
102 }
103 
105 {
106  reference r;
107  if (cell_gap_p(c)) return false;
108  else if (cell_reference_p(c))
109  r = cell_reference(c);
110  else
113 }
114 
116 {
119 }
120 
122 {
124 }
125 
126 /***************** SHORTCUTS FOR MAKING POINTER_VALUES CELL_RELATIONS */
127 
128 
130 {
134 
136  pv = make_cell_relation(ic2, ic1, make_approximation(app_tag, UU), d);
137  else
138  pv = make_cell_relation(ic1, ic2, make_approximation(app_tag, UU), d);
139  return(pv);
140 }
141 
143 {
146  cell_relation pv = make_cell_relation(ic1, ic2, make_approximation(app_tag, UU), d);
147  return(pv);
148 }
149 
150 /***************** UTILS */
151 
152 /*
153  @brief tests the syntactic equality of the corresponding cells of two pointer_value relations
154  @param pv1 is a pointer_value
155  @param pv2 is another pointer value
156  @return true if the input pointer values are syntactically equal.
157 
158  if both pvs are value_of pvs, they are considered equal if their first cells are equal
159  and second cells are equal but also if the first cell of the first pv is equal to
160  the second cell of the second pv and conversely.
161  */
163 {
164 
165 
166  bool value_of_1_p = cell_relation_second_value_of_p(pv1);
167  bool value_of_2_p = cell_relation_second_value_of_p(pv1);
168 
169  if ( (value_of_1_p && !value_of_2_p) || (value_of_2_p && !value_of_1_p))
170  return false;
171 
172  cell c_first_1 = cell_relation_first_cell(pv1);
173  cell c_second_1 = cell_relation_second_cell(pv1);
174 
175  cell c_first_2 = cell_relation_first_cell(pv2);
176  cell c_second_2 = cell_relation_second_cell(pv2);
177 
178  int n_first_first = cell_compare(&c_first_1, &c_first_2);
179 
180  if (n_first_first == 0)
181  {
182  int n_second_second = cell_compare(&c_second_1, &c_second_2);
183 
184  if (n_second_second != 0)
185  return false;
186  }
187  else
188  {
189  if (!value_of_1_p)
190  return false;
191  else /* value_of pvs, try to see if their cells are inverted */
192  {
193  int n_first_second = cell_compare(&c_first_1, &c_second_2);
194  if (n_first_second == 0)
195  {
196  int n_second_first = cell_compare(&c_second_1, &c_first_2);
197 
198  if (n_second_first != 0)
199  return false;
200  }
201  else
202  return false;
203 
204  }
205  }
206 
209 
210  if (descriptor_none_p(d1) && descriptor_none_p(d2))
211  {
212  return true;
213  }
214  else
215  pips_internal_error("Convex pointer_values not implemented yet");
216 
217  return false;
218 }
219 
220 /*
221  @brief tests the syntactic equality of the corresponding cells of two pointer_value relations
222  @param pv1 is a pointer_value
223  @param pv2 is another pointer value
224  @return true if the input pointer values are syntactically equal.
225 
226  if both pvs are value_of pvs, they are considered equal if their first cells are equal
227  and second cells are equal but also if the first cell of the first pv is equal to
228  the second cell of the second pv and conversely.
229  */
231 {
232 
233 
234  bool value_of_1_p = cell_relation_second_value_of_p(pv1);
235  bool value_of_2_p = cell_relation_second_value_of_p(pv1);
236 
237  if ( (value_of_1_p && !value_of_2_p) || (value_of_2_p && !value_of_1_p))
238  return false;
239 
240  cell c_first_1 = cell_relation_first_cell(pv1);
241  cell c_second_1 = cell_relation_second_cell(pv1);
242 
243  cell c_first_2 = cell_relation_first_cell(pv2);
244  cell c_second_2 = cell_relation_second_cell(pv2);
245 
246  int n_first_first = cell_compare(&c_first_1, &c_first_2);
247 
248  if (n_first_first == 0)
249  {
250  int n_second_second = cell_compare(&c_second_1, &c_second_2);
251 
252  if (n_second_second != 0)
253  {
254  if (cell_entity(c_second_1) != cell_entity(c_second_2)
257  return false;
258  }
259  }
260  else
261  {
262  if (!value_of_1_p)
263  return false;
264  else /* value_of pvs, try to see if their cells are inverted */
265  {
266  int n_first_second = cell_compare(&c_first_1, &c_second_2);
267  if (n_first_second == 0)
268  {
269  int n_second_first = cell_compare(&c_second_1, &c_first_2);
270 
271  if (n_second_first != 0)
272  return false;
273  }
274  else
275  return false;
276 
277  }
278  }
279 
282 
283  if (descriptor_none_p(d1) && descriptor_none_p(d2))
284  {
285  return true;
286  }
287  else
288  pips_internal_error("Convex pointer_values not implemented yet");
289 
290  return false;
291 }
292 
cell make_cell_reference(reference _field_)
Definition: effects.c:293
cell_relation make_cell_relation(interpreted_cell a1, interpreted_cell a2, approximation a3, descriptor a4)
Definition: effects.c:341
interpreted_cell make_interpreted_cell(cell a1, cell_interpretation a2)
Definition: effects.c:709
cell_interpretation make_cell_interpretation_value_of(void)
Definition: effects.c:237
cell_interpretation make_cell_interpretation_address_of(void)
Definition: effects.c:240
approximation make_approximation(enum approximation_utype tag, void *val)
Definition: effects.c:176
value make_value_unknown(void)
Definition: ri.c:2847
type make_type_variable(variable _field_)
Definition: ri.c:2715
storage make_storage_rom(void)
Definition: ri.c:2285
type make_type_void(list _field_)
Definition: ri.c:2727
basic make_basic_pointer(type _field_)
Definition: ri.c:179
reference make_reference(entity a1, list a2)
Definition: ri.c:2083
variable make_variable(basic a1, list a2, list a3)
Definition: ri.c:2895
bool entity_null_locations_p(entity e)
test if an entity is the NULL POINTER
entity entity_null_locations()
return TOP-LEVEL:NULL_POINTER The NULL pointer should be a global variable, unique for all modules FI...
int cell_compare(cell *c1, cell *c2)
Definition: compare.c:168
#define UNDEFINED_POINTER_VALUE_NAME
#define cell_relation_second_cell(cr)
#define cell_relation_second_value_of_p(cr)
#define cell_relation_first_cell(cr)
#define ANY_MODULE_NAME
reference cell_any_reference(cell)
API for reference.
Definition: effects.c:77
entity cell_entity(cell)
Definition: effects.c:57
#define cell_reference(x)
Definition: effects.h:469
#define cell_relation_descriptor(x)
Definition: effects.h:517
#define cell_preference(x)
Definition: effects.h:472
#define cell_reference_p(x)
Definition: effects.h:467
#define cell_gap_p(x)
Definition: effects.h:473
#define cell_relation_undefined
Definition: effects.h:485
#define descriptor_none_p(x)
Definition: effects.h:602
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
size_t gen_length(const list l)
Definition: list.c:150
#define pips_internal_error
Definition: misc-local.h:149
#define MODULE_SEP_STRING
Definition: naming-local.h:30
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
#define same_string_p(s1, s2)
void * gen_find_tabulated(const char *, int)
Definition: tabulated.c:218
int tag
TAG.
Definition: newgen_types.h:92
#define UU
Definition: newgen_types.h:98
cell_relation make_address_of_pointer_value(cell c1, cell c2, tag app_tag, descriptor d)
bool null_pointer_value_cell_p(cell c)
cell make_undefined_pointer_value_cell()
entity null_pointer_value_entity()
bool null_pointer_value_entity_p(entity e)
cell make_null_pointer_value_cell()
bool abstract_pointer_value_entity_p(entity e)
bool pv_cells_mergeable_p(cell_relation pv1, cell_relation pv2)
bool undefined_pointer_value_entity_p(entity e)
bool abstract_pointer_value_cell_p(cell c)
bool pv_cells_syntactically_equal_p(cell_relation pv1, cell_relation pv2)
bool undefined_pointer_value_cell_p(cell c)
cell_relation make_value_of_pointer_value(cell c1, cell c2, tag app_tag, descriptor d)
entity undefined_pointer_value_entity()
pointer_values.c
#define make_entity(n, t, s, i)
@ ABSTRACT_LOCATION
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
const char * entity_module_name(entity e)
See comments about module_name().
Definition: entity.c:1092
#define reference_variable(x)
Definition: ri.h:2326
#define entity_undefined_p(x)
Definition: ri.h:2762
#define entity_undefined
Definition: ri.h:2761
#define reference_indices(x)
Definition: ri.h:2328
#define preference_reference(x)
Definition: ri.h:2102
#define entity_kind(x)
Definition: ri.h:2798
#define entity_domain
newgen_syntax_domain_defined
Definition: ri.h:410
char * strdup()