Browse Source

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

Artur K 12 years ago
parent
commit
e0503c71a3
4 changed files with 24 additions and 28 deletions
  1. 1 1
      include/Procedure.h
  2. 7 11
      include/icode.h
  3. 15 15
      src/dataflow.cpp
  4. 1 1
      src/procs.cpp

+ 1 - 1
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);

+ 7 - 11
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

+ 15 - 15
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;

+ 1 - 1
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;