PIPS
compile.c
Go to the documentation of this file.
1 /*
2 
3  $Id: compile.c 23495 2018-10-24 09:19:47Z 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 by Fabien Coelho, May 1993 and later...
28  */
29 
30 #include "defines-local.h"
31 
32 #include "pipsdbm.h"
33 #include "workspace-util.h" // for reset_prettyprinter_common_hook
34 #include "prettyprint.h"
35 #include "resources.h"
36 #include "effects-generic.h"
37 #include "effects-simple.h"
38 #include "effects-convex.h"
39 #include "expressions.h"
40 
41 #define src(name, suf) \
42  strdup(concatenate(WORKSPACE_SRC_SPACE "/", name, suf, NULL))
43 
44 void
46 {
47  const char* name = entity_local_name(module);
48  entity host, node;
49 
51  return;
52 
54  {
57  }
58  else
59  {
60  string tmp;
61 
62  /* HOST and NODE empty routines...
63  */
64  tmp = strdup(concatenate(name, "_", HOST_NAME, NULL));
66  free(tmp);
67 
68  tmp = strdup(concatenate(name, "_", NODE_NAME, NULL));
70  free(tmp);
71 
72  /* Arity and result
73  */
76 
78  {
79  /* then the variable corresponding to the function name
80  * must be created for those new functions. The overloaded
81  * basic is used to be sure that the variable will not be put
82  * in the declarations by the enforced coherency.
83  * ??? this issue could be managed by the coherency function ?
84  */
85  string
86  var_name = concatenate(name, MODULE_SEP_STRING, name, NULL);
87  entity
88  var = gen_find_tabulated(var_name, entity_domain), neh, nen;
89 
90  pips_assert("defined", !entity_undefined_p(var));
91 
92  const char* tmp_name = entity_local_name(host);
93  neh = find_or_create_scalar_entity(tmp_name, tmp_name,
95  tmp_name = entity_local_name(node);
96  nen = find_or_create_scalar_entity(tmp_name, tmp_name,
98  store_new_host_node_variable(neh, nen, var);
99  }
100  }
101 
102  /* to allow the update of the call sites.
103  */
106 }
107 
108 /* kind of a quick hack to remove distributed arguments for the host
109  */
110 static void
112 {
113  type t = entity_type(module);
114  functional f;
115  list /* of parameter */ le = NIL, lp;
116  int len, i, n /* number of next kept parameter */;
117 
118  message_assert("functional", type_functional_p(t));
119  f = type_functional(t);
120  lp = functional_parameters(f);
121  len = gen_length(lp);
122 
123  pips_debug(8, "considering %d arg(s) of %s\n", len, entity_name(module));
124 
125  for (i=1, n=1; i<=len; i++, POP(lp))
126  {
127  entity ent = find_ith_parameter(module, i);
128 
129  if (!entity_undefined_p(ent) && !array_distributed_p(ent))
130  {
131  le = CONS(PARAMETER, PARAMETER(CAR(lp)), le);
132  pips_debug(8, "keeping %d argument %s\n", i, entity_name(ent));
133 
135  n++;
136  }
137  else
138  {
139  if (!entity_undefined_p(ent))
141 
142  pips_debug(8, "dropping %d argument %s\n", i,
143  entity_undefined_p(ent)? "undefined": entity_name(ent));
144  }
145  }
146 
147  lp = functional_parameters(f);
149  gen_free_list(lp);
150 }
151 
152 static entity
154  entity module,
155  entity array,
156  bool upper,
157  int dim,
158  int number)
159 {
160  entity result = argument_bound_entity(module, array, upper, dim);
161 
162  free_storage(entity_storage(result));
163  entity_storage(result) =
165 
166  pips_assert("formal variable", type_variable_p(entity_type(result)));
167 
169 
170  pips_debug(9, "creating %s in %s (arg %d)\n",
171  entity_name(result), entity_name(module), number);
172 
173  return result;
174 }
175 
176 static list
178  list /* of parameter */ lp,
179  entity module,
180  entity array,
181  bool upper,
182  int dim,
183  int formal_number)
184 {
185  (void) create_bound_entity(module, array, upper, dim, formal_number);
186  lp = CONS(PARAMETER,
189  make_mode_reference(), // FI: Used to be value...
191  lp);
192  return lp;
193 }
194 
195 static void
196 add_bound_arguments(entity module) /* for the node */
197 {
198  type t = entity_type(module);
199  functional f;
200  list /* of parameter */ le = NIL, lp;
201  int len, i, next;
202 
203  message_assert("functional", type_functional_p(t));
204  f = type_functional(t);
205  lp = functional_parameters(f);
206  len = gen_length(lp);
207  next = len+1;
208 
209  for(i=1; i<=len; i++)
210  {
211  entity arg = find_ith_parameter(module, i),
212  old = load_old_node(arg);
213  pips_debug(8, "array %s\n", entity_name(old));
214 
215  if (array_distributed_p(old))
216  {
217  int dim, ndim;
218  ndim = NumberOfDimension(arg);
219 
220  for(dim=1; dim<=ndim; dim++)
221  {
222  if (ith_dim_overlapable_p(old, dim))
223  {
225  (le, module, arg, false, dim, next++);
227  (le, module, arg, true, dim, next++);
228  }
229  }
230  }
231  }
232 
233  if (le)
234  {
235  functional_parameters(f) = gen_nconc(lp, le);
236  }
237 }
238 
239 /* both host and node modules are initialized with the same
240  * declarations than the compiled module, but the distributed arrays
241  * declarations... which are not declared in the case of the host_module,
242  * and the declarations of which are modified in the node_module
243  * (call to NewDeclarationsOfDistributedArrays)...
244  */
245 void
247 {
249 
250  ifdebug(3)
251  {
252  text t;
253  debug_on("PRETTYPRINT_DEBUG_LEVEL");
254  pips_debug(3, "old declarations:\n");
256  print_text(stderr, t);
257  free_text(t);
258  debug_off();
259  }
260 
263 
264  /* First, the commons are updated
265  */
266  MAP(ENTITY, e,
267  {
268  type t = entity_type(e);
269 
270  if (type_area_p(t) && !entity_special_area_p(e))
271  {
272  debug(3, "init_host_and_node_entities", /* COMMONS */
273  "considering common %s\n", entity_name(e));
274 
276  add_a_common(e);
277  }
278  },
280 
281  /* Then, the other entities
282  */
283  MAP(ENTITY, e,
284  {
285  type t = entity_type(e);
286 
287  /* parameters are selected. I think they may be either
288  * functional of variable (if declared...) FC 15/09/93
289  */
290 
291  if ((type_variable_p(t)) || /* VARIABLES */
292  ((storage_rom_p(entity_storage(e))) &&
295  else
296  if (type_functional_p(t)) /* PARAMETERS */
297  {
300  }
301  },
303 
305 
308 
309  ifdebug(3)
310  {
311  text t;
312  debug_on("PRETTYPRINT_DEBUG_LEVEL");
313  pips_debug(3,"new declarations - node_module:\n");
316  print_text(stderr, t);
317  free_text(t);
318 
319  pips_debug(3, "new declarations - host_module:\n");
322  print_text(stderr, t);
323  free_text(t);
324  debug_off();
325  }
326 }
327 
328 FILE *
330  string name)
331 {
332  string base = pips_basename(name, NULL);
333  FILE *f = (FILE *) safe_fopen(name, "w");
334  fprintf(f, "!\n! File %s\n! This file has been automatically generated "
335  "by the HPF compiler\n!\n", base);
336  free(base);
337  return f;
338 }
339 
340 void
342  FILE *f,
343  string name)
344 {
345  string base = pips_basename(name, NULL);
346  fprintf(f, "!\n! That is all for %s\n!\n", base);
347  free(base);
348  safe_fclose(f, name);
349 }
350 
351 /* old name of obj while in module now.
352  */
353 static const char*
355  entity module, /* module in which obj appears */
356  entity obj) /* obj */
357 {
358  return module_local_name
360 }
361 
362 /* to be used by the prettyprinter at the head of a file.
363  * inclusion of needed runtime headers.
364  */
365 static string
367  entity m) /* module */
368 {
369  return strdup(concatenate
370  (" implicit none\n"
371  " include \"" GLOBAL_PARAMETERS_H "\"\n"
372  " include \"hpfc_commons.h\"\n"
373  " include \"hpfc_includes.h\"\n"
374  " include \"", old_name(m, m), PARM_SUFFIX "\"\n", NULL));
375 }
376 
377 /* to be used by the prettyprinter when dealing with a common.
378  * inclusion of the parameters and commons...
379  */
380 static string
382  entity module,
383  entity common)
384 {
385  const char* name = module_local_name(common);/* old_name(module, common); */
386  return strdup(concatenate
387  (" include \"", name, PARM_SUFFIX "\"\n"
388  " include \"", name,
389  module==host_module ? HINC_SUFFIX "\"\n" : NINC_SUFFIX "\"\n", NULL));
390 }
391 
392 void
394  FILE* file,
395  entity module,
396  statement stat)
397 {
398  text t;
399  debug_on("PRETTYPRINT_DEBUG_LEVEL");
400 
403 
404  t = text_module(module, stat);
405  print_text(file, t);
406  free_text(t);
407 
410 
411  debug_off();
412 }
413 
414 #define full_name(dir, name) concatenate(dir, "/", name, NULL)
415 
416 void
418 {
419  FILE *host_file, *node_file, *parm_file, *init_file;
420  string host_name, node_name, parm_name, init_name, dir_name;
421  entity node_common, host_common;
422 
423  node_common = load_new_node(common),
424  host_common = load_new_host(common);
425  const char *prefix = module_local_name(common);
427 
428  host_name = src(prefix, HINC_SUFFIX);
429  node_name = src(prefix, NINC_SUFFIX);
430  parm_name = src(prefix, PARM_SUFFIX);
431  init_name = src(prefix, INIT_SUFFIX);
432 
433  host_file = hpfc_fopen(full_name(dir_name, host_name));
434  hpfc_print_common(host_file, host_module, host_common);
435  hpfc_fclose(host_file, host_name);
436 
437  node_file = hpfc_fopen(full_name(dir_name, node_name));
438  hpfc_print_common(node_file, node_module, node_common);
439  hpfc_fclose(node_file, node_name);
440 
441  parm_file = hpfc_fopen(full_name(dir_name, parm_name));
442  create_parameters_h(parm_file, common);
443  hpfc_fclose(parm_file, parm_name);
444 
445  init_file = hpfc_fopen(full_name(dir_name, init_name));
446  create_init_common_param_for_arrays(init_file, common);
447  hpfc_fclose(init_file, init_name);
448 
449  ifdebug(1)
450  {
451  fprintf(stderr, "Result of HPFC for common %s\n", entity_name(common));
452  fprintf(stderr, "-----------------\n");
453 
454  hpfc_print_file(parm_name);
455  hpfc_print_file(init_name);
456  hpfc_print_file(host_name);
457  hpfc_print_file(node_name);
458  }
459 
460  free(parm_name),
461  free(init_name),
462  free(host_name),
463  free(node_name);
464 }
465 
466 /* just copied for the host
467  */
468 void
470 {
471  string file_name, h_name, dir_name, fs, ft;
472 
473  const char *prefix = module_local_name(module);
474  file_name = db_get_file_resource(DBR_SOURCE_FILE, prefix, true);
476  h_name = src(prefix, HOST_SUFFIX);
477 
478  fs = strdup(concatenate(dir_name, "/", file_name, NULL));
479  ft = strdup(concatenate(dir_name, "/", h_name, NULL));
480  safe_copy(fs, ft);
481  free(fs);
482  free(ft);
483 
484  DB_PUT_FILE_RESOURCE(DBR_HPFC_HOST, prefix, h_name);
485  DB_PUT_FILE_RESOURCE(DBR_HPFC_NODE, prefix, NO_FILE);
486  DB_PUT_FILE_RESOURCE(DBR_HPFC_RTINIT, prefix, NO_FILE);
487  DB_PUT_FILE_RESOURCE(DBR_HPFC_PARAMETERS, prefix, NO_FILE);
488 }
489 
490 /* simply copied for both host and node...
491  */
492 void
494 {
495  string file_name, hn_name, dir_name, fs, ft;
496 
497  pips_debug(1, "compiling pure a function (%s)\n", entity_name(module));
498 
499  const char* prefix = module_local_name(module);
501  file_name = db_get_file_resource(DBR_SOURCE_FILE, prefix, true);
502  hn_name = src(prefix, BOTH_SUFFIX);
503 
504  fs = strdup(concatenate(dir_name, "/", file_name, NULL));
505  ft = strdup(concatenate(dir_name, "/", hn_name, NULL));
506  safe_copy(fs, ft);
507  free(fs), free(ft);
508 
509  DB_PUT_FILE_RESOURCE(DBR_HPFC_HOST, prefix, hn_name);
510  DB_PUT_FILE_RESOURCE(DBR_HPFC_NODE, prefix, strdup(hn_name));
511  DB_PUT_FILE_RESOURCE(DBR_HPFC_RTINIT, prefix, NO_FILE);
512  DB_PUT_FILE_RESOURCE(DBR_HPFC_PARAMETERS, prefix, NO_FILE);
513 }
514 
515 void
517  _UNUSED_ statement stat,
518  statement host_stat,
519  statement node_stat)
520 {
521  FILE *host_file, *node_file, *parm_file, *init_file;
523  string host_name, node_name, parm_name, init_name, dir_name;
524 
525  const char *prefix = module_local_name(module);
527 
528  host_name = src(prefix, HOST_SUFFIX);
529  host_file = hpfc_fopen(full_name(dir_name, host_name));
530  hpfc_print_code(host_file, host_module, host_stat);
531  hpfc_fclose(host_file, host_name);
532 
533  node_name = src(prefix, NODE_SUFFIX);
534  node_file = hpfc_fopen(full_name(dir_name, node_name));
535  hpfc_print_code(node_file, node_module, node_stat);
536  hpfc_fclose(node_file, node_name);
537 
538  parm_name = src(prefix, PARM_SUFFIX);
539  parm_file = hpfc_fopen(full_name(dir_name, parm_name));
540  create_parameters_h(parm_file, module);
541  hpfc_fclose(parm_file, parm_name);
542 
543  init_name = src(prefix, INIT_SUFFIX);
544  init_file = hpfc_fopen(full_name(dir_name, init_name));
546  hpfc_fclose(init_file, init_name);
547 
548  ifdebug(1)
549  {
550  fprintf(stderr, "Result of HPFC for module %s:\n",
552  fprintf(stderr, "-----------------\n");
553 
554  hpfc_print_file(parm_name);
555  hpfc_print_file(init_name);
556  hpfc_print_file(host_name);
557  hpfc_print_file(node_name);
558  }
559 
560  DB_PUT_FILE_RESOURCE(DBR_HPFC_PARAMETERS, prefix, parm_name);
561  DB_PUT_FILE_RESOURCE(DBR_HPFC_HOST, prefix, host_name);
562  DB_PUT_FILE_RESOURCE(DBR_HPFC_NODE, prefix, node_name);
563  DB_PUT_FILE_RESOURCE(DBR_HPFC_RTINIT, prefix, init_name);
564 }
565 
566 void
568 {
569  FILE *comm_file, *init_file;
570  string comm, init, dir_name;
571 
573 
574  comm = src(GLOBAL_PARAMETERS_H, "");
575  init = src(GLOBAL_INIT_H, "");
576 
577  comm_file = hpfc_fopen(full_name(dir_name, comm));
578  create_common_parameters_h(comm_file);
579  hpfc_fclose(comm_file, comm);
580 
581  init_file = hpfc_fopen(full_name(dir_name, init));
582  create_init_common_param(init_file);
583  hpfc_fclose(init_file, init);
584 
585  ifdebug(1)
586  {
587  fprintf(stderr, "Results of HPFC for the program\n");
588  fprintf(stderr, "-----------------\n");
589 
590  hpfc_print_file(comm);
592  }
593 
594  free(comm);
595  free(init);
596 }
597 
598 /* Compiler call, obsole. left here for allowing linking
599  */
600 void
601 hpfcompile (const char* module_name)
602 {
603  debug_on("HPFC_DEBUG_LEVEL");
604  pips_debug(1, "module: %s\n", module_name);
605  pips_internal_error("obsolete");
606  debug_off();
607 }
608 
609 
610 /******************************************************* HPFC ATOMIZATION */
611 
612 /* drivers for atomize_as_required in transformations
613  */
615 {
616  reference r;
617  if (!expression_reference_p(e)) return(false);
621 }
622 
623 /* break expression e in reference r if ...
624  */
626 {
630 }
631 
633 {
635  AddEntityToCurrentModule(new_ent);
636  return new_ent;
637 }
638 
639 
640 /********************* EXTRACT NON VARIANT TERMS ON DISTRIBUTED DIMENSIONS */
641 
643 
645 {
646  error_reset_c_stmt_stack();
647 }
648 
649 /* true if no written effect on any variables of e in loe
650  */
652  expression e,
653  list /* of effect */ loe,
654  list /* of entity */ le)
655 {
656  list /* of effect */ l = proper_effects_of_expression(e);
657 
658  ifdebug(3) {
659  pips_debug(3, "considering expression:");
660  print_expression(e);
661  }
662 
663  FOREACH(EFFECT, ef1, l) {
664  FOREACH(EFFECT, ef2, loe) {
665  if(store_effect_p(ef1) && store_effect_p(ef2)) {
666  entity v = effect_variable(ef1);
667  if ((v==effect_variable(ef2) && effect_write_p(ef2)) ||
668  gen_in_list_p(v, le))
669  {
670  gen_free_list(l);
671  pips_debug(3, "variant\n");
672  return false;
673  }
674  }
675  }
676  }
677 
678  gen_free_list(l);
679  pips_debug(3, "invariant\n");
680  return true;
681 }
682 
683 /* substitute all occurences of expression e in statement s by variable v
684  */
685 static entity subs_v;
688 
689 /* returns if vin is in vref
690  */
691 static bool vect_in_p(Pvecteur vin, Pvecteur vref)
692 {
693  Pvecteur v;
694 
695  for (v=vin; v; v=v->succ)
696  {
697  Variable x = vecteur_var(v);
698  if (x)
699  {
700  if (value_ne(vecteur_val(v),vect_coeff(x, vref)))
701  return false;
702  }
703  }
704 
705  return true;
706 }
707 
708 
710 {
711  /* does sg about the linearization of the expression
712  */
713  if (subs_pv && expression_linear_p(e))
714  {
717  if (vect_in_p(subs_pv, v))
718  {
721  vect_rm(v);
723  }
724  }
725 
726  if (expression_equal_p(e, subs_e))
727  {
728  /* ??? memory leak, but how to deal with effect references? */
729  expression_syntax(e) =
735  return false;
736  }
737  return true;
738 }
740 {
741  instruction i;
742 
743  ifdebug(3) {
744  pips_debug(3, "variable %s substituted for\n", entity_name(v));
745  print_expression(e);
746  }
747 
748  subs_v = v;
749  subs_e = copy_expression(e);
750 
753  (Pvecteur) NULL;
754 
756 
758 
760  (make_loop(v,
762  subs_e, /* the copy is reused! */
763  int_to_expression(1)),
767  NIL));
768 
769  statement_instruction(s) = i;
770 }
771 
772 static bool loop_flt(loop l)
773 {
774  statement s;
775  list /* of effect */ loce;
776  list /* of entity */ lsubs = NIL;
777 
779  return true;
780 
781  s = c_stmt_head();
783 
784  FOREACH(EFFECT, e, loce)
785  {
786  if(store_effect_p(e)) {
788  entity v = reference_variable(r);
789 
790  if (array_distributed_p(v) && effect_write_p(e))
791  {
792  int dim = 0;
793  int p;
794  entity n;
795 
796  pips_debug(3, "considering reference to %s[%zd]\n",
798 
800  {
801  dim++;
802  ifdebug(3) {
803  pips_debug(3, "considering on dim. %d:\n", dim);
805  }
806  if (ith_dim_distributed_p(v, dim, &p) &&
807  invariant_expression_p(x, loce, lsubs) &&
809  {
812  substitute_and_create(s, n, x);
813  lsubs = CONS(ENTITY, n, lsubs);
814  }
815  }
816  }
817  }
818  }
819 
820  return false;
821 }
822 
823 /* transformation: DOALL I,J ... A(I,J,e) -> DOALL E=e,e,1 ,I,J A(I,J,E)
824  */
825 static void
827  statement s)
828 {
829  DEBUG_STAT(2, "in", s);
830 
831  make_c_stmt_stack();
833  statement_domain, c_stmt_filter, c_stmt_rewrite,
835  NULL);
836  free_c_stmt_stack();
837 
838  DEBUG_STAT(2, "out", s);
839 }
840 
842 {
843  return ref_to_dist_array_p(t);
844 }
845 
846 /*
847  */
849 {
853  hpfc_decision, /* reference test */
854  (bool(*)(call,expression)) gen_false2, /* function call test */
855  (bool(*)(test,expression)) test_atomization,/* test condition test */
856  (bool(*)(range,expression)) gen_false2, /* range test */
857  (bool(*)(whileloop,expression)) gen_false2, /* whileloop test */
859 }
860 
861 /*************************************************************** COMMONS */
862 
863 /* To manage the common entities, I decided arbitrarilly that all
864  * commons will have to be declared exactly the same way (name and so),
865  * so I can safely unify the entities among the modules.
866  * The rational for this stupid ugly transformation is that it is much
867  * easier to manage the common overlaps for instance if they are
868  * simply linked to the same entity.
869  *
870  * ??? very ugly, indeed.
871  */
872 
873 GENERIC_CURRENT_MAPPING(update_common, entity, entity)
874 
876 {
877  entity var = reference_variable(r),
878  new_var = load_entity_update_common(var);
879 
880  pips_debug(7, "%s to %s\n", entity_name(var),
881  entity_undefined_p(new_var) ? "undefined" : entity_name(new_var));
882 
883  if (!entity_undefined_p(new_var))
884  reference_variable(r) = new_var;
885 }
886 
887 static void update_loop_rewrite(l)
888 loop l;
889 {
890  entity var = loop_index(l),
891  new_var = load_entity_update_common(var);
892 
893  if (!entity_undefined_p(new_var))
894  loop_index(l) = new_var;
895 }
896 
897 static void debug_ref_rwt(reference r)
898 {
899  entity var = reference_variable(r);
900 
901  if (entity_in_common_p(var))
902  fprintf(stderr, "[debug_ref_rwt] reference to %s\n",
903  entity_name(var));
904 }
905 
907 {
909 }
910 
912 {
913  gen_multi_recurse(obj,
916  NULL);
917 
919 }
920 
922 {
923 
924  STATEMENT_EFFECTS_MAP(stat, effs,
925  {
926  list lef = effects_effects(effs);
927 
928  pips_debug(3, "statement %p (%zu effects)\n",
929  stat, gen_length((list) lef));
930 
931  // FI: Let's hope the rw effects do not have to be
932  // filtered to keep only the store effects...
934  (list) lef);
935  },
936  get_rw_effects());
937 }
938 
939 void
941  entity module,
942  statement stat)
943 {
944  list ldecl = code_declarations(entity_code(module)), lnewdecl = NIL, ltmp;
945  entity common, new_e;
946 
947  /* the new entities for the common variables are created and
948  * inserted in the common. The declarations are updated.
949  */
950  MAP(ENTITY, e,
951  {
952  if (entity_in_common_p(e))
953  {
954  common = ram_section(storage_ram(entity_storage(e)));
955  new_e = AddEntityToModule(e, common);
956  ltmp = area_layout(type_area(entity_type(common)));
957 
958  if (gen_find_eq(new_e, ltmp)==entity_undefined)
959  gen_insert_after(new_e, e, ltmp);
960 
961  lnewdecl = CONS(ENTITY, new_e, lnewdecl);
962  store_entity_update_common(e, new_e);
963 
964  pips_debug(8, "module %s: %s -> %s\n",
966  }
967  else
968  lnewdecl = CONS(ENTITY, e, lnewdecl);
969  },
970  ldecl);
971 
972  gen_free_list(ldecl);
973  code_declarations(entity_code(module)) = lnewdecl;
974 
975  /* the references within the program are updated with the new entities
976  */
978 }
979 
980 /* That is all
981  */
static void node(FILE *out, string name)
Build for module name a node and link to its successors.
Definition: graph.c:56
static string current_module
Definition: message.c:63
void free_normalized(normalized p)
Definition: ri.c:1407
execution make_execution(enum execution_utype tag, void *val)
Definition: ri.c:838
normalized make_normalized(enum normalized_utype tag, void *val)
Definition: ri.c:1447
parameter make_parameter(type a1, mode a2, dummy a3)
Definition: ri.c:1495
loop make_loop(entity a1, range a2, statement a3, entity a4, execution a5, list a6)
Definition: ri.c:1301
language make_language_fortran(void)
Definition: ri.c:1250
type make_type_variable(variable _field_)
Definition: ri.c:2715
mode make_mode_reference(void)
Definition: ri.c:1356
basic copy_basic(basic p)
BASIC.
Definition: ri.c:104
storage make_storage(enum storage_utype tag, void *val)
Definition: ri.c:2273
expression copy_expression(expression p)
EXPRESSION.
Definition: ri.c:850
reference make_reference(entity a1, list a2)
Definition: ri.c:2083
variable make_variable(basic a1, list a2, list a3)
Definition: ri.c:2895
void free_storage(storage p)
Definition: ri.c:2231
syntax make_syntax(enum syntax_utype tag, void *val)
Definition: ri.c:2491
dummy make_dummy_unknown(void)
Definition: ri.c:617
bool entity_consistent_p(entity p)
Definition: ri.c:2530
range make_range(expression a1, expression a2, expression a3)
Definition: ri.c:2041
formal make_formal(entity a1, intptr_t a2)
Definition: ri.c:1067
void free_text(text p)
Definition: text.c:74
#define value_ne(v1, v2)
#define VALUE_ONE
bdt base
Current expression.
Definition: bdt_read_paf.c:100
entity host_module
HPFC - Fabien Coelho, May 1993 and later...
Definition: compiler.c:47
entity node_module
Definition: compiler.c:47
#define newgen_Pvecteur(p)
Definition: compsec.h:26
void hpfc_print_file(string file_name)
Definition: debug-util.c:169
void hpfc_print_common(FILE *file, entity module, entity common)
Definition: debug-util.c:154
void reset_prettyprinter_common_hook(void)
text text_declaration(entity module)
exported for hpfc.
effects load_cumulated_references(statement)
statement_effects get_rw_effects(void)
list proper_effects_of_expression(expression)
#define effect_any_reference(e)
FI: cannot be used as a left hand side.
#define effect_write_p(eff)
#define effect_variable(e)
For COMPATIBILITY purpose only - DO NOT USE anymore.
bool store_effect_p(effect)
Definition: effects.c:1062
#define STATEMENT_EFFECTS_MAP(k, v, c, f)
Definition: effects.h:1057
#define effects_effects(x)
Definition: effects.h:710
#define EFFECT(x)
EFFECT.
Definition: effects.h:608
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
void atomize_as_required(statement, bool(*)(reference, expression), bool(*)(call, expression), bool(*)(test, expression), bool(*)(range, expression), bool(*)(whileloop, expression), entity(*)(entity, basic))
void safe_copy(char *source, char *target)
Definition: file.c:706
FILE * safe_fopen(const char *filename, const char *what)
Definition: file.c:67
int safe_fclose(FILE *stream, const char *filename)
Definition: file.c:77
char * pips_basename(char *fullpath, char *suffix)
Definition: file.c:822
#define gen_recurse(start, domain_number, flt, rwt)
Definition: genC.h:283
void free(void *)
statement instruction_to_statement(instruction)
Build a statement from a give instruction.
Definition: statement.c:597
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.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
bool gen_false2(__attribute__((unused)) gen_chunk *u1, __attribute__((unused)) void *u2)
Definition: genClib.c:2801
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
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
#define POP(l)
Modify a list pointer to point on the next element of the list.
Definition: newgen_list.h:59
#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 FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
Definition: newgen_list.h:179
void * gen_find_eq(const void *item, const list seq)
Definition: list.c:422
#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
void gen_insert_after(const void *no, const void *o, list l)
Definition: list.c:223
#define DB_PUT_FILE_RESOURCE
Put a file resource into the current workspace database.
Definition: pipsdbm-local.h:85
void store_new_node_variable(entity new, entity old)
void store_new_host_node_variable(entity neh, entity nen, entity old)
void store_new_host_variable(entity new, entity old)
void AddEntityToHostAndNodeModules(entity e)
AddEntityToHostAndNodeModules.
Definition: hpfc-util.c:298
void AddCommonToHostAndNodeModules(entity common)
Definition: hpfc-util.c:371
bool ith_dim_distributed_p(entity array, int i, int *pprocdim)
whether a dimension is distributed or not.
Definition: hpfc-util.c:160
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 make_host_and_node_modules(entity module)
compile.c
Definition: compile.c:45
static expression subs_e
Definition: compile.c:686
static Pvecteur subs_pv
Definition: compile.c:687
#define src(name, suf)
HPFC by Fabien Coelho, May 1993 and later...
Definition: compile.c:41
void NormalizeCodeForHpfc(statement s)
Definition: compile.c:848
#define full_name(dir, name)
Definition: compile.c:414
static void drop_distributed_arguments(entity module)
kind of a quick hack to remove distributed arguments for the host
Definition: compile.c:111
static bool vect_in_p(Pvecteur vin, Pvecteur vref)
returns if vin is in vref
Definition: compile.c:691
static void extract_distributed_non_constant_terms(statement s)
transformation: DOALL I,J ...
Definition: compile.c:826
void NormalizeCommonVariables(entity module, statement stat)
Definition: compile.c:940
void put_generated_resources_for_common(entity common)
Definition: compile.c:417
void debug_print_referenced_entities(void *obj)
Definition: compile.c:906
static entity create_bound_entity(entity module, entity array, bool upper, int dim, int number)
Definition: compile.c:153
static bool invariant_expression_p(expression e, list loe, list le)
true if no written effect on any variables of e in loe
Definition: compile.c:651
void hpfc_print_code(FILE *file, entity module, statement stat)
Definition: compile.c:393
void update_common_references_in_regions()
Definition: compile.c:921
void init_host_and_node_entities()
both host and node modules are initialized with the same declarations than the compiled module,...
Definition: compile.c:246
static void add_bound_arguments(entity module)
for the node
Definition: compile.c:196
static bool expression_simple_nondist_p(expression e)
drivers for atomize_as_required in transformations
Definition: compile.c:614
static bool loop_flt(loop l)
Definition: compile.c:772
void put_generated_resources_for_program(_UNUSED_ string program_name)
Definition: compile.c:567
static bool expression_flt(expression e)
Definition: compile.c:709
static bool hpfc_decision(reference r, expression e)
break expression e in reference r if ...
Definition: compile.c:625
static bool test_atomization(test t, _UNUSED_ expression e)
Definition: compile.c:841
void hpfc_compile_error_handler()
Definition: compile.c:644
void compile_a_special_io_function(entity module)
just copied for the host
Definition: compile.c:469
entity hpfc_new_variable(entity module, basic b)
Definition: compile.c:632
void put_generated_resources_for_module(_UNUSED_ statement stat, statement host_stat, statement node_stat)
Definition: compile.c:516
static string hpfc_head_hook(entity m)
to be used by the prettyprinter at the head of a file.
Definition: compile.c:366
FILE * hpfc_fopen(string name)
Definition: compile.c:329
static entity subs_v
substitute all occurences of expression e in statement s by variable v
Definition: compile.c:685
void hpfcompile(const char *module_name)
Compiler call, obsole.
Definition: compile.c:601
static void substitute_and_create(statement s, entity v, expression e)
Definition: compile.c:739
static void debug_ref_rwt(reference r)
Definition: compile.c:897
static void update_loop_rewrite(loop l)
Definition: compile.c:887
static list add_one_bound_argument(list lp, entity module, entity array, bool upper, int dim, int formal_number)
Definition: compile.c:177
void compile_a_pure_function(entity module)
simply copied for both host and node...
Definition: compile.c:493
void hpfc_fclose(FILE *f, string name)
Definition: compile.c:341
static string hpfc_common_hook(entity module, entity common)
to be used by the prettyprinter when dealing with a common.
Definition: compile.c:381
void update_common_references_in_obj(void *obj)
Definition: compile.c:911
static void update_common_rewrite(reference r)
To manage the common entities, I decided arbitrarilly that all commons will have to be declared exact...
Definition: compile.c:875
static const char * old_name(entity module, entity obj)
old name of obj while in module now.
Definition: compile.c:354
void NewDeclarationsOfDistributedArrays()
this procedure generate the new declarations of every distributed arrays of the program,...
Definition: declarations.c:676
#define NINC_SUFFIX
#define PARM_SUFFIX
#define HOST_SUFFIX
File suffixes.
#define HINC_SUFFIX
#define GLOBAL_INIT_H
#define GLOBAL_PARAMETERS_H
file names to be generated
#define NO_FILE
fake resources...
#define NODE_NAME
#define DEBUG_STAT(D, W, S)
#define NODE_SUFFIX
#define BOTH_SUFFIX
#define update_functional_as_model(e, model)
Definition: defines-local.h:98
#define HOST_NAME
Constants.
#define INIT_SUFFIX
void add_a_common(entity c)
HPFC module by Fabien COELHO.
Definition: hpfc.c:48
void store_entity_update_common(entity, entity)
entity load_entity_update_common(entity)
entity load_old_node(entity)
entity load_new_node(entity)
void create_init_common_param_for_arrays(FILE *, entity)
Definition: inits.c:158
void create_parameters_h(FILE *, entity)
create_parameters_h
Definition: inits.c:65
entity argument_bound_entity(entity, entity, bool, int)
Definition: run-time.c:499
void create_init_common_param(FILE *)
create_init_common_param (templates and modules)
Definition: inits.c:511
void create_common_parameters_h(FILE *)
inits.c
Definition: inits.c:36
bool bound_new_node_p(entity)
entity load_new_host(entity)
entity load_old_host(entity)
bool array_distributed_p(entity)
#define debug_on(env)
Definition: misc-local.h:157
#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 debug_off()
Definition: misc-local.h:160
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189
#define MODULE_SEP_STRING
Definition: naming-local.h:30
#define message_assert(msg, ex)
Definition: newgen_assert.h:47
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
#define GENERIC_CURRENT_MAPPING(name, result, type)
#define DEFINE_LOCAL_STACK(name, type)
void * gen_find_tabulated(const char *, int)
Definition: tabulated.c:218
#define UU
Definition: newgen_types.h:98
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
void normalize_all_expressions_of(void *obj)
Definition: normalize.c:668
static char * module
Definition: pips.c:74
#define db_get_file_resource
string db_get_current_workspace_directory(void)
Definition: workspace.c:96
void print_expression(expression e)
no file descriptor is passed to make is easier to use in a debugging stage.
Definition: expression.c:58
void reset_prettyprinter_head_hook()
Definition: misc.c:3964
void set_prettyprinter_head_hook(string(*f)(entity))
Definition: misc.c:3963
text text_module(entity, statement)
void set_prettyprinter_common_hook(string(*)(entity, entity))
declarations2.c
static const char * prefix
#define entity_declarations(e)
MISC: newgen shorthands.
#define loop_to_instruction
bool entity_special_area_p(entity e)
Definition: area.c:154
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
code entity_code(entity e)
Definition: entity.c:1098
entity AddEntityToModule(entity e, entity module)
!!! caution, it may not be a module, but a common...
Definition: entity.c:3171
entity make_empty_subroutine(const char *name, language l)
Definition: entity.c:268
bool entity_main_module_p(entity e)
Definition: entity.c:700
bool entity_function_p(entity e)
Definition: entity.c:724
entity entity_empty_label(void)
Definition: entity.c:1105
static int init
Maximal value set for Fortran 77.
Definition: entity.c:320
const char * module_local_name(entity e)
Returns the module local user name.
Definition: entity.c:582
bool entity_in_common_p(entity e)
Definition: entity.c:1082
bool expression_linear_p(expression e)
returns if e is already normalized and linear.
Definition: eval.c:951
bool expression_integer_constant_p(expression e)
Definition: expression.c:2417
bool expression_equal_p(expression e1, expression e2)
Syntactic equality e1==e2.
Definition: expression.c:1347
expression int_to_expression(_int i)
transform an int into an expression and generate the corresponding entity if necessary; it is not cle...
Definition: expression.c:1188
bool expression_reference_p(expression e)
Test if an expression is a reference.
Definition: expression.c:528
basic MakeBasic(int)
END_EOLE.
Definition: type.c:128
entity make_new_scalar_variable(entity, basic)
Definition: variable.c:741
void AddEntityToDeclarations(entity, entity)
END_EOLE.
Definition: variable.c:108
void AddEntityToCurrentModule(entity)
Add a variable entity to the current module declarations.
Definition: variable.c:260
int NumberOfDimension(entity)
Definition: size.c:588
entity find_or_create_scalar_entity(const char *, const char *, tag)
Looks for an entity which should be a scalar of the specified basic.
Definition: variable.c:1025
entity find_ith_parameter(entity, int)
Definition: util.c:93
#define type_functional_p(x)
Definition: ri.h:2950
#define formal_offset(x)
Definition: ri.h:1408
#define normalized_linear_(x)
Definition: ri.h:1780
@ is_basic_overloaded
Definition: ri.h:574
@ is_basic_int
Definition: ri.h:571
#define expression_domain
newgen_execution_domain_defined
Definition: ri.h:154
#define loop_execution(x)
Definition: ri.h:1648
#define syntax_reference(x)
Definition: ri.h:2730
#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 type_functional(x)
Definition: ri.h:2952
#define entity_storage(x)
Definition: ri.h:2794
#define statement_domain
newgen_sizeofexpression_domain_defined
Definition: ri.h:362
#define code_declarations(x)
Definition: ri.h:784
@ is_syntax_reference
Definition: ri.h:2691
#define ram_section(x)
Definition: ri.h:2249
#define storage_formal(x)
Definition: ri.h:2524
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
@ is_storage_formal
Definition: ri.h:2493
#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 execution_sequential_p(x)
Definition: ri.h:1208
#define value_symbolic_p(x)
Definition: ri.h:3068
#define entity_name(x)
Definition: ri.h:2790
#define area_layout(x)
Definition: ri.h:546
#define expression_normalized(x)
Definition: ri.h:1249
#define functional_parameters(x)
Definition: ri.h:1442
#define PARAMETER(x)
PARAMETER.
Definition: ri.h:1788
#define reference_indices(x)
Definition: ri.h:2328
#define type_area(x)
Definition: ri.h:2946
#define statement_instruction(x)
Definition: ri.h:2458
#define storage_ram(x)
Definition: ri.h:2521
#define type_area_p(x)
Definition: ri.h:2944
#define storage_rom_p(x)
Definition: ri.h:2525
@ is_execution_parallel
Definition: ri.h:1190
#define entity_type(x)
Definition: ri.h:2792
#define normalized_linear(x)
Definition: ri.h:1781
#define expression_syntax(x)
Definition: ri.h:1247
#define type_variable_p(x)
Definition: ri.h:2947
#define entity_domain
newgen_syntax_domain_defined
Definition: ri.h:410
#define loop_index(x)
Definition: ri.h:1640
@ is_normalized_linear
Definition: ri.h:1760
#define entity_initial(x)
Definition: ri.h:2796
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
char * strdup()
#define ifdebug(n)
Definition: sg.c:47
static entity array
static char * x
Definition: split_file.c:159
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
struct Svecteur * succ
Definition: vecteur-local.h:92
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
void print_text(FILE *fd, text t)
Definition: print.c:195
static string file_name
#define vecteur_val(v)
#define vecteur_var(v)
struct Svecteur * Pvecteur
void * Variable
arithmetique is a requirement for vecteur, but I do not want to inforce it in all pips files....
Definition: vecteur-local.h:60
Pvecteur vect_dup(Pvecteur v_in)
Pvecteur vect_dup(Pvecteur v_in): duplication du vecteur v_in; allocation de et copie dans v_out;.
Definition: alloc.c:51
Pvecteur vect_new(Variable var, Value coeff)
Pvecteur vect_new(Variable var,Value coeff): allocation d'un vecteur colineaire au vecteur de base va...
Definition: alloc.c:110
void vect_rm(Pvecteur v)
void vect_rm(Pvecteur v): desallocation des couples de v;
Definition: alloc.c:78
Pvecteur vect_substract(Pvecteur v1, Pvecteur v2)
Pvecteur vect_substract(Pvecteur v1, Pvecteur v2): allocation d'un vecteur v dont la valeur est la di...
Definition: binaires.c:75
void vect_add_elem(Pvecteur *pvect, Variable var, Value val)
void vect_add_elem(Pvecteur * pvect, Variable var, Value val): addition d'un vecteur colineaire au ve...
Definition: unaires.c:72
Value vect_coeff(Variable var, Pvecteur vect)
Variable vect_coeff(Variable var, Pvecteur vect): coefficient de coordonnee var du vecteur vect —> So...
Definition: unaires.c:228