Moved most of register definitions to use eReg enum
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
/* Machine registers */
|
||||
enum eReg
|
||||
{
|
||||
rUNDEF = 0,
|
||||
rAX = 1, /* These are numbered relative to real 8086 */
|
||||
rCX = 2,
|
||||
rDX = 3,
|
||||
|
||||
@@ -165,6 +165,6 @@ protected:
|
||||
void findIdioms();
|
||||
void propLong();
|
||||
void genLiveKtes();
|
||||
uint8_t findDerivedSeq (derSeq *derivedGi);
|
||||
bool nextOrderGraph(derSeq *derivedGi);
|
||||
uint8_t findDerivedSeq (derSeq &derivedGi);
|
||||
bool nextOrderGraph(derSeq &derivedGi);
|
||||
};
|
||||
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
static COND_EXPR *idRegIdx(int idx, regType reg_type);
|
||||
static COND_EXPR *idKte(uint32_t kte, uint8_t size);
|
||||
static COND_EXPR *idLoc(int off, LOCAL_ID *localId);
|
||||
static COND_EXPR *idReg(uint8_t regi, uint32_t icodeFlg, LOCAL_ID *locsym);
|
||||
static COND_EXPR *idReg(eReg regi, uint32_t icodeFlg, LOCAL_ID *locsym);
|
||||
static COND_EXPR *idLongIdx(int idx);
|
||||
static COND_EXPR *idOther(uint8_t seg, uint8_t regi, int16_t off);
|
||||
static COND_EXPR *idParam(int off, const STKFRAME *argSymtab);
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
static COND_EXPR * id(const LLInst &ll_insn, opLoc sd, Function *pProc, iICODE ix_, ICODE &duIcode, operDu du);
|
||||
static COND_EXPR *boolOp(COND_EXPR *_lhs, COND_EXPR *_rhs, condOp _op);
|
||||
static bool insertSubTreeLongReg(COND_EXPR *exp, COND_EXPR **tree, int longIdx);
|
||||
static bool insertSubTreeReg(COND_EXPR *&tree, COND_EXPR *_expr, uint8_t regi, LOCAL_ID *locsym);
|
||||
static bool insertSubTreeReg(COND_EXPR *&tree, COND_EXPR *_expr, eReg regi, LOCAL_ID *locsym);
|
||||
public:
|
||||
virtual COND_EXPR *clone();
|
||||
void release();
|
||||
@@ -106,7 +106,7 @@ public:
|
||||
public:
|
||||
virtual COND_EXPR *inverse(); // return new COND_EXPR that is invarse of this
|
||||
virtual bool xClear(iICODE f, iICODE t, iICODE lastBBinst, Function *pproc);
|
||||
virtual COND_EXPR *insertSubTreeReg(COND_EXPR *_expr, uint8_t regi, LOCAL_ID *locsym);
|
||||
virtual COND_EXPR *insertSubTreeReg(COND_EXPR *_expr, eReg regi, LOCAL_ID *locsym);
|
||||
virtual COND_EXPR *insertSubTreeLongReg(COND_EXPR *_expr, int longIdx);
|
||||
};
|
||||
struct BinaryOperator : public COND_EXPR
|
||||
@@ -124,7 +124,7 @@ struct BinaryOperator : public COND_EXPR
|
||||
virtual COND_EXPR *inverse();
|
||||
virtual COND_EXPR *clone();
|
||||
virtual bool xClear(iICODE f, iICODE t, iICODE lastBBinst, Function *pproc);
|
||||
virtual COND_EXPR *insertSubTreeReg(COND_EXPR *_expr, uint8_t regi, LOCAL_ID *locsym);
|
||||
virtual COND_EXPR *insertSubTreeReg(COND_EXPR *_expr, eReg regi, LOCAL_ID *locsym);
|
||||
virtual COND_EXPR *insertSubTreeLongReg(COND_EXPR *_expr, int longIdx);
|
||||
|
||||
COND_EXPR *lhs()
|
||||
|
||||
@@ -101,7 +101,7 @@ extern PROG prog; /* Loaded program image parameters */
|
||||
extern std::bitset<32> duReg[30]; /* def/use bits for registers */
|
||||
|
||||
//extern uint32_t duReg[30]; /* def/use bits for registers */
|
||||
extern uint32_t maskDuReg[30]; /* masks off du bits for regs */
|
||||
extern std::bitset<32> maskDuReg[30]; /* masks off du bits for regs */
|
||||
|
||||
/* Registers used by icode instructions */
|
||||
static constexpr const char *allRegs[21] = {"ax", "cx", "dx", "bx", "sp", "bp",
|
||||
@@ -174,4 +174,4 @@ 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 *, Assignment &asgn, iICODE);
|
||||
uint8_t otherLongRegi (uint8_t, int, LOCAL_ID *);
|
||||
eReg otherLongRegi(eReg, int, LOCAL_ID *);
|
||||
|
||||
@@ -45,10 +45,10 @@ struct COND_EXPR;
|
||||
struct HlTypeSupport
|
||||
{
|
||||
//hlIcode opcode; /* hlIcode opcode */
|
||||
virtual bool removeRegFromLong(uint8_t regi, LOCAL_ID *locId)=0;
|
||||
virtual bool removeRegFromLong(eReg regi, LOCAL_ID *locId)=0;
|
||||
virtual std::string writeOut(Function *pProc, int *numLoc)=0;
|
||||
protected:
|
||||
void performLongRemoval (uint8_t regi, LOCAL_ID *locId, COND_EXPR *tree);
|
||||
void performLongRemoval (eReg regi, LOCAL_ID *locId, COND_EXPR *tree);
|
||||
};
|
||||
|
||||
struct CallType : public HlTypeSupport
|
||||
@@ -60,7 +60,7 @@ struct CallType : public HlTypeSupport
|
||||
bool newStkArg(COND_EXPR *exp, llIcode opcode, Function *pproc);
|
||||
void placeStkArg(COND_EXPR *exp, int pos);
|
||||
public:
|
||||
bool removeRegFromLong(uint8_t regi, LOCAL_ID *locId)
|
||||
bool removeRegFromLong(eReg regi, LOCAL_ID *locId)
|
||||
{
|
||||
printf("CallType : removeRegFromLong not supproted");
|
||||
return false;
|
||||
@@ -72,7 +72,7 @@ struct AssignType : public HlTypeSupport
|
||||
/* for HLI_ASSIGN */
|
||||
COND_EXPR *lhs;
|
||||
COND_EXPR *rhs;
|
||||
bool removeRegFromLong(uint8_t regi, LOCAL_ID *locId)
|
||||
bool removeRegFromLong(eReg regi, LOCAL_ID *locId)
|
||||
{
|
||||
performLongRemoval(regi,locId,lhs);
|
||||
return true;
|
||||
@@ -83,7 +83,7 @@ struct ExpType : public HlTypeSupport
|
||||
{
|
||||
/* for HLI_JCOND, HLI_RET, HLI_PUSH, HLI_POP*/
|
||||
COND_EXPR *v;
|
||||
bool removeRegFromLong(uint8_t regi, LOCAL_ID *locId)
|
||||
bool removeRegFromLong(eReg regi, LOCAL_ID *locId)
|
||||
{
|
||||
performLongRemoval(regi,locId,v);
|
||||
return true;
|
||||
@@ -156,7 +156,7 @@ struct LLOperand //: public llvm::MCOperand
|
||||
uint8_t seg; /* CS, DS, ES, SS */
|
||||
int16_t segValue; /* Value of segment seg during analysis */
|
||||
uint8_t segOver; /* CS, DS, ES, SS if segment override */
|
||||
uint8_t regi; /* 0 < regs < INDEXBASE <= index modes */
|
||||
eReg regi; /* 0 < regs < INDEXBASE <= index modes */
|
||||
int16_t off; /* memory address offset */
|
||||
uint32_t opz; /* idx of immed src op */
|
||||
//union {/* Source operand if (flg & I) */
|
||||
@@ -352,7 +352,7 @@ public:
|
||||
void copyDU(const ICODE &duIcode, operDu _du, operDu duDu);
|
||||
bool valid() {return not invalid;}
|
||||
public:
|
||||
bool removeDefRegi(uint8_t regi, int thisDefIdx, LOCAL_ID *locId);
|
||||
bool removeDefRegi(eReg regi, int thisDefIdx, LOCAL_ID *locId);
|
||||
void checkHlCall();
|
||||
bool newStkArg(COND_EXPR *exp, llIcode opcode, Function *pproc)
|
||||
{
|
||||
@@ -372,3 +372,11 @@ public:
|
||||
iterator labelSrch(uint32_t target);
|
||||
ICODE * GetIcode(int ip);
|
||||
};
|
||||
constexpr eReg subRegH(eReg reg)
|
||||
{
|
||||
return eReg((int)reg + (int)rAH-(int)rAX);
|
||||
}
|
||||
constexpr eReg subRegL(eReg reg)
|
||||
{
|
||||
return eReg((int)reg + (int)rAL-(int)rAX);
|
||||
}
|
||||
|
||||
@@ -8,11 +8,11 @@ struct Idiom14 : public Idiom
|
||||
{
|
||||
protected:
|
||||
iICODE m_icodes[2];
|
||||
uint8_t m_regL;
|
||||
uint8_t m_regH;
|
||||
eReg m_regL;
|
||||
eReg m_regH;
|
||||
public:
|
||||
virtual ~Idiom14() {}
|
||||
Idiom14(Function *f) : Idiom(f),m_regL(0),m_regH(0)
|
||||
Idiom14(Function *f) : Idiom(f),m_regL(rUNDEF),m_regH(rUNDEF)
|
||||
{
|
||||
}
|
||||
uint8_t minimum_match_length() {return 2;}
|
||||
@@ -24,7 +24,7 @@ struct Idiom13 : public Idiom
|
||||
{
|
||||
protected:
|
||||
iICODE m_icodes[2];
|
||||
uint8_t m_loaded_reg;
|
||||
eReg m_loaded_reg;
|
||||
public:
|
||||
virtual ~Idiom13() {}
|
||||
Idiom13(Function *f) : Idiom(f)
|
||||
|
||||
@@ -55,8 +55,8 @@ typedef struct
|
||||
} LONG_STKID_TYPE;
|
||||
typedef struct
|
||||
{ /* For TYPE_LONG_(UN)SIGN registers */
|
||||
uint8_t h; /* high register */
|
||||
uint8_t l; /* low register */
|
||||
eReg h; /* high register */
|
||||
eReg l; /* low register */
|
||||
} LONGID_TYPE;
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ struct ID
|
||||
char macro[10]; /* Macro for this identifier */
|
||||
char name[20]; /* Identifier's name */
|
||||
union { /* Different types of identifiers */
|
||||
uint8_t regi; /* For TYPE_BYTE(uint16_t)_(UN)SIGN registers */
|
||||
eReg regi; /* For TYPE_BYTE(uint16_t)_(UN)SIGN registers */
|
||||
struct { /* For TYPE_BYTE(uint16_t)_(UN)SIGN on the stack */
|
||||
uint8_t regOff; /* register offset (if any) */
|
||||
int off; /* offset from BP */
|
||||
@@ -113,10 +113,10 @@ public:
|
||||
{
|
||||
id_arr.reserve(256);
|
||||
}
|
||||
int newByteWordReg(hlType t, uint8_t regi);
|
||||
int newByteWordReg(hlType t, eReg regi);
|
||||
int newByteWordStk(hlType t, int off, uint8_t regOff);
|
||||
int newIntIdx(int16_t seg, int16_t off, uint8_t regi, int ix, hlType t);
|
||||
int newLongReg(hlType t, uint8_t regH, uint8_t regL, iICODE ix_);
|
||||
int newLongReg(hlType t, eReg regH, eReg regL, iICODE ix_);
|
||||
int newLong(opLoc sd, iICODE pIcode, hlFirst f, iICODE ix, operDu du, int off);
|
||||
int newLong(opLoc sd, iICODE pIcode, hlFirst f, iICODE ix, operDu du, iICODE atOffset);
|
||||
void newIdent(hlType t, frameType f);
|
||||
|
||||
Reference in New Issue
Block a user