PIPS
compiler.c
Go to the documentation of this file.
1 /*
2 
3  $Id: compiler.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 - Fabien Coelho, May 1993 and later...
28  *
29  * Compiler
30  *
31  * stat is the current statement to be compiled, and there are
32  * pointers to the current statement building of the node and host
33  * codes. the module of these are also kept in order to add
34  * the needed declarations generated by the compilation.
35  *
36  * however, every entities of the compiled program, and of
37  * both generated programs will be mixed, due to the
38  * tabulated nature of these objects.
39  * some objects will be shared.
40  * I don't think this is a problem.
41  */
42 
43 #include "defines-local.h"
44 
45 /* global variables
46  */
48 
49 #define debug_print_control(c, w)\
50  fprintf(stderr, \
51  "%s: ctr %p (stat %p) , %zd preds, %zd succs\n", w, \
52  c, control_statement(c), \
53  gen_length(control_predecessors(c)), \
54  gen_length(control_successors(c))); \
55  print_statement(control_statement(c));
56 
57 static void
58 hpf_compile_block(stat, hoststatp, nodestatp)
59 statement stat;
60 statement *hoststatp,*nodestatp;
61 {
62  list /* of statements */ lhost=NIL, lnode=NIL;
63  statement hostcd, nodecd;
64 
66 
67  (*hoststatp) = MakeStatementLike(stat, is_instruction_block);
68  (*nodestatp) = MakeStatementLike(stat, is_instruction_block);
69 
70  MAP(STATEMENT, s,
71  {
72  hpf_compiler(s,&hostcd,&nodecd);
73 
74  lhost = CONS(STATEMENT, hostcd, lhost);
75  lnode = CONS(STATEMENT, nodecd, lnode);
76  },
78 
81 
82  DEBUG_STAT(9, entity_name(host_module), *hoststatp);
83  DEBUG_STAT(9, entity_name(node_module), *nodestatp);
84 }
85 
86 static void
87 hpf_compile_test(s, hoststatp, nodestatp)
88 statement s;
89 statement *hoststatp,*nodestatp;
90 {
91  statement
92  s_true, s_hosttrue, s_nodetrue,
93  s_false, s_hostfalse, s_nodefalse;
94  test the_test;
95  expression condition;
96 
98 
100  condition = test_condition(the_test);
101 
102  (*hoststatp) = MakeStatementLike(s, is_instruction_test);
103  (*nodestatp) = MakeStatementLike(s, is_instruction_test);
104 
105  /* if it may happen that a condition modifies the value
106  * of a distributed variable, this condition is to be
107  * put out of the statement, for separate compilation.
108  */
109 
110  s_true = test_true(the_test);
111  s_false = test_false(the_test);
112 
113  hpf_compiler(s_true, &s_hosttrue, &s_nodetrue);
114  hpf_compiler(s_false, &s_hostfalse, &s_nodefalse);
115 
118  s_hosttrue,
119  s_hostfalse);
120 
123  s_nodetrue,
124  s_nodefalse);
125 
126  DEBUG_STAT(9, entity_name(host_module), *hoststatp);
127  DEBUG_STAT(9, entity_name(node_module), *nodestatp);
128 }
129 
130 /* return the list of bounds
131  */
132 static list /* of expression */
134  _UNUSED_ entity fun,
135  list /* of expression */ le)
136 {
137  list /* of expression */ lneeded = NIL;
138  int len = gen_length(le);
139 
140  for (; len>=1; len--)
141  {
142  expression e = EXPRESSION(gen_nth(len-1, le));
143  syntax s = expression_syntax(e);
144 
145  if (syntax_reference_p(s))
146  {
147  entity var, old;
148 
150  var = load_new_node(old);
151  pips_debug(8, "considering %s\n", entity_name(var));
152 
153  if (array_distributed_p(old))
154  {
155  int dim = NumberOfDimension(var);
156 
157  for (; dim>=1; dim--)
158  {
159  if (ith_dim_overlapable_p(old, dim))
160  {
161  lneeded =
162  CONS(EXPRESSION, hpfc_array_bound(var, false, dim),
163  CONS(EXPRESSION, hpfc_array_bound(var, true, dim),
164  lneeded));
165  }
166  }
167  }
168  }
169  }
170 
171  return lneeded;
172 }
173 
174 static void
176  statement stat, /* compiled statement */
177  statement *hoststatp, /* returned host version */
178  statement *nodestatp) /* returned node version */
179 {
181 
182  /* IO functions should be detected earlier, in hpf_compiler
183  */
184  pips_assert("not an io call", !IO_CALL_P(c));
186  pips_debug(7, "function %s\n", entity_name(call_function(c)));
187 
188  DEBUG_STAT(9, "statement", stat);
189 
190  /* "kill" FC directive.
191  * tells that the array is dead, hence all copies are live...
192  */
194  {
195  list /* of statement */ ls = NIL;
196 
197  MAP(EXPRESSION, e,
198  {
199  entity primary = expression_to_entity(e);
200  pips_debug(5, "dealing with array %s\n", entity_name(primary));
201  if (array_distributed_p(primary))
202  ls = CONS(STATEMENT, generate_all_liveness(primary, true), ls);
203  },
204  call_arguments(c));
205 
206  (*hoststatp) = MakeStatementLike(stat, is_instruction_block);
207  (*nodestatp) = MakeStatementLike(stat, is_instruction_block);
208 
210  instruction_block(statement_instruction(*nodestatp)) = ls;
211 
212  return;
213  }
214 
215  /* no reference to distributed arrays...
216  * the call is just translated into local objects.
217  */
218  if (!ref_to_dist_array_p(c))
219  {
220  pips_debug(7, "no reference to distributed variable\n");
221 
222  (*hoststatp)=MakeStatementLike(stat, is_instruction_call);
223  (*nodestatp)=MakeStatementLike(stat, is_instruction_call);
224 
227 
230 
231  DEBUG_STAT(8, entity_name(host_module), *hoststatp);
232  DEBUG_STAT(8, entity_name(node_module), *nodestatp);
233 
234  return;
235  }
236 
237  /* should consider read and written variables
238  */
240  {
241  list /* of expressions */
242  lh = NIL, ln = NIL, args = call_arguments(c) ;
243  expression
244  w = EXPRESSION(CAR(args)),
245  r = EXPRESSION(CAR(CDR(args)));
246 
248 
251  {
252  pips_debug(8, "c1-alpha\n");
253 
254  generate_c1_alpha(stat, &lh, &ln); /* C1-ALPHA */
255  }
256  else
257  {
258  syntax s = expression_syntax(r);
259 
260  /* reductions are detected here. They are not handled otherwise
261  */
263  {
264  statement sh, sn;
265 
266  if (!compile_reduction(stat, &sh, &sn))
267  pips_internal_error("reduction compilation failed");
268 
269  lh = CONS(STATEMENT, sh, NIL);
270  ln = CONS(STATEMENT, sn, NIL);
271  }
272  else
273  {
274  pips_debug(8, "c1-beta\n");
275 
276  generate_c1_beta(stat, &lh, &ln); /* C1-BETA */
277  }
278  }
279 
280  (*hoststatp) = MakeStatementLike(stat, is_instruction_block);
281  (*nodestatp) = MakeStatementLike(stat, is_instruction_block);
282 
283  instruction_block(statement_instruction(*hoststatp)) = lh;
284  instruction_block(statement_instruction(*nodestatp)) = ln;
285 
286  DEBUG_STAT(8, entity_name(host_module), *hoststatp);
287  DEBUG_STAT(8, entity_name(node_module), *nodestatp);
288 
289  return;
290  }
291 
292  /* call to something with distributed variables, which is not an
293  * assignment. Since I do not use the effects as I should, nothing is
294  * done...
295  */
296 
297  /* temporary (?:-) hack
298  */
299  {
300  entity fun = call_function(c);
301  list /* of expressions */
302  args = call_arguments(c),
304  len=lUpdateExpr(node_module, args);
305 
306  update_overlaps_in_caller(fun, args);
307 
308  pips_debug(7, "some references to distributed variable\n");
309 
310  (*hoststatp)=MakeStatementLike(stat, is_instruction_call);
311  (*nodestatp)=MakeStatementLike(stat, is_instruction_call);
312 
314  make_call(fun, leh);
315 
317  make_call(fun, gen_nconc(len, caller_list_of_bounds(fun, args)));
318 
319  DEBUG_STAT(8, entity_name(host_module), *hoststatp);
320  DEBUG_STAT(8, entity_name(node_module), *nodestatp);
321 
322  return;
323  }
324 }
325 
326 static void compile_control(
327  control c,
328  statement_mapping maph,
329  statement_mapping mapn)
330 {
331  control hostc, nodec;
332  statement stath, statn, statc = control_statement(c);
333 
334  hpf_compiler(statc, &stath, &statn);
335 
336  DEBUG_STAT(7, "statc", statc);
337  DEBUG_STAT(7, "host stat", stath);
338  DEBUG_STAT(7, "node stat", statn);
339 
340  hostc = make_control(stath, NIL, NIL);
341  SET_CONTROL_MAPPING(maph, c, hostc);
342 
343  nodec = make_control(statn, NIL, NIL);
344  SET_CONTROL_MAPPING(mapn, c, nodec);
345 }
346 
347 static void
349  statement stat,
350  statement *hoststatp,
351  statement *nodestatp)
352 {
354 
355  pips_assert("unstructured", instruction_unstructured_p(inst));
356 
358  {
359  pips_debug(7, "one statement recognize\n");
360 
361  /* nothing spacial is done!
362  * ??? there may be a problem with the label of the statement, if any.
363  */
366  hoststatp, nodestatp);
367  }
368  else
369  {
371  hostmap = MAKE_CONTROL_MAPPING(),
372  nodemap = MAKE_CONTROL_MAPPING();
375  ce = unstructured_exit(u), new_ct, new_ce;
376  list blocks = NIL;
377 
378  pips_debug(6, "beginning\n");
379 
380  CONTROL_MAP(c, compile_control(c, hostmap, nodemap), ct, blocks);
381 
382  if (!gen_in_list_p(ce, blocks))
383  {
384  pips_debug(5, "exit not in blocks\n");
385  blocks = CONS(CONTROL, ce, blocks);
386  compile_control(ce, hostmap, nodemap);
387  }
388 
389  MAP(CONTROL, c,
390  {
391  update_control_lists(c, hostmap);
392  update_control_lists(c, nodemap);
393  },
394  blocks);
395 
396  ifdebug(9)
397  {
398  control h_tmp, n_tmp;
399 
400  pips_debug(9, "controls:\n");
401 
402  MAP(CONTROL, c_tmp,
403  {
404  h_tmp = (control) GET_CONTROL_MAPPING(hostmap, c_tmp);
405  n_tmp = (control) GET_CONTROL_MAPPING(nodemap, c_tmp);
406 
407  debug_print_control(c_tmp, "initial");
408  debug_print_control(h_tmp, "host");
409  debug_print_control(n_tmp, "node");
410  },
411  blocks);
412  }
413 
414  /* HOST statement
415  */
416  (*hoststatp) = MakeStatementLike(stat, is_instruction_unstructured);
417 
418  new_ct = (control) GET_CONTROL_MAPPING(hostmap, ct);
419  new_ce = (control) GET_CONTROL_MAPPING(hostmap, ce);
420 
421  pips_assert("defined control", !control_undefined_p(new_ct) &&
422  !control_undefined_p(new_ce));
423 
424  ifdebug(9)
425  {
426  pips_debug(9, "host controls for [%p,%p]:\n", ct, ce);
427 
428  debug_print_control(new_ct, "main");
429  debug_print_control(new_ce, "exit");
430  }
431 
433  make_unstructured(new_ct, new_ce);
434 
435  DEBUG_STAT(7, "host new stat", *hoststatp);
436 
437  /* NODE statement
438  */
439  (*nodestatp) = MakeStatementLike(stat, is_instruction_unstructured);
440 
441  new_ct = (control) GET_CONTROL_MAPPING(nodemap, ct);
442  new_ce = (control) GET_CONTROL_MAPPING(nodemap, ce);
443 
444  pips_assert("defined control",
445  !control_undefined_p(new_ct) &&
446  !control_undefined_p(new_ce));
447 
449  make_unstructured(new_ct, new_ce);
450 
451  DEBUG_STAT(7, "host new stat (again)", *hoststatp);
452 
454  FREE_CONTROL_MAPPING(hostmap);
455  FREE_CONTROL_MAPPING(nodemap);
456  }
457 }
458 
459 static void
460 hpf_compile_sequential_loop(stat,hoststatp,nodestatp)
461 statement stat, *hoststatp, *nodestatp;
462 {
463  loop the_loop=statement_loop(stat);
464  statement body = loop_body(the_loop), hostbody, nodebody;
465  range r=loop_range(the_loop);
466  list /* of entities */ locals=loop_locals(the_loop);
467  entity
468  label = loop_label(the_loop),
469  index = loop_index(the_loop),
470  nindex = NewVariableForModule(node_module, index),
471  hindex = NewVariableForModule(host_module, index);
472  expression
473  lower = range_lower(r),
474  upper = range_upper(r),
475  increment = range_increment(r);
476 
477  hpf_compiler(body, &hostbody, &nodebody);
478 
479  if (empty_code_p(hostbody))
480  {
481  /* ??? memory leak, hostbody is lost whatever it was.
482  */
484  }
485  else
486  {
487  (*hoststatp)=MakeStatementLike(stat, is_instruction_loop);
488 
490  make_loop(hindex,
494  hostbody,
495  label,
498  }
499 
500  DEBUG_STAT(8, "host stat", *hoststatp);
501 
502  (*nodestatp)=MakeStatementLike(stat, is_instruction_loop);
503 
505  make_loop(nindex,
509  nodebody,
510  label,
513 
514  DEBUG_STAT(8, "node stat", *nodestatp);
515 }
516 
517 static void
518 hpf_compile_parallel_body(body, hoststatp, nodestatp)
519 statement body, *hoststatp, *nodestatp;
520 {
521  list lw = NIL, lr = NIL, li = NIL, ls = NIL, lbs = NIL;
522 
523  /* ???
524  * dependances are not surely respected in the definitions list...
525  * should check that only locals variables, that are not replicated,
526  * may be defined during the body of the loop...
527  */
528  FindRefToDistArrayInStatement(body, &lw, &lr);
530  ls = FindDefinitionsOf(body, li);
531  gen_free_list(li), li=NIL;
532 
533  if (gen_length(lw)==0 && gen_length(lr)==0) /* very partial */
534  {
535  (*hoststatp) = copy_statement(body);
536  (*nodestatp) = copy_statement(body);
537  }
538  else
539  {
540  generate_parallel_body(body, &lbs, lw, lr);
541 
542  (*hoststatp) = NULL;
543  (*nodestatp) = make_block_statement(gen_nconc(ls, lbs));
544  }
545 
546  gen_free_list(lw), lw=NIL;
547  gen_free_list(lr), lr=NIL;
548 }
549 
550 static void
552  statement stat,
553  statement *hoststatp,
554  statement *nodestatp)
555 {
556  loop the_loop = statement_loop(stat);
557  statement s, nodebody, body = loop_body(the_loop);
558  instruction bodyinst = statement_instruction(body);
559  entity
560  label = loop_label(the_loop),
561  index = loop_index(the_loop),
562  nindex = NewVariableForModule(node_module,index);
563  range r = loop_range(the_loop);
564  expression
565  lower = range_lower(r),
566  upper = range_upper(r),
567  increment = range_increment(r);
568  list lw=NIL, lr=NIL;
569 
570  FindRefToDistArrayInStatement(stat, &lw, &lr);
571 
572  if (lw||lr)
573  {
574  pips_assert("parallel loop",
576 
577  if ((instruction_loop_p(bodyinst)) &&
579  hpf_compile_parallel_loop(body, &s, &nodebody);
580  else
581  hpf_compile_parallel_body(body, &s, &nodebody);
582 
584  (*nodestatp) = MakeStatementLike(stat, is_instruction_loop);
585 
587  make_loop(nindex,
591  nodebody,
592  label,
594  NULL);
595  } else {
596  (*hoststatp) = copy_statement(stat);
597  (*nodestatp) = copy_statement(stat);
598  }
599 
600  gen_free_list(lw), gen_free_list(lr);
601 
602 }
603 
604 /* is there a parallel loop down s?
605  */
607 static bool loop_flt(loop l)
608 {
610  parallel_loop_found = true;
611  gen_recurse_stop(NULL);
612  }
613  return !parallel_loop_found;
614 }
616 {
617  parallel_loop_found = false;
619  return parallel_loop_found;
620 }
621 
622 static void
623 hpf_compile_loop(stat, hoststatp, nodestatp)
624 statement stat;
625 statement *hoststatp, *nodestatp;
626 {
627  loop the_loop = instruction_loop(statement_instruction(stat));
628  list l = NIL;
629  entity var;
630  bool is_shift = subarray_shift_p(stat, &var, &l);
631 
632  pips_assert("stat is a loop", statement_loop_p(stat));
633 
634  if (is_shift)
635  {
636  pips_debug(4, "shift detected\n");
637 
638  *nodestatp = generate_subarray_shift(stat, var, l);
639  *hoststatp = make_empty_statement();
640  }
641  else if (execution_parallel_p(loop_execution(the_loop)))
642  {
643  reference left, right;
644  bool /* should verify that only listed in labels and distributed
645  * entities are defined inside the body of the loop
646  */
647  at_ac = atomic_accesses_only_p(stat),
648  in_in = indirections_inside_statement_p(stat),
649  is_full_copy = full_copy_p(stat, &left, &right);
650 
651  pips_debug(5, "condition results: aa %d, in %d\n", at_ac, in_in);
652 
653 
654  if (is_full_copy)
655  {
656  pips_debug(4, "full copy detected\n");
657 
658  *nodestatp = generate_full_copy(left, right);
659  *hoststatp = make_empty_statement();
660  }
661  else if (at_ac && !in_in)
662  {
663  statement overlapstat;
664 
665  pips_debug(7, "compiling a parallel loop\n");
666 
667  if (Overlap_Analysis(stat, &overlapstat))
668  {
669  string c = statement_comments(stat);
670  pips_debug(7, "overlap analysis succeeded\n");
671 
673  *nodestatp = overlapstat;
674  if (!string_undefined_p(c))
675  insert_comments_to_statement(*nodestatp, c);
676  }
677  else
678  {
679  pips_debug(7, "overlap analysis is not ok...\n");
680 
681  if (parallel_loop_in_stat_p(loop_body(the_loop)))
682  hpf_compile_sequential_loop(stat, hoststatp, nodestatp);
683  else
684  hpf_compile_parallel_loop(stat, hoststatp, nodestatp);
685  }
686  }
687  else
688  {
689  pips_debug(7, "compiling a parallel loop sequential...\n");
690  hpf_compile_sequential_loop(stat, hoststatp, nodestatp);
691  }
692  }
693  else
694  {
695  pips_debug(7,"compiling a sequential loop\n");
696 
697  hpf_compile_sequential_loop(stat, hoststatp, nodestatp);
698  }
699 }
700 
701 /* what: compile a statement into a host and SPMD node code.
702  * how: double code rewriting in a recursive traversal of stat.
703  * input: statement stat.
704  * output: statements *hoststatp and *nodestatp
705  * side effects: ?
706  * bugs or features:
707  * - special care is made here of I/O and remappings.
708  */
709 void
711  statement stat,
712  statement *hoststatp,
713  statement *nodestatp)
714 {
715  list /* of hpfc_reduction */ lr = NIL;
716  bool root_statement_p = stat==get_current_module_statement();
717 
718  DEBUG_STAT(9, "stat is", stat);
719  pips_debug(9, "only io %d, remapping %d, reduction %d\n",
721  bound_renamings_p(stat),
722  bound_hpf_reductions_p(stat));
723 
724  if (load_statement_only_io(stat)==1) /* necessary */
725  {
726  io_efficient_compile(stat, hoststatp, nodestatp);
727  return;
728  }
729  else if (bound_renamings_p(stat) && !root_statement_p) /* remapping */
730  {
731  remapping_compile(stat, hoststatp, nodestatp);
732  return;
733  }
734 
735  if (bound_hpf_reductions_p(stat)) /* HPF REDUCTION */
736  lr = handle_hpf_reduction(stat);
737 
738  /* else usual stuff
739  */
741  {
743  hpf_compile_block(stat, hoststatp, nodestatp);
744  break;
745  case is_instruction_test:
746  hpf_compile_test(stat, hoststatp, nodestatp);
747  break;
748  case is_instruction_loop:
749  hpf_compile_loop(stat, hoststatp, nodestatp);
750  break;
751  case is_instruction_call:
752  hpf_compile_call(stat, hoststatp, nodestatp);
753  break;
755  hpf_compile_unstructured(stat, hoststatp, nodestatp);
756  break;
757  case is_instruction_goto:
758  default:
759  pips_internal_error("unexpected instruction tag");
760  break;
761  }
762 
763  if (lr)
764  {
765  list /* of statement */ lh, ln;
766  lh = gen_nconc(compile_hpf_reduction(lr, true, true),
767  CONS(STATEMENT, *hoststatp,
768  compile_hpf_reduction(lr, false, true)));
769  ln = gen_nconc(compile_hpf_reduction(lr, true, false),
770  CONS(STATEMENT, *nodestatp,
771  compile_hpf_reduction(lr, false, false)));
772 
773  *hoststatp = make_block_statement(lh);
774  *nodestatp = make_block_statement(ln);
775  }
776 
777  if (root_statement_p && bound_renamings_p(stat))
778  {
779  *nodestatp = make_block_statement(
781  CONS(STATEMENT, *nodestatp, NIL)));
782  }
783 }
784 
785 /* That is all
786  */
unstructured make_unstructured(control a1, control a2)
Definition: ri.c:2778
execution make_execution(enum execution_utype tag, void *val)
Definition: ri.c:838
call make_call(entity a1, list a2)
Definition: ri.c:269
loop make_loop(entity a1, range a2, statement a3, entity a4, execution a5, list a6)
Definition: ri.c:1301
statement copy_statement(statement p)
STATEMENT.
Definition: ri.c:2186
test make_test(expression a1, statement a2, statement a3)
Definition: ri.c:2607
call copy_call(call p)
CALL.
Definition: ri.c:233
control make_control(statement a1, list a2, list a3)
Definition: ri.c:523
range make_range(expression a1, expression a2, expression a3)
Definition: ri.c:2041
static list blocks
lisp of loops
bool indirections_inside_statement_p(_UNUSED_ statement stat)
indirections_inside_statement_p
list lIndicesOfRef(list lsyn)
computes the list of indices of the list of ref that are variables...
void FindRefToDistArrayInStatement(statement obj, list *lwp, list *lrp)
list FindDefinitionsOf(statement stat, list lsyn)
bool atomic_accesses_only_p(_UNUSED_ statement stat)
atomic_accesses_only_p
void update_control_lists(control c, control_mapping map)
Compiler Utilities.
Definition: compiler-util.c:36
list AddOnceToIndicesList(list l, list lsyn)
static void hpf_compile_loop(statement stat, statement *hoststatp, statement *nodestatp)
Definition: compiler.c:623
void hpf_compiler(statement stat, statement *hoststatp, statement *nodestatp)
what: compile a statement into a host and SPMD node code.
Definition: compiler.c:710
entity host_module
HPFC - Fabien Coelho, May 1993 and later...
Definition: compiler.c:47
#define debug_print_control(c, w)
Definition: compiler.c:49
static void hpf_compile_call(statement stat, statement *hoststatp, statement *nodestatp)
returned node version
Definition: compiler.c:175
entity node_module
Definition: compiler.c:47
static void hpf_compile_parallel_body(statement body, statement *hoststatp, statement *nodestatp)
Definition: compiler.c:518
static bool loop_flt(loop l)
Definition: compiler.c:607
static void hpf_compile_unstructured(statement stat, statement *hoststatp, statement *nodestatp)
Definition: compiler.c:348
static list caller_list_of_bounds(_UNUSED_ entity fun, list le)
return the list of bounds
Definition: compiler.c:133
static void hpf_compile_test(statement s, statement *hoststatp, statement *nodestatp)
Definition: compiler.c:87
static void hpf_compile_sequential_loop(statement stat, statement *hoststatp, statement *nodestatp)
Definition: compiler.c:460
static bool parallel_loop_in_stat_p(statement s)
Definition: compiler.c:615
static void hpf_compile_parallel_loop(statement stat, statement *hoststatp, statement *nodestatp)
Definition: compiler.c:551
static bool parallel_loop_found
is there a parallel loop down s?
Definition: compiler.c:606
static void compile_control(control c, statement_mapping maph, statement_mapping mapn)
Definition: compiler.c:326
static void hpf_compile_block(statement stat, statement *hoststatp, statement *nodestatp)
Definition: compiler.c:58
#define gen_recurse(start, domain_number, flt, rwt)
Definition: genC.h:283
void generate_c1_beta(statement stat, list *lhp, list *lnp)
??? this should work (but that is not the case yet), with every call with no write to distributed arr...
Definition: generate.c:41
void generate_c1_alpha(statement stat, list *lhp, list *lnp)
generate_c1_alpha
Definition: generate.c:121
void generate_parallel_body(statement body, list *lstatp, list lw, list lr)
Definition: generate.c:511
statement make_block_statement(list)
Make a block statement from a list of statement.
Definition: statement.c:616
#define CONTROL_MAP(ctl, code, c, list)
Macro to walk through all the controls reachable from a given control node of an unstructured.
statement get_current_module_statement(void)
Get the current module statement.
Definition: static.c:208
void gen_recurse_stop(void *obj)
Tells the recursion not to go in this object.
Definition: genClib.c:3251
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
Definition: genClib.c:2752
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
size_t gen_length(const list l)
Definition: list.c:150
#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
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
bool gen_in_list_p(const void *vo, const list lx)
tell whether vo belongs to lx
Definition: list.c:734
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
gen_chunk gen_nth(int n, const list l)
to be used as ENTITY(gen_nth(3, l))...
Definition: list.c:710
#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
loop statement_loop(statement)
Get the loop of a statement.
Definition: statement.c:1374
bool statement_loop_p(statement)
Definition: statement.c:349
void insert_comments_to_statement(statement, const char *)
Insert a comment string (if non empty) at the beginning of the comments of a statement.
Definition: statement.c:1916
bool empty_code_p(statement)
statement.c
Definition: statement.c:86
statement make_continue_statement(entity)
Definition: statement.c:953
void update_object_for_module(void *obj, entity module)
list lNewVariableForModule(entity module, list le)
entity NewVariableForModule(entity module, entity e)
list lUpdateExpr(entity module, list l)
list lUpdateExpr_but_distributed(entity module, list l)
used for compiling calls.
expression UpdateExpressionForModule(entity module, expression ex)
this function creates a new expression using the mapping of old to new variables map.
statement MakeStatementLike(statement stat, int the_tag)
creates a new statement for the given module that looks like the stat one, i.e.
Definition: hpfc-util.c:203
bool ref_to_dist_array_p(void *obj)
this file describe a few functions usefull to the compiler to manage the hpfc data structures.
Definition: hpfc-util.c:48
bool ith_dim_overlapable_p(entity array, int i)
Definition: hpfc-util.c:178
void update_overlaps_in_caller(entity fun, list le)
the overlaps of the actual parameters are updated according to the formal requirements.
Definition: declarations.c:864
#define one_statement_unstructured(u)
Definition: defines-local.h:92
#define DEBUG_STAT(D, W, S)
void remapping_compile(statement, statement *, statement *)
void remapping_compile(s, hsp, nsp) statement s, *hsp, *nsp;
Definition: remapping.c:1302
bool bound_hpf_reductions_p(statement)
bool bound_renamings_p(statement)
entity load_new_node(entity)
statement root_statement_remapping_inits(statement)
returns the initialization statement: must initialize the status and liveness of arrays
Definition: remapping.c:1265
bool full_copy_p(statement, reference *, reference *)
bool Overlap_Analysis(statement, statement *)
check conditions and compile...
Definition: o-analysis.c:870
void io_efficient_compile(statement, statement *, statement *)
compile an io statement
Definition: io-compile.c:911
expression hpfc_array_bound(entity, bool, int)
Definition: run-time.c:516
list compile_hpf_reduction(list, bool, bool)
of statement
list handle_hpf_reduction(statement)
of hpfc_reductions
bool subarray_shift_p(statement, entity *, list *)
statement generate_full_copy(reference, reference)
statement generate_full_copy(reference left, reference right)
bool compile_reduction(statement, statement *, statement *)
bool compile_reduction(initial, phost, pnode)
statement generate_all_liveness(entity, bool)
Definition: remapping.c:940
bool load_statement_only_io(statement)
statement generate_subarray_shift(statement, entity, list)
statement generate_subarray_shift(s, var, lshift) statement s; entity var; list lshift;
bool call_reduction_p(call)
Definition: special_cases.c:87
bool array_distributed_p(entity)
struct _newgen_struct_control_ * control
#define _UNUSED_
Definition: misc-local.h:232
#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 MAKE_CONTROL_MAPPING()
Definition: newgen-local.h:82
#define GET_CONTROL_MAPPING(map, cont)
Definition: newgen-local.h:88
#define FREE_CONTROL_MAPPING(map)
Definition: newgen-local.h:84
#define SET_CONTROL_MAPPING(map, cont, val)
Definition: newgen-local.h:86
#define string_undefined_p(s)
Definition: newgen_types.h:41
#define UU
Definition: newgen_types.h:98
#define IO_CALL_P(call)
#define instruction_block_p(i)
#define ENTITY_ASSIGN_P(e)
#define unstructured_control
After the modification in Newgen: unstructured = entry:control x exit:control we have create a macro ...
#define is_instruction_block
soft block->sequence transition
#define instruction_block(i)
#define make_empty_statement
An alias for make_empty_block_statement.
entity entity_empty_label(void)
Definition: entity.c:1105
entity expression_to_entity(expression e)
just returns the entity of an expression, or entity_undefined
Definition: expression.c:3140
bool dead_fcd_directive_p(entity f)
Definition: hpfc.c:74
int NumberOfDimension(entity)
Definition: size.c:588
#define loop_body(x)
Definition: ri.h:1644
#define syntax_reference_p(x)
Definition: ri.h:2728
#define loop_execution(x)
Definition: ri.h:1648
#define syntax_reference(x)
Definition: ri.h:2730
#define instruction_loop_p(x)
Definition: ri.h:1518
#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 range_upper(x)
Definition: ri.h:2290
#define syntax_call_p(x)
Definition: ri.h:2734
#define instruction_loop(x)
Definition: ri.h:1520
#define test_false(x)
Definition: ri.h:2837
#define CONTROL(x)
CONTROL.
Definition: ri.h:910
#define range_increment(x)
Definition: ri.h:2292
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define entity_undefined
Definition: ri.h:2761
@ is_instruction_goto
Definition: ri.h:1473
@ is_instruction_unstructured
Definition: ri.h:1475
@ is_instruction_test
Definition: ri.h:1470
@ is_instruction_call
Definition: ri.h:1474
@ is_instruction_loop
Definition: ri.h:1471
#define instruction_tag(x)
Definition: ri.h:1511
#define entity_name(x)
Definition: ri.h:2790
#define test_true(x)
Definition: ri.h:2835
#define syntax_call(x)
Definition: ri.h:2736
#define loop_label(x)
Definition: ri.h:1646
#define control_undefined_p(x)
Definition: ri.h:917
#define unstructured_exit(x)
Definition: ri.h:3006
#define instruction_unstructured_p(x)
Definition: ri.h:1530
#define instruction_call_p(x)
Definition: ri.h:1527
#define loop_locals(x)
Definition: ri.h:1650
#define test_condition(x)
Definition: ri.h:2833
#define range_lower(x)
Definition: ri.h:2288
#define statement_instruction(x)
Definition: ri.h:2458
#define statement_comments(x)
Definition: ri.h:2456
#define instruction_call(x)
Definition: ri.h:1529
#define loop_range(x)
Definition: ri.h:1642
@ is_execution_sequential
Definition: ri.h:1189
#define instruction_test_p(x)
Definition: ri.h:1515
#define call_arguments(x)
Definition: ri.h:711
#define control_statement(x)
Definition: ri.h:941
#define instruction_test(x)
Definition: ri.h:1517
#define expression_syntax(x)
Definition: ri.h:1247
#define execution_parallel_p(x)
Definition: ri.h:1211
#define instruction_unstructured(x)
Definition: ri.h:1532
#define loop_index(x)
Definition: ri.h:1640
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
#define ifdebug(n)
Definition: sg.c:47
The structure used to build lists in NewGen.
Definition: newgen_list.h:41