liveIn/Out def/use changed to use bitset<32>

This commit is contained in:
Artur K
2012-02-26 17:47:25 +01:00
parent 15deb26f2b
commit 74c5966579
23 changed files with 415 additions and 401 deletions

View File

@@ -75,10 +75,10 @@ public:
/* For live register analysis
* LiveIn(b) = LiveUse(b) U (LiveOut(b) - Def(b)) */
dword liveUse; /* LiveUse(b) */
dword def; /* Def(b) */
dword liveIn; /* LiveIn(b) */
dword liveOut; /* LiveOut(b) */
std::bitset<32> liveUse; /* LiveUse(b) */
std::bitset<32> def; /* Def(b) */
std::bitset<32> liveIn; /* LiveIn(b) */
std::bitset<32> liveOut; /* LiveOut(b) */
/* For structuring analysis */
Int dfsFirstNum; /* DFS #: first visit of node */
@@ -97,8 +97,8 @@ public:
Int caseTail; /* tail node for the case */
Int index; /* Index, used in several ways */
static BB *Create(void *ctx=0,const std::string &s="",Function *parent=0,BB *insertBefore=0);
static BB *Create(Int start, Int ip, byte nodeType, Int numOutEdges, Function * parent);
static BB * Create(void *ctx=0,const std::string &s="",Function *parent=0,BB *insertBefore=0);
static BB * Create(Int start, Int ip, byte nodeType, Int numOutEdges, Function * parent);
void writeCode(Int indLevel, Function *pProc, Int *numLoc, Int latchNode, Int ifFollow);
void mergeFallThrough(CIcodeRec &Icode);
void dfsNumbering(std::vector<BB *> &dfsLast, Int *first, Int *last);

View File

@@ -1,6 +1,7 @@
#pragma once
#include <llvm/ADT/ilist.h>
#include <llvm/ADT/ilist_node.h>
#include <bitset>
#include "BasicBlock.h"
#include "types.h"
#include "ast.h"
@@ -68,8 +69,8 @@ public:
/* Icodes and control flow graph */
CIcodeRec Icode; /* Object with ICODE records */
std::vector<BB*> cfg; /* Ptr. to BB list/CFG */
std::vector<BB*> dfsLast;
std::vector<BB*> m_cfg; /* Ptr. to BB list/CFG */
std::vector<BB*> m_dfsLast;
std::vector<BB*> heldBBs;
//BB * *dfsLast; /* Array of pointers to BBs in dfsLast
// * (reverse postorder) order */
@@ -77,11 +78,11 @@ public:
boolT hasCase; /* Procedure has a case node */
/* For interprocedural live analysis */
dword liveIn; /* Registers used before defined */
dword liveOut; /* Registers that may be used in successors */
boolT liveAnal; /* Procedure has been analysed already */
std::bitset<32> liveIn; /* Registers used before defined */
std::bitset<32> liveOut; /* Registers that may be used in successors */
bool liveAnal; /* Procedure has been analysed already */
Function(void *ty=0) : procEntry(0),depth(0),flg(0),cbParam(0),cfg(0),dfsLast(0),numBBs(0),
Function(void *ty=0) : procEntry(0),depth(0),flg(0),cbParam(0),m_cfg(0),m_dfsLast(0),numBBs(0),
hasCase(false),liveIn(0),liveOut(0),liveAnal(0)//,next(0),prev(0)
{
}
@@ -96,7 +97,7 @@ public:
void writeProcComments();
void lowLevelAnalysis();
void bindIcodeOff();
void dataFlow(dword liveOut);
void dataFlow(std::bitset<32> &liveOut);
void compressCFG();
void highLevelGen();
void structure(derSeq *derivedG);
@@ -120,17 +121,17 @@ public:
void newRegArg(ICODE *picode, ICODE *ticode);
protected:
// TODO: replace those with friend visitor ?
void propLongReg(Int loc_ident_idx, const ID *pLocId);
void propLongStk(Int i, ID *pLocId);
void propLongGlb(Int i, ID *pLocId);
void propLongReg(Int loc_ident_idx, const ID &pLocId);
void propLongStk(Int i, const ID &pLocId);
void propLongGlb(Int i, const ID &pLocId);
int checkBackwarLongDefs(int loc_ident_idx, const ID &pLocId, iICODE iter, Assignment &assign);
int checkForwardLongDefs(int loc_ident_idx, const ID &pLocId, iICODE beg, Assignment &asgn);
int findBackwarLongDefs(int loc_ident_idx, const ID &pLocId, iICODE iter);
int findForwardLongUses(int loc_ident_idx, const ID &pLocId, iICODE beg);
void structCases();
void findExps();
void genDU1();
void elimCondCodes();
void liveRegAnalysis(dword in_liveOut);
void liveRegAnalysis(std::bitset<32> &in_liveOut);
void findIdioms();
void propLong();
void genLiveKtes();

View File

@@ -31,12 +31,12 @@ struct STKFRAME
{
std::vector<STKSYM> sym;
//STKSYM * sym; /* Symbols */
int16 minOff; /* Initial offset in stack frame*/
int16 m_minOff; /* Initial offset in stack frame*/
int16 maxOff; /* Maximum offset in stack frame*/
Int cb; /* Number of bytes in arguments */
Int numArgs; /* No. of arguments in the table*/
void adjustForArgType(Int numArg_, hlType actType_);
STKFRAME() : sym(0),minOff(0),maxOff(0),cb(0),numArgs(0)
STKFRAME() : sym(0),m_minOff(0),maxOff(0),cb(0),numArgs(0)
{
}

View File

@@ -124,7 +124,7 @@ struct PROG /* Loaded program image parameters */
};
extern PROG prog; /* Loaded program image parameters */
extern dword duReg[30]; /* def/use bits for registers */
extern std::bitset<32> duReg[30]; /* def/use bits for registers */
//extern dword duReg[30]; /* def/use bits for registers */
extern dword maskDuReg[30]; /* masks off du bits for regs */
@@ -204,7 +204,7 @@ Int power2 (Int);
void inverseCondOp (COND_EXPR **);
/* Exported funcions from locident.c */
boolT checkLongEq (LONG_STKID_TYPE, iICODE, Int, Function *, COND_EXPR **, COND_EXPR **, Int);
boolT checkLongEq (LONG_STKID_TYPE, iICODE, Int, Function *, Assignment &asgn, Int);
boolT checkLongRegEq (LONGID_TYPE, iICODE, Int, Function *, COND_EXPR *&, COND_EXPR *&, Int);
byte otherLongRegi (byte, Int, LOCAL_ID *);
void insertIdx (IDX_ARRAY *, Int);

View File

@@ -4,6 +4,7 @@
****************************************************************************/
#pragma once
#include <vector>
#include <bitset>
#include <llvm/MC/MCInst.h>
#include <llvm/MC/MCAsmInfo.h>
#include "Enums.h"
@@ -245,9 +246,12 @@ struct DU
/* Def/Use of registers and stack variables */
struct DU_ICODE
{
dword def; /* For Registers: position in dword is reg index*/
dword lastDefRegi;/* Bit set if last def of this register in BB */
dword use; /* For Registers: position in dword is reg index*/
std::bitset<32> def; // For Registers: position in bitset is reg index
//dword def; // For Registers: position in dword is reg index
//dword def; // For Registers: position in dword is reg index
//dword lastDefRegi; // Bit set if last def of this register in BB
std::bitset<32> use; // For Registers: position in dword is reg index
std::bitset<32> lastDefRegi;
};
@@ -322,7 +326,7 @@ struct ICODE
Int idx[MAX_REGS_DEF][MAX_USES]; /* inst that uses this def */
};
icodeType type; /* Icode type */
boolT invalid; /* Has no HIGH_LEVEL equivalent */
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 */

View File

@@ -109,6 +109,16 @@ struct ID
type=t;
loc=f;
}
bool isSigned() const { return (type==TYPE_BYTE_SIGN)||(type==TYPE_WORD_SIGN)||(type==TYPE_LONG_SIGN);}
uint16_t typeBitsize() const
{
switch(type)
{
case TYPE_WORD_SIGN: case TYPE_WORD_UNSIGN:
return 16;
}
return ~0;
}
};
struct LOCAL_ID