PIPS
host_node_entities.c
Go to the documentation of this file.
1 /*
2 
3  $Id: host_node_entities.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 /* HPFC module by Fabien COELHO
28  */
29 
30 #include "defines-local.h"
31 
32 #include "effects-generic.h"
33 #include "effects-simple.h"
34 #include "effects-convex.h"
35 
36 /* HOST AND NODE ENTITIES MANAGEMENT
37  */
42 
43 void
45 {
46  fprintf(stderr, "variable %s:\n\tnh=%s\n\toh=%s\n\tnn=%s\n\ton=%s\n",
47  entity_name(e),
48  bound_new_host_p(e)? entity_name(load_new_host(e)): "<undef>",
49  bound_old_host_p(e)? entity_name(load_old_host(e)): "<undef>",
50  bound_new_node_p(e)? entity_name(load_new_node(e)): "<undef>",
51  bound_old_node_p(e)? entity_name(load_old_node(e)): "<undef>");
52 }
53 
54 void
56 {
57  pips_assert("defined", !entity_undefined_p(new)&&!entity_undefined_p(old));
58 
59  store_or_update_new_node(old, new);
60  store_or_update_old_node(new, old);
61 }
62 
63 void
65 {
66  pips_assert("defined", !entity_undefined_p(new)&&!entity_undefined_p(old));
67 
68  store_or_update_new_host(old, new);
69  store_or_update_old_host(new, old);
70 }
71 
72 void
74  entity neh /* host version */,
75  entity nen /* node version */,
76  entity old /* initial entity */)
77 {
78  store_new_host_variable(neh, old);
79  store_new_host_variable(neh, nen);
80  store_new_node_variable(nen, old);
81  store_new_node_variable(nen, neh);
82 }
83 
84 
86 {
87  init_new_host();
88  init_old_host();
89  init_new_node();
90  init_old_node();
91 }
92 
94 {
96  get_new_node(),
97  get_old_host(),
98  get_old_node(),
100 }
101 
103 {
108 }
109 
111 {
112  reset_new_host();
113  reset_old_host();
114  reset_new_node();
115  reset_old_node();
116 }
117 
119 {
120  close_new_host();
121  close_old_host();
122  close_new_node();
123  close_old_node();
124 }
125 
127 entity module;
128 {
129  if (module==node_module) return(NODE_NAME);
130  if (module==host_module) return(HOST_NAME);
131  /* else
132  */
133  pips_internal_error("unexpected module");
134  return string_undefined; /* to avoid a gcc warning */
135 }
136 
137 
138 /****************************************************************** UPDATES */
139 
140 static bool (*bound_p)(entity) = (bool(*)(entity)) gen_false;
142 
144  entity *pe)
145 {
146  if (bound_p(*pe))
147  {
148  entity n = load(*pe);
149  pips_debug(10, "%s -> %s\n", entity_name(*pe), entity_name(n));
150  *pe = n;
151  }
152 }
153 
154 /* shift the references to the right variable, in the module
155  */
157 {
159 }
160 
161 /* shift the calls to the right variable, in the module
162  */
164 {
166 }
167 
169 {
170  MAPL(ce,
171  update_for_module_rewrite((entity*) &(CAR(ce).p)),
172  code_declarations(c));
173 }
174 
176 {
178 }
179 
181  void * obj, /* loosely typed, indeed */
182  entity module)
183 {
184  bool (*saved_bound)(entity);
185  entity (*saved_load)(entity);
186 
187  pips_debug(8, "updating (%s) %p\n", gen_domain_name(gen_type(obj)), obj);
188 
189  saved_bound = bound_p, saved_load = load; /* push the current functions */
190 
191  if (module==host_module)
192  {
193  pips_debug(8, "for host\n");
196  }
197  else
198  {
199  pips_debug(8, "for node\n");
202  }
203 
205  (obj,
210  NULL);
211 
212  bound_p = saved_bound, load = saved_load; /* pop the initial functions */
213 }
214 
216 {
218 }
219 
220 /* this function creates a new expression using the mapping of
221  * old to new variables map.
222  * some of the structures generated may be shared...
223  */
224 
226 entity module;
227 expression ex;
228 {
229  expression new = copy_expression(ex);
231  return(new);
232 }
233 
234 /* used for compiling calls.
235  */
236 list
238  entity module,
239  list /* of expression */ l)
240 {
241  list new = NIL;
242 
243  MAP(EXPRESSION, e,
244  {
246  new = CONS(EXPRESSION, copy_expression(e), new);
247  },
248  l);
249 
250  new = gen_nreverse(new);
252  return new;
253 }
254 
255 list
256 lUpdateExpr(entity module, list /* of anything */ l)
257 {
258  list new = gen_full_copy_list(l);
260  return new;
261 }
262 
264 entity module;
265 list le;
266 {
267  list result, last;
268 
269  if (ENDP(le)) return(NIL);
270 
271  for (result = CONS(ENTITY,
273  NIL),
274  last = result, le = CDR(le);
275  !ENDP(le);
276  le = CDR(le), last = CDR(last))
278  NIL);
279 
280  return(result);
281 }
282 
284  entity module,
285  entity e)
286 {
287  if (module==host_module)
288  {
289  if (bound_new_host_p(e))
290  return load_new_host(e);
291  }
292  else
293  {
294  if (bound_new_node_p(e))
295  return load_new_node(e);
296  }
297 
298  pips_internal_error("unexpected entity %s", entity_name(e));
299 
300  return entity_undefined;
301 }
302 
304  entity module,
305  statement stat)
306 {
307  statement new_stat = copy_statement(stat);
308  update_object_for_module(new_stat, module);
309  return(new_stat);
310 }
311 
312 /* That is all
313  */
entity_status make_entity_status(entitymap a1, entitymap a2, entitymap a3, entitymap a4, entity_int a5)
Definition: hpf_private.c:406
expression copy_expression(expression p)
EXPRESSION.
Definition: ri.c:850
statement copy_statement(statement p)
STATEMENT.
Definition: ri.c:2186
struct _newgen_struct_entity_ * entity
Definition: abc_private.h:14
static reference ref
Current stmt (an integer)
Definition: adg_read_paf.c:163
entity host_module
HPFC - Fabien Coelho, May 1993 and later...
Definition: compiler.c:47
entity node_module
Definition: compiler.c:47
#define CHUNK(x)
Definition: genC.h:90
string gen_domain_name(int t)
GEN_DOMAIN_NAME returns the domain name, and may be used for debug purposes.
Definition: genClib.c:97
int gen_type(gen_chunk *obj)
GEN_TYPE returns the domain number for the object in argument.
Definition: genClib.c:82
void gen_multi_recurse(void *o,...)
Multi recursion visitor function.
Definition: genClib.c:3428
bool gen_false(__attribute__((unused)) gen_chunk *unused)
Return false and ignore the argument.
Definition: genClib.c:2796
bool gen_true(__attribute__((unused)) gen_chunk *unused)
Return true and ignore the argument.
Definition: genClib.c:2780
void * gen_identity(const void *x)
Just return the argument.
Definition: genClib.c:2807
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
#define MAPL(_map_list_cp, _code, _l)
Apply some code on the addresses of all the elements of a list.
Definition: newgen_list.h:203
#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
list gen_full_copy_list(list l)
Copy a list structure with element copy.
Definition: list.c:535
void debug_host_node_variables(entity e)
HPFC module by Fabien COELHO.
static entity(* load)(entity)
void store_new_node_variable(entity new, entity old)
static void update_for_module_rewrite(entity *pe)
static bool(* bound_p)(entity)
void update_object_for_module(void *obj, entity module)
list lNewVariableForModule(entity module, list le)
static void update_call_for_module_rewrite(call c)
shift the calls to the right variable, in the module
entity_status get_entity_status()
static void update_loop_for_module_rewrite(loop l)
entity NewVariableForModule(entity module, entity e)
static void update_code_for_module_rewrite(code c)
string hpfc_module_suffix(entity module)
void store_new_host_node_variable(entity neh, entity nen, entity old)
list lUpdateExpr(entity module, list l)
void store_new_host_variable(entity new, entity old)
list lUpdateExpr_but_distributed(entity module, list l)
used for compiling calls.
void set_entity_status(entity_status s)
static void update_reference_for_module_rewrite(reference ref)
shift the references to the right variable, in the module
void update_list_for_module(list l, entity module)
expression UpdateExpressionForModule(entity module, expression ex)
this function creates a new expression using the mapping of old to new variables map.
void close_entity_status()
void init_entity_status()
statement UpdateStatementForModule(entity module, statement stat)
void reset_entity_status()
#define entity_status_new_node(x)
Definition: hpf_private.h:535
#define entity_status_old_node(x)
Definition: hpf_private.h:539
#define entity_status_new_host(x)
Definition: hpf_private.h:533
#define entity_status_old_host(x)
Definition: hpf_private.h:537
#define NODE_NAME
#define HOST_NAME
Constants.
void set_old_host(entitymap)
bool bound_old_node_p(entity)
entity load_old_node(entity)
void init_old_node(void)
bool bound_new_host_p(entity)
void store_or_update_new_node(entity, entity)
entity load_new_node(entity)
void close_new_node(void)
void init_new_host(void)
void close_old_node(void)
void set_new_node(entitymap)
void init_old_host(void)
void store_or_update_new_host(entity, entity)
void store_or_update_old_host(entity, entity)
void set_new_host(entitymap)
entitymap get_old_node(void)
void reset_new_node(void)
entitymap get_old_host(void)
void close_new_host(void)
void close_old_host(void)
entitymap get_new_host(void)
entitymap get_new_node(void)
void set_old_node(entitymap)
bool bound_new_node_p(entity)
void store_or_update_old_node(entity, entity)
void reset_old_node(void)
void reset_old_host(void)
bool bound_old_host_p(entity)
void init_new_node(void)
void reset_new_host(void)
entity load_new_host(entity)
entity load_old_host(entity)
bool array_distributed_p(entity)
#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_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define pips_internal_error
Definition: misc-local.h:149
#define GENERIC_GLOBAL_FUNCTION(name, type)
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
#define string_undefined
Definition: newgen_types.h:40
static char * module
Definition: pips.c:74
entity expression_to_entity(expression e)
just returns the entity of an expression, or entity_undefined
Definition: expression.c:3140
#define call_function(x)
Definition: ri.h:709
#define reference_variable(x)
Definition: ri.h:2326
#define loop_domain
newgen_language_domain_defined
Definition: ri.h:218
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define code_declarations(x)
Definition: ri.h:784
#define call_domain
newgen_callees_domain_defined
Definition: ri.h:58
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define entity_undefined_p(x)
Definition: ri.h:2762
#define reference_domain
newgen_range_domain_defined
Definition: ri.h:338
#define entity_undefined
Definition: ri.h:2761
#define entity_name(x)
Definition: ri.h:2790
#define entity_int_undefined
Definition: ri.h:1043
#define code_domain
newgen_cast_domain_defined
Definition: ri.h:74
#define loop_index(x)
Definition: ri.h:1640
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
The structure used to build lists in NewGen.
Definition: newgen_list.h:41