PIPS
compiler-util.c File Reference
#include "defines-local.h"
+ Include dependency graph for compiler-util.c:

Go to the source code of this file.

Macros

#define call_assign_p(c)    (strcmp(entity_local_name(call_function(c)), ASSIGN_OPERATOR_NAME)==0)
 

Functions

void update_control_lists (control c, control_mapping map)
 Compiler Utilities. More...
 
list updated_control_list (list lc, control_mapping map)
 
static bool FindRefToDistArrayInStatement_call_filter (call c)
 
static bool FindRefToDistArrayInStatement_expression_filter (expression e)
 
void FindRefToDistArrayInStatement (statement obj, list *lwp, list *lrp)
 
list lIndicesOfRef (list lsyn)
 computes the list of indices of the list of ref that are variables... More...
 
list IndicesOfRef (syntax syn)
 
list AddOnceToIndicesList (list l, list lsyn)
 
bool is_in_syntax_list (entity e, list l)
 
static void FindDefinitionsOf_rewrite (statement s)
 
list FindDefinitionsOf (statement stat, list lsyn)
 
bool atomic_accesses_only_p (_UNUSED_ statement stat)
 atomic_accesses_only_p More...
 
bool indirections_inside_statement_p (_UNUSED_ statement stat)
 indirections_inside_statement_p More...
 
static bool loop_filter (loop l)
 
static void sequence_rewrite (sequence s)
 
static void loop_rewrite (loop l)
 
statement parallel_loop_nest_to_body (statement loop_nest, list *pblocks, list *ploops)
 
static void set_current_loops_rewrite (loop l)
 
void set_current_loops (statement obj)
 
void reset_current_loops ()
 
bool entity_loop_index_p (entity e)
 
range loop_index_to_range (entity index)
 

Variables

static list found_written = NIL
 FindRefToDistArrayInStatement. More...
 
static list found_read = NIL
 
static list syntax_list =NIL
 ??? False! The definition looked for must be an assignment call... More...
 
static list found_definitions =NIL
 
static list loops
 
static list blocks
 lisp of loops More...
 
static int n_loops
 list of lists, may be NIL if none More...
 
static int n_levels
 
static statement inner_body
 
static list current_loop_list =NIL
 management of a list of current loops. More...
 

Macro Definition Documentation

◆ call_assign_p

#define call_assign_p (   c)     (strcmp(entity_local_name(call_function(c)), ASSIGN_OPERATOR_NAME)==0)

Definition at line 87 of file compiler-util.c.

Function Documentation

◆ AddOnceToIndicesList()

list AddOnceToIndicesList ( list  l,
list  lsyn 
)
Parameters
lsynsyn

Definition at line 188 of file compiler-util.c.

190 {
191  MAP(SYNTAX, s,
193  lsyn = CONS(SYNTAX, s, lsyn),
194  l);
195 
196  gen_free_list(l);
197  return(lsyn);
198 }
bool is_in_syntax_list(entity e, list l)
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#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
#define syntax_reference(x)
Definition: ri.h:2730
#define reference_variable(x)
Definition: ri.h:2326
#define SYNTAX(x)
SYNTAX.
Definition: ri.h:2670

References CONS, gen_free_list(), is_in_syntax_list(), MAP, reference_variable, SYNTAX, and syntax_reference.

Referenced by hpf_compile_parallel_body(), and lIndicesOfRef().

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

◆ atomic_accesses_only_p()

bool atomic_accesses_only_p ( _UNUSED_ statement  stat)

atomic_accesses_only_p

checks that only atomic accesses to distributed variables are made inside a parallel loop nest, for every iterations.

??? partially implemented, and the conclusions may be false...

Definition at line 268 of file compiler-util.c.

269 {
270  ifdebug(1)
271  hpfc_warning("not implemented, returning TRUE\n");
272  return true;
273 }
#define hpfc_warning
WARNING.
#define true
Definition: newgen_types.h:81
return(s1)
#define ifdebug(n)
Definition: sg.c:47

References hpfc_warning, and ifdebug.

Referenced by hpf_compile_loop().

+ Here is the caller graph for this function:

◆ entity_loop_index_p()

bool entity_loop_index_p ( entity  e)

Definition at line 383 of file compiler-util.c.

385 {
386  MAP(LOOP, l, if (e == loop_index(l)) return true, current_loop_list);
387  return false;
388 }
static list current_loop_list
management of a list of current loops.
#define LOOP(x)
LOOP.
Definition: ri.h:1606
#define loop_index(x)
Definition: ri.h:1640

References current_loop_list, LOOP, loop_index, and MAP.

Referenced by affine_expression_of_loop_index_p(), shift_expression_of_loop_index_p(), and simple_indices_p().

+ Here is the caller graph for this function:

◆ FindDefinitionsOf()

list FindDefinitionsOf ( statement  stat,
list  lsyn 
)
Parameters
stattat
lsynsyn

Definition at line 239 of file compiler-util.c.

242 {
243  list result = NIL;
244 
245  pips_assert("empty lists", ENDP(syntax_list) && ENDP(found_definitions));
246 
247  syntax_list = lsyn;
248 
249  gen_recurse(stat,
251  gen_true,
253 
254  result = found_definitions,
255  syntax_list = NIL,
257 
258  return(result);
259 }
static list syntax_list
??? False! The definition looked for must be an assignment call...
static list found_definitions
static void FindDefinitionsOf_rewrite(statement s)
#define gen_recurse(start, domain_number, flt, rwt)
Definition: genC.h:283
bool gen_true(__attribute__((unused)) gen_chunk *unused)
Return true and ignore the argument.
Definition: genClib.c:2780
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define statement_domain
newgen_sizeofexpression_domain_defined
Definition: ri.h:362
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References ENDP, FindDefinitionsOf_rewrite(), found_definitions, gen_recurse, gen_true(), NIL, pips_assert, statement_domain, and syntax_list.

Referenced by hpf_compile_parallel_body().

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

◆ FindDefinitionsOf_rewrite()

static void FindDefinitionsOf_rewrite ( statement  s)
static

??? False! nothing is checked about the statement movement...

Definition at line 218 of file compiler-util.c.

220 {
222 
223  /* ??? False! nothing is checked about the statement movement...
224  */
225  if (instruction_assign_p(i))
230  syntax_list))
231  {
236  }
237 }
statement instruction_to_statement(instruction)
Build a statement from a give instruction.
Definition: statement.c:597
instruction make_continue_instruction()
Creates a CONTINUE instruction, that is the FORTRAN nop, the ";" in C or the "pass" in Python for exa...
Definition: instruction.c:79
bool instruction_assign_p(instruction i)
Test if an instruction is an assignment.
Definition: instruction.c:164
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
reference expression_reference(expression e)
Short cut, meaningful only if expression_reference_p(e) holds.
Definition: expression.c:1832
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define statement_instruction(x)
Definition: ri.h:2458
#define instruction_call(x)
Definition: ri.h:1529
#define call_arguments(x)
Definition: ri.h:711
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413

References call_arguments, CAR, CONS, EXPRESSION, expression_reference(), found_definitions, instruction_assign_p(), instruction_call, instruction_to_statement(), is_in_syntax_list(), make_continue_instruction(), reference_variable, STATEMENT, statement_instruction, and syntax_list.

Referenced by FindDefinitionsOf().

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

◆ FindRefToDistArrayInStatement()

void FindRefToDistArrayInStatement ( statement  obj,
list lwp,
list lrp 
)
Parameters
objbj
lwpwp
lrprp

Definition at line 121 of file compiler-util.c.

124 {
125  list
126  saved_r = found_read,
127  saved_w = found_written;
128 
130 
131  gen_multi_recurse(obj,
132  call_domain,
134  gen_null,
137  gen_null,
138  NULL);
139 
140  *lwp = found_written, *lrp = found_read,
141  found_read = saved_r, found_written = saved_w;
142 }
static bool FindRefToDistArrayInStatement_call_filter(call c)
Definition: compiler-util.c:90
static list found_written
FindRefToDistArrayInStatement.
Definition: compiler-util.c:84
static bool FindRefToDistArrayInStatement_expression_filter(expression e)
static list found_read
Definition: compiler-util.c:85
void gen_multi_recurse(void *o,...)
Multi recursion visitor function.
Definition: genClib.c:3428
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
Definition: genClib.c:2752
#define expression_domain
newgen_execution_domain_defined
Definition: ri.h:154
#define call_domain
newgen_callees_domain_defined
Definition: ri.h:58

References call_domain, expression_domain, FindRefToDistArrayInStatement_call_filter(), FindRefToDistArrayInStatement_expression_filter(), found_read, found_written, gen_multi_recurse(), gen_null(), and NIL.

Referenced by hpf_compile_parallel_body(), hpf_compile_parallel_loop(), and Overlap_Analysis().

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

◆ FindRefToDistArrayInStatement_call_filter()

static bool FindRefToDistArrayInStatement_call_filter ( call  c)
static

else ASSIGN case

Definition at line 90 of file compiler-util.c.

92 {
93  list l;
94  syntax s;
95 
96  if (!call_assign_p(c)) return(true);
97 
98  /* else ASSIGN case
99  */
100 
101  l = call_arguments(c);
103 
106 
107  found_read =
109  found_read);
110 
111  return(false);
112 }
#define call_assign_p(c)
Definition: compiler-util.c:87
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
list FindRefToDistArray(void *obj)
Definition: hpfc-util.c:282
bool array_distributed_p(entity)
#define expression_syntax(x)
Definition: ri.h:1247

References array_distributed_p(), call_arguments, call_assign_p, CAR, CDR, CONS, EXPRESSION, expression_syntax, FindRefToDistArray(), found_read, found_written, gen_nconc(), reference_variable, SYNTAX, and syntax_reference.

Referenced by FindRefToDistArrayInStatement().

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

◆ FindRefToDistArrayInStatement_expression_filter()

static bool FindRefToDistArrayInStatement_expression_filter ( expression  e)
static

Definition at line 114 of file compiler-util.c.

116 {
118  return(false);
119 }

References FindRefToDistArray(), found_read, and gen_nconc().

Referenced by FindRefToDistArrayInStatement().

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

◆ IndicesOfRef()

list IndicesOfRef ( syntax  syn)

??? could check that the given call is a constant.

Parameters
synyn

Definition at line 156 of file compiler-util.c.

158 {
159  list l = NIL;
160 
161  pips_assert("reference", syntax_reference_p(syn));
162 
163  MAP(EXPRESSION, e,
164  {
165  syntax s = expression_syntax(e);
166 
167  switch (syntax_tag(s))
168  {
169  case is_syntax_reference:
170  l = CONS(SYNTAX, s, l);
171  break;
172  case is_syntax_range:
173  pips_internal_error("don't konw what to do with a range");
174  break;
175  case is_syntax_call:
176  /* ??? could check that the given call is a constant.
177  */
178  break;
179  default:
180  pips_internal_error("unexpected syntax tag");
181  }
182  },
184 
185  return(l);
186 }
#define pips_internal_error
Definition: misc-local.h:149
#define syntax_reference_p(x)
Definition: ri.h:2728
#define syntax_tag(x)
Definition: ri.h:2727
@ is_syntax_range
Definition: ri.h:2692
@ is_syntax_call
Definition: ri.h:2693
@ is_syntax_reference
Definition: ri.h:2691
#define reference_indices(x)
Definition: ri.h:2328

References CONS, EXPRESSION, expression_syntax, is_syntax_call, is_syntax_range, is_syntax_reference, MAP, NIL, pips_assert, pips_internal_error, reference_indices, SYNTAX, syntax_reference, syntax_reference_p, and syntax_tag.

Referenced by lIndicesOfRef().

+ Here is the caller graph for this function:

◆ indirections_inside_statement_p()

bool indirections_inside_statement_p ( _UNUSED_ statement  stat)

indirections_inside_statement_p

??? this may be checked using the dependences graph, looking for edges linking two distributed variables inside the loop...

Definition at line 280 of file compiler-util.c.

281 {
282  ifdebug(1)
283  hpfc_warning("not implemented yet, returning FALSE\n");
284  return false;
285 }
#define false
Definition: newgen_types.h:80

References hpfc_warning, and ifdebug.

Referenced by hpf_compile_loop().

+ Here is the caller graph for this function:

◆ is_in_syntax_list()

bool is_in_syntax_list ( entity  e,
list  l 
)

Definition at line 200 of file compiler-util.c.

203 {
204  MAP(SYNTAX, s,
205  if (e==reference_variable(syntax_reference(s))) return(true),
206  l);
207 
208  return(false);
209 }

References MAP, reference_variable, SYNTAX, and syntax_reference.

Referenced by AddOnceToIndicesList(), and FindDefinitionsOf_rewrite().

+ Here is the caller graph for this function:

◆ lIndicesOfRef()

list lIndicesOfRef ( list  lsyn)

computes the list of indices of the list of ref that are variables...

Parameters
lsynsyn

Definition at line 147 of file compiler-util.c.

149 {
150  return((ENDP(lsyn))?
151  (NULL):
153  lIndicesOfRef(CDR(lsyn)))));
154 }
list lIndicesOfRef(list lsyn)
computes the list of indices of the list of ref that are variables...
list IndicesOfRef(syntax syn)
list AddOnceToIndicesList(list l, list lsyn)

References AddOnceToIndicesList(), CAR, CDR, ENDP, IndicesOfRef(), and SYNTAX.

Referenced by hpf_compile_parallel_body().

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

◆ loop_filter()

static bool loop_filter ( loop  l)
static

Definition at line 310 of file compiler-util.c.

311 {
313 }
#define loop_execution(x)
Definition: ri.h:1648
#define execution_parallel_p(x)
Definition: ri.h:1211

References execution_parallel_p, and loop_execution.

Referenced by parallel_loop_nest_to_body().

+ Here is the caller graph for this function:

◆ loop_index_to_range()

range loop_index_to_range ( entity  index)
Parameters
indexndex

Definition at line 390 of file compiler-util.c.

392 {
393  MAP(LOOP, l, if (loop_index(l)==index) return(loop_range(l)),
395  return range_undefined;
396 }
#define range_undefined
Definition: ri.h:2263
#define loop_range(x)
Definition: ri.h:1642

References current_loop_list, LOOP, loop_index, loop_range, MAP, and range_undefined.

Referenced by array_access_to_array_ranges(), and generate_one_message().

+ Here is the caller graph for this function:

◆ loop_rewrite()

static void loop_rewrite ( loop  l)
static

a loop was found directly as a body

Definition at line 326 of file compiler-util.c.

327 {
328  if (n_loops!=n_levels) /* a loop was found directly as a body */
329  n_levels++, blocks = CONS(LIST, NIL, blocks);
330 
331  if (n_loops==0) inner_body=loop_body(l);
332  loops = CONS(LOOP, l, loops);
333  n_loops++;
334 }
static int n_loops
list of lists, may be NIL if none
static list blocks
lisp of loops
static int n_levels
static list loops
static statement inner_body
#define LIST(x)
Definition: genC.h:93
#define loop_body(x)
Definition: ri.h:1644

References blocks, CONS, inner_body, LIST, LOOP, loop_body, loops, n_levels, n_loops, and NIL.

Referenced by parallel_loop_nest_to_body().

+ Here is the caller graph for this function:

◆ parallel_loop_nest_to_body()

statement parallel_loop_nest_to_body ( statement  loop_nest,
list pblocks,
list ploops 
)

nothing was done for the first !

Parameters
loop_nestoop_nest
pblocksblocks
ploopsloops

Definition at line 336 of file compiler-util.c.

339 {
340  loops=NIL, n_loops=0;
341  blocks=NIL, n_levels=0;
343 
345 
346  gen_multi_recurse(loop_nest,
349  NULL);
350 
351  pips_assert("loops found", n_loops!=0 && (n_loops-n_levels==1));
352 
353  *pblocks = CONS(LIST, NIL, blocks); /* nothing was done for the first ! */
354  *ploops=loops;
355 
356  return(inner_body);
357 }
static bool loop_filter(loop l)
static void loop_rewrite(loop l)
static void sequence_rewrite(sequence s)
#define instruction_loop_p(x)
Definition: ri.h:1518
#define loop_domain
newgen_language_domain_defined
Definition: ri.h:218
#define sequence_domain
newgen_reference_domain_defined
Definition: ri.h:346
#define statement_undefined
Definition: ri.h:2419

References blocks, CONS, gen_multi_recurse(), gen_true(), inner_body, instruction_loop_p, LIST, loop_domain, loop_filter(), loop_rewrite(), loops, n_levels, n_loops, NIL, pips_assert, sequence_domain, sequence_rewrite(), statement_instruction, and statement_undefined.

Referenced by full_copy_p(), and Overlap_Analysis().

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

◆ reset_current_loops()

void reset_current_loops ( void  )

Definition at line 377 of file compiler-util.c.

378 {
381 }

References current_loop_list, gen_free_list(), and NIL.

+ Here is the call graph for this function:

◆ sequence_rewrite()

static void sequence_rewrite ( sequence  s)
static

there was no doall inside

Definition at line 315 of file compiler-util.c.

316 {
317  if (n_loops==0 && n_levels==0) /* there was no doall inside */
318  return;
319 
320  if (n_loops-n_levels!=1)
321  pips_internal_error("block within a block encountered");
322 
324 }
#define sequence_statements(x)
Definition: ri.h:2360

References blocks, CONS, LIST, n_levels, n_loops, pips_internal_error, and sequence_statements.

Referenced by parallel_loop_nest_to_body().

+ Here is the caller graph for this function:

◆ set_current_loops()

void set_current_loops ( statement  obj)
Parameters
objbj

Definition at line 371 of file compiler-util.c.

372 {
373  pips_assert("no current loop", current_loop_list==NIL);
375 }
static void set_current_loops_rewrite(loop l)

References current_loop_list, gen_recurse, gen_true(), loop_domain, NIL, pips_assert, and set_current_loops_rewrite().

Referenced by Overlap_Analysis().

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

◆ set_current_loops_rewrite()

static void set_current_loops_rewrite ( loop  l)
static

Definition at line 366 of file compiler-util.c.

367 {
369 }

References CONS, current_loop_list, and LOOP.

Referenced by set_current_loops().

+ Here is the caller graph for this function:

◆ update_control_lists()

void update_control_lists ( control  c,
control_mapping  map 
)

Compiler Utilities.

compiler-util.c

Fabien Coelho, May 1993

Parameters
mapap

Definition at line 36 of file compiler-util.c.

39 {
40  control cprime = (control) GET_CONTROL_MAPPING(map, c);
41 
42  pips_assert("empty lists for cprime",
43  control_predecessors(cprime)==NIL &&
44  control_successors(cprime)==NIL);
45 
46  control_predecessors(cprime) =
48  control_successors(cprime) =
50 }
list updated_control_list(list lc, control_mapping map)
Definition: compiler-util.c:52
struct _newgen_struct_control_ * control
#define GET_CONTROL_MAPPING(map, cont)
Definition: newgen-local.h:88
#define control_predecessors(x)
Definition: ri.h:943
#define control_successors(x)
Definition: ri.h:945

References control_predecessors, control_successors, GET_CONTROL_MAPPING, NIL, pips_assert, and updated_control_list().

Referenced by hpf_compile_unstructured().

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

◆ updated_control_list()

list updated_control_list ( list  lc,
control_mapping  map 
)
Parameters
lcc
mapap

Definition at line 52 of file compiler-util.c.

55 {
56  list lc_result = NIL;
57  control new_c = control_undefined;
58 
60  {
61  new_c = (control) GET_CONTROL_MAPPING(map, current);
62 
63  pips_assert("defined",
65  !control_undefined_p(new_c));
66 
67  lc_result = CONS(CONTROL, new_c, lc_result);
68  },
69  lc);
70 
71  return(gen_nreverse(lc_result));
72 }
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
#define control_undefined
Definition: ri.h:916
#define CONTROL(x)
CONTROL.
Definition: ri.h:910
#define control_undefined_p(x)
Definition: ri.h:917
static size_t current
Definition: string.c:115

References CONS, CONTROL, control_undefined, control_undefined_p, current, gen_nreverse(), GET_CONTROL_MAPPING, MAP, NIL, and pips_assert.

Referenced by update_control_lists().

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

Variable Documentation

◆ blocks

◆ current_loop_list

list current_loop_list =NIL
static

management of a list of current loops.

very burk ???

Definition at line 364 of file compiler-util.c.

Referenced by entity_loop_index_p(), loop_index_to_range(), reset_current_loops(), set_current_loops(), and set_current_loops_rewrite().

◆ found_definitions

list found_definitions =NIL
static

Definition at line 216 of file compiler-util.c.

Referenced by FindDefinitionsOf(), and FindDefinitionsOf_rewrite().

◆ found_read

◆ found_written

list found_written = NIL
static

FindRefToDistArrayInStatement.

everything may be quite false regarding to the real effects of the functions called, but it seems to me that the pips effect analysis doesn't match my needs... and I have not much time to think about that...

??? these stupid functions assume no indirections on distributed arrays ??? also that they are not written by a function other than assign

Definition at line 84 of file compiler-util.c.

Referenced by FindRefToDistArrayInStatement(), and FindRefToDistArrayInStatement_call_filter().

◆ inner_body

◆ loops

list loops
static

statement parallel_loop_nest_to_body(loop_nest, pblocks, ploops) statement loop_nest; list *pblocks, *ploops;

What I want is to extract the parallel loops from loop_nest, while keeping track of the structure if the loop nest is not perfectly nested. Only a very simple structure is recognized.

it returns the inner statement of the loop nest, a list of pointers to the loops, and a list of pointers to the blocks containing these loops if any.

we may discuss the implementation based on static global variables... but I cannot see how to do it otherwise with a gen_recurse.

Definition at line 305 of file compiler-util.c.

Referenced by add_conflicts(), adg_get_predicate_of_loops(), CodeGenerate(), find_level_l_loop_statement(), index_of_a_loop_p(), IsolatedStatement(), loop_rewrite(), loops_mapping_of_statement(), MakeNestOfParallelLoops(), MakeNestOfStatementList(), module_loops(), parallel_loop_nest_to_body(), print_loops(), process_reduced_loops(), quick_privatize_statement_pair(), rloops_mapping_of_statement(), rloops_mapping_of_unstructured(), simdizer_auto_tile(), statement_imbrication_level(), and variable_private_to_loop_p().

◆ n_levels

int n_levels
static

Definition at line 307 of file compiler-util.c.

Referenced by loop_rewrite(), parallel_loop_nest_to_body(), and sequence_rewrite().

◆ n_loops

int n_loops
static

list of lists, may be NIL if none

Definition at line 307 of file compiler-util.c.

Referenced by loop_rewrite(), parallel_loop_nest_to_body(), and sequence_rewrite().

◆ syntax_list

list syntax_list =NIL
static

??? False! The definition looked for must be an assignment call...

Definition at line 215 of file compiler-util.c.

Referenced by FindDefinitionsOf(), and FindDefinitionsOf_rewrite().