Fix struct scoping
This commit is contained in:
parent
33433403b1
commit
55b79ecfce
|
@ -14,8 +14,8 @@ struct CIA
|
||||||
byte cra, crb;
|
byte cra, crb;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define cia1 (*((CIA *)0xdc00))
|
#define cia1 (*((struct CIA *)0xdc00))
|
||||||
#define cia2 (*((CIA *)0xdd00))
|
#define cia2 (*((struct CIA *)0xdd00))
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -26,11 +26,11 @@ enum RIRQCodeIndex
|
||||||
RIRQ_SIZE = 31
|
RIRQ_SIZE = 31
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RIRQCode
|
typedef struct RIRQCode
|
||||||
{
|
{
|
||||||
byte size;
|
byte size;
|
||||||
byte code[RIRQ_SIZE];
|
byte code[RIRQ_SIZE];
|
||||||
};
|
} RIRQCode;
|
||||||
|
|
||||||
void rirq_build(RIRQCode * ic, byte size);
|
void rirq_build(RIRQCode * ic, byte size);
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ struct VIC
|
||||||
|
|
||||||
void vic_setbank(char bank);
|
void vic_setbank(char bank);
|
||||||
|
|
||||||
#define vic (*((VIC *)0xd000))
|
#define vic (*((struct VIC *)0xd000))
|
||||||
|
|
||||||
#pragma compile("vic.c")
|
#pragma compile("vic.c")
|
||||||
|
|
||||||
|
|
|
@ -7068,6 +7068,29 @@ bool NativeCodeBasicBlock::MoveAbsoluteLoadStoreUp(int at)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NativeCodeBasicBlock::MoveStoreXUp(int at)
|
||||||
|
{
|
||||||
|
bool done = false;
|
||||||
|
|
||||||
|
while (at > 0)
|
||||||
|
{
|
||||||
|
if (mIns[at - 1].ChangesXReg())
|
||||||
|
return done;
|
||||||
|
if ((mIns[at - 1].mMode == ASMIM_ZERO_PAGE || mIns[at - 1].mMode == ASMIM_INDIRECT_Y) && mIns[at - 1].mAddress == mIns[at].mAddress)
|
||||||
|
return done;
|
||||||
|
if (mIns[at - 1].mMode == ASMIM_INDIRECT_Y && mIns[at - 1].mAddress == mIns[at].mAddress + 1)
|
||||||
|
return done;
|
||||||
|
|
||||||
|
NativeCodeInstruction ins = mIns[at - 1];
|
||||||
|
mIns[at - 1] = mIns[at];
|
||||||
|
mIns[at] = ins;
|
||||||
|
at--;
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return done;
|
||||||
|
}
|
||||||
|
|
||||||
bool NativeCodeBasicBlock::MoveLoadStoreUp(int at)
|
bool NativeCodeBasicBlock::MoveLoadStoreUp(int at)
|
||||||
{
|
{
|
||||||
int j = at;
|
int j = at;
|
||||||
|
@ -7621,6 +7644,9 @@ bool NativeCodeBasicBlock::PeepHoleOptimizer(void)
|
||||||
// shorten x/y register livetime
|
// shorten x/y register livetime
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
|
//
|
||||||
|
// move ldy down
|
||||||
|
|
||||||
for (int i = 0; i + 1 < mIns.Size(); i++)
|
for (int i = 0; i + 1 < mIns.Size(); i++)
|
||||||
{
|
{
|
||||||
if (mIns[i].mType == ASMIT_LDY && mIns[i].mMode == ASMIM_IMMEDIATE)
|
if (mIns[i].mType == ASMIT_LDY && mIns[i].mMode == ASMIM_IMMEDIATE)
|
||||||
|
@ -7635,6 +7661,19 @@ bool NativeCodeBasicBlock::PeepHoleOptimizer(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
// move stx up
|
||||||
|
|
||||||
|
for (int i = 1; i + 1 < mIns.Size(); i++)
|
||||||
|
{
|
||||||
|
if (mIns[i].mType == ASMIT_STX && mIns[i].mMode == ASMIM_ZERO_PAGE)
|
||||||
|
{
|
||||||
|
if (MoveStoreXUp(i))
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool progress = false;
|
bool progress = false;
|
||||||
do {
|
do {
|
||||||
progress = false;
|
progress = false;
|
||||||
|
@ -7853,6 +7892,34 @@ bool NativeCodeBasicBlock::PeepHoleOptimizer(void)
|
||||||
mIns[i + 0].mLive |= LIVE_CPU_REG_A;
|
mIns[i + 0].mLive |= LIVE_CPU_REG_A;
|
||||||
progress = true;
|
progress = true;
|
||||||
}
|
}
|
||||||
|
else if (
|
||||||
|
mIns[i + 0].mType == ASMIT_TXA &&
|
||||||
|
mIns[i + 1].mType == ASMIT_STA && mIns[i + 1].mMode == ASMIM_ZERO_PAGE)
|
||||||
|
{
|
||||||
|
mIns[i + 1].mType = ASMIT_STX;
|
||||||
|
progress = true;
|
||||||
|
}
|
||||||
|
else if (
|
||||||
|
mIns[i + 0].mType == ASMIT_TYA &&
|
||||||
|
mIns[i + 1].mType == ASMIT_STA && mIns[i + 1].mMode == ASMIM_ZERO_PAGE)
|
||||||
|
{
|
||||||
|
mIns[i + 1].mType = ASMIT_STY;
|
||||||
|
progress = true;
|
||||||
|
}
|
||||||
|
else if (
|
||||||
|
mIns[i + 0].mType == ASMIT_TAX &&
|
||||||
|
mIns[i + 1].mType == ASMIT_STX && mIns[i + 1].mMode == ASMIM_ZERO_PAGE)
|
||||||
|
{
|
||||||
|
mIns[i + 1].mType = ASMIT_STA;
|
||||||
|
progress = true;
|
||||||
|
}
|
||||||
|
else if (
|
||||||
|
mIns[i + 0].mType == ASMIT_TAY &&
|
||||||
|
mIns[i + 1].mType == ASMIT_STY && mIns[i + 1].mMode == ASMIM_ZERO_PAGE)
|
||||||
|
{
|
||||||
|
mIns[i + 1].mType = ASMIT_STA;
|
||||||
|
progress = true;
|
||||||
|
}
|
||||||
else if (
|
else if (
|
||||||
(mIns[i + 0].mType == ASMIT_ASL || mIns[i + 0].mType == ASMIT_LSR || mIns[i + 0].mType == ASMIT_ROL || mIns[i + 0].mType == ASMIT_ROR) && mIns[i + 0].mMode == ASMIM_ZERO_PAGE &&
|
(mIns[i + 0].mType == ASMIT_ASL || mIns[i + 0].mType == ASMIT_LSR || mIns[i + 0].mType == ASMIT_ROL || mIns[i + 0].mType == ASMIT_ROR) && mIns[i + 0].mMode == ASMIM_ZERO_PAGE &&
|
||||||
mIns[i + 1].mType == ASMIT_LDA && mIns[i + 1].mMode == ASMIM_ZERO_PAGE && mIns[i + 1].mAddress == mIns[i + 0].mAddress && !(mIns[i + 1].mLive & LIVE_MEM))
|
mIns[i + 1].mType == ASMIT_LDA && mIns[i + 1].mMode == ASMIM_ZERO_PAGE && mIns[i + 1].mAddress == mIns[i + 0].mAddress && !(mIns[i + 1].mLive & LIVE_MEM))
|
||||||
|
|
|
@ -166,6 +166,7 @@ public:
|
||||||
bool FindAddressSumY(int at, int reg, int & apos, int& breg, int& ireg);
|
bool FindAddressSumY(int at, int reg, int & apos, int& breg, int& ireg);
|
||||||
bool FindGlobalAddress(int at, int reg, int& apos);
|
bool FindGlobalAddress(int at, int reg, int& apos);
|
||||||
bool FindGlobalAddressSumY(int at, int reg, bool direct, int& apos, const NativeCodeInstruction * & ains, int& ireg);
|
bool FindGlobalAddressSumY(int at, int reg, bool direct, int& apos, const NativeCodeInstruction * & ains, int& ireg);
|
||||||
|
bool MoveStoreXUp(int at);
|
||||||
|
|
||||||
bool ValueForwarding(const NativeRegisterDataSet& data);
|
bool ValueForwarding(const NativeRegisterDataSet& data);
|
||||||
|
|
||||||
|
|
|
@ -33,16 +33,24 @@ Declaration* Parser::ParseStructDeclaration(uint32 flags, DecType dt)
|
||||||
{
|
{
|
||||||
structName = mScanner->mTokenIdent;
|
structName = mScanner->mTokenIdent;
|
||||||
mScanner->NextToken();
|
mScanner->NextToken();
|
||||||
Declaration* pdec = mScope->Insert(structName, dec);
|
Declaration* edec = mScope->Lookup(structName);
|
||||||
if (pdec)
|
if (edec && mScanner->mToken != TK_OPEN_BRACE)
|
||||||
{
|
{
|
||||||
if (pdec->mType == dt && (pdec->mFlags & DTF_DEFINED))
|
dec = edec;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Declaration* pdec = mScope->Insert(structName, dec);
|
||||||
|
if (pdec)
|
||||||
{
|
{
|
||||||
dec = pdec;
|
if (pdec->mType == dt && (pdec->mFlags & DTF_DEFINED))
|
||||||
}
|
{
|
||||||
else
|
dec = pdec;
|
||||||
{
|
}
|
||||||
mErrors->Error(mScanner->mLocation, EERR_DUPLICATE_DEFINITION, "Error duplicate struct declaration", structName->mString);
|
else
|
||||||
|
{
|
||||||
|
mErrors->Error(mScanner->mLocation, EERR_DUPLICATE_DEFINITION, "Error duplicate struct declaration", structName->mString);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -745,7 +753,7 @@ Declaration* Parser::ParseDeclaration(bool variable)
|
||||||
if (ndec->mIdent)
|
if (ndec->mIdent)
|
||||||
{
|
{
|
||||||
Declaration* pdec = mScope->Insert(ndec->mIdent, ndec->mBase);
|
Declaration* pdec = mScope->Insert(ndec->mIdent, ndec->mBase);
|
||||||
if (pdec)
|
if (pdec && pdec != ndec->mBase)
|
||||||
mErrors->Error(ndec->mLocation, EERR_DUPLICATE_DEFINITION, "Duplicate type declaration", ndec->mIdent->mString);
|
mErrors->Error(ndec->mLocation, EERR_DUPLICATE_DEFINITION, "Duplicate type declaration", ndec->mIdent->mString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue