Removed lints

This commit is contained in:
Artur K
2012-03-10 22:46:15 +01:00
parent eb6c1ac939
commit 3bcbb7a2cf
35 changed files with 301 additions and 472 deletions

View File

@@ -40,6 +40,7 @@ private:
//friend class SymbolTableListTraits<BB, Function>;
iICODE range_start;
iICODE range_end;
public:
iICODE begin();
iICODE end() const;

View File

@@ -15,6 +15,7 @@ struct bundle
public:
void appendCode(const char *format, ...);
void appendDecl(const char *format, ...);
void appendDecl(const std::string &);
strTable decl; /* Declarations */
strTable code; /* C code */
};

View File

@@ -104,10 +104,6 @@ extern std::bitset<32> duReg[30]; /* def/use bits for registers */
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",
"si", "di", "es", "cs", "ss", "ds",
"al", "cl", "dl", "bl", "ah", "ch", "dh", "bh",
"tmp"};
/* Memory map states */
#define BM_UNKNOWN 0 /* Unscanned memory */
@@ -169,7 +165,7 @@ hlType expType (const COND_EXPR *, Function *);
std::string writeCall (Function *, STKFRAME *, Function *, int *);
char *writeJcond (const HLTYPE &, Function *, int *);
char *writeJcondInv (HLTYPE, Function *, int *);
int power2 (int);
/* Exported funcions from locident.c */
boolT checkLongEq (LONG_STKID_TYPE, iICODE, int, Function *, Assignment &asgn, iICODE atOffset);
@@ -177,6 +173,6 @@ boolT checkLongRegEq (LONGID_TYPE, iICODE, int, Function *, Assignment &asgn, iI
eReg otherLongRegi(eReg, int, LOCAL_ID *);
extern eReg subRegH(eReg reg);
extern eReg subRegH(eReg reg); //TODO: move these into machine_x86
extern eReg subRegL(eReg reg);
extern const char *indentStr(int level);

View File

@@ -2,6 +2,11 @@
* dcc project disassembler header
* (C) Mike van Emmerik
****************************************************************************/
#pragma once
#include <sstream>
#include <vector>
#include "bundle.h"
struct LLInst;
/* Definitions for extended keys (first key is zero) */

View File

@@ -30,7 +30,7 @@ enum eErrorId
WHILE_FAIL
};
//lint -function(exit,fatalError)
void fatalError(eErrorId errId, ...);
void reportError(eErrorId errId, ...);

View File

@@ -3,11 +3,13 @@
* (C) Cristina Cifuentes
****************************************************************************/
#pragma once
#include <memory>
#include <vector>
#include <list>
#include <bitset>
#include <llvm/ADT/ilist.h>
#include <llvm/ADT/ilist_node.h>
#include <llvm/CodeGen/MachineInstr.h>
#include <llvm/MC/MCInst.h>
#include <llvm/MC/MCAsmInfo.h>
#include "Enums.h"
@@ -20,9 +22,12 @@ struct Function;
struct STKFRAME;
struct CIcodeRec;
struct ICODE;
struct bundle;
typedef std::list<ICODE>::iterator iICODE;
typedef std::list<ICODE>::reverse_iterator riICODE;
/* uint8_t and uint16_t registers */
/* Def/use of flags - low 4 bits represent flags */
struct DU
{
@@ -65,19 +70,19 @@ struct AssignType : public HlTypeSupport
/* for HLI_ASSIGN */
COND_EXPR *lhs;
COND_EXPR *rhs;
AssignType() : lhs(0),rhs(0) {}
bool removeRegFromLong(eReg regi, LOCAL_ID *locId)
{
performLongRemoval(regi,locId,lhs);
return true;
}
std::string writeOut(Function *pProc, int *numLoc);
AssignType() : lhs(0),rhs(0)
{}
};
struct ExpType : public HlTypeSupport
{
/* for HLI_JCOND, HLI_RET, HLI_PUSH, HLI_POP*/
COND_EXPR *v;
ExpType() : v(0) {}
bool removeRegFromLong(eReg regi, LOCAL_ID *locId)
{
performLongRemoval(regi,locId,v);
@@ -148,7 +153,7 @@ public:
void setAsgn(COND_EXPR *lhs, COND_EXPR *rhs);
} ;
/* LOW_LEVEL icode operand record */
struct LLOperand //: public llvm::MCOperand
struct LLOperand : public llvm::MCOperand
{
eReg seg; /* CS, DS, ES, SS */
int16_t segValue; /* Value of segment seg during analysis */
@@ -161,15 +166,22 @@ struct LLOperand //: public llvm::MCOperand
Function *proc; /* pointer to target proc (for CALL(F))*/
int cb; /* # actual arg bytes */
} proc;
LLOperand() : seg(rUNDEF),segValue(0),segOver(rUNDEF),regi(rUNDEF),off(0),opz(0)
{
proc.proc=0;
proc.cb=0;
}
uint32_t op() const {return opz;}
void SetImmediateOp(uint32_t dw) {opz=dw;}
bool isReg() const;
};
struct LLInst : public llvm::ilist_node<LLInst>
struct LLInst : public llvm::MCInst //: public llvm::ilist_node<LLInst>
{
protected:
uint32_t flg; /* icode flags */
llIcode opcode; /* llIcode instruction */
// llIcode opcode; /* llIcode instruction */
public:
int codeIdx; /* Index into cCode.code */
uint8_t numBytes; /* Number of bytes this instr */
@@ -185,13 +197,13 @@ public:
int hllLabNum; /* label # for hll codegen */
bool conditionalJump()
{
return (opcode >= iJB) && (opcode < iJCXZ);
return (getOpcode() >= iJB) && (getOpcode() < iJCXZ);
}
bool testFlags(uint32_t x) const { return (flg & x)!=0;}
void setFlags(uint32_t flag) {flg |= flag;}
void clrFlags(uint32_t flag)
{
if(opcode==iMOD)
if(getOpcode()==iMOD)
{
assert(false);
}
@@ -199,7 +211,7 @@ public:
}
uint32_t getFlag() const {return flg;}
llIcode getOpcode() const { return opcode; }
//llIcode getOpcode() const { return opcode; }
uint32_t GetLlLabel() const { return label;}
@@ -208,19 +220,19 @@ public:
bool match(llIcode op)
{
return (opcode==op);
return (getOpcode()==op);
}
bool match(llIcode op,eReg dest)
{
return (opcode==op)&&dst.regi==dest;
return (getOpcode()==op)&&dst.regi==dest;
}
bool match(llIcode op,eReg dest,uint32_t flgs)
{
return (opcode==op) and (dst.regi==dest) and testFlags(flgs);
return (getOpcode()==op) and (dst.regi==dest) and testFlags(flgs);
}
bool match(llIcode op,eReg dest,eReg src_reg)
{
return (opcode==op)&&(dst.regi==dest)&&(src.regi==src_reg);
return (getOpcode()==op)&&(dst.regi==dest)&&(src.regi==src_reg);
}
bool match(eReg dest,eReg src_reg)
{
@@ -232,17 +244,13 @@ public:
}
bool match(llIcode op,uint32_t flgs)
{
return (opcode==op) and testFlags(flgs);
return (getOpcode()==op) and testFlags(flgs);
}
void set(llIcode op,uint32_t flags)
{
opcode = op;
setOpcode(op);
flg =flags;
}
void setOpcode(llIcode op)
{
opcode = op;
}
void emitGotoLabel(int indLevel);
void findJumpTargets(CIcodeRec &_pc);
void writeIntComment(std::ostringstream &s);
@@ -253,6 +261,11 @@ public:
bool isJmpInst();
HLTYPE toHighLevel(COND_EXPR *lhs, COND_EXPR *rhs, Function *func);
HLTYPE createCall();
LLInst(ICODE *container) : m_link(container),flg(0)
{
}
ICODE *m_link;
};
/* Icode definition: LOW_LEVEL and HIGH_LEVEL */
@@ -261,6 +274,7 @@ struct ICODE
protected:
LLInst m_ll;
HLTYPE m_hl;
bool invalid; /* Has no HIGH_LEVEL equivalent */
public:
/* Def/Use of registers and stack variables */
struct DU_ICODE
@@ -317,18 +331,20 @@ public:
Use &u(idx[regIdx]);
u.removeUser(ic);
}
DU1() : numRegsDef(0) {}
};
icodeType type; /* Icode type */
bool invalid; /* Has no HIGH_LEVEL equivalent */
BB *inBB; /* BB to which this icode belongs */
DU_ICODE du; /* Def/use regs/vars */
DU1 du1; /* du chain 1 */
int loc_ip; // used by CICodeRec to number ICODEs
LLInst * ll() { return &m_ll;}
const LLInst * ll() const { return &m_ll;}
HLTYPE * hl() { return &m_hl;}
const HLTYPE * hl() const { return &m_hl;}
void hl(const HLTYPE &v) { m_hl=v;}
int loc_ip; // used by CICodeRec to number ICODEs
void setRegDU(eReg regi, operDu du_in);
void invalidate();
@@ -355,8 +371,15 @@ public:
{
return hl()->call.newStkArg(exp,opcode,pproc);
}
ICODE() : m_ll(this),type(NOT_SCANNED),inBB(0),loc_ip(0),invalid(false)
{
}
};
struct MappingLLtoML
{
std::list<std::shared_ptr<LLInst> > m_low_level;
std::list<std::shared_ptr<HLTYPE> > m_middle_level;
};
// This is the icode array object.
class CIcodeRec : public std::list<ICODE>
{

View File

@@ -1,5 +1,8 @@
#pragma once
#include <stdint.h>
#include <string>
#include <sstream>
#include <bitset>
/* Machine registers */
enum eReg
{
@@ -45,4 +48,18 @@ class Machine_X86
public:
Machine_X86();
static const std::string &regName(eReg r);
static const std::string &opcodeName(unsigned r);
static bool physicalReg(eReg r);
/* Writes the registers that are set in the bitvector */
//TODO: move this into Machine_X86 ?
static void writeBitVector (std::ostream &ostr,const std::bitset<32> &regi)
{
int j;
for (j = rAX; j < INDEX_BX_SI; j++)
{
if (regi.test(j-1))
ostr << regName(eReg(j));
}
}
};

View File

@@ -25,7 +25,7 @@ struct STATE
JCond.regi=0;
JCond.immed=0;
memset(r,0,sizeof(int16_t)*INDEX_BX_SI);
memset(r,0,sizeof(int16_t)*INDEX_BX_SI); //TODO: move this to machine_x86
memset(f,0,sizeof(uint8_t)*INDEX_BX_SI);
}
};