Fix 16bit const add propagation

This commit is contained in:
drmortalwombat 2025-05-05 11:17:00 +02:00
parent 064fed63f5
commit fccfe35c4f
2 changed files with 17 additions and 6 deletions

View File

@ -2910,7 +2910,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
ptype->mSize = 2;
ptype->mStride = vl.mType->mStride;
vl.mReference = 0;
vl.mType = exp->mDecType; // ptype;
vl.mType = ptype;
}
if (vr.mType->mType == DT_TYPE_POINTER)
@ -2972,7 +2972,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
ins->mDst.mTemp = proc->AddTemporary(ins->mDst.mType);
block->Append(ins);
}
else if (vr.mType->mType == DT_TYPE_POINTER && vr.mType->mBase->IsConstSame(vl.mType->mBase))
else if ((vr.mType->mType == DT_TYPE_POINTER || vr.mType->mType == DT_TYPE_ARRAY) && (vl.mType->mType == DT_TYPE_POINTER || vl.mType->mType == DT_TYPE_ARRAY) && vr.mType->mBase->IsConstSame(vl.mType->mBase))
{
if (exp->mToken == TK_SUB)
{
@ -3035,6 +3035,8 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
}
else
mErrors->Error(exp->mLocation, EERR_INCOMPATIBLE_OPERATOR, "Invalid pointer operation");
vl.mType = exp->mDecType;
}
else if (vr.mType->mType == DT_TYPE_POINTER || vr.mType->mType == DT_TYPE_ARRAY)
{

View File

@ -34496,7 +34496,10 @@ bool NativeCodeBasicBlock::Propagate16BitSum(const ExpandingArray<NativeRegister
if (!info.mLinkerObject && !mRSumInfos[j].mLinkerObject)
{
info.mAddress += mRSumInfos[j].mAddress;
if (info.mSrcL->mType == ASMIT_LDA)
info.mAddL->mType = ASMIT_ADC;
else
info.mSrcL->mType = ASMIT_ADC;
info.mAddL->mAddress = info.mAddress & 0xff;
info.mAddH->mAddress = info.mAddress >> 8;
info.mSrcL->mAddress = mRSumInfos[j].mSrcL->mAddress;
@ -34507,7 +34510,10 @@ bool NativeCodeBasicBlock::Propagate16BitSum(const ExpandingArray<NativeRegister
else if (!mRSumInfos[j].mLinkerObject)
{
info.mAddress += mRSumInfos[j].mAddress;
if (info.mSrcL->mType == ASMIT_LDA)
info.mAddL->mType = ASMIT_ADC;
else
info.mSrcL->mType = ASMIT_ADC;
info.mAddL->mAddress = info.mAddress;
info.mAddH->mAddress = info.mAddress;
info.mSrcL->mAddress = mRSumInfos[j].mSrcL->mAddress;
@ -34519,7 +34525,10 @@ bool NativeCodeBasicBlock::Propagate16BitSum(const ExpandingArray<NativeRegister
{
info.mAddress += mRSumInfos[j].mAddress;
info.mLinkerObject = mRSumInfos[j].mLinkerObject;
if (info.mSrcL->mType == ASMIT_LDA)
info.mAddL->mType = ASMIT_ADC;
else
info.mSrcL->mType = ASMIT_ADC;
info.mAddL->mAddress = info.mAddress;
info.mAddL->mLinkerObject = info.mLinkerObject;
info.mAddL->mMode = ASMIM_IMMEDIATE_ADDRESS;
@ -54464,7 +54473,7 @@ void NativeCodeProcedure::Compile(InterCodeProcedure* proc)
mInterProc->mLinkerObject->mNativeProc = this;
CheckFunc = !strcmp(mIdent->mString, "midc<u8>");
CheckFunc = !strcmp(mIdent->mString, "main");
int nblocks = proc->mBlocks.Size();
tblocks = new NativeCodeBasicBlock * [nblocks];