rename otherLongRegi to getPairedRegisterAt, make it a method of
LOCAL_ID struct.
This commit is contained in:
parent
a5f1d17e83
commit
d7acc8cd4d
@ -221,9 +221,6 @@ struct AstIdent : public UnaryOperator
|
||||
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);
|
||||
protected:
|
||||
eReg otherLongRegi (eReg regi, int idx, LOCAL_ID *locTbl);
|
||||
|
||||
};
|
||||
struct GlobalVariable : public AstIdent
|
||||
{
|
||||
@ -272,7 +269,7 @@ struct Constant : public AstIdent
|
||||
}
|
||||
QString walkCondExpr(Function *pProc, int *numLoc) const;
|
||||
int hlTypeSize(Function *pproc) const;
|
||||
hlType expType(Function *pproc) const;
|
||||
hlType expType(Function *pproc) const { return TYPE_CONST; }
|
||||
};
|
||||
struct FuncNode : public AstIdent
|
||||
{
|
||||
|
||||
@ -100,7 +100,5 @@ QString writeJcondInv(HLTYPE, Function *, int *);
|
||||
/* Exported funcions from locident.c */
|
||||
bool checkLongEq(LONG_STKID_TYPE, iICODE, int, Function *, Assignment &asgn, LLInst &atOffset);
|
||||
bool checkLongRegEq(LONGID_TYPE, iICODE, int, Function *, Assignment &asgn, LLInst &);
|
||||
eReg otherLongRegi(eReg, int, LOCAL_ID *);
|
||||
|
||||
|
||||
extern const char *indentStr(int level);
|
||||
|
||||
@ -96,10 +96,9 @@ protected:
|
||||
LONGID_TYPE m_longId; /* For TYPE_LONG_(UN)SIGN registers */
|
||||
public:
|
||||
hlType type; /* Probable type */
|
||||
bool illegal; /* Boolean: not a valid field any more */
|
||||
//std::vector<iICODE> idx;
|
||||
IDX_ARRAY idx; /* Index into icode array (REG_FRAME only) */
|
||||
frameType loc; /* Frame location */
|
||||
bool illegal; /* Boolean: not a valid field any more */
|
||||
bool hasMacro; /* Identifier requires a macro */
|
||||
char macro[10]; /* Macro for this identifier */
|
||||
QString name; /* Identifier's name */
|
||||
@ -143,6 +142,8 @@ public:
|
||||
sprintf (buf, "loc%d", i);
|
||||
name=buf;
|
||||
}
|
||||
bool isLongRegisterPair() const { return (loc == REG_FRAME) and isLong();}
|
||||
eReg getPairedRegister(eReg first) const;
|
||||
};
|
||||
|
||||
struct LOCAL_ID
|
||||
@ -174,6 +175,7 @@ public:
|
||||
void processTargetIcode(ICODE & picode, int &numHlIcodes, ICODE & ticode, bool isLong) const;
|
||||
void forwardSubs(Expr *lhs, Expr *rhs, ICODE & picode, ICODE & ticode, int &numHlIcodes) const;
|
||||
AstIdent *createId(const ID *retVal, iICODE ix_);
|
||||
eReg getPairedRegisterAt(int idx,eReg first) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
21
src/ast.cpp
21
src/ast.cpp
@ -850,26 +850,12 @@ Expr *AstIdent::performLongRemoval(eReg regi, LOCAL_ID *locId)
|
||||
|
||||
if (ident.idType == LONG_VAR)
|
||||
{
|
||||
otherRegi = otherLongRegi (regi, ident.idNode.longIdx, locId);
|
||||
otherRegi = locId->getPairedRegisterAt(ident.idNode.longIdx,regi);
|
||||
delete this;
|
||||
return new RegisterNode(locId->newByteWordReg(TYPE_WORD_SIGN,otherRegi),WORD_REG,locId);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
eReg AstIdent::otherLongRegi (eReg regi, int idx, LOCAL_ID *locTbl)
|
||||
{
|
||||
ID *id = &locTbl->id_arr[idx];
|
||||
if ((id->loc == REG_FRAME) and ((id->type == TYPE_LONG_SIGN) or
|
||||
(id->type == TYPE_LONG_UNSIGN)))
|
||||
{
|
||||
if (id->longId().h() == regi)
|
||||
return (id->longId().l());
|
||||
else if (id->longId().l() == regi)
|
||||
return (id->longId().h());
|
||||
}
|
||||
return rUNDEF; // Cristina: please check this!
|
||||
}
|
||||
|
||||
|
||||
QString Constant::walkCondExpr(Function *, int *) const
|
||||
{
|
||||
@ -884,10 +870,7 @@ int Constant::hlTypeSize(Function *) const
|
||||
return kte.size;
|
||||
}
|
||||
|
||||
hlType Constant::expType(Function *pproc) const
|
||||
{
|
||||
return TYPE_CONST;
|
||||
}
|
||||
|
||||
|
||||
QString FuncNode::walkCondExpr(Function *pProc, int *numLoc) const
|
||||
{
|
||||
|
||||
@ -10,6 +10,8 @@
|
||||
#include "msvc_fixes.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
static const int LOCAL_ID_DELTA = 25;
|
||||
static const int IDX_ARRAY_DELTA = 5;
|
||||
|
||||
@ -57,6 +59,14 @@ ID::ID(hlType t, const LONGGLB_TYPE &s) : type(t),illegal(false)
|
||||
assert((t==TYPE_LONG_SIGN) or (t==TYPE_LONG_UNSIGN));
|
||||
}
|
||||
|
||||
eReg ID::getPairedRegister(eReg first) const {
|
||||
if (longId().h() == first)
|
||||
return (longId().l());
|
||||
else if (longId().l() == first)
|
||||
return (longId().h());
|
||||
return rUNDEF;
|
||||
}
|
||||
|
||||
|
||||
/* Creates a new identifier node of type t and returns it.
|
||||
* Arguments: locSym : local long symbol table
|
||||
@ -174,7 +184,7 @@ int LOCAL_ID::newLongReg(hlType t, const LONGID_TYPE &longT, iICODE ix_)
|
||||
for (idx = 0; idx < id_arr.size(); idx++)
|
||||
{
|
||||
ID &entry(id_arr[idx]);
|
||||
if(not entry.isLong() or (entry.loc != REG_FRAME))
|
||||
if(not entry.isLongRegisterPair())
|
||||
continue;
|
||||
if (/*(locSym->id[idx].type == t) and Not checking type */
|
||||
(entry.longId().h() == regH) and
|
||||
@ -222,7 +232,7 @@ int LOCAL_ID::newLongGlb(int16_t seg, int16_t offH, int16_t offL,hlType t)
|
||||
printf("%d",t);
|
||||
/* Not in the table, create new identifier */
|
||||
id_arr.emplace_back(t, LONGGLB_TYPE(seg,offH,offL));
|
||||
return (id_arr.size() - 1);
|
||||
return id_arr.size() - 1;
|
||||
|
||||
}
|
||||
|
||||
@ -232,10 +242,8 @@ int LOCAL_ID::newLongGlb(int16_t seg, int16_t offH, int16_t offL,hlType t)
|
||||
* TYPE_LONG_(UN)SIGN and returns the index to this new entry. */
|
||||
int LOCAL_ID::newLongIdx( int16_t seg, int16_t offH, int16_t offL,uint8_t regi, hlType t)
|
||||
{
|
||||
size_t idx;
|
||||
|
||||
/* Check for entry in the table */
|
||||
for (idx = 0; idx < id_arr.size(); idx++)
|
||||
for (size_t idx = 0; idx < id_arr.size(); idx++)
|
||||
{
|
||||
if (/*(locSym->id[idx].type == t) and Not checking type */
|
||||
(id_arr[idx].id.longGlb.seg == seg) and
|
||||
@ -247,8 +255,7 @@ int LOCAL_ID::newLongIdx( int16_t seg, int16_t offH, int16_t offL,uint8_t regi,
|
||||
|
||||
/* Not in the table, create new identifier */
|
||||
id_arr.emplace_back(t,LONGGLB_TYPE(seg,offH,offL,regi));
|
||||
idx = id_arr.size() - 1;
|
||||
return (idx);
|
||||
return id_arr.size() - 1;
|
||||
}
|
||||
|
||||
|
||||
@ -326,7 +333,7 @@ int LOCAL_ID::newLong(opLoc sd, iICODE pIcode, hlFirst f, iICODE ix,operDu du, L
|
||||
else /* (pm->regi >= INDEXBASE and pm->off = 0) => indexed and no off */
|
||||
printf ("long not supported, idx and no off\n");
|
||||
|
||||
return (idx);
|
||||
return idx;
|
||||
}
|
||||
|
||||
|
||||
@ -423,25 +430,19 @@ bool checkLongRegEq (LONGID_TYPE longId, iICODE pIcode, int i,
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Given an index into the local identifier table for a long register
|
||||
* variable, determines whether regi is the high or low part, and returns
|
||||
* the other part */
|
||||
eReg otherLongRegi (eReg regi, int idx, LOCAL_ID *locTbl)
|
||||
eReg LOCAL_ID::getPairedRegisterAt(int idx,eReg regi) const
|
||||
{
|
||||
ID *id;
|
||||
|
||||
id = &locTbl->id_arr[idx];
|
||||
if ((id->loc == REG_FRAME) and ((id->type == TYPE_LONG_SIGN) or
|
||||
(id->type == TYPE_LONG_UNSIGN)))
|
||||
eReg res=rUNDEF; // Cristina: please check this!
|
||||
const ID *id = &id_arr[idx];
|
||||
if (id->isLongRegisterPair())
|
||||
{
|
||||
if (id->longId().h() == regi)
|
||||
return (id->longId().l());
|
||||
else if (id->longId().l() == regi)
|
||||
return (id->longId().h());
|
||||
res = id->getPairedRegister(regi);
|
||||
}
|
||||
return rUNDEF; // Cristina: please check this!
|
||||
qWarning() << "Cannot find paired register";
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user