From 067e1698031e0d379efea300cb46c9c25d9f89c2 Mon Sep 17 00:00:00 2001 From: drmortalwombat <90205530+drmortalwombat@users.noreply.github.com> Date: Fri, 6 Dec 2024 18:54:55 +0100 Subject: [PATCH] Fix analysis of register usage of inline assembler --- oscar64/InterCodeGenerator.cpp | 2 ++ oscar64/NativeCodeGenerator.cpp | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/oscar64/InterCodeGenerator.cpp b/oscar64/InterCodeGenerator.cpp index 83ec6a0..df25b6c 100644 --- a/oscar64/InterCodeGenerator.cpp +++ b/oscar64/InterCodeGenerator.cpp @@ -434,6 +434,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::CoerceType(InterCodeProcedure* p v.mTemp = cins->mDst.mTemp; v.mType = type; } +#if 1 else if (type->mType == DT_TYPE_BOOL && v.mType->IsIntegerType() && v.mType->mType != DT_TYPE_BOOL) { InterInstruction* zins = new InterInstruction(MapLocation(exp, inlineMapper), IC_CONSTANT); @@ -455,6 +456,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::CoerceType(InterCodeProcedure* p v.mTemp = cins->mDst.mTemp; v.mType = type; } +#endif else if (v.mType->mSize < type->mSize) { if (v.mType->mSize == 1 && type->mSize == 2) diff --git a/oscar64/NativeCodeGenerator.cpp b/oscar64/NativeCodeGenerator.cpp index 170e096..99ab5d3 100644 --- a/oscar64/NativeCodeGenerator.cpp +++ b/oscar64/NativeCodeGenerator.cpp @@ -1291,6 +1291,14 @@ void NativeCodeInstruction::BuildCollisionTable(NumberSet& liveTemps, NumberSet* for (int i = BC_REG_TMP; i < BC_REG_TMP + mLinkerObject->mProc->mCallerSavedTemps; i++) UpdateCollisionSet(liveTemps, collisionSets, i); } + else if (mLinkerObject && mLinkerObject->mNumTemporaries) + { + for (int i = 0; i < mLinkerObject->mNumTemporaries; i++) + { + for (int j = 0; j < mLinkerObject->mTempSizes[i]; j++) + UpdateCollisionSet(liveTemps, collisionSets, mLinkerObject->mTemporaries[i] + j); + } + } else { for (int i = BC_REG_TMP; i < BC_REG_TMP_SAVED; i++) @@ -1409,6 +1417,8 @@ bool NativeCodeInstruction::ChangesZeroPage(int address) const return mType == ASMIT_INC || mType == ASMIT_DEC || mType == ASMIT_ASL || mType == ASMIT_LSR || mType == ASMIT_ROL || mType == ASMIT_ROR || mType == ASMIT_STA || mType == ASMIT_STX || mType == ASMIT_STY; else if (mType == ASMIT_JSR) { + if (address == BC_REG_WORK_Y) + return true; if (address >= BC_REG_ACCU && address < BC_REG_ACCU + 4) return true; if (address >= BC_REG_WORK && address < BC_REG_WORK + 8) @@ -51801,7 +51811,7 @@ void NativeCodeProcedure::Compile(InterCodeProcedure* proc) mInterProc = proc; mInterProc->mLinkerObject->mNativeProc = this; - CheckFunc = !strcmp(mInterProc->mIdent->mString, "diggers_vacate_room"); + CheckFunc = !strcmp(mInterProc->mIdent->mString, "bmmcu_line"); int nblocks = proc->mBlocks.Size(); tblocks = new NativeCodeBasicBlock * [nblocks]; @@ -53636,6 +53646,7 @@ void NativeCodeProcedure::Optimize(void) ResetVisited(); mEntryBlock->CombineAlternateLoads(); #endif + #if 1 ResetVisited(); mEntryBlock->ReduceLocalYPressure(); @@ -53650,6 +53661,7 @@ void NativeCodeProcedure::Optimize(void) CompressTemporaries(true); #endif + do { ResetVisited(); NativeRegisterDataSet data;