cruft removal wip
This commit is contained in:
parent
8cb5449591
commit
2b2eaeabe5
@ -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<Function>
|
||||
{
|
||||
typedef llvm::iplist<BB> BasicBlockListType;
|
||||
@ -119,7 +125,7 @@ public:
|
||||
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();
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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"
|
||||
puts "**************************************\n"
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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,22 +159,21 @@ 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))
|
||||
{
|
||||
psym = &symtab[Icode[i].ic.ll.caseTbl.numEntries];
|
||||
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++)
|
||||
{
|
||||
if (BITMAP(c, BM_CODE))
|
||||
{
|
||||
Icode[i].SetLlFlag(IMPURE);
|
||||
icod.SetLlFlag(IMPURE);
|
||||
flg |= IMPURE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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))
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
254
src/proplong.cpp
254
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();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user