PIPS
comEngine_HRE_distribute.c File Reference
#include <stdio.h>
#include <ctype.h>
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "effects.h"
#include "resources.h"
#include "misc.h"
#include "ri-util.h"
#include "prettyprint.h"
#include "effects-util.h"
#include "text-util.h"
#include "ray_dte.h"
#include "sommet.h"
#include "sg.h"
#include "polyedre.h"
#include "phrase_tools.h"
#include "effects-generic.h"
#include "effects-simple.h"
#include "effects-convex.h"
#include "phrase_distribution.h"
#include "comEngine.h"
#include "comEngine_generate_code.h"
#include "phrase.h"
+ Include dependency graph for comEngine_HRE_distribute.c:

Go to the source code of this file.

Functions

static statement HRE_distribute_stat (statement stat, bool calledFromLoop)
 
static void generate_scalar_variables_from_list (list lRef)
 
static entity find_or_create_newInd (entity ind, bool bIsInd)
 
static expression get_indExp_from_ref (reference curRef, hash_table ht, bool *innerInd)
 
expression get_fifoExp_from_ref (reference curRef, expression buffExp, hash_table ht)
 comEngine_HRE_distribute.c More...
 
static statement make_read_write_fifo_stat (string name, expression fifoExp, expression indExp, expression hreBuffExp)
 
statement generate_fifo_stat2 (reference curRef, bool bRead)
 
statement generate_ind_fifo_stat2 (entity oldInd, entity newInd, bool bRead)
 
void generate_fifo_stats2 (list lRef, list *lReadStats, list *lWriteStats)
 
static void replace_array_ref_with_fifos2 (list lRef, statement *newStat)
 
static statement add_index_statements (statement stat)
 
static statement generate_code ()
 
static void make_HRE_empty_module ()
 
static void fill_HRE_module (statement stat)
 
static void loop_enter ()
 
static statement HRE_distribute_loop (statement stat)
 
static statement HRE_distribute_call (statement stat)
 
static statement HRE_distribute_seq (statement stat)
 
static statement HRE_distribute_test (statement stat)
 
statement HRE_distribute (statement stat, string new_module_name, const char *module_name)
 

Variables

static hash_table gOldIndToNewInd
 
static hash_table gIsIndex
 
static list gCurStats = NIL
 
static list glCurRep = NIL
 
static const char * g_new_module_name = NULL
 
static const char * g_module_name = NULL
 
static int gIfCount = 0
 
static list glCurLoop = NIL
 
static entity gNewInd = entity_undefined
 
static list glReadStats = NIL
 
static list glWriteStats = NIL
 

Function Documentation

◆ add_index_statements()

static statement add_index_statements ( statement  stat)
static

Definition at line 557 of file comEngine_HRE_distribute.c.

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 }
static list glWriteStats
static entity gNewInd
static hash_table gOldIndToNewInd
static list glReadStats
statement generate_ind_fifo_stat2(entity oldInd, entity newInd, bool bRead)
statement make_block_statement(list)
Make a block statement from a list of statement.
Definition: statement.c:616
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#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 HASH_MAP(k, v, code, ht)
Definition: newgen_hash.h:60
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References CONS, gen_nconc(), generate_ind_fifo_stat2(), glReadStats, glWriteStats, gNewInd, gOldIndToNewInd, HASH_MAP, make_block_statement(), NIL, and STATEMENT.

Referenced by generate_code().

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

◆ fill_HRE_module()

static void fill_HRE_module ( statement  stat)
static

Definition at line 686 of file comEngine_HRE_distribute.c.

687 {
690 }
static const char * g_module_name
void create_HRE_module(const char *new_module_name, const char *module_name, statement stat, entity new_fun)
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
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

References create_HRE_module(), entity_local_name(), g_module_name, and get_current_module_entity().

Referenced by loop_enter().

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

◆ find_or_create_newInd()

static entity find_or_create_newInd ( entity  ind,
bool  bIsInd 
)
static

Definition at line 168 of file comEngine_HRE_distribute.c.

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 }
basic copy_basic(basic p)
BASIC.
Definition: ri.c:104
static list glCurLoop
static hash_table gIsIndex
hash_table gLoopToUnSupRef
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
loop statement_loop(statement)
Get the loop of a statement.
Definition: statement.c:1374
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
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#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
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
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
#define entity_undefined
Definition: ri.h:2761
#define loop_index(x)
Definition: ri.h:1640

References AddEntityToCurrentModule(), CAR, copy_basic(), entity_basic(), entity_local_name(), entity_undefined, get_current_module_entity(), gIsIndex, glCurLoop, gLoopToUnSupRef, gNewInd, gOldIndToNewInd, hash_get(), hash_put(), HASH_UNDEFINED_VALUE, loop_index, make_new_scalar_variable_with_prefix(), NIL, pips_assert, STATEMENT, and statement_loop().

Referenced by get_fifoExp_from_ref(), and get_indExp_from_ref().

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

◆ generate_code()

static statement generate_code ( )
static

rintf("glCurRep\n"); MAP(REFERENCE, curRef, { printf("glCurRep it\n"); print_reference(curRef);printf("\n"); }, glCurRep);

Definition at line 593 of file comEngine_HRE_distribute.c.

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 }
instruction make_instruction_loop(loop _field_)
Definition: ri.c:1175
execution make_execution(enum execution_utype tag, void *val)
Definition: ri.c:838
loop make_loop(entity a1, range a2, statement a3, entity a4, execution a5, list a6)
Definition: ri.c:1301
expression copy_expression(expression p)
EXPRESSION.
Definition: ri.c:850
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 list glCurRep
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)
static list gCurStats
expression gBufferSizeEnt
hash_table gRefToHREVar
comEngine_generate_HRECode.c
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
hash_table hash_table_make(hash_key_type key_type, size_t size)
Definition: hash.c:294
void hash_table_free(hash_table htp)
this function deletes a hash table that is no longer useful.
Definition: hash.c:327
#define STATEMENT_ORDERING_UNDEFINED
mapping.h inclusion
Definition: newgen-local.h:35
@ hash_pointer
Definition: newgen_hash.h:32
#define UU
Definition: newgen_types.h:98
void print_statement(statement)
Print a statement on stderr.
Definition: statement.c:98
#define STATEMENT_NUMBER_UNDEFINED
default values
#define empty_comments
Empty comments (i.e.
entity entity_empty_label(void)
Definition: entity.c:1105
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
extensions empty_extensions(void)
extension.c
Definition: extension.c:43
#define loop_label(x)
Definition: ri.h:1646
@ is_execution_sequential
Definition: ri.h:1189
int printf()

References add_index_statements(), CAR, copy_expression(), empty_comments, empty_extensions(), entity_empty_label(), entity_undefined, gBufferSizeEnt, gCurStats, gen_free_list(), generate_scalar_variables_from_list(), glCurLoop, glCurRep, glReadStats, glWriteStats, gNewInd, gOldIndToNewInd, gRefToHREVar, hash_pointer, hash_table_free(), hash_table_make(), int_to_expression(), is_execution_sequential, loop_label, make_block_statement(), make_execution(), make_instruction_loop(), make_loop(), make_range(), make_statement(), make_synchronization_none(), NIL, print_statement(), printf(), replace_array_ref_with_fifos2(), STATEMENT, statement_loop(), STATEMENT_NUMBER_UNDEFINED, STATEMENT_ORDERING_UNDEFINED, and UU.

Referenced by loop_enter().

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

◆ generate_fifo_stat2()

statement generate_fifo_stat2 ( reference  curRef,
bool  bRead 
)
Parameters
curRefurRef
bReadRead

Definition at line 336 of file comEngine_HRE_distribute.c.

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 }
#define WRITE_FIFO
Definition: comEngine.h:36
#define READ_FIFO
Definition: comEngine.h:35
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 make_read_write_fifo_stat(string name, expression fifoExp, expression indExp, expression hreBuffExp)
hash_table gRefToInd
hash_table gRefToToggle
expression get_fifo_from_ref(reference ref)
entity get_HRE_buff_ent_from_ref(reference ref)
expression entity_to_expression(entity e)
if v is a constant, returns a constant call.
Definition: expression.c:165
#define expression_undefined
Definition: ri.h:1223
#define statement_undefined
Definition: ri.h:2419
char * strdup()

References CONS, entity_to_expression(), entity_undefined, expression_undefined, get_fifo_from_ref(), get_fifoExp_from_ref(), get_HRE_buff_ent_from_ref(), get_indExp_from_ref(), glReadStats, glWriteStats, gRefToInd, gRefToToggle, make_read_write_fifo_stat(), pips_assert, READ_FIFO, STATEMENT, statement_undefined, strdup(), and WRITE_FIFO.

Referenced by generate_fifo_stats2().

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

◆ generate_fifo_stats2()

void generate_fifo_stats2 ( list  lRef,
list lReadStats,
list lWriteStats 
)
Parameters
lRefRef
lReadStatsReadStats
lWriteStatsWriteStats

Definition at line 432 of file comEngine_HRE_distribute.c.

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 }
#define R_EFFECT
Definition: comEngine.h:29
statement generate_fifo_stat2(reference curRef, bool bRead)
hash_table gRefToEff
#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
bool reference_equal_p(reference r1, reference r2)
Definition: expression.c:1500
#define REFERENCE(x)
REFERENCE.
Definition: ri.h:2296

References CONS, gen_free_list(), gen_nconc(), generate_fifo_stat2(), gRefToEff, hash_get(), HASH_UNDEFINED_VALUE, MAP, NIL, pips_assert, R_EFFECT, REFERENCE, reference_equal_p(), STATEMENT, and statement_undefined.

Referenced by replace_array_ref_with_fifos2().

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

◆ generate_ind_fifo_stat2()

statement generate_ind_fifo_stat2 ( entity  oldInd,
entity  newInd,
bool  bRead 
)
Parameters
oldIndldInd
newIndewInd
bReadRead

Definition at line 396 of file comEngine_HRE_distribute.c.

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 }
hash_table gIndToNum
hash_table gEntToHREFifo
#define intptr_t
Definition: stdint.in.h:294

References entity_to_expression(), gEntToHREFifo, gIndToNum, hash_get(), HASH_UNDEFINED_VALUE, int_to_expression(), intptr_t, make_read_write_fifo_stat(), pips_assert, READ_FIFO, statement_undefined, strdup(), and WRITE_FIFO.

Referenced by add_index_statements().

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

◆ generate_scalar_variables_from_list()

static void generate_scalar_variables_from_list ( list  lRef)
static

Definition at line 104 of file comEngine_HRE_distribute.c.

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 }
basic basic_of_reference(reference)
Retrieves the basic of a reference in a newly allocated basic object.
Definition: type.c:1459
#define reference_undefined
Definition: ri.h:2302
#define reference_variable(x)
Definition: ri.h:2326
#define basic_undefined
Definition: ri.h:556

References AddEntityToCurrentModule(), basic_of_reference(), basic_undefined, entity_local_name(), get_current_module_entity(), gRefToHREVar, hash_get(), HASH_MAP, hash_put(), HASH_UNDEFINED_VALUE, make_new_scalar_variable_with_prefix(), MAP, pips_assert, REFERENCE, reference_equal_p(), reference_undefined, reference_variable, and strdup().

Referenced by generate_code().

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

◆ get_fifoExp_from_ref()

expression get_fifoExp_from_ref ( reference  curRef,
expression  buffExp,
hash_table  ht 
)

comEngine_HRE_distribute.c

Parameters
curRefurRef
buffExpuffExp
htt

Definition at line 260 of file comEngine_HRE_distribute.c.

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 }
call make_call(entity a1, list a2)
Definition: ri.c:269
static entity find_or_create_newInd(entity ind, bool bIsInd)
list gen_make_list(int domain,...)
Definition: list.c:851
#define PLUS_OPERATOR_NAME
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
Definition: entity.c:1292
expression call_to_expression(call c)
Build an expression that call a function or procedure.
Definition: expression.c:309
#define expression_domain
newgen_execution_domain_defined
Definition: ri.h:154

References call_to_expression(), entity_intrinsic(), entity_to_expression(), entity_undefined, expression_domain, find_or_create_newInd(), gen_make_list(), HASH_MAP, make_call(), PLUS_OPERATOR_NAME, and reference_equal_p().

Referenced by generate_fifo_stat2().

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

◆ get_indExp_from_ref()

static expression get_indExp_from_ref ( reference  curRef,
hash_table  ht,
bool innerInd 
)
static

Definition at line 219 of file comEngine_HRE_distribute.c.

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 }

References CAR, entity_to_expression(), entity_undefined, find_or_create_newInd(), glCurLoop, HASH_MAP, int_to_expression(), loop_index, reference_equal_p(), STATEMENT, and statement_loop().

Referenced by generate_fifo_stat2().

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

◆ HRE_distribute()

statement HRE_distribute ( statement  stat,
string  new_module_name,
const char *  module_name 
)
Parameters
stattat
new_module_nameew_module_name
module_nameodule_name

Definition at line 955 of file comEngine_HRE_distribute.c.

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 }
static void loop_enter()
static const char * g_new_module_name
static int gIfCount
static statement HRE_distribute_stat(statement stat, bool calledFromLoop)
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296

References entity_undefined, g_module_name, g_new_module_name, gCurStats, gIfCount, gIsIndex, glCurLoop, glCurRep, glReadStats, glWriteStats, gNewInd, gOldIndToNewInd, hash_pointer, hash_table_free(), hash_table_make(), HRE_distribute_stat(), loop_enter(), make_block_statement(), module_name(), NIL, print_statement(), and printf().

Referenced by comEngine_generate_HRECode().

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

◆ HRE_distribute_call()

static statement HRE_distribute_call ( statement  stat)
static

Definition at line 794 of file comEngine_HRE_distribute.c.

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 }
statement copy_statement(statement p)
STATEMENT.
Definition: ri.c:2186
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...
list gen_concatenate(const list l1x, const list l2x)
concatenate two lists.
Definition: list.c:436
#define string_undefined
Definition: newgen_types.h:40
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#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 call_arguments(x)
Definition: ri.h:711
#define exp
Avoid some warnings from "gcc -Wshadow".
Definition: vasnprintf.c:207

References call_arguments, comEngine_expression_to_reference_list(), copy_statement(), exp, EXPRESSION, gen_concatenate(), gen_free_list(), gen_nconc(), gIfCount, glCurRep, instruction_call, MAP, NIL, statement_comments, statement_instruction, statement_undefined, and string_undefined.

Referenced by HRE_distribute_stat().

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

◆ HRE_distribute_loop()

static statement HRE_distribute_loop ( statement  stat)
static

Definition at line 771 of file comEngine_HRE_distribute.c.

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 }
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 loop_body(x)
Definition: ri.h:1644

References CONS, gen_remove(), glCurLoop, HRE_distribute_stat(), loop_body, loop_enter(), STATEMENT, statement_loop(), and statement_undefined.

Referenced by HRE_distribute_stat().

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

◆ HRE_distribute_seq()

static statement HRE_distribute_seq ( statement  stat)
static

Definition at line 830 of file comEngine_HRE_distribute.c.

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 }
#define sequence_statements(x)
Definition: ri.h:2360
#define instruction_sequence(x)
Definition: ri.h:1514

References CONS, gCurStats, gen_nconc(), gIfCount, HRE_distribute_stat(), instruction_sequence, MAP, NIL, sequence_statements, STATEMENT, statement_instruction, and statement_undefined.

Referenced by HRE_distribute_stat().

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

◆ HRE_distribute_stat()

static statement HRE_distribute_stat ( statement  stat,
bool  calledFromLoop 
)
static

Definition at line 897 of file comEngine_HRE_distribute.c.

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 }
static statement HRE_distribute_test(statement stat)
static statement HRE_distribute_loop(statement stat)
static statement HRE_distribute_call(statement stat)
static statement HRE_distribute_seq(statement stat)
@ 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

References CONS, gCurStats, gen_nconc(), gIfCount, HRE_distribute_call(), HRE_distribute_loop(), HRE_distribute_seq(), HRE_distribute_test(), instruction_tag, is_instruction_call, is_instruction_loop, is_instruction_sequence, is_instruction_test, NIL, pips_assert, print_statement(), printf(), STATEMENT, statement_instruction, and statement_undefined.

Referenced by HRE_distribute(), HRE_distribute_loop(), HRE_distribute_seq(), and HRE_distribute_test().

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

◆ HRE_distribute_test()

static statement HRE_distribute_test ( statement  stat)
static

Definition at line 862 of file comEngine_HRE_distribute.c.

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 }
test statement_test(statement)
Get the test of a statement.
Definition: statement.c:1348
#define test_false(x)
Definition: ri.h:2837
#define test_true(x)
Definition: ri.h:2835
#define test_condition(x)
Definition: ri.h:2833

References comEngine_expression_to_reference_list(), copy_statement(), gen_nconc(), gIfCount, glCurRep, HRE_distribute_stat(), NIL, statement_comments, statement_test(), statement_undefined, string_undefined, test_condition, test_false, and test_true.

Referenced by HRE_distribute_stat().

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

◆ loop_enter()

static void loop_enter ( )
static

Definition at line 695 of file comEngine_HRE_distribute.c.

696 {
697  if(gCurStats == NIL)
698  {
699  return;
700  }
701 
703 
704  statement newStat = generate_code();
705 
706  fill_HRE_module(newStat);
707 }
static statement generate_code()
static void make_HRE_empty_module()
static void fill_HRE_module(statement stat)

References fill_HRE_module(), gCurStats, generate_code(), make_HRE_empty_module(), and NIL.

Referenced by HRE_distribute(), and HRE_distribute_loop().

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

◆ make_HRE_empty_module()

static void make_HRE_empty_module ( )
static

Definition at line 666 of file comEngine_HRE_distribute.c.

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 }
language make_language_unknown(void)
Definition: ri.c:1259
static int num
Definition: bourdoncle.c:137
void free(void *)
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
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
static const char * prefix
entity make_empty_subroutine(const char *name, language l)
Definition: entity.c:268
char * int2a(int)
util.c
Definition: util.c:42

References concatenate(), free(), g_new_module_name, int2a(), make_empty_subroutine(), make_language_unknown(), num, prefix, reset_current_module_entity(), set_current_module_entity(), and strdup().

Referenced by loop_enter().

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

◆ make_read_write_fifo_stat()

static statement make_read_write_fifo_stat ( string  name,
expression  fifoExp,
expression  indExp,
expression  hreBuffExp 
)
static

Definition at line 297 of file comEngine_HRE_distribute.c.

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 }
statement make_assign_statement(expression, expression)
Definition: statement.c:583
#define call_to_statement(c)
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

References call_to_expression(), call_to_statement, expression_domain, gen_make_list(), make_assign_statement(), make_call(), module_name_to_runtime_entity(), and READ_FIFO.

Referenced by generate_fifo_stat2(), and generate_ind_fifo_stat2().

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

◆ replace_array_ref_with_fifos2()

static void replace_array_ref_with_fifos2 ( list  lRef,
statement newStat 
)
static

Definition at line 519 of file comEngine_HRE_distribute.c.

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 }
reference make_reference(entity a1, list a2)
Definition: ri.c:2083
void generate_fifo_stats2(list lRef, list *lReadStats, list *lWriteStats)
void comEngine_replace_reference_in_stat(statement stat, reference ref, expression new)
#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 print_reference(reference r)
Definition: expression.c:142
expression reference_to_expression(reference r)
Definition: expression.c:196

References comEngine_replace_reference_in_stat(), CONS, entity_undefined, FOREACH, gen_nconc(), generate_fifo_stats2(), get_HRE_buff_ent_from_ref(), make_block_statement(), make_reference(), NIL, pips_assert, print_reference(), printf(), REFERENCE, reference_to_expression(), STATEMENT, and statement_undefined.

Referenced by generate_code().

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

Variable Documentation

◆ g_module_name

const char* g_module_name = NULL
static

Definition at line 79 of file comEngine_HRE_distribute.c.

Referenced by fill_HRE_module(), and HRE_distribute().

◆ g_new_module_name

const char* g_new_module_name = NULL
static

Definition at line 78 of file comEngine_HRE_distribute.c.

Referenced by HRE_distribute(), and make_HRE_empty_module().

◆ gCurStats

list gCurStats = NIL
static

◆ gIfCount

◆ gIsIndex

hash_table gIsIndex
static

Definition at line 71 of file comEngine_HRE_distribute.c.

Referenced by find_or_create_newInd(), and HRE_distribute().

◆ glCurLoop

◆ glCurRep

list glCurRep = NIL
static

◆ glReadStats

list glReadStats = NIL
static

◆ glWriteStats

list glWriteStats = NIL
static

◆ gNewInd

◆ gOldIndToNewInd

hash_table gOldIndToNewInd
static