Fix array to pointer cast
This commit is contained in:
parent
d8ecd34ac6
commit
480270f4c9
|
@ -1851,6 +1851,7 @@ InterCodeBasicBlock::InterCodeBasicBlock(void)
|
||||||
mInPath = false;
|
mInPath = false;
|
||||||
mLoopHead = false;
|
mLoopHead = false;
|
||||||
mChecked = false;
|
mChecked = false;
|
||||||
|
mTraceIndex = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
InterCodeBasicBlock::~InterCodeBasicBlock(void)
|
InterCodeBasicBlock::~InterCodeBasicBlock(void)
|
||||||
|
@ -1924,15 +1925,17 @@ void InterCodeBasicBlock::GenerateTraces(bool expand)
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
if (mTrueJump && mTrueJump->mInstructions.Size() == 1 && mTrueJump->mInstructions[0]->mCode == IC_JUMP && !mTrueJump->mLoopHead)
|
if (mTrueJump && mTrueJump->mInstructions.Size() == 1 && mTrueJump->mInstructions[0]->mCode == IC_JUMP && !mTrueJump->mLoopHead && mTrueJump->mTraceIndex != mIndex)
|
||||||
{
|
{
|
||||||
|
mTrueJump->mTraceIndex = mIndex;
|
||||||
mTrueJump->mNumEntries--;
|
mTrueJump->mNumEntries--;
|
||||||
mTrueJump = mTrueJump->mTrueJump;
|
mTrueJump = mTrueJump->mTrueJump;
|
||||||
if (mTrueJump)
|
if (mTrueJump)
|
||||||
mTrueJump->mNumEntries++;
|
mTrueJump->mNumEntries++;
|
||||||
}
|
}
|
||||||
else if (mFalseJump && mFalseJump->mInstructions.Size() == 1 && mFalseJump->mInstructions[0]->mCode == IC_JUMP && !mFalseJump->mLoopHead)
|
else if (mFalseJump && mFalseJump->mInstructions.Size() == 1 && mFalseJump->mInstructions[0]->mCode == IC_JUMP && !mFalseJump->mLoopHead && mFalseJump->mTraceIndex != mIndex)
|
||||||
{
|
{
|
||||||
|
mFalseJump->mTraceIndex = mIndex;
|
||||||
mFalseJump->mNumEntries--;
|
mFalseJump->mNumEntries--;
|
||||||
mFalseJump = mFalseJump->mTrueJump;
|
mFalseJump = mFalseJump->mTrueJump;
|
||||||
if (mFalseJump)
|
if (mFalseJump)
|
||||||
|
|
|
@ -404,7 +404,7 @@ public:
|
||||||
class InterCodeBasicBlock
|
class InterCodeBasicBlock
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int mIndex, mNumEntries, mNumEntered;
|
int mIndex, mNumEntries, mNumEntered, mTraceIndex;
|
||||||
InterCodeBasicBlock * mTrueJump, * mFalseJump, * mDominator;
|
InterCodeBasicBlock * mTrueJump, * mFalseJump, * mDominator;
|
||||||
GrowingInstructionArray mInstructions;
|
GrowingInstructionArray mInstructions;
|
||||||
|
|
||||||
|
|
|
@ -2706,6 +2706,11 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
// no need for actual operation when casting pointer to pointer
|
// no need for actual operation when casting pointer to pointer
|
||||||
return ExValue(exp->mLeft->mDecType, vr.mTemp, vr.mReference);
|
return ExValue(exp->mLeft->mDecType, vr.mTemp, vr.mReference);
|
||||||
}
|
}
|
||||||
|
else if (exp->mLeft->mDecType->mType == DT_TYPE_POINTER && vr.mType->mType == DT_TYPE_ARRAY)
|
||||||
|
{
|
||||||
|
// no need for actual operation when casting pointer to pointer
|
||||||
|
return ExValue(exp->mLeft->mDecType, vr.mTemp, vr.mReference - 1);
|
||||||
|
}
|
||||||
else if (exp->mLeft->mDecType->mType != DT_TYPE_VOID && vr.mType->mType == DT_TYPE_VOID)
|
else if (exp->mLeft->mDecType->mType != DT_TYPE_VOID && vr.mType->mType == DT_TYPE_VOID)
|
||||||
{
|
{
|
||||||
mErrors->Error(exp->mLocation, EERR_INCOMPATIBLE_OPERATOR, "Cannot cast void object to non void object");
|
mErrors->Error(exp->mLocation, EERR_INCOMPATIBLE_OPERATOR, "Cannot cast void object to non void object");
|
||||||
|
|
|
@ -7956,9 +7956,9 @@ bool NativeCodeBasicBlock::PeepHoleOptimizer(void)
|
||||||
int apos, breg, ireg;
|
int apos, breg, ireg;
|
||||||
if (FindAddressSumY(i, sreg, apos, breg, ireg))
|
if (FindAddressSumY(i, sreg, apos, breg, ireg))
|
||||||
{
|
{
|
||||||
if (breg != mIns[i + 0].mAddress || !(mIns[i + 0].mLive & LIVE_MEM))
|
if (!(breg == sreg || ireg == sreg)|| !(mIns[i + 0].mLive & LIVE_MEM))
|
||||||
{
|
{
|
||||||
if (breg == mIns[i + 0].mAddress)
|
if (breg == sreg || ireg == sreg)
|
||||||
{
|
{
|
||||||
mIns[apos + 3].mType = ASMIT_NOP;
|
mIns[apos + 3].mType = ASMIT_NOP;
|
||||||
mIns[apos + 3].mMode = ASMIM_IMPLIED;
|
mIns[apos + 3].mMode = ASMIM_IMPLIED;
|
||||||
|
|
Loading…
Reference in New Issue