From 2b2eaeabe5981e14303790062dbdd12a752d324d Mon Sep 17 00:00:00 2001 From: Artur K Date: Wed, 22 Feb 2012 21:48:58 +0100 Subject: [PATCH] cruft removal wip --- include/Procedure.h | 10 +- include/dcc.h | 2 +- include/icode.h | 9 +- regression_tester.rb | 2 +- src/backend.cpp | 2 +- src/disassem.cpp | 2 +- src/graph.cpp | 27 +++-- src/hlicode.cpp | 2 +- src/icode.cpp | 45 -------- src/idioms.cpp | 4 +- src/locident.cpp | 10 +- src/parser.cpp | 8 +- src/proplong.cpp | 254 ++++++++++++++++--------------------------- 13 files changed, 131 insertions(+), 246 deletions(-) diff --git a/include/Procedure.h b/include/Procedure.h index cdbc076..92cc56f 100644 --- a/include/Procedure.h +++ b/include/Procedure.h @@ -40,6 +40,12 @@ struct FunctionType bool m_vararg; bool isVarArg() const {return m_vararg;} }; +struct Assignment +{ + COND_EXPR *lhs; + COND_EXPR *rhs; +}; + struct Function : public llvm::ilist_node { typedef llvm::iplist BasicBlockListType; @@ -113,13 +119,13 @@ public: void buildCFG(); void controlFlowAnalysis(); void newRegArg(ICODE *picode, ICODE *ticode); - protected: +protected: // TODO: replace those with friend visitor ? void propLongReg(Int loc_ident_idx, ID *pLocId); void propLongStk(Int i, ID *pLocId); void propLongGlb(Int i, ID *pLocId); - int checkBackwarLongDefs(int loc_ident_idx, ID *pLocId, int pLocId_idx); + int checkBackwarLongDefs(int loc_ident_idx, ID *pLocId, int pLocId_idx, Assignment &assign); void structCases(); void findExps(); void genDU1(); diff --git a/include/dcc.h b/include/dcc.h index ec8219d..0271b06 100644 --- a/include/dcc.h +++ b/include/dcc.h @@ -201,7 +201,7 @@ void inverseCondOp (COND_EXPR **); /* Exported funcions from locident.c */ boolT checkLongEq (LONG_STKID_TYPE, iICODE, Int, Int, Function *, COND_EXPR **,COND_EXPR **, Int); -boolT checkLongRegEq (LONGID_TYPE, iICODE, Int, Int, Function *, COND_EXPR **,COND_EXPR **, Int); +boolT checkLongRegEq (LONGID_TYPE, iICODE, Int, Int, Function *, COND_EXPR *&, COND_EXPR *&, Int); byte otherLongRegi (byte, Int, LOCAL_ID *); void insertIdx (IDX_ARRAY *, Int); diff --git a/include/icode.h b/include/icode.h index b4a780d..efa269a 100644 --- a/include/icode.h +++ b/include/icode.h @@ -335,7 +335,7 @@ struct ICODE void ClrLlFlag(dword flag) {ic.ll.flg &= ~flag;} void SetLlFlag(dword flag) {ic.ll.flg |= flag;} dword GetLlFlag() {return ic.ll.flg;} - bool isLlFlag(dword flg) {return (ic.ll.flg&flg)==flg;} + bool isLlFlag(dword flg) {return (ic.ll.flg&flg)!=0;} llIcode GetLlOpcode() const { return ic.ll.opcode; } void writeIntComment(std::ostringstream &s); @@ -364,16 +364,9 @@ public: ~CIcodeRec(); // Destructor ICODE * addIcode(ICODE *pIcode); - ICODE * GetFirstIcode(); // ICODE * GetNextIcode(ICODE * pCurIcode); - boolT IsValid(ICODE * pCurIcode); - int GetNumIcodes(); void SetInBB(int start, int end, BB* pnewBB); void SetImmediateOp(int ip, dword dw); - void SetLlFlag(int ip, dword flag); - void ClearLlFlag(int ip, dword flag); - dword GetLlFlag(int ip); - void SetLlInvalid(int ip, boolT fInv); dword GetLlLabel(int ip); llIcode GetLlOpcode(int ip); bool labelSrch(dword target, dword &pIndex); diff --git a/regression_tester.rb b/regression_tester.rb index 3f748dd..eee5c67 100755 --- a/regression_tester.rb +++ b/regression_tester.rb @@ -28,4 +28,4 @@ Dir.open(TESTS_DIR+"/inputs").each() {|f| next if f=="." or f==".." FileUtils.mv(TESTS_DIR+"/inputs/"+f,TESTS_DIR+"/outputs/"+f) if f.end_with?(".b") } -"diff -rqbwB" \ No newline at end of file +puts "**************************************\n" \ No newline at end of file diff --git a/src/backend.cpp b/src/backend.cpp index eda0c14..1276f70 100644 --- a/src/backend.cpp +++ b/src/backend.cpp @@ -346,7 +346,7 @@ static void backBackEnd (char *filename, CALL_GRAPH * pcallGraph, std::ostream & } /* Generate code for this procedure */ - stats.numLLIcode = pcallGraph->proc->Icode.GetNumIcodes(); + stats.numLLIcode = pcallGraph->proc->Icode.size(); stats.numHLIcode = 0; pcallGraph->proc->codeGen (ios); diff --git a/src/disassem.cpp b/src/disassem.cpp index dbdc740..5e7dc5f 100644 --- a/src/disassem.cpp +++ b/src/disassem.cpp @@ -184,7 +184,7 @@ void disassem(Int pass, Function * ppProc) lab = 0; /* Restart label numbers */ } createSymTables(); - allocIcode = numIcode = pProc->Icode.GetNumIcodes(); + allocIcode = numIcode = pProc->Icode.size(); cb = allocIcode * sizeof(ICODE); if (numIcode == 0) { diff --git a/src/graph.cpp b/src/graph.cpp index f5ff918..fcb3a81 100644 --- a/src/graph.cpp +++ b/src/graph.cpp @@ -36,14 +36,14 @@ void Function::createCFG() Int ip, start; BB * psBB; BB * pBB; - ICODE * pIcode = Icode.GetFirstIcode(); + iICODE pIcode = Icode.begin(); stats.numBBbef = stats.numBBaft = 0; - for (ip = start = 0; Icode.IsValid(pIcode); ip++, pIcode++) + for (ip = start = 0; pIcode!=Icode.end(); ip++, pIcode++) { /* Stick a NOWHERE_NODE on the end if we terminate * with anything other than a ret, jump or terminate */ - if (ip + 1 == Icode.GetNumIcodes() && + if (ip + 1 == Icode.size() && ! (pIcode->ic.ll.flg & TERMINATES) && pIcode->ic.ll.opcode != iJMP && pIcode->ic.ll.opcode != iJMPF && pIcode->ic.ll.opcode != iRET && pIcode->ic.ll.opcode != iRETF) @@ -122,7 +122,7 @@ CondJumps: start = ip + 1; } /* Check for a fall through */ - else if (Icode.GetFirstIcode()[ip + 1].ic.ll.flg & (TARGET | CASE)) + else if (Icode[ip + 1].ic.ll.flg & (TARGET | CASE)) { pBB = BB::Create(start, ip, FALL_NODE, 1, this); start = ip + 1; @@ -159,19 +159,18 @@ CondJumps: void Function::markImpure() { SYM * psym; - for (int i = 0; i < Icode.GetNumIcodes(); i++) + for(ICODE &icod : Icode) { - if (Icode.GetLlFlag(i) & (SYM_USE | SYM_DEF)) + if ( not icod.isLlFlag(SYM_USE | SYM_DEF)) + continue; + psym = &symtab[icod.ic.ll.caseTbl.numEntries]; + for (int c = (Int)psym->label; c < (Int)psym->label+psym->size; c++) { - psym = &symtab[Icode[i].ic.ll.caseTbl.numEntries]; - for (int c = (Int)psym->label; c < (Int)psym->label+psym->size; c++) + if (BITMAP(c, BM_CODE)) { - if (BITMAP(c, BM_CODE)) - { - Icode[i].SetLlFlag(IMPURE); - flg |= IMPURE; - break; - } + icod.SetLlFlag(IMPURE); + flg |= IMPURE; + break; } } } diff --git a/src/hlicode.cpp b/src/hlicode.cpp index 560bb24..4ce29b0 100644 --- a/src/hlicode.cpp +++ b/src/hlicode.cpp @@ -140,7 +140,7 @@ void Function::highLevelGen() COND_EXPR *lhs, *rhs; /* left- and right-hand side of expression */ flags32 flg; /* icode flags */ - numIcode = Icode.GetNumIcodes(); + numIcode = Icode.size(); for (i = 0; i < numIcode; i++) { pIcode = Icode.GetIcode(i); diff --git a/src/icode.cpp b/src/icode.cpp index 5d1d30f..faba3fe 100644 --- a/src/icode.cpp +++ b/src/icode.cpp @@ -32,31 +32,6 @@ ICODE * CIcodeRec::addIcode(ICODE *pIcode) return &back(); } -ICODE * CIcodeRec::GetFirstIcode() -{ - return &front(); -} - -/* Don't need this; just pIcode++ since array is guaranteed to be contiguous -ICODE * CIcodeRec::GetNextIcode(ICODE * pCurIcode) -{ - int idx = pCurIcode - icode; // Current index - ASSERT(idx+1 < numIcode); - return &icode[idx+1]; -} -*/ - -boolT CIcodeRec::IsValid(ICODE *pCurIcode) -{ - ptrdiff_t idx = pCurIcode - &this->front(); // Current index - return (idx>=0) && (idx < size()); -} - -int CIcodeRec::GetNumIcodes() -{ - return size(); -} - void CIcodeRec::SetInBB(int start, int end, BB *pnewBB) { for (int i = start; i <= end; i++) @@ -68,26 +43,6 @@ void CIcodeRec::SetImmediateOp(int ip, dword dw) at(ip).ic.ll.immed.op = dw; } -void CIcodeRec::SetLlFlag(int ip, dword flag) -{ - at(ip).ic.ll.flg |= flag; -} - -dword CIcodeRec::GetLlFlag(int ip) -{ - return at(ip).ic.ll.flg; -} - -void CIcodeRec::ClearLlFlag(int ip, dword flag) -{ - at(ip).ic.ll.flg &= (~flag); -} - -void CIcodeRec::SetLlInvalid(int ip, boolT fInv) -{ - at(ip).invalid = fInv; -} - dword CIcodeRec::GetLlLabel(int ip) { return at(ip).ic.ll.label; diff --git a/src/idioms.cpp b/src/idioms.cpp index f39445d..da2c326 100644 --- a/src/idioms.cpp +++ b/src/idioms.cpp @@ -1422,12 +1422,12 @@ void Function::bindIcodeOff() iICODE pIcode; /* ptr icode array */ dword *p,j; /* for case table */ - if (! Icode.GetNumIcodes()) /* No Icode */ + if (Icode.empty()) /* No Icode */ return; pIcode = Icode.begin(); /* Flag all jump targets for BB construction and disassembly stage 2 */ - for (i = 0; i < Icode.GetNumIcodes(); i++) + for (i = 0; i < Icode.size(); i++) if ((pIcode[i].ic.ll.flg & I) && JmpInst(pIcode[i].ic.ll.opcode)) { if (Icode.labelSrch(pIcode[i].ic.ll.immed.op, j)) diff --git a/src/locident.cpp b/src/locident.cpp index 7e70f4a..d610b00 100644 --- a/src/locident.cpp +++ b/src/locident.cpp @@ -344,7 +344,7 @@ boolT checkLongEq (LONG_STKID_TYPE longId, iICODE pIcode, Int i, Int idx, * pProc : ptr to current procedure record * rhs, lhs : return expressions if successful. */ boolT checkLongRegEq (LONGID_TYPE longId, iICODE pIcode, Int i, Int idx, - Function * pProc, COND_EXPR **rhs, COND_EXPR **lhs, Int off) + Function * pProc, COND_EXPR *&rhs, COND_EXPR *&lhs, Int off) { ICODEMEM *pmHdst, *pmLdst, *pmHsrc, *pmLsrc; /* pointers to LOW_LEVEL icodes */ @@ -355,15 +355,15 @@ boolT checkLongRegEq (LONGID_TYPE longId, iICODE pIcode, Int i, Int idx, if ((longId.h == pmHdst->regi) && (longId.l == pmLdst->regi)) { - *lhs = COND_EXPR::idLongIdx (i); + lhs = COND_EXPR::idLongIdx (i); if ((pIcode->ic.ll.flg & NO_SRC) != NO_SRC) - *rhs = COND_EXPR::idLong (&pProc->localId, SRC, pIcode, HIGH_FIRST, idx, eUSE, off); + rhs = COND_EXPR::idLong (&pProc->localId, SRC, pIcode, HIGH_FIRST, idx, eUSE, off); return true; } else if ((longId.h == pmHsrc->regi) && (longId.l == pmLsrc->regi)) { - *lhs = COND_EXPR::idLong (&pProc->localId, DST, pIcode, HIGH_FIRST, idx, eDEF, off); - *rhs = COND_EXPR::idLongIdx (i); + lhs = COND_EXPR::idLong (&pProc->localId, DST, pIcode, HIGH_FIRST, idx, eDEF, off); + rhs = COND_EXPR::idLongIdx (i); return true; } return false; diff --git a/src/parser.cpp b/src/parser.cpp index 83e284d..e868ec7 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -485,7 +485,7 @@ boolT Function::process_JMP (ICODE * pIcode, STATE *pstate, CALL_GRAPH * pcallGr { memcpy(&StCopy, pstate, sizeof(STATE)); StCopy.IP = cs + LH(&prog.Image[i]); - ip = Icode.GetNumIcodes(); + ip = Icode.size(); FollowCtrl (pcallGraph, &StCopy); @@ -501,7 +501,7 @@ boolT Function::process_JMP (ICODE * pIcode, STATE *pstate, CALL_GRAPH * pcallGr flg |= PROC_IJMP; flg &= ~TERMINATES; - interactDis(this, this->Icode.GetNumIcodes()-1); + interactDis(this, this->Icode.size()-1); return TRUE; } @@ -517,7 +517,7 @@ boolT Function::process_JMP (ICODE * pIcode, STATE *pstate, CALL_GRAPH * pcallGr boolT Function::process_CALL (ICODE * pIcode, CALL_GRAPH * pcallGraph, STATE *pstate) { - Int ip = Icode.GetNumIcodes() - 1; + Int ip = Icode.size() - 1; STATE localState; /* Local copy of the machine state */ dword off; boolT indirect; @@ -1026,7 +1026,7 @@ static void use_def(opLoc d, ICODE * pIcode, Function * pProc, STATE * pstate, I * bitmap */ void Function::process_operands(ICODE * pIcode, STATE * pstate) { - Int ix=Icode.GetNumIcodes(); + Int ix=Icode.size(); Int i; Int sseg = (pIcode->ic.ll.src.seg)? pIcode->ic.ll.src.seg: rDS; Int cb = (pIcode->ic.ll.flg & B) ? 1: 2; diff --git a/src/proplong.cpp b/src/proplong.cpp index 3ffd3e5..bfd058f 100644 --- a/src/proplong.cpp +++ b/src/proplong.cpp @@ -76,7 +76,7 @@ static boolT isLong22 (iICODE pIcode, iICODE pEnd, Int *off) * Removes excess nodes from the graph by flagging them, and updates * the new edges for the remaining nodes. */ static void longJCond23 (COND_EXPR *rhs, COND_EXPR *lhs, iICODE pIcode, - Int *idx, Function * pProc, Int arc, Int off) + Int *idx, Int arc, Int off) { Int j; BB * pbb, * obb1, * obb2, * tbb; @@ -229,7 +229,7 @@ void Function::propLongStk (Int i, ID *pLocId) /* Check all icodes for offHi:offLo */ pEnd = Icode.end(); - for (idx = 0; idx < (this->Icode.GetNumIcodes() - 1); idx++) + for (idx = 0; idx < (this->Icode.size() - 1); idx++) { pIcode = Icode.begin()+idx; if ((pIcode->type == HIGH_LEVEL) || (pIcode->invalid == TRUE)) @@ -284,7 +284,7 @@ void Function::propLongStk (Int i, ID *pLocId) else if ((pIcode->ic.ll.opcode == iCMP) && (isLong23 (idx, pIcode->inBB, &off, &arc))) { if (checkLongEq (pLocId->id.longStkId, pIcode, i, idx, this, &rhs, &lhs, off) == TRUE) - longJCond23 (rhs, lhs, pIcode, &idx, this, arc, off); + longJCond23 (rhs, lhs, pIcode, &idx, arc, off); } /* Check for long conditional equality or inequality. This requires @@ -299,74 +299,77 @@ void Function::propLongStk (Int i, ID *pLocId) } } void checkBack(); -//int Function::checkBackwarLongDefs(int loc_ident_idx, ID *pLocId, int pLocId_idx) -//{ -// int idx; -// for (idx = pLocId_idx - 1; idx > 0 ; idx--) -// { -// pIcode = Icode.begin()+(idx-1); -// if ((pIcode->type == HIGH_LEVEL) || (pIcode->invalid == TRUE)) -// continue; +int Function::checkBackwarLongDefs(int loc_ident_idx, ID *pLocId, int pLocId_idx,Assignment &asgn) +{ + int idx; + ICODEMEM * pmH,* pmL; + iICODE pIcode; + for (idx = pLocId_idx - 1; idx > 0 ; idx--) + { + pIcode = Icode.begin()+(idx-1); + if ((pIcode->type == HIGH_LEVEL) || (pIcode->invalid == TRUE)) + continue; -// if (pIcode->ic.ll.opcode != (pIcode+1)->ic.ll.opcode) -// continue; -// switch (pIcode->ic.ll.opcode) -// { -// case iMOV: -// pmH = &pIcode->ic.ll.dst; -// pmL = &(pIcode+1)->ic.ll.dst; -// if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi)) -// { -// lhs = COND_EXPR::idLongIdx (i); -// this->localId.id_arr[i].idx.push_back(idx-1); -// pIcode->setRegDU( pmL->regi, eDEF); -// rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode, HIGH_FIRST, idx, eUSE, 1); -// pIcode->setAsgn(lhs, rhs); -// (pIcode+1)->invalidate(); -// idx = 0; /* to exit the loop */ -// } -// break; + if (pIcode->ic.ll.opcode != (pIcode+1)->ic.ll.opcode) + continue; + switch (pIcode->ic.ll.opcode) + { + case iMOV: + pmH = &pIcode->ic.ll.dst; + pmL = &(pIcode+1)->ic.ll.dst; + if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi)) + { + asgn.lhs = COND_EXPR::idLongIdx (loc_ident_idx); + this->localId.id_arr[loc_ident_idx].idx.push_back(idx-1); + pIcode->setRegDU( pmL->regi, eDEF); + asgn.rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode, HIGH_FIRST, idx, eUSE, 1); + pIcode->setAsgn(asgn.lhs, asgn.rhs); + (pIcode+1)->invalidate(); + idx = 0; /* to exit the loop */ + } + break; -// case iPOP: -// pmH = &(pIcode+1)->ic.ll.dst; -// pmL = &pIcode->ic.ll.dst; -// if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi)) -// { -// lhs = COND_EXPR::idLongIdx (i); -// pIcode->setRegDU( pmH->regi, eDEF); -// pIcode->setUnary(HLI_POP, lhs); -// (pIcode+1)->invalidate(); -// idx = 0; /* to exit the loop */ -// } -// break; + case iPOP: + pmH = &(pIcode+1)->ic.ll.dst; + pmL = &pIcode->ic.ll.dst; + if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi)) + { + asgn.lhs = COND_EXPR::idLongIdx (loc_ident_idx); + pIcode->setRegDU( pmH->regi, eDEF); + pIcode->setUnary(HLI_POP, asgn.lhs); + (pIcode+1)->invalidate(); + idx = 0; /* to exit the loop */ + } + break; // /**** others missing ***/ -// case iAND: case iOR: case iXOR: -// pmL = &pIcode->ic.ll.dst; -// pmH = &(pIcode+1)->ic.ll.dst; -// if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi)) -// { -// lhs = COND_EXPR::idLongIdx (i); -// pIcode->setRegDU( pmH->regi, USE_DEF); -// rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode, LOW_FIRST, idx, eUSE, 1); -// switch (pIcode->ic.ll.opcode) { -// case iAND: rhs = COND_EXPR::boolOp (lhs, rhs, AND); -// break; -// case iOR: -// rhs = COND_EXPR::boolOp (lhs, rhs, OR); -// break; -// case iXOR: rhs = COND_EXPR::boolOp (lhs, rhs, XOR); -// break; -// } /* eos */ -// pIcode->setAsgn(lhs, rhs); -// (pIcode+1)->invalidate(); -// idx = 0; -// } -// break; -// } /* eos */ -// } -//} + case iAND: case iOR: case iXOR: + pmL = &pIcode->ic.ll.dst; + pmH = &(pIcode+1)->ic.ll.dst; + if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi)) + { + asgn.lhs = COND_EXPR::idLongIdx (loc_ident_idx); + pIcode->setRegDU( pmH->regi, USE_DEF); + asgn.rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode, LOW_FIRST, idx, eUSE, 1); + switch (pIcode->ic.ll.opcode) { + case iAND: asgn.rhs = COND_EXPR::boolOp (asgn.lhs, asgn.rhs, AND); + break; + case iOR: + asgn.rhs = COND_EXPR::boolOp (asgn.lhs, asgn.rhs, OR); + break; + case iXOR: asgn.rhs = COND_EXPR::boolOp (asgn.lhs, asgn.rhs, XOR); + break; + } /* eos */ + pIcode->setAsgn(asgn.lhs, asgn.rhs); + (pIcode+1)->invalidate(); + idx = 0; + } + break; + } /* eos */ + } + return idx; +} /* Finds the definition of the long register pointed to by pLocId, and * transforms that instruction into a HIGH_LEVEL icode instruction. @@ -385,77 +388,9 @@ void Function::propLongReg (Int loc_ident_idx, ID *pLocId) for (int j = 0; j < pLocId->idx.size(); j++) { int pLocId_idx=pLocId->idx[j]; + Assignment asgn; /* Check backwards for a definition of this long register */ - - COND_EXPR *lhs, *rhs; - - for (idx = pLocId_idx - 1; idx > 0 ; idx--) - { - iICODE pIcode; - ICODEMEM * pmH,* pmL; /* Pointers to dst LOW_LEVEL icodes */ - pIcode = Icode.begin()+(idx-1); - if ((pIcode->type == HIGH_LEVEL) || (pIcode->invalid == TRUE)) - continue; - - if (pIcode->ic.ll.opcode != (pIcode+1)->ic.ll.opcode) - continue; - switch (pIcode->ic.ll.opcode) - { - case iMOV: - pmH = &pIcode->ic.ll.dst; - pmL = &(pIcode+1)->ic.ll.dst; - if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi)) - { - lhs = COND_EXPR::idLongIdx (loc_ident_idx); - this->localId.id_arr[loc_ident_idx].idx.push_back(idx-1); - pIcode->setRegDU( pmL->regi, eDEF); - rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode, HIGH_FIRST, idx, eUSE, 1); - pIcode->setAsgn(lhs, rhs); - (pIcode+1)->invalidate(); - idx = 0; /* to exit the loop */ - } - break; - - case iPOP: - pmH = &(pIcode+1)->ic.ll.dst; - pmL = &pIcode->ic.ll.dst; - if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi)) - { - lhs = COND_EXPR::idLongIdx (loc_ident_idx); - pIcode->setRegDU( pmH->regi, eDEF); - pIcode->setUnary(HLI_POP, lhs); - (pIcode+1)->invalidate(); - idx = 0; /* to exit the loop */ - } - break; - - /**** others missing ***/ - - case iAND: case iOR: case iXOR: - pmL = &pIcode->ic.ll.dst; - pmH = &(pIcode+1)->ic.ll.dst; - if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi)) - { - lhs = COND_EXPR::idLongIdx (loc_ident_idx); - pIcode->setRegDU( pmH->regi, USE_DEF); - rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode, LOW_FIRST, idx, eUSE, 1); - switch (pIcode->ic.ll.opcode) { - case iAND: rhs = COND_EXPR::boolOp (lhs, rhs, AND); - break; - case iOR: - rhs = COND_EXPR::boolOp (lhs, rhs, OR); - break; - case iXOR: - rhs = COND_EXPR::boolOp (lhs, rhs, XOR); - break; - } /* eos */ - pIcode->setAsgn(lhs, rhs); - (pIcode+1)->invalidate(); - idx = 0; - } - break; - } /* eos */ - } + idx = checkBackwarLongDefs(loc_ident_idx,pLocId,pLocId_idx,asgn); /* If no definition backwards, check forward for a use of this long reg */ if (idx > 0) continue; @@ -474,13 +409,12 @@ void Function::propLongReg (Int loc_ident_idx, ID *pLocId) if ((pLocId->id.longId.h == pIcode->ic.ll.src.regi) && (pLocId->id.longId.l == (pIcode+1)->ic.ll.src.regi)) { - rhs = COND_EXPR::idLongIdx (loc_ident_idx); + asgn.rhs = COND_EXPR::idLongIdx (loc_ident_idx); pIcode->setRegDU( (pIcode+1)->ic.ll.src.regi, eUSE); - lhs = COND_EXPR::idLong (&this->localId, DST, pIcode, - HIGH_FIRST, idx, eDEF, 1); - pIcode->setAsgn(lhs, rhs); + asgn.lhs = COND_EXPR::idLong (&this->localId, DST, pIcode,HIGH_FIRST, idx, eDEF, 1); + pIcode->setAsgn(asgn.lhs, asgn.rhs); (pIcode+1)->invalidate(); - idx = this->Icode.GetNumIcodes(); /* to exit the loop */ + idx = this->Icode.size(); /* to exit the loop */ } break; @@ -488,12 +422,12 @@ void Function::propLongReg (Int loc_ident_idx, ID *pLocId) if ((pLocId->id.longId.h == pIcode->ic.ll.src.regi) && (pLocId->id.longId.l == (pIcode+1)->ic.ll.src.regi)) { - rhs = COND_EXPR::idLongIdx (loc_ident_idx); + asgn.rhs = COND_EXPR::idLongIdx (loc_ident_idx); pIcode->setRegDU( (pIcode+1)->ic.ll.src.regi, eUSE); - pIcode->setUnary(HLI_PUSH, lhs); + pIcode->setUnary(HLI_PUSH, asgn.lhs); (pIcode+1)->invalidate(); } - idx = this->Icode.GetNumIcodes(); /* to exit the loop */ + idx = this->Icode.size(); /* to exit the loop */ break; /*** others missing ****/ @@ -504,19 +438,19 @@ void Function::propLongReg (Int loc_ident_idx, ID *pLocId) if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi)) { - lhs = COND_EXPR::idLongIdx (loc_ident_idx); + asgn.lhs = COND_EXPR::idLongIdx (loc_ident_idx); pIcode->setRegDU( pmH->regi, USE_DEF); - rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode, + asgn.rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode, LOW_FIRST, idx, eUSE, 1); switch (pIcode->ic.ll.opcode) { - case iAND: rhs = COND_EXPR::boolOp (lhs, rhs, AND); + case iAND: asgn.rhs = COND_EXPR::boolOp (asgn.lhs, asgn.rhs, AND); break; - case iOR: rhs = COND_EXPR::boolOp (lhs, rhs, OR); + case iOR: asgn.rhs = COND_EXPR::boolOp (asgn.lhs, asgn.rhs, OR); break; - case iXOR: rhs = COND_EXPR::boolOp (lhs, rhs, XOR); + case iXOR: asgn.rhs = COND_EXPR::boolOp (asgn.lhs, asgn.rhs, XOR); break; } - pIcode->setAsgn(lhs, rhs); + pIcode->setAsgn(asgn.lhs, asgn.rhs); (pIcode+1)->invalidate(); idx = 0; } @@ -524,12 +458,11 @@ void Function::propLongReg (Int loc_ident_idx, ID *pLocId) } /* eos */ /* Check long conditional (i.e. 2 CMPs and 3 branches */ - else if ((pIcode->ic.ll.opcode == iCMP) && - (isLong23 (idx, pIcode->inBB, &off, &arc))) + else if ((pIcode->ic.ll.opcode == iCMP) && (isLong23 (idx, pIcode->inBB, &off, &arc))) { if (checkLongRegEq (pLocId->id.longId, pIcode, loc_ident_idx, idx, this, - &rhs, &lhs, off) == TRUE) - longJCond23 (rhs, lhs, pIcode, &idx, this, arc, off); + asgn.rhs, asgn.lhs, off) == TRUE) + longJCond23 (asgn.rhs, asgn.lhs, pIcode, &idx, arc, off); } /* Check for long conditional equality or inequality. This requires @@ -538,8 +471,8 @@ void Function::propLongReg (Int loc_ident_idx, ID *pLocId) (isLong22 (pIcode, pEnd, &off))) { if (checkLongRegEq (pLocId->id.longId, pIcode, loc_ident_idx, idx, this, - &rhs, &lhs, off) == TRUE) - longJCond22 (rhs, lhs, pIcode, &idx); + asgn.rhs, asgn.lhs, off) == TRUE) + longJCond22 (asgn.rhs, asgn.lhs, pIcode, &idx); } /* Check for OR regH, regL @@ -552,12 +485,11 @@ void Function::propLongReg (Int loc_ident_idx, ID *pLocId) if ((pIcode->ic.ll.dst.regi == pLocId->id.longId.h) && (pIcode->ic.ll.src.regi == pLocId->id.longId.l)) { - lhs = COND_EXPR::idLongIdx (loc_ident_idx); + asgn.lhs = COND_EXPR::idLongIdx (loc_ident_idx); - rhs = COND_EXPR::idKte (0, 4); /* long 0 */ - lhs = COND_EXPR::boolOp (lhs, rhs, - condOpJCond[(pIcode+1)->ic.ll.opcode - iJB]); - (pIcode+1)->setJCond(lhs); + asgn.rhs = COND_EXPR::idKte (0, 4); /* long 0 */ + asgn.lhs = COND_EXPR::boolOp (asgn.lhs, asgn.rhs, condOpJCond[(pIcode+1)->ic.ll.opcode - iJB]); + (pIcode+1)->setJCond(asgn.lhs); (pIcode+1)->copyDU(*pIcode, eUSE, eUSE); pIcode->invalidate(); }