PIPS
comEngine_HRE_distribute.c
Go to the documentation of this file.
1 /*
2 
3  $Id: comEngine_HRE_distribute.c 23065 2016-03-02 09:05:50Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of PIPS.
8 
9  PIPS is free software: you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 #ifdef HAVE_CONFIG_H
25  #include "pips_config.h"
26 #endif
27 /*
28 This file contains the functions to generate the HRE code using several
29 processes on the HRE
30  */
31 
32 #include <stdio.h>
33 #include <ctype.h>
34 
35 #include "genC.h"
36 #include "linear.h"
37 #include "ri.h"
38 #include "effects.h"
39 
40 #include "resources.h"
41 
42 #include "misc.h"
43 #include "ri-util.h"
44 #include "prettyprint.h"
45 #include "effects-util.h"
46 
47 #include "text-util.h"
48 
49 #include "ray_dte.h"
50 #include "sommet.h"
51 #include "sg.h"
52 #include "polyedre.h"
53 
54 #include "phrase_tools.h"
55 
56 #include "effects-generic.h"
57 #include "effects-simple.h"
58 #include "effects-convex.h"
59 
60 #include "phrase_distribution.h"
61 #include "comEngine.h"
63 #include "phrase.h"
64 
65 // gOldIndToNewInd associated a loop index of
66 // input code to a loop index of the new one
68 
69 // gIsIndex is used to store the fact that
70 // an index has to be incremented
72 
73 static list gCurStats = NIL;
74 static list glCurRep = NIL;
75 
76 // These are global variable to the names we want to
77 // give to the created modules
78 static const char* g_new_module_name = NULL;
79 static const char* g_module_name = NULL;
80 
81 // This variable holds the number of
82 // if we have entered at a given point of
83 // the algorithm
84 static int gIfCount = 0;
85 
86 // This list holds the enclosing loops at a given point of
87 // the algorithm
88 static list glCurLoop = NIL;
89 
91 
92 // These lists hold the read or write statements that
93 // make to read values from the fifos
94 static list glReadStats = NIL;
96 
97 static statement HRE_distribute_stat(statement stat, bool calledFromLoop);
98 
99 /*
100 This function creates the private variables of the new module. Then,
101 it store the association between the created variable and the old reference
102 holded by lRef ingRefToHREVar
103  */
105 {
106  MAP(REFERENCE, curRef,
107  {
108  bool alreadyDone = false;
109  reference refFound = reference_undefined;
110 
111  HASH_MAP(ref1, var1,
112  {
113  if(reference_equal_p(curRef, ref1))
114  {
115  alreadyDone = true;
116  refFound = ref1;
117  break;
118  }
119  }, gRefToHREVar);
120 
121  if(!alreadyDone)
122  {
123  //printf("it\n");
124  //print_reference(curRef);printf("\n");
125 
126  string name =
128 
129  basic bas = basic_of_reference((reference)curRef);
130 
131  pips_assert("bas != basic_undefined", bas != basic_undefined);
132 
133  //entity new_ent = make_new_scalar_entity(name, copy_basic(bas));
134 
137  bas);
138  AddEntityToCurrentModule(new_ent);
139 
140  //printf("%s\n", entity_user_name(new_ent));
141 
143  {
144  hash_put(gRefToHREVar, curRef, new_ent);
145  }
146  }
147  else
148  {
149  //printf("it found\n");
150  //print_reference(curRef);printf("\n");
151 
152  entity scalEnt = hash_get(gRefToHREVar, refFound);
153 
155  {
156  hash_put(gRefToHREVar, curRef, scalEnt);
157  }
158  }
159 
160  }, lRef);
161 
162 }
163 
164 /*
165 This function creates a private entity whose prefix is the local name
166 of ind
167  */
168 static entity find_or_create_newInd(entity ind, bool bIsInd)
169 {
170  entity new_ent = entity_undefined;
171 
172  // If the entity was already created, then just return the existing
173  // entity
174  new_ent = hash_get(gOldIndToNewInd, ind);
175 
176  if(new_ent != HASH_UNDEFINED_VALUE)
177  {
178  return new_ent;
179  }
180 
181  // Create a new entity
182  new_ent =
185  copy_basic(entity_basic(ind)));
186  AddEntityToCurrentModule(new_ent);
187 
188  statement loopStat = STATEMENT(CAR(glCurLoop));
189 
190  list lUnSupportedRef = hash_get(gLoopToUnSupRef, loopStat);
191 
192  pips_assert("lUnSupportedRef != HASH_UNDEFINED_VALUE",
193  lUnSupportedRef != HASH_UNDEFINED_VALUE);
194 
195  // If the entity created is actually the index of
196  // the new loop, then do gNewInd = new_ent
197  if((loop_index(statement_loop(loopStat)) == ind) &&
198  (lUnSupportedRef == NIL))
199  {
200  gNewInd = new_ent;
201  }
202 
203  // Memorize the creation of the entity
204  hash_put(gOldIndToNewInd, ind, new_ent);
205 
206  // If the entity is an index, then memorize it with gIsIndex
207  if(bIsInd)
208  {
209  hash_put(gIsIndex, new_ent, (void *)true);
210  }
211 
212  return new_ent;
213 }
214 
215 /*
216 Get the expression that defines the index of the fifo that has to be
217 read or written
218  */
220  bool * innerInd)
221 {
222  entity ind = entity_undefined;
223 
224  HASH_MAP(ref1, ind1,
225  {
226  if(reference_equal_p(curRef, ref1))
227  {
228  ind = ind1;
229  break;
230  }
231  }, ht);
232 
233  expression indExp;
234 
235  // If the index ind is undefined then let read from the
236  // beginning of the fifo
237  if(ind == entity_undefined)
238  {
239  indExp = int_to_expression(0);
240  }
241  else
242  {
244  {
245  *innerInd = true;
246  }
247 
248  entity new_ent = find_or_create_newInd(ind, true);
249 
250  indExp = entity_to_expression(new_ent);
251  }
252 
253  return indExp;
254 }
255 
256 /*
257 Get the expression that defines the fifo that has to be
258 read or written
259  */
261  hash_table ht)
262 {
263  entity ind = entity_undefined;
264 
265  HASH_MAP(ref1, ind1,
266  {
267  if(reference_equal_p(curRef, ref1))
268  {
269  ind = ind1;
270  break;
271  }
272  }, ht);
273 
274  expression fifoExp;
275 
276  if(ind == entity_undefined)
277  {
278  fifoExp = buffExp;
279  }
280  else
281  {
282  entity new_ent = find_or_create_newInd(ind, false);
283 
285  buffExp,
286  entity_to_expression(new_ent),
287  NULL);
288 
289  fifoExp =
291  addArg));
292  }
293 
294  return fifoExp;
295 }
296 
298  expression fifoExp,
299  expression indExp,
300  expression hreBuffExp)
301 {
302  statement newStat;
303 
304  if(!strcmp(name, READ_FIFO))
305  {
307  fifoExp,
308  indExp,
309  NULL);
310 
312  arg));
313 
314  newStat = make_assign_statement(hreBuffExp, rExp);
315  }
316  else
317  {
319  fifoExp,
320  indExp,
321  hreBuffExp,
322  NULL);
323 
324  newStat = call_to_statement(
326  arg));
327  }
328 
329  return newStat;
330 }
331 
332 /*
333 This function generates the statement that read or write the value
334 (corresponding to the old reference curRef) in the fifo
335 */
337 {
338  statement newStat = statement_undefined;
339 
340  string name = NULL;
341 
342  expression buffExp = get_fifo_from_ref(curRef);
343 
344  //printf("generate_fifo_stat2\n");
345  //print_reference(curRef);printf("\n");
346 
347  if(buffExp == expression_undefined)
348  {
349  return statement_undefined;
350  }
351 
352  bool innerInd = false;
353 
354  expression indExp = get_indExp_from_ref(curRef, gRefToInd, &innerInd);
355 
356  expression fifoExp = get_fifoExp_from_ref(curRef, buffExp, gRefToToggle);
357 
358  entity hreBuffEnt = get_HRE_buff_ent_from_ref(curRef);
359 
360  pips_assert("hreBuffEnt != entity_undefined",
361  hreBuffEnt != entity_undefined);
362 
363  if(bRead)
364  {
365  name = strdup(READ_FIFO);
366  }
367  else
368  {
369  name = strdup(WRITE_FIFO);
370  }
371 
372  newStat = make_read_write_fifo_stat(name, fifoExp, indExp,
373  entity_to_expression(hreBuffEnt));
374 
375  if(!innerInd)
376  {
377  if(bRead)
378  {
379  glReadStats = CONS(STATEMENT, newStat, glReadStats);
380  }
381  else
382  {
384  }
385 
386  return statement_undefined;
387  }
388 
389  return newStat;
390 }
391 
392 /*
393 This function generates the statement that read or write the value
394 (corresponding to the old entity oldInd) in the fifo
395 */
396 statement generate_ind_fifo_stat2(entity oldInd, entity newInd, bool bRead)
397 {
398  statement newStat = statement_undefined;
399 
400  string name = NULL;
401 
402  intptr_t indNum = (intptr_t)hash_get(gIndToNum, oldInd);
403 
404  pips_assert("indNum != HASH_UNDEFINED_VALUE",
405  indNum != (intptr_t)HASH_UNDEFINED_VALUE);
406 
407  if(bRead)
408  {
409  name = strdup(READ_FIFO);
410  }
411  else
412  {
413  name = strdup(WRITE_FIFO);
414  }
415 
416  intptr_t fifoNum = (intptr_t)hash_get(gEntToHREFifo, oldInd);
417 
418  pips_assert("fifoNum != HASH_UNDEFINED_VALUE",
419  fifoNum != (intptr_t)HASH_UNDEFINED_VALUE);
420 
421  newStat =
423  int_to_expression(fifoNum),
424  int_to_expression(indNum),
425  entity_to_expression(newInd));
426  return newStat;
427 }
428 
429 /*
430 This function generates the read or write statements
431  */
433  list * lReadStats, list * lWriteStats)
434 {
435  list lReadDone = NIL;
436  list lWriteDone = NIL;
437 
438  MAP(REFERENCE, curRef,
439  {
440  string effAction = hash_get(gRefToEff, curRef);
441 
442  pips_assert("effAction != HASH_UNDEFINED_VALUE",
443  effAction != HASH_UNDEFINED_VALUE);
444 
445  //printf("fifo ref %d\n", (int)curRef);
446  //print_reference(curRef);printf("\n");
447 
448  if(!strcmp(effAction, R_EFFECT))
449  {
450  bool alreadyDone = false;
451 
452  MAP(REFERENCE, doneRef,
453  {
454  if(reference_equal_p(curRef, doneRef))
455  {
456  alreadyDone = true;
457  break;
458  }
459  }, lReadDone);
460 
461  if(!alreadyDone)
462  {
463  //printf("read eff\n");
464 
465  lReadDone = gen_nconc(lReadDone, CONS(REFERENCE, curRef, NIL));
466 
467  statement readStat = generate_fifo_stat2(curRef, true);
468 
469  if(readStat == statement_undefined)
470  {
471  continue;
472  }
473 
474  *lReadStats = gen_nconc(*lReadStats, CONS(STATEMENT, readStat, NIL));
475  //print_statement(readStat);
476  }
477  }
478  else
479  {
480  bool alreadyDone = false;
481 
482  MAP(REFERENCE, doneRef,
483  {
484  if(reference_equal_p(curRef, doneRef))
485  {
486  alreadyDone = true;
487  break;
488  }
489  }, lWriteDone);
490 
491  if(!alreadyDone)
492  {
493  //printf("write eff\n");
494 
495  lWriteDone = gen_nconc(lWriteDone, CONS(REFERENCE, curRef, NIL));
496 
497  statement writeStat = generate_fifo_stat2(curRef, false);
498 
499  if(writeStat == statement_undefined)
500  {
501  continue;
502  }
503 
504  *lWriteStats = gen_nconc(*lWriteStats, CONS(STATEMENT, writeStat, NIL));
505 
506  //print_statement(writeStat);
507  }
508  }
509 
510  }, lRef);
511 
512  gen_free_list(lReadDone);
513  gen_free_list(lWriteDone);
514 }
515 
516 /*
517 This function replaces the old references with new references
518  */
519 static void replace_array_ref_with_fifos2(list lRef, statement * newStat)
520 {
521  list lStats = NIL;
522 
523  list lReadStats = NIL;
524  list lWriteStats = NIL;
525 printf("replace_array_ref_with_fifos2\n");
526  generate_fifo_stats2(lRef, &lReadStats, &lWriteStats);
527 printf("replace_array_ref_with_fifos2 1\n");
528  FOREACH(REFERENCE, curRef,lRef)
529  {
530  printf("replace_array_ref %p\n", curRef);
531  print_reference(curRef);printf("\n");
532 
533  entity hreBuffEnt = get_HRE_buff_ent_from_ref(curRef);
534 
535  pips_assert("hreBuffEnt != entity_undefined",
536  hreBuffEnt != entity_undefined);
537 
538  reference hreBuffRef = make_reference(hreBuffEnt, NIL);
539 
540  comEngine_replace_reference_in_stat(*newStat, curRef, reference_to_expression(hreBuffRef));
541 
542  }
543 
544  lStats = lReadStats;
545  if(*newStat != statement_undefined)
546  {
547  lStats = gen_nconc(lStats, CONS(STATEMENT, *newStat, NIL));
548  }
549  lStats = gen_nconc(lStats, lWriteStats);
550 
551  *newStat = make_block_statement(lStats);
552 }
553 
554 /*
555 This function adds the read and write statements to the module statements
556  */
558 {
559  list lReadStats = NIL;
560  //list lWriteStats = NIL;
561 
562  HASH_MAP(oldInd, newInd,
563  {
564  if(newInd == gNewInd)
565  {
566  continue;
567  }
568 
569  statement readStat = generate_ind_fifo_stat2(oldInd, newInd, true);
570 
571  lReadStats = CONS(STATEMENT, readStat, lReadStats);
572 
573  //statement writeStat = generate_ind_fifo_stat2(oldInd, newInd, false);
574 
575  //lWriteStats = CONS(STATEMENT, writeStat, lWriteStats);
576 
577  }, gOldIndToNewInd);
578 
579  list lStats = NIL;
580 
581  lStats = gen_nconc(lStats, lReadStats);
582  lStats = gen_nconc(lStats, glReadStats);
583  lStats = gen_nconc(lStats, CONS(STATEMENT, stat, NIL));
584  lStats = gen_nconc(lStats, glWriteStats);
585  //lStats = gen_nconc(lStats, lWriteStats);
586 
587  return make_block_statement(lStats);
588 }
589 
590 /*
591 This function generate the statement of a new module
592  */
594 {
595  if(gCurStats == NIL)
596  {
597  return make_block_statement(NIL);
598  }
599 
600  printf("generate_code\n");
601 
603 
604  /*printf("glCurRep\n");
605  MAP(REFERENCE, curRef,
606  {
607  printf("glCurRep it\n");
608  print_reference(curRef);printf("\n");
609  }, glCurRep);
610 */
612 
613  printf("newStat bef\n");
614  print_statement(newStat);
615 
617 
618  printf("newStat aft 1\n");
619  print_statement(newStat);
620 
622  {
624 
625  loop newLoop = make_loop(gNewInd,
628  int_to_expression(1)),
629  newStat,
630  loop_label(curLoop),
632  NIL);
633 
638  make_instruction_loop(newLoop),NIL,NULL,
640  }
641 
642  newStat = add_index_statements(newStat);
643 
644  // Reinitialize global variables
645  glReadStats = NIL;
646  glWriteStats = NIL;
647 
649 
650  gCurStats = NIL;
651  glCurRep = NIL;
652 
656 
659 
660  return newStat;
661 }
662 
663 /*
664 this function makes an empty module
665  */
667 {
668  static int number = 0;
669 
670  string num = int2a(number++);
672  num,
673  (char *) NULL));
674  free(num);
675 
677 
679 
680  set_current_module_entity(new_fun);
681 }
682 
683 /*
684 This function assigns statement stat to the current empty module
685  */
686 static void fill_HRE_module(statement stat)
687 {
690 }
691 
692 /*
693 This function generates a new HRE module if (gCurStats != NIL)
694  */
695 static void loop_enter()
696 {
697  if(gCurStats == NIL)
698  {
699  return;
700  }
701 
703 
704  statement newStat = generate_code();
705 
706  fill_HRE_module(newStat);
707 }
708 
709 #if 0
710 static void create_loop_HRE_module()
711 {
712  if(glCurLoop == NIL)
713  {
714  return;
715  }
716 
718 
719  list lStats = NIL;
720  list lReadStats = NIL;
721  list lIncStats = NIL;
722  list lWriteStats = NIL;
723 
724  MAP(STATEMENT, loopStat,
725  {
726  entity oldInd = loop_index(statement_loop(loopStat));
727 
728  entity newInd =
731  copy_basic(entity_basic(oldInd)));
732  AddEntityToCurrentModule(newInd);
733 
734  statement readStat = generate_ind_fifo_stat2(oldInd, newInd, true);
735 
736  lReadStats = CONS(STATEMENT, readStat, lReadStats);
737 
739  entity_to_expression(newInd),
741  NULL);
742 
743  expression rExp =
744  call_to_expression(make_call(get_function_entity(PLUS_OPERATOR_NAME),
745  addArg));
746 
747  statement incStat = make_assign_statement(entity_to_expression(newInd), rExp);
748 
749  lIncStats = CONS(STATEMENT, incStat, lIncStats);
750 
751  statement writeStat = generate_ind_fifo_stat2(oldInd, newInd, false);
752 
753  lWriteStats = CONS(STATEMENT, writeStat, lWriteStats);
754 
755  }, glCurLoop);
756 
757  lStats = gen_nconc(lStats, lReadStats);
758  lStats = gen_nconc(lStats, lIncStats);
759  lStats = gen_nconc(lStats, lWriteStats);
760 
761  statement newStat = make_block_statement(lStats);
762 
763  fill_HRE_module(newStat);
764 }
765 #endif
766 
767 /*
768 This function processes the HRE code generation for a
769 loop statement
770  */
772 {
773  //printf("HRE_distribute_loop beg\n");
774 
775  loop_enter();
776 
777  glCurLoop = CONS(STATEMENT, stat, glCurLoop);
778 
780 
781  loop_enter();
782 
783  gen_remove(&glCurLoop, stat);
784 
785  //create_loop_HRE_module();
786 
787  return statement_undefined;
788 }
789 
790 /*
791 This function processes the HRE code generation for a
792 call statement
793  */
795 {
796  statement newStat = statement_undefined;
797 
798  list lCallRef = NIL;
800 
801  MAP(EXPRESSION, exp,
802  {
803  list old = lCallRef;
804  list new = NIL;
806 
807  lCallRef = gen_concatenate(old, new);
808 
809  gen_free_list(old);
810  gen_free_list(new);
811 
812  }, call_arguments(curCall));
813 
814  glCurRep = gen_nconc(glCurRep, lCallRef);
815 
816  if(gIfCount == 0)
817  {
818  newStat = copy_statement(stat);
819 
821  }
822 
823  return newStat;
824 }
825 
826 /*
827 This function processes the HRE code generation for a
828 block statement
829  */
831 {
832  instruction instr = statement_instruction(stat);
833 
834  //printf("HRE_distribute_seq\n");
835  MAP(STATEMENT, curStat,
836  {
837  statement seqStat = HRE_distribute_stat(curStat, false);
838 
839  //printf("seqStat\n");
840  if(seqStat == statement_undefined)
841  {
842  //printf("undefined\n");
843  }
844  else
845  {
846  //print_statement(seqStat);
847  if(gIfCount == 0)
848  {
850  }
851  }
852 
854 
855  return statement_undefined;
856 }
857 
858 /*
859 This function processes the HRE code generation for a
860 test statement
861  */
863 {
864  statement newStat = statement_undefined;
865 
866  list lCond = NIL;
867  lCond =
869  lCond);
870 
871  glCurRep = gen_nconc(glCurRep, lCond);
872 
873  gIfCount++;
874 
875  // Generate the HRE code for the true statement
877 
878  // Generate the HRE code for the false statement
880 
881  gIfCount--;
882 
883  if(gIfCount == 0)
884  {
885  newStat = copy_statement(stat);
886 
888  }
889 
890  return newStat;
891 }
892 
893 /*
894 This function processes the HRE code generation for any
895 statements
896  */
897 static statement HRE_distribute_stat(statement stat, bool calledFromLoop)
898 {
899  statement newStat = statement_undefined;
900 
901  printf("HRE_distribute_stat\n");
902  print_statement(stat);
903 
904  instruction instr = statement_instruction(stat);
905 
906  switch(instruction_tag(instr))
907  {
909  {
910  newStat = HRE_distribute_seq(stat);
911 
912  break;
913  }
914  case is_instruction_loop:
915  {
916  newStat = HRE_distribute_loop(stat);
917  break;
918  }
919  case is_instruction_call:
920  {
921  newStat = HRE_distribute_call(stat);
922 
923  if(calledFromLoop && (gIfCount == 0))
924  {
926  }
927 
928  break;
929  }
930  case is_instruction_test:
931  {
932  newStat = HRE_distribute_test(stat);
933 
934  if(calledFromLoop && (gIfCount == 0))
935  {
937  }
938 
939  break;
940  }
941  default:
942  {
943  pips_assert("FALSE", false);
944  break;
945  }
946  }
947  printf("HRE_distribute_stat end\n");
948  return newStat;
949 }
950 
951 /*
952 This function generates the HRE code using several
953 processes on the HRE
954  */
955 statement HRE_distribute(statement stat, string new_module_name, const char* module_name)
956 {
957  printf("stat bef HRE_distribute\n");
958  print_statement(stat);
959 
960  // Global variables initialization
961  g_new_module_name = new_module_name;
963  gCurStats = NIL;
964  glCurRep = NIL;
965  gIfCount = 0;
966  glCurLoop = NIL;
970  glReadStats = NIL;
971  glWriteStats = NIL;
972 
973  HRE_distribute_stat(stat, true);
974 
975  loop_enter();
976 
977  // Free some global variables
980 
981  return make_block_statement(NIL);
982 }
instruction make_instruction_loop(loop _field_)
Definition: ri.c:1175
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
basic copy_basic(basic p)
BASIC.
Definition: ri.c:104
language make_language_unknown(void)
Definition: ri.c:1259
expression copy_expression(expression p)
EXPRESSION.
Definition: ri.c:850
statement copy_statement(statement p)
STATEMENT.
Definition: ri.c:2186
reference make_reference(entity a1, list a2)
Definition: ri.c:2083
statement make_statement(entity a1, intptr_t a2, intptr_t a3, string a4, instruction a5, list a6, string a7, extensions a8, synchronization a9)
Definition: ri.c:2222
synchronization make_synchronization_none(void)
Definition: ri.c:2424
range make_range(expression a1, expression a2, expression a3)
Definition: ri.c:2041
static int num
Definition: bourdoncle.c:137
#define R_EFFECT
Definition: comEngine.h:29
#define WRITE_FIFO
Definition: comEngine.h:36
#define READ_FIFO
Definition: comEngine.h:35
static list glWriteStats
static list glCurLoop
static void loop_enter()
static statement generate_code()
static const char * g_module_name
static statement HRE_distribute_test(statement stat)
statement generate_fifo_stat2(reference curRef, bool bRead)
static list glCurRep
static entity gNewInd
static void make_HRE_empty_module()
static void fill_HRE_module(statement stat)
static statement HRE_distribute_loop(statement stat)
static hash_table gOldIndToNewInd
void generate_fifo_stats2(list lRef, list *lReadStats, list *lWriteStats)
static statement HRE_distribute_call(statement stat)
static const char * g_new_module_name
static hash_table gIsIndex
static int gIfCount
static entity find_or_create_newInd(entity ind, bool bIsInd)
static statement HRE_distribute_stat(statement stat, bool calledFromLoop)
expression get_fifoExp_from_ref(reference curRef, expression buffExp, hash_table ht)
comEngine_HRE_distribute.c
static expression get_indExp_from_ref(reference curRef, hash_table ht, bool *innerInd)
static statement add_index_statements(statement stat)
static void replace_array_ref_with_fifos2(list lRef, statement *newStat)
static void generate_scalar_variables_from_list(list lRef)
statement HRE_distribute(statement stat, string new_module_name, const char *module_name)
static list glReadStats
static list gCurStats
static statement make_read_write_fifo_stat(string name, expression fifoExp, expression indExp, expression hreBuffExp)
statement generate_ind_fifo_stat2(entity oldInd, entity newInd, bool bRead)
static statement HRE_distribute_seq(statement stat)
expression gBufferSizeEnt
hash_table gRefToInd
void create_HRE_module(const char *new_module_name, const char *module_name, statement stat, entity new_fun)
hash_table gRefToToggle
hash_table gIndToNum
hash_table gEntToHREFifo
hash_table gRefToEff
hash_table gLoopToUnSupRef
list comEngine_expression_to_reference_list(expression e, list lr)
conversion of an expression into a list of references; references are appended to list lr as they are...
expression get_fifo_from_ref(reference ref)
hash_table gRefToHREVar
comEngine_generate_HRECode.c
entity get_HRE_buff_ent_from_ref(reference ref)
void comEngine_replace_reference_in_stat(statement stat, reference ref, expression new)
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
void free(void *)
statement make_block_statement(list)
Make a block statement from a list of statement.
Definition: statement.c:616
void reset_current_module_entity(void)
Reset the current module entity.
Definition: static.c:97
entity set_current_module_entity(entity)
static.c
Definition: static.c:66
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
list gen_make_list(int domain,...)
Definition: list.c:851
void gen_remove(list *cpp, const void *o)
remove all occurences of item o from list *cpp, which is thus modified.
Definition: list.c:685
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
list gen_concatenate(const list l1x, const list l2x)
concatenate two lists.
Definition: list.c:436
#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
#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
#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
test statement_test(statement)
Get the test of a statement.
Definition: statement.c:1348
statement make_assign_statement(expression, expression)
Definition: statement.c:583
hash_table hash_table_make(hash_key_type key_type, size_t size)
Definition: hash.c:294
void * hash_get(const hash_table htp, const void *key)
this function retrieves in the hash table pointed to by htp the couple whose key is equal to key.
Definition: hash.c:449
void hash_put(hash_table htp, const void *key, const void *val)
This functions stores a couple (key,val) in the hash table pointed to by htp.
Definition: hash.c:364
void hash_table_free(hash_table htp)
this function deletes a hash table that is no longer useful.
Definition: hash.c:327
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define STATEMENT_ORDERING_UNDEFINED
mapping.h inclusion
Definition: newgen-local.h:35
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
#define HASH_MAP(k, v, code, ht)
Definition: newgen_hash.h:60
@ hash_pointer
Definition: newgen_hash.h:32
#define HASH_UNDEFINED_VALUE
value returned by hash_get() when the key is not found; could also be called HASH_KEY_NOT_FOUND,...
Definition: newgen_hash.h:56
#define string_undefined
Definition: newgen_types.h:40
#define UU
Definition: newgen_types.h:98
void print_reference(reference r)
Definition: expression.c:142
void print_statement(statement)
Print a statement on stderr.
Definition: statement.c:98
static const char * prefix
#define PLUS_OPERATOR_NAME
#define STATEMENT_NUMBER_UNDEFINED
default values
#define call_to_statement(c)
#define empty_comments
Empty comments (i.e.
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
entity make_empty_subroutine(const char *name, language l)
Definition: entity.c:268
entity entity_empty_label(void)
Definition: entity.c:1105
basic entity_basic(entity e)
return the basic associated to entity e if it's a function/variable/constant basic_undefined otherwis...
Definition: entity.c:1380
entity module_name_to_runtime_entity(const char *name)
similar to module_name_to_entity but generates a warning and a stub if the entity is not found
Definition: entity.c:1485
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
Definition: entity.c:1292
expression reference_to_expression(reference r)
Definition: expression.c:196
expression entity_to_expression(entity e)
if v is a constant, returns a constant call.
Definition: expression.c:165
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 reference_equal_p(reference r1, reference r2)
Definition: expression.c:1500
expression call_to_expression(call c)
Build an expression that call a function or procedure.
Definition: expression.c:309
extensions empty_extensions(void)
extension.c
Definition: extension.c:43
void AddEntityToCurrentModule(entity)
Add a variable entity to the current module declarations.
Definition: variable.c:260
entity make_new_scalar_variable_with_prefix(const char *, entity, basic)
Create a new scalar variable of type b in the given module.
Definition: variable.c:592
basic basic_of_reference(reference)
Retrieves the basic of a reference in a newly allocated basic object.
Definition: type.c:1459
#define loop_body(x)
Definition: ri.h:1644
#define expression_domain
newgen_execution_domain_defined
Definition: ri.h:154
#define REFERENCE(x)
REFERENCE.
Definition: ri.h:2296
#define reference_undefined
Definition: ri.h:2302
#define reference_variable(x)
Definition: ri.h:2326
#define test_false(x)
Definition: ri.h:2837
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define basic_undefined
Definition: ri.h:556
#define entity_undefined
Definition: ri.h:2761
#define expression_undefined
Definition: ri.h:1223
@ is_instruction_test
Definition: ri.h:1470
@ is_instruction_call
Definition: ri.h:1474
@ is_instruction_sequence
Definition: ri.h:1469
@ is_instruction_loop
Definition: ri.h:1471
#define instruction_tag(x)
Definition: ri.h:1511
#define test_true(x)
Definition: ri.h:2835
#define sequence_statements(x)
Definition: ri.h:2360
#define instruction_sequence(x)
Definition: ri.h:1514
#define loop_label(x)
Definition: ri.h:1646
#define test_condition(x)
Definition: ri.h:2833
#define statement_instruction(x)
Definition: ri.h:2458
#define statement_comments(x)
Definition: ri.h:2456
#define instruction_call(x)
Definition: ri.h:1529
@ is_execution_sequential
Definition: ri.h:1189
#define call_arguments(x)
Definition: ri.h:711
#define loop_index(x)
Definition: ri.h:1640
#define statement_undefined
Definition: ri.h:2419
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
char * strdup()
int printf()
#define intptr_t
Definition: stdint.in.h:294
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
char * int2a(int)
util.c
Definition: util.c:42
#define exp
Avoid some warnings from "gcc -Wshadow".
Definition: vasnprintf.c:207