PIPS
comEngine_generate_code.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 "properties.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 "phrase.h"
+ Include dependency graph for comEngine_generate_code.c:

Go to the source code of this file.

Functions

entity comEngine_make_new_scalar_variable (const char *prefix, basic bas)
 
static void fill_gLoopToOpt (list lRef)
 
static void fill_gLoopToToggleEnt (statement stat, list lRef)
 
statement make_toggle_init_statement (entity toggleEnt)
 
static void update_toggle_init_stats_list (statement stat)
 
statement make_toggle_inc_statement (entity toggleEnt, int val)
 
static void add_toggle_inc_statements (statement stat, list lInStats)
 
static statement make_loopStat1 (statement stat, entity transferSize, statement innerStat, entity newOuterInd, list lSupportedRef, hash_table htOffset, expression bufferSizeExp, entity newInnerInd)
 
static statement usual_loop_tiling (statement stat, statement newBody, list lSupportedRef, list lUnSupportedRef, hash_table htOffset, expression bufferSizeExp, entity newOuterInd, entity newInnerInd)
 
static statement generate_code_loop (statement stat)
 
static void process_ref_lists (statement stat, list *lInRef)
 
static void process_opt_replace (statement *newStat)
 
static list replace_glCurRep_in_seq (list lStats, list lPrevSeq, list lSeq)
 
static statement generate_code_seq (statement stat)
 
static statement add_exec_mmcd (statement stat)
 
static statement generate_code_call (statement stat, bool bCalledFromSeq)
 
static statement process_code_seq (statement newStat, statement stat)
 
statement generate_code_function (statement stat, bool bCalledFromSeq)
 
statement comEngine_generate_code (statement stat)
 

Variables

hash_table gLoopToOuterInd
 comEngine_generate_code.c More...
 
bool gGenHRE = false
 
static bool COM_OPT
 
static bool gExecPut
 
static list glCurRep = NIL
 
static hash_table gHtCurNewInd
 
static list glCurLoop = NIL
 
static list glOutEffStats = NIL
 
list glToggleInitStats
 

Function Documentation

◆ add_exec_mmcd()

static statement add_exec_mmcd ( statement  stat)
static

Definition at line 938 of file comEngine_generate_code.c.

939 {
940  statement mmcdStat = make_exec_mmcd();
941 
942  statement stepStat = make_step_inc_statement(1);
943 
944  mmcdStat = make_block_statement(gen_nconc(CONS(STATEMENT, stepStat, NIL),
945  CONS(STATEMENT, mmcdStat, NIL)));
946 
947  if(glCurLoop != NIL)
948  {
949  statement loopStat = STATEMENT(CAR(glCurLoop));
950 
951  list lUnSupportedRef = hash_get(gLoopToUnSupRef, loopStat);
952 
953  pips_assert("lUnSupportedRef != HASH_UNDEFINED_VALUE",
954  lUnSupportedRef != HASH_UNDEFINED_VALUE);
955 
956  if(lUnSupportedRef == NIL)
957  {
958  loop curLoop = statement_loop(loopStat);
959 
960  entity newInd = hash_get(gHtCurNewInd, loopStat);
961 
963  entity_to_expression(newInd),
965  NULL);
966 
967  expression neExp =
969  neArg));
970 
971  test t = make_test(neExp, mmcdStat, make_empty_statement());
972 
973  mmcdStat = make_statement(entity_empty_label(),
978  NIL,NULL,
980  }
981  }
982 
983  if(stat == statement_undefined)
984  {
985  return mmcdStat;
986  }
987  else
988  {
990  CONS(STATEMENT, mmcdStat, NIL)));
991  }
992 }
call make_call(entity a1, list a2)
Definition: ri.c:269
expression copy_expression(expression p)
EXPRESSION.
Definition: ri.c:850
test make_test(expression a1, statement a2, statement a3)
Definition: ri.c:2607
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
instruction make_instruction(enum instruction_utype tag, void *val)
Definition: ri.c:1166
synchronization make_synchronization_none(void)
Definition: ri.c:2424
hash_table gLoopToUnSupRef
static list glCurLoop
static hash_table gHtCurNewInd
statement make_step_inc_statement(int incNum)
statement make_exec_mmcd()
statement make_block_statement(list)
Make a block statement from a list of statement.
Definition: statement.c:616
list gen_make_list(int domain,...)
Definition: list.c:851
#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 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
#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
#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 STATEMENT_NUMBER_UNDEFINED
default values
#define empty_comments
Empty comments (i.e.
#define C_EQUAL_OPERATOR_NAME
#define make_empty_statement
An alias for make_empty_block_statement.
entity entity_empty_label(void)
Definition: entity.c:1105
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
Definition: entity.c:1292
expression entity_to_expression(entity e)
if v is a constant, returns a constant call.
Definition: expression.c:165
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
#define expression_domain
newgen_execution_domain_defined
Definition: ri.h:154
@ is_instruction_test
Definition: ri.h:1470
#define range_lower(x)
Definition: ri.h:2288
#define loop_range(x)
Definition: ri.h:1642
#define statement_undefined
Definition: ri.h:2419
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References C_EQUAL_OPERATOR_NAME, call_to_expression(), CAR, CONS, copy_expression(), empty_comments, empty_extensions(), entity_empty_label(), entity_intrinsic(), entity_to_expression(), expression_domain, gen_make_list(), gen_nconc(), gHtCurNewInd, glCurLoop, gLoopToUnSupRef, hash_get(), HASH_UNDEFINED_VALUE, is_instruction_test, loop_range, make_block_statement(), make_call(), make_empty_statement, make_exec_mmcd(), make_instruction(), make_statement(), make_step_inc_statement(), make_synchronization_none(), make_test(), NIL, pips_assert, range_lower, STATEMENT, statement_loop(), STATEMENT_NUMBER_UNDEFINED, STATEMENT_ORDERING_UNDEFINED, and statement_undefined.

Referenced by generate_code_call().

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

◆ add_toggle_inc_statements()

static void add_toggle_inc_statements ( statement  stat,
list  lInStats 
)
static

Definition at line 241 of file comEngine_generate_code.c.

242 {
243  list lToggleEnt = hash_get(gLoopToToggleEnt, stat);
244 
245  pips_assert("lToggleEnt != HASH_UNDEFINED_VALUE",
246  lToggleEnt!= HASH_UNDEFINED_VALUE);
247 
248  // The loop we consider is the first statement of the list lInStats
249  statement newLoopStat = STATEMENT(CAR(lInStats));
250 
251  pips_assert("newLoopStat is a loop statement",
252  statement_loop_p(newLoopStat));
253 
254  statement body = loop_body(statement_loop(newLoopStat));
255 
256  list lStats = CONS(STATEMENT, body, NIL);
257 
258  MAP(STATEMENT, loopStat,
259  {
260  if(loopStat == STATEMENT(CAR(glCurLoop)))
261  {
262  continue;
263  }
264 
265  entity inInd = hash_get(gHtCurNewInd, loopStat);
266 
267  statement indStat = make_init_newInd_stat(loopStat, inInd);
268 
269  if(indStat != statement_undefined)
270  {
271  lStats = gen_nconc(CONS(STATEMENT, indStat, NIL), lStats);
272  }
273  }, glCurLoop);
274 
275  // For each toggle variable, create a statement to increment it
276  MAP(ENTITY, toggleEnt,
277  {
278  statement mmcdStat = make_toggle_mmcd(toggleEnt);
279 
280  lStats = gen_nconc(CONS(STATEMENT, mmcdStat, NIL), lStats);
281 
282  intptr_t inc = (intptr_t)hash_get(gToggleToInc, toggleEnt);
283 
284  statement toggleStat =
285  make_toggle_inc_statement(toggleEnt, inc);
286 
287  lStats = gen_nconc(lStats, CONS(STATEMENT, toggleStat, NIL));
288  }, lToggleEnt);
289 
290  loop_body(statement_loop(newLoopStat)) = make_block_statement(lStats);
291 }
hash_table gLoopToToggleEnt
hash_table gToggleToInc
statement make_toggle_inc_statement(entity toggleEnt, int val)
statement make_toggle_mmcd(entity ent)
statement make_init_newInd_stat(statement stat, entity newInd)
#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 statement_loop_p(statement)
Definition: statement.c:349
#define loop_body(x)
Definition: ri.h:1644
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define intptr_t
Definition: stdint.in.h:294

References CAR, CONS, ENTITY, gen_nconc(), gHtCurNewInd, glCurLoop, gLoopToToggleEnt, gToggleToInc, hash_get(), HASH_UNDEFINED_VALUE, intptr_t, loop_body, make_block_statement(), make_init_newInd_stat(), make_toggle_inc_statement(), make_toggle_mmcd(), MAP, NIL, pips_assert, STATEMENT, statement_loop(), statement_loop_p(), and statement_undefined.

Referenced by generate_code_loop().

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

◆ comEngine_generate_code()

statement comEngine_generate_code ( statement  stat)
Parameters
stattat

Definition at line 1187 of file comEngine_generate_code.c.

1188 {
1189  statement newStat = statement_undefined;
1190 
1191  // Initialize some global variables
1192  COM_OPT = true;
1193  gExecPut = false;
1196  glCurLoop = NIL;
1197  glCurRep = NIL;
1199  glOutEffStats = NIL;
1201 
1202  // Do the job
1203  newStat = generate_code_function(stat, false);
1204 
1205  if(statement_block_p(stat))
1206  {
1207  newStat = process_code_seq(newStat, stat);
1208  }
1209 
1210  // Add the loop indices statements
1211  if(glOutEffStats != NIL)
1212  {
1213  newStat =
1215  glOutEffStats));
1216  }
1217 
1218  // Add the toggle initialization statements
1219  if(glToggleInitStats != NIL)
1220  {
1221  newStat =
1223  CONS(STATEMENT, newStat, NIL)));
1224  }
1225 
1226  // Free some global variables
1230 
1231  return newStat;
1232 }
list glToggleInitStats
static bool gExecPut
static list glCurRep
static list glOutEffStats
hash_table gLoopToOuterInd
comEngine_generate_code.c
statement generate_code_function(statement stat, bool bCalledFromSeq)
static statement process_code_seq(statement newStat, statement stat)
static bool COM_OPT
hash_table gLoopToOpt
cproto-generated files
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
@ hash_pointer
Definition: newgen_hash.h:32
#define statement_block_p(stat)

References COM_OPT, CONS, gen_nconc(), generate_code_function(), gExecPut, gHtCurNewInd, glCurLoop, glCurRep, gLoopToOpt, gLoopToOuterInd, glOutEffStats, glToggleInitStats, hash_pointer, hash_table_free(), hash_table_make(), make_block_statement(), NIL, process_code_seq(), STATEMENT, statement_block_p, and statement_undefined.

Referenced by comEngine_generate_HRECode(), and comEngine_generate_procCode().

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

◆ comEngine_make_new_scalar_variable()

entity comEngine_make_new_scalar_variable ( const char *  prefix,
basic  bas 
)
Parameters
prefixrefix
basas

Definition at line 94 of file comEngine_generate_code.c.

96 {
97  entity retEnt = entity_undefined;
100  bas);
101  AddEntityToCurrentModule(retEnt);
102 
103  return retEnt;
104 }
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
static const char * prefix
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

References AddEntityToCurrentModule(), entity_undefined, get_current_module_entity(), make_new_scalar_variable_with_prefix(), and prefix.

Referenced by comEngine_generate_procCode(), fill_gLoopToToggleEnt(), generate_code_loop(), regenerate_toggles(), and usual_loop_tiling().

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

◆ fill_gLoopToOpt()

static void fill_gLoopToOpt ( list  lRef)
static

Definition at line 110 of file comEngine_generate_code.c.

111 {
112  if(lRef != NIL)
113  {
114  MAP(STATEMENT, loopStat,
115  {
116  hash_put(gLoopToOpt, loopStat, (void *)false);
117  }, glCurLoop);
118  }
119 }
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

References glCurLoop, gLoopToOpt, hash_put(), MAP, NIL, and STATEMENT.

Referenced by generate_code_call(), generate_code_loop(), process_code_seq(), process_opt_replace(), and usual_loop_tiling().

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

◆ fill_gLoopToToggleEnt()

static void fill_gLoopToToggleEnt ( statement  stat,
list  lRef 
)
static

Definition at line 125 of file comEngine_generate_code.c.

126 {
127  list lDone = NIL;
128 
129  // Go through the reference list attached to this loop
130  FOREACH(REFERENCE, curRef, lRef)
131  {
132  // Get the fifo number for the current reference
133  intptr_t fifoNum = (intptr_t)hash_get(gRefToFifo, curRef);
134 
135  pips_assert("fifoNum != HASH_UNDEFINED_VALUE",
136  fifoNum != (intptr_t)HASH_UNDEFINED_VALUE);
137 
138  // Get the fifo offset for the cureent reference
139  intptr_t inc = (intptr_t)hash_get(gRefToFifoOff, (void *)fifoNum);
140 
141  pips_assert("inc != HASH_UNDEFINED_VALUE",
143 
144  bool bDone = false;
145 
146  // If a toggle variable has already been created for this loop,
147  // then continue
148  MAP(INT, incDone,
149  {
150  if(inc == incDone)
151  {
152  bDone = true;
153  break;
154  }
155  }, lDone);
156 
157  if(bDone)
158  continue;
159 
160  lDone = CONS(INT, inc, lDone);
161 
162  // Create a new toggle variable
163  entity toggleEnt =
165  make_basic(is_basic_int, (void *)4));
166 
167  list lToggleEnt = hash_get(gLoopToToggleEnt, stat);
168 
169  if(lToggleEnt == HASH_UNDEFINED_VALUE)
170  {
171  lToggleEnt = NIL;
172  }
173 
174  // Store the new variable in the list of toggle variables
175  lToggleEnt = CONS(ENTITY, toggleEnt, lToggleEnt);
176 
177  hash_put(gLoopToToggleEnt, stat, lToggleEnt);
178 
179  // Associate the value corresponding to the fifo offset to the toggle
180  // variable
181  hash_put(gToggleToInc, toggleEnt, (void *)inc);
182 
183  }
184 }
basic make_basic(enum basic_utype tag, void *val)
Definition: ri.c:155
@ INT
Definition: atomic.c:48
hash_table gRefToFifoOff
hash_table gRefToFifo
entity comEngine_make_new_scalar_variable(const char *prefix, basic bas)
#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
@ is_basic_int
Definition: ri.h:571
#define REFERENCE(x)
REFERENCE.
Definition: ri.h:2296
char * strdup()

References comEngine_make_new_scalar_variable(), CONS, ENTITY, FOREACH, gLoopToToggleEnt, gRefToFifo, gRefToFifoOff, gToggleToInc, hash_get(), hash_put(), HASH_UNDEFINED_VALUE, INT, intptr_t, is_basic_int, make_basic(), MAP, NIL, pips_assert, REFERENCE, and strdup().

Referenced by generate_code_loop().

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

◆ generate_code_call()

static statement generate_code_call ( statement  stat,
bool  bCalledFromSeq 
)
static

Definition at line 998 of file comEngine_generate_code.c.

999 {
1000  //printf("generate_code_call\n");
1001  //print_statement(stat);printf("\n");
1002  statement newStat = statement_undefined;
1003 
1004  if(gGenHRE)
1005  {
1006  newStat = get_call_stat_HRE(stat);
1007  }
1008  else
1009  {
1010  newStat = get_call_stat_proc(stat);
1011  }
1012 
1013  if(COM_OPT && gGenHRE)
1014  {
1015  list lCallRef = NIL;
1016  call curCall = instruction_call(statement_instruction(stat));
1017 
1018  MAP(EXPRESSION, exp,
1019  {
1020  list old = lCallRef;
1021  list new = NIL;
1023 
1024  lCallRef = gen_concatenate(old, new);
1025 
1026  gen_free_list(old);
1027  gen_free_list(new);
1028 
1029  }, call_arguments(curCall));
1030 
1031  glCurRep = gen_nconc(glCurRep, lCallRef);
1032 
1033  if(!bCalledFromSeq)
1034  {
1035  process_opt_replace(&newStat);
1036  }
1037  }
1038 
1039  if(!get_bool_property("COMENGINE_CONTROL_IN_HRE")
1040  && !gGenHRE && !gExecPut)
1041  {
1042  newStat = add_exec_mmcd(newStat);
1043 
1044  gExecPut = true;
1045  }
1046 
1047  if(get_bool_property("COMENGINE_CONTROL_IN_HRE") &&
1048  !gExecPut)
1049  {
1050  statement stepStat;
1051 
1052  if(gGenHRE)
1053  {
1054  stepStat = make_wait_step_statement();
1055  }
1056  else
1057  {
1058  stepStat = make_step_inc_statement(1);
1059  }
1060 
1061  if(newStat == statement_undefined)
1062  {
1063  newStat = stepStat;
1064  }
1065  else
1066  {
1067  newStat =
1069  CONS(STATEMENT, newStat, NIL)));
1070  }
1071 
1072  gExecPut = true;
1073  }
1074 
1075  list lRef = hash_get(gStatToRef, stat);
1076 
1077  if(lRef == HASH_UNDEFINED_VALUE)
1078  {
1079  return newStat;
1080  }
1081 
1082  if(gGenHRE)
1083  {
1084  if(!COM_OPT)
1085  {
1087  }
1088 
1089  newStat = generate_stat_from_ref_list_HRE(lRef, newStat);
1090  }
1091  else
1092  {
1093  newStat = generate_stat_from_ref_list_proc(lRef, NIL, newStat);
1094 
1095  fill_gLoopToOpt(lRef);
1096  }
1097  printf("generate_code_call 2\n");
1098  return newStat;
1099 }
hash_table gStatToRef
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...
statement make_wait_step_statement()
statement get_call_stat_HRE(statement stat)
statement generate_stat_from_ref_list_HRE(list lRef, statement stat)
void process_replacement_HRE(list lRef, expression buffIndExp, statement *stat)
static void process_opt_replace(statement *newStat)
static void fill_gLoopToOpt(list lRef)
static statement add_exec_mmcd(statement stat)
bool gGenHRE
statement get_call_stat_proc(_UNUSED_ statement stat)
statement generate_stat_from_ref_list_proc(list lRef, list lToggleEnt, statement stat)
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
list gen_concatenate(const list l1x, const list l2x)
concatenate two lists.
Definition: list.c:436
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define expression_undefined
Definition: ri.h:1223
#define statement_instruction(x)
Definition: ri.h:2458
#define instruction_call(x)
Definition: ri.h:1529
#define call_arguments(x)
Definition: ri.h:711
int printf()
#define exp
Avoid some warnings from "gcc -Wshadow".
Definition: vasnprintf.c:207

References add_exec_mmcd(), call_arguments, COM_OPT, comEngine_expression_to_reference_list(), CONS, exp, EXPRESSION, expression_undefined, fill_gLoopToOpt(), gen_concatenate(), gen_free_list(), gen_nconc(), generate_stat_from_ref_list_HRE(), generate_stat_from_ref_list_proc(), get_bool_property(), get_call_stat_HRE(), get_call_stat_proc(), gExecPut, gGenHRE, glCurRep, gStatToRef, hash_get(), HASH_UNDEFINED_VALUE, instruction_call, make_block_statement(), make_step_inc_statement(), make_wait_step_statement(), MAP, NIL, printf(), process_opt_replace(), process_replacement_HRE(), STATEMENT, statement_instruction, and statement_undefined.

Referenced by generate_code_function().

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

◆ generate_code_function()

statement generate_code_function ( statement  stat,
bool  bCalledFromSeq 
)
Parameters
stattat
bCalledFromSeqCalledFromSeq

Definition at line 1137 of file comEngine_generate_code.c.

1138 {
1139  statement newStat = statement_undefined;
1140 
1141  instruction instr = statement_instruction(stat);
1142 
1143  switch(instruction_tag(instr))
1144  {
1146  {
1147  newStat = generate_code_seq(stat);
1148 
1149  break;
1150  }
1151  case is_instruction_loop:
1152  {
1153  newStat = generate_code_loop(stat);
1154  break;
1155  }
1156  case is_instruction_call:
1157  {
1158  newStat = generate_code_call(stat, bCalledFromSeq);
1159  break;
1160  }
1161  case is_instruction_test:
1162  {
1163  if(gGenHRE)
1164  {
1165  newStat = generate_code_test_HRE(stat);
1166  }
1167  else
1168  {
1169  newStat = generate_code_test_proc(stat);
1170  }
1171  break;
1172  }
1173  default:
1174  {
1175  pips_assert("FALSE", false);
1176  break;
1177  }
1178  }
1179 
1180  return newStat;
1181 }
statement generate_code_test_HRE(statement stat)
static statement generate_code_loop(statement stat)
static statement generate_code_call(statement stat, bool bCalledFromSeq)
static statement generate_code_seq(statement stat)
statement generate_code_test_proc(statement stat)
@ 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 generate_code_call(), generate_code_loop(), generate_code_seq(), generate_code_test_HRE(), generate_code_test_proc(), gGenHRE, instruction_tag, is_instruction_call, is_instruction_loop, is_instruction_sequence, is_instruction_test, pips_assert, statement_instruction, and statement_undefined.

Referenced by comEngine_generate_code(), generate_code_loop(), generate_code_seq(), generate_code_test_HRE(), and generate_code_test_proc().

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

◆ generate_code_loop()

static statement generate_code_loop ( statement  stat)
static

Definition at line 501 of file comEngine_generate_code.c.

502 {
503  printf("generate_code_loop\n");
504  print_statement(stat);
505 
506  statement newBody = statement_undefined;
507 
508  list lStats = NIL;
509 
510  hash_table htOffset = hash_get(gStatToHtOffset, stat);
511 
512  if(!gGenHRE)
513  {
514  pips_assert("htOffset != HASH_UNDEFINED_VALUE",
515  htOffset != HASH_UNDEFINED_VALUE);
516  }
517 
518  loop curLoop = statement_loop(stat);
519 
520  list lRef = hash_get(gLoopToRef, stat);
521 
522  if(lRef == HASH_UNDEFINED_VALUE)
523  {
524  lRef = NIL;
525  }
526 
527  list lSupportedRef = NIL;
528  list lUnSupportedRef = NIL;
529 
530  // Store the list of supported and unsupported references for loop
531  // statement stat.
533  &lSupportedRef, &lUnSupportedRef);
534 
535  // Create a new index
536  entity newOuterInd =
538  copy_basic(entity_basic(loop_index(curLoop))));
539 
540  // Memorize the index created in the hash_table gLoopToOuterInd
541  hash_put(gLoopToOuterInd, stat, newOuterInd);
542 
543  // Create a new index
544  entity newInnerInd =
546  copy_basic(entity_basic(loop_index(curLoop))));
547 
548  // If we are generating the MMCD code, then create the fifos for the
549  // supported and unsupported references
550  if(!gGenHRE)
551  {
552  create_realFifo_proc(stat, lSupportedRef);
553  create_realFifo_proc(stat, lUnSupportedRef);
554  }
555 
556  // Create the toggle references and store them in gLoopToToggleEnt
557  fill_gLoopToToggleEnt(stat, lSupportedRef);
558  fill_gLoopToToggleEnt(loop_body(statement_loop(stat)), lUnSupportedRef);
559 
560  // Add the loop to the current loops list
561  glCurLoop = CONS(STATEMENT, stat, glCurLoop);
562 
563  // Memorize the current newInnerInd in gHtCurNewInd
564  hash_put(gHtCurNewInd, stat, newInnerInd);
565 
566  hash_put(gLoopToOpt, stat, (void *)true);
567 
568  gExecPut = false;
569 
570  // Get the new statements for the loop body
571  newBody = generate_code_function(loop_body(curLoop), false);
572 
573  gExecPut = false;
574 
575  printf("newBody real\n");
576  if(newBody == statement_undefined)
577  {
578  printf("undefined\n");
579  }
580  else
581  {
582  print_statement(newBody);
583  }
584 
585  // If there are some supported references, the let us perform a loop
586  // tiling operation
587  if(lSupportedRef != NIL)
588  {
589  expression bufferSizeExp = expression_undefined;
590 
591  bufferSizeExp = copy_expression(gBufferSizeEnt);
592 
593  statement newStat = usual_loop_tiling(stat, newBody,
594  lSupportedRef, lUnSupportedRef,
595  htOffset, bufferSizeExp,
596  newOuterInd, newInnerInd);
597 
598  list lToggleEnt = hash_get(gLoopToToggleEnt, stat);
599 
600  if(lToggleEnt != HASH_UNDEFINED_VALUE)
601  {
602  printf("put lToggleEnt\n");
603  print_statement(newStat);
604  hash_put(gLoopToToggleEnt, newStat, gen_copy_seq(lToggleEnt));
605  }
606 
607  lStats = CONS(STATEMENT, newStat, NIL);
608 
609  if(!gGenHRE)
610  {
612  }
613  }
614  // else if the new body is not undefined, then just create a loop without
615  // loop tiling
616  else if(newBody != statement_undefined)
617  {
618  // If there are some unsupported references, then let us add some
619  // statements to the code to support them
620  if(lUnSupportedRef != NIL)
621  {
622  // Let us do what needs to be done to handle the references list
623  if(gGenHRE)
624  {
625  if(!COM_OPT)
626  {
627  process_replacement_HRE(lUnSupportedRef, expression_undefined, &newBody);
628  }
629 
630  newBody = generate_stat_from_ref_list_HRE(lUnSupportedRef, newBody);
631  }
632  else
633  {
634  list lToggleEnt = hash_get(gLoopToToggleEnt,
635  loop_body(statement_loop(stat)));
636 
637  if(lToggleEnt == HASH_UNDEFINED_VALUE)
638  {
639  lToggleEnt = NIL;
640  }
641 
642  newBody = generate_stat_from_ref_list_proc(lUnSupportedRef,
643  lToggleEnt,
644  newBody);
645 
646  fill_gLoopToOpt(lUnSupportedRef);
647  }
648  }
649 
650  // The following lines create the loop
651  loop outerLoop = make_loop(newInnerInd,
652  copy_range(loop_range(curLoop)),
653  newBody,
654  loop_label(curLoop),
656  NIL);
657 
662  make_instruction_loop(outerLoop),NIL,NULL,
664 
665  lStats = CONS(STATEMENT, newStat, NIL);
666 
668  make_reference(loop_index(curLoop), NIL),
669  entity_to_expression(newInnerInd));
670 
671  if(!gGenHRE)
672  {
674  }
675  }
676  else
677  {
678  return make_block_statement(NIL);
679  }
680 
681  if(!gGenHRE)
682  {
683  add_toggle_inc_statements(stat, lStats);
684 
686  }
687 
688  //pips_assert("newStat != statement_undefined",
689  //newStat != statement_undefined);
690 
691  // If some references attached to the loop statement but are not
692  // some supported or unsupported references, then let us handle them
693  list lOutRef = hash_get(gStatToRef, stat);
694 
695  if(lOutRef != HASH_UNDEFINED_VALUE)
696  {
697  // Let us do what needs to be done to handle the references list
698  if(gGenHRE)
699  {
700  if(!COM_OPT)
701  {
702  lStats = process_replacement_HRE_OutRef(lOutRef, lStats);
703  }
704 
705  lStats = generate_stat_from_ref_list_HRE_list(lOutRef, lStats);
706  }
707  else
708  {
709  lStats = generate_stat_from_ref_list_proc_list(lOutRef, lStats);
710 
711  fill_gLoopToOpt(lOutRef);
712  }
713  }
714 
715  // Add some bubbles in the pipeline if needed
716  if(gGenHRE)
717  {
718  lStats = process_gLoopToSync_HRE(stat, lStats);
719 
720  //fill_gLoopToOpt(!NIL);
721  }
722  else
723  {
724  lStats = process_gLoopToSync_proc(stat, lStats);
725 
726  //fill_gLoopToOpt(!NIL);
727  }
728 
729  if(!gGenHRE)
730  {
731  hash_table_free(htOffset);
732  }
733 
734  // Remove the loop statement to the current loops list
735  gen_remove(&glCurLoop, stat);
736 
737  statement newStat = make_block_statement(lStats);
738 
739  printf("newStat real\n");
740  if(newStat == statement_undefined)
741  {
742  printf("newStat == statement_undefined\n");
743  }
744  else
745  {
746  print_statement(newStat);
747  }
748 
749  hash_put(gIsNewLoop, newStat, (void *)true);
750 
751  return newStat;
752 }
instruction make_instruction_loop(loop _field_)
Definition: ri.c:1175
execution make_execution(enum execution_utype tag, void *val)
Definition: ri.c:838
range copy_range(range p)
RANGE.
Definition: ri.c:2005
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
reference make_reference(entity a1, list a2)
Definition: ri.c:2083
hash_table gIsNewLoop
expression gBufferSizeEnt
hash_table gLoopToRef
comEngine_distribute.c
hash_table gStatToHtOffset
void get_supportedRef_HRE(statement stat, list *lSupportedRef, list *lUnSupportedRef)
list process_gLoopToSync_HRE(statement stat, list lInStats)
list generate_stat_from_ref_list_HRE_list(list lRef, list lInStats)
list process_replacement_HRE_OutRef(list lRef, list lStats)
static void fill_gLoopToToggleEnt(statement stat, list lRef)
static statement usual_loop_tiling(statement stat, statement newBody, list lSupportedRef, list lUnSupportedRef, hash_table htOffset, expression bufferSizeExp, entity newOuterInd, entity newInnerInd)
static void update_toggle_init_stats_list(statement stat)
static void add_toggle_inc_statements(statement stat, list lInStats)
void comEngine_replace_reference_in_stat(statement stat, reference ref, expression new)
list generate_stat_from_ref_list_proc_list(list lRef, list lInStats)
list process_gLoopToSync_proc(statement stat, list lInStats)
list add_index_out_effect_proc(loop curLoop, list lStats)
void create_realFifo_proc(statement stat, list lRef)
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
list gen_copy_seq(list l)
Copy a list structure.
Definition: list.c:501
#define UU
Definition: newgen_types.h:98
void print_statement(statement)
Print a statement on stderr.
Definition: statement.c:98
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
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
#define loop_label(x)
Definition: ri.h:1646
@ is_execution_sequential
Definition: ri.h:1189
#define loop_index(x)
Definition: ri.h:1640

References add_index_out_effect_proc(), add_toggle_inc_statements(), COM_OPT, comEngine_make_new_scalar_variable(), comEngine_replace_reference_in_stat(), CONS, copy_basic(), copy_expression(), copy_range(), create_realFifo_proc(), empty_comments, empty_extensions(), entity_basic(), entity_empty_label(), entity_local_name(), entity_to_expression(), expression_undefined, fill_gLoopToOpt(), fill_gLoopToToggleEnt(), gBufferSizeEnt, gen_copy_seq(), gen_remove(), generate_code_function(), generate_stat_from_ref_list_HRE(), generate_stat_from_ref_list_HRE_list(), generate_stat_from_ref_list_proc(), generate_stat_from_ref_list_proc_list(), get_supportedRef_HRE(), gExecPut, gGenHRE, gHtCurNewInd, gIsNewLoop, glCurLoop, gLoopToOpt, gLoopToOuterInd, gLoopToRef, gLoopToToggleEnt, glOutEffStats, gStatToHtOffset, gStatToRef, hash_get(), hash_put(), hash_table_free(), HASH_UNDEFINED_VALUE, is_execution_sequential, loop_body, loop_index, loop_label, loop_range, make_block_statement(), make_execution(), make_instruction_loop(), make_loop(), make_reference(), make_statement(), make_synchronization_none(), NIL, pips_assert, print_statement(), printf(), process_gLoopToSync_HRE(), process_gLoopToSync_proc(), process_replacement_HRE(), process_replacement_HRE_OutRef(), STATEMENT, statement_loop(), STATEMENT_NUMBER_UNDEFINED, STATEMENT_ORDERING_UNDEFINED, statement_undefined, update_toggle_init_stats_list(), usual_loop_tiling(), and UU.

Referenced by generate_code_function().

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

◆ generate_code_seq()

static statement generate_code_seq ( statement  stat)
static

Definition at line 865 of file comEngine_generate_code.c.

866 {
867  statement newStat = statement_undefined;
868 
869  instruction instr = statement_instruction(stat);
870 
871  list lSeq = NIL;
872  list lTempSeq = NIL;
873  list lPrevSeq = NIL;
874 
875  //printf("generate_code_seq\n");
876 
877  // Go through each statement of the sequence
878  MAP(STATEMENT, curStat,
879  {
880  if((COM_OPT && gGenHRE)&& !statement_call_p(curStat) &&
881  !statement_test_p(curStat))
882  {
883  lSeq = replace_glCurRep_in_seq(lTempSeq, lPrevSeq, lSeq);
884 
885  lTempSeq = NIL;
886  }
887 
888  // Let us get the new statement for the current sequence statement
889  statement seqNewStat = generate_code_function(curStat, true);
890 
891  if(seqNewStat != statement_undefined)
892  {
893  list newStatCons = CONS(STATEMENT, seqNewStat, NIL);
894 
895  lSeq = gen_nconc(lSeq, newStatCons);
896 
897  if((COM_OPT && gGenHRE)&&!statement_call_p(curStat) &&
898  !statement_test_p(curStat))
899  {
900  lPrevSeq = newStatCons;
901  }
902 
903  if((COM_OPT && gGenHRE)&&(lTempSeq == NIL) &&
904  (statement_call_p(curStat) ||
905  statement_test_p(curStat)))
906  {
907  lTempSeq = newStatCons;
908  }
909  }
910 
912 
913  if(COM_OPT && gGenHRE)
914  {
915  lSeq = replace_glCurRep_in_seq(lTempSeq, lPrevSeq, lSeq);
916  }
917 
918  if(lSeq == NIL)
919  {
920  newStat = statement_undefined;
921  }
922  else if(gen_length(lSeq) == 1)
923  {
924  newStat = STATEMENT(CAR(lSeq));
925  }
926  else
927  {
928  newStat = make_block_statement(lSeq);
929  }
930 
931  return newStat;
932 }
static list replace_glCurRep_in_seq(list lStats, list lPrevSeq, list lSeq)
size_t gen_length(const list l)
Definition: list.c:150
bool statement_test_p(statement)
Definition: statement.c:343
bool statement_call_p(statement)
Definition: statement.c:364
#define sequence_statements(x)
Definition: ri.h:2360
#define instruction_sequence(x)
Definition: ri.h:1514

References CAR, COM_OPT, CONS, gen_length(), gen_nconc(), generate_code_function(), gGenHRE, instruction_sequence, make_block_statement(), MAP, NIL, replace_glCurRep_in_seq(), sequence_statements, STATEMENT, statement_call_p(), statement_instruction, statement_test_p(), and statement_undefined.

Referenced by generate_code_function().

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

◆ make_loopStat1()

static statement make_loopStat1 ( statement  stat,
entity  transferSize,
statement  innerStat,
entity  newOuterInd,
list  lSupportedRef,
hash_table  htOffset,
expression  bufferSizeExp,
entity  newInnerInd 
)
static

Definition at line 297 of file comEngine_generate_code.c.

301 {
302  loop curLoop = statement_loop(stat);
303 
304  if(innerStat != statement_undefined)
305  {
306  expression indExp = entity_to_expression(newInnerInd);
307 
308  // If we are generating the HRE code, then replace the references by
309  // the private HRE references
310  if(gGenHRE)
311  {
312  if(!COM_OPT)
313  {
314  process_replacement_HRE(lSupportedRef, indExp, &loop_body(statement_loop(innerStat)));
315  }
316  }
317 
318  free_expression(indExp);
319  }
320 
321  // Add some statements to the innerStat
322  list lStats = NIL;
323  if(gGenHRE)
324  {
325  lStats = make_loop_lStats_HRE(stat, transferSize,
326  innerStat, newOuterInd,
327  lSupportedRef, htOffset,
328  bufferSizeExp);
329  }
330  else
331  {
332  lStats = make_loop_lStats_proc(stat, transferSize,
333  innerStat, newOuterInd,
334  lSupportedRef, htOffset,
335  bufferSizeExp);
336  }
337 
338  innerStat = make_block_statement(lStats);
339 
340  // The following lines create the outer loop of the loop tiling
341  // operation
342  range outerRange1 = make_range(copy_expression(range_lower(loop_range(curLoop))),
344  copy_expression(bufferSizeExp));
345 
346  loop outerLoop1 = make_loop(newOuterInd,
347  outerRange1,
348  innerStat,
349  loop_label(curLoop),
351  NIL);
352 
357  make_instruction_loop(outerLoop1),NIL,NULL,
359 }
void free_expression(expression p)
Definition: ri.c:853
range make_range(expression a1, expression a2, expression a3)
Definition: ri.c:2041
list make_loop_lStats_HRE(statement stat, entity transferSize, statement innerStat, entity newOuterInd, _UNUSED_ list lSupportedRef, _UNUSED_ hash_table htOffset, expression bufferSizeExp)
list make_loop_lStats_proc(statement stat, entity transferSize, statement innerStat, entity newOuterInd, list lSupportedRef, hash_table htOffset, expression bufferSizeExp)
#define range_upper(x)
Definition: ri.h:2290

References COM_OPT, copy_expression(), empty_comments, empty_extensions(), entity_empty_label(), entity_to_expression(), free_expression(), gGenHRE, is_execution_sequential, loop_body, loop_label, loop_range, make_block_statement(), make_execution(), make_instruction_loop(), make_loop(), make_loop_lStats_HRE(), make_loop_lStats_proc(), make_range(), make_statement(), make_synchronization_none(), NIL, process_replacement_HRE(), range_lower, range_upper, statement_loop(), STATEMENT_NUMBER_UNDEFINED, STATEMENT_ORDERING_UNDEFINED, statement_undefined, and UU.

Referenced by usual_loop_tiling().

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

◆ make_toggle_inc_statement()

statement make_toggle_inc_statement ( entity  toggleEnt,
int  val 
)
Parameters
toggleEntoggleEnt
valal

Definition at line 222 of file comEngine_generate_code.c.

223 {
225  entity_to_expression(toggleEnt),
226  int_to_expression(val),
227  NULL);
228 
229  expression modExp =
231  modArg));
232 
234  modExp);
235 }
statement make_assign_statement(expression, expression)
Definition: statement.c:583
#define C_MODULO_OPERATOR_NAME
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

References C_MODULO_OPERATOR_NAME, call_to_expression(), entity_intrinsic(), entity_to_expression(), expression_domain, gen_make_list(), int_to_expression(), make_assign_statement(), and make_call().

Referenced by add_toggle_inc_statements(), and regenerate_toggles().

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

◆ make_toggle_init_statement()

statement make_toggle_init_statement ( entity  toggleEnt)
Parameters
toggleEntoggleEnt

Definition at line 189 of file comEngine_generate_code.c.

190 {
192  int_to_expression(0));
193 }

References entity_to_expression(), int_to_expression(), and make_assign_statement().

Referenced by regenerate_toggles(), and update_toggle_init_stats_list().

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

◆ process_code_seq()

static statement process_code_seq ( statement  newStat,
statement  stat 
)
static

Definition at line 1105 of file comEngine_generate_code.c.

1106 {
1107  list lRef = hash_get(gStatToRef, stat);
1108 
1109  if(lRef == HASH_UNDEFINED_VALUE)
1110  {
1111  return newStat;
1112  }
1113 
1114  if(gGenHRE)
1115  {
1116  if(!COM_OPT)
1117  {
1119  }
1120 
1121  newStat = generate_stat_from_ref_list_HRE(lRef, newStat);
1122  }
1123  else
1124  {
1125  newStat = generate_stat_from_ref_list_proc(lRef, NIL, newStat);
1126 
1127  fill_gLoopToOpt(lRef);
1128  }
1129 
1130  return newStat;
1131 }

References COM_OPT, expression_undefined, fill_gLoopToOpt(), generate_stat_from_ref_list_HRE(), generate_stat_from_ref_list_proc(), gGenHRE, gStatToRef, hash_get(), HASH_UNDEFINED_VALUE, NIL, and process_replacement_HRE().

Referenced by comEngine_generate_code().

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

◆ process_opt_replace()

static void process_opt_replace ( statement newStat)
static

Definition at line 799 of file comEngine_generate_code.c.

800 {
801  MAP(STATEMENT, loopStat,
802  {
803  list lIn = NIL;
804 
805  process_ref_lists(loopStat, &lIn);
806 
807  entity curNewInd = hash_get(gHtCurNewInd, loopStat);
808 
809  pips_assert("curNewInd != HASH_UNDEFINED_VALUE",
810  curNewInd != HASH_UNDEFINED_VALUE);
811 
812  expression indExp = entity_to_expression(curNewInd);
813 
814  process_replacement_HRE(lIn, indExp, newStat);
815 
816  free_expression(indExp);
817 
818  gen_free_list(lIn);
819 
820  }, glCurLoop);
821 
823 
825 
827  glCurRep = NIL;
828 }
static void process_ref_lists(statement stat, list *lInRef)

References entity_to_expression(), expression_undefined, fill_gLoopToOpt(), free_expression(), gen_free_list(), gHtCurNewInd, glCurLoop, glCurRep, hash_get(), HASH_UNDEFINED_VALUE, MAP, NIL, pips_assert, process_ref_lists(), process_replacement_HRE(), and STATEMENT.

Referenced by generate_code_call(), and replace_glCurRep_in_seq().

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

◆ process_ref_lists()

static void process_ref_lists ( statement  stat,
list lInRef 
)
static

Definition at line 758 of file comEngine_generate_code.c.

759 {
760  list lRef = NIL;
761 
762  lRef = hash_get(gLoopToSupRef, stat);
763 
764  if(lRef == HASH_UNDEFINED_VALUE)
765  {
766  lRef = NIL;
767  }
768 
769  MAP(REFERENCE, curRef,
770  {
771  bool bInRef = false;
772 
773  MAP(REFERENCE, supRef,
774  {
775  if(reference_equal_p(curRef, supRef))
776  {
777  bInRef = true;
778  break;
779  }
780  }, lRef);
781 
782  if(bInRef)
783  {
784  *lInRef = CONS(REFERENCE, curRef, *lInRef);
785  }
786 
787  }, glCurRep);
788 
789  MAP(REFERENCE, curRef,
790  {
791  gen_remove(&glCurRep, curRef);
792  }, *lInRef);
793 }
hash_table gLoopToSupRef
bool reference_equal_p(reference r1, reference r2)
Definition: expression.c:1500

References CONS, gen_remove(), glCurRep, gLoopToSupRef, hash_get(), HASH_UNDEFINED_VALUE, MAP, NIL, REFERENCE, and reference_equal_p().

Referenced by process_opt_replace().

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

◆ replace_glCurRep_in_seq()

static list replace_glCurRep_in_seq ( list  lStats,
list  lPrevSeq,
list  lSeq 
)
static

Definition at line 834 of file comEngine_generate_code.c.

835 {
836  list newLStats = NIL;
837 
838  if(lStats == NIL)
839  {
840  return lSeq;
841  }
842 
843  statement newStat = make_block_statement(lStats);
844 
845  process_opt_replace(&newStat);
846 
847  newLStats = CONS(STATEMENT, newStat, NIL);
848 
849  if(lPrevSeq != NIL)
850  {
851  CDR(lPrevSeq) = newLStats;
852  }
853  else
854  {
855  lSeq = newLStats;
856  }
857 
858  return lSeq;
859 }
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111

References CDR, CONS, make_block_statement(), NIL, process_opt_replace(), and STATEMENT.

Referenced by generate_code_seq().

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

◆ update_toggle_init_stats_list()

static void update_toggle_init_stats_list ( statement  stat)
static

Definition at line 198 of file comEngine_generate_code.c.

199 {
200  list lToggleEnt = hash_get(gLoopToToggleEnt, stat);
201 
202  pips_assert("lToggleEnt != HASH_UNDEFINED_VALUE",
203  lToggleEnt != HASH_UNDEFINED_VALUE);
204 
205  list lStats = NIL;
206 
207  MAP(ENTITY, toggleEnt,
208  {
209  // Create an initialization statement for the curren toggle variable
210  statement toggleStat = make_toggle_init_statement(toggleEnt);
211 
212  lStats = gen_nconc(lStats, CONS(STATEMENT, toggleStat, NIL));
213  }, lToggleEnt);
214 
216 }
statement make_toggle_init_statement(entity toggleEnt)

References CONS, ENTITY, gen_nconc(), gLoopToToggleEnt, glToggleInitStats, hash_get(), HASH_UNDEFINED_VALUE, make_toggle_init_statement(), MAP, NIL, pips_assert, and STATEMENT.

Referenced by generate_code_loop().

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

◆ usual_loop_tiling()

static statement usual_loop_tiling ( statement  stat,
statement  newBody,
list  lSupportedRef,
list  lUnSupportedRef,
hash_table  htOffset,
expression  bufferSizeExp,
entity  newOuterInd,
entity  newInnerInd 
)
static

Definition at line 393 of file comEngine_generate_code.c.

397 {
398  loop curLoop = statement_loop(stat);
399 
400  statement innerStat1 = statement_undefined;
401 
402  statement loopStat1 = statement_undefined;
403 
404  entity transferSize =
406  make_basic(is_basic_int, (void*)4));
407 
408  // If the new body is not undefined, then create the inner loop.
409  if((newBody != statement_undefined) ||
410  (lUnSupportedRef != NIL))
411  {
412  // If there are some unsupported references, then let us add some
413  // statements to the code to support them
414  if(lUnSupportedRef != NIL)
415  {
416  // Let us do what needs to be done to handle the references list
417  if(gGenHRE)
418  {
419  if(!COM_OPT)
420  {
421  process_replacement_HRE(lUnSupportedRef, expression_undefined, &newBody);
422  }
423 
424  newBody = generate_stat_from_ref_list_HRE(lUnSupportedRef, newBody);
425  }
426  else
427  {
428  list lToggleEnt = hash_get(gLoopToToggleEnt,
429  loop_body(statement_loop(stat)));
430 
431  if(lToggleEnt == HASH_UNDEFINED_VALUE)
432  {
433  lToggleEnt = NIL;
434  }
435 
436  newBody = generate_stat_from_ref_list_proc(lUnSupportedRef,
437  lToggleEnt,
438  newBody);
439 
440  fill_gLoopToOpt(lUnSupportedRef);
441  }
442  }
443  else if(newBody == statement_undefined)
444  {
445  newBody = make_block_statement(NIL);
446  }
447 
448  //newBody = make_init_prev_ind(newBody);
449 
450  // The following lines create the inner loop of the loop tiling
451  // operation
452  range innerRange = make_range(int_to_expression(0),
453  entity_to_expression(transferSize),
454  int_to_expression(1));
455 
456  loop innerLoop = make_loop(newInnerInd,
457  innerRange,
458  newBody,
459  loop_label(curLoop),
461  NIL);
462 
463  innerStat1 = make_statement(entity_empty_label(),
467  make_instruction_loop(innerLoop),NIL,NULL,
469 
470  if(!gGenHRE)
471  {
472  process_innerStat1_proc(innerStat1, loop_index(curLoop),
473  newOuterInd, newInnerInd);
474  }
475 
476  //printf("innerStat1\n");
477  //print_statement(innerStat1);
478 
479  // Let us try and see if we can optimize the transfers
480  if(COM_OPT)
481  {
482  innerStat1 = comEngine_opt_loop_interchange(stat, innerStat1,
483  newOuterInd);
484  }
485 
486  }
487 
488  // This function finishes the loop tiling operation
489  loopStat1 = make_loopStat1(stat, transferSize,
490  innerStat1, newOuterInd,
491  lSupportedRef, htOffset,
492  bufferSizeExp, newInnerInd);
493 
494  return loopStat1;
495 }
static statement make_loopStat1(statement stat, entity transferSize, statement innerStat, entity newOuterInd, list lSupportedRef, hash_table htOffset, expression bufferSizeExp, entity newInnerInd)
void process_innerStat1_proc(statement stat, entity oldInd, entity newOuterInd, entity newInnerInd)
statement comEngine_opt_loop_interchange(statement stat, statement innerStat, entity newInd)

References COM_OPT, comEngine_make_new_scalar_variable(), comEngine_opt_loop_interchange(), empty_comments, empty_extensions(), entity_empty_label(), entity_to_expression(), expression_undefined, fill_gLoopToOpt(), generate_stat_from_ref_list_HRE(), generate_stat_from_ref_list_proc(), gGenHRE, gLoopToToggleEnt, hash_get(), HASH_UNDEFINED_VALUE, int_to_expression(), is_basic_int, is_execution_sequential, loop_body, loop_index, loop_label, make_basic(), make_block_statement(), make_execution(), make_instruction_loop(), make_loop(), make_loopStat1(), make_range(), make_statement(), make_synchronization_none(), NIL, process_innerStat1_proc(), process_replacement_HRE(), statement_loop(), STATEMENT_NUMBER_UNDEFINED, STATEMENT_ORDERING_UNDEFINED, statement_undefined, strdup(), and UU.

Referenced by generate_code_loop().

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

Variable Documentation

◆ COM_OPT

◆ gExecPut

bool gExecPut
static

◆ gGenHRE

◆ gHtCurNewInd

◆ glCurLoop

◆ glCurRep

◆ gLoopToOuterInd

◆ glOutEffStats

list glOutEffStats = NIL
static

Definition at line 83 of file comEngine_generate_code.c.

Referenced by comEngine_generate_code(), and generate_code_loop().

◆ glToggleInitStats

list glToggleInitStats