Optimize bytecode generator
This commit is contained in:
parent
6007553d03
commit
12aa385e38
|
@ -41,6 +41,8 @@ char * strcpy(char * dst, const char * src)
|
|||
}
|
||||
#endif
|
||||
|
||||
#pragma native(strcpy)
|
||||
|
||||
#if 1
|
||||
|
||||
int strcmp(const char * ptr1, const char * ptr2)
|
||||
|
@ -97,6 +99,7 @@ int strcmp(const char * ptr1, const char * ptr2)
|
|||
}
|
||||
#endif
|
||||
|
||||
#pragma native(strcmp)
|
||||
|
||||
int strlen(const char * str)
|
||||
{
|
||||
|
@ -212,6 +215,8 @@ void * memcpy(void * dst, const void * src, int size)
|
|||
#endif
|
||||
}
|
||||
|
||||
#pragma native(memcpy)
|
||||
|
||||
void * memmove(void * dst, const void * src, int size)
|
||||
{
|
||||
char * d = dst, * s = src;
|
||||
|
|
|
@ -4952,6 +4952,20 @@ bool ByteCodeBasicBlock::PeepHoleOptimizer(int phase)
|
|||
mBranch = TransposeBranchCondition(mBranch);
|
||||
progress = true;
|
||||
}
|
||||
else if (
|
||||
i + 3 == mIns.Size() && mFalseJump &&
|
||||
mIns[i + 0].mCode == BC_STORE_REG_16 &&
|
||||
mIns[i + 1].mCode == BC_LOAD_REG_16 &&
|
||||
mIns[i + 2].mCode == BC_BINOP_CMPUR_16 && mIns[i + 0].mRegister == mIns[i + 2].mRegister && !(mExitLive & LIVE_ACCU) && mIns[i + 2].mRegisterFinal
|
||||
)
|
||||
{
|
||||
mIns[i + 0].mCode = BC_NOP;
|
||||
mIns[i + 1].mCode = BC_NOP;
|
||||
mIns[i + 2].mRegister = mIns[i + 1].mRegister;
|
||||
mIns[i + 2].mRegisterFinal = mIns[i + 1].mRegisterFinal;
|
||||
mBranch = TransposeBranchCondition(mBranch);
|
||||
progress = true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -5187,6 +5201,16 @@ bool ByteCodeBasicBlock::PeepHoleOptimizer(int phase)
|
|||
mIns[i + 1].mCode = BC_NOP;
|
||||
progress = true;
|
||||
}
|
||||
else if (
|
||||
mIns[i + 0].mCode == BC_LOAD_REG_8 && !(mIns[i + 1].mLive & LIVE_ACCU) &&
|
||||
(mIns[i + 1].mCode == BC_STORE_ABS_8 || mIns[i + 1].mCode == BC_STORE_LOCAL_8 || mIns[i + 1].mCode == BC_STORE_ADDR_8 || mIns[i + 1].mCode == BC_STORE_FRAME_8) &&
|
||||
mIns[i + 1].mRegister == BC_REG_ACCU)
|
||||
{
|
||||
mIns[i + 0].mCode = BC_NOP;
|
||||
mIns[i + 1].mRegister = mIns[i + 0].mRegister;
|
||||
mIns[i + 1].mRegisterFinal = mIns[i + 0].mRegisterFinal;
|
||||
progress = true;
|
||||
}
|
||||
|
||||
#if 1
|
||||
else if (
|
||||
|
@ -5603,6 +5627,22 @@ void ByteCodeBasicBlock::CalculateOffset(int& total)
|
|||
mTrueJump->CalculateOffset(total);
|
||||
}
|
||||
}
|
||||
#if 1
|
||||
else if (!mTrueJump->mFalseJump && !mFalseJump->mFalseJump && mTrueJump->mTrueJump == mFalseJump->mTrueJump &&
|
||||
mTrueJump->mCode.Size() < 120 && mFalseJump->mCode.Size() < 120 && mTrueJump->mTrueJump->mOffset > mOffset)
|
||||
{
|
||||
// Small diamond so place true then false directly behind each other
|
||||
// with short branches
|
||||
|
||||
mSize = mCode.Size() + 2;
|
||||
|
||||
mFalseJump->mOffset = next + 2;
|
||||
mFalseJump->mSize = mFalseJump->mCode.Size() + 2;
|
||||
|
||||
total = mFalseJump->mOffset + mFalseJump->mSize;
|
||||
mTrueJump->CalculateOffset(total);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
// neither falseJump nor trueJump have been placed
|
||||
|
|
|
@ -119,7 +119,7 @@ void GlobalAnalyzer::AutoInline(void)
|
|||
for (int i = 0; i < mFunctions.Size(); i++)
|
||||
{
|
||||
Declaration* f = mFunctions[i];
|
||||
if (!(f->mFlags & DTF_INLINE) && !(f->mBase->mFlags & DTF_VARIADIC) && !(f->mFlags & DTF_FUNC_VARIABLE) && !(f->mFlags & DTF_INTRINSIC) && f->mCalled.Size() == 0)
|
||||
if (!(f->mFlags & DTF_INLINE) && !(f->mBase->mFlags & DTF_VARIADIC) && !(f->mFlags & DTF_FUNC_VARIABLE) && f->mCalled.Size() == 0)
|
||||
{
|
||||
int nparams = 0;
|
||||
Declaration* dec = f->mBase->mParams;
|
||||
|
|
Loading…
Reference in New Issue