Respect FP bit in MSR when running floating point instructions - #135
Merged
Conversation
Rather than running them normally, they should trigger a "no FPU" exception. This appears to be required to allow correct graphical rendering under Mac OS X - the FP bit cleared via mtmsr and rfi instructions and something else appears to be relying on the exception to be thrown. Implemented by maintaining a parallel version of the OpcodeGrabber table (OpcodeGrabberNoFPU) which contains alternate implementations for all the floating point instructions. We switch the table whenever the MSR value changes. This should minimize the overhead of doing these checks.
61 tasks
mihaip
added a commit
to mihaip/dingusppc
that referenced
this pull request
Jan 26, 2025
In dingusdev#135 we switched from a static OpcodeGrabber table to a curOpcodeGrabber pointer in ppc_main_opcode results. This results in an extra indirection (as far as generated assembly having an additional load), which reduces execution speed. Switch to making the opcode grabber into a parameter to ppc_main_opcode, and make ppc_exec_inner keep it up to date (via an EXEF_OPCODE exception flag). Also fixes FPU instructions in ppctestss - we now need to set the FP MSR bit when initializing the CPU.
mihaip
added a commit
to mihaip/dingusppc
that referenced
this pull request
Jan 26, 2025
In dingusdev#135 we switched from a static OpcodeGrabber table to a curOpcodeGrabber pointer in ppc_main_opcode. This results in an extra indirection (as far as generated assembly having an additional load), which reduces execution speed. Switch to making the opcode grabber into a parameter to ppc_main_opcode, and make ppc_exec_inner keep it up to date (via an EXEF_OPCODE exception flag). Also fixes FPU instructions in ppctests - we now need to set the FP MSR bit when initializing the CPU.
mihaip
added a commit
to mihaip/pearpc
that referenced
this pull request
Jan 27, 2025
To make them throw NO_FPU exceptions when the MSR FP bit is not set, we switch between two different opcode tables (using the same approach as dingusdev/dingusppc#135 and dingusdev/dingusppc#136) Should be a no-op to a slight regression in the benchmark (since it has no FPU instructions and there's the slight overhead of checking for MSR changes), but instead it goes from ~442.5 to 460 MiB/s. ¯\_(ツ)_/¯
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rather than running them normally, they should trigger a "no FPU" exception. This appears to be required to allow correct graphical rendering under Mac OS X - the FP bit cleared via
mtmsrandrfiinstructions and something else appears to be relying on the exception to be thrown.Implemented by maintaining a parallel version of the
OpcodeGrabbertable (OpcodeGrabberNoFPU) which contains alternate implementations for all the floating point instructions. We switch the table whenever the MSR value changes. This should minimize the overhead of doing these checks.