Browse Source

LLInst opcode is private now, added accessors and moved a few functions into LLInst

Artur K 12 years ago
parent
commit
32d1b71e79
16 changed files with 312 additions and 309 deletions
  1. 9 0
      include/Enums.h
  2. 1 1
      include/dcc.h
  3. 28 20
      include/icode.h
  4. 1 1
      src/ast.cpp
  5. 7 7
      src/comwrite.cpp
  6. 11 11
      src/dataflow.cpp
  7. 125 123
      src/disassem.cpp
  8. 5 5
      src/graph.cpp
  9. 22 27
      src/hlicode.cpp
  10. 6 5
      src/idioms.cpp
  11. 3 3
      src/idioms/arith_idioms.cpp
  12. 2 3
      src/idioms/xor_idioms.cpp
  13. 5 5
      src/locident.cpp
  14. 22 24
      src/parser.cpp
  15. 35 45
      src/proplong.cpp
  16. 30 29
      src/scanner.cpp

+ 9 - 0
include/Enums.h

@@ -128,6 +128,7 @@ enum icodeType
 /* LOW_LEVEL icode opcodes */
 enum llIcode
 {
+    //iINVALID,
     iCBW,		/* 0 */
     iAAA,
     iAAD,
@@ -301,3 +302,11 @@ enum operDu
     NONE			/* No operation is required on this operand	*/
 };
 
+/* LOW_LEVEL icode, DU flag bits */
+enum eDuFlags
+{
+    Cf=1,
+    Sf=2,
+    Zf=4,
+    Df=8
+};

+ 1 - 1
include/dcc.h

@@ -175,5 +175,5 @@ int     power2 (int);
 
 /* Exported funcions from locident.c */
 boolT checkLongEq (LONG_STKID_TYPE, iICODE, int, Function *, Assignment &asgn, iICODE atOffset);
-boolT checkLongRegEq (LONGID_TYPE, iICODE, int, Function *, COND_EXPR *&, COND_EXPR *&, iICODE);
+boolT checkLongRegEq (LONGID_TYPE, iICODE, int, Function *, Assignment &asgn, iICODE);
 uint8_t otherLongRegi (uint8_t, int, LOCAL_ID *);

+ 28 - 20
include/icode.h

@@ -11,17 +11,14 @@
 #include <llvm/MC/MCInst.h>
 #include <llvm/MC/MCAsmInfo.h>
 #include "Enums.h"
+#include "state.h"			// State depends on INDEXBASE, but later need STATE
 //enum condId;
-struct LOCAL_ID;
 
-/* LOW_LEVEL icode, DU flag bits */
-enum eDuFlags
-{
-    Cf=1,
-    Sf=2,
-    Zf=4,
-    Df=8
-};
+struct LOCAL_ID;
+struct BB;
+struct Function;
+struct STKFRAME;
+struct CIcodeRec;
 
 /* uint8_t and uint16_t registers */
 static const char *const byteReg[9]  = {"al", "cl", "dl", "bl",
@@ -30,12 +27,6 @@ static const char *const wordReg[21] = {"ax", "cx", "dx", "bx", "sp", "bp",
                                         "si", "di", "es", "cs", "ss", "ds",
                                         "", "", "", "", "", "", "", "", "tmp"};
 
-#include "state.h"			// State depends on INDEXBASE, but later need STATE
-
-struct BB;
-struct Function;
-struct STKFRAME;
-
 /* Def/use of flags - low 4 bits represent flags */
 struct DU
 {
@@ -100,7 +91,7 @@ struct ExpType : public HlTypeSupport
 
 struct HLTYPE
 {
-    hlIcode              opcode;    /* hlIcode opcode           */
+    hlIcode         opcode;    /* hlIcode opcode           */
     ExpType         exp;      /* for HLI_JCOND, HLI_RET, HLI_PUSH, HLI_POP*/
     AssignType      asgn;
     CallType        call;
@@ -143,6 +134,7 @@ struct HLTYPE
     }
 public:
     std::string write1HlIcode(Function *pProc, int *numLoc);
+    void setAsgn(COND_EXPR *lhs, COND_EXPR *rhs);
 } ;
 /* LOW_LEVEL icode operand record */
 struct LLOperand //: public llvm::MCOperand
@@ -166,9 +158,9 @@ struct LLInst : public llvm::ilist_node<LLInst>
 {
 protected:
     uint32_t     flg;            /* icode flags                  */
+    llIcode      opcode;         /* llIcode instruction          */
 public:
     int          codeIdx;    	/* Index into cCode.code            */
-    llIcode      opcode;         /* llIcode instruction          */
     uint8_t      numBytes;       /* Number of bytes this instr   */
     uint32_t     label;          /* offset in image (20-bit adr) */
     LLOperand    dst;            /* destination operand          */
@@ -189,7 +181,7 @@ public:
     void  clrFlags(uint32_t flag) {flg &= ~flag;}
 
     uint32_t getFlag() const {return flg;}
-    llIcode GetLlOpcode() const { return opcode; }
+    llIcode getOpcode() const { return opcode; }
 
     uint32_t  GetLlLabel() const { return label;}
 
@@ -229,7 +221,18 @@ public:
         opcode = op;
         flg =flags;
     }
+    void setOpcode(llIcode op)
+    {
+        opcode = op;
+    }
     void emitGotoLabel(int indLevel);
+    void findJumpTargets(CIcodeRec &pc);
+    void writeIntComment(std::ostringstream &s);
+    void dis1Line(int loc_ip, int pass);
+    std::ostringstream &strSrc(std::ostringstream &os,bool skip_comma=false);
+
+    void flops(std::ostringstream &out);
+    bool isJmpInst();
 };
 
 /* Icode definition: LOW_LEVEL and HIGH_LEVEL */
@@ -306,16 +309,21 @@ public:
     const HLTYPE *      hl() const { return &m_hl;}
     int loc_ip; // used by CICodeRec to number ICODEs
 
-    void writeIntComment(std::ostringstream &s);
     void setRegDU(uint8_t regi, operDu du_in);
     void invalidate();
     void newCallHl();
     void writeDU(int idx);
     condId idType(opLoc sd);
     // HLL setting functions
-    void setAsgn(COND_EXPR *lhs, COND_EXPR *rhs); // set this icode to be an assign
+    // set this icode to be an assign
+    void setAsgn(COND_EXPR *lhs, COND_EXPR *rhs)
+    {
+        type=HIGH_LEVEL;
+        hl()->setAsgn(lhs,rhs);
+    }
     void setUnary(hlIcode op, COND_EXPR *exp);
     void setJCond(COND_EXPR *cexp);
+
     void emitGotoLabel(int indLevel);
     void copyDU(const ICODE &duIcode, operDu _du, operDu duDu);
     bool valid() {return not invalid;}

+ 1 - 1
src/ast.cpp

@@ -66,7 +66,7 @@ void ICODE::setRegDU (uint8_t regi, operDu du_in)
 /* Copies the def, use, or def and use fields of duIcode into pIcode */
 void ICODE::copyDU(const ICODE &duIcode, operDu _du, operDu duDu)
 {
-    //    printf("%s %d,%d from %d to %d\n",__FUNCTION__,int(du),int(duDu),duIcode->ll()->opcode,pIcode->ll()->opcode);
+    //    printf("%s %d,%d from %d to %d\n",__FUNCTION__,int(du),int(duDu),duIcode->ll()->getOpcode(),pIcode->ll()->getOpcode());
     switch (_du)
     {
     case eDEF:

+ 7 - 7
src/comwrite.cpp

@@ -147,20 +147,20 @@ static const char *intOthers[] = {
 
 /* Writes the description of the current interrupt. Appends it to the
  * string s.	*/
-void ICODE::writeIntComment (std::ostringstream &s)
+void LLInst::writeIntComment (std::ostringstream &s)
 {
     s<<"\t/* ";
-    if (ll()->src.op() == 0x21)
+    if (src.op() == 0x21)
     {
-        s <<int21h[ll()->dst.off];
+        s <<int21h[dst.off];
     }
-    else if (ll()->src.op() > 0x1F && ll()->src.op() < 0x2F)
+    else if (src.op() > 0x1F && src.op() < 0x2F)
     {
-        s <<intOthers[ll()->src.op() - 0x20];
+        s <<intOthers[src.op() - 0x20];
     }
-    else if (ll()->src.op() == 0x2F)
+    else if (src.op() == 0x2F)
     {
-        switch (ll()->dst.off)
+        switch (dst.off)
         {
             case 0x01 :
                 s << "Print spooler";

+ 11 - 11
src/dataflow.cpp

@@ -124,7 +124,7 @@ void Function::elimCondCodes ()
 
         for (useAt = pBB->rbegin2(); useAt != pBB->rend2(); useAt++)
         {
-            llIcode useAtOp = useAt->ll()->GetLlOpcode();
+            llIcode useAtOp = useAt->ll()->getOpcode();
             if ((useAt->type == LOW_LEVEL) && (useAt->valid()) && (use = useAt->ll()->flagDU.u))
             {
                 /* Find definition within the same basic block */
@@ -139,7 +139,7 @@ void Function::elimCondCodes ()
                     if ((useAtOp >= iJB) && (useAtOp <= iJNS))
                     {
                         iICODE befDefAt = (++riICODE(defAt)).base();
-                        switch (defAt->ll()->GetLlOpcode())
+                        switch (defAt->ll()->getOpcode())
                         {
                         case iCMP:
                             rhs = srcIdent (*defAt, this, befDefAt,*useAt, eUSE);
@@ -168,7 +168,7 @@ void Function::elimCondCodes ()
                         default:
                             notSup = TRUE;
                             std::cout << hex<<defAt->loc_ip;
-                            reportError (JX_NOT_DEF, defAt->ll()->GetLlOpcode());
+                            reportError (JX_NOT_DEF, defAt->ll()->getOpcode());
                             flg |= PROC_ASM;		/* generate asm */
                         }
                         if (! notSup)
@@ -186,11 +186,11 @@ void Function::elimCondCodes ()
                         exp = COND_EXPR::boolOp (lhs, rhs, EQUAL);
                         useAt->setJCond(exp);
                     }
-//                    else if (useAt->GetLlOpcode() == iRCL)
+//                    else if (useAt->getOpcode() == iRCL)
 //                    {
 //                        ICODE &a(*defAt);
 //                        ICODE &b(*useAt);
-//                        if(a.GetLlOpcode() == iRCL)
+//                        if(a.getOpcode() == iRCL)
 //                        {
 //                            if ((b.ll()->flg & NO_SRC) != NO_SRC)   /* if there is src op */
 //                                rhs = COND_EXPR::id (*useAt, SRC, this, Icode.end(), *useAt, NONE);
@@ -206,7 +206,7 @@ void Function::elimCondCodes ()
                     {
                         ICODE &a(*defAt);
                         ICODE &b(*useAt);
-                        reportError (NOT_DEF_USE,a.ll()->GetLlOpcode(),b.ll()->GetLlOpcode());
+                        reportError (NOT_DEF_USE,a.ll()->getOpcode(),b.ll()->getOpcode());
                         flg |= PROC_ASM;		/* generate asm */
                     }
                     break;
@@ -228,7 +228,7 @@ void Function::elimCondCodes ()
                 else if (defAt == pBB->rend2())
                 {
                     reportError(DEF_NOT_FOUND,useAtOp);
-                    //fatalError (DEF_NOT_FOUND, Icode.GetLlOpcode(useAt-1));
+                    //fatalError (DEF_NOT_FOUND, Icode.getOpcode(useAt-1));
                 }
             }
         }
@@ -680,13 +680,13 @@ static void processCArg (Function * pp, Function * pProc, ICODE * picode, int nu
             }
             else
                 adjustActArgType (exp, pp->args.sym[numArgs].type, pProc);
-        res = picode->newStkArg (exp, picode->ll()->opcode, pProc);
+        res = picode->newStkArg (exp, picode->ll()->getOpcode(), pProc);
     }
     else			/* user function */
     {
         if (pp->args.numArgs > 0)
             pp->args.adjustForArgType (numArgs, expType (exp, pProc));
-        res = picode->newStkArg (exp, picode->ll()->opcode, pProc);
+        res = picode->newStkArg (exp, picode->ll()->getOpcode(), pProc);
     }
 
     /* Do not update the size of k if the expression was a segment register
@@ -1019,13 +1019,13 @@ void Function::findExps()
                             {
                                 if (pp->args.numArgs > 0)
                                     adjustActArgType(exp, pp->args.sym[numArgs].type, this);
-                                res = picode->newStkArg (exp, picode->ll()->opcode, this);
+                                res = picode->newStkArg (exp, picode->ll()->getOpcode(), this);
                             }
                             else			/* user function */
                             {
                                 if (pp->args.numArgs >0)
                                     pp->args.adjustForArgType (numArgs,expType (exp, this));
-                                res = picode->newStkArg (exp,picode->ll()->opcode, this);
+                                res = picode->newStkArg (exp,picode->ll()->getOpcode(), this);
                             }
                             if (res == FALSE)
                                 k += hlTypeSize (exp, this);

+ 125 - 123
src/disassem.cpp

@@ -127,17 +127,14 @@ static const char *szWreg[12] = { "ax", "cx", "dx", "bx", "sp", "bp", "si", "di"
 static const char *szPtr[2]   = { "word ptr ", "byte ptr " };
 
 
-static void  dis1Line  (ICODE &icode, int pass);
 void  dis1LineOp(int i, boolT fWin, char attr, uint16_t *len, Function * pProc);
 static void  formatRM(ostringstream &p, uint32_t flg, const LLOperand &pm);
 static ostringstream &strDst(ostringstream &os, uint32_t flg, LLOperand &pm);
-static ostringstream &strSrc(ostringstream &os,const LLInst &pc,bool skip_comma=false);
 
 static char *strHex(uint32_t d);
 static int   checkScanned(uint32_t pcCur);
 static void  setProc(Function * proc);
 static void  dispData(uint16_t dataSeg);
-void flops(LLInst &pIcode, std::ostringstream &out);
 boolT callArg(uint16_t off, char *temp);  /* Check for procedure name */
 
 static  FILE   *fp;
@@ -168,6 +165,27 @@ uint8_t              iPS;          /* Index into the stack */
 #define dis_show()					// Nothing to do unless using Curses
 
 
+void LLInst::findJumpTargets(CIcodeRec &pc)
+{
+    if (testFlags(I) && ! testFlags(JMP_ICODE) && isJmpInst())
+    {
+        /* Replace the immediate operand with an icode index */
+        iICODE labTgt=pc.labelSrch(src.op());
+        if (labTgt!=pc.end())
+        {
+            src.SetImmediateOp(labTgt->loc_ip);
+            /* This icode is the target of a jump */
+            labTgt->ll()->setFlags(TARGET);
+            setFlags(JMP_ICODE);   /* So its not done twice */
+        }
+        else
+        {
+            /* This jump cannot be linked to a label */
+            setFlags(NO_LABEL);
+        }
+    }
+
+}
 /*****************************************************************************
  * disassem - Prints a disassembled listing of a procedure.
  *			  pass == 1 generates output on file .a1
@@ -214,23 +232,7 @@ void disassem(int pass, Function * ppProc)
         for( ICODE &icode : pc)
         {
             LLInst *ll=icode.ll();
-            if (ll->testFlags(I) && ! ll->testFlags(JMP_ICODE) && JmpInst(ll->opcode))
-            {
-                /* Replace the immediate operand with an icode index */
-                iICODE labTgt=pc.labelSrch(ll->src.op());
-                if (labTgt!=pc.end())
-                {
-                    ll->src.SetImmediateOp(labTgt->loc_ip);
-                    /* This icode is the target of a jump */
-                    labTgt->ll()->setFlags(TARGET);
-                    ll->setFlags(JMP_ICODE);   /* So its not done twice */
-                }
-                else
-                {
-                    /* This jump cannot be linked to a label */
-                    ll->setFlags(NO_LABEL);
-                }
-            }
+            ll->findJumpTargets(pc);
         }
     }
 
@@ -243,9 +245,10 @@ void disassem(int pass, Function * ppProc)
 
     /* Loop over array printing each record */
     nextInst = 0;
-    std::for_each(pc.begin(),
-                  pc.end(),
-                  [pass](ICODE &iter)->void {dis1Line(iter, pass);});
+    for( ICODE &icode : pc)
+    {
+        icode.ll()->dis1Line(icode.loc_ip,pass);
+    }
 
     /* Write procedure epilogue */
     if (pass != 3)
@@ -263,7 +266,7 @@ void disassem(int pass, Function * ppProc)
  * i is index into Icode for this proc                                      *
  * It is assumed that icode i is already scanned                            *
  ****************************************************************************/
-static void dis1Line(ICODE &icode_iter, int pass)
+void LLInst::dis1Line(int loc_ip, int pass)
 {
     ostringstream oper_stream;
     ostringstream hex_bytes;
@@ -271,21 +274,20 @@ static void dis1Line(ICODE &icode_iter, int pass)
 
     oper_stream << uppercase;
     hex_bytes << uppercase;
-    LLInst &_IcLL(*icode_iter.ll());
     /* Disassembly stage 1 --
          * Do not try to display NO_CODE entries or synthetic instructions,
          * other than JMPs, that have been introduced for def/use analysis. */
     if ((option.asm1) &&
-            ( _IcLL.testFlags(NO_CODE) ||
-             (_IcLL.testFlags(SYNTHETIC) && (_IcLL.opcode != iJMP))))
+            ( testFlags(NO_CODE) ||
+             (testFlags(SYNTHETIC) && (opcode != iJMP))))
     {
         return;
     }
-    else if (_IcLL.testFlags(NO_CODE))
+    else if (testFlags(NO_CODE))
     {
         return;
     }
-    if (_IcLL.testFlags(TARGET | CASE))
+    if (testFlags(TARGET | CASE))
     {
         if (pass == 3)
             cCode.appendCode("\n"); /* Print to c code buffer */
@@ -294,19 +296,19 @@ static void dis1Line(ICODE &icode_iter, int pass)
     }
 
     /* Find next instruction label and print hex bytes */
-    if (_IcLL.testFlags(SYNTHETIC))
-        nextInst = _IcLL.label;
+    if (testFlags(SYNTHETIC))
+        nextInst = label;
     else
     {
-        cb = (uint32_t) _IcLL.numBytes;
-        nextInst = _IcLL.label + cb;
+        cb = (uint32_t) numBytes;
+        nextInst = label + cb;
 
         /* Output hexa code in program image */
         if (pass != 3)
         {
             for (j = 0; j < cb; j++)
             {
-                hex_bytes << hex << setw(2) << setfill('0') << uint16_t(prog.Image[_IcLL.label + j]);
+                hex_bytes << hex << setw(2) << setfill('0') << uint16_t(prog.Image[label + j]);
             }
             hex_bytes << ' ';
         }
@@ -317,78 +319,78 @@ static void dis1Line(ICODE &icode_iter, int pass)
     oper_stream << setw(5)<<left; // align for the labels
     {
         ostringstream lab_contents;
-        if (readVal(lab_contents, _IcLL.label, 0))
+        if (readVal(lab_contents, label, 0))
         {
             lab_contents << ':';             /* Also removes the null */
         }
-        else if (_IcLL.testFlags(TARGET))    /* Symbols override Lnn labels */
+        else if (testFlags(TARGET))    /* Symbols override Lnn labels */
         {
             /* Print label */
-            if (pl.count(icode_iter.loc_ip)==0)
+            if (pl.count(loc_ip)==0)
             {
-                pl[icode_iter.loc_ip] = ++lab;
+                pl[loc_ip] = ++lab;
             }
-            lab_contents<< "L"<<pl[icode_iter.loc_ip]<<':';
+            lab_contents<< "L"<<pl[loc_ip]<<':';
         }
         oper_stream<< lab_contents.str();
     }
-    if (_IcLL.opcode == iSIGNEX && _IcLL.testFlags(B))
+    if (opcode == iSIGNEX && testFlags(B))
     {
-        _IcLL.opcode = iCBW;
+        opcode = iCBW;
     }
-    oper_stream << setw(15) << left <<szOps[_IcLL.opcode];
+    oper_stream << setw(15) << left <<szOps[opcode];
 
-    switch (_IcLL.opcode)
+    switch (opcode)
     {
         case iADD:  case iADC:  case iSUB:  case iSBB:  case iAND:  case iOR:
         case iXOR:  case iTEST: case iCMP:  case iMOV:  case iLEA:  case iXCHG:
-            strDst(oper_stream,_IcLL.getFlag(), _IcLL.dst);
-            strSrc(oper_stream,_IcLL);
+            strDst(oper_stream,getFlag(), dst);
+            strSrc(oper_stream);
             break;
 
         case iESC:
-            flops(_IcLL,oper_stream);
+            flops(oper_stream);
             break;
 
         case iSAR:  case iSHL:  case iSHR:  case iRCL:  case iRCR:  case iROL:
         case iROR:
-            strDst(oper_stream,_IcLL.getFlag() | I, _IcLL.dst);
-            if(_IcLL.testFlags(I))
-                strSrc(oper_stream,_IcLL);
+            strDst(oper_stream,getFlag() | I, dst);
+            if(testFlags(I))
+                strSrc(oper_stream);
             else
                 oper_stream<<", cl";
             break;
 
         case iINC:  case iDEC:  case iNEG:  case iNOT:  case iPOP:
-            strDst(oper_stream,_IcLL.getFlag() | I, _IcLL.dst);
+            strDst(oper_stream,getFlag() | I, dst);
             break;
 
         case iPUSH:
-            if (_IcLL.testFlags(I))
+            if (testFlags(I))
             {
-                oper_stream<<strHex(_IcLL.src.op());
+                oper_stream<<strHex(src.op());
 //                strcpy(p + WID_PTR, strHex(pIcode->ll()->immed.op));
             }
             else
             {
-                strDst(oper_stream,_IcLL.getFlag() | I, _IcLL.dst);
+                strDst(oper_stream,getFlag() | I, dst);
             }
             break;
 
         case iDIV:  case iIDIV:  case iMUL: case iIMUL: case iMOD:
-            if (_IcLL.testFlags(I))
+            if (testFlags(I))
             {
-                strDst(oper_stream,_IcLL.getFlag(), _IcLL.dst) <<", ";
-                formatRM(oper_stream, _IcLL.getFlag(), _IcLL.src);
-                strSrc(oper_stream,_IcLL);
+                strDst(oper_stream,getFlag(), dst) <<", ";
+                formatRM(oper_stream, getFlag(), src);
+                strSrc(oper_stream);
             }
             else
-                strDst(oper_stream,_IcLL.getFlag() | I, _IcLL.src);
+                strDst(oper_stream,getFlag() | I, src);
             break;
 
         case iLDS:  case iLES:  case iBOUND:
-            strDst(oper_stream,_IcLL.getFlag(), _IcLL.dst)<<", dword ptr";
-            strSrc(oper_stream,_IcLL,true);
+            strDst(oper_stream,getFlag(), dst)<<", dword ptr";
+            strSrc(oper_stream,true);
             break;
 
         case iJB:  case iJBE:  case iJAE:  case iJA:
@@ -400,71 +402,71 @@ static void dis1Line(ICODE &icode_iter, int pass)
 
             /* Check if there is a symbol here */
     {
-        ICODE *lab=pc.GetIcode(_IcLL.src.op());
+        ICODE *lab=pc.GetIcode(src.op());
             selectTable(Label);
-        if ((_IcLL.src.op() < (uint32_t)numIcode) &&  /* Ensure in range */
+        if ((src.op() < (uint32_t)numIcode) &&  /* Ensure in range */
                 readVal(oper_stream, lab->ll()->label, 0))
             {
                 break;                          /* Symbolic label. Done */
         }
             }
 
-            if (_IcLL.testFlags(NO_LABEL))
+            if (testFlags(NO_LABEL))
             {
                 //strcpy(p + WID_PTR, strHex(pIcode->ll()->immed.op));
-                oper_stream<<strHex(_IcLL.src.op());
+                oper_stream<<strHex(src.op());
             }
-            else if (_IcLL.testFlags(I) )
+            else if (testFlags(I) )
             {
-                j = _IcLL.src.op();
+                j = src.op();
                 if (pl.count(j)==0)       /* Forward jump */
                 {
                     pl[j] = ++lab;
                 }
-                if (_IcLL.opcode == iJMPF)
+                if (opcode == iJMPF)
                 {
                     oper_stream<<" far ptr ";
                 }
                 oper_stream<<"L"<<pl[j];
             }
-            else if (_IcLL.opcode == iJMPF)
+            else if (opcode == iJMPF)
             {
                 oper_stream<<"dword ptr";
-                strSrc(oper_stream,_IcLL,true);
+                strSrc(oper_stream,true);
             }
             else
             {
-                strDst(oper_stream,I, _IcLL.src);
+                strDst(oper_stream,I, src);
             }
             break;
 
         case iCALL: case iCALLF:
-            if (_IcLL.testFlags(I))
+            if (testFlags(I))
             {
-                if((_IcLL.opcode == iCALL))
+                if((opcode == iCALL))
                     oper_stream<< "near";
                 else
                     oper_stream<< " far";
-                oper_stream<<" ptr "<<(_IcLL.src.proc.proc)->name;
+                oper_stream<<" ptr "<<(src.proc.proc)->name;
             }
-            else if (_IcLL.opcode == iCALLF)
+            else if (opcode == iCALLF)
             {
                 oper_stream<<"dword ptr ";
-                strSrc(oper_stream,_IcLL,true);
+                strSrc(oper_stream,true);
             }
             else
-                strDst(oper_stream,I, _IcLL.src);
+                strDst(oper_stream,I, src);
             break;
 
         case iENTER:
-            oper_stream<<strHex(_IcLL.dst.off)<<", ";
-            oper_stream<<strHex(_IcLL.src.op());
+            oper_stream<<strHex(dst.off)<<", ";
+            oper_stream<<strHex(src.op());
             break;
 
         case iRET:  case iRETF:  case iINT:
-            if (_IcLL.testFlags(I))
+            if (testFlags(I))
             {
-                oper_stream<<strHex(_IcLL.src.op());
+                oper_stream<<strHex(src.op());
             }
             break;
 
@@ -475,46 +477,46 @@ static void dis1Line(ICODE &icode_iter, int pass)
         case iMOVS:  case iREP_MOVS:
         case iINS:   case iREP_INS:
         case iOUTS:  case iREP_OUTS:
-            if (_IcLL.src.segOver)
+            if (src.segOver)
             {
-                bool is_dx_src=(_IcLL.opcode == iOUTS || _IcLL.opcode == iREP_OUTS);
+                bool is_dx_src=(opcode == iOUTS || opcode == iREP_OUTS);
                 if(is_dx_src)
-                    oper_stream<<"dx, "<<szPtr[_IcLL.getFlag() & B];
+                    oper_stream<<"dx, "<<szPtr[getFlag() & B];
                 else
-                    oper_stream<<szPtr[_IcLL.getFlag() & B];
-                if (_IcLL.opcode == iLODS ||
-                    _IcLL.opcode == iREP_LODS ||
-                    _IcLL.opcode == iOUTS ||
-                    _IcLL.opcode == iREP_OUTS)
+                    oper_stream<<szPtr[getFlag() & B];
+                if (opcode == iLODS ||
+                    opcode == iREP_LODS ||
+                    opcode == iOUTS ||
+                    opcode == iREP_OUTS)
                 {
-                    oper_stream<<szWreg[_IcLL.src.segOver-rAX];
+                    oper_stream<<szWreg[src.segOver-rAX];
                 }
                 else
                 {
-                    oper_stream<<"es:[di], "<<szWreg[_IcLL.src.segOver - rAX];
+                    oper_stream<<"es:[di], "<<szWreg[src.segOver - rAX];
                 }
                 oper_stream<<":[si]";
             }
             else
-                oper_stream<<(_IcLL.getFlag() & B)? "B": "W";
+                oper_stream<<(getFlag() & B)? "B": "W";
             break;
 
         case iXLAT:
-            if (_IcLL.src.segOver)
+            if (src.segOver)
             {
                 oper_stream<<" "<<szPtr[1];
-                oper_stream<<szWreg[_IcLL.src.segOver-rAX]<<":[bx]";
+                oper_stream<<szWreg[src.segOver-rAX]<<":[bx]";
             }
             break;
 
         case iIN:
-            oper_stream<<(_IcLL.getFlag() & B)?"al, ": "ax, ";
-            oper_stream<<(_IcLL.testFlags(I))? strHex(_IcLL.src.op()): "dx";
+            oper_stream<<(getFlag() & B)?"al, ": "ax, ";
+            oper_stream<<(testFlags(I))? strHex(src.op()): "dx";
             break;
 
         case iOUT:
-            oper_stream<<(_IcLL.testFlags(I))? strHex(_IcLL.src.op()): "dx";
-            oper_stream<<(_IcLL.getFlag() & B)?", al": ", ax";
+            oper_stream<<(testFlags(I))? strHex(src.op()): "dx";
+            oper_stream<<(getFlag() & B)?", al": ", ax";
             break;
 
         default:
@@ -522,13 +524,13 @@ static void dis1Line(ICODE &icode_iter, int pass)
     }
 
     /* Comments */
-    if (_IcLL.testFlags(SYNTHETIC))
+    if (testFlags(SYNTHETIC))
     {
         fImpure = FALSE;
     }
     else
     {
-        for (j = _IcLL.label, fImpure = 0; j > 0 && j < (int)nextInst; j++)
+        for (j = label, fImpure = 0; j > 0 && j < (int)nextInst; j++)
         {
             fImpure |= BITMAP(j, BM_DATA);
         }
@@ -538,17 +540,17 @@ static void dis1Line(ICODE &icode_iter, int pass)
     /* Check for user supplied comment */
     selectTable(Comment);
     ostringstream cbuf;
-    if (readVal(cbuf, _IcLL.label, 0))
+    if (readVal(cbuf, label, 0))
     {
         result_stream <<"; "<<cbuf.str();
     }
-    else if (fImpure || (_IcLL.testFlags(SWITCH | CASE | SEG_IMMED | IMPURE | SYNTHETIC | TERMINATES)))
+    else if (fImpure || (testFlags(SWITCH | CASE | SEG_IMMED | IMPURE | SYNTHETIC | TERMINATES)))
     {
-        if (_IcLL.testFlags(CASE))
+        if (testFlags(CASE))
         {
-            result_stream << ";Case l"<< _IcLL.caseTbl.numEntries;
+            result_stream << ";Case l"<< caseTbl.numEntries;
         }
-        if (_IcLL.testFlags(SWITCH))
+        if (testFlags(SWITCH))
         {
             result_stream << ";Switch ";
         }
@@ -556,29 +558,29 @@ static void dis1Line(ICODE &icode_iter, int pass)
         {
             result_stream << ";Accessed as data ";
         }
-        if (_IcLL.testFlags(IMPURE))
+        if (testFlags(IMPURE))
         {
             result_stream << ";Impure operand ";
         }
-        if (_IcLL.testFlags(SEG_IMMED))
+        if (testFlags(SEG_IMMED))
         {
             result_stream << ";Segment constant";
         }
-        if (_IcLL.testFlags(TERMINATES))
+        if (testFlags(TERMINATES))
         {
             result_stream << ";Exit to DOS";
         }
     }
 
     /* Comment on iINT icodes */
-    if (_IcLL.opcode == iINT)
-        icode_iter.writeIntComment(result_stream);
+    if (opcode == iINT)
+        writeIntComment(result_stream);
 
     /* Display output line */
     if(pass==3)
     {
         /* output to .b code buffer */
-        if (_IcLL.testFlags(SYNTHETIC))
+        if (testFlags(SYNTHETIC))
             result_stream<<";Synthetic inst";
         if (pass == 3)		/* output to .b code buffer */
             cCode.appendCode("%s\n", result_stream.str().c_str());
@@ -586,15 +588,15 @@ static void dis1Line(ICODE &icode_iter, int pass)
     }
     else
     {
-        if (not _IcLL.testFlags(SYNTHETIC) )
+        if (not testFlags(SYNTHETIC) )
         {
             /* output to .a1 or .a2 file */
-            fprintf (fp, "%03ld %06lX %s\n", icode_iter.loc_ip, _IcLL.label, result_stream.str().c_str());
+            fprintf (fp, "%03ld %06lX %s\n", loc_ip, label, result_stream.str().c_str());
         }
         else		/* SYNTHETIC instruction */
         {
             result_stream<<";Synthetic inst";
-            fprintf (fp, "%03ld        %s\n", icode_iter.loc_ip, result_stream.str().c_str());
+            fprintf (fp, "%03ld        %s\n", loc_ip, result_stream.str().c_str());
         }
     }
 }
@@ -665,17 +667,17 @@ static ostringstream & strDst(ostringstream &os,uint32_t flg, LLOperand &pm)
 /****************************************************************************
  * strSrc                                                                   *
  ****************************************************************************/
-static ostringstream &strSrc(ostringstream &os,const LLInst &l_ins,bool skip_comma)
+ostringstream &LLInst::strSrc(ostringstream &os,bool skip_comma)
 {
     static char buf[30] = {", "};
     if(false==skip_comma)
         os<<", ";
-    if (l_ins.testFlags(I))
-        os<<strHex(l_ins.src.op());
-    else if (l_ins.testFlags(IM_SRC))		/* level 2 */
+    if (testFlags(I))
+        os<<strHex(src.op());
+    else if (testFlags(IM_SRC))		/* level 2 */
         os<<"dx:ax";
     else
-        formatRM(os, l_ins.getFlag(), l_ins.src);
+        formatRM(os, getFlag(), src);
 
     return os;
 }
@@ -704,15 +706,15 @@ void interactDis(Function * initProc, int initIC)
 }
 
 /* Handle the floating point opcodes (icode iESC) */
-void flops(LLInst &pIcode,std::ostringstream &out)
+void LLInst::flops(std::ostringstream &out)
 {
     char bf[30];
-    uint8_t op = (uint8_t)pIcode.src.op();
+    uint8_t op = (uint8_t)src.op();
 
     /* Note that op is set to the escape number, e.g.
         esc 0x38 is FILD */
 
-    if ((pIcode.dst.regi == 0) || (pIcode.dst.regi >= INDEXBASE))
+    if ((dst.regi == 0) || (dst.regi >= INDEXBASE))
     {
         /* The mod/rm mod bits are not set to 11 (i.e. register). This is the normal floating point opcode */
         out<<szFlops1[op]<<' ';
@@ -748,7 +750,7 @@ void flops(LLInst &pIcode,std::ostringstream &out)
                 }
         }
 
-        formatRM(out, pIcode.getFlag(), pIcode.dst);
+        formatRM(out, getFlag(), dst);
     }
     else
     {
@@ -757,7 +759,7 @@ void flops(LLInst &pIcode,std::ostringstream &out)
                    normal opcodes. Because the opcodes are slightly different for
                    this case (e.g. op=04 means FSUB if reg != 3, but FSUBR for
                    reg == 3), a separate table is used (szFlops2). */
-        int destRegIdx=pIcode.dst.regi - rAX;
+        int destRegIdx=dst.regi - rAX;
         switch (op)
         {
             case 0x0C:

+ 5 - 5
src/graph.cpp

@@ -44,10 +44,10 @@ void Function::createCFG()
         LLInst *ll = pIcode->ll();
         /* Stick a NOWHERE_NODE on the end if we terminate
                  * with anything other than a ret, jump or terminate */
-        if (ip + 1 == Icode.size() &&
-                (not ll->testFlags(TERMINATES)) &&
-                ll->opcode != iJMP && ll->opcode != iJMPF &&
-                ll->opcode != iRET && ll->opcode != iRETF)
+        if (ip + 1 == Icode.size() and
+                (not ll->testFlags(TERMINATES)) and
+                (not ll->match(iJMP)) and (not ll->match(iJMPF)) and
+                (not ll->match(iRET)) and (not ll->match(iRETF)))
         {
             pBB=BB::Create(start, ip, NOWHERE_NODE, 0, this);
         }
@@ -55,7 +55,7 @@ void Function::createCFG()
         /* Only process icodes that have valid instructions */
         else if (not ll->testFlags(NO_CODE) )
         {
-            switch (ll->opcode) {
+            switch (ll->getOpcode()) {
                 case iJB:  case iJBE:  case iJAE:  case iJA:
                 case iJL:  case iJLE:  case iJGE:  case iJG:
                 case iJE:  case iJNE:  case iJS:   case iJNS:

+ 22 - 27
src/hlicode.cpp

@@ -28,10 +28,9 @@ static char buf[lineSize];     /* Line buffer for hl icode output */
 
 
 /* Places the new HLI_ASSIGN high-level operand in the high-level icode array */
-void ICODE::setAsgn(COND_EXPR *lhs, COND_EXPR *rhs)
+void HLTYPE::setAsgn(COND_EXPR *lhs, COND_EXPR *rhs)
 {
-    type = HIGH_LEVEL;
-    hl()->set(lhs,rhs);
+    set(lhs,rhs);
 
 }
 void ICODE::checkHlCall()
@@ -155,7 +154,7 @@ void Function::highLevelGen()
                     lhs = COND_EXPR::id (*pIcode, DST, this, i, *pIcode, NONE);
                 }
 
-            switch (ll->opcode)
+            switch (ll->getOpcode())
             {
                 case iADD:
                     rhs = COND_EXPR::boolOp (lhs, rhs, ADD);
@@ -452,38 +451,34 @@ int power2 (int i)
  * instruction. */
 void ICODE::writeDU(int idx)
 {
-    static char buf[100];
-    int i, j;
-
-    memset (buf, ' ', sizeof(buf));
-    buf[0] = '\0';
-    for (i = 0; i < (INDEXBASE-1); i++)
     {
-        if (du.def[i])
-        {
-            strcat (buf, allRegs[i]);
-            strcat (buf, " ");
-        }
+        ostringstream ostr;
+        for (int i = 0; i < (INDEXBASE-1); i++)
+            if (du.def[i])
+                ostr << allRegs[i] << " ";
+        if (!ostr.str().empty())
+            printf ("Def (reg) = %s\n", ostr.str().c_str());
     }
-    if (buf[0] != '\0')
-        printf ("Def (reg) = %s\n", buf);
-
-    memset (buf, ' ', sizeof(buf));
-    buf[0] = '\0';
-    for (i = 0; i < INDEXBASE; i++)
     {
-        if (du.use[i])
+        ostringstream ostr;
+        for (int i = 0; i < (INDEXBASE-1); i++)
+            if (du.def[i])
+                ostr << allRegs[i] << " ";
+        if (!ostr.str().empty())
+            printf ("Def (reg) = %s\n", ostr.str().c_str());
+        for (int i = 0; i < INDEXBASE; i++)
         {
-            strcat (buf, allRegs[i]);
-            strcat (buf, " ");
+            if (du.use[i])
+                ostr << allRegs[i] << " ";
         }
+        if (!ostr.str().empty())
+            printf ("Use (reg) = %s\n", ostr.str().c_str());
+
     }
-    if (buf[0] != '\0')
-        printf ("Use (reg) = %s\n", buf);
 
     /* Print du1 chain */
     printf ("# regs defined = %d\n", du1.numRegsDef);
-    for (i = 0; i < MAX_REGS_DEF; i++)
+    for (int i = 0; i < MAX_REGS_DEF; i++)
     {
         if (du1.used(i))
         {

+ 6 - 5
src/idioms.cpp

@@ -19,9 +19,10 @@
 /*****************************************************************************
  * JmpInst - Returns TRUE if opcode is a conditional or unconditional jump
  ****************************************************************************/
-bool JmpInst(llIcode opcode)
+bool LLInst::isJmpInst()
 {
-    switch (opcode) {
+    switch (opcode)
+    {
         case iJMP:  case iJMPF: case iJCXZ:
         case iLOOP: case iLOOPE:case iLOOPNE:
         case iJB:   case iJBE:  case iJAE:  case iJA:
@@ -77,7 +78,7 @@ void Function::findIdioms()
     typedef boost::filter_iterator<is_valid,iICODE> ifICODE;
     while (pIcode != pEnd)
     {
-        switch (pIcode->ll()->opcode)
+        switch (pIcode->ll()->getOpcode())
         {
             case iDEC: case iINC:
             if (i18.match(pIcode))
@@ -231,7 +232,7 @@ void Function::bindIcodeOff()
     for(ICODE &c : Icode)
         {
         LLInst *ll=c.ll();
-        if (ll->testFlags(I) && JmpInst(ll->opcode))
+        if (ll->testFlags(I) && ll->isJmpInst())
         {
             iICODE loc=Icode.labelSrch(ll->src.op());
             if (loc!=Icode.end())
@@ -246,7 +247,7 @@ void Function::bindIcodeOff()
     for(ICODE &icode : Icode)
         {
         LLInst *ll=icode.ll();
-        if (not JmpInst(ll->opcode))
+        if (not ll->isJmpInst())
             continue;
         if (ll->testFlags(I) )
             {

+ 3 - 3
src/idioms/arith_idioms.cpp

@@ -163,7 +163,7 @@ int Idiom18::action() // action length
     lhs     = COND_EXPR::id (*m_icodes[0], SRC, m_func, m_icodes[1], *m_icodes[1], eUSE);
     lhs     = COND_EXPR::unary ( m_is_dec ? POST_DEC : POST_INC, lhs);
     rhs     = COND_EXPR::id (*m_icodes[2], SRC, m_func, m_icodes[1], *m_icodes[3], eUSE);
-    expr    = COND_EXPR::boolOp (lhs, rhs, condOpJCond[m_icodes[3]->ll()->opcode - iJB]);
+    expr    = COND_EXPR::boolOp (lhs, rhs, condOpJCond[m_icodes[3]->ll()->getOpcode() - iJB]);
     m_icodes[3]->setJCond(expr);
 
     m_icodes[0]->invalidate();
@@ -214,7 +214,7 @@ int Idiom19::action()
     lhs = COND_EXPR::id (*m_icodes[1], DST, m_func, m_icodes[0], *m_icodes[1], eUSE);
     lhs = COND_EXPR::unary (m_is_dec ? PRE_DEC : PRE_INC, lhs);
     rhs = COND_EXPR::idKte (0, 2);
-    expr = COND_EXPR::boolOp (lhs, rhs, condOpJCond[m_icodes[1]->ll()->opcode - iJB]);
+    expr = COND_EXPR::boolOp (lhs, rhs, condOpJCond[m_icodes[1]->ll()->getOpcode() - iJB]);
     m_icodes[1]->setJCond(expr);
     m_icodes[0]->invalidate();
     return 2;
@@ -303,7 +303,7 @@ int Idiom20::action()
     lhs  = COND_EXPR::id (*m_icodes[1], SRC, m_func, m_icodes[0], *m_icodes[0], eUSE);
     lhs  = COND_EXPR::unary (m_is_dec ? PRE_DEC : PRE_INC, lhs);
     rhs  = COND_EXPR::id (*m_icodes[2], SRC, m_func, m_icodes[0], *m_icodes[3], eUSE);
-    expr = COND_EXPR::boolOp (lhs, rhs, condOpJCond[m_icodes[3]->ll()->opcode - iJB]);
+    expr = COND_EXPR::boolOp (lhs, rhs, condOpJCond[m_icodes[3]->ll()->getOpcode() - iJB]);
     m_icodes[3]->setJCond(expr);
     for(int i=0; i<3; ++i)
         m_icodes[i]->invalidate();

+ 2 - 3
src/idioms/xor_idioms.cpp

@@ -126,9 +126,8 @@ bool Idiom10::match(iICODE pIcode)
 
 int Idiom10::action()
 {
-    m_icodes[0]->ll()->opcode = iCMP;
-    m_icodes[0]->ll()->setFlags(I);
-      m_icodes[0]->ll()->src.SetImmediateOp(0); // todo check if proc should be zeroed too
+    m_icodes[0]->ll()->set(iCMP,I);
+    m_icodes[0]->ll()->src.SetImmediateOp(0); // todo check if proc should be zeroed too
     m_icodes[0]->du.def = 0;
     m_icodes[0]->du1.numRegsDef = 0;
     return 2;

+ 5 - 5
src/locident.cpp

@@ -362,7 +362,7 @@ boolT checkLongEq (LONG_STKID_TYPE longId, iICODE pIcode, int i, Function * pPro
  *            pProc     : ptr to current procedure record
  *            rhs, lhs  : return expressions if successful. */
 boolT checkLongRegEq (LONGID_TYPE longId, iICODE pIcode, int i,
-                      Function * pProc, COND_EXPR *&rhs, COND_EXPR *&lhs, iICODE atOffset)
+                      Function * pProc, Assignment &asgn, iICODE atOffset)
 {
     LLOperand *pmHdst, *pmLdst, *pmHsrc, *pmLsrc;  /* pointers to LOW_LEVEL icodes */
 //    iICODE atOffset(pIcode);
@@ -375,17 +375,17 @@ boolT checkLongRegEq (LONGID_TYPE longId, iICODE pIcode, int i,
 
     if ((longId.h == pmHdst->regi) && (longId.l == pmLdst->regi))
     {
-        lhs = COND_EXPR::idLongIdx (i);
+        asgn.lhs = COND_EXPR::idLongIdx (i);
         if ( not pIcode->ll()->testFlags(NO_SRC) )
         {
-            rhs = COND_EXPR::idLong (&pProc->localId, SRC, pIcode, HIGH_FIRST,  pIcode, eUSE, atOffset);
+            asgn.rhs = COND_EXPR::idLong (&pProc->localId, SRC, pIcode, HIGH_FIRST,  pIcode, eUSE, atOffset);
         }
         return true;
     }
     else if ((longId.h == pmHsrc->regi) && (longId.l == pmLsrc->regi))
     {
-        lhs = COND_EXPR::idLong (&pProc->localId, DST, pIcode, HIGH_FIRST, pIcode, eDEF, atOffset);
-        rhs = COND_EXPR::idLongIdx (i);
+        asgn.lhs = COND_EXPR::idLong (&pProc->localId, DST, pIcode, HIGH_FIRST, pIcode, eDEF, atOffset);
+        asgn.rhs = COND_EXPR::idLongIdx (i);
         return true;
     }
     return false;

+ 22 - 24
src/parser.cpp

@@ -153,12 +153,12 @@ void Function::FollowCtrl(CALL_GRAPH * pcallGraph, STATE *pstate)
         }
 
         /* Copy Icode to Proc */
-        if ((_Icode.ll()->opcode == iDIV) || (_Icode.ll()->opcode == iIDIV))
+        if ((_Icode.ll()->getOpcode() == iDIV) || (_Icode.ll()->getOpcode() == iIDIV))
         {
             /* MOV rTMP, reg */
             eIcode = ICODE();
             eIcode.type = LOW_LEVEL;
-            eIcode.ll()->opcode = iMOV;
+            eIcode.ll()->set(iMOV,0);
             eIcode.ll()->dst.regi = rTMP;
             if (ll->testFlags(B) )
             {
@@ -184,19 +184,19 @@ void Function::FollowCtrl(CALL_GRAPH * pcallGraph, STATE *pstate)
             /* iMOD */
             eIcode = ICODE();
             eIcode.type = LOW_LEVEL;
-            eIcode.ll()->opcode = iMOD;
+            eIcode.ll()->set(iMOD,0);
             eIcode.ll()->src = _Icode.ll()->src;
             eIcode.du = _Icode.du;
             eIcode.ll()->setFlags( ( ll->getFlag() | SYNTHETIC) );
             eIcode.ll()->label = SynthLab++;
             pIcode = Icode.addIcode(&eIcode);
         }
-        else if (_Icode.ll()->opcode == iXCHG)
+        else if (_Icode.ll()->getOpcode() == iXCHG)
         {
             /* MOV rTMP, regDst */
             eIcode = ICODE();
             eIcode.type = LOW_LEVEL;
-            eIcode.ll()->opcode = iMOV;
+            eIcode.ll()->set(iMOV,0);
             eIcode.ll()->dst.regi = rTMP;
             eIcode.ll()->src.regi = _Icode.ll()->dst.regi;
             eIcode.setRegDU( rTMP, eDEF);
@@ -207,28 +207,26 @@ void Function::FollowCtrl(CALL_GRAPH * pcallGraph, STATE *pstate)
             Icode.addIcode(&eIcode);
 
             /* MOV regDst, regSrc */
-            _Icode.ll()->opcode = iMOV;
-            ll->setFlags( SYNTHETIC );
+            _Icode.ll()->set(iMOV,SYNTHETIC);
             /* Icode.ll()->label = SynthLab++; */
             Icode.addIcode(&_Icode);
-            ll->opcode = iXCHG; /* for next case */
+            ll->setOpcode(iXCHG); /* for next case */
 
             /* MOV regSrc, rTMP */
             eIcode = ICODE();
             eIcode.type = LOW_LEVEL;
-            eIcode.ll()->opcode = iMOV;
+            eIcode.ll()->set(iMOV,SYNTHETIC);
             eIcode.ll()->dst.regi = ll->src.regi;
             eIcode.ll()->src.regi = rTMP;
             eIcode.setRegDU( eIcode.ll()->dst.regi, eDEF);
             eIcode.setRegDU( rTMP, eUSE);
-            eIcode.ll()->setFlags(SYNTHETIC);
             eIcode.ll()->label = SynthLab++;
             pIcode = Icode.addIcode(&eIcode);
         }
         else
             pIcode = Icode.addIcode(&_Icode);
 
-        switch (ll->opcode) {
+        switch (ll->getOpcode()) {
             /*** Conditional jumps ***/
             case iLOOP: case iLOOPE:    case iLOOPNE:
             case iJB:   case iJBE:      case iJAE:  case iJA:
@@ -246,15 +244,15 @@ void Function::FollowCtrl(CALL_GRAPH * pcallGraph, STATE *pstate)
                 /* This sets up range check for indexed JMPs hopefully
              * Handles JA/JAE for fall through and JB/JBE on branch
             */
-                if (ip > 0 && prev.ll()->opcode == iCMP && (prev.ll()->testFlags(I)))
+                if (ip > 0 && prev.ll()->getOpcode() == iCMP && (prev.ll()->testFlags(I)))
                 {
                     pstate->JCond.immed = (int16_t)prev.ll()->src.op();
-                    if (ll->opcode == iJA || ll->opcode == iJBE)
+                    if (ll->match(iJA) || ll->match(iJBE) )
                         pstate->JCond.immed++;
-                    if (ll->opcode == iJAE || ll->opcode == iJA)
+                    if (ll->getOpcode() == iJAE || ll->getOpcode() == iJA)
                         pstate->JCond.regi = prev.ll()->dst.regi;
                     fBranch = (boolT)
-                            (ll->opcode == iJB || ll->opcode == iJBE);
+                            (ll->getOpcode() == iJB || ll->getOpcode() == iJBE);
                 }
                 StCopy = *pstate;
                 //memcpy(&StCopy, pstate, sizeof(STATE));
@@ -286,7 +284,7 @@ void Function::FollowCtrl(CALL_GRAPH * pcallGraph, STATE *pstate)
                 /*** Returns ***/
             case iRET:
             case iRETF:
-                this->flg |= (ll->opcode == iRET)? PROC_NEAR:PROC_FAR;
+                this->flg |= (ll->getOpcode() == iRET)? PROC_NEAR:PROC_FAR;
                 /* Fall through */
             case iIRET:
                 this->flg &= ~TERMINATES;
@@ -357,7 +355,7 @@ void Function::FollowCtrl(CALL_GRAPH * pcallGraph, STATE *pstate)
                 if ((psym = lookupAddr(&ll->src, pstate, 4, eDuVal::USE))
                         /* && (Icode.ll()->flg & SEG_IMMED) */ ) {
                     offset = LH(&prog.Image[psym->label]);
-                    pstate->setState( (ll->opcode == iLDS)? rDS: rES,
+                    pstate->setState( (ll->getOpcode() == iLDS)? rDS: rES,
                                       LH(&prog.Image[psym->label + 2]));
                     pstate->setState( ll->dst.regi, (int16_t)offset);
                     psym->type = TYPE_PTR;
@@ -393,7 +391,7 @@ boolT Function::process_JMP (ICODE & pIcode, STATE *pstate, CALL_GRAPH * pcallGr
 
     if (pIcode.ll()->testFlags(I))
     {
-        if (pIcode.ll()->opcode == iJMPF)
+        if (pIcode.ll()->getOpcode() == iJMPF)
             pstate->setState( rCS, LH(prog.Image + pIcode.ll()->label + 3));
         i = pstate->IP = pIcode.ll()->src.op();
         if ((long)i < 0)
@@ -545,7 +543,7 @@ boolT Function::process_CALL (ICODE & pIcode, CALL_GRAPH * pcallGraph, STATE *ps
         /* Address of function is given by 4 (CALLF) or 2 (CALL) bytes at
                  * previous offset into the program image */
         uint32_t tgtAddr=0;
-        if (pIcode.ll()->opcode == iCALLF)
+        if (pIcode.ll()->getOpcode() == iCALLF)
             tgtAddr= LH(&prog.Image[off]) + (uint32_t)(LH(&prog.Image[off+2])) << 4;
         else
             tgtAddr= LH(&prog.Image[off]) + (uint32_t)(uint16_t)state.r[rCS] << 4;
@@ -595,7 +593,7 @@ boolT Function::process_CALL (ICODE & pIcode, CALL_GRAPH * pcallGraph, STATE *ps
             /* Save machine state in localState, load up IP and CS.*/
             localState = *pstate;
             pstate->IP = pIcode.ll()->src.op();
-            if (pIcode.ll()->opcode == iCALLF)
+            if (pIcode.ll()->getOpcode() == iCALLF)
                 pstate->setState( rCS, LH(prog.Image + pIcode.ll()->label + 3));
             x.state = *pstate;
 
@@ -1022,7 +1020,7 @@ void Function::process_operands(ICODE & pIcode,  STATE * pstate)
     int   cb   = pIcode.ll()->testFlags(B) ? 1: 2;
     uint32_t Imm  = (pIcode.ll()->testFlags(I));
 
-    switch (pIcode.ll()->opcode) {
+    switch (pIcode.ll()->getOpcode()) {
         case iAND:  case iOR:   case iXOR:
         case iSAR:  case iSHL:  case iSHR:
         case iRCL:  case iRCR:  case iROL:  case iROR:
@@ -1096,7 +1094,7 @@ void Function::process_operands(ICODE & pIcode,  STATE * pstate)
             cb = 4;
         case iCALL:  case iPUSH:  case iPOP:
             if (! Imm) {
-                if (pIcode.ll()->opcode == iPOP)
+                if (pIcode.ll()->getOpcode() == iPOP)
                     def(DST, pIcode, this, pstate, cb, ix);
                 else
                     use(DST, pIcode, this, pstate, cb, ix);
@@ -1108,7 +1106,7 @@ void Function::process_operands(ICODE & pIcode,  STATE * pstate)
             break;
 
         case iLDS:  case iLES:
-            pIcode.du.def |= duReg[(pIcode.ll()->opcode == iLDS) ? rDS : rES];
+            pIcode.du.def |= duReg[(pIcode.ll()->getOpcode() == iLDS) ? rDS : rES];
             pIcode.du1.numRegsDef++;
             cb = 4;
         case iMOV:
@@ -1157,7 +1155,7 @@ void Function::process_operands(ICODE & pIcode,  STATE * pstate)
         case iSCAS:  case iSTOS:  case iINS:
             pIcode.du.def |= duReg[rDI];
             pIcode.du1.numRegsDef++;
-            if (pIcode.ll()->opcode == iREP_INS || pIcode.ll()->opcode== iINS)
+            if (pIcode.ll()->getOpcode() == iREP_INS || pIcode.ll()->getOpcode()== iINS)
             {
                 pIcode.du.use |= duReg[rDI] | duReg[rES] | duReg[rDX];
             }

+ 35 - 45
src/proplong.cpp

@@ -35,7 +35,7 @@ static bool isLong23 (iICODE iter, BB * pbb, iICODE &off, int *arc)
     if ((t->size() == 1) && (t->nodeType == TWO_BRANCH) && (t->inEdges.size() == 1))
     {
         obb2 = t->edges[THEN].BBptr;
-        if ((obb2->size() == 2) && (obb2->nodeType == TWO_BRANCH) && (obb2->front().ll()->opcode == iCMP))
+        if ((obb2->size() == 2) && (obb2->nodeType == TWO_BRANCH) && (obb2->front().ll()->getOpcode() == iCMP))
         {
             off = obb2->begin2();//std::distance(iter,obb2->begin2());
             *arc = THEN;
@@ -47,7 +47,7 @@ static bool isLong23 (iICODE iter, BB * pbb, iICODE &off, int *arc)
     else if ((e->size() == 1) && (e->nodeType == TWO_BRANCH) && (e->inEdges.size() == 1))
     {
         obb2 = e->edges[THEN].BBptr;
-        if ((obb2->size() == 2) && (obb2->nodeType == TWO_BRANCH) &&  (obb2->front().ll()->opcode == iCMP))
+        if ((obb2->size() == 2) && (obb2->nodeType == TWO_BRANCH) &&  (obb2->front().ll()->getOpcode() == iCMP))
         {
             off = obb2->begin2();//std::distance(iter,obb2->begin2());//obb2->front().loc_ip - i;
             *arc = ELSE;
@@ -67,8 +67,8 @@ static boolT isLong22 (iICODE pIcode, iICODE pEnd, iICODE &off)
     // preincrement because pIcode is not checked here
     iICODE icodes[] = { ++pIcode,++pIcode,++pIcode };
     if (   icodes[1]->ll()->match(iCMP) &&
-           (isJCond (icodes[0]->ll()->opcode)) &&
-           (isJCond (icodes[2]->ll()->opcode)))
+           (isJCond (icodes[0]->ll()->getOpcode())) &&
+           (isJCond (icodes[2]->ll()->getOpcode())))
     {
         off = initial_icode;
         advance(off,2);
@@ -142,7 +142,7 @@ static int longJCond23 (COND_EXPR *rhs, COND_EXPR *lhs, iICODE pIcode, int arc,
     iICODE atOffset1(atOffset),next1(++iICODE(pIcode));
     advance(atOffset1,1);
     /* Create new HLI_JCOND and condition */
-    lhs = COND_EXPR::boolOp (lhs, rhs, condOpJCond[atOffset1->ll()->opcode-iJB]);
+    lhs = COND_EXPR::boolOp (lhs, rhs, condOpJCond[atOffset1->ll()->getOpcode()-iJB]);
     next1->setJCond(lhs);
     next1->copyDU(*pIcode, eUSE, eUSE);
     next1->du.use |= atOffset->du.use;
@@ -177,7 +177,7 @@ static int longJCond22 (COND_EXPR *rhs, COND_EXPR *lhs, iICODE pIcode,iICODE pEn
     iICODE icodes[] = { pIcode++,pIcode++,pIcode++,pIcode++ };
 
     /* Form conditional expression */
-    lhs = COND_EXPR::boolOp (lhs, rhs, condOpJCond[icodes[3]->ll()->opcode - iJB]);
+    lhs = COND_EXPR::boolOp (lhs, rhs, condOpJCond[icodes[3]->ll()->getOpcode() - iJB]);
     icodes[1]->setJCond(lhs);
     icodes[1]->copyDU (*icodes[0], eUSE, eUSE);
     icodes[1]->du.use |= icodes[2]->du.use;
@@ -198,7 +198,7 @@ static int longJCond22 (COND_EXPR *rhs, COND_EXPR *lhs, iICODE pIcode,iICODE pEn
         assert(iter!=tbb->inEdges.end());
         tbb->inEdges.erase(iter);
 
-        if (icodes[3]->ll()->opcode != iJE)
+        if (icodes[3]->ll()->getOpcode() != iJE)
             tbb->inEdges.push_back(pbb); /* iJNE => replace arc */
 
         /* Modify ELSE out edge of header basic block */
@@ -208,7 +208,7 @@ static int longJCond22 (COND_EXPR *rhs, COND_EXPR *lhs, iICODE pIcode,iICODE pEn
         iter=std::find(tbb->inEdges.begin(),tbb->inEdges.end(),obb1);
         assert(iter!=tbb->inEdges.end());
         tbb->inEdges.erase(iter);
-        if (icodes[3]->ll()->opcode == iJE)	/* replace */
+        if (icodes[3]->ll()->getOpcode() == iJE)	/* replace */
             tbb->inEdges.push_back(pbb);
 
         /* Update statistics */
@@ -246,22 +246,19 @@ void Function::propLongStk (int i, const ID &pLocId)
             break;
         if ((pIcode->type == HIGH_LEVEL) || (pIcode->invalid == TRUE))
             continue;
-        if (pIcode->ll()->opcode == next1->ll()->opcode)
+        if (pIcode->ll()->getOpcode() == next1->ll()->getOpcode())
         {
-            switch (pIcode->ll()->opcode)
+            if (checkLongEq (pLocId.id.longStkId, pIcode, i, this, asgn, next1) == TRUE)
             {
-            case iMOV:
-                if (checkLongEq (pLocId.id.longStkId, pIcode, i, this, asgn, next1) == TRUE)
+                switch (pIcode->ll()->getOpcode())
                 {
+                case iMOV:
                     pIcode->setAsgn(asgn.lhs, asgn.rhs);
                     next1->invalidate();
-                }
-                break;
+                    break;
 
-            case iAND: case iOR: case iXOR:
-                if (checkLongEq (pLocId.id.longStkId, pIcode, i, this, asgn, next1) == TRUE)
-                {
-                    switch (pIcode->ll()->opcode)
+                case iAND: case iOR: case iXOR:
+                    switch (pIcode->ll()->getOpcode())
                     {
                     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;
@@ -269,27 +266,20 @@ void Function::propLongStk (int i, const ID &pLocId)
                     }
                     pIcode->setAsgn(asgn.lhs, asgn.rhs);
                     next1->invalidate();
-                }
-                break;
+                    break;
 
-            case iPUSH:
-                if (checkLongEq (pLocId.id.longStkId, pIcode, i, this, asgn, next1) == TRUE)
-                {
+                case iPUSH:
                     pIcode->setUnary( HLI_PUSH, asgn.lhs);
                     next1->invalidate();
-                }
-                break;
-            default:
-                printf("Wild ass checkLongEq");
-//                if (checkLongEq (pLocId.id.longStkId, pIcode, i, this, asgn, next1) == TRUE)
-//                {
-//                    printf("Wild ass checkLongEq success on opcode %d\n",pIcode->ll()->opcode);
-//                }
-            } /*eos*/
+                    break;
+                default:
+                    printf("Wild ass checkLongEq success on opcode %d\n",pIcode->ll()->getOpcode());
+                } /*eos*/
+            }
         }
 
         /* Check long conditional (i.e. 2 CMPs and 3 branches */
-        else if ((pIcode->ll()->opcode == iCMP) && (isLong23 (pIcode, pIcode->inBB, l23, &arc)))
+        else if ((pIcode->ll()->getOpcode() == iCMP) && (isLong23 (pIcode, pIcode->inBB, l23, &arc)))
         {
             if ( checkLongEq (pLocId.id.longStkId, pIcode, i, this, asgn, l23) )
             {
@@ -299,7 +289,7 @@ void Function::propLongStk (int i, const ID &pLocId)
 
         /* Check for long conditional equality or inequality.  This requires
                  * 2 CMPs and 2 branches */
-        else if ((pIcode->ll()->opcode == iCMP) && isLong22 (pIcode, pEnd, l23))
+        else if ((pIcode->ll()->getOpcode() == iCMP) && isLong22 (pIcode, pEnd, l23))
         {
             if ( checkLongEq (pLocId.id.longStkId, pIcode, i, this,asgn, l23) )
             {
@@ -324,10 +314,10 @@ int Function::findBackwarLongDefs(int loc_ident_idx, const ID &pLocId, iICODE be
 
         if ((icode.type == HIGH_LEVEL) || (icode.invalid == TRUE))
             continue;
-        if (icode.ll()->opcode != next1->ll()->opcode)
+        if (icode.ll()->getOpcode() != next1->ll()->getOpcode())
             continue;
 
-        switch (icode.ll()->opcode)
+        switch (icode.ll()->getOpcode())
         {
         case iMOV:
             pmH = &icode.ll()->dst;
@@ -368,7 +358,7 @@ int Function::findBackwarLongDefs(int loc_ident_idx, const ID &pLocId, iICODE be
                 asgn.lhs = COND_EXPR::idLongIdx (loc_ident_idx);
                 asgn.rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode, LOW_FIRST, pIcode/*idx*/, eUSE, next1);
                 icode.setRegDU( pmH->regi, USE_DEF);
-                switch (icode.ll()->opcode)
+                switch (icode.ll()->getOpcode())
                 {
                 case iAND: asgn.rhs = COND_EXPR::boolOp (asgn.lhs, asgn.rhs, AND);
                     break;
@@ -404,8 +394,8 @@ int Function::findForwardLongUses(int loc_ident_idx, const ID &pLocId, iICODE be
         if ((pIcode->type == HIGH_LEVEL) || (pIcode->invalid == TRUE))
             continue;
 
-        if (pIcode->ll()->opcode == next1->ll()->opcode)
-            switch (pIcode->ll()->opcode)
+        if (pIcode->ll()->getOpcode() == next1->ll()->getOpcode())
+            switch (pIcode->ll()->getOpcode())
             {
             case iMOV:
                 if ((pLocId.id.longId.h == pIcode->ll()->src.regi) &&
@@ -446,7 +436,7 @@ int Function::findForwardLongUses(int loc_ident_idx, const ID &pLocId, iICODE be
                     pIcode->setRegDU( pmH->regi, USE_DEF);
                     asgn.rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode,
                                                   LOW_FIRST, pIcode, eUSE, next1);
-                    switch (pIcode->ll()->opcode) {
+                    switch (pIcode->ll()->getOpcode()) {
                     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);
@@ -465,9 +455,9 @@ int Function::findForwardLongUses(int loc_ident_idx, const ID &pLocId, iICODE be
             } /* eos */
 
         /* Check long conditional (i.e. 2 CMPs and 3 branches */
-        else if ((pIcode->ll()->opcode == iCMP) && (isLong23 (pIcode, pIcode->inBB, long_loc, &arc)))
+        else if ((pIcode->ll()->getOpcode() == iCMP) && (isLong23 (pIcode, pIcode->inBB, long_loc, &arc)))
         {
-            if (checkLongRegEq (pLocId.id.longId, pIcode, loc_ident_idx, this, asgn.rhs, asgn.lhs, long_loc))
+            if (checkLongRegEq (pLocId.id.longId, pIcode, loc_ident_idx, this, asgn, long_loc))
             {
                                 // reduce the advance by 1 here (loop increases) ?
                 advance(pIcode,longJCond23 (asgn.rhs, asgn.lhs, pIcode, arc, long_loc));
@@ -478,7 +468,7 @@ int Function::findForwardLongUses(int loc_ident_idx, const ID &pLocId, iICODE be
              * 2 CMPs and 2 branches */
         else if (pIcode->ll()->match(iCMP) && (isLong22 (pIcode, pEnd, long_loc)))
         {
-            if (checkLongRegEq (pLocId.id.longId, pIcode, loc_ident_idx, this, asgn.rhs, asgn.lhs, long_loc) )
+            if (checkLongRegEq (pLocId.id.longId, pIcode, loc_ident_idx, this, asgn, long_loc) )
             {
                 advance(pIcode,longJCond22 (asgn.rhs, asgn.lhs, pIcode,pEnd) - 1);
             }
@@ -488,13 +478,13 @@ int Function::findForwardLongUses(int loc_ident_idx, const ID &pLocId, iICODE be
              *			 JX lab
              *		=> HLI_JCOND (regH:regL X 0) lab
              * This is better code than HLI_JCOND (HI(regH:regL) | LO(regH:regL)) */
-        else if (pIcode->ll()->match(iOR) && (next1 != pEnd) && (isJCond (next1->ll()->opcode)))
+        else if (pIcode->ll()->match(iOR) && (next1 != pEnd) && (isJCond (next1->ll()->getOpcode())))
         {
             if ((pIcode->ll()->dst.regi == pLocId.id.longId.h) && (pIcode->ll()->src.regi == pLocId.id.longId.l))
             {
                 asgn.lhs = COND_EXPR::idLongIdx (loc_ident_idx);
                 asgn.rhs = COND_EXPR::idKte (0, 4);	/* long 0 */
-                asgn.lhs = COND_EXPR::boolOp (asgn.lhs, asgn.rhs, condOpJCond[next1->ll()->opcode - iJB]);
+                asgn.lhs = COND_EXPR::boolOp (asgn.lhs, asgn.rhs, condOpJCond[next1->ll()->getOpcode() - iJB]);
                 next1->setJCond(asgn.lhs);
                 next1->copyDU(*pIcode, eUSE, eUSE);
                 pIcode->invalidate();

+ 30 - 29
src/scanner.cpp

@@ -352,7 +352,7 @@ eErrorId scan(uint32_t ip, ICODE &p)
 
     } while (stateTable[op].state1 == prefix);	/* Loop if prefix */
 
-    if (p.ll()->opcode)
+    if (p.ll()->getOpcode())
     {
         /* Save bytes of image used */
         p.ll()->numBytes = (uint8_t)((pInst - prog.Image) - ip);
@@ -503,7 +503,7 @@ static void segrm(int i)
     int	reg = REG(*pInst) + rES;
 
     if (reg > rDS || (reg == rCS && (stateTable[i].flg & TO_REG)))
-        pIcode->ll()->opcode = (llIcode)0;
+        pIcode->ll()->setOpcode((llIcode)0); // setCBW because it has that index
     else {
         setAddress(i, FALSE, 0, (int16_t)reg, 0);
         rm(i);
@@ -566,7 +566,7 @@ static void memImp(int i)
 static void memOnly(int )
 {
     if ((*pInst & 0xC0) == 0xC0)
-        pIcode->ll()->opcode = (llIcode)0;
+        pIcode->ll()->setOpcode((llIcode)0);
 }
 
 
@@ -576,7 +576,7 @@ static void memOnly(int )
 static void memReg0(int i)
 {
     if (REG(*pInst) || (*pInst & 0xC0) == 0xC0)
-        pIcode->ll()->opcode = (llIcode)0;
+        pIcode->ll()->setOpcode((llIcode)0);
     else
         rm(i);
 }
@@ -590,12 +590,12 @@ static void immed(int i)
     static llIcode immedTable[8] = {iADD, iOR, iADC, iSBB, iAND, iSUB, iXOR, iCMP};
     static uint8_t uf[8] = { 0,  0,  Cf,  Cf,  0,   0,   0,   0  };
 
-    pIcode->ll()->opcode = immedTable[REG(*pInst)];
+    pIcode->ll()->setOpcode(immedTable[REG(*pInst)]) ;
     pIcode->ll()->flagDU.u = uf[REG(*pInst)];
     pIcode->ll()->flagDU.d = (Sf | Zf | Cf);
     rm(i);
 
-    if (pIcode->ll()->opcode == iADD || pIcode->ll()->opcode == iSUB)
+    if (pIcode->ll()->getOpcode() == iADD || pIcode->ll()->getOpcode() == iSUB)
         pIcode->ll()->clrFlags(NOT_HLL);	/* Allow ADD/SUB SP, immed */
 }
 
@@ -613,7 +613,7 @@ static void shift(int i)
     static uint8_t df[8]	  = {Cf,  Cf,  Cf,  Cf, Sf | Zf | Cf,
                              Sf | Zf | Cf, 0, Sf | Zf | Cf};
 
-    pIcode->ll()->opcode = shiftTable[REG(*pInst)];
+    pIcode->ll()->setOpcode(shiftTable[REG(*pInst)]);
     pIcode->ll()->flagDU.u = uf[REG(*pInst)];
     pIcode->ll()->flagDU.d = df[REG(*pInst)];
     rm(i);
@@ -634,13 +634,13 @@ static void trans(int i)
     static uint8_t df[8]	= {Sf | Zf, Sf | Zf, 0, 0, 0, 0, 0, 0};
     LLInst *ll = pIcode->ll();
     if ((uint8_t)REG(*pInst) < 2 || !(stateTable[i].flg & B)) { /* INC & DEC */
-        ll->opcode = transTable[REG(*pInst)];   /* valid on bytes */
+        ll->setOpcode(transTable[REG(*pInst)]);   /* valid on bytes */
         ll->flagDU.d = df[REG(*pInst)];
         rm(i);
         ll->src = pIcode->ll()->dst;
-        if (ll->opcode == iJMP || ll->opcode == iCALL || ll->opcode == iCALLF)
+        if (ll->match(iJMP) || ll->match(iCALL) || ll->match(iCALLF))
             ll->setFlags(NO_OPS);
-        else if (ll->opcode == iINC || ll->opcode == iPUSH || ll->opcode == iDEC)
+        else if (ll->match(iINC) || ll->match(iPUSH) || ll->match(iDEC))
             ll->setFlags(NO_SRC);
     }
 }
@@ -650,17 +650,18 @@ static void trans(int i)
  arith - Sets up dst and opcode from modrm uint8_t
  ****************************************************************************/
 static void arith(int i)
-{ uint8_t opcode;
+{
+    uint8_t opcode;
     static llIcode arithTable[8] =
     {
-        (llIcode)iTEST, (llIcode)0,		(llIcode)iNOT, (llIcode)iNEG,
-        (llIcode)iMUL,  (llIcode)iIMUL, (llIcode)iDIV, (llIcode)iIDIV
+        iTEST , (llIcode)0, iNOT, iNEG,
+        iMUL ,       iIMUL, iDIV, iIDIV
     };
     static uint8_t df[8]	  = {Sf | Zf | Cf, 0, 0, Sf | Zf | Cf,
                              Sf | Zf | Cf, Sf | Zf | Cf, Sf | Zf | Cf,
                              Sf | Zf | Cf};
-
-    opcode = pIcode->ll()->opcode = arithTable[REG(*pInst)];
+    opcode = arithTable[REG(*pInst)];
+    pIcode->ll()->setOpcode((llIcode)opcode);
     pIcode->ll()->flagDU.d = df[REG(*pInst)];
     rm(i);
     if (opcode == iTEST)
@@ -709,7 +710,7 @@ static void data2(int )
          * on the stack.  The procedure level is stored in the immediate
          * field.  There is no source operand; therefore, the flag flg is
          * set to NO_OPS.	*/
-    if (pIcode->ll()->opcode == iENTER)
+    if (pIcode->ll()->getOpcode() == iENTER)
     {
         pIcode->ll()->dst.off = getWord();
         pIcode->ll()->setFlags(NO_OPS);
@@ -776,15 +777,17 @@ static void dispF(int )
  ****************************************************************************/
 static void prefix(int )
 {
-    if (pIcode->ll()->opcode == iREPE || pIcode->ll()->opcode == iREPNE)
-        RepPrefix = pIcode->ll()->opcode;
+    if (pIcode->ll()->getOpcode() == iREPE || pIcode->ll()->getOpcode() == iREPNE)
+        RepPrefix = pIcode->ll()->getOpcode();
     else
-        SegPrefix = pIcode->ll()->opcode;
+        SegPrefix = pIcode->ll()->getOpcode();
 }
 
-inline void BumpOpcode(llIcode& ic)
+inline void BumpOpcode(LLInst &ll)
 {
+    llIcode ic = ll.getOpcode();
     ic = (llIcode)(((int)ic)+1);		// Bump this icode via the int type
+    ll.setOpcode(ic);
 }
 
 /*****************************************************************************
@@ -794,14 +797,13 @@ static void strop(int )
 {
     if (RepPrefix)
     {
-        //		pIcode->ll()->opcode += ((pIcode->ll()->opcode == iCMPS ||
-        //								  pIcode->ll()->opcode == iSCAS)
+        //		pIcode->ll()->getOpcode() += ((pIcode->ll()->getOpcode() == iCMPS ||
+        //								  pIcode->ll()->getOpcode() == iSCAS)
         //								&& RepPrefix == iREPE)? 2: 1;
-        if ((pIcode->ll()->opcode == iCMPS || pIcode->ll()->opcode == iSCAS)
-                && RepPrefix == iREPE)
-            BumpOpcode(pIcode->ll()->opcode);	// += 2
-        BumpOpcode(pIcode->ll()->opcode);		// else += 1
-        if (pIcode->ll()->opcode == iREP_LODS)
+        if ((pIcode->ll()->match(iCMPS) || pIcode->ll()->match(iSCAS) ) && RepPrefix == iREPE)
+            BumpOpcode(*pIcode->ll());	// += 2
+        BumpOpcode(*pIcode->ll());		// else += 1
+        if (pIcode->ll()->match(iREP_LODS) )
             pIcode->ll()->setFlags(NOT_HLL);
         RepPrefix = 0;
     }
@@ -867,8 +869,7 @@ static void checkInt(int )
         /* This is a Borland/Microsoft floating point emulation instruction.
             Treat as if it is an ESC opcode */
         pIcode->ll()->src.SetImmediateOp(wOp - 0x34);
-        pIcode->ll()->opcode = iESC;
-        pIcode->ll()->setFlags(FLOAT_OP);
+        pIcode->ll()->set(iESC,FLOAT_OP);
 
         escop(wOp - 0x34 + 0xD8);