Fix sample build crash on linux
This commit is contained in:
parent
400017bc54
commit
5564b01d11
|
@ -465,6 +465,7 @@ public:
|
||||||
void Insert(int at, T t)
|
void Insert(int at, T t)
|
||||||
{
|
{
|
||||||
Grow(size + 1, false);
|
Grow(size + 1, false);
|
||||||
|
assert(at >= 0 && at < size);
|
||||||
int j = size - 1;
|
int j = size - 1;
|
||||||
while (j > at)
|
while (j > at)
|
||||||
{
|
{
|
||||||
|
@ -476,6 +477,7 @@ public:
|
||||||
|
|
||||||
void Remove(int at)
|
void Remove(int at)
|
||||||
{
|
{
|
||||||
|
assert(at >= 0 && at < size);
|
||||||
while (at + 1 < size)
|
while (at + 1 < size)
|
||||||
{
|
{
|
||||||
array[at] = array[at + 1];
|
array[at] = array[at + 1];
|
||||||
|
@ -486,6 +488,7 @@ public:
|
||||||
|
|
||||||
void Remove(int at, int n)
|
void Remove(int at, int n)
|
||||||
{
|
{
|
||||||
|
assert(at >= 0 && at + n <= size);
|
||||||
while (at + n < size)
|
while (at + n < size)
|
||||||
{
|
{
|
||||||
array[at] = array[at + n];
|
array[at] = array[at + n];
|
||||||
|
@ -516,6 +519,7 @@ public:
|
||||||
|
|
||||||
T Top(void) const
|
T Top(void) const
|
||||||
{
|
{
|
||||||
|
assert(size > 0);
|
||||||
return array[size - 1];
|
return array[size - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -531,6 +535,7 @@ public:
|
||||||
|
|
||||||
void SetSize(int size, bool clear = false)
|
void SetSize(int size, bool clear = false)
|
||||||
{
|
{
|
||||||
|
assert(size >= 0);
|
||||||
Grow(size, clear);
|
Grow(size, clear);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "Assembler.h"
|
#include "Assembler.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
AsmInsData DecInsData[256] = {
|
AsmInsData DecInsData[256] = {
|
||||||
|
@ -347,7 +348,7 @@ static inline char toupper(char ch)
|
||||||
}
|
}
|
||||||
AsmInsType FindAsmInstruction(const char* ins)
|
AsmInsType FindAsmInstruction(const char* ins)
|
||||||
{
|
{
|
||||||
if (!ins[3])
|
if (ins && strlen(ins) == 3)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < NUM_ASM_INS_TYPES; i++)
|
for (int i = 0; i < NUM_ASM_INS_TYPES; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -97,7 +97,7 @@ void IntegerValueRange::LimitMinWeak(int64 value)
|
||||||
|
|
||||||
void IntegerValueRange::LimitMaxWeak(int64 value)
|
void IntegerValueRange::LimitMaxWeak(int64 value)
|
||||||
{
|
{
|
||||||
if (mMaxState == S_UNBOUND || mMinState != S_UNKNOWN && mMaxValue > value)
|
if (mMaxState == S_UNBOUND || mMaxState != S_UNKNOWN && mMaxValue > value)
|
||||||
{
|
{
|
||||||
mMaxState = S_BOUND;
|
mMaxState = S_BOUND;
|
||||||
mMaxValue = value;
|
mMaxValue = value;
|
||||||
|
@ -6152,7 +6152,6 @@ void InterCodeBasicBlock::UpdateLocalIntegerRangeSets(const GrowingVariableArray
|
||||||
|
|
||||||
if (singleLoop)
|
if (singleLoop)
|
||||||
{
|
{
|
||||||
#if 1
|
|
||||||
struct TempChain
|
struct TempChain
|
||||||
{
|
{
|
||||||
int mBaseTemp;
|
int mBaseTemp;
|
||||||
|
@ -6197,50 +6196,6 @@ void InterCodeBasicBlock::UpdateLocalIntegerRangeSets(const GrowingVariableArray
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#else
|
|
||||||
FastNumberSet changedTemps(mExitRequiredTemps.Size());
|
|
||||||
GrowingArray<int> expandedTemps(-1);
|
|
||||||
|
|
||||||
for (int i = 0; i < sz; i++)
|
|
||||||
{
|
|
||||||
InterInstruction* ins(mInstructions[i]);
|
|
||||||
|
|
||||||
if (ins->mCode == IC_BINARY_OPERATOR && ins->mOperator == IA_ADD && ins->mDst.mTemp == ins->mSrc[1].mTemp && ins->mSrc[0].mTemp < 0 && ins->mSrc[0].mIntConst > 0)
|
|
||||||
{
|
|
||||||
if (dependTemps[ins->mDst.mTemp])
|
|
||||||
changedTemps += ins->mDst.mTemp;
|
|
||||||
else if (pblock->mTrueValueRange[ins->mDst.mTemp].IsConstant())
|
|
||||||
dependTemps += ins->mDst.mTemp;
|
|
||||||
else
|
|
||||||
changedTemps += ins->mDst.mTemp;
|
|
||||||
}
|
|
||||||
else if (ins->mCode == IC_BINARY_OPERATOR && ins->mOperator == IA_ADD &&
|
|
||||||
ins->mSrc[1].mTemp >= 0 &&
|
|
||||||
ins->mDst.mTemp == expandedTemps[ins->mSrc[1].mTemp] && ins->mSrc[0].mTemp < 0 && ins->mSrc[0].mIntConst > 0)
|
|
||||||
{
|
|
||||||
if (dependTemps[ins->mDst.mTemp])
|
|
||||||
changedTemps += ins->mDst.mTemp;
|
|
||||||
else if (pblock->mTrueValueRange[ins->mDst.mTemp].IsConstant())
|
|
||||||
dependTemps += ins->mDst.mTemp;
|
|
||||||
else
|
|
||||||
changedTemps += ins->mDst.mTemp;
|
|
||||||
expandedTemps[ins->mSrc[1].mTemp] = -1;
|
|
||||||
}
|
|
||||||
else if (ins->mCode == IC_CONVERSION_OPERATOR && ins->mOperator == IA_EXT8TO16U && ins->mSrc[0].mTemp >= 0)
|
|
||||||
{
|
|
||||||
expandedTemps[ins->mDst.mTemp] = ins->mSrc[0].mTemp;
|
|
||||||
changedTemps += ins->mDst.mTemp;
|
|
||||||
}
|
|
||||||
else if (ins->mDst.mTemp >= 0)
|
|
||||||
{
|
|
||||||
expandedTemps[ins->mDst.mTemp] = -1;
|
|
||||||
changedTemps += ins->mDst.mTemp;
|
|
||||||
dependTemps -= ins->mDst.mTemp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < sz; i++)
|
for (int i = 0; i < sz; i++)
|
||||||
|
@ -6305,9 +6260,15 @@ void InterCodeBasicBlock::UpdateLocalIntegerRangeSets(const GrowingVariableArray
|
||||||
vr.LimitMax(65535);
|
vr.LimitMax(65535);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
|
LinkerObject* lo = mInstructions[i]->mSrc[0].mLinkerObject;
|
||||||
|
|
||||||
if (i > 0 &&
|
if (i > 0 &&
|
||||||
mInstructions[i - 1]->mCode == IC_LEA && mInstructions[i - 1]->mDst.mTemp == ins->mSrc[0].mTemp &&
|
mInstructions[i - 1]->mCode == IC_LEA && mInstructions[i - 1]->mDst.mTemp == ins->mSrc[0].mTemp &&
|
||||||
mInstructions[i - 1]->mSrc[1].mTemp < 0 && mInstructions[i - 1]->mSrc[1].mMemory == IM_GLOBAL && (mInstructions[i - 1]->mSrc[1].mLinkerObject->mFlags & LOBJF_CONST))
|
mInstructions[i - 1]->mSrc[1].mTemp < 0 && mInstructions[i - 1]->mSrc[1].mMemory == IM_GLOBAL)
|
||||||
|
lo = mInstructions[i - 1]->mSrc[1].mLinkerObject;
|
||||||
|
|
||||||
|
if (lo && lo->mFlags & LOBJF_CONST)
|
||||||
{
|
{
|
||||||
if (ins->mDst.mType == IT_INT8)
|
if (ins->mDst.mType == IT_INT8)
|
||||||
{
|
{
|
||||||
|
@ -6316,7 +6277,6 @@ void InterCodeBasicBlock::UpdateLocalIntegerRangeSets(const GrowingVariableArray
|
||||||
mInstructions[i + 1]->mSrc[0].mTemp == mInstructions[i + 0]->mDst.mTemp && mInstructions[i + 1]->mSrc[0].mFinal)
|
mInstructions[i + 1]->mSrc[0].mTemp == mInstructions[i + 0]->mDst.mTemp && mInstructions[i + 1]->mSrc[0].mFinal)
|
||||||
isUnsigned = true;
|
isUnsigned = true;
|
||||||
|
|
||||||
LinkerObject* lo = mInstructions[i - 1]->mSrc[1].mLinkerObject;
|
|
||||||
int mi = 0, ma = 0;
|
int mi = 0, ma = 0;
|
||||||
|
|
||||||
if (vr.mMinState == IntegerValueRange::S_BOUND && vr.mMaxState == IntegerValueRange::S_BOUND &&
|
if (vr.mMinState == IntegerValueRange::S_BOUND && vr.mMaxState == IntegerValueRange::S_BOUND &&
|
||||||
|
@ -6347,6 +6307,7 @@ void InterCodeBasicBlock::UpdateLocalIntegerRangeSets(const GrowingVariableArray
|
||||||
vr.LimitMin(mi);
|
vr.LimitMin(mi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case IC_CONSTANT:
|
case IC_CONSTANT:
|
||||||
|
@ -9365,6 +9326,84 @@ static int Find(GrowingIntArray& table, int i)
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InterCodeBasicBlock::LinkerObjectForwarding(const GrowingInstructionPtrArray& tvalue)
|
||||||
|
{
|
||||||
|
if (!mVisited)
|
||||||
|
{
|
||||||
|
GrowingInstructionPtrArray ltvalue(tvalue);
|
||||||
|
|
||||||
|
if (mLoopHead)
|
||||||
|
{
|
||||||
|
if (mNumEntries == 2 && (mTrueJump == this || mFalseJump == this))
|
||||||
|
{
|
||||||
|
mLoadStoreInstructions = tvalue;
|
||||||
|
for (int i = 0; i < mInstructions.Size(); i++)
|
||||||
|
{
|
||||||
|
InterInstruction* ins(mInstructions[i]);
|
||||||
|
if (ins->mDst.mTemp >= 0)
|
||||||
|
ltvalue[ins->mDst.mTemp] = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ltvalue.Clear();
|
||||||
|
}
|
||||||
|
else if (mNumEntries > 0)
|
||||||
|
{
|
||||||
|
if (mNumEntered > 0)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < ltvalue.Size(); i++)
|
||||||
|
{
|
||||||
|
if (mMergeTValues[i] != ltvalue[i])
|
||||||
|
ltvalue[i] = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mNumEntered++;
|
||||||
|
|
||||||
|
if (mNumEntered < mNumEntries)
|
||||||
|
{
|
||||||
|
mMergeTValues = ltvalue;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mVisited = true;
|
||||||
|
|
||||||
|
for (int i = 0; i < mInstructions.Size(); i++)
|
||||||
|
{
|
||||||
|
InterInstruction * ins(mInstructions[i]);
|
||||||
|
InterInstruction* lins = nullptr;
|
||||||
|
|
||||||
|
if (ins->mCode == IC_LEA)
|
||||||
|
{
|
||||||
|
if (ins->mSrc[1].mTemp >= 0 && ltvalue[ins->mSrc[1].mTemp])
|
||||||
|
ins->mSrc[1].mLinkerObject = ltvalue[ins->mSrc[1].mTemp]->mSrc[1].mLinkerObject;
|
||||||
|
|
||||||
|
if (ins->mSrc[1].mLinkerObject)
|
||||||
|
lins = ins;
|
||||||
|
}
|
||||||
|
else if (ins->mCode == IC_LOAD)
|
||||||
|
{
|
||||||
|
if (ins->mSrc[0].mTemp >= 0 && ltvalue[ins->mSrc[0].mTemp])
|
||||||
|
ins->mSrc[0].mLinkerObject = ltvalue[ins->mSrc[0].mTemp]->mSrc[1].mLinkerObject;
|
||||||
|
}
|
||||||
|
else if (ins->mCode == IC_STORE)
|
||||||
|
{
|
||||||
|
if (ins->mSrc[1].mTemp >= 0 && ltvalue[ins->mSrc[1].mTemp])
|
||||||
|
ins->mSrc[1].mLinkerObject = ltvalue[ins->mSrc[1].mTemp]->mSrc[1].mLinkerObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lins)
|
||||||
|
ltvalue[lins->mDst.mTemp] = lins;
|
||||||
|
else if (ins->mDst.mTemp >= 0)
|
||||||
|
ltvalue[ins->mDst.mTemp] = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mTrueJump) mTrueJump->LinkerObjectForwarding(ltvalue);
|
||||||
|
if (mFalseJump) mFalseJump->LinkerObjectForwarding(ltvalue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool InterCodeBasicBlock::LoadStoreForwarding(const GrowingInstructionPtrArray& tvalue, const GrowingVariableArray& staticVars)
|
bool InterCodeBasicBlock::LoadStoreForwarding(const GrowingInstructionPtrArray& tvalue, const GrowingVariableArray& staticVars)
|
||||||
{
|
{
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
@ -12620,7 +12659,7 @@ void InterCodeBasicBlock::SingleBlockLoopOptimisation(const NumberSet& aliasedPa
|
||||||
InterInstruction* sins = mInstructions[j];
|
InterInstruction* sins = mInstructions[j];
|
||||||
if (sins->mCode == IC_STORE && CollidingMem(ins, sins))
|
if (sins->mCode == IC_STORE && CollidingMem(ins, sins))
|
||||||
{
|
{
|
||||||
if (sins->mSrc[1].mTemp >= 0)
|
if (sins->mSrc[1].mTemp >= 0 && ins->mSrc[0].mTemp < 0)
|
||||||
{
|
{
|
||||||
if ((ins->mSrc[0].mMemory != IM_PARAM && ins->mSrc[0].mMemory != IM_FPARAM) || aliasedParams[ins->mSrc[0].mVarIndex])
|
if ((ins->mSrc[0].mMemory != IM_PARAM && ins->mSrc[0].mMemory != IM_FPARAM) || aliasedParams[ins->mSrc[0].mVarIndex])
|
||||||
{
|
{
|
||||||
|
@ -12642,7 +12681,7 @@ void InterCodeBasicBlock::SingleBlockLoopOptimisation(const NumberSet& aliasedPa
|
||||||
ins->mInvariant = false;
|
ins->mInvariant = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (CollidingMem(ins, sins))
|
else
|
||||||
{
|
{
|
||||||
ins->mInvariant = false;
|
ins->mInvariant = false;
|
||||||
}
|
}
|
||||||
|
@ -15752,7 +15791,7 @@ void InterCodeProcedure::Close(void)
|
||||||
{
|
{
|
||||||
GrowingTypeArray tstack(IT_NONE);
|
GrowingTypeArray tstack(IT_NONE);
|
||||||
|
|
||||||
CheckFunc = !strcmp(mIdent->mString, "sieve");
|
CheckFunc = !strcmp(mIdent->mString, "strtof");
|
||||||
|
|
||||||
mEntryBlock = mBlocks[0];
|
mEntryBlock = mBlocks[0];
|
||||||
|
|
||||||
|
@ -16038,6 +16077,10 @@ void InterCodeProcedure::Close(void)
|
||||||
|
|
||||||
DisassembleDebug("Estimated value range");
|
DisassembleDebug("Estimated value range");
|
||||||
|
|
||||||
|
GrowingInstructionPtrArray pipa(nullptr);
|
||||||
|
ResetVisited();
|
||||||
|
mEntryBlock->LinkerObjectForwarding(pipa);
|
||||||
|
|
||||||
RebuildIntegerRangeSet();
|
RebuildIntegerRangeSet();
|
||||||
|
|
||||||
ResetVisited();
|
ResetVisited();
|
||||||
|
@ -16391,6 +16434,27 @@ void InterCodeProcedure::Close(void)
|
||||||
|
|
||||||
ResetVisited();
|
ResetVisited();
|
||||||
mEntryBlock->CollectStaticStack(mLinkerObject, mLocalVars);
|
mEntryBlock->CollectStaticStack(mLinkerObject, mLocalVars);
|
||||||
|
|
||||||
|
GrowingInstructionPtrArray pipa(nullptr);
|
||||||
|
ResetVisited();
|
||||||
|
mEntryBlock->LinkerObjectForwarding(pipa);
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
BuildLoopPrefix();
|
||||||
|
DisassembleDebug("added dominators");
|
||||||
|
|
||||||
|
BuildDataFlowSets();
|
||||||
|
|
||||||
|
ResetVisited();
|
||||||
|
mEntryBlock->SingleBlockLoopOptimisation(mParamAliasedSet, mModule->mGlobalVars);
|
||||||
|
|
||||||
|
DisassembleDebug("single block loop opt 3");
|
||||||
|
|
||||||
|
BuildDataFlowSets();
|
||||||
|
|
||||||
|
BuildTraces(false);
|
||||||
|
DisassembleDebug("Rebuilt traces");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -441,6 +441,7 @@ public:
|
||||||
GrowingIntArray mEntryRenameTable;
|
GrowingIntArray mEntryRenameTable;
|
||||||
GrowingIntArray mExitRenameTable;
|
GrowingIntArray mExitRenameTable;
|
||||||
|
|
||||||
|
void LinkerObjectForwarding(const GrowingInstructionPtrArray& tvalue);
|
||||||
bool LoadStoreForwarding(const GrowingInstructionPtrArray& tvalue, const GrowingVariableArray& staticVars);
|
bool LoadStoreForwarding(const GrowingInstructionPtrArray& tvalue, const GrowingVariableArray& staticVars);
|
||||||
|
|
||||||
void LocalRenameRegister(const GrowingIntArray& renameTable, int& num);
|
void LocalRenameRegister(const GrowingIntArray& renameTable, int& num);
|
||||||
|
|
|
@ -12975,6 +12975,8 @@ bool NativeCodeBasicBlock::ReduceLocalYPressure(void)
|
||||||
if (!pblock->mFalseJump && !nblock->mEntryRequiredRegs[CPU_REG_Y])
|
if (!pblock->mFalseJump && !nblock->mEntryRequiredRegs[CPU_REG_Y])
|
||||||
{
|
{
|
||||||
int pz = pblock->mIns.Size();
|
int pz = pblock->mIns.Size();
|
||||||
|
while (pz > 0 && !pblock->mIns[pz - 1].ReferencesYReg() && !pblock->mIns[pz - 1].ReferencesXReg())
|
||||||
|
pz--;
|
||||||
|
|
||||||
if (mEntryRequiredRegs[CPU_REG_Y] && pz > 0 && pblock->mIns[pz - 1].mType == ASMIT_LDY && pblock->mIns[pz - 1].mMode == ASMIM_IMMEDIATE)
|
if (mEntryRequiredRegs[CPU_REG_Y] && pz > 0 && pblock->mIns[pz - 1].mType == ASMIT_LDY && pblock->mIns[pz - 1].mMode == ASMIM_IMMEDIATE)
|
||||||
{
|
{
|
||||||
|
@ -12989,7 +12991,14 @@ bool NativeCodeBasicBlock::ReduceLocalYPressure(void)
|
||||||
mEntryRequiredRegs -= CPU_REG_Y;
|
mEntryRequiredRegs -= CPU_REG_Y;
|
||||||
mExitRequiredRegs -= CPU_REG_Y;
|
mExitRequiredRegs -= CPU_REG_Y;
|
||||||
|
|
||||||
pblock->mIns[pz - 1].mType = ASMIT_LDX;
|
pz--;
|
||||||
|
pblock->mIns[pz].mType = ASMIT_LDX;
|
||||||
|
while (pz < pblock->mIns.Size())
|
||||||
|
{
|
||||||
|
pblock->mIns[pz].mLive |= LIVE_CPU_REG_X;
|
||||||
|
pz++;
|
||||||
|
}
|
||||||
|
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15387,6 +15396,14 @@ bool NativeCodeBasicBlock::CrossBlockStoreLoadBypass(NativeCodeProcedure* proc)
|
||||||
lblock->mIns.Push(mTrueJump->mIns[i]);
|
lblock->mIns.Push(mTrueJump->mIns[i]);
|
||||||
mTrueJump->mIns.SetSize(1);
|
mTrueJump->mIns.SetSize(1);
|
||||||
|
|
||||||
|
mTrueJump->mTrueJump->RemEntryBlock(mTrueJump);
|
||||||
|
mTrueJump->mTrueJump->AddEntryBlock(lblock);
|
||||||
|
if (mTrueJump->mFalseJump)
|
||||||
|
{
|
||||||
|
mTrueJump->mFalseJump->RemEntryBlock(mTrueJump);
|
||||||
|
mTrueJump->mFalseJump->AddEntryBlock(lblock);
|
||||||
|
}
|
||||||
|
|
||||||
lblock->mTrueJump = mTrueJump->mTrueJump;
|
lblock->mTrueJump = mTrueJump->mTrueJump;
|
||||||
lblock->mFalseJump = mTrueJump->mFalseJump;
|
lblock->mFalseJump = mTrueJump->mFalseJump;
|
||||||
lblock->mBranch = mTrueJump->mBranch;
|
lblock->mBranch = mTrueJump->mBranch;
|
||||||
|
@ -15401,8 +15418,7 @@ bool NativeCodeBasicBlock::CrossBlockStoreLoadBypass(NativeCodeProcedure* proc)
|
||||||
|
|
||||||
mTrueJump->mEntryRequiredRegs += CPU_REG_A;
|
mTrueJump->mEntryRequiredRegs += CPU_REG_A;
|
||||||
|
|
||||||
mTrueJump->mEntryBlocks.Remove(mTrueJump->mEntryBlocks.IndexOf(this));
|
mTrueJump->RemEntryBlock(this);
|
||||||
mTrueJump->mNumEntries--;
|
|
||||||
|
|
||||||
mTrueJump->mFalseJump = nullptr;
|
mTrueJump->mFalseJump = nullptr;
|
||||||
mTrueJump->mTrueJump = lblock;
|
mTrueJump->mTrueJump = lblock;
|
||||||
|
@ -17556,22 +17572,23 @@ bool NativeCodeBasicBlock::HasTailSTY(int& addr, int& index) const
|
||||||
|
|
||||||
void NativeCodeBasicBlock::AddEntryBlock(NativeCodeBasicBlock* block)
|
void NativeCodeBasicBlock::AddEntryBlock(NativeCodeBasicBlock* block)
|
||||||
{
|
{
|
||||||
int i = 0;
|
assert(mEntryBlocks.Size() == mNumEntries);
|
||||||
while (i < mEntryBlocks.Size() && mEntryBlocks[i] != block)
|
int i = mEntryBlocks.IndexOf(block);
|
||||||
i++;
|
assert(i < 0);
|
||||||
if (i == mEntryBlocks.Size())
|
|
||||||
mEntryBlocks.Push(block);
|
mEntryBlocks.Push(block);
|
||||||
|
mNumEntries++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeCodeBasicBlock::RemEntryBlock(NativeCodeBasicBlock* block)
|
void NativeCodeBasicBlock::RemEntryBlock(NativeCodeBasicBlock* block)
|
||||||
{
|
{
|
||||||
int i = 0;
|
assert(mEntryBlocks.Size() == mNumEntries);
|
||||||
while (i < mEntryBlocks.Size() && mEntryBlocks[i] != block)
|
int i = mEntryBlocks.IndexOf(block);
|
||||||
i++;
|
assert(i >= 0);
|
||||||
if (i < mEntryBlocks.Size())
|
|
||||||
mEntryBlocks.Remove(i);
|
mEntryBlocks.Remove(i);
|
||||||
|
mNumEntries--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NativeCodeBasicBlock * NativeCodeBasicBlock::SplitMatchingTails(NativeCodeProcedure* proc)
|
NativeCodeBasicBlock * NativeCodeBasicBlock::SplitMatchingTails(NativeCodeProcedure* proc)
|
||||||
{
|
{
|
||||||
NativeCodeBasicBlock* nblock = nullptr;
|
NativeCodeBasicBlock* nblock = nullptr;
|
||||||
|
@ -17874,7 +17891,7 @@ bool NativeCodeBasicBlock::PropagateSinglePath(void)
|
||||||
{
|
{
|
||||||
if (mTrueJump->mEntryRequiredRegs[mIns[i + 1].mAddress] &&
|
if (mTrueJump->mEntryRequiredRegs[mIns[i + 1].mAddress] &&
|
||||||
!mFalseJump->mEntryRequiredRegs[mIns[i + 1].mAddress] &&
|
!mFalseJump->mEntryRequiredRegs[mIns[i + 1].mAddress] &&
|
||||||
mTrueJump->mNumEntries == 1)
|
mTrueJump->mNumEntries == 1 && !mTrueJump->mEntryRequiredRegs[CPU_REG_Z])
|
||||||
{
|
{
|
||||||
for (int j = 0; j < 2; j++)
|
for (int j = 0; j < 2; j++)
|
||||||
{
|
{
|
||||||
|
@ -17887,7 +17904,7 @@ bool NativeCodeBasicBlock::PropagateSinglePath(void)
|
||||||
}
|
}
|
||||||
else if (mFalseJump->mEntryRequiredRegs[mIns[i + 1].mAddress] &&
|
else if (mFalseJump->mEntryRequiredRegs[mIns[i + 1].mAddress] &&
|
||||||
!mTrueJump->mEntryRequiredRegs[mIns[i + 1].mAddress] &&
|
!mTrueJump->mEntryRequiredRegs[mIns[i + 1].mAddress] &&
|
||||||
mFalseJump->mNumEntries == 1)
|
mFalseJump->mNumEntries == 1 && !mFalseJump->mEntryRequiredRegs[CPU_REG_Z])
|
||||||
{
|
{
|
||||||
for (int j = 0; j < 2; j++)
|
for (int j = 0; j < 2; j++)
|
||||||
{
|
{
|
||||||
|
@ -26753,13 +26770,13 @@ bool NativeCodeBasicBlock::BitFieldForwarding(const NativeRegisterDataSet& data)
|
||||||
{
|
{
|
||||||
if (mNDataSet.mRegs[CPU_REG_A].mValue != 0)
|
if (mNDataSet.mRegs[CPU_REG_A].mValue != 0)
|
||||||
{
|
{
|
||||||
mTrueJump->RemoveEntryBlock(this);
|
mTrueJump->RemEntryBlock(this);
|
||||||
mTrueJump = mFalseJump;
|
mTrueJump = mFalseJump;
|
||||||
mFalseJump = nullptr;
|
mFalseJump = nullptr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mFalseJump->RemoveEntryBlock(this);
|
mFalseJump->RemEntryBlock(this);
|
||||||
mFalseJump = nullptr;
|
mFalseJump = nullptr;
|
||||||
}
|
}
|
||||||
mBranch = ASMIT_JMP;
|
mBranch = ASMIT_JMP;
|
||||||
|
@ -26782,13 +26799,13 @@ bool NativeCodeBasicBlock::BitFieldForwarding(const NativeRegisterDataSet& data)
|
||||||
{
|
{
|
||||||
if (mNDataSet.mRegs[CPU_REG_A].mValue == 0)
|
if (mNDataSet.mRegs[CPU_REG_A].mValue == 0)
|
||||||
{
|
{
|
||||||
mTrueJump->RemoveEntryBlock(this);
|
mTrueJump->RemEntryBlock(this);
|
||||||
mTrueJump = mFalseJump;
|
mTrueJump = mFalseJump;
|
||||||
mFalseJump = nullptr;
|
mFalseJump = nullptr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mFalseJump->RemoveEntryBlock(this);
|
mFalseJump->RemEntryBlock(this);
|
||||||
mFalseJump = nullptr;
|
mFalseJump = nullptr;
|
||||||
}
|
}
|
||||||
mBranch = ASMIT_JMP;
|
mBranch = ASMIT_JMP;
|
||||||
|
@ -26811,13 +26828,13 @@ bool NativeCodeBasicBlock::BitFieldForwarding(const NativeRegisterDataSet& data)
|
||||||
{
|
{
|
||||||
if (mNDataSet.mRegs[CPU_REG_A].mValue & 0x80)
|
if (mNDataSet.mRegs[CPU_REG_A].mValue & 0x80)
|
||||||
{
|
{
|
||||||
mTrueJump->RemoveEntryBlock(this);
|
mTrueJump->RemEntryBlock(this);
|
||||||
mTrueJump = mFalseJump;
|
mTrueJump = mFalseJump;
|
||||||
mFalseJump = nullptr;
|
mFalseJump = nullptr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mFalseJump->RemoveEntryBlock(this);
|
mFalseJump->RemEntryBlock(this);
|
||||||
mFalseJump = nullptr;
|
mFalseJump = nullptr;
|
||||||
}
|
}
|
||||||
mBranch = ASMIT_JMP;
|
mBranch = ASMIT_JMP;
|
||||||
|
@ -26844,13 +26861,13 @@ bool NativeCodeBasicBlock::BitFieldForwarding(const NativeRegisterDataSet& data)
|
||||||
{
|
{
|
||||||
if (!(mNDataSet.mRegs[CPU_REG_A].mValue & 0x80))
|
if (!(mNDataSet.mRegs[CPU_REG_A].mValue & 0x80))
|
||||||
{
|
{
|
||||||
mTrueJump->RemoveEntryBlock(this);
|
mTrueJump->RemEntryBlock(this);
|
||||||
mTrueJump = mFalseJump;
|
mTrueJump = mFalseJump;
|
||||||
mFalseJump = nullptr;
|
mFalseJump = nullptr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mFalseJump->RemoveEntryBlock(this);
|
mFalseJump->RemEntryBlock(this);
|
||||||
mFalseJump = nullptr;
|
mFalseJump = nullptr;
|
||||||
}
|
}
|
||||||
mBranch = ASMIT_JMP;
|
mBranch = ASMIT_JMP;
|
||||||
|
@ -29329,6 +29346,7 @@ bool NativeCodeBasicBlock::OptimizeSimpleLoop(NativeCodeProcedure * proc, bool f
|
||||||
{
|
{
|
||||||
mVisited = true;
|
mVisited = true;
|
||||||
|
|
||||||
|
assert(mLocked || mNumEntries == mEntryBlocks.Size());
|
||||||
assert(mIns.Size() == 0 || mIns[0].mType != ASMIT_INV);
|
assert(mIns.Size() == 0 || mIns[0].mType != ASMIT_INV);
|
||||||
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
@ -33977,7 +33995,7 @@ bool NativeCodeBasicBlock::PeepHoleOptimizer(NativeCodeProcedure* proc, int pass
|
||||||
mIns[i + 0].mType == ASMIT_LDA && mIns[i + 0].mMode == ASMIM_ZERO_PAGE && !(mIns[i + 0].mLive & LIVE_MEM) &&
|
mIns[i + 0].mType == ASMIT_LDA && mIns[i + 0].mMode == ASMIM_ZERO_PAGE && !(mIns[i + 0].mLive & LIVE_MEM) &&
|
||||||
mIns[i + 1].IsShift() && mIns[i + 1].mMode == ASMIM_IMPLIED && !(mIns[i + 1].mLive & LIVE_CPU_REG_A))
|
mIns[i + 1].IsShift() && mIns[i + 1].mMode == ASMIM_IMPLIED && !(mIns[i + 1].mLive & LIVE_CPU_REG_A))
|
||||||
{
|
{
|
||||||
mIns[i + 0].mType = mIns[i + 1].mType; mIns[i + 0].mLive |= LIVE_CPU_REG_C;
|
mIns[i + 0].mType = mIns[i + 1].mType; mIns[i + 0].mLive |= LIVE_CPU_REG_C | LIVE_CPU_REG_Z;
|
||||||
mIns[i + 1].mType = ASMIT_NOP; mIns[i + 1].mMode = ASMIM_IMPLIED;
|
mIns[i + 1].mType = ASMIT_NOP; mIns[i + 1].mMode = ASMIM_IMPLIED;
|
||||||
progress = true;
|
progress = true;
|
||||||
}
|
}
|
||||||
|
@ -38516,14 +38534,6 @@ void NativeCodeBasicBlock::Close(const InterInstruction* ins, NativeCodeBasicBlo
|
||||||
this->mBranchIns = ins;
|
this->mBranchIns = ins;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeCodeBasicBlock::RemoveEntryBlock(NativeCodeBasicBlock* block)
|
|
||||||
{
|
|
||||||
int i = mEntryBlocks.IndexOf(block);
|
|
||||||
assert(i >= 0);
|
|
||||||
mEntryBlocks.Remove(i);
|
|
||||||
mNumEntries--;
|
|
||||||
}
|
|
||||||
|
|
||||||
NativeCodeBasicBlock* NativeCodeBasicBlock::BypassEmptyBlocks(void)
|
NativeCodeBasicBlock* NativeCodeBasicBlock::BypassEmptyBlocks(void)
|
||||||
{
|
{
|
||||||
if (mBypassed)
|
if (mBypassed)
|
||||||
|
@ -38852,7 +38862,9 @@ NativeCodeBasicBlock::NativeCodeBasicBlock(void)
|
||||||
mEntryRegY = false;
|
mEntryRegY = false;
|
||||||
mExitRegA = false;
|
mExitRegA = false;
|
||||||
mExitRegX = false;
|
mExitRegX = false;
|
||||||
|
mVisited = false;
|
||||||
|
mLoopHead = false;
|
||||||
|
mNumEntries = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
NativeCodeBasicBlock::~NativeCodeBasicBlock(void)
|
NativeCodeBasicBlock::~NativeCodeBasicBlock(void)
|
||||||
|
@ -39845,6 +39857,8 @@ void NativeCodeProcedure::Optimize(void)
|
||||||
#if 1
|
#if 1
|
||||||
if (step > 0)
|
if (step > 0)
|
||||||
{
|
{
|
||||||
|
RebuildEntry();
|
||||||
|
|
||||||
ResetVisited();
|
ResetVisited();
|
||||||
if (mEntryBlock->OptimizeSimpleLoop(this, step > 5))
|
if (mEntryBlock->OptimizeSimpleLoop(this, step > 5))
|
||||||
changed = true;
|
changed = true;
|
||||||
|
@ -40233,6 +40247,8 @@ void NativeCodeProcedure::Optimize(void)
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
RebuildEntry();
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
if (step == 2 && !changed)
|
if (step == 2 && !changed)
|
||||||
{
|
{
|
||||||
|
|
|
@ -226,7 +226,6 @@ public:
|
||||||
int BranchByteSize(NativeCodeBasicBlock* target, int from, int to);
|
int BranchByteSize(NativeCodeBasicBlock* target, int from, int to);
|
||||||
|
|
||||||
NativeCodeBasicBlock* BypassEmptyBlocks(void);
|
NativeCodeBasicBlock* BypassEmptyBlocks(void);
|
||||||
void RemoveEntryBlock(NativeCodeBasicBlock* block);
|
|
||||||
|
|
||||||
int LeadsInto(NativeCodeBasicBlock* block, int dist);
|
int LeadsInto(NativeCodeBasicBlock* block, int dist);
|
||||||
void BuildPlacement(ExpandingArray<NativeCodeBasicBlock*>& placement);
|
void BuildPlacement(ExpandingArray<NativeCodeBasicBlock*>& placement);
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "NumberSet.h"
|
#include "NumberSet.h"
|
||||||
|
|
||||||
|
#define VALGRIND 0
|
||||||
|
|
||||||
NumberSet::NumberSet(void)
|
NumberSet::NumberSet(void)
|
||||||
{
|
{
|
||||||
size = 0;
|
size = 0;
|
||||||
|
@ -174,6 +176,10 @@ FastNumberSet::FastNumberSet(int size, bool set)
|
||||||
{
|
{
|
||||||
this->size = this->asize = size;
|
this->size = this->asize = size;
|
||||||
buffer = new uint32[2 * size];
|
buffer = new uint32[2 * size];
|
||||||
|
#if VALGRIND
|
||||||
|
for (int i = 0; i < 2 * size; i++)
|
||||||
|
buffer[i] = 0;
|
||||||
|
#endif
|
||||||
if (set)
|
if (set)
|
||||||
{
|
{
|
||||||
for (num = 0; num < size; num++)
|
for (num = 0; num < size; num++)
|
||||||
|
@ -193,6 +199,11 @@ FastNumberSet::FastNumberSet(const FastNumberSet& set)
|
||||||
this->size = this->asize = set.size;
|
this->size = this->asize = set.size;
|
||||||
this->num = set.num;
|
this->num = set.num;
|
||||||
buffer = new uint32[2 * size];
|
buffer = new uint32[2 * size];
|
||||||
|
#if VALGRIND
|
||||||
|
for (int i = 0; i < 2 * size; i++)
|
||||||
|
buffer[i] = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
for (i = 0; i < num; i++)
|
for (i = 0; i < num; i++)
|
||||||
{
|
{
|
||||||
buffer[i] = set.buffer[i];
|
buffer[i] = set.buffer[i];
|
||||||
|
@ -206,6 +217,10 @@ void FastNumberSet::Reset(int size, bool set)
|
||||||
{
|
{
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
buffer = new uint32[2 * size];
|
buffer = new uint32[2 * size];
|
||||||
|
#if VALGRIND
|
||||||
|
for (int i = 0; i < 2 * size; i++)
|
||||||
|
buffer[i] = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
this->asize = size;
|
this->asize = size;
|
||||||
}
|
}
|
||||||
|
|
|
@ -308,6 +308,7 @@ Scanner::Scanner(Errors* errors, Preprocessor* preprocessor)
|
||||||
|
|
||||||
mDefines = new MacroDict();
|
mDefines = new MacroDict();
|
||||||
mDefineArguments = nullptr;
|
mDefineArguments = nullptr;
|
||||||
|
mToken = TK_NONE;
|
||||||
|
|
||||||
NextChar();
|
NextChar();
|
||||||
NextToken();
|
NextToken();
|
||||||
|
|
Loading…
Reference in New Issue