moved struct DU_ICODE into ICODE, alse replaced newRegArg pointer params with iterators

This commit is contained in:
Artur K 2012-02-28 16:50:15 +01:00
parent fbf8cc3a7a
commit e0503c71a3
4 changed files with 24 additions and 28 deletions

View File

@ -118,7 +118,7 @@ public:
void structLoops(derSeq *derivedG); void structLoops(derSeq *derivedG);
void buildCFG(); void buildCFG();
void controlFlowAnalysis(); void controlFlowAnalysis();
void newRegArg(ICODE *picode, ICODE *ticode); void newRegArg(iICODE picode, iICODE ticode);
protected: protected:
// TODO: replace those with friend visitor ? // TODO: replace those with friend visitor ?
void propLongReg(Int loc_ident_idx, const ID &pLocId); void propLongReg(Int loc_ident_idx, const ID &pLocId);

View File

@ -247,17 +247,6 @@ struct DU
byte u; byte u;
}; };
/* Def/Use of registers and stack variables */
struct DU_ICODE
{
std::bitset<32> def; // For Registers: position in bitset is reg index
//dword def; // For Registers: position in dword is reg index
//dword def; // For Registers: position in dword is reg index
std::bitset<32> use; // For Registers: position in dword is reg index
std::bitset<32> lastDefRegi;// Bit set if last def of this register in BB
};
/* Definition-use chain for level 1 (within a basic block) */ /* Definition-use chain for level 1 (within a basic block) */
#define MAX_REGS_DEF 2 /* 2 regs def'd for long-reg vars */ #define MAX_REGS_DEF 2 /* 2 regs def'd for long-reg vars */
#define MAX_USES 5 #define MAX_USES 5
@ -347,6 +336,13 @@ struct LLInst : public llvm::MCInst
/* Icode definition: LOW_LEVEL and HIGH_LEVEL */ /* Icode definition: LOW_LEVEL and HIGH_LEVEL */
struct ICODE struct ICODE
{ {
/* Def/Use of registers and stack variables */
struct DU_ICODE
{
std::bitset<32> def; // For Registers: position in bitset is reg index
std::bitset<32> use; // For Registers: position in dword is reg index
std::bitset<32> lastDefRegi;// Bit set if last def of this register in BB
};
struct DU1 struct DU1
{ {
struct DefUse struct DefUse

View File

@ -533,8 +533,8 @@ void Function::genDU1 ()
/* Substitutes the rhs (or lhs if rhs not possible) of ticode for the rhs /* Substitutes the rhs (or lhs if rhs not possible) of ticode for the rhs
* of picode. */ * of picode. */
static void forwardSubs (COND_EXPR *lhs, COND_EXPR *rhs, ICODE * picode, static void forwardSubs (COND_EXPR *lhs, COND_EXPR *rhs, iICODE picode,
ICODE * ticode, LOCAL_ID *locsym, Int &numHlIcodes) iICODE ticode, LOCAL_ID *locsym, Int &numHlIcodes)
{ {
boolT res; boolT res;
@ -688,15 +688,15 @@ void Function::findExps()
{ {
Int i, k, numHlIcodes; Int i, k, numHlIcodes;
iICODE lastInst, iICODE lastInst,
picode, /* Current icode */ picode, // Current icode */
ticode; /* Target icode */ ticode; // Target icode */
BB * pbb; /* Current and next basic block */ BB * pbb; // Current and next basic block */
boolT res; boolT res;
COND_EXPR *exp, /* expression pointer - for HLI_POP and HLI_CALL */ COND_EXPR *exp, // expression pointer - for HLI_POP and HLI_CALL */
*lhs; /* exp ptr for return value of a HLI_CALL */ *lhs; // exp ptr for return value of a HLI_CALL */
//STKFRAME * args; /* pointer to arguments - for HLI_CALL */ //STKFRAME * args; // pointer to arguments - for HLI_CALL */
byte regi, regi2; /* register(s) to be forward substituted */ byte regi; // register(s) to be forward substituted */
ID *retVal; /* function return value */ ID *retVal; // function return value
/* Initialize expression stack */ /* Initialize expression stack */
g_exp_stk.init(); g_exp_stk.init();
@ -745,7 +745,7 @@ void Function::findExps()
case HLI_ASSIGN: case HLI_ASSIGN:
forwardSubs (picode->ic.hl.oper.asgn.lhs, forwardSubs (picode->ic.hl.oper.asgn.lhs,
picode->ic.hl.oper.asgn.rhs, picode->ic.hl.oper.asgn.rhs,
&(*picode), &(*ticode), &localId, picode, ticode, &localId,
numHlIcodes); numHlIcodes);
break; break;
@ -763,7 +763,7 @@ void Function::findExps()
break; break;
case HLI_CALL: /* register arguments */ case HLI_CALL: /* register arguments */
newRegArg (&(*picode), &(*ticode)); newRegArg (picode, ticode);
picode->invalidate(); picode->invalidate();
numHlIcodes--; numHlIcodes--;
break; break;
@ -782,7 +782,7 @@ void Function::findExps()
switch (ticode->ic.hl.opcode) { switch (ticode->ic.hl.opcode) {
case HLI_ASSIGN: case HLI_ASSIGN:
forwardSubs (picode->ic.hl.oper.exp, exp, forwardSubs (picode->ic.hl.oper.exp, exp,
&(*picode), &(*ticode), &localId, picode, ticode, &localId,
numHlIcodes); numHlIcodes);
break; break;
@ -822,7 +822,7 @@ void Function::findExps()
&ticode->ic.hl.oper.asgn.lhs, &ticode->ic.hl.oper.asgn.lhs,
picode->ic.hl.oper.call.proc->retVal.id.regi, picode->ic.hl.oper.call.proc->retVal.id.regi,
&localId); &localId);
/*** HERE missing: 2 regs ****/ /*** TODO: HERE missing: 2 regs ****/
picode->invalidate(); picode->invalidate();
numHlIcodes--; numHlIcodes--;
break; break;
@ -899,7 +899,7 @@ void Function::findExps()
break; break;
case HLI_CALL: /* register arguments */ case HLI_CALL: /* register arguments */
newRegArg ( &(*picode), &(*ticode)); newRegArg ( picode, ticode);
picode->invalidate(); picode->invalidate();
numHlIcodes--; numHlIcodes--;
break; break;

View File

@ -94,7 +94,7 @@ void CALL_GRAPH::write()
/* Updates the argument table by including the register(s) (ie. lhs of /* Updates the argument table by including the register(s) (ie. lhs of
* picode) and the actual expression (ie. rhs of picode). * picode) and the actual expression (ie. rhs of picode).
* Note: register(s) are only included once in the table. */ * Note: register(s) are only included once in the table. */
void Function::newRegArg(ICODE *picode, ICODE *ticode) void Function::newRegArg(iICODE picode, iICODE ticode)
{ {
COND_EXPR *lhs; COND_EXPR *lhs;
STKFRAME * ps, *ts; STKFRAME * ps, *ts;