Repository navigation
X86 FPU fixes - #792
Draft
mrexodia wants to merge 14 commits into
Draft
X86 FPU fixes#792mrexodia wants to merge 14 commits into
mrexodia wants to merge 14 commits into
Conversation
XED produces POPA_16 for the 16-bit operand form. POPA_32 did not match that form; POPAD_32 remains separate.
Match both destination operands emitted by the decoder and retain the upper lanes from the old destination for register and memory sources.
Set bit 6 and clear bits 7 and 13-15. Native regressions are in patch 0009.
Use explicit ties-to-even for RC=00. Update C1 by magnitude and accumulate precision/invalid flags. Check signed conversion bounds before FP-to-int casts to avoid LLVM poison, retain FISTTP truncation, and use an exclusive BCD bound. This does not implement unmasked exception delivery or all unsupported encodings.
FLDCW preserves the guest PC field. FNSTCW and STMXCSR store guest control state without replacing it with the host environment. Arithmetic precision emulation and MXCSR reserved-bit exceptions remain separate issues.
Select x87 RC or MXCSR RC and restore the caller mode. Compile semantics with constrained floating-point operations. Native regressions are in 0009.
Reset abridged tags and TOP. Rotate the logical x87 view while retaining the physical MMX view. Intel native FXSAVE/EMMS/FXSAVE probes confirm TOP reset and physical data preservation; do not fake an undefined-f80 aggregate ABI.
Use the existing assembly suite and runner for controls, rounding, POPA, CVTPI2PS and EMMS. Add opt-in raw-register, status and tag checks.
Preserve sticky IE and inspect both operands with the ext80 SNaN classifier. Cover all ten register comparison forms in the native assembly suite. Comparison C1 remains excluded from these regressions.
LLVM 17/18 reject inlining strict-FP semantics into non-strict lifted functions. This leaves internal calls behind and makes the installed lifter abort when moving the trace to its output module.
Keep real CALL/RET opcodes in the lifted input. Use four-byte stack operations in the long-mode reference, with equal sequence extents so return-PC offsets match. Preserve the full-stack comparison.
mrexodia
force-pushed
the
bo2-x86-fpu-fixes
branch
from
November 14, 2026 09:41
7c793d1 to
9da6d26
Compare
mrexodia
marked this pull request as draft
November 20, 2026 10:52
Contributor
Author
|
Converted to draft because it has performance implications that need further investigation. |
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.
Based on work in: https://github.com/adrbn/bo2-mac
A few patches were taken as-is, the rest based on X87/MMX instructions used in the game executables. Note that this breaks the “ABI” regarding intrinsics used and exception/rounding mode state, but it’s necessary to be able to use X87 correctly for this recompilation project.
For future reference: https://github.com/mrexodia/agent-scratch/tree/claude/trusting-hopper-mkoj3i this is a liberally-licensed software implementation of X87 I used for testing in another project.