PIPS
references.c
Go to the documentation of this file.
1 /*
2 
3  $Id: references.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 /*
28  * Function of manipulation of reference lists
29  *
30  * Corinne Ancourt
31  */
32 #include <stdio.h>
33 #include <string.h>
34 #include <stdlib.h>
35 
36 #include "linear.h"
37 
38 #include "genC.h"
39 #include "ri.h"
40 #include "effects.h"
41 #include "misc.h"
42 #include "ri-util.h"
43 #include "effects-util.h"
44 #include "constants.h"
45 #include "ri.h"
46 #include "effects.h"
47 
48 #include "dg.h"
51 #include "graph.h"
52 
53 #include "matrice.h"
54 #include "tiling.h"
55 #include "database.h"
56 #include "text.h"
57 #include "text-util.h"
58 #include "resources.h"
59 
60 #include "wp65.h"
61 
63 {
64  pips_assert("true", lt==lt && r==r);
65  return (false);
66 }
67 
69 {
70  list lt;
71 
72  lt = (list) GET_STATEMENT_MAPPING(m,st);
73  if (lt != (list) HASH_UNDEFINED_VALUE) {
74  if (!ref_in_list_p(lt,r)) {
75  lt = gen_nconc(lt, CONS(REFERENCE,r, NIL));
76  ifdebug(9)
77  (void) fprintf(stderr,
78  "ajout de la ref: %s au statement %"PRIdPTR"\n",
80  statement_number(st));
81  }
82  }
83  else {
84  lt= CONS(REFERENCE,r, NIL);
85  ifdebug(9)
86  (void) fprintf (stderr,
87  "ajout de la ref: %s au statement %"PRIdPTR"\n",
89  statement_number(st));
90  }
91  SET_STATEMENT_MAPPING(m,st,lt);
92 }
93 
94 /* This function gives the list of operands belonging to Expression e
95 */
97 expression e;
98 list lr;
99 {
100  syntax s = expression_syntax(e);
101  switch(syntax_tag(s)) {
102  case is_syntax_reference:
103  lr = gen_nconc(lr, CONS(REFERENCE, syntax_reference(s), NIL));
104  break;
105  case is_syntax_range:
109  lr);
110  break;
111  case is_syntax_call:
112  MAPL(ce, {
113  expression e = EXPRESSION(CAR(ce));
114  lr = expression_to_operand_list(e, lr);
115  },
117  break;
118  default:
119  (void) fprintf(stderr,
120  "expression_to_operand_list - unexpected syntax\n");
121  }
122 
123  return lr;
124 }
125 
126 /* This function tests whether at least one array indice of
127  * Reference r belongs to List lwr or not
128  */
129 
131 {
132  list lref2;
133  bool result = false;
134  for (lref2 = lwr;
135  lref2 != NULL && !result;
136  result = result || reference_equal_p(r,REFERENCE(CAR(lref2))),
137  lref2 = CDR(lref2)) ;
138  return(result);
139 }
141 {
142 
143  list lr = NIL;
144  bool result = false;
145  list lref1;
146  MAPL(ce,{ expression e = EXPRESSION(CAR(ce));
147  lr = expression_to_reference_list(e, lr);
148  },
149  reference_indices(r));
150  for (lref1 = lr;
151  lref1 != NIL && !result;
152  result = result || reference_in_list_p(REFERENCE(CAR(lref1)),
153  lwr),
154  lref1 = CDR(lref1));
155 
156  return result;
157 }
158 
159 /* This function add Reference r to List l, if r doesn't belong to l
160 */
162 {
163  list lref1 =*l ;
164  if (*l != NIL) {
165  for(; lref1!= NIL && !(reference_equal_p(REFERENCE(CAR(lref1)),r)) ;
166  lref1 = CDR(lref1));
167  if (lref1 == NIL)
168  *l= gen_nconc(*l, CONS(REFERENCE,r,NIL));
169  }
170  else *l = CONS(REFERENCE,r,NIL);
171 }
172 
173 /* This function adds all the references of l2 to l1 if they don't appear in l1
174 */
176 {
177  list lref2 =*l2 ;
178  for(; lref2!= NIL;
179  reference_list_update(l1, REFERENCE(CAR(lref2))),
180  lref2 = CDR(lref2));
181 }
182 
183 
184 /* This function prints the references belonging to l
185 */
187 {
188  list lref;
189  for (lref = l;
190  lref != NIL;
191  (void) fprintf(stderr,
192  "%s,",
194  lref = CDR(lref));
195  (void) fprintf(stderr,"\n");
196 }
197 
198 
200 {
202  && r!=NULL && reference_variable(r)!=NULL
203  && reference_indices(r) == NIL);
204 }
205 /* This function adds the reference r to List l, if the reference_variable(r)
206  * doesn't belong to l
207 */
209 {
210  list lvar1 =*l ;
211  if (*l != NIL) {
212  for(;
213  lvar1!= NIL
216  lvar1 = CDR(lvar1));
217  if (lvar1 == NIL)
218  *l= gen_nconc(*l, CONS(REFERENCE,r,NIL));
219  }
220  else *l = CONS(REFERENCE,r,NIL);
221 }
222 
223 /* This function adds all the references of l2 to l1 if they don't appear in l1
224 */
226 {
227  list lvar2 =*l2 ;
228  for(; lvar2!= NIL;
229  variable_list_update(l1,REFERENCE(CAR(lvar2))),
230  lvar2 = CDR(lvar2));
231 }
232 
233 
234 
235 
236 void concat_data_list(list * l,list * lr, statement st,statement_mapping map, bool perfect_nested_loop)
237 {
238  instruction inst;
239  list lt = (list) GET_STATEMENT_MAPPING(map,st);
240 
241  if (lt != (list) HASH_UNDEFINED_VALUE) {
242  variable_list_add(l, &lt);
243  reference_list_add(lr,&lt);
244  }
245  inst = statement_instruction(st);
246  switch(instruction_tag(inst)) {
247  case is_instruction_block:{
248  cons * b;
249  b = instruction_block(inst);
250  if (list_of_calls_p(b))
251  concat_data_list(l,lr,STATEMENT(CAR(b)),map,perfect_nested_loop);
252  else
253  MAPL(st, {
254  concat_data_list(l,lr,STATEMENT(CAR(st)), map,
255  perfect_nested_loop);
256  } , b);
257  break;
258  }
259 
260  case is_instruction_loop: {
262  perfect_nested_loop);
263  break;}
264  default: return;
265  }
266 }
267 
268 
#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
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
#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
bool list_of_calls_p(list lsb)
instruction_to_wp65_code.c
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define GET_STATEMENT_MAPPING(map, stat)
Definition: newgen-local.h:49
#define SET_STATEMENT_MAPPING(map, stat, val)
Definition: newgen-local.h:47
#define assert(ex)
Definition: newgen_assert.h:41
#define HASH_UNDEFINED_VALUE
value returned by hash_get() when the key is not found; could also be called HASH_KEY_NOT_FOUND,...
Definition: newgen_hash.h:56
struct cons * list
Definition: newgen_types.h:106
list expression_to_operand_list(expression e, list lr)
This function gives the list of operands belonging to Expression e.
Definition: references.c:96
void concat_data_list(list *l, list *lr, statement st, statement_mapping map, bool perfect_nested_loop)
Definition: references.c:236
void reference_list_print(list l)
This function prints the references belonging to l.
Definition: references.c:186
void reference_list_add(list *l1, list *l2)
This function adds all the references of l2 to l1 if they don't appear in l1.
Definition: references.c:175
dg_vertex_label vertex_label
Definition: references.c:50
void reference_list_update(list *l, reference r)
This function add Reference r to List l, if r doesn't belong to l.
Definition: references.c:161
bool array_indice_in_list_p(reference r, list lwr)
Definition: references.c:140
bool reference_in_list_p(reference r, list lwr)
This function tests whether at least one array indice of Reference r belongs to List lwr or not.
Definition: references.c:130
dg_arc_label arc_label
Function of manipulation of reference lists.
Definition: references.c:49
void reference_scalar_defined_p(reference r)
Definition: references.c:199
void variable_list_add(list *l1, list *l2)
This function adds all the references of l2 to l1 if they don't appear in l1.
Definition: references.c:225
void update_map(statement_mapping m, statement st, reference r)
Definition: references.c:68
bool ref_in_list_p(list lt, reference r)
references.c
Definition: references.c:62
void variable_list_update(list *l, reference r)
This function adds the reference r to List l, if the reference_variable(r) doesn't belong to l.
Definition: references.c:208
#define is_instruction_block
soft block->sequence transition
#define instruction_block(i)
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
bool reference_equal_p(reference r1, reference r2)
Definition: expression.c:1500
list expression_to_reference_list(expression e, list lr)
conversion of an expression into a list of references; references are appended to list lr as they are...
Definition: expression.c:1263
#define loop_body(x)
Definition: ri.h:1644
#define REFERENCE(x)
REFERENCE.
Definition: ri.h:2296
#define syntax_reference(x)
Definition: ri.h:2730
#define syntax_tag(x)
Definition: ri.h:2727
#define reference_variable(x)
Definition: ri.h:2326
#define range_upper(x)
Definition: ri.h:2290
#define reference_undefined_p(x)
Definition: ri.h:2303
#define instruction_loop(x)
Definition: ri.h:1520
#define syntax_range(x)
Definition: ri.h:2733
@ is_syntax_range
Definition: ri.h:2692
@ is_syntax_call
Definition: ri.h:2693
@ is_syntax_reference
Definition: ri.h:2691
#define range_increment(x)
Definition: ri.h:2292
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
@ is_instruction_loop
Definition: ri.h:1471
#define instruction_tag(x)
Definition: ri.h:1511
#define reference_indices(x)
Definition: ri.h:2328
#define syntax_call(x)
Definition: ri.h:2736
#define range_lower(x)
Definition: ri.h:2288
#define statement_instruction(x)
Definition: ri.h:2458
#define call_arguments(x)
Definition: ri.h:711
#define statement_number(x)
Definition: ri.h:2452
#define expression_syntax(x)
Definition: ri.h:1247
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
#define ifdebug(n)
Definition: sg.c:47
The structure used to build lists in NewGen.
Definition: newgen_list.h:41