More logic operator replacements.
Use Qt string classes.
This commit is contained in:
@@ -111,7 +111,7 @@ public:
|
||||
///
|
||||
const Function *getParent() const { return Parent; }
|
||||
Function *getParent() { return Parent; }
|
||||
void writeBB(std::ostream &ostr, int lev, Function *pProc, int *numLoc);
|
||||
void writeBB(QTextStream & ostr, int lev, Function *pProc, int *numLoc);
|
||||
BB * rmJMP(int marker, BB *pBB);
|
||||
void genDU1();
|
||||
void findBBExps(LOCAL_ID &locals, Function *f);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
#include "ast.h"
|
||||
|
||||
class QTextStream;
|
||||
|
||||
struct CConv {
|
||||
enum Type {
|
||||
UNKNOWN=0,
|
||||
@@ -8,7 +10,7 @@ struct CConv {
|
||||
PASCAL
|
||||
};
|
||||
virtual void processHLI(Function *func, Expr *_exp, iICODE picode)=0;
|
||||
virtual void writeComments(std::ostream &)=0;
|
||||
virtual void writeComments(QTextStream &)=0;
|
||||
static CConv * create(Type v);
|
||||
protected:
|
||||
|
||||
@@ -16,16 +18,16 @@ protected:
|
||||
|
||||
struct C_CallingConvention : public CConv {
|
||||
virtual void processHLI(Function *func, Expr *_exp, iICODE picode);
|
||||
virtual void writeComments(std::ostream &);
|
||||
virtual void writeComments(QTextStream &);
|
||||
|
||||
private:
|
||||
int processCArg(Function *callee, Function *pProc, ICODE *picode, size_t numArgs);
|
||||
};
|
||||
struct Pascal_CallingConvention : public CConv {
|
||||
virtual void processHLI(Function *func, Expr *_exp, iICODE picode);
|
||||
virtual void writeComments(std::ostream &);
|
||||
virtual void writeComments(QTextStream &);
|
||||
};
|
||||
struct Unknown_CallingConvention : public CConv {
|
||||
void processHLI(Function *func, Expr *_exp, iICODE picode) {}
|
||||
virtual void writeComments(std::ostream &);
|
||||
virtual void writeComments(QTextStream &);
|
||||
};
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
#pragma once
|
||||
#include <llvm/ADT/ilist.h>
|
||||
//#include <llvm/ADT/ilist_node.h>
|
||||
#include <bitset>
|
||||
#include <map>
|
||||
#include "BasicBlock.h"
|
||||
#include "locident.h"
|
||||
#include "state.h"
|
||||
#include "icode.h"
|
||||
#include "StackFrame.h"
|
||||
#include "CallConvention.h"
|
||||
|
||||
#include <llvm/ADT/ilist.h>
|
||||
//#include <llvm/ADT/ilist_node.h>
|
||||
#include <QtCore/QString>
|
||||
#include <bitset>
|
||||
#include <map>
|
||||
|
||||
class QIODevice;
|
||||
class QTextStream;
|
||||
|
||||
/* PROCEDURE NODE */
|
||||
struct CALL_GRAPH;
|
||||
struct Expr;
|
||||
@@ -126,8 +132,8 @@ public:
|
||||
FunctionType * type;
|
||||
CConv * m_call_conv;
|
||||
uint32_t procEntry; /* label number */
|
||||
std::string name; /* Meaningful name for this proc */
|
||||
STATE state; /* Entry state */
|
||||
QString name; /* Meaningful name for this proc */
|
||||
STATE state; /* Entry state */
|
||||
int depth; /* Depth at which we found it - for printing */
|
||||
uint32_t flg; /* Combination of Icode & Proc flags */
|
||||
int16_t cbParam; /* Probable no. of bytes of parameters */
|
||||
@@ -153,7 +159,7 @@ public:
|
||||
delete type;
|
||||
}
|
||||
public:
|
||||
static Function *Create(FunctionType *ty=0,int /*Linkage*/=0,const std::string &nm="",void */*module*/=0)
|
||||
static Function *Create(FunctionType *ty=0,int /*Linkage*/=0,const QString &nm="",void */*module*/=0)
|
||||
{
|
||||
Function *r=new Function(ty);
|
||||
r->name = nm;
|
||||
@@ -185,14 +191,14 @@ public:
|
||||
bool process_JMP(ICODE &pIcode, STATE *pstate, CALL_GRAPH *pcallGraph);
|
||||
bool process_CALL(ICODE &pIcode, CALL_GRAPH *pcallGraph, STATE *pstate);
|
||||
void freeCFG();
|
||||
void codeGen(std::ostream &fs);
|
||||
void codeGen(QIODevice & fs);
|
||||
void mergeFallThrough(BB *pBB);
|
||||
void structIfs();
|
||||
void structLoops(derSeq *derivedG);
|
||||
void buildCFG(Disassembler &ds);
|
||||
void controlFlowAnalysis();
|
||||
void newRegArg(iICODE picode, iICODE ticode);
|
||||
void writeProcComments(std::ostream &ostr);
|
||||
void writeProcComments(QTextStream & ostr);
|
||||
|
||||
void displayCFG();
|
||||
void displayStats();
|
||||
@@ -200,7 +206,7 @@ public:
|
||||
|
||||
void preprocessReturnDU(LivenessSet &_liveOut);
|
||||
Expr * adjustActArgType(Expr *_exp, hlType forType);
|
||||
std::string writeCall(Function *tproc, STKFRAME &args, int *numLoc);
|
||||
QString writeCall(Function *tproc, STKFRAME &args, int *numLoc);
|
||||
void processDosInt(STATE *pstate, PROG &prog, bool done);
|
||||
ICODE *translate_DIV(LLInst *ll, ICODE &_Icode);
|
||||
ICODE *translate_XCHG(LLInst *ll, ICODE &_Icode);
|
||||
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
/** Recursively deallocates the abstract syntax tree rooted at *exp */
|
||||
virtual ~Expr() {}
|
||||
public:
|
||||
virtual std::string walkCondExpr (Function * pProc, int* numLoc) const=0;
|
||||
virtual QString walkCondExpr (Function * pProc, int* numLoc) const=0;
|
||||
virtual Expr *inverse() const=0; // return new COND_EXPR that is invarse of this
|
||||
virtual bool xClear(rICODE range_to_check, iICODE lastBBinst, const LOCAL_ID &locId)=0;
|
||||
virtual Expr *insertSubTreeReg(Expr *_expr, eReg regi, const LOCAL_ID *locsym)=0;
|
||||
@@ -100,10 +100,12 @@ struct UnaryOperator : public Expr
|
||||
}
|
||||
public:
|
||||
int hlTypeSize(Function *pproc) const;
|
||||
virtual std::string walkCondExpr(Function *pProc, int *numLoc) const;
|
||||
virtual QString walkCondExpr(Function *pProc, int *numLoc) const;
|
||||
virtual Expr *insertSubTreeReg(Expr *_expr, eReg regi, const LOCAL_ID *locsym);
|
||||
virtual hlType expType(Function *pproc) const;
|
||||
virtual Expr *insertSubTreeLongReg(Expr *_expr, int longIdx);
|
||||
private:
|
||||
QString wrapUnary(Function *pProc, int *numLoc, QChar op) const;
|
||||
};
|
||||
|
||||
struct BinaryOperator : public Expr
|
||||
@@ -188,7 +190,7 @@ struct BinaryOperator : public Expr
|
||||
condOp op() const { return m_op;}
|
||||
/* Changes the boolean conditional operator at the root of this expression */
|
||||
void op(condOp o) { m_op=o;}
|
||||
std::string walkCondExpr (Function * pProc, int* numLoc) const;
|
||||
QString walkCondExpr(Function * pProc, int* numLoc) const;
|
||||
public:
|
||||
hlType expType(Function *pproc) const;
|
||||
int hlTypeSize(Function *pproc) const;
|
||||
@@ -215,7 +217,7 @@ struct AstIdent : public UnaryOperator
|
||||
virtual int hlTypeSize(Function *pproc) const;
|
||||
virtual hlType expType(Function *pproc) const;
|
||||
virtual Expr * performLongRemoval(eReg regi, LOCAL_ID *locId);
|
||||
virtual std::string walkCondExpr(Function *pProc, int *numLoc) const;
|
||||
virtual QString walkCondExpr(Function *pProc, int *numLoc) const;
|
||||
virtual Expr *insertSubTreeReg(Expr *_expr, eReg regi, const LOCAL_ID *locsym);
|
||||
virtual Expr *insertSubTreeLongReg(Expr *_expr, int longIdx);
|
||||
virtual bool xClear(rICODE range_to_check, iICODE lastBBinst, const LOCAL_ID &locId);
|
||||
@@ -232,7 +234,7 @@ struct GlobalVariable : public AstIdent
|
||||
return new GlobalVariable(*this);
|
||||
}
|
||||
GlobalVariable(int16_t segValue, int16_t off);
|
||||
std::string walkCondExpr(Function *pProc, int *numLoc) const;
|
||||
QString walkCondExpr(Function *pProc, int *numLoc) const;
|
||||
int hlTypeSize(Function *pproc) const;
|
||||
hlType expType(Function *pproc) const;
|
||||
};
|
||||
@@ -246,7 +248,7 @@ struct GlobalVariableIdx : public AstIdent
|
||||
return new GlobalVariableIdx(*this);
|
||||
}
|
||||
GlobalVariableIdx(int16_t segValue, int16_t off, uint8_t regi, const LOCAL_ID *locSym);
|
||||
std::string walkCondExpr(Function *pProc, int *numLoc) const;
|
||||
QString walkCondExpr(Function *pProc, int *numLoc) const;
|
||||
int hlTypeSize(Function *pproc) const;
|
||||
hlType expType(Function *pproc) const;
|
||||
};
|
||||
@@ -268,7 +270,7 @@ struct Constant : public AstIdent
|
||||
{
|
||||
return new Constant(*this);
|
||||
}
|
||||
std::string walkCondExpr(Function *pProc, int *numLoc) const;
|
||||
QString walkCondExpr(Function *pProc, int *numLoc) const;
|
||||
int hlTypeSize(Function *pproc) const;
|
||||
hlType expType(Function *pproc) const;
|
||||
};
|
||||
@@ -288,7 +290,7 @@ struct FuncNode : public AstIdent
|
||||
{
|
||||
return new FuncNode(*this);
|
||||
}
|
||||
std::string walkCondExpr(Function *pProc, int *numLoc) const;
|
||||
QString walkCondExpr(Function *pProc, int *numLoc) const;
|
||||
int hlTypeSize(Function *pproc) const;
|
||||
hlType expType(Function *pproc) const;
|
||||
};
|
||||
@@ -314,7 +316,7 @@ struct RegisterNode : public AstIdent
|
||||
{
|
||||
return new RegisterNode(*this);
|
||||
}
|
||||
std::string walkCondExpr(Function *pProc, int *numLoc) const;
|
||||
QString walkCondExpr(Function *pProc, int *numLoc) const;
|
||||
int hlTypeSize(Function *) const;
|
||||
hlType expType(Function *pproc) const;
|
||||
bool xClear(rICODE range_to_check, iICODE lastBBinst, const LOCAL_ID &locId);
|
||||
|
||||
@@ -7,8 +7,10 @@
|
||||
#pragma once
|
||||
#include <stdio.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
struct strTable : std::vector<std::string>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QIODevice>
|
||||
|
||||
struct strTable : std::vector<QString>
|
||||
{
|
||||
/* Returns the next available index into the table */
|
||||
size_t nextIdx() {return size();}
|
||||
@@ -20,9 +22,9 @@ struct bundle
|
||||
{
|
||||
public:
|
||||
void appendCode(const char *format, ...);
|
||||
void appendCode(const std::string &s);
|
||||
void appendCode(const QString &s);
|
||||
void appendDecl(const char *format, ...);
|
||||
void appendDecl(const std::string &);
|
||||
void appendDecl(const QString &);
|
||||
void init()
|
||||
{
|
||||
decl.clear();
|
||||
@@ -37,6 +39,6 @@ extern bundle cCode;
|
||||
#define lineSize 360 /* 3 lines in the mean time */
|
||||
|
||||
//void newBundle (bundle *procCode);
|
||||
void writeBundle (std::ostream &ios, bundle procCode);
|
||||
void writeBundle (QIODevice & ios, bundle procCode);
|
||||
void freeBundle (bundle *procCode);
|
||||
|
||||
|
||||
@@ -93,8 +93,8 @@ bool LibCheck(Function &p); /* chklib.c */
|
||||
|
||||
|
||||
/* Exported functions from hlicode.c */
|
||||
const char *writeJcond(const HLTYPE &, Function *, int *);
|
||||
const char *writeJcondInv (HLTYPE, Function *, int *);
|
||||
QString writeJcond(const HLTYPE &, Function *, int *);
|
||||
QString writeJcondInv(HLTYPE, Function *, int *);
|
||||
|
||||
|
||||
/* Exported funcions from locident.c */
|
||||
|
||||
@@ -5,9 +5,12 @@
|
||||
***************************************************************************
|
||||
*/
|
||||
#pragma once
|
||||
#include "bundle.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include "bundle.h"
|
||||
#include <QString>
|
||||
#include <QTextStream>
|
||||
struct LLInst;
|
||||
struct Function;
|
||||
struct Disassembler
|
||||
@@ -16,7 +19,8 @@ protected:
|
||||
int pass;
|
||||
int g_lab;
|
||||
//bundle &cCode;
|
||||
std::ofstream m_fp;
|
||||
QIODevice *m_disassembly_target;
|
||||
QTextStream m_fp;
|
||||
std::vector<std::string> m_decls;
|
||||
std::vector<std::string> m_code;
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <llvm/MC/MCInst.h>
|
||||
#include <llvm/IR/Instruction.h>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <QtCore/QString>
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
@@ -145,8 +146,8 @@ struct UnaryOperator;
|
||||
struct HlTypeSupport
|
||||
{
|
||||
//hlIcode opcode; /* hlIcode opcode */
|
||||
virtual bool removeRegFromLong(eReg regi, LOCAL_ID *locId)=0;
|
||||
virtual std::string writeOut(Function *pProc, int *numLoc) const=0;
|
||||
virtual bool removeRegFromLong(eReg regi, LOCAL_ID *locId)=0;
|
||||
virtual QString writeOut(Function *pProc, int *numLoc) const=0;
|
||||
protected:
|
||||
Expr * performLongRemoval (eReg regi, LOCAL_ID *locId, Expr *tree);
|
||||
};
|
||||
@@ -166,7 +167,7 @@ public:
|
||||
printf("CallType : removeRegFromLong not supproted");
|
||||
return false;
|
||||
}
|
||||
std::string writeOut(Function *pProc, int *numLoc) const;
|
||||
QString writeOut(Function *pProc, int *numLoc) const;
|
||||
};
|
||||
struct AssignType : public HlTypeSupport
|
||||
{
|
||||
@@ -179,7 +180,7 @@ public:
|
||||
Expr *lhs() const {return m_lhs;}
|
||||
void lhs(Expr *l);
|
||||
bool removeRegFromLong(eReg regi, LOCAL_ID *locId);
|
||||
std::string writeOut(Function *pProc, int *numLoc) const;
|
||||
QString writeOut(Function *pProc, int *numLoc) const;
|
||||
};
|
||||
struct ExpType : public HlTypeSupport
|
||||
{
|
||||
@@ -191,7 +192,7 @@ struct ExpType : public HlTypeSupport
|
||||
v=performLongRemoval(regi,locId,v);
|
||||
return true;
|
||||
}
|
||||
std::string writeOut(Function *pProc, int *numLoc) const;
|
||||
QString writeOut(Function *pProc, int *numLoc) const;
|
||||
};
|
||||
|
||||
struct HLTYPE
|
||||
@@ -245,7 +246,7 @@ public:
|
||||
return *this;
|
||||
}
|
||||
public:
|
||||
std::string write1HlIcode(Function *pProc, int *numLoc) const;
|
||||
QString write1HlIcode(Function *pProc, int *numLoc) const;
|
||||
void setAsgn(Expr *lhs, Expr *rhs);
|
||||
} ;
|
||||
/* LOW_LEVEL icode operand record */
|
||||
@@ -404,11 +405,11 @@ public:
|
||||
}
|
||||
void emitGotoLabel(int indLevel);
|
||||
void findJumpTargets(CIcodeRec &_pc);
|
||||
void writeIntComment(std::ostringstream &s);
|
||||
void writeIntComment(QTextStream & s);
|
||||
void dis1Line(int loc_ip, int pass);
|
||||
std::ostringstream &strSrc(std::ostringstream &os,bool skip_comma=false);
|
||||
QTextStream & strSrc(QTextStream & os, bool skip_comma=false);
|
||||
|
||||
void flops(std::ostringstream &out);
|
||||
void flops(QTextStream & out);
|
||||
bool isJmpInst();
|
||||
HLTYPE createCall();
|
||||
LLInst(ICODE *container) : flg(0),codeIdx(0),numBytes(0),m_link(container)
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "Enums.h"
|
||||
#include "machine_x86.h"
|
||||
|
||||
#include <QtCore/QString>
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
@@ -101,7 +102,7 @@ public:
|
||||
frameType loc; /* Frame location */
|
||||
bool hasMacro; /* Identifier requires a macro */
|
||||
char macro[10]; /* Macro for this identifier */
|
||||
std::string name; /* Identifier's name */
|
||||
QString name; /* Identifier's name */
|
||||
union ID_UNION { /* Different types of identifiers */
|
||||
friend struct ID;
|
||||
protected:
|
||||
@@ -167,7 +168,7 @@ public:
|
||||
int newLong(opLoc sd, iICODE pIcode, hlFirst f, iICODE ix, operDu du, LLInst &atOffset);
|
||||
void newIdent(hlType t, frameType f);
|
||||
void flagByteWordId(int off);
|
||||
void propLongId(uint8_t regL, uint8_t regH, const char *name);
|
||||
void propLongId(uint8_t regL, uint8_t regH, const QString & name);
|
||||
size_t csym() const {return id_arr.size();}
|
||||
void newRegArg(iICODE picode, iICODE ticode) const;
|
||||
void processTargetIcode(iICODE picode, int &numHlIcodes, iICODE ticode, bool isLong) const;
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/QString>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <bitset>
|
||||
|
||||
class QTextStream;
|
||||
|
||||
struct LivenessSet;
|
||||
/* Machine registers */
|
||||
enum eReg
|
||||
@@ -60,13 +62,13 @@ class Machine_X86 : public SourceMachine
|
||||
public:
|
||||
Machine_X86();
|
||||
virtual ~Machine_X86() {}
|
||||
static const std::string ®Name(eReg r);
|
||||
static const std::string &opcodeName(unsigned r);
|
||||
static const std::string &floatOpName(unsigned r);
|
||||
static const QString & regName(eReg r);
|
||||
static const QString & opcodeName(unsigned r);
|
||||
static const QString & floatOpName(unsigned 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 LivenessSet ®i);
|
||||
static void writeRegVector (QTextStream & ostr, const LivenessSet ®i);
|
||||
static eReg subRegH(eReg reg);
|
||||
static eReg subRegL(eReg reg);
|
||||
static bool isMemOff(eReg r);
|
||||
|
||||
@@ -52,14 +52,14 @@ public:
|
||||
QString output_name(const char *ext);
|
||||
ilFunction funcIter(Function *to_find);
|
||||
ilFunction findByEntry(uint32_t entry);
|
||||
ilFunction createFunction(FunctionType *f,const std::string &name);
|
||||
ilFunction createFunction(FunctionType *f, const QString & name);
|
||||
bool valid(ilFunction iter);
|
||||
|
||||
int getSymIdxByAdd(uint32_t adr);
|
||||
bool validSymIdx(size_t idx);
|
||||
size_t symbolSize(size_t idx);
|
||||
hlType symbolType(size_t idx);
|
||||
const std::string &symbolName(size_t idx);
|
||||
const QString & symbolName(size_t idx);
|
||||
const SYM &getSymByIdx(size_t idx) const;
|
||||
|
||||
static Project *get();
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "types.h"
|
||||
#include "msvc_fixes.h"
|
||||
|
||||
#include <QtCore/QString>
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
struct Expr;
|
||||
@@ -17,7 +18,7 @@ struct TypeContainer;
|
||||
/* * * * * * * * * * * * * * * * * */
|
||||
struct SymbolCommon
|
||||
{
|
||||
std::string name; /* New name for this variable/symbol/argument */
|
||||
QString name; /* New name for this variable/symbol/argument */
|
||||
int size; /* Size/maximum size */
|
||||
hlType type; /* probable type */
|
||||
eDuVal duVal; /* DEF, USE, VAL */
|
||||
@@ -38,12 +39,12 @@ struct SYM : public SymbolCommon
|
||||
struct STKSYM : public SymbolCommon
|
||||
{
|
||||
typedef int16_t tLabel;
|
||||
Expr *actual=0; /* Expression tree of actual parameter */
|
||||
AstIdent *regs=0; /* For register arguments only */
|
||||
Expr * actual=0; /* Expression tree of actual parameter */
|
||||
AstIdent * regs=0; /* For register arguments only */
|
||||
tLabel label=0; /* Immediate off from BP (+:args, -:params) */
|
||||
uint8_t regOff=0; /* Offset is a register (e.g. SI, DI) */
|
||||
uint8_t regOff=0; /* Offset is a register (e.g. SI, DI) */
|
||||
bool hasMacro=false; /* This type needs a macro */
|
||||
std::string macro; /* Macro name */
|
||||
QString macro; /* Macro name */
|
||||
bool invalid=false; /* Boolean: invalid entry in formal arg list*/
|
||||
void setArgName(int i)
|
||||
{
|
||||
@@ -106,6 +107,6 @@ constexpr int NUM_TABLE_TYPES = int(Comment)+1; /* Number of entries: must be la
|
||||
|
||||
void createSymTables(void);
|
||||
void destroySymTables(void);
|
||||
bool readVal (std::ostringstream &symName, uint32_t symOff, Function *symProc);
|
||||
bool readVal (QTextStream & symName, uint32_t symOff, Function *symProc);
|
||||
void selectTable(tableType); /* Select a particular table */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user