Skip to content

Conversation

@nazar-pc
Copy link
Owner

Extracted from my local branch, should be much more fitting.

There are also some other minor changes included.

Copilot AI review requested due to automatic review settings January 22, 2026 22:04
@nazar-pc nazar-pc enabled auto-merge January 22, 2026 22:16
Copy link
Contributor

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 pull request improves the type safety and clarity of RISC-V instruction immediate values by using more appropriate integer types. The PR changes I-type and S-type immediate fields from i32 to i16 (which properly represents 12-bit signed values), and shift amount fields from u32 to u8 (which properly represents 6-bit unsigned values). Additionally, it improves code clarity by using i64::from() instead of as i64 casts and refactors test utilities for better genericity.

Changes:

  • Changed immediate value types from i32 to i16 for I-type and S-type instructions (12-bit signed immediates)
  • Changed shift amount types from u32 to u8 for shift instructions (6-bit and 5-bit unsigned values)
  • Replaced as i64 casts with i64::from() for clearer type conversions in the interpreter
  • Consolidated test utility functions for improved code reuse
  • Added /build.rs to package include lists for proper distribution

Reviewed changes

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

Show a summary per file
File Description
crates/execution/ab-riscv-primitives/src/instruction/rv64.rs Changed immediate types from i32 to i16 and shift amounts from u32 to u8 in instruction enum and decoder
crates/execution/ab-riscv-primitives/Cargo.toml Reordered include list to put /src before /build.rs
crates/execution/ab-riscv-interpreter/src/rv64/test_utils.rs Refactored test utilities to use generic Into trait for better code reuse
crates/execution/ab-riscv-interpreter/src/rv64/m/tests.rs Updated test calls to use renamed function
crates/execution/ab-riscv-interpreter/src/rv64/b/zbs/tests.rs Updated test calls to use renamed function
crates/execution/ab-riscv-interpreter/src/rv64/b/zbc/tests.rs Updated test calls to use renamed function
crates/execution/ab-riscv-interpreter/src/rv64/b/zbb/tests.rs Updated test calls to use renamed function
crates/execution/ab-riscv-interpreter/src/rv64/b/zba/tests.rs Updated test calls to use renamed function
crates/execution/ab-riscv-interpreter/src/rv64.rs Updated interpreter to use i64::from() instead of as casts when converting immediates
crates/execution/ab-riscv-interpreter/Cargo.toml Added /build.rs to include list
crates/execution/ab-riscv-benchmarks/Cargo.toml Added /build.rs to include list

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

@nazar-pc nazar-pc merged commit 36b88ad into main Jan 22, 2026
67 checks passed
@nazar-pc nazar-pc deleted the improve-immediate-types branch January 22, 2026 22:39
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