lots of changes, created Disassembler class, removed a few globals etc.
This commit is contained in:
@@ -6,15 +6,11 @@
|
||||
#include "locident.h"
|
||||
#include "state.h"
|
||||
#include "icode.h"
|
||||
//#include "types.h"
|
||||
//#include "ast.h"
|
||||
//#include "error.h"
|
||||
//#include "graph.h"
|
||||
//#include "bundle.h"
|
||||
#include "StackFrame.h"
|
||||
/* PROCEDURE NODE */
|
||||
struct CALL_GRAPH;
|
||||
struct COND_EXPR;
|
||||
struct Disassembler;
|
||||
namespace llvm
|
||||
{
|
||||
// Traits for intrusive list of basic blocks...
|
||||
@@ -144,7 +140,7 @@ public:
|
||||
void mergeFallThrough(BB *pBB);
|
||||
void structIfs();
|
||||
void structLoops(derSeq *derivedG);
|
||||
void buildCFG();
|
||||
void buildCFG(Disassembler &ds);
|
||||
void controlFlowAnalysis();
|
||||
void newRegArg(iICODE picode, iICODE ticode);
|
||||
protected:
|
||||
@@ -153,7 +149,7 @@ protected:
|
||||
void propLongStk(int i, const ID &pLocId);
|
||||
void propLongGlb(int i, const ID &pLocId);
|
||||
void processTargetIcode(iICODE picode, int &numHlIcodes, iICODE ticode, bool isLong);
|
||||
void processHliCall1(COND_EXPR *exp, iICODE picode);
|
||||
void processHliCall(COND_EXPR *exp, iICODE picode);
|
||||
|
||||
int findBackwarLongDefs(int loc_ident_idx, const ID &pLocId, iICODE iter);
|
||||
int findForwardLongUses(int loc_ident_idx, const ID &pLocId, iICODE beg);
|
||||
|
||||
@@ -140,7 +140,7 @@ eErrorId scan(uint32_t ip, ICODE &p); /* scanner.c *
|
||||
void parse (CALL_GRAPH * *); /* parser.c */
|
||||
|
||||
int strSize (uint8_t *, char); /* parser.c */
|
||||
void disassem(int pass, Function * pProc); /* disassem.c */
|
||||
//void disassem(int pass, Function * pProc); /* disassem.c */
|
||||
void interactDis(Function * initProc, int initIC); /* disassem.c */
|
||||
bool JmpInst(llIcode opcode); /* idioms.c */
|
||||
queue::iterator appendQueue(queue &Q, BB *node); /* reducible.c */
|
||||
|
||||
@@ -4,10 +4,30 @@
|
||||
****************************************************************************/
|
||||
#pragma once
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include "bundle.h"
|
||||
struct LLInst;
|
||||
struct Disassembler
|
||||
{
|
||||
protected:
|
||||
int pass;
|
||||
int g_lab;
|
||||
//bundle &cCode;
|
||||
std::ofstream m_fp;
|
||||
std::vector<std::string> m_decls;
|
||||
std::vector<std::string> m_code;
|
||||
|
||||
public:
|
||||
Disassembler(int _p) : pass(_p)
|
||||
{
|
||||
g_lab=0;
|
||||
}
|
||||
public:
|
||||
void disassem(Function *ppProc);
|
||||
void disassem(Function *ppProc, int i);
|
||||
void dis1Line(LLInst &inst, int loc_ip, int pass);
|
||||
};
|
||||
/* Definitions for extended keys (first key is zero) */
|
||||
|
||||
#define EXT 0x100 /* "Extended" flag */
|
||||
@@ -24,10 +44,10 @@ struct LLInst;
|
||||
#ifdef _CONSOLE
|
||||
#define KEY_DOWN 0x50 /* Same as keypad scancodes */
|
||||
#define KEY_LEFT 0x4B
|
||||
#define KEY_UP 0x48
|
||||
#define KEY_RIGHT 0x4D
|
||||
#define KEY_NPAGE 0x51
|
||||
#define KEY_PPAGE 0x49
|
||||
#define KEY_UP 0x48
|
||||
#define KEY_RIGHT 0x4D
|
||||
#define KEY_NPAGE 0x51
|
||||
#define KEY_PPAGE 0x49
|
||||
#endif
|
||||
|
||||
#ifdef __UNIX__
|
||||
|
||||
@@ -261,9 +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)
|
||||
LLInst(ICODE *container) : flg(0),codeIdx(0),numBytes(0),m_link(container)
|
||||
{
|
||||
|
||||
caseTbl.entries=0;
|
||||
caseTbl.numEntries=0;
|
||||
setOpcode(0);
|
||||
}
|
||||
ICODE *m_link;
|
||||
};
|
||||
@@ -331,7 +333,9 @@ public:
|
||||
Use &u(idx[regIdx]);
|
||||
u.removeUser(ic);
|
||||
}
|
||||
DU1() : numRegsDef(0) {}
|
||||
DU1() : numRegsDef(0)
|
||||
{
|
||||
}
|
||||
};
|
||||
icodeType type; /* Icode type */
|
||||
BB *inBB; /* BB to which this icode belongs */
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
/* STATE TABLE */
|
||||
struct STATE
|
||||
{
|
||||
uint32_t IP; /* Offset into Image */
|
||||
uint32_t IP; /* Offset into Image */
|
||||
int16_t r[INDEX_BX_SI]; /* Value of segs and AX */
|
||||
uint8_t f[INDEX_BX_SI]; /* True if r[.] has a value */
|
||||
bool f[INDEX_BX_SI]; /* True if r[.] has a value */
|
||||
struct
|
||||
{ /* For case stmt indexed reg */
|
||||
uint8_t regi; /* Last conditional jump */
|
||||
@@ -20,6 +20,8 @@ struct STATE
|
||||
} JCond;
|
||||
void setState(uint16_t reg, int16_t value);
|
||||
void checkStartup();
|
||||
bool isKnown(eReg v) {return f[v];}
|
||||
void kill(eReg v) { f[v]=false;}
|
||||
STATE() : IP(0)
|
||||
{
|
||||
JCond.regi=0;
|
||||
|
||||
Reference in New Issue
Block a user