From 0184a550c5a2ef30b2cb623b138cec8fa4a5f59f Mon Sep 17 00:00:00 2001 From: drmortalwombat <90205530+drmortalwombat@users.noreply.github.com> Date: Wed, 10 Apr 2024 15:15:22 +0200 Subject: [PATCH] Fix volatile violation when recycling immediates --- oscar64/NativeCodeGenerator.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/oscar64/NativeCodeGenerator.cpp b/oscar64/NativeCodeGenerator.cpp index 63a15ed..067c559 100644 --- a/oscar64/NativeCodeGenerator.cpp +++ b/oscar64/NativeCodeGenerator.cpp @@ -16708,6 +16708,7 @@ bool NativeCodeBasicBlock::MoveImmediateStoreUp(int at) { bool usex = mIns[at + 1].mMode == ASMIM_ABSOLUTE_X || mIns[at + 1].mMode == ASMIM_INDIRECT_X || mIns[at + 1].mMode == ASMIM_ZERO_PAGE_X; bool usey = mIns[at + 1].mMode == ASMIM_ABSOLUTE_Y || mIns[at + 1].mMode == ASMIM_INDIRECT_Y || mIns[at + 1].mMode == ASMIM_ZERO_PAGE_Y; + bool vol = mIns[at + 1].mFlags & NCIF_VOLATILE; int val = mIns[at].mAddress; int i = at; @@ -16744,6 +16745,8 @@ bool NativeCodeBasicBlock::MoveImmediateStoreUp(int at) return false; else if (mIns[at + 1].mMode == ASMIM_INDIRECT_Y && (mIns[i].ChangesZeroPage(mIns[at + 1].mAddress) || mIns[i].ChangesZeroPage(mIns[at + 1].mAddress + 1))) return false; + else if (vol && (mIns[i].mFlags & NCIF_VOLATILE)) + return false; } return false; } @@ -16752,6 +16755,7 @@ bool NativeCodeBasicBlock::MoveImmediateStoreDown(int at) { bool usex = mIns[at + 1].mMode == ASMIM_ABSOLUTE_X || mIns[at + 1].mMode == ASMIM_INDIRECT_X || mIns[at + 1].mMode == ASMIM_ZERO_PAGE_X; bool usey = mIns[at + 1].mMode == ASMIM_ABSOLUTE_Y || mIns[at + 1].mMode == ASMIM_INDIRECT_Y || mIns[at + 1].mMode == ASMIM_ZERO_PAGE_Y; + bool vol = mIns[at + 1].mFlags & NCIF_VOLATILE; int val = mIns[at].mAddress; int i = at + 2; @@ -16808,6 +16812,8 @@ bool NativeCodeBasicBlock::MoveImmediateStoreDown(int at) return false; else if (mIns[at + 1].mMode == ASMIM_INDIRECT_Y && (mIns[i].ChangesZeroPage(mIns[at + 1].mAddress) || mIns[i].ChangesZeroPage(mIns[at + 1].mAddress + 1))) return false; + else if (vol && (mIns[i].mFlags & NCIF_VOLATILE)) + return false; i++; } @@ -47133,7 +47139,7 @@ void NativeCodeProcedure::Compile(InterCodeProcedure* proc) { mInterProc = proc; - CheckFunc = !strcmp(mInterProc->mIdent->mString, "memmove"); + CheckFunc = !strcmp(mInterProc->mIdent->mString, "reu_count_pages"); int nblocks = proc->mBlocks.Size(); tblocks = new NativeCodeBasicBlock * [nblocks]; @@ -48618,7 +48624,6 @@ void NativeCodeProcedure::Optimize(void) else cnt++; - } while (changed); #if 1