Skip to content

Fix simx jalr target alignment#339

Open
cassuto wants to merge 3 commits intovortexgpgpu:masterfrom
cassuto:fix_pc_misaligned
Open

Fix simx jalr target alignment#339
cassuto wants to merge 3 commits intovortexgpgpu:masterfrom
cassuto:fix_pc_misaligned

Conversation

@cassuto
Copy link
Copy Markdown
Contributor

@cassuto cassuto commented Apr 24, 2026

This fixes JALR target address alignment in sim/simx by clearing bit 0 of the computed target, as required by the RISC-V ISA.
It also adds a regression test under tests/regression/jalr.

Copilot AI review requested due to automatic review settings April 24, 2026 02:37
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR corrects RISC-V JALR target address alignment in the sim/simx emulator by clearing bit 0 of the computed target address, and adds a focused regression test to prevent the issue from reappearing.

Changes:

  • Fix sim/simx JALR next-PC computation to enforce (rs1 + imm) & ~1.
  • Add a new tests/regression/jalr test (host + kernel + startup) that fails deterministically when JALR doesn’t clear bit 0.
  • Wire the new regression into the top-level tests/regression/Makefile targets (build/run/clean).

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
sim/simx/execute.cpp Masks off bit 0 when computing JALR target PC to match the ISA requirement.
tests/regression/Makefile Adds the new jalr regression to aggregate build/run/clean targets.
tests/regression/jalr/Makefile Build/run glue for the new regression test.
tests/regression/jalr/start.S Minimal startup that calls main, dumps perf, and terminates.
tests/regression/jalr/main.cpp Host-side test runner that launches the kernel and validates per-core pass signatures.
tests/regression/jalr/kernel.cpp Kernel that uses an intentionally odd JALR target to distinguish correct vs incorrect alignment behavior.
tests/regression/jalr/common.h Kernel argument struct for passing the destination buffer address.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants