Pre branch commit

This commit is contained in:
Artur K
2012-03-18 11:35:56 +01:00
parent fee4d6fe9a
commit 9cc5202ff7
12 changed files with 457 additions and 344 deletions

View File

@@ -150,7 +150,7 @@ public:
void findImmedDom();
void FollowCtrl(CALL_GRAPH *pcallGraph, STATE *pstate);
void process_operands(ICODE &pIcode, STATE *pstate);
boolT process_JMP(ICODE &pIcode, STATE *pstate, CALL_GRAPH *pcallGraph);
bool process_JMP(ICODE &pIcode, STATE *pstate, CALL_GRAPH *pcallGraph);
boolT process_CALL(ICODE &pIcode, CALL_GRAPH *pcallGraph, STATE *pstate);
void freeCFG();
void codeGen(std::ostream &fs);
@@ -168,6 +168,8 @@ public:
void preprocessReturnDU(std::bitset<32> &_liveOut);
protected:
void extractJumpTableRange(ICODE& pIcode, STATE *pstate, JumpTable &table);
bool followAllTableEntries(JumpTable &table, uint32_t cs, ICODE &pIcode, CALL_GRAPH *pcallGraph, STATE *pstate);
bool removeInEdge_Flag_and_ProcessLatch(BB *pbb, BB *a, BB *b);
bool Case_X_and_Y(BB* pbb, BB* thenBB, BB* elseBB);
bool Case_X_or_Y(BB* pbb, BB* thenBB, BB* elseBB);

View File

@@ -62,8 +62,6 @@ typedef struct { /* Command line option flags */
extern OPTION option; /* Command line options */
#include "BinaryImage.h"
//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 */

View File

@@ -31,7 +31,7 @@ struct bundle;
typedef std::list<ICODE>::iterator iICODE;
typedef std::list<ICODE>::reverse_iterator riICODE;
typedef boost::iterator_range<iICODE> rCODE;
extern std::bitset<32> duReg[30];
/* uint8_t and uint16_t registers */
/* Def/use of flags - low 4 bits represent flags */
@@ -214,19 +214,15 @@ struct LLInst : public llvm::MCInst //: public llvm::ilist_node<LLInst>
{
protected:
uint32_t flg; /* icode flags */
// llIcode opcode; /* llIcode instruction */
LLOperand m_src; /* source operand */
public:
int codeIdx; /* Index into cCode.code */
uint8_t numBytes; /* Number of bytes this instr */
uint32_t label; /* offset in image (20-bit adr) */
LLOperand dst; /* destination operand */
LLOperand m_src; /* source operand */
DU flagDU; /* def/use of flags */
struct { /* Case table if op==JMP && !I */
int numEntries; /* # entries in case table */
uint32_t *entries; /* array of offsets */
} caseTbl;
int caseEntry;
std::vector<uint32_t> caseTbl2;
int hllLabNum; /* label # for hll codegen */
bool conditionalJump()
{
@@ -295,8 +291,6 @@ public:
HLTYPE createCall();
LLInst(ICODE *container) : flg(0),codeIdx(0),numBytes(0),m_link(container)
{
caseTbl.entries=0;
caseTbl.numEntries=0;
setOpcode(0);
}
const LLOperand &src() const {return m_src;}
@@ -322,6 +316,7 @@ public:
dst = LLOperand::CreateReg2(r);
}
ICODE *m_link;
condId idType(opLoc sd) const;
const LLOperand * get(opLoc sd) const { return (sd == SRC) ? &src() : &dst; }
LLOperand * get(opLoc sd) { return (sd == SRC) ? &src() : &dst; }
};
@@ -370,6 +365,12 @@ public:
std::bitset<32> def; // For Registers: position in bitset is reg index
std::bitset<32> use; // For Registers: position in uint32_t is reg index
std::bitset<32> lastDefRegi;// Bit set if last def of this register in BB
void addDefinedAndUsed(eReg r)
{
def |= duReg[r];
use |= duReg[r];
}
};
struct DU1
{

View File

@@ -46,7 +46,7 @@ enum eReg
class SourceMachine
{
public:
// virtual bool physicalReg(eReg r)=0;
virtual bool physicalReg(eReg r)=0;
};
//class Machine_X86_Disassembler
@@ -61,7 +61,7 @@ public:
static const std::string &regName(eReg r);
static const std::string &opcodeName(unsigned r);
static const std::string &floatOpName(unsigned r);
static bool physicalReg(eReg r);
bool physicalReg(eReg r);
/* Writes the registers that are set in the bitvector */
//TODO: move this into Machine_X86 ?
static void writeRegVector (std::ostream &ostr,const std::bitset<32> &regi)