Fix struct scoping
This commit is contained in:
parent
33433403b1
commit
55b79ecfce
|
@ -14,8 +14,8 @@ struct CIA
|
|||
byte cra, crb;
|
||||
};
|
||||
|
||||
#define cia1 (*((CIA *)0xdc00))
|
||||
#define cia2 (*((CIA *)0xdd00))
|
||||
#define cia1 (*((struct CIA *)0xdc00))
|
||||
#define cia2 (*((struct CIA *)0xdd00))
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -26,11 +26,11 @@ enum RIRQCodeIndex
|
|||
RIRQ_SIZE = 31
|
||||
};
|
||||
|
||||
struct RIRQCode
|
||||
typedef struct RIRQCode
|
||||
{
|
||||
byte size;
|
||||
byte code[RIRQ_SIZE];
|
||||
};
|
||||
} RIRQCode;
|
||||
|
||||
void rirq_build(RIRQCode * ic, byte size);
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ struct VIC
|
|||
|
||||
void vic_setbank(char bank);
|
||||
|
||||
#define vic (*((VIC *)0xd000))
|
||||
#define vic (*((struct VIC *)0xd000))
|
||||
|
||||
#pragma compile("vic.c")
|
||||
|
||||
|
|
|
@ -7068,6 +7068,29 @@ bool NativeCodeBasicBlock::MoveAbsoluteLoadStoreUp(int at)
|
|||
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)
|
||||
{
|
||||
int j = at;
|
||||
|
@ -7621,6 +7644,9 @@ bool NativeCodeBasicBlock::PeepHoleOptimizer(void)
|
|||
// shorten x/y register livetime
|
||||
|
||||
#if 1
|
||||
//
|
||||
// move ldy down
|
||||
|
||||
for (int i = 0; i + 1 < mIns.Size(); i++)
|
||||
{
|
||||
if (mIns[i].mType == ASMIT_LDY && mIns[i].mMode == ASMIM_IMMEDIATE)
|
||||
|
@ -7635,6 +7661,19 @@ bool NativeCodeBasicBlock::PeepHoleOptimizer(void)
|
|||
}
|
||||
#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;
|
||||
do {
|
||||
progress = false;
|
||||
|
@ -7853,6 +7892,34 @@ bool NativeCodeBasicBlock::PeepHoleOptimizer(void)
|
|||
mIns[i + 0].mLive |= LIVE_CPU_REG_A;
|
||||
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 (
|
||||
(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))
|
||||
|
|
|
@ -166,6 +166,7 @@ public:
|
|||
bool FindAddressSumY(int at, int reg, int & apos, int& breg, int& ireg);
|
||||
bool FindGlobalAddress(int at, int reg, int& apos);
|
||||
bool FindGlobalAddressSumY(int at, int reg, bool direct, int& apos, const NativeCodeInstruction * & ains, int& ireg);
|
||||
bool MoveStoreXUp(int at);
|
||||
|
||||
bool ValueForwarding(const NativeRegisterDataSet& data);
|
||||
|
||||
|
|
|
@ -33,6 +33,13 @@ Declaration* Parser::ParseStructDeclaration(uint32 flags, DecType dt)
|
|||
{
|
||||
structName = mScanner->mTokenIdent;
|
||||
mScanner->NextToken();
|
||||
Declaration* edec = mScope->Lookup(structName);
|
||||
if (edec && mScanner->mToken != TK_OPEN_BRACE)
|
||||
{
|
||||
dec = edec;
|
||||
}
|
||||
else
|
||||
{
|
||||
Declaration* pdec = mScope->Insert(structName, dec);
|
||||
if (pdec)
|
||||
{
|
||||
|
@ -46,6 +53,7 @@ Declaration* Parser::ParseStructDeclaration(uint32 flags, DecType dt)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!dec->mIdent || !dec->mScope)
|
||||
{
|
||||
|
@ -745,7 +753,7 @@ Declaration* Parser::ParseDeclaration(bool variable)
|
|||
if (ndec->mIdent)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue