Fix pointer register loss while forwarding index
This commit is contained in:
parent
1a06102668
commit
425aae8f72
|
@ -717,6 +717,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
|||
return ExValue(TheVoidTypeDeclaration);
|
||||
|
||||
case EX_SEQUENCE:
|
||||
case EX_LIST:
|
||||
vr = TranslateExpression(procType, proc, block, exp->mLeft, breakBlock, continueBlock, inlineMapper);
|
||||
exp = exp->mRight;
|
||||
if (!exp)
|
||||
|
@ -1732,9 +1733,11 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
|||
ins->mOperator = IA_NOT;
|
||||
break;
|
||||
case TK_MUL:
|
||||
if (vl.mType->mType != DT_TYPE_POINTER)
|
||||
if (vl.mType->mType == DT_TYPE_ARRAY)
|
||||
vl = Dereference(proc, exp, block, vl, 1);
|
||||
else if (vl.mType->mType != DT_TYPE_POINTER)
|
||||
mErrors->Error(exp->mLocation, EERR_INCOMPATIBLE_OPERATOR, "Not a pointer type");
|
||||
if (vl.mType->mStride != 1)
|
||||
else if (vl.mType->mStride != 1)
|
||||
vl = Dereference(proc, exp, block, vl, 0);
|
||||
return ExValue(vl.mType->mBase, vl.mTemp, vl.mReference + 1);
|
||||
case TK_BINARY_AND:
|
||||
|
@ -2402,6 +2405,8 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
|||
{
|
||||
if (vr.mType->mType == DT_TYPE_ARRAY || vr.mType->mType == DT_TYPE_FUNCTION)
|
||||
vr = Dereference(proc, texp, block, vr, 1);
|
||||
else if (pdec && pdec->mBase->mType == DT_TYPE_POINTER && vr.mType->mType == DT_TYPE_INTEGER && texp->mDecValue->mType == DT_CONST_INTEGER && texp->mDecValue->mInteger == 0)
|
||||
vr = CoerceType(proc, texp, block, vr, pdec->mBase);
|
||||
else
|
||||
vr = Dereference(proc, texp, block, vr);
|
||||
|
||||
|
|
|
@ -15952,7 +15952,6 @@ bool NativeCodeBasicBlock::JoinTailCodeSequences(NativeCodeProcedure* proc, bool
|
|||
{
|
||||
for (int i = 0; i < mEntryBlocks.Size(); i++)
|
||||
mEntryBlocks[i]->ChangeTailZPStoreToX(mIns[0].mAddress);
|
||||
mEntryProvidedRegs += CPU_REG_X;
|
||||
mEntryRequiredRegs += CPU_REG_X;
|
||||
mIns[0].mType = ASMIT_TXA;
|
||||
mIns[0].mMode = ASMIM_IMPLIED;
|
||||
|
@ -15970,7 +15969,6 @@ bool NativeCodeBasicBlock::JoinTailCodeSequences(NativeCodeProcedure* proc, bool
|
|||
{
|
||||
for (int i = 0; i < mEntryBlocks.Size(); i++)
|
||||
mEntryBlocks[i]->ChangeTailZPStoreToY(mIns[0].mAddress);
|
||||
mEntryProvidedRegs += CPU_REG_Y;
|
||||
mEntryRequiredRegs += CPU_REG_Y;
|
||||
mIns[0].mType = ASMIT_TYA;
|
||||
mIns[0].mMode = ASMIM_IMPLIED;
|
||||
|
@ -16939,7 +16937,11 @@ bool NativeCodeBasicBlock::PatchSingleUseGlobalLoad(const NativeCodeBasicBlock*
|
|||
{
|
||||
ins.CopyMode(ains);
|
||||
if (!(ins.mLive & LIVE_MEM))
|
||||
{
|
||||
if (ains.mMode == ASMIM_INDIRECT_Y)
|
||||
ins.mLive |= LIVE_MEM;
|
||||
return true;
|
||||
}
|
||||
changed = true;
|
||||
}
|
||||
else
|
||||
|
@ -16950,6 +16952,8 @@ bool NativeCodeBasicBlock::PatchSingleUseGlobalLoad(const NativeCodeBasicBlock*
|
|||
ins.mLive |= LIVE_CPU_REG_X;
|
||||
if (ains.mMode == ASMIM_ABSOLUTE_Y || ains.mMode == ASMIM_INDIRECT_Y)
|
||||
ins.mLive |= LIVE_CPU_REG_Y;
|
||||
if (ains.mMode == ASMIM_INDIRECT_Y)
|
||||
ins.mLive |= LIVE_MEM;
|
||||
|
||||
at++;
|
||||
}
|
||||
|
@ -31952,6 +31956,7 @@ void NativeCodeProcedure::Optimize(void)
|
|||
mEntryBlock->CheckBlocks();
|
||||
#endif
|
||||
|
||||
|
||||
#if 1
|
||||
ResetVisited();
|
||||
if (mEntryBlock->PeepHoleOptimizer(this, step))
|
||||
|
@ -32345,8 +32350,6 @@ void NativeCodeProcedure::Optimize(void)
|
|||
else
|
||||
cnt++;
|
||||
|
||||
|
||||
|
||||
} while (changed);
|
||||
|
||||
#if 1
|
||||
|
|
|
@ -966,6 +966,18 @@ Expression* Parser::ParseInitExpression(Declaration* dtype)
|
|||
nexp->mDecValue = ndec;
|
||||
exp = nexp;
|
||||
}
|
||||
else if (exp->mDecValue->mType == DT_CONST_INTEGER && exp->mDecValue->mInteger == 0)
|
||||
{
|
||||
Declaration * ndec = new Declaration(exp->mDecValue->mLocation, DT_CONST_ADDRESS);
|
||||
ndec->mBase = TheVoidPointerTypeDeclaration;
|
||||
ndec->mInteger = 0;
|
||||
dec = ndec;
|
||||
|
||||
Expression* nexp = new Expression(mScanner->mLocation, EX_CONSTANT);
|
||||
nexp->mDecValue = ndec;
|
||||
nexp->mDecType = ndec->mBase;
|
||||
exp = nexp;
|
||||
}
|
||||
else
|
||||
mErrors->Error(mScanner->mLocation, EERR_CONSTANT_INITIALIZER, "Illegal pointer constant initializer");
|
||||
|
||||
|
@ -2433,7 +2445,7 @@ Expression* Parser::ParseStatement(void)
|
|||
break;
|
||||
|
||||
default:
|
||||
exp = ParseExpression();
|
||||
exp = ParseListExpression();
|
||||
ConsumeToken(TK_SEMICOLON);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue