Optimize pointer forwarding with striped addressing
This commit is contained in:
parent
83869ad3a0
commit
175520c885
|
@ -19779,6 +19779,27 @@ bool NativeCodeBasicBlock::CheckPatchFailReg(const NativeCodeBasicBlock* block,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NativeCodeBasicBlock::CheckPatchFailRegPair(const NativeCodeBasicBlock* block, int reg)
|
||||||
|
{
|
||||||
|
if (mPatched && (mEntryRequiredRegs[reg] || mEntryRequiredRegs[reg + 1]))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!mPatchFail)
|
||||||
|
{
|
||||||
|
mPatchFail = true;
|
||||||
|
|
||||||
|
if (this != block)
|
||||||
|
{
|
||||||
|
if (mTrueJump && !mTrueJump->CheckPatchFailRegPair(block, reg))
|
||||||
|
return false;
|
||||||
|
if (mFalseJump && !mFalseJump->CheckPatchFailRegPair(block, reg))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool NativeCodeBasicBlock::CheckSingleUseGlobalLoad(const NativeCodeBasicBlock* block, int reg, int at, const NativeCodeInstruction& ains, int cycles)
|
bool NativeCodeBasicBlock::CheckSingleUseGlobalLoad(const NativeCodeBasicBlock* block, int reg, int at, const NativeCodeInstruction& ains, int cycles)
|
||||||
{
|
{
|
||||||
if (!mPatched)
|
if (!mPatched)
|
||||||
|
@ -19971,7 +19992,16 @@ bool NativeCodeBasicBlock::CheckForwardSumYPointer(const NativeCodeBasicBlock* b
|
||||||
mPatched = true;
|
mPatched = true;
|
||||||
|
|
||||||
if (!mEntryRequiredRegs[reg] && !mEntryRequiredRegs[reg + 1])
|
if (!mEntryRequiredRegs[reg] && !mEntryRequiredRegs[reg + 1])
|
||||||
|
{
|
||||||
|
mPatchFail = true;
|
||||||
|
|
||||||
|
if (mTrueJump && !mTrueJump->CheckPatchFailRegPair(block, reg))
|
||||||
|
return false;
|
||||||
|
if (mFalseJump && !mFalseJump->CheckPatchFailRegPair(block, reg))
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (mNumEntries > 1)
|
if (mNumEntries > 1)
|
||||||
{
|
{
|
||||||
|
@ -19982,6 +20012,9 @@ bool NativeCodeBasicBlock::CheckForwardSumYPointer(const NativeCodeBasicBlock* b
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mPatchFail)
|
||||||
|
return false;
|
||||||
|
|
||||||
while (at < mIns.Size())
|
while (at < mIns.Size())
|
||||||
{
|
{
|
||||||
NativeCodeInstruction& ins(mIns[at]);
|
NativeCodeInstruction& ins(mIns[at]);
|
||||||
|
@ -21243,7 +21276,20 @@ bool NativeCodeBasicBlock::CheckGlobalAddressSumYPointer(const NativeCodeBasicBl
|
||||||
{
|
{
|
||||||
NativeCodeInstruction& ins(mIns[at]);
|
NativeCodeInstruction& ins(mIns[at]);
|
||||||
|
|
||||||
if (ins.mMode == ASMIM_ZERO_PAGE)
|
if (mIns[at + 0].mType == ASMIT_CLC &&
|
||||||
|
mIns[at + 1].mType == ASMIT_LDA && mIns[at + 1].mMode == ASMIM_ZERO_PAGE && mIns[at + 1].mAddress == reg &&
|
||||||
|
mIns[at + 2].mType == ASMIT_ADC && mIns[at + 2].mMode == ASMIM_IMMEDIATE &&
|
||||||
|
mIns[at + 3].mType == ASMIT_STA && mIns[at + 3].mMode == ASMIM_ZERO_PAGE && mIns[at + 3].mAddress != index &&
|
||||||
|
mIns[at + 4].mType == ASMIT_LDA && mIns[at + 4].mMode == ASMIM_ZERO_PAGE && mIns[at + 4].mAddress == reg + 1 &&
|
||||||
|
mIns[at + 5].mType == ASMIT_ADC && mIns[at + 5].mMode == ASMIM_IMMEDIATE &&
|
||||||
|
mIns[at + 6].mType == ASMIT_STA && mIns[at + 6].mMode == ASMIM_ZERO_PAGE && mIns[at + 6].mAddress != index &&
|
||||||
|
!(mIns[at + 6].mLive & LIVE_CPU_REG_C))
|
||||||
|
{
|
||||||
|
if (!(mIns[at + 1].mLive & LIVE_MEM) && !(mIns[at + 4].mLive & LIVE_MEM))
|
||||||
|
return true;
|
||||||
|
at += 6;
|
||||||
|
}
|
||||||
|
else if (ins.mMode == ASMIM_ZERO_PAGE)
|
||||||
{
|
{
|
||||||
if (ins.mAddress == index && ins.ChangesAddress())
|
if (ins.mAddress == index && ins.ChangesAddress())
|
||||||
return false;
|
return false;
|
||||||
|
@ -21307,7 +21353,42 @@ bool NativeCodeBasicBlock::PatchGlobalAddressSumYPointer(const NativeCodeBasicBl
|
||||||
|
|
||||||
assert(!(ins.mMode == ASMIM_ZERO_PAGE && (ins.mAddress == reg || ins.mAddress == reg + 1) && reg == index));
|
assert(!(ins.mMode == ASMIM_ZERO_PAGE && (ins.mAddress == reg || ins.mAddress == reg + 1) && reg == index));
|
||||||
|
|
||||||
if (ins.mMode == ASMIM_INDIRECT_Y && ins.mAddress == reg)
|
if (mIns[at + 0].mType == ASMIT_CLC &&
|
||||||
|
mIns[at + 1].mType == ASMIT_LDA && mIns[at + 1].mMode == ASMIM_ZERO_PAGE && mIns[at + 1].mAddress == reg &&
|
||||||
|
mIns[at + 2].mType == ASMIT_ADC && mIns[at + 2].mMode == ASMIM_IMMEDIATE &&
|
||||||
|
mIns[at + 3].mType == ASMIT_STA && mIns[at + 3].mMode == ASMIM_ZERO_PAGE && mIns[at + 3].mAddress != index &&
|
||||||
|
mIns[at + 4].mType == ASMIT_LDA && mIns[at + 4].mMode == ASMIM_ZERO_PAGE && mIns[at + 4].mAddress == reg + 1 &&
|
||||||
|
mIns[at + 5].mType == ASMIT_ADC && mIns[at + 5].mMode == ASMIM_IMMEDIATE &&
|
||||||
|
mIns[at + 6].mType == ASMIT_STA && mIns[at + 6].mMode == ASMIM_ZERO_PAGE && mIns[at + 6].mAddress != index &&
|
||||||
|
!(mIns[at + 6].mLive & LIVE_CPU_REG_C))
|
||||||
|
{
|
||||||
|
bool done = !(mIns[at + 1].mLive & LIVE_MEM) && !(mIns[at + 4].mLive & LIVE_MEM);
|
||||||
|
|
||||||
|
mIns[at + 1].mAddress = index;
|
||||||
|
|
||||||
|
int naddr = address + mIns[at + 2].mAddress + 256 * mIns[at + 5].mAddress;
|
||||||
|
|
||||||
|
mIns[at + 2].mMode = ASMIM_IMMEDIATE_ADDRESS;
|
||||||
|
mIns[at + 2].mLinkerObject = lobj;
|
||||||
|
mIns[at + 2].mAddress = naddr;
|
||||||
|
mIns[at + 2].mFlags = NCIF_LOWER;
|
||||||
|
|
||||||
|
mIns[at + 4].mMode = ASMIM_IMMEDIATE;
|
||||||
|
mIns[at + 4].mAddress = 0;
|
||||||
|
|
||||||
|
mIns[at + 5].mMode = ASMIM_IMMEDIATE_ADDRESS;
|
||||||
|
mIns[at + 5].mLinkerObject = lobj;
|
||||||
|
mIns[at + 5].mAddress = naddr;
|
||||||
|
mIns[at + 5].mFlags = NCIF_UPPER;
|
||||||
|
|
||||||
|
at += 6;
|
||||||
|
|
||||||
|
changed = true;
|
||||||
|
|
||||||
|
if (done)
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
else if (ins.mMode == ASMIM_INDIRECT_Y && ins.mAddress == reg)
|
||||||
{
|
{
|
||||||
assert(yval >= 0);
|
assert(yval >= 0);
|
||||||
|
|
||||||
|
@ -23377,7 +23458,7 @@ bool NativeCodeBasicBlock::Check16BitSum(int at, NativeRegisterSum16Info& info)
|
||||||
{
|
{
|
||||||
if (mIns[at + 0].mType == ASMIT_CLC &&
|
if (mIns[at + 0].mType == ASMIT_CLC &&
|
||||||
mIns[at + 1].mType == ASMIT_LDA &&
|
mIns[at + 1].mType == ASMIT_LDA &&
|
||||||
mIns[at + 2].mType == ASMIT_ADC &&
|
(mIns[at + 2].mType == ASMIT_ADC || mIns[at + 2].mType == ASMIT_ORA && mIns[at + 2].mMode == ASMIM_IMMEDIATE && mIns[at + 2].mAddress == 0) &&
|
||||||
mIns[at + 3].mType == ASMIT_STA && mIns[at + 3].mMode == ASMIM_ZERO_PAGE &&
|
mIns[at + 3].mType == ASMIT_STA && mIns[at + 3].mMode == ASMIM_ZERO_PAGE &&
|
||||||
mIns[at + 4].mType == ASMIT_LDA &&
|
mIns[at + 4].mType == ASMIT_LDA &&
|
||||||
mIns[at + 5].mType == ASMIT_ADC &&
|
mIns[at + 5].mType == ASMIT_ADC &&
|
||||||
|
@ -24018,6 +24099,21 @@ bool NativeCodeBasicBlock::BackwardReplaceZeroPage(int at, int from, int to, boo
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NativeRegisterSum16Info::operator==(const NativeRegisterSum16Info& ri) const
|
||||||
|
{
|
||||||
|
if (mSrcL != ri.mSrcL || mSrcH != ri.mSrcH || mAddL != ri.mAddL || mAddH != ri.mAddH || mDstL != ri.mDstL || mDstH != ri.mDstH)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (mImmediate)
|
||||||
|
return mAddress == ri.mAddress && mLinkerObject == ri.mLinkerObject;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NativeRegisterSum16Info::operator!=(const NativeRegisterSum16Info& ri) const
|
||||||
|
{
|
||||||
|
return !(*this == ri);
|
||||||
|
}
|
||||||
|
|
||||||
bool NativeCodeBasicBlock::Propagate16BitSum(const ExpandingArray<NativeRegisterSum16Info> & cinfo)
|
bool NativeCodeBasicBlock::Propagate16BitSum(const ExpandingArray<NativeRegisterSum16Info> & cinfo)
|
||||||
{
|
{
|
||||||
|
@ -24025,11 +24121,30 @@ bool NativeCodeBasicBlock::Propagate16BitSum(const ExpandingArray<NativeRegister
|
||||||
|
|
||||||
if (!mVisited)
|
if (!mVisited)
|
||||||
{
|
{
|
||||||
mVisited = true;
|
if (mLoopHead)
|
||||||
|
mRSumInfos.SetSize(0);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (mNumEntered == 0)
|
||||||
|
mRSumInfos = cinfo;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
while (i < mRSumInfos.Size())
|
||||||
|
{
|
||||||
|
if (cinfo.Contains(mRSumInfos[i]))
|
||||||
|
i++;
|
||||||
|
else
|
||||||
|
mRSumInfos.Remove(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ExpandingArray<NativeRegisterSum16Info> infos;
|
mNumEntered++;
|
||||||
if (mNumEntries == 1)
|
if (mNumEntered < mNumEntries)
|
||||||
infos = cinfo;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mVisited = true;
|
||||||
|
|
||||||
for (int i = 0; i < mIns.Size(); i++)
|
for (int i = 0; i < mIns.Size(); i++)
|
||||||
{
|
{
|
||||||
|
@ -24037,36 +24152,39 @@ bool NativeCodeBasicBlock::Propagate16BitSum(const ExpandingArray<NativeRegister
|
||||||
|
|
||||||
if (Check16BitSum(i, info))
|
if (Check16BitSum(i, info))
|
||||||
{
|
{
|
||||||
for (int j = 0; j < infos.Size(); j++)
|
for (int j = 0; j < mRSumInfos.Size(); j++)
|
||||||
{
|
{
|
||||||
if (info.mSrcL->mAddress == infos[j].mDstL->mAddress && info.mSrcH->mAddress == infos[j].mDstH->mAddress)
|
if (info.mSrcL->mAddress == mRSumInfos[j].mDstL->mAddress && info.mSrcH->mAddress == mRSumInfos[j].mDstH->mAddress)
|
||||||
{
|
{
|
||||||
if (info.mImmediate && infos[j].mImmediate)
|
if (info.mImmediate && mRSumInfos[j].mImmediate)
|
||||||
{
|
{
|
||||||
if (!info.mLinkerObject && !infos[j].mLinkerObject)
|
if (!info.mLinkerObject && !mRSumInfos[j].mLinkerObject)
|
||||||
{
|
{
|
||||||
info.mAddress += infos[j].mAddress;
|
info.mAddress += mRSumInfos[j].mAddress;
|
||||||
|
info.mAddL->mType = ASMIT_ADC;
|
||||||
info.mAddL->mAddress = info.mAddress & 0xff;
|
info.mAddL->mAddress = info.mAddress & 0xff;
|
||||||
info.mAddH->mAddress = info.mAddress >> 8;
|
info.mAddH->mAddress = info.mAddress >> 8;
|
||||||
info.mSrcL->mAddress = infos[j].mSrcL->mAddress;
|
info.mSrcL->mAddress = mRSumInfos[j].mSrcL->mAddress;
|
||||||
info.mSrcH->mAddress = infos[j].mSrcH->mAddress;
|
info.mSrcH->mAddress = mRSumInfos[j].mSrcH->mAddress;
|
||||||
info.mSrcH->mMode = infos[j].mSrcH->mMode;
|
info.mSrcH->mMode = mRSumInfos[j].mSrcH->mMode;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
else if (!infos[j].mLinkerObject)
|
else if (!mRSumInfos[j].mLinkerObject)
|
||||||
{
|
{
|
||||||
info.mAddress += infos[j].mAddress;
|
info.mAddress += mRSumInfos[j].mAddress;
|
||||||
|
info.mAddL->mType = ASMIT_ADC;
|
||||||
info.mAddL->mAddress = info.mAddress;
|
info.mAddL->mAddress = info.mAddress;
|
||||||
info.mAddH->mAddress = info.mAddress;
|
info.mAddH->mAddress = info.mAddress;
|
||||||
info.mSrcL->mAddress = infos[j].mSrcL->mAddress;
|
info.mSrcL->mAddress = mRSumInfos[j].mSrcL->mAddress;
|
||||||
info.mSrcH->mAddress = infos[j].mSrcH->mAddress;
|
info.mSrcH->mAddress = mRSumInfos[j].mSrcH->mAddress;
|
||||||
info.mSrcH->mMode = infos[j].mSrcH->mMode;
|
info.mSrcH->mMode = mRSumInfos[j].mSrcH->mMode;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
else if (!info.mLinkerObject)
|
else if (!info.mLinkerObject)
|
||||||
{
|
{
|
||||||
info.mAddress += infos[j].mAddress;
|
info.mAddress += mRSumInfos[j].mAddress;
|
||||||
info.mLinkerObject = infos[j].mLinkerObject;
|
info.mLinkerObject = mRSumInfos[j].mLinkerObject;
|
||||||
|
info.mAddL->mType = ASMIT_ADC;
|
||||||
info.mAddL->mAddress = info.mAddress;
|
info.mAddL->mAddress = info.mAddress;
|
||||||
info.mAddL->mLinkerObject = info.mLinkerObject;
|
info.mAddL->mLinkerObject = info.mLinkerObject;
|
||||||
info.mAddL->mMode = ASMIM_IMMEDIATE_ADDRESS;
|
info.mAddL->mMode = ASMIM_IMMEDIATE_ADDRESS;
|
||||||
|
@ -24075,31 +24193,31 @@ bool NativeCodeBasicBlock::Propagate16BitSum(const ExpandingArray<NativeRegister
|
||||||
info.mAddH->mLinkerObject = info.mLinkerObject;
|
info.mAddH->mLinkerObject = info.mLinkerObject;
|
||||||
info.mAddH->mMode = ASMIM_IMMEDIATE_ADDRESS;
|
info.mAddH->mMode = ASMIM_IMMEDIATE_ADDRESS;
|
||||||
info.mAddH->mFlags = NCIF_UPPER;
|
info.mAddH->mFlags = NCIF_UPPER;
|
||||||
info.mSrcL->mAddress = infos[j].mSrcL->mAddress;
|
info.mSrcL->mAddress = mRSumInfos[j].mSrcL->mAddress;
|
||||||
info.mSrcH->mAddress = infos[j].mSrcH->mAddress;
|
info.mSrcH->mAddress = mRSumInfos[j].mSrcH->mAddress;
|
||||||
info.mSrcH->mMode = infos[j].mSrcH->mMode;
|
info.mSrcH->mMode = mRSumInfos[j].mSrcH->mMode;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (info.mSrcL->mAddress == infos[j].mSrcL->mAddress && info.mSrcH->mAddress == infos[j].mSrcH->mAddress)
|
else if (info.mSrcL->mAddress == mRSumInfos[j].mSrcL->mAddress && info.mSrcH->mAddress == mRSumInfos[j].mSrcH->mAddress)
|
||||||
{
|
{
|
||||||
if (info.mAddH->mMode == ASMIM_IMMEDIATE && infos[j].mAddH->mMode == ASMIM_IMMEDIATE &&
|
if (info.mAddH->mMode == ASMIM_IMMEDIATE && mRSumInfos[j].mAddH->mMode == ASMIM_IMMEDIATE &&
|
||||||
info.mAddL->mMode == ASMIM_ZERO_PAGE && infos[j].mAddL->mMode == ASMIM_ZERO_PAGE && info.mAddL->mAddress == infos[j].mAddL->mAddress)
|
info.mAddL->mMode == ASMIM_ZERO_PAGE && mRSumInfos[j].mAddL->mMode == ASMIM_ZERO_PAGE && info.mAddL->mAddress == mRSumInfos[j].mAddL->mAddress)
|
||||||
{
|
{
|
||||||
info.mAddL->mType = ASMIT_NOP; info.mAddL->mMode = ASMIM_IMPLIED;
|
info.mAddL->mType = ASMIT_NOP; info.mAddL->mMode = ASMIM_IMPLIED;
|
||||||
info.mSrcL->mAddress = infos[j].mDstL->mAddress;
|
info.mSrcL->mAddress = mRSumInfos[j].mDstL->mAddress;
|
||||||
info.mSrcH->mAddress = infos[j].mDstH->mAddress;
|
info.mSrcH->mAddress = mRSumInfos[j].mDstH->mAddress;
|
||||||
info.mAddH->mAddress -= infos[j].mAddH->mAddress;
|
info.mAddH->mAddress -= mRSumInfos[j].mAddH->mAddress;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
else if (info.mAddL->mMode == ASMIM_IMMEDIATE && info.mAddH->mMode == ASMIM_IMMEDIATE &&
|
else if (info.mAddL->mMode == ASMIM_IMMEDIATE && info.mAddH->mMode == ASMIM_IMMEDIATE &&
|
||||||
infos[j].mAddL->mMode == ASMIM_IMMEDIATE && infos[j].mAddH->mMode == ASMIM_IMMEDIATE)
|
mRSumInfos[j].mAddL->mMode == ASMIM_IMMEDIATE && mRSumInfos[j].mAddH->mMode == ASMIM_IMMEDIATE)
|
||||||
{
|
{
|
||||||
if (info.mAddress == infos[j].mAddress)
|
if (info.mAddress == mRSumInfos[j].mAddress)
|
||||||
{
|
{
|
||||||
info.mSrcL->mAddress = infos[j].mDstL->mAddress;
|
info.mSrcL->mAddress = mRSumInfos[j].mDstL->mAddress;
|
||||||
info.mSrcH->mAddress = infos[j].mDstH->mAddress;
|
info.mSrcH->mAddress = mRSumInfos[j].mDstH->mAddress;
|
||||||
info.mAddL->mType = ASMIT_NOP; info.mAddL->mMode = ASMIM_IMPLIED;
|
info.mAddL->mType = ASMIT_NOP; info.mAddL->mMode = ASMIM_IMPLIED;
|
||||||
info.mAddH->mType = ASMIT_NOP; info.mAddH->mMode = ASMIM_IMPLIED;
|
info.mAddH->mType = ASMIT_NOP; info.mAddH->mMode = ASMIM_IMPLIED;
|
||||||
changed = true;
|
changed = true;
|
||||||
|
@ -24109,23 +24227,23 @@ bool NativeCodeBasicBlock::Propagate16BitSum(const ExpandingArray<NativeRegister
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.mSrcL->mAddress != info.mDstL->mAddress && (info.mSrcH->mMode == ASMIM_IMMEDIATE || info.mSrcH->mAddress != info.mDstH->mAddress))
|
if (info.mSrcL->mAddress != info.mDstL->mAddress && (info.mSrcH->mMode == ASMIM_IMMEDIATE || info.mSrcH->mAddress != info.mDstH->mAddress))
|
||||||
infos.Push(info);
|
mRSumInfos.Push(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
int j = 0;
|
int j = 0;
|
||||||
while (j < infos.Size())
|
while (j < mRSumInfos.Size())
|
||||||
{
|
{
|
||||||
if (infos[j].mDstL != &(mIns[i]) && infos[j].mDstH != &(mIns[i]))
|
if (mRSumInfos[j].mDstL != &(mIns[i]) && mRSumInfos[j].mDstH != &(mIns[i]))
|
||||||
{
|
{
|
||||||
if (
|
if (
|
||||||
infos[j].mSrcL->MayBeChangedOnAddress(mIns[i]) ||
|
mRSumInfos[j].mSrcL->MayBeChangedOnAddress(mIns[i]) ||
|
||||||
infos[j].mSrcH->MayBeChangedOnAddress(mIns[i]) ||
|
mRSumInfos[j].mSrcH->MayBeChangedOnAddress(mIns[i]) ||
|
||||||
infos[j].mAddL->MayBeChangedOnAddress(mIns[i]) ||
|
mRSumInfos[j].mAddL->MayBeChangedOnAddress(mIns[i]) ||
|
||||||
infos[j].mAddH->MayBeChangedOnAddress(mIns[i]) ||
|
mRSumInfos[j].mAddH->MayBeChangedOnAddress(mIns[i]) ||
|
||||||
infos[j].mDstL->MayBeChangedOnAddress(mIns[i]) ||
|
mRSumInfos[j].mDstL->MayBeChangedOnAddress(mIns[i]) ||
|
||||||
infos[j].mDstH->MayBeChangedOnAddress(mIns[i]))
|
mRSumInfos[j].mDstH->MayBeChangedOnAddress(mIns[i]))
|
||||||
{
|
{
|
||||||
infos.Remove(j);
|
mRSumInfos.Remove(j);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
j++;
|
j++;
|
||||||
|
@ -24135,9 +24253,9 @@ bool NativeCodeBasicBlock::Propagate16BitSum(const ExpandingArray<NativeRegister
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mTrueJump && mTrueJump->Propagate16BitSum(infos))
|
if (mTrueJump && mTrueJump->Propagate16BitSum(mRSumInfos))
|
||||||
changed = true;
|
changed = true;
|
||||||
if (mFalseJump && mFalseJump->Propagate16BitSum(infos))
|
if (mFalseJump && mFalseJump->Propagate16BitSum(mRSumInfos))
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
|
@ -27860,6 +27978,9 @@ bool NativeCodeBasicBlock::OptimizeSimpleLoop(NativeCodeProcedure * proc, bool f
|
||||||
int zreg = mIns[sz - 1].mAddress;
|
int zreg = mIns[sz - 1].mAddress;
|
||||||
int yinc = 0, xinc = 0;
|
int yinc = 0, xinc = 0;
|
||||||
|
|
||||||
|
if (mIns[sz - 1].mLive & LIVE_CPU_REG_Y)
|
||||||
|
yother = true;
|
||||||
|
|
||||||
for (int i = 0; i < sz - 1; i++)
|
for (int i = 0; i < sz - 1; i++)
|
||||||
{
|
{
|
||||||
if (mIns[i].mType == ASMIT_TAY)
|
if (mIns[i].mType == ASMIT_TAY)
|
||||||
|
@ -32710,7 +32831,7 @@ bool NativeCodeBasicBlock::PeepHoleOptimizer(NativeCodeProcedure* proc, int pass
|
||||||
mIns[i + 0].mType = ASMIT_SEC;
|
mIns[i + 0].mType = ASMIT_SEC;
|
||||||
progress = true;
|
progress = true;
|
||||||
}
|
}
|
||||||
else if (
|
else if (pass > 0 &&
|
||||||
mIns[i + 0].mType == ASMIT_CLC &&
|
mIns[i + 0].mType == ASMIT_CLC &&
|
||||||
mIns[i + 1].mType == ASMIT_LDA && mIns[i + 1].mMode == ASMIM_IMMEDIATE && mIns[i + 1].mAddress == 0 &&
|
mIns[i + 1].mType == ASMIT_LDA && mIns[i + 1].mMode == ASMIM_IMMEDIATE && mIns[i + 1].mAddress == 0 &&
|
||||||
mIns[i + 2].mType == ASMIT_ADC)
|
mIns[i + 2].mType == ASMIT_ADC)
|
||||||
|
@ -32719,7 +32840,7 @@ bool NativeCodeBasicBlock::PeepHoleOptimizer(NativeCodeProcedure* proc, int pass
|
||||||
mIns[i + 2].mType = ASMIT_LDA;
|
mIns[i + 2].mType = ASMIT_LDA;
|
||||||
progress = true;
|
progress = true;
|
||||||
}
|
}
|
||||||
else if (
|
else if (pass > 0 &&
|
||||||
mIns[i + 0].mType == ASMIT_CLC &&
|
mIns[i + 0].mType == ASMIT_CLC &&
|
||||||
mIns[i + 1].mType == ASMIT_LDA &&
|
mIns[i + 1].mType == ASMIT_LDA &&
|
||||||
mIns[i + 2].mType == ASMIT_ADC && mIns[i + 2].mMode == ASMIM_IMMEDIATE && mIns[i + 2].mAddress == 0)
|
mIns[i + 2].mType == ASMIT_ADC && mIns[i + 2].mMode == ASMIM_IMMEDIATE && mIns[i + 2].mAddress == 0)
|
||||||
|
@ -37527,7 +37648,7 @@ void NativeCodeProcedure::RebuildEntry(void)
|
||||||
|
|
||||||
void NativeCodeProcedure::Optimize(void)
|
void NativeCodeProcedure::Optimize(void)
|
||||||
{
|
{
|
||||||
CheckFunc = !strcmp(mInterProc->mIdent->mString, "move");
|
CheckFunc = !strcmp(mInterProc->mIdent->mString, "pad_poll");
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
int step = 0;
|
int step = 0;
|
||||||
|
@ -37607,6 +37728,7 @@ void NativeCodeProcedure::Optimize(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int t = 0;
|
||||||
#if 1
|
#if 1
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -37616,6 +37738,7 @@ void NativeCodeProcedure::Optimize(void)
|
||||||
ResetVisited();
|
ResetVisited();
|
||||||
changed = mEntryBlock->RemoveUnusedResultInstructions();
|
changed = mEntryBlock->RemoveUnusedResultInstructions();
|
||||||
|
|
||||||
|
|
||||||
if (step == 0)
|
if (step == 0)
|
||||||
{
|
{
|
||||||
ResetVisited();
|
ResetVisited();
|
||||||
|
@ -37649,6 +37772,7 @@ void NativeCodeProcedure::Optimize(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
t++;
|
||||||
|
|
||||||
} while (changed);
|
} while (changed);
|
||||||
#endif
|
#endif
|
||||||
|
@ -37719,6 +37843,8 @@ void NativeCodeProcedure::Optimize(void)
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
if (step > 0)
|
if (step > 0)
|
||||||
{
|
{
|
||||||
|
@ -37790,6 +37916,7 @@ void NativeCodeProcedure::Optimize(void)
|
||||||
ResetVisited();
|
ResetVisited();
|
||||||
mEntryBlock->CheckBlocks(true);
|
mEntryBlock->CheckBlocks(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
if (step == 3 || step == 4)
|
if (step == 3 || step == 4)
|
||||||
{
|
{
|
||||||
|
|
|
@ -63,6 +63,9 @@ struct NativeRegisterSum16Info
|
||||||
bool mImmediate;
|
bool mImmediate;
|
||||||
int mAddress;
|
int mAddress;
|
||||||
LinkerObject * mLinkerObject;
|
LinkerObject * mLinkerObject;
|
||||||
|
|
||||||
|
bool operator==(const NativeRegisterSum16Info& ri) const;
|
||||||
|
bool operator!=(const NativeRegisterSum16Info& ri) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -188,6 +191,8 @@ public:
|
||||||
NativeRegisterDataSet mDataSet, mNDataSet, mFDataSet;
|
NativeRegisterDataSet mDataSet, mNDataSet, mFDataSet;
|
||||||
int mYAlias[256], mYOffset;
|
int mYAlias[256], mYOffset;
|
||||||
|
|
||||||
|
ExpandingArray<NativeRegisterSum16Info> mRSumInfos;
|
||||||
|
|
||||||
NativeCodeInstruction DecodeNative(LinkerObject * lobj, int& offset) const;
|
NativeCodeInstruction DecodeNative(LinkerObject * lobj, int& offset) const;
|
||||||
|
|
||||||
int PutBranch(NativeCodeProcedure* proc, NativeCodeBasicBlock* target, AsmInsType code, int offset);
|
int PutBranch(NativeCodeProcedure* proc, NativeCodeBasicBlock* target, AsmInsType code, int offset);
|
||||||
|
@ -509,6 +514,7 @@ public:
|
||||||
bool ShortcutPointerAddForward(void);
|
bool ShortcutPointerAddForward(void);
|
||||||
|
|
||||||
bool CheckPatchFailReg(const NativeCodeBasicBlock* block, int reg);
|
bool CheckPatchFailReg(const NativeCodeBasicBlock* block, int reg);
|
||||||
|
bool CheckPatchFailRegPair(const NativeCodeBasicBlock* block, int reg);
|
||||||
bool CheckPatchFailUse(void);
|
bool CheckPatchFailUse(void);
|
||||||
|
|
||||||
bool CheckPatchFailLoop(const NativeCodeBasicBlock* block, const NativeCodeBasicBlock* head, int reg, bool changed);
|
bool CheckPatchFailLoop(const NativeCodeBasicBlock* block, const NativeCodeBasicBlock* head, int reg, bool changed);
|
||||||
|
|
Loading…
Reference in New Issue