PIPS
references.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "linear.h"
#include "genC.h"
#include "ri.h"
#include "effects.h"
#include "misc.h"
#include "ri-util.h"
#include "effects-util.h"
#include "constants.h"
#include "dg.h"
#include "graph.h"
#include "matrice.h"
#include "tiling.h"
#include "database.h"
#include "text.h"
#include "text-util.h"
#include "resources.h"
#include "wp65.h"
+ Include dependency graph for references.c:

Go to the source code of this file.

Typedefs

typedef dg_arc_label arc_label
 Function of manipulation of reference lists. More...
 
typedef dg_vertex_label vertex_label
 

Functions

bool ref_in_list_p (list lt, reference r)
 references.c More...
 
void update_map (statement_mapping m, statement st, reference r)
 
list expression_to_operand_list (expression e, list lr)
 This function gives the list of operands belonging to Expression e. More...
 
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. More...
 
bool array_indice_in_list_p (reference r, list lwr)
 
void reference_list_update (list *l, reference r)
 This function add Reference r to List l, if r doesn't belong to l. More...
 
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. More...
 
void reference_list_print (list l)
 This function prints the references belonging to l. More...
 
void reference_scalar_defined_p (reference r)
 
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. More...
 
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. More...
 
void concat_data_list (list *l, list *lr, statement st, statement_mapping map, bool perfect_nested_loop)
 

Typedef Documentation

◆ arc_label

Function of manipulation of reference lists.

Corinne Ancourt

Definition at line 49 of file references.c.

◆ vertex_label

Definition at line 50 of file references.c.

Function Documentation

◆ array_indice_in_list_p()

bool array_indice_in_list_p ( reference  r,
list  lwr 
)
Parameters
lwrwr

Definition at line 140 of file references.c.

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 }
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#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 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
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 REFERENCE(x)
REFERENCE.
Definition: ri.h:2296
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define reference_indices(x)
Definition: ri.h:2328
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References CAR, CDR, EXPRESSION, expression_to_reference_list(), MAPL, NIL, REFERENCE, reference_in_list_p(), and reference_indices.

Referenced by call_instruction_to_communications().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ concat_data_list()

void concat_data_list ( list l,
list lr,
statement  st,
statement_mapping  map,
bool  perfect_nested_loop 
)
Parameters
lrr
stt
mapap
perfect_nested_looperfect_nested_loop

Definition at line 236 of file references.c.

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 }
bool list_of_calls_p(list lsb)
instruction_to_wp65_code.c
#define GET_STATEMENT_MAPPING(map, stat)
Definition: newgen-local.h:49
#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
void concat_data_list(list *l, list *lr, statement st, statement_mapping map, bool perfect_nested_loop)
Definition: references.c:236
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
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
#define is_instruction_block
soft block->sequence transition
#define instruction_block(i)
#define loop_body(x)
Definition: ri.h:1644
#define instruction_loop(x)
Definition: ri.h:1520
@ is_instruction_loop
Definition: ri.h:1471
#define instruction_tag(x)
Definition: ri.h:1511
#define statement_instruction(x)
Definition: ri.h:2458
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413

References CAR, GET_STATEMENT_MAPPING, HASH_UNDEFINED_VALUE, instruction_block, instruction_loop, instruction_tag, is_instruction_block, is_instruction_loop, list_of_calls_p(), loop_body, MAPL, reference_list_add(), STATEMENT, statement_instruction, and variable_list_add().

Referenced by loop_nest_movement_generation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expression_to_operand_list()

list expression_to_operand_list ( expression  e,
list  lr 
)

This function gives the list of operands belonging to Expression e.

Parameters
lrr

Definition at line 96 of file references.c.

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 }
#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
list expression_to_operand_list(expression e, list lr)
This function gives the list of operands belonging to Expression e.
Definition: references.c:96
#define syntax_reference(x)
Definition: ri.h:2730
#define syntax_tag(x)
Definition: ri.h:2727
#define range_upper(x)
Definition: ri.h:2290
#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 syntax_call(x)
Definition: ri.h:2736
#define range_lower(x)
Definition: ri.h:2288
#define call_arguments(x)
Definition: ri.h:711
#define expression_syntax(x)
Definition: ri.h:1247
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...

References call_arguments, CAR, CONS, EXPRESSION, expression_syntax, fprintf(), gen_nconc(), is_syntax_call, is_syntax_range, is_syntax_reference, MAPL, NIL, range_increment, range_lower, range_upper, REFERENCE, syntax_call, syntax_range, syntax_reference, and syntax_tag.

Referenced by call_instruction_to_communications().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ref_in_list_p()

bool ref_in_list_p ( list  lt,
reference  r 
)

references.c

Parameters
ltt

Definition at line 62 of file references.c.

63 {
64  pips_assert("true", lt==lt && r==r);
65  return (false);
66 }
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172

References pips_assert.

Referenced by update_map().

+ Here is the caller graph for this function:

◆ reference_in_list_p()

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.

Parameters
lwrwr

Definition at line 130 of file references.c.

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 }
bool reference_equal_p(reference r1, reference r2)
Definition: expression.c:1500

References CAR, CDR, REFERENCE, and reference_equal_p().

Referenced by array_indice_in_list_p(), call_instruction_to_communications(), and make_all_movement_blocks().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reference_list_add()

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.

Parameters
l11
l22

Definition at line 175 of file references.c.

176 {
177  list lref2 =*l2 ;
178  for(; lref2!= NIL;
179  reference_list_update(l1, REFERENCE(CAR(lref2))),
180  lref2 = CDR(lref2));
181 }
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

References CAR, CDR, NIL, REFERENCE, and reference_list_update().

Referenced by concat_data_list(), loop_instruction_to_communications(), and statement_to_communications().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reference_list_print()

void reference_list_print ( list  l)

This function prints the references belonging to l.

Definition at line 186 of file references.c.

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 }
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
#define reference_variable(x)
Definition: ri.h:2326

References CAR, CDR, entity_local_name(), fprintf(), NIL, REFERENCE, and reference_variable.

Referenced by call_instruction_to_communications(), call_to_wp65_code(), insert_array_scalar_access_movement(), and loop_nest_to_wp65_code().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reference_list_update()

void reference_list_update ( list l,
reference  r 
)

This function add Reference r to List l, if r doesn't belong to l.

Definition at line 161 of file references.c.

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 }

References CAR, CDR, CONS, gen_nconc(), NIL, REFERENCE, and reference_equal_p().

Referenced by call_instruction_to_communications(), loop_instruction_to_communications(), and reference_list_add().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reference_scalar_defined_p()

void reference_scalar_defined_p ( reference  r)

Definition at line 199 of file references.c.

200 {
202  && r!=NULL && reference_variable(r)!=NULL
203  && reference_indices(r) == NIL);
204 }
#define assert(ex)
Definition: newgen_assert.h:41
#define reference_undefined_p(x)
Definition: ri.h:2303

References assert, NIL, reference_indices, reference_undefined_p, and reference_variable.

Referenced by loop_nest_to_wp65_code().

+ Here is the caller graph for this function:

◆ update_map()

void update_map ( statement_mapping  m,
statement  st,
reference  r 
)
Parameters
stt

Definition at line 68 of file references.c.

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 }
#define SET_STATEMENT_MAPPING(map, stat, val)
Definition: newgen-local.h:47
bool ref_in_list_p(list lt, reference r)
references.c
Definition: references.c:62
#define statement_number(x)
Definition: ri.h:2452
#define ifdebug(n)
Definition: sg.c:47

References CONS, entity_local_name(), fprintf(), gen_nconc(), GET_STATEMENT_MAPPING, HASH_UNDEFINED_VALUE, ifdebug, NIL, ref_in_list_p(), REFERENCE, reference_variable, SET_STATEMENT_MAPPING, and statement_number.

Referenced by call_instruction_to_communications().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ variable_list_add()

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.

Parameters
l11
l22

Definition at line 225 of file references.c.

226 {
227  list lvar2 =*l2 ;
228  for(; lvar2!= NIL;
229  variable_list_update(l1,REFERENCE(CAR(lvar2))),
230  lvar2 = CDR(lvar2));
231 }
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

References CAR, CDR, NIL, REFERENCE, and variable_list_update().

Referenced by concat_data_list().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ variable_list_update()

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 at line 208 of file references.c.

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 }

References CAR, CDR, CONS, entity_local_name(), gen_nconc(), NIL, REFERENCE, and reference_variable.

Referenced by variable_list_add().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: