PIPS
methods.c
Go to the documentation of this file.
1 /*
2 
3  $Id: methods.c 23065 2016-03-02 09:05:50Z coelho $
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 #ifdef HAVE_CONFIG_H
25  #include "pips_config.h"
26 #endif
27 /* package generic effects : Be'atrice Creusillet 5/97
28  *
29  * File: utils.c
30  * ~~~~~~~~~~~~~~~~~
31  *
32  * This File contains various useful functions, some of which should be moved
33  * elsewhere.
34  *
35  */
36 
37 #include <stdio.h>
38 #include <string.h>
39 #include <stdlib.h>
40 
41 #include "genC.h"
42 #include "linear.h"
43 #include "ri.h"
44 #include "effects.h"
45 #include "ri-util.h"
46 #include "effects-util.h"
47 #include "text-util.h"
48 
49 #include "effects-generic.h"
50 
51 /* All this has to be changed into a context structure */
52 
53 
54 static pointer_info_val pointer_info_kind = with_no_pointer_info;
55 
57 {
58  pointer_info_kind = val;
59 }
61 {
62  return pointer_info_kind;
63 }
64 
65 static bool constant_paths_p = false;
66 
67 void set_constant_paths_p(bool b)
68 {
69  constant_paths_p = b;
70 }
71 
73 {
74  return constant_paths_p;
75 }
76 
77 
78 /* GENERIC FUNCTIONS on lists of effects to be instanciated for
79  specific types of effects */
80 
81 /* consistency checking */
83 
84 /* initialisation and finalization */
85 void (*effects_computation_init_func)(const char* /* module_name */);
86 void (*effects_computation_reset_func)(const char* /* module_name */);
87 
88 /* dup and free - This should be handled by newgen, but there is a problem
89  * with the persistency of references - I do not understand what happens. */
91 void (*effect_free_func)(effect eff);
92 
93 /* make functions for effects */
95  bool /* use_preference */);
99  int i);
100 
101 /* union */
104  list, list, bool (*eff1_eff2_combinable_p)(effect, effect));
106  list, list, bool (*eff1_eff2_combinable_p)(effect, effect));
107 
108 /* intersection */
110  list, list, bool (*eff1_eff2_combinable_p)(effect, effect));
111 
112 /* difference */
114  list, list, bool (*eff1_eff2_combinable_p)(effect, effect));
116  list, list, bool (*eff1_eff2_combinable_p)(effect, effect));
117 
118 /* composition with transformers */
121 
122 /* composition with preconditions */
124 
125 /* evaluation with pointer information */
128 
129 /* union over a range */
132 
133 /* modify effect list depending on loop range information
134  * input list is consummed, it and may be returned or destroyed
135  */
137  entity *, range);
138 
140  list /* of effects */, entity /* index */, range,
141  entity* /* new loop index */, descriptor /* range descriptor */,
142  bool /* normalize descriptor ? */);
145 
146 /* interprocedural translation */
147 void (*effects_translation_init_func)(entity /* callee */,
148  list /* real_args */,
149  bool /* backward_p */);
152 
154 list (*fortran_effects_forward_translation_op)(entity /* callee */, list /* args */,
155  list /* effects */,
156  transformer /* context */);
157 
159 (list /* of effects */,
160  expression /* args */,
161  transformer /* context */);
162 
164 (entity /* callee */ ,
165  expression /* real arg */,
166  entity /* formal entity */,
167  list /* effects */,
168  transformer /* context */);
169 
170 /* local to global name space translation */
172 
173 
174 
175 /* functions to provide context, a.k.a. precondition, and transformer information */
179 
181 
182 /* proper to contracted proper effects or to summary effects functions */
184 
185 /* normalization of descriptors */
186 void (*effects_descriptor_normalize_func)(list /* of effects */);
187 
188 /* getting/putting resources from/to pipsdbm */
189 
191 void (*db_put_proper_rw_effects_func)(const char *, statement_effects);
192 
195 
197 void (*db_put_rw_effects_func)(const char *, statement_effects);
198 
199 list (*db_get_summary_rw_effects_func)(const char *);
200 void (*db_put_summary_rw_effects_func)(const char *, list);
201 
203 void (*db_put_in_effects_func)(const char *, statement_effects);
204 
207 
210 
211 list (*db_get_summary_in_effects_func)(const char *);
212 void (*db_put_summary_in_effects_func)(const char *, list);
213 
214 list (*db_get_summary_out_effects_func)(const char *);
215 void (*db_put_summary_out_effects_func)(const char *, list);
216 
218 void (*db_put_out_effects_func)(const char *, statement_effects);
219 
221 void (*db_put_live_in_paths_func)(const char *, statement_effects);
222 
224 void (*db_put_live_out_paths_func)(const char *, statement_effects);
225 
226 list (*db_get_live_in_summary_paths_func)(const char *);
227 void (*db_put_live_in_summary_paths_func)(const char *, list);
228 
230 void (*db_put_live_out_summary_paths_func)(const char *, list);
231 
234 
235 /* prettyprint function for debug */
236 void (*effects_prettyprint_func)(list); /* should be avoided : use print_effects instead */
238 
239 /* prettyprint function for sequential and user views */
242 
243 
244 /* for cells */
246 
247 // used for convex effects to preserve must regions on tests
249 
250 /* RESET all generic methods... should be called when pips is started...
251  */
252 
253 #define UNDEF abort
254 
255 typedef void (*void_function)();
256 typedef gen_chunk* (*chunks_function)();
257 typedef list (*list_function)();
258 typedef bool (*bool_function)();
259 typedef descriptor (*descriptor_function)();
260 typedef effect (*effect_function)();
261 typedef transformer (*transformer_function)();
263 typedef text (*text_function)();
264 
265 void
267 {
270 
271  effect_dup_func = (effect_function) UNDEF;
273 
274  effect_union_op = (effect_function) UNDEF;
284 
287 
290 
295 
300 
301  load_context_func = (transformer_function) UNDEF;
302  load_transformer_func = (transformer_function) UNDEF;
304  proper_to_summary_effect_func = (effect_function) UNDEF;
306 
335 
338 
339  set_descriptor_range_p(false);
340 
341  /* PRETTYPRINT related functions and settings
342  */
343  set_is_user_view_p(false);
345 
348  effects_to_text_func = (text_function) UNDEF;
350 
353 
355 }
struct _newgen_struct_entity_ * entity
Definition: abc_private.h:14
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
struct _newgen_struct_reference_ * reference
Definition: compsec.h:14
struct _newgen_struct_action_ * action
Definition: compsec.h:21
struct _newgen_struct_effect_ * effect
Definition: dg.h:21
@ with_no_pointer_info
transformer(* load_transformer_func)(statement)
effect(* effect_union_op)(effect, effect)
list(* effects_sup_difference_op)(list, list, bool(*eff1_eff2_combinable_p)(effect, effect))
void(* db_put_invariant_in_effects_func)(const char *, statement_effects)
list(* fortran_effects_backward_translation_op)(entity, list, list, transformer)
statement_effects(* db_get_invariant_in_effects_func)(const char *)
void set_is_user_view_p(bool)
void(* db_put_summary_in_effects_func)(const char *, list)
void(* db_put_in_effects_func)(const char *, statement_effects)
list(* effect_to_constant_path_effects_func)(effect)
bool(* empty_context_test)(transformer)
list(* effects_intersection_op)(list, list, bool(*eff1_eff2_combinable_p)(effect, effect))
transformer(* load_completed_transformer_func)(statement)
void set_contracted_rw_effects(bool)
rw_effects_engine.c
list(* c_effects_on_formal_parameter_backward_translation_func)(list, expression, transformer)
transformer(* load_context_func)(statement)
statement_effects(* db_get_live_in_paths_func)(const char *)
effect(* proper_to_summary_effect_func)(effect)
list(* effects_union_op)(list, list, bool(*eff1_eff2_combinable_p)(effect, effect))
void(* db_put_rw_effects_func)(const char *, statement_effects)
void(* effect_descriptor_interprocedural_translation_op)(effect)
void(* db_put_useful_variables_effects_func)(const char *, entity_effects)
void(* effects_translation_end_func)(void)
void(* effects_descriptor_normalize_func)(list)
pointer_info_val get_pointer_info_kind(void)
list(* effects_transformer_composition_op)(list, transformer)
void(* db_put_invariant_rw_effects_func)(const char *, statement_effects)
statement_effects(* db_get_invariant_rw_effects_func)(const char *)
list(* effect_to_store_independent_effect_list_func)(effect, bool)
bool(* effect_consistent_p_func)(effect)
void(* loop_range_in_effect_func)(loop, list *, list *, bool(*)(effect, effect), entity *, range)
statement_effects(* db_get_live_out_paths_func)(const char *)
descriptor(* loop_descriptor_make_func)(loop)
bool(* cell_preceding_p_func)(cell, descriptor, cell, descriptor, bool, bool *)
void(* effect_free_func)(effect eff)
list(* effects_local_to_global_translation_op)(list)
void(* attach_effects_decoration_to_text_func)(text)
list(* db_get_summary_in_effects_func)(const char *)
effect(* reference_to_effect_func)(reference, action, bool)
statement_effects(* db_get_out_effects_func)(const char *)
void(* db_put_out_effects_func)(const char *, statement_effects)
void set_descriptor_range_p(bool)
void(* db_put_live_out_paths_func)(const char *, statement_effects)
void(* effects_computation_init_func)(const char *)
text(* effects_to_text_func)(list)
list(* db_get_summary_out_effects_func)(const char *)
entity_effects(* db_get_useful_variables_effects_func)(const char *)
void(* db_put_live_in_summary_paths_func)(const char *, list)
statement_effects(* db_get_cumulated_in_effects_func)(const char *)
void(* db_put_live_out_summary_paths_func)(const char *, list)
list(* effects_test_union_op)(list, list, bool(*eff1_eff2_combinable_p)(effect, effect))
void(* effects_translation_init_func)(entity, list, bool)
list(* effects_loop_normalize_func)(list, entity, range, entity *, descriptor, bool)
void reset_generic_prettyprints(void)
void(* effect_prettyprint_func)(effect)
void set_contracted_proper_effects(bool)
end of effects-generic-local.h
bool get_constant_paths_p(void)
void(* db_put_summary_out_effects_func)(const char *, list)
list(* effects_descriptors_variable_change_func)(list, entity, entity)
list(* db_get_live_out_summary_paths_func)(const char *)
void set_prettyprint_with_attachments(bool)
descriptor(* vector_to_descriptor_func)(Pvecteur)
void(* db_put_summary_rw_effects_func)(const char *, list)
void(* effect_add_expression_dimension_func)(effect eff, expression exp)
list(* db_get_live_in_summary_paths_func)(const char *)
void(* effects_computation_reset_func)(const char *)
void(* db_put_cumulated_in_effects_func)(const char *, statement_effects)
list(* effects_inf_difference_op)(list, list, bool(*eff1_eff2_combinable_p)(effect, effect))
effect(* effect_dup_func)(effect eff)
statement_effects(* db_get_in_effects_func)(const char *)
list(* fortran_effects_forward_translation_op)(entity, list, list, transformer)
void(* effect_change_ith_dimension_expression_func)(effect eff, expression exp, int i)
void generic_effects_reset_all_methods(void)
void(* db_put_proper_rw_effects_func)(const char *, statement_effects)
void set_pointer_info_kind(pointer_info_val)
methods.c
list(* eval_cell_with_points_to_func)(cell, descriptor, list, bool *, transformer)
void(* effects_prettyprint_func)(list)
statement_effects(* db_get_proper_rw_effects_func)(const char *)
list(* effects_union_over_range_op)(list, entity, range, descriptor)
void(* db_put_live_in_paths_func)(const char *, statement_effects)
list(* effects_transformer_inverse_composition_op)(list, transformer)
void set_constant_paths_p(bool)
list(* db_get_summary_rw_effects_func)(const char *)
bool(* stmt_strongly_feasible_p_func)(statement)
list(* effects_precondition_composition_op)(list, transformer, bool)
statement_effects(* db_get_rw_effects_func)(const char *)
list(* c_effects_on_actual_parameter_forward_translation_func)(entity, expression, entity, list, transformer)
struct _newgen_struct_cell_ * cell
Definition: effects.h:90
struct _newgen_struct_statement_effects_ * statement_effects
Definition: effects.h:210
struct _newgen_struct_descriptor_ * descriptor
Definition: effects.h:114
struct _newgen_struct_entity_effects_ * entity_effects
Definition: effects.h:146
#define loop
Definition: gfc2pips.h:54
struct _newgen_struct_range_ * range
Definition: message.h:21
int bool
we cannot use an enum or stdbool because we need to be compatible with newgen, thus boolean need to h...
Definition: newgen_types.h:78
struct cons * list
Definition: newgen_types.h:106
void(* void_function)()
descriptor(* descriptor_function)()
bool(* bool_function)()
list(* list_function)()
statement_effects(* statement_effects_function)()
#define UNDEF
struct _newgen_struct_transformer_ * transformer
Definition: ri.h:431
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
struct _newgen_struct_text_ * text
Definition: text.h:23
A gen_chunk is used to store every object.
Definition: genC.h:58
#define exp
Avoid some warnings from "gcc -Wshadow".
Definition: vasnprintf.c:207
struct Svecteur * Pvecteur