Fix MIPS lifter bugs: overflow detection and MSUB/MSUBU subtraction order#126
Merged
Conversation
Fix tests asserting wrong behavior per MIPS32 manual: - ADD: -1 + 1 = 0 is not overflow, add MIN_INT + (-1) overflow case - SUB: 0 - 1 = -1 is not overflow, add MAX_INT - (-1) overflow case - MSUB/MSUBU: fix reversed subtraction (manual: accumulator - product) Add edge cases to existing tests: - CLZ(0)=32, CLO(0xFFFFFFFF)=32, DIV neg/neg, SRA shift-31 - BGEZAL/BLTZAL: assert $ra written unconditionally Add new test functions: - TEQ, LL, SC, RDHWR, PREF, SYNC, ADDIU negative imm, SLTIU negative imm Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ction order - ADD/ADDI: Overflow check compared result sign to lhs sign only, which falsely triggered on e.g. -1 + 1 = 0. Now uses manual-specified 33-bit check: sign-extend to 64 bits, add, overflow if bit32 != bit31. - SUB: Overflow used incorrect cmpltu formula. Now uses same 33-bit approach as ADD but with subtraction. - MSUB/MSUBU: Computed product - accumulator instead of manual-specified accumulator - product. Swapped operand order. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- actions/checkout@v2 → v4 - actions-rs/toolchain@v1 → dtolnay/rust-toolchain@stable - actions-rs/cargo@v1 → direct cargo commands - Consolidate rustfmt + clippy components in single toolchain step Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
product - accumulator, manual specifiesaccumulator - productTest plan
cargo test --lib translator::mips::test)🤖 Generated with Claude Code