proplong.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. /**************************************************************************
  2. * File : propLong.c
  3. * Purpose: propagate the value of long variables (local variables and
  4. * registers) along the graph. Structure the graph in this way.
  5. * (C) Cristina Cifuentes
  6. **************************************************************************/
  7. #include <string.h>
  8. #include <memory.h>
  9. #include <cassert>
  10. #include <algorithm>
  11. #include "dcc.h"
  12. /* Returns whether the given icode opcode is within the range of valid
  13. * high-level conditional jump icodes (iJB..iJG) */
  14. static boolT isJCond (llIcode opcode)
  15. {
  16. if ((opcode >= iJB) && (opcode <= iJG))
  17. return true;
  18. return false;
  19. }
  20. /* Returns whether the conditions for a 2-3 long variable are satisfied */
  21. static bool isLong23 (BB * pbb, iICODE &off, int *arc)
  22. {
  23. BB * t, * e, * obb2;
  24. if (pbb->nodeType != TWO_BRANCH)
  25. return false;
  26. t = pbb->edges[THEN].BBptr;
  27. e = pbb->edges[ELSE].BBptr;
  28. /* Check along the THEN path */
  29. if ((t->size() == 1) && (t->nodeType == TWO_BRANCH) && (t->inEdges.size() == 1))
  30. {
  31. obb2 = t->edges[THEN].BBptr;
  32. if ((obb2->size() == 2) && (obb2->nodeType == TWO_BRANCH) && (obb2->front().ll()->getOpcode() == iCMP))
  33. {
  34. off = obb2->begin();//std::distance(iter,obb2->begin2());
  35. *arc = THEN;
  36. return true;
  37. }
  38. }
  39. /* Check along the ELSE path */
  40. else if ((e->size() == 1) && (e->nodeType == TWO_BRANCH) && (e->inEdges.size() == 1))
  41. {
  42. obb2 = e->edges[THEN].BBptr;
  43. if ((obb2->size() == 2) && (obb2->nodeType == TWO_BRANCH) && (obb2->front().ll()->getOpcode() == iCMP))
  44. {
  45. off = obb2->begin();//std::distance(iter,obb2->begin2());//obb2->front().loc_ip - i;
  46. *arc = ELSE;
  47. return true;
  48. }
  49. }
  50. return false;
  51. }
  52. /* Returns whether the conditions for a 2-2 long variable are satisfied */
  53. static boolT isLong22 (iICODE pIcode, iICODE pEnd, iICODE &off)
  54. {
  55. iICODE initial_icode=pIcode;
  56. if(distance(pIcode,pEnd)<4)
  57. return false;
  58. // preincrement because pIcode is not checked here
  59. iICODE icodes[] = { ++pIcode,++pIcode,++pIcode };
  60. if ( icodes[1]->ll()->match(iCMP) &&
  61. (isJCond ((llIcode)icodes[0]->ll()->getOpcode())) &&
  62. (isJCond ((llIcode)icodes[2]->ll()->getOpcode())))
  63. {
  64. off = initial_icode;
  65. advance(off,2);
  66. return true;
  67. }
  68. return false;
  69. }
  70. /** Creates a long conditional <=, >=, <, or > at (pIcode+1).
  71. * Removes excess nodes from the graph by flagging them, and updates
  72. * the new edges for the remaining nodes.
  73. * @return number of ICODEs to skip
  74. */
  75. static int longJCond23 (Assignment &asgn, iICODE pIcode, int arc, iICODE atOffset)
  76. {
  77. BB * pbb, * obb1, * obb2, * tbb;
  78. int skipped_insn=0;
  79. if (arc == THEN)
  80. {
  81. /* Find intermediate basic blocks and target block */
  82. pbb = pIcode->getParent();
  83. obb1 = pbb->edges[THEN].BBptr;
  84. obb2 = obb1->edges[THEN].BBptr;
  85. tbb = obb2->edges[THEN].BBptr;
  86. /* Modify out edge of header basic block */
  87. pbb->edges[THEN].BBptr = tbb;
  88. /* Modify in edges of target basic block */
  89. auto newlast=std::remove_if(tbb->inEdges.begin(),tbb->inEdges.end(),
  90. [obb1,obb2](BB *b) -> bool {
  91. return (b==obb1) || (b==obb2); });
  92. tbb->inEdges.erase(newlast,tbb->inEdges.end());
  93. tbb->inEdges.push_back(pbb); /* looses 2 arcs, gains 1 arc */
  94. /* Modify in edges of the ELSE basic block */
  95. tbb = pbb->edges[ELSE].BBptr;
  96. auto iter=std::find(tbb->inEdges.begin(),tbb->inEdges.end(),obb2);
  97. assert(iter!=tbb->inEdges.end());
  98. tbb->inEdges.erase(iter); /* looses 1 arc */
  99. /* Update icode index */
  100. skipped_insn = 5;
  101. }
  102. else /* ELSE arc */
  103. {
  104. /* Find intermediate basic blocks and target block */
  105. pbb = pIcode->getParent();
  106. obb1 = pbb->edges[ELSE].BBptr;
  107. obb2 = obb1->edges[THEN].BBptr;
  108. tbb = obb2->edges[THEN].BBptr;
  109. /* Modify in edges of target basic block */
  110. auto iter=std::find(tbb->inEdges.begin(),tbb->inEdges.end(),obb2);
  111. assert(iter!=tbb->inEdges.end());
  112. tbb->inEdges.erase(iter); /* looses 1 arc */
  113. /* Modify in edges of the ELSE basic block */
  114. tbb = obb2->edges[ELSE].BBptr;
  115. auto newlast=std::remove_if(tbb->inEdges.begin(),tbb->inEdges.end(),
  116. [obb1,obb2](BB *b) -> bool { return (b==obb1) || (b==obb2); });
  117. tbb->inEdges.erase(newlast,tbb->inEdges.end());
  118. tbb->inEdges.push_back(pbb); /* looses 2 arcs, gains 1 arc */
  119. /* Modify out edge of header basic block */
  120. pbb->edges[ELSE].BBptr = tbb;
  121. /* Update icode index */
  122. skipped_insn = 2;
  123. }
  124. iICODE atOffset1(atOffset),next1(++iICODE(pIcode));
  125. advance(atOffset1,1);
  126. /* Create new HLI_JCOND and condition */
  127. asgn.lhs = COND_EXPR::boolOp (asgn.lhs, asgn.rhs, condOpJCond[atOffset1->ll()->getOpcode()-iJB]);
  128. next1->setJCond(asgn.lhs);
  129. next1->copyDU(*pIcode, eUSE, eUSE);
  130. next1->du.use |= atOffset->du.use;
  131. /* Update statistics */
  132. obb1->flg |= INVALID_BB;
  133. obb2->flg |= INVALID_BB;
  134. stats.numBBaft -= 2;
  135. pIcode->invalidate();
  136. obb1->front().invalidate();
  137. // invalidate 2 first instructions of BB 2
  138. iICODE ibb2 = obb2->begin();
  139. (ibb2++)->invalidate();
  140. (ibb2++)->invalidate();
  141. return skipped_insn;
  142. }
  143. /** Creates a long conditional equality or inequality at (pIcode+1).
  144. * Removes excess nodes from the graph by flagging them, and updates
  145. * the new edges for the remaining nodes.
  146. * @return number of ICODE's to skip
  147. */
  148. static int longJCond22 (Assignment &asgn, iICODE pIcode,iICODE pEnd)
  149. {
  150. BB * pbb, * obb1, * tbb;
  151. if(distance(pIcode,pEnd)<4)
  152. return false;
  153. // preincrement because pIcode is not checked here
  154. iICODE icodes[] = { pIcode++,pIcode++,pIcode++,pIcode++ };
  155. /* Form conditional expression */
  156. asgn.lhs = COND_EXPR::boolOp (asgn.lhs, asgn.rhs, condOpJCond[icodes[3]->ll()->getOpcode() - iJB]);
  157. icodes[1]->setJCond(asgn.lhs);
  158. icodes[1]->copyDU (*icodes[0], eUSE, eUSE);
  159. icodes[1]->du.use |= icodes[2]->du.use;
  160. /* Adjust outEdges[0] to the new target basic block */
  161. pbb = icodes[0]->getParent();
  162. if (pbb->back().loc_ip == icodes[1]->loc_ip)
  163. {
  164. /* Find intermediate and target basic blocks */
  165. obb1 = pbb->edges[THEN].BBptr;
  166. tbb = obb1->edges[THEN].BBptr;
  167. /* Modify THEN out edge of header basic block */
  168. pbb->edges[THEN].BBptr = tbb;
  169. /* Modify in edges of target basic block */
  170. auto iter=std::find(tbb->inEdges.begin(),tbb->inEdges.end(),obb1);
  171. assert(iter!=tbb->inEdges.end());
  172. tbb->inEdges.erase(iter);
  173. if (icodes[3]->ll()->getOpcode() != iJE)
  174. tbb->inEdges.push_back(pbb); /* iJNE => replace arc */
  175. /* Modify ELSE out edge of header basic block */
  176. tbb = obb1->edges[ELSE].BBptr;
  177. pbb->edges[ELSE].BBptr = tbb;
  178. iter=std::find(tbb->inEdges.begin(),tbb->inEdges.end(),obb1);
  179. assert(iter!=tbb->inEdges.end());
  180. tbb->inEdges.erase(iter);
  181. if (icodes[3]->ll()->getOpcode() == iJE) /* replace */
  182. tbb->inEdges.push_back(pbb);
  183. /* Update statistics */
  184. obb1->flg |= INVALID_BB;
  185. stats.numBBaft--;
  186. }
  187. icodes[0]->invalidate();
  188. icodes[2]->invalidate();
  189. icodes[3]->invalidate();
  190. return 4;
  191. }
  192. /* Propagates TYPE_LONG_(UN)SIGN icode information to the current pIcode
  193. * Pointer.
  194. * Arguments: i : index into the local identifier table
  195. * pLocId: ptr to the long local identifier
  196. * pProc : ptr to current procedure's record. */
  197. void Function::propLongStk (int i, const ID &pLocId)
  198. {
  199. int arc;
  200. Assignment asgn;
  201. //COND_EXPR *lhs, *rhs; /* Pointers to left and right hand expression */
  202. iICODE next1, pEnd;
  203. iICODE l23;
  204. /* Check all icodes for offHi:offLo */
  205. pEnd = Icode.end();
  206. size_t stat_size=Icode.size();
  207. // for (idx = 0; idx < (Icode.size() - 1); idx++)
  208. for(auto pIcode = Icode.begin(); ;++pIcode)
  209. {
  210. assert(Icode.size()==stat_size);
  211. next1 = ++iICODE(pIcode);
  212. if(next1==pEnd)
  213. break;
  214. if ((pIcode->type == HIGH_LEVEL) || ( not pIcode->valid() ))
  215. continue;
  216. if (pIcode->ll()->getOpcode() == next1->ll()->getOpcode())
  217. {
  218. if (checkLongEq (pLocId.id.longStkId, pIcode, i, this, asgn, *next1->ll()) == true)
  219. {
  220. switch (pIcode->ll()->getOpcode())
  221. {
  222. case iMOV:
  223. pIcode->setAsgn(asgn.lhs, asgn.rhs);
  224. next1->invalidate();
  225. break;
  226. case iAND: case iOR: case iXOR:
  227. switch (pIcode->ll()->getOpcode())
  228. {
  229. case iAND: asgn.rhs = COND_EXPR::boolOp (asgn.lhs, asgn.rhs, AND); break;
  230. case iOR: asgn.rhs = COND_EXPR::boolOp (asgn.lhs, asgn.rhs, OR); break;
  231. case iXOR: asgn.rhs = COND_EXPR::boolOp (asgn.lhs, asgn.rhs, XOR); break;
  232. }
  233. pIcode->setAsgn(asgn.lhs, asgn.rhs);
  234. next1->invalidate();
  235. break;
  236. case iPUSH:
  237. pIcode->setUnary( HLI_PUSH, asgn.lhs);
  238. next1->invalidate();
  239. break;
  240. default:
  241. printf("Wild ass checkLongEq success on opcode %d\n",pIcode->ll()->getOpcode());
  242. } /*eos*/
  243. }
  244. }
  245. //TODO: Simplify this!
  246. /* Check long conditional (i.e. 2 CMPs and 3 branches */
  247. else if ((pIcode->ll()->getOpcode() == iCMP) && (isLong23 (pIcode->getParent(), l23, &arc)))
  248. {
  249. if ( checkLongEq (pLocId.id.longStkId, pIcode, i, this, asgn, *l23->ll()) )
  250. {
  251. advance(pIcode,longJCond23 (asgn, pIcode, arc, l23));
  252. }
  253. }
  254. /* Check for long conditional equality or inequality. This requires
  255. * 2 CMPs and 2 branches */
  256. else if ((pIcode->ll()->getOpcode() == iCMP) && isLong22 (pIcode, pEnd, l23))
  257. {
  258. if ( checkLongEq (pLocId.id.longStkId, pIcode, i, this,asgn, *l23->ll()) )
  259. {
  260. advance(pIcode,longJCond22 (asgn, pIcode,pEnd));
  261. }
  262. }
  263. }
  264. }
  265. int Function::findBackwarLongDefs(int loc_ident_idx, const ID &pLocId, iICODE beg)
  266. {
  267. Assignment asgn;
  268. LLOperand * pmH,* pmL;
  269. iICODE pIcode;
  270. riICODE rev(beg);
  271. bool forced_finish=false;
  272. for (; not forced_finish and rev!=Icode.rend();rev++) //idx = pLocId_idx - 1; idx > 0 ; idx--
  273. {
  274. pIcode = (++riICODE(rev)).base();//forward iterator from rev
  275. iICODE next1((++iICODE(pIcode))); // next instruction
  276. ICODE &icode(*pIcode);
  277. if ((icode.type == HIGH_LEVEL) || ( not icode.valid() ))
  278. continue;
  279. if (icode.ll()->getOpcode() != next1->ll()->getOpcode())
  280. continue;
  281. switch (icode.ll()->getOpcode())
  282. {
  283. case iMOV:
  284. pmH = &icode.ll()->dst;
  285. pmL = &next1->ll()->dst;
  286. if ((pLocId.id.longId.h == pmH->regi) && (pLocId.id.longId.l == pmL->regi))
  287. {
  288. localId.id_arr[loc_ident_idx].idx.push_back(pIcode);//idx-1//insert
  289. icode.setRegDU( pmL->regi, eDEF);
  290. asgn.lhs = COND_EXPR::idLongIdx (loc_ident_idx);
  291. asgn.rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode, HIGH_FIRST, pIcode, eUSE, *next1->ll());
  292. icode.setAsgn(asgn.lhs, asgn.rhs);
  293. next1->invalidate();
  294. forced_finish=true; /* to exit the loop */
  295. }
  296. break;
  297. case iPOP:
  298. pmH = &next1->ll()->dst;
  299. pmL = &icode.ll()->dst;
  300. if ((pLocId.id.longId.h == pmH->regi) && (pLocId.id.longId.l == pmL->regi))
  301. {
  302. asgn.lhs = COND_EXPR::idLongIdx (loc_ident_idx);
  303. icode.setRegDU( pmH->regi, eDEF);
  304. icode.setUnary(HLI_POP, asgn.lhs);
  305. next1->invalidate();
  306. asgn.lhs=0;
  307. forced_finish=true; /* to exit the loop */
  308. }
  309. break;
  310. // /**** others missing ***/
  311. case iAND: case iOR: case iXOR:
  312. pmL = &icode.ll()->dst;
  313. pmH = &next1->ll()->dst;
  314. if ((pLocId.id.longId.h == pmH->regi) && (pLocId.id.longId.l == pmL->regi))
  315. {
  316. asgn.lhs = COND_EXPR::idLongIdx (loc_ident_idx);
  317. asgn.rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode, LOW_FIRST, pIcode, eUSE, *next1->ll());
  318. icode.setRegDU( pmH->regi, USE_DEF);
  319. switch (icode.ll()->getOpcode())
  320. {
  321. case iAND: asgn.rhs = COND_EXPR::boolOp (asgn.lhs, asgn.rhs, AND);
  322. break;
  323. case iOR:
  324. asgn.rhs = COND_EXPR::boolOp (asgn.lhs, asgn.rhs, OR);
  325. break;
  326. case iXOR: asgn.rhs = COND_EXPR::boolOp (asgn.lhs, asgn.rhs, XOR);
  327. break;
  328. } /* eos */
  329. icode.setAsgn(asgn.lhs, asgn.rhs);
  330. next1->invalidate();
  331. forced_finish=true; /* to exit the loop */
  332. }
  333. break;
  334. } /* eos */
  335. }
  336. return rev!=Icode.rend();
  337. }
  338. int Function::findForwardLongUses(int loc_ident_idx, const ID &pLocId, iICODE beg)
  339. {
  340. bool forced_finish=false;
  341. auto pEnd=Icode.end();
  342. iICODE long_loc;
  343. Assignment asgn;
  344. for (auto pIcode=beg; not forced_finish; ++pIcode)
  345. {
  346. iICODE next1(++iICODE(pIcode));
  347. if(next1==pEnd)
  348. break;
  349. LLOperand * pmH,* pmL; /* Pointers to dst LOW_LEVEL icodes */
  350. int arc;
  351. if ((pIcode->type == HIGH_LEVEL) || ( not pIcode->valid() ))
  352. continue;
  353. if (pIcode->ll()->getOpcode() == next1->ll()->getOpcode())
  354. switch (pIcode->ll()->getOpcode())
  355. {
  356. case iMOV:
  357. if ((pLocId.id.longId.h == pIcode->ll()->src().getReg2()) &&
  358. (pLocId.id.longId.l == next1->ll()->src().getReg2()))
  359. {
  360. pIcode->setRegDU( next1->ll()->src().getReg2(), eUSE);
  361. asgn.rhs = COND_EXPR::idLongIdx (loc_ident_idx);
  362. asgn.lhs = COND_EXPR::idLong (&this->localId, DST, pIcode,HIGH_FIRST, pIcode, eDEF, *next1->ll());
  363. pIcode->setAsgn(asgn.lhs, asgn.rhs);
  364. next1->invalidate();
  365. forced_finish =true; /* to exit the loop */
  366. }
  367. break;
  368. case iPUSH:
  369. if ((pLocId.id.longId.h == pIcode->ll()->src().getReg2()) &&
  370. (pLocId.id.longId.l == next1->ll()->src().getReg2()))
  371. {
  372. asgn.rhs = COND_EXPR::idLongIdx (loc_ident_idx);
  373. pIcode->setRegDU( next1->ll()->src().getReg2(), eUSE);
  374. pIcode->setUnary(HLI_PUSH, asgn.rhs);
  375. next1->invalidate();
  376. }
  377. forced_finish =true; /* to exit the loop */
  378. break;
  379. /*** others missing ****/
  380. case iAND: case iOR: case iXOR:
  381. pmL = &pIcode->ll()->dst;
  382. pmH = &next1->ll()->dst;
  383. if ((pLocId.id.longId.h == pmH->regi) &&
  384. (pLocId.id.longId.l == pmL->regi))
  385. {
  386. asgn.lhs = COND_EXPR::idLongIdx (loc_ident_idx);
  387. pIcode->setRegDU( pmH->regi, USE_DEF);
  388. asgn.rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode,
  389. LOW_FIRST, pIcode, eUSE, *next1->ll());
  390. switch (pIcode->ll()->getOpcode()) {
  391. case iAND: asgn.rhs = COND_EXPR::boolOp (asgn.lhs, asgn.rhs, AND);
  392. break;
  393. case iOR: asgn.rhs = COND_EXPR::boolOp (asgn.lhs, asgn.rhs, OR);
  394. break;
  395. case iXOR: asgn.rhs = COND_EXPR::boolOp (asgn.lhs, asgn.rhs, XOR);
  396. break;
  397. }
  398. pIcode->setAsgn(asgn.lhs, asgn.rhs);
  399. next1->invalidate();
  400. // ftw loop restart ????
  401. //idx = 0;
  402. // maybe this should end the loop instead
  403. forced_finish =true; /* to exit the loop */
  404. }
  405. break;
  406. } /* eos */
  407. /* Check long conditional (i.e. 2 CMPs and 3 branches */
  408. else if ((pIcode->ll()->getOpcode() == iCMP) && (isLong23 (pIcode->getParent(), long_loc, &arc)))
  409. {
  410. if (checkLongRegEq (pLocId.id.longId, pIcode, loc_ident_idx, this, asgn, *long_loc->ll()))
  411. {
  412. // reduce the advance by 1 here (loop increases) ?
  413. advance(pIcode,longJCond23 (asgn, pIcode, arc, long_loc));
  414. }
  415. }
  416. /* Check for long conditional equality or inequality. This requires
  417. * 2 CMPs and 2 branches */
  418. else if (pIcode->ll()->match(iCMP) && (isLong22 (pIcode, pEnd, long_loc)))
  419. {
  420. if (checkLongRegEq (pLocId.id.longId, pIcode, loc_ident_idx, this, asgn, *long_loc->ll()) )
  421. {
  422. // TODO: verify that removing -1 does not change anything !
  423. advance(pIcode,longJCond22 (asgn, pIcode,pEnd));
  424. }
  425. }
  426. /* Check for OR regH, regL
  427. * JX lab
  428. * => HLI_JCOND (regH:regL X 0) lab
  429. * This is better code than HLI_JCOND (HI(regH:regL) | LO(regH:regL)) */
  430. else if (pIcode->ll()->match(iOR) && (next1 != pEnd) && (isJCond ((llIcode)next1->ll()->getOpcode())))
  431. {
  432. if (pLocId.id.longId.srcDstRegMatch(pIcode,pIcode))
  433. {
  434. asgn.lhs = COND_EXPR::idLongIdx (loc_ident_idx);
  435. asgn.rhs = COND_EXPR::idKte (0, 4); /* long 0 */
  436. asgn.lhs = COND_EXPR::boolOp (asgn.lhs, asgn.rhs, condOpJCond[next1->ll()->getOpcode() - iJB]);
  437. next1->setJCond(asgn.lhs);
  438. next1->copyDU(*pIcode, eUSE, eUSE);
  439. pIcode->invalidate();
  440. }
  441. }
  442. } /* end for */
  443. return 0;
  444. }
  445. /** Finds the definition of the long register pointed to by pLocId, and
  446. * transforms that instruction into a HIGH_LEVEL icode instruction.
  447. * @arg i index into the local identifier table
  448. * @arg pLocId ptr to the long local identifier
  449. *
  450. */
  451. void Function::propLongReg (int loc_ident_idx, const ID &pLocId)
  452. {
  453. /* Process all definitions/uses of long registers at an icode position */
  454. // WARNING: this loop modifies the iterated-over container.
  455. //size_t initial_size=pLocId.idx.size();
  456. for (size_t j = 0; j < pLocId.idx.size(); j++)
  457. {
  458. auto idx_iter=pLocId.idx.begin();
  459. std::advance(idx_iter,j);
  460. /* Check backwards for a definition of this long register */
  461. if (findBackwarLongDefs(loc_ident_idx,pLocId,*idx_iter))
  462. {
  463. //assert(initial_size==pLocId.idx.size());
  464. continue;
  465. }
  466. /* If no definition backwards, check forward for a use of this long reg */
  467. findForwardLongUses(loc_ident_idx,pLocId,*idx_iter);
  468. //assert(initial_size==pLocId.idx.size());
  469. } /* end for */
  470. }
  471. /* Propagates the long global address across all LOW_LEVEL icodes.
  472. * Transforms some LOW_LEVEL icodes into HIGH_LEVEL */
  473. void Function::propLongGlb (int /*i*/, const ID &/*pLocId*/)
  474. {
  475. printf("WARN: Function::propLongGlb not implemented");
  476. }
  477. /* Propagated identifier information, thus converting some LOW_LEVEL icodes
  478. * into HIGH_LEVEL icodes. */
  479. void Function::propLong()
  480. {
  481. /* Pointer to current local identifier */
  482. //TODO: change into range based for
  483. for (size_t i = 0; i < localId.csym(); i++)
  484. {
  485. const ID &pLocId(localId.id_arr[i]);
  486. if ((pLocId.type==TYPE_LONG_SIGN) || (pLocId.type==TYPE_LONG_UNSIGN))
  487. {
  488. switch (pLocId.loc)
  489. {
  490. case STK_FRAME:
  491. propLongStk (i, pLocId);
  492. break;
  493. case REG_FRAME:
  494. propLongReg (i, pLocId);
  495. break;
  496. case GLB_FRAME:
  497. propLongGlb (i, pLocId);
  498. break;
  499. }
  500. }
  501. }
  502. }