From e0503c71a399da46b2f471ef793f18c1ea86435a Mon Sep 17 00:00:00 2001 From: Artur K Date: Tue, 28 Feb 2012 16:50:15 +0100 Subject: [PATCH] moved struct DU_ICODE into ICODE, alse replaced newRegArg pointer params with iterators --- include/Procedure.h | 2 +- include/icode.h | 18 +++++++----------- src/dataflow.cpp | 30 +++++++++++++++--------------- src/procs.cpp | 2 +- 4 files changed, 24 insertions(+), 28 deletions(-) diff --git a/include/Procedure.h b/include/Procedure.h index a69bfc7..78fed5c 100644 --- a/include/Procedure.h +++ b/include/Procedure.h @@ -118,7 +118,7 @@ public: void structLoops(derSeq *derivedG); void buildCFG(); void controlFlowAnalysis(); - void newRegArg(ICODE *picode, ICODE *ticode); + void newRegArg(iICODE picode, iICODE ticode); protected: // TODO: replace those with friend visitor ? void propLongReg(Int loc_ident_idx, const ID &pLocId); diff --git a/include/icode.h b/include/icode.h index 70c4a72..d4918c1 100644 --- a/include/icode.h +++ b/include/icode.h @@ -247,17 +247,6 @@ struct DU 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) */ #define MAX_REGS_DEF 2 /* 2 regs def'd for long-reg vars */ #define MAX_USES 5 @@ -347,6 +336,13 @@ struct LLInst : public llvm::MCInst /* Icode definition: LOW_LEVEL and HIGH_LEVEL */ 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 DefUse diff --git a/src/dataflow.cpp b/src/dataflow.cpp index 7c38f09..39839f4 100644 --- a/src/dataflow.cpp +++ b/src/dataflow.cpp @@ -533,8 +533,8 @@ void Function::genDU1 () /* Substitutes the rhs (or lhs if rhs not possible) of ticode for the rhs * of picode. */ -static void forwardSubs (COND_EXPR *lhs, COND_EXPR *rhs, ICODE * picode, - ICODE * ticode, LOCAL_ID *locsym, Int &numHlIcodes) +static void forwardSubs (COND_EXPR *lhs, COND_EXPR *rhs, iICODE picode, + iICODE ticode, LOCAL_ID *locsym, Int &numHlIcodes) { boolT res; @@ -688,15 +688,15 @@ void Function::findExps() { Int i, k, numHlIcodes; iICODE lastInst, - picode, /* Current icode */ - ticode; /* Target icode */ - BB * pbb; /* Current and next basic block */ + picode, // Current icode */ + ticode; // Target icode */ + BB * pbb; // Current and next basic block */ boolT res; - COND_EXPR *exp, /* expression pointer - for HLI_POP and HLI_CALL */ - *lhs; /* exp ptr for return value of a HLI_CALL */ - //STKFRAME * args; /* pointer to arguments - for HLI_CALL */ - byte regi, regi2; /* register(s) to be forward substituted */ - ID *retVal; /* function return value */ + COND_EXPR *exp, // expression pointer - for HLI_POP and HLI_CALL */ + *lhs; // exp ptr for return value of a HLI_CALL */ + //STKFRAME * args; // pointer to arguments - for HLI_CALL */ + byte regi; // register(s) to be forward substituted */ + ID *retVal; // function return value /* Initialize expression stack */ g_exp_stk.init(); @@ -745,7 +745,7 @@ void Function::findExps() case HLI_ASSIGN: forwardSubs (picode->ic.hl.oper.asgn.lhs, picode->ic.hl.oper.asgn.rhs, - &(*picode), &(*ticode), &localId, + picode, ticode, &localId, numHlIcodes); break; @@ -763,7 +763,7 @@ void Function::findExps() break; case HLI_CALL: /* register arguments */ - newRegArg (&(*picode), &(*ticode)); + newRegArg (picode, ticode); picode->invalidate(); numHlIcodes--; break; @@ -782,7 +782,7 @@ void Function::findExps() switch (ticode->ic.hl.opcode) { case HLI_ASSIGN: forwardSubs (picode->ic.hl.oper.exp, exp, - &(*picode), &(*ticode), &localId, + picode, ticode, &localId, numHlIcodes); break; @@ -822,7 +822,7 @@ void Function::findExps() &ticode->ic.hl.oper.asgn.lhs, picode->ic.hl.oper.call.proc->retVal.id.regi, &localId); - /*** HERE missing: 2 regs ****/ + /*** TODO: HERE missing: 2 regs ****/ picode->invalidate(); numHlIcodes--; break; @@ -899,7 +899,7 @@ void Function::findExps() break; case HLI_CALL: /* register arguments */ - newRegArg ( &(*picode), &(*ticode)); + newRegArg ( picode, ticode); picode->invalidate(); numHlIcodes--; break; diff --git a/src/procs.cpp b/src/procs.cpp index dc753f4..2be3b5c 100644 --- a/src/procs.cpp +++ b/src/procs.cpp @@ -94,7 +94,7 @@ void CALL_GRAPH::write() /* Updates the argument table by including the register(s) (ie. lhs of * picode) and the actual expression (ie. rhs of picode). * 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; STKFRAME * ps, *ts;