PIPS
effects-util-local.h
Go to the documentation of this file.
1 /*
2 
3  $Id: effects-util-local.h 23412 2017-08-09 15:07:09Z irigoin $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of PIPS.
8 
9  PIPS is free software: you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 
25 #include "linear.h"
26 #include "newgen.h"
27 #include "ri.h"
28 #include "effects.h"
29 #include "points_to_private.h"
30 
31 #define ANY_MODULE_NAME "*ANY_MODULE*"
32 #define ANYWHERE_LOCATION "*ANYWHERE*"
33 #define NOWHERE_LOCATION "*NOWHERE*"
34 // Target of the null pointers:
35 #define NULL_POINTER_NAME "*NULL*"
36 #define UNDEFINED_LOCATION "*UNDEFINED*"
37 
38 #define UNDEFINED_POINTER_VALUE_NAME "*UNDEFINED*"
39 #define NULL_POINTER_VALUE_NAME "*NULL*"
40 
41 #define PHI_PREFIX "PHI"
42 #define PSI_PREFIX "PSI"
43 #define RHO_PREFIX "RHO"
44 #define BETA_PREFIX "BETA"
45 #define PROPER true
46 #define SUMMARY false
47 
48 /* some useful SHORTHANDS for EFFECT:
49  */
50 /* FI: Let's hope this one is not used as lhs! */
51 #define effect_any_entity(e) effect_to_entity(e)
52 #define effect_action_tag(eff) action_tag(effect_action(eff))
53 #define effect_approximation_tag(eff) \
54  approximation_tag(effect_approximation(eff))
55 
56 /* #define effect_scalar_p(eff) entity_scalar_p(effect_entity(eff))
57  *
58  * The semantics of effects_scalar_p() must be refined. If all the
59  * indices are constant expressions, we still have a scalar effect,
60  * unless they are later replaced by "*", as is the case currently for
61  * summary effects.
62  *
63  * Potential bug: eff is evaluated twice. Should be copied in a local
64  * variable and braces be used.
65  */
66 /*
67 //#define effect_scalar_p(eff) (((type_depth(entity_type(effect_entity(eff)))==0) \
68 // || ((type_depth(entity_type(effect_entity(eff)))==1) \
69 // && pointer_type_p(entity_type(effect_entity(eff))))) \
70 // && ENDP(reference_indices(effect_any_reference(eff))))
71 */
72 #define effect_read_p(eff) (action_tag(effect_action(eff))==is_action_read)
73 #define effect_write_p(eff) (action_tag(effect_action(eff))==is_action_write)
74 #define effect_may_p(eff) \
75  (approximation_tag(effect_approximation(eff)) == is_approximation_may)
76 #define effect_must_p(eff) \
77  (approximation_tag(effect_approximation(eff)) == is_approximation_must)
78 #define effect_exact_p(eff) \
79  (approximation_tag(effect_approximation(eff)) ==is_approximation_exact)
80 
81 
82 
83 
84 /* For COMPATIBILITY purpose only - DO NOT USE anymore
85  */
86 #define effect_variable(e) reference_variable(effect_any_reference(e))
87 
88 
89 
90 /* true if e is a phi variable
91  * PHI entities have a name like: REGIONS:PHI#, where # is a number.
92  * takes care if TCST and undefined entities, just in case.
93  * FC, 09/12/94
94  */
95 #define variable_phi_p(e) \
96  ((e)!=(entity)NULL && (e)!=entity_undefined && \
97  strncmp(entity_name(e), REGIONS_MODULE_NAME, 10)==0 && \
98  strstr(entity_name(e), PHI_PREFIX) != NULL)
99 
100 #define variable_psi_p(e) \
101  ((e)!=(entity)NULL && (e)!=entity_undefined && \
102  strncmp(entity_name(e), REGIONS_MODULE_NAME, 10)==0 && \
103  strstr(entity_name(e), PSI_PREFIX) != NULL)
104 
105 #define variable_rho_p(e) \
106  ((e)!=(entity)NULL && (e)!=entity_undefined && \
107  strncmp(entity_name(e), REGIONS_MODULE_NAME, 10)==0 && \
108  strstr(entity_name(e), RHO_PREFIX) != NULL)
109 
110 #define variable_beta_p(e)\
111  ((e)!=(entity)NULL && (e)!=entity_undefined && \
112  strncmp(entity_name(e), REGIONS_MODULE_NAME, 10)==0 && \
113  strstr(entity_name(e), BETA_PREFIX) != NULL)
114 
115 #define effect_system(e) \
116  (descriptor_convex_p(effect_descriptor(e))? \
117  descriptor_convex(effect_descriptor(e)) : SC_UNDEFINED)
118 
119 /* FI: it would be useful to assert cell_preference_p(effect_cell(e)),
120  but I do not know how to do it in such a way that it works both for
121  left hand sides and right hand sides using commas.
122  I definitely remove this one : it is too dangerous.
123 */
124 /* #define effect_reference(e) \
125  preference_reference(cell_preference(effect_cell(e))) */
126 #define effect_reference(e) \
127  /* DO NOT REMOVE, PREVENT REDEFINITION :)
128  * use effect_any_reference instead !
129  */ \
130  effect_reference_not_defined_anymore()
131 
132 /* FI: cannot be used as a left hand side */
133 #define effect_any_reference(e) \
134  (cell_preference_p(effect_cell(e))? preference_reference(cell_preference(effect_cell(e))) : cell_reference(effect_cell(e)))
135 #define make_preference_simple_effect(reference,action,approximation)\
136  make_effect(make_cell(is_cell_preference, make_preference(reference)),\
137  (action), (approximation), \
138  make_descriptor(is_descriptor_none,UU))
139 
140 #define make_reference_simple_effect(reference,action,approximation)\
141  make_effect(make_cell(is_cell_reference, (reference)), \
142  (action), (approximation), \
143  make_descriptor(is_descriptor_none,UU))
144 
145 #define make_simple_effect(reference,action,approximation)\
146  make_effect(make_cell(is_cell_preference, make_preference(reference)),\
147  (action), (approximation), \
148  make_descriptor(is_descriptor_none,UU))
149 
150 #define make_convex_effect(reference,action,approximation,system)\
151  make_effect(make_cell(is_reference, (reference)), \
152  (action), (approximation), \
153  make_descriptor(is_descriptor_convex,system))
154 
155 
156 /********* CELL_RELATION SHORTHANDS */
157 
158 #define cell_relation_first_cell(cr)\
159  interpreted_cell_cell(cell_relation_first(cr))
160 
161 #define cell_relation_first_interpretation_tag(cr)\
162  cell_interpretation_tag(interpreted_cell_cell_interpretation(cell_relation_first(cr)))
163 
164 #define cell_relation_first_value_of_p(cr)\
165  cell_interpretation_value_of_p(interpreted_cell_cell_interpretation(cell_relation_first(cr)))
166 
167 #define cell_relation_first_address_of_p(cr)\
168  cell_interpretation_address_of_p(interpreted_cell_cell_interpretation(cell_relation_first(cr)))
169 
170 #define cell_relation_second_cell(cr)\
171  interpreted_cell_cell(cell_relation_second(cr))
172 
173 #define cell_relation_second_interpretation_tag(cr)\
174  cell_interpretation_tag(interpreted_cell_cell_interpretation(cell_relation_second(cr)))
175 
176 #define cell_relation_second_value_of_p(cr)\
177  cell_interpretation_value_of_p(interpreted_cell_cell_interpretation(cell_relation_second(cr)))
178 
179 #define cell_relation_second_address_of_p(cr)\
180  cell_interpretation_address_of_p(interpreted_cell_cell_interpretation(cell_relation_second(cr)))
181 
182 #define cell_relation_approximation_tag(cr)\
183  approximation_tag(cell_relation_approximation(cr))
184 
185 #define cell_relation_may_p(cr)\
186  approximation_tag(cell_relation_approximation(cr))==is_approximation_may
187 
188 #define cell_relation_exact_p(cr)\
189  approximation_tag(cell_relation_approximation(cr))==is_approximation_exact
190 
191 #define pips_debug_pv(level, message, pv) \
192  ifdebug(level) { pips_debug(level, "%s\n", message); \
193  print_pointer_value(pv);}
194 
195 #define pips_debug_pvs(level, message, l_pv) \
196  ifdebug(level) { pips_debug(level, "%s\n", message); \
197  print_pointer_values(l_pv);}
198 
199 /********* CONTEXT AND FLOW SENSITIVITY INFORMATION */
200 typedef struct
201 {
204  list enclosing_flow; /* not used yet, we don't know if it should retain enclosing loops and/or modules */
static string current_module
Definition: message.c:63
static statement current_stmt
The structure used to build lists in NewGen.
Definition: newgen_list.h:41