proplong.cpp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  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 boolT isLong23 (Int i, BB * pbb, Int *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().ic.ll.opcode == iCMP))
  33. {
  34. *off = obb2->front().loc_ip - i;
  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().ic.ll.opcode == iCMP))
  44. {
  45. *off = 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, Int *off)
  54. {
  55. if (((pIcode+2) < pEnd) && ((pIcode+2)->ic.ll.opcode == iCMP) &&
  56. (isJCond ((pIcode+1)->ic.ll.opcode)) &&
  57. (isJCond ((pIcode+3)->ic.ll.opcode)))
  58. {
  59. *off = 2;
  60. return true;
  61. }
  62. return false;
  63. }
  64. /* Creates a long conditional <=, >=, <, or > at (pIcode+1).
  65. * Removes excess nodes from the graph by flagging them, and updates
  66. * the new edges for the remaining nodes. */
  67. static void longJCond23 (COND_EXPR *rhs, COND_EXPR *lhs, iICODE pIcode,
  68. Int *idx, Function * pProc, Int arc, Int off)
  69. { Int j;
  70. BB * pbb, * obb1, * obb2, * tbb;
  71. if (arc == THEN)
  72. {
  73. /* Find intermediate basic blocks and target block */
  74. pbb = pIcode->inBB;
  75. obb1 = pbb->edges[THEN].BBptr;
  76. obb2 = obb1->edges[THEN].BBptr;
  77. tbb = obb2->edges[THEN].BBptr;
  78. /* Modify out edge of header basic block */
  79. pbb->edges[THEN].BBptr = tbb;
  80. /* Modify in edges of target basic block */
  81. auto newlast=std::remove_if(tbb->inEdges.begin(),tbb->inEdges.end(),
  82. [obb1,obb2](BB *b) -> bool
  83. {
  84. return (b==obb1) || (b==obb2);
  85. }
  86. );
  87. tbb->inEdges.erase(newlast,tbb->inEdges.end());
  88. tbb->inEdges.push_back(pbb); /* looses 2 arcs, gains 1 arc */
  89. /* Modify in edges of the ELSE basic block */
  90. tbb = pbb->edges[ELSE].BBptr;
  91. auto iter=std::find(tbb->inEdges.begin(),tbb->inEdges.end(),obb2);
  92. assert(iter!=tbb->inEdges.end());
  93. tbb->inEdges.erase(iter); /* looses 1 arc */
  94. /* Update icode index */
  95. (*idx) += 5;
  96. }
  97. else /* ELSE arc */
  98. {
  99. /* Find intermediate basic blocks and target block */
  100. pbb = pIcode->inBB;
  101. obb1 = pbb->edges[ELSE].BBptr;
  102. obb2 = obb1->edges[THEN].BBptr;
  103. tbb = obb2->edges[THEN].BBptr;
  104. /* Modify in edges of target basic block */
  105. auto iter=std::find(tbb->inEdges.begin(),tbb->inEdges.end(),obb2);
  106. assert(iter!=tbb->inEdges.end());
  107. tbb->inEdges.erase(iter); /* looses 1 arc */
  108. /* Modify in edges of the ELSE basic block */
  109. tbb = obb2->edges[ELSE].BBptr;
  110. auto newlast=std::remove_if(tbb->inEdges.begin(),tbb->inEdges.end(),
  111. [obb1,obb2](BB *b) -> bool
  112. {
  113. return (b==obb1) || (b==obb2);
  114. }
  115. );
  116. tbb->inEdges.erase(newlast,tbb->inEdges.end());
  117. tbb->inEdges.push_back(pbb); /* looses 2 arcs, gains 1 arc */
  118. /* Modify out edge of header basic block */
  119. pbb->edges[ELSE].BBptr = tbb;
  120. /* Update icode index */
  121. (*idx) += 2;
  122. }
  123. /* Create new HLI_JCOND and condition */
  124. lhs = COND_EXPR::boolOp (lhs, rhs, condOpJCond[(pIcode+off+1)->ic.ll.opcode-iJB]);
  125. (pIcode+1)->setJCond(lhs);
  126. (pIcode+1)->copyDU(*pIcode, eUSE, eUSE);
  127. (pIcode+1)->du.use |= (pIcode+off)->du.use;
  128. /* Update statistics */
  129. obb1->flg |= INVALID_BB;
  130. obb2->flg |= INVALID_BB;
  131. stats.numBBaft -= 2;
  132. pIcode->invalidate();
  133. obb1->front().invalidate();
  134. obb2->front().invalidate();
  135. (obb2->begin2()+1)->invalidate();
  136. }
  137. /* Creates a long conditional equality or inequality at (pIcode+1).
  138. * Removes excess nodes from the graph by flagging them, and updates
  139. * the new edges for the remaining nodes. */
  140. static void longJCond22 (COND_EXPR *rhs, COND_EXPR *lhs, iICODE pIcode, Int *idx)
  141. {
  142. Int j;
  143. BB * pbb, * obb1, * tbb;
  144. /* Form conditional expression */
  145. lhs = COND_EXPR::boolOp (lhs, rhs, condOpJCond[(pIcode+3)->ic.ll.opcode - iJB]);
  146. (pIcode+1)->setJCond(lhs);
  147. (pIcode+1)->copyDU (*pIcode, eUSE, eUSE);
  148. (pIcode+1)->du.use |= (pIcode+2)->du.use;
  149. /* Adjust outEdges[0] to the new target basic block */
  150. pbb = pIcode->inBB;
  151. if (pbb->back().loc_ip == (*idx + 1))
  152. {
  153. /* Find intermediate and target basic blocks */
  154. obb1 = pbb->edges[THEN].BBptr;
  155. tbb = obb1->edges[THEN].BBptr;
  156. /* Modify THEN out edge of header basic block */
  157. pbb->edges[THEN].BBptr = tbb;
  158. /* Modify in edges of target basic block */
  159. auto iter=std::find(tbb->inEdges.begin(),tbb->inEdges.end(),obb1);
  160. assert(iter!=tbb->inEdges.end());
  161. tbb->inEdges.erase(iter);
  162. if ((pIcode+3)->ic.ll.opcode != iJE)
  163. tbb->inEdges.push_back(pbb); /* iJNE => replace arc */
  164. /* Modify ELSE out edge of header basic block */
  165. tbb = obb1->edges[ELSE].BBptr;
  166. pbb->edges[ELSE].BBptr = tbb;
  167. iter=std::find(tbb->inEdges.begin(),tbb->inEdges.end(),obb1);
  168. assert(iter!=tbb->inEdges.end());
  169. tbb->inEdges.erase(iter);
  170. if ((pIcode+3)->ic.ll.opcode == iJE) /* replace */
  171. tbb->inEdges.push_back(pbb);
  172. // else
  173. // tbb->numInEdges--; /* iJNE => looses 1 arc */
  174. /* Update statistics */
  175. obb1->flg |= INVALID_BB;
  176. stats.numBBaft--;
  177. }
  178. pIcode->invalidate();
  179. (pIcode+2)->invalidate();
  180. (pIcode+3)->invalidate();
  181. (*idx) += 4;
  182. }
  183. /* Propagates TYPE_LONG_(UN)SIGN icode information to the current pIcode
  184. * Pointer.
  185. * Arguments: i : index into the local identifier table
  186. * pLocId: ptr to the long local identifier
  187. * pProc : ptr to current procedure's record. */
  188. void Function::propLongStk (Int i, ID *pLocId)
  189. {
  190. Int idx, off, arc;
  191. COND_EXPR *lhs, *rhs; /* Pointers to left and right hand expression */
  192. iICODE pIcode, pEnd;
  193. /* Check all icodes for offHi:offLo */
  194. pEnd = Icode.end();
  195. for (idx = 0; idx < (this->Icode.GetNumIcodes() - 1); idx++)
  196. {
  197. pIcode = Icode.begin()+idx;
  198. if ((pIcode->type == HIGH_LEVEL) || (pIcode->invalid == TRUE))
  199. continue;
  200. if (pIcode->ic.ll.opcode == (pIcode+1)->ic.ll.opcode)
  201. {
  202. switch (pIcode->ic.ll.opcode)
  203. {
  204. case iMOV:
  205. if (checkLongEq (pLocId->id.longStkId, pIcode, i, idx, this,
  206. &rhs, &lhs, 1) == TRUE)
  207. {
  208. pIcode->setAsgn(lhs, rhs);
  209. (pIcode+1)->invalidate();
  210. idx++;
  211. }
  212. break;
  213. case iAND: case iOR: case iXOR:
  214. if (checkLongEq (pLocId->id.longStkId, pIcode, i, idx, this,
  215. &rhs, &lhs, 1) == TRUE)
  216. {
  217. switch (pIcode->ic.ll.opcode)
  218. {
  219. case iAND: rhs = COND_EXPR::boolOp (lhs, rhs, AND);
  220. break;
  221. case iOR: rhs = COND_EXPR::boolOp (lhs, rhs, OR);
  222. break;
  223. case iXOR: rhs = COND_EXPR::boolOp (lhs, rhs, XOR);
  224. break;
  225. }
  226. pIcode->setAsgn(lhs, rhs);
  227. (pIcode+1)->invalidate();
  228. idx++;
  229. }
  230. break;
  231. case iPUSH:
  232. if (checkLongEq (pLocId->id.longStkId, pIcode, i, idx, this,
  233. &rhs, &lhs, 1) == TRUE)
  234. {
  235. pIcode->setUnary( HLI_PUSH, lhs);
  236. (pIcode+1)->invalidate();
  237. idx++;
  238. }
  239. break;
  240. } /*eos*/
  241. }
  242. /* Check long conditional (i.e. 2 CMPs and 3 branches */
  243. else if ((pIcode->ic.ll.opcode == iCMP) && (isLong23 (idx, pIcode->inBB, &off, &arc)))
  244. {
  245. if (checkLongEq (pLocId->id.longStkId, pIcode, i, idx, this, &rhs, &lhs, off) == TRUE)
  246. longJCond23 (rhs, lhs, pIcode, &idx, this, arc, off);
  247. }
  248. /* Check for long conditional equality or inequality. This requires
  249. * 2 CMPs and 2 branches */
  250. else if ((pIcode->ic.ll.opcode == iCMP) &&
  251. isLong22 (pIcode, pEnd, &off))
  252. {
  253. if (checkLongEq (pLocId->id.longStkId, pIcode, i, idx, this,
  254. &rhs, &lhs, off) == TRUE)
  255. longJCond22 (rhs, lhs, pIcode, &idx);
  256. }
  257. }
  258. }
  259. void checkBack();
  260. //int Function::checkBackwarLongDefs(int loc_ident_idx, ID *pLocId, int pLocId_idx)
  261. //{
  262. // int idx;
  263. // for (idx = pLocId_idx - 1; idx > 0 ; idx--)
  264. // {
  265. // pIcode = Icode.begin()+(idx-1);
  266. // if ((pIcode->type == HIGH_LEVEL) || (pIcode->invalid == TRUE))
  267. // continue;
  268. // if (pIcode->ic.ll.opcode != (pIcode+1)->ic.ll.opcode)
  269. // continue;
  270. // switch (pIcode->ic.ll.opcode)
  271. // {
  272. // case iMOV:
  273. // pmH = &pIcode->ic.ll.dst;
  274. // pmL = &(pIcode+1)->ic.ll.dst;
  275. // if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi))
  276. // {
  277. // lhs = COND_EXPR::idLongIdx (i);
  278. // this->localId.id_arr[i].idx.push_back(idx-1);
  279. // pIcode->setRegDU( pmL->regi, eDEF);
  280. // rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode, HIGH_FIRST, idx, eUSE, 1);
  281. // pIcode->setAsgn(lhs, rhs);
  282. // (pIcode+1)->invalidate();
  283. // idx = 0; /* to exit the loop */
  284. // }
  285. // break;
  286. // case iPOP:
  287. // pmH = &(pIcode+1)->ic.ll.dst;
  288. // pmL = &pIcode->ic.ll.dst;
  289. // if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi))
  290. // {
  291. // lhs = COND_EXPR::idLongIdx (i);
  292. // pIcode->setRegDU( pmH->regi, eDEF);
  293. // pIcode->setUnary(HLI_POP, lhs);
  294. // (pIcode+1)->invalidate();
  295. // idx = 0; /* to exit the loop */
  296. // }
  297. // break;
  298. // /**** others missing ***/
  299. // case iAND: case iOR: case iXOR:
  300. // pmL = &pIcode->ic.ll.dst;
  301. // pmH = &(pIcode+1)->ic.ll.dst;
  302. // if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi))
  303. // {
  304. // lhs = COND_EXPR::idLongIdx (i);
  305. // pIcode->setRegDU( pmH->regi, USE_DEF);
  306. // rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode, LOW_FIRST, idx, eUSE, 1);
  307. // switch (pIcode->ic.ll.opcode) {
  308. // case iAND: rhs = COND_EXPR::boolOp (lhs, rhs, AND);
  309. // break;
  310. // case iOR:
  311. // rhs = COND_EXPR::boolOp (lhs, rhs, OR);
  312. // break;
  313. // case iXOR: rhs = COND_EXPR::boolOp (lhs, rhs, XOR);
  314. // break;
  315. // } /* eos */
  316. // pIcode->setAsgn(lhs, rhs);
  317. // (pIcode+1)->invalidate();
  318. // idx = 0;
  319. // }
  320. // break;
  321. // } /* eos */
  322. // }
  323. //}
  324. /* Finds the definition of the long register pointed to by pLocId, and
  325. * transforms that instruction into a HIGH_LEVEL icode instruction.
  326. * Arguments: i : index into the local identifier table
  327. * pLocId: ptr to the long local identifier
  328. * pProc : ptr to current procedure's record. */
  329. void Function::propLongReg (Int loc_ident_idx, ID *pLocId)
  330. {
  331. Int idx;
  332. iICODE pEnd;
  333. /* Process all definitions/uses of long registers at an icode position */
  334. pEnd = this->Icode.end();
  335. // for (int pLocId_idx : pLocId->idx)
  336. // WARNING: this loop modifies the iterated-over container.
  337. for (int j = 0; j < pLocId->idx.size(); j++)
  338. {
  339. int pLocId_idx=pLocId->idx[j];
  340. /* Check backwards for a definition of this long register */
  341. COND_EXPR *lhs, *rhs;
  342. for (idx = pLocId_idx - 1; idx > 0 ; idx--)
  343. {
  344. iICODE pIcode;
  345. ICODEMEM * pmH,* pmL; /* Pointers to dst LOW_LEVEL icodes */
  346. pIcode = Icode.begin()+(idx-1);
  347. if ((pIcode->type == HIGH_LEVEL) || (pIcode->invalid == TRUE))
  348. continue;
  349. if (pIcode->ic.ll.opcode != (pIcode+1)->ic.ll.opcode)
  350. continue;
  351. switch (pIcode->ic.ll.opcode)
  352. {
  353. case iMOV:
  354. pmH = &pIcode->ic.ll.dst;
  355. pmL = &(pIcode+1)->ic.ll.dst;
  356. if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi))
  357. {
  358. lhs = COND_EXPR::idLongIdx (loc_ident_idx);
  359. this->localId.id_arr[loc_ident_idx].idx.push_back(idx-1);
  360. pIcode->setRegDU( pmL->regi, eDEF);
  361. rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode, HIGH_FIRST, idx, eUSE, 1);
  362. pIcode->setAsgn(lhs, rhs);
  363. (pIcode+1)->invalidate();
  364. idx = 0; /* to exit the loop */
  365. }
  366. break;
  367. case iPOP:
  368. pmH = &(pIcode+1)->ic.ll.dst;
  369. pmL = &pIcode->ic.ll.dst;
  370. if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi))
  371. {
  372. lhs = COND_EXPR::idLongIdx (loc_ident_idx);
  373. pIcode->setRegDU( pmH->regi, eDEF);
  374. pIcode->setUnary(HLI_POP, lhs);
  375. (pIcode+1)->invalidate();
  376. idx = 0; /* to exit the loop */
  377. }
  378. break;
  379. /**** others missing ***/
  380. case iAND: case iOR: case iXOR:
  381. pmL = &pIcode->ic.ll.dst;
  382. pmH = &(pIcode+1)->ic.ll.dst;
  383. if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi))
  384. {
  385. lhs = COND_EXPR::idLongIdx (loc_ident_idx);
  386. pIcode->setRegDU( pmH->regi, USE_DEF);
  387. rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode, LOW_FIRST, idx, eUSE, 1);
  388. switch (pIcode->ic.ll.opcode) {
  389. case iAND: rhs = COND_EXPR::boolOp (lhs, rhs, AND);
  390. break;
  391. case iOR:
  392. rhs = COND_EXPR::boolOp (lhs, rhs, OR);
  393. break;
  394. case iXOR:
  395. rhs = COND_EXPR::boolOp (lhs, rhs, XOR);
  396. break;
  397. } /* eos */
  398. pIcode->setAsgn(lhs, rhs);
  399. (pIcode+1)->invalidate();
  400. idx = 0;
  401. }
  402. break;
  403. } /* eos */
  404. }
  405. /* If no definition backwards, check forward for a use of this long reg */
  406. if (idx > 0)
  407. continue;
  408. for (idx = pLocId_idx + 1; idx < Icode.size() - 1; idx++)
  409. {
  410. iICODE pIcode;
  411. ICODEMEM * pmH,* pmL; /* Pointers to dst LOW_LEVEL icodes */
  412. int off,arc;
  413. pIcode = Icode.begin()+(idx);
  414. if ((pIcode->type == HIGH_LEVEL) || (pIcode->invalid == TRUE))
  415. continue;
  416. if (pIcode->ic.ll.opcode == (pIcode+1)->ic.ll.opcode)
  417. switch (pIcode->ic.ll.opcode) {
  418. case iMOV:
  419. if ((pLocId->id.longId.h == pIcode->ic.ll.src.regi) &&
  420. (pLocId->id.longId.l == (pIcode+1)->ic.ll.src.regi))
  421. {
  422. rhs = COND_EXPR::idLongIdx (loc_ident_idx);
  423. pIcode->setRegDU( (pIcode+1)->ic.ll.src.regi, eUSE);
  424. lhs = COND_EXPR::idLong (&this->localId, DST, pIcode,
  425. HIGH_FIRST, idx, eDEF, 1);
  426. pIcode->setAsgn(lhs, rhs);
  427. (pIcode+1)->invalidate();
  428. idx = this->Icode.GetNumIcodes(); /* to exit the loop */
  429. }
  430. break;
  431. case iPUSH:
  432. if ((pLocId->id.longId.h == pIcode->ic.ll.src.regi) &&
  433. (pLocId->id.longId.l == (pIcode+1)->ic.ll.src.regi))
  434. {
  435. rhs = COND_EXPR::idLongIdx (loc_ident_idx);
  436. pIcode->setRegDU( (pIcode+1)->ic.ll.src.regi, eUSE);
  437. pIcode->setUnary(HLI_PUSH, lhs);
  438. (pIcode+1)->invalidate();
  439. }
  440. idx = this->Icode.GetNumIcodes(); /* to exit the loop */
  441. break;
  442. /*** others missing ****/
  443. case iAND: case iOR: case iXOR:
  444. pmL = &pIcode->ic.ll.dst;
  445. pmH = &(pIcode+1)->ic.ll.dst;
  446. if ((pLocId->id.longId.h == pmH->regi) &&
  447. (pLocId->id.longId.l == pmL->regi))
  448. {
  449. lhs = COND_EXPR::idLongIdx (loc_ident_idx);
  450. pIcode->setRegDU( pmH->regi, USE_DEF);
  451. rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode,
  452. LOW_FIRST, idx, eUSE, 1);
  453. switch (pIcode->ic.ll.opcode) {
  454. case iAND: rhs = COND_EXPR::boolOp (lhs, rhs, AND);
  455. break;
  456. case iOR: rhs = COND_EXPR::boolOp (lhs, rhs, OR);
  457. break;
  458. case iXOR: rhs = COND_EXPR::boolOp (lhs, rhs, XOR);
  459. break;
  460. }
  461. pIcode->setAsgn(lhs, rhs);
  462. (pIcode+1)->invalidate();
  463. idx = 0;
  464. }
  465. break;
  466. } /* eos */
  467. /* Check long conditional (i.e. 2 CMPs and 3 branches */
  468. else if ((pIcode->ic.ll.opcode == iCMP) &&
  469. (isLong23 (idx, pIcode->inBB, &off, &arc)))
  470. {
  471. if (checkLongRegEq (pLocId->id.longId, pIcode, loc_ident_idx, idx, this,
  472. &rhs, &lhs, off) == TRUE)
  473. longJCond23 (rhs, lhs, pIcode, &idx, this, arc, off);
  474. }
  475. /* Check for long conditional equality or inequality. This requires
  476. * 2 CMPs and 2 branches */
  477. else if ((pIcode->ic.ll.opcode == iCMP) &&
  478. (isLong22 (pIcode, pEnd, &off)))
  479. {
  480. if (checkLongRegEq (pLocId->id.longId, pIcode, loc_ident_idx, idx, this,
  481. &rhs, &lhs, off) == TRUE)
  482. longJCond22 (rhs, lhs, pIcode, &idx);
  483. }
  484. /* Check for OR regH, regL
  485. * JX lab
  486. * => HLI_JCOND (regH:regL X 0) lab
  487. * This is better code than HLI_JCOND (HI(regH:regL) | LO(regH:regL)) */
  488. else if ((pIcode->ic.ll.opcode == iOR) && ((pIcode+1) < pEnd) &&
  489. (isJCond ((pIcode+1)->ic.ll.opcode)))
  490. {
  491. if ((pIcode->ic.ll.dst.regi == pLocId->id.longId.h) &&
  492. (pIcode->ic.ll.src.regi == pLocId->id.longId.l))
  493. {
  494. lhs = COND_EXPR::idLongIdx (loc_ident_idx);
  495. rhs = COND_EXPR::idKte (0, 4); /* long 0 */
  496. lhs = COND_EXPR::boolOp (lhs, rhs,
  497. condOpJCond[(pIcode+1)->ic.ll.opcode - iJB]);
  498. (pIcode+1)->setJCond(lhs);
  499. (pIcode+1)->copyDU(*pIcode, eUSE, eUSE);
  500. pIcode->invalidate();
  501. }
  502. }
  503. } /* end for */
  504. } /* end for */
  505. }
  506. /* Propagates the long global address across all LOW_LEVEL icodes.
  507. * Transforms some LOW_LEVEL icodes into HIGH_LEVEL */
  508. void Function::propLongGlb (Int i, ID *pLocId)
  509. {
  510. printf("WARN: Function::propLongGlb not implemented");
  511. }
  512. /* Propagated identifier information, thus converting some LOW_LEVEL icodes
  513. * into HIGH_LEVEL icodes. */
  514. void Function::propLong()
  515. {
  516. Int i;
  517. ID *pLocId; /* Pointer to current local identifier */
  518. for (i = 0; i < localId.csym(); i++)
  519. {
  520. pLocId = &localId.id_arr[i];
  521. if ((pLocId->type==TYPE_LONG_SIGN) || (pLocId->type==TYPE_LONG_UNSIGN))
  522. {
  523. switch (pLocId->loc)
  524. {
  525. case STK_FRAME:
  526. propLongStk (i, pLocId);
  527. break;
  528. case REG_FRAME:
  529. propLongReg (i, pLocId);
  530. break;
  531. case GLB_FRAME:
  532. propLongGlb (i, pLocId);
  533. break;
  534. }
  535. }
  536. }
  537. }