Improve reordering of function arguments
This commit is contained in:
parent
bb8c31bf32
commit
9b47a34840
|
@ -898,7 +898,17 @@ bool InterCodeBasicBlock::CanSwapInstructions(const InterInstruction* ins0, cons
|
|||
ins1->mCode == IC_PUSH_FRAME || ins1->mCode == IC_POP_FRAME || ins1->mCode == IC_MALLOC || ins1->mCode == IC_FREE)
|
||||
return false;
|
||||
|
||||
if (ins1->mCode == IC_LOAD || ins1->mCode == IC_STORE || ins1->mCode == IC_COPY || ins1->mCode == IC_STRCPY || ins1->mCode == IC_FILL)
|
||||
if (ins0->mSrc[0].mMemory == IM_PROCEDURE && ins0->mSrc[0].mLinkerObject && ins0->mSrc[0].mLinkerObject->mProc && ins0->mSrc[0].mLinkerObject->mProc->mParamVars.Size() == 0)
|
||||
{
|
||||
if (ins1->mCode == IC_STORE)
|
||||
{
|
||||
if (ins1->mSrc[1].mMemory != IM_FRAME && ins1->mSrc[1].mMemory != IM_FFRAME)
|
||||
return false;
|
||||
}
|
||||
else if (ins1->mCode == IC_LOAD || ins1->mCode == IC_STORE || ins1->mCode == IC_COPY || ins1->mCode == IC_STRCPY || ins1->mCode == IC_FILL)
|
||||
return false;
|
||||
}
|
||||
else if (ins1->mCode == IC_LOAD || ins1->mCode == IC_STORE || ins1->mCode == IC_COPY || ins1->mCode == IC_STRCPY || ins1->mCode == IC_FILL)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -656,7 +656,7 @@ public:
|
|||
InterCodeModule * mModule;
|
||||
int mID;
|
||||
|
||||
int mLocalSize, mNumLocals;
|
||||
int mLocalSize, mNumLocals, mNumParams;
|
||||
GrowingVariableArray mLocalVars, mParamVars;
|
||||
NumberSet mLocalAliasedSet, mParamAliasedSet;
|
||||
|
||||
|
|
|
@ -5428,6 +5428,7 @@ InterCodeProcedure* InterCodeGenerator::TranslateProcedure(InterCodeModule * mod
|
|||
dec->mVarIndex = proc->mID;
|
||||
dec->mLinkerObject = proc->mLinkerObject;
|
||||
proc->mNumLocals = dec->mNumVars;
|
||||
proc->mNumParams = dec->mBase->mSize;
|
||||
proc->mDeclaration = dec;
|
||||
|
||||
if (dec->mFlags & DTF_NATIVE)
|
||||
|
|
|
@ -10439,7 +10439,39 @@ NativeCodeBasicBlock* NativeCodeBasicBlock::BinaryOperator(InterCodeProcedure* p
|
|||
}
|
||||
else if (ins->mSrc[1].mTemp < 0)
|
||||
{
|
||||
if (sins0)
|
||||
if ((ins->mSrc[1].mIntConst & (ins->mSrc[1].mIntConst + 1)) == 0 && ins->mSrc[0].IsUnsigned() && ins->mSrc[0].mRange.mMaxValue <= ins->mSrc[1].mIntConst)
|
||||
{
|
||||
NativeCodeInstruction insl = NativeCodeInstruction(ins, ASMIT_EOR, ASMIM_IMMEDIATE, ins->mSrc[1].mIntConst & 0xff);
|
||||
NativeCodeInstruction insh = NativeCodeInstruction(ins, ASMIT_EOR, ASMIM_IMMEDIATE, (ins->mSrc[1].mIntConst >> 8) & 0xff);
|
||||
if (sins0)
|
||||
{
|
||||
if (ins->mDst.IsUByte())
|
||||
insh = NativeCodeInstruction(ins, ASMIT_LDA, ASMIM_IMMEDIATE, 0);
|
||||
|
||||
LoadValueToReg(proc, sins0, treg, &insl, &insh);
|
||||
}
|
||||
else
|
||||
{
|
||||
mIns.Push(NativeCodeInstruction(ins, ASMIT_LDA, ASMIM_ZERO_PAGE, BC_REG_TMP + proc->mTempOffset[ins->mSrc[0].mTemp]));
|
||||
mIns.Push(insl);
|
||||
mIns.Push(NativeCodeInstruction(ins, ASMIT_STA, ASMIM_ZERO_PAGE, treg));
|
||||
if (InterTypeSize[ins->mDst.mType] > 1)
|
||||
{
|
||||
if (ins->mDst.IsUByte())
|
||||
{
|
||||
mIns.Push(NativeCodeInstruction(ins, ASMIT_LDA, ASMIM_IMMEDIATE, 0));
|
||||
mIns.Push(NativeCodeInstruction(ins, ASMIT_STA, ASMIM_ZERO_PAGE, treg + 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
mIns.Push(NativeCodeInstruction(ins, ASMIT_LDA, ASMIM_ZERO_PAGE, BC_REG_TMP + proc->mTempOffset[ins->mSrc[0].mTemp] + 1));
|
||||
mIns.Push(insh);
|
||||
mIns.Push(NativeCodeInstruction(ins, ASMIT_STA, ASMIM_ZERO_PAGE, treg + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (sins0)
|
||||
{
|
||||
LoadValueToReg(proc, sins0, treg, nullptr, nullptr);
|
||||
|
||||
|
@ -31502,6 +31534,9 @@ bool NativeCodeBasicBlock::MoveLoadAddImmStoreUp(int at)
|
|||
{
|
||||
if (mIns[j].mType == ASMIT_STA && mIns[j].mMode == ASMIM_ZERO_PAGE && mIns[j].mAddress == mIns[at + 1].mAddress)
|
||||
{
|
||||
while (j + 1 < mIns.Size() && mIns[j + 1].mType == ASMIT_STA)
|
||||
j++;
|
||||
|
||||
if (mIns[j].mLive & (LIVE_CPU_REG_A | LIVE_CPU_REG_C))
|
||||
return false;
|
||||
|
||||
|
|
Loading…
Reference in New Issue