proplong.cpp 21 KB

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