Skip to content

Load-Exclusive/Store-Exclusive#62

Merged
monoid merged 2 commits into
masterfrom
feat/exclusive
Jul 12, 2026
Merged

Load-Exclusive/Store-Exclusive#62
monoid merged 2 commits into
masterfrom
feat/exclusive

Conversation

@monoid

@monoid monoid commented Jul 12, 2026

Copy link
Copy Markdown
Owner

LDXR/STXR et al.

Summary by CodeRabbit

  • New Features
    • Added support for AArch64 exclusive load and store instructions, including byte, halfword, word, doubleword, and pair variants.
    • Added constructors and operand accessors for exclusive memory operations.
    • Added support for register and stack-pointer addressing, including zero-register forms.
  • Tests
    • Added encoding and formatting coverage for the new instruction variants.

`LDXR`/`STXR` et al.
@monoid monoid self-assigned this Jul 12, 2026
@monoid monoid added enhancement New feature or request harm The `harm` dynamic assembler labels Jul 12, 2026
@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@monoid, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 38 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 67ce2f5e-1ad0-4171-b434-338a003171c7

📥 Commits

Reviewing files that changed from the base of the PR and between 3139fe7 and 9a7b25a.

📒 Files selected for processing (1)
  • harm/src/instructions/ldst/exclusive/exclusive_args.rs
📝 Walkthrough

Walkthrough

Adds typed argument wrappers and public module exports for AArch64 exclusive load/store instructions. Implements LDXP, LDXR, LDXRB, LDXRH, STXP, STXR, STXRB, and STXRH constructors, operand accessors, encodings, and tests.

Changes

Exclusive load/store instruction support

Layer / File(s) Summary
Argument contracts and module wiring
harm/src/instructions/ldst.rs, harm/src/instructions/ldst/args*, harm/src/instructions/ldst/exclusive.rs, harm/src/instructions/ldst/exclusive/exclusive_args.rs
Adds module exports and sealed typed constructors for register/address, exclusive store, and pair operands.
Exclusive load instruction wrappers
harm/src/instructions/ldst/exclusive/ldxp.rs, ldxr.rs, ldxrb.rs, ldxrh.rs
Adds constructors, accessors, raw encodings, and tests for exclusive load instructions.
Exclusive store instruction wrappers
harm/src/instructions/ldst/exclusive/stxp.rs, stxr.rs, stxrb.rs, stxrh.rs
Adds constructors, accessors, raw encodings, and tests for exclusive store instructions.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant InstructionConstructor
  participant TypedArgs
  participant RawInstruction
  Caller->>InstructionConstructor: provide register and address inputs
  InstructionConstructor->>TypedArgs: convert inputs with IntoReg
  TypedArgs-->>InstructionConstructor: return typed operands
  InstructionConstructor->>RawInstruction: encode operand indices
  RawInstruction-->>Caller: return instruction code
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 35.71% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and directly describes the main change: adding load-exclusive and store-exclusive instruction support.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/exclusive

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (7)
harm/src/instructions/ldst/exclusive/ldxp.rs (1)

16-18: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider adding #[derive(Debug, Clone, Copy)] for consistency.

Ldxrb derives these traits but Ldxp and Ldxr do not. Since Ldxp already requires Rt: Copy in its impl block, deriving Copy is safe. Adding these derives would make all exclusive instruction wrappers consistent and improve debuggability.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@harm/src/instructions/ldst/exclusive/ldxp.rs` around lines 16 - 18, Add
#[derive(Debug, Clone, Copy)] to the Ldxp struct, matching the existing derives
on Ldxrb and the Rt: Copy constraint in its implementation. Ensure the wrapper
remains otherwise unchanged.
harm/src/instructions/ldst/exclusive/ldxr.rs (1)

16-28: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider adding #[derive(Debug, Clone, Copy)] for consistency.

Same as the Ldxp comment — Ldxr already requires Rt: Copy, so deriving Copy is safe. This would match the Ldxrb wrapper.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@harm/src/instructions/ldst/exclusive/ldxr.rs` around lines 16 - 28, Add
Debug, Clone, and Copy derives to the Ldxr struct, matching the existing Ldxrb
and Ldxp wrapper conventions. Preserve the current Rt: Copy bound, which
supports the derived Copy implementation.
harm/src/instructions/ldst/exclusive/stxrh.rs (1)

12-15: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add #[derive(Debug, Clone, Copy)] and fix the doc comment.

The struct lacks derives that Ldxrh has (depends on ExclusiveStore32Args in exclusive_args.rs also deriving them). The doc comment says "a destination and an address" but STXRH has a status register, a data register, and an address.

♻️ Proposed fix
-/// A `stxrh` instruction with a destination and an address.
+/// A `stxrh` instruction with a status, data register, and an address.
+#[derive(Debug, Clone, Copy)]
 pub struct Stxrh {
     args: ExclusiveStore32Args,
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@harm/src/instructions/ldst/exclusive/stxrh.rs` around lines 12 - 15, Update
the Stxrh struct declaration to derive Debug, Clone, and Copy, ensuring
ExclusiveStore32Args supports those derives as required. Correct its
documentation to describe the status register, data register, and address
operands rather than a generic destination and address.
harm/src/instructions/ldst/exclusive/stxr.rs (1)

15-18: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add #[derive(Debug, Clone, Copy)] and fix the doc comment.

The struct lacks derives that Ldxrh has (depends on ExclusiveStoreArgs in exclusive_args.rs also deriving them). The doc comment says "a destination and an address" but STXR has a status register, a data register, and an address.

♻️ Proposed fix
-/// A `stxr` instruction with a destination and an address.
+/// A `stxr` instruction with a status, data register, and an address.
+#[derive(Debug, Clone, Copy)]
 pub struct Stxr<Rt> {
     args: ExclusiveStoreArgs<Rt>,
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@harm/src/instructions/ldst/exclusive/stxr.rs` around lines 15 - 18, Update
the Stxr struct to derive Debug, Clone, and Copy, ensuring ExclusiveStoreArgs
supports those derives as required. Revise its documentation to describe the
status register, data register, and address operands instead of only a
destination and address.
harm/src/instructions/ldst/exclusive/exclusive_args.rs (1)

6-201: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add #[derive(Debug, Clone, Copy)] to all argument structs.

The structs in reg_addr.rs (RegAddr, Reg32Addr, Reg64Addr) all derive Debug, Clone, Copy, but none of the 5 structs here do. This prevents the instruction wrappers Stxr, Stxp, Stxrb, and Stxrh from deriving these traits, creating an API inconsistency with Ldxrh (which derives them because it uses Reg32Addr).

♻️ Proposed fix — add derives to all 5 structs
+#[derive(Debug, Clone, Copy)]
 pub struct ExclusiveStoreArgs<Reg> {
     pub status: RegOrZero32,
     pub reg: Reg,
     pub addr: RegOrSp64,
 }
+#[derive(Debug, Clone, Copy)]
 pub struct ExclusiveStore32Args {
     pub status: RegOrZero32,
     pub reg: RegOrZero32,
     pub addr: RegOrSp64,
 }
+#[derive(Debug, Clone, Copy)]
 pub struct ExclusiveStore64Args {
     pub status: RegOrZero32,
     pub reg: RegOrZero64,
     pub addr: RegOrSp64,
 }
+#[derive(Debug, Clone, Copy)]
 pub struct ExclusivePairLoadArgs<Reg> {
     pub reg1: Reg,
     pub reg2: Reg,
     pub addr: RegOrSp64,
 }
+#[derive(Debug, Clone, Copy)]
 pub struct ExclusivePairStoreArgs<Reg> {
     pub status: RegOrZero32,
     pub reg1: Reg,
     pub reg2: Reg,
     pub addr: RegOrSp64,
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@harm/src/instructions/ldst/exclusive/exclusive_args.rs` around lines 6 - 201,
Add #[derive(Debug, Clone, Copy)] to the five argument structs
ExclusiveStoreArgs, ExclusiveStore32Args, ExclusiveStore64Args,
ExclusivePairLoadArgs, and ExclusivePairStoreArgs. Leave their fields and
constructor implementations unchanged so the related instruction wrappers can
derive the same traits consistently.
harm/src/instructions/ldst/exclusive/stxrb.rs (1)

12-15: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add #[derive(Debug, Clone, Copy)] and fix the doc comment.

The struct lacks derives that Ldxrh has (depends on ExclusiveStore32Args in exclusive_args.rs also deriving them). The doc comment says "a destination and an address" but STXRB has a status register, a data register, and an address.

♻️ Proposed fix
-/// A `stxrb` instruction with a destination and an address.
+/// A `stxrb` instruction with a status, data register, and an address.
+#[derive(Debug, Clone, Copy)]
 pub struct Stxrb {
     args: ExclusiveStore32Args,
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@harm/src/instructions/ldst/exclusive/stxrb.rs` around lines 12 - 15, Update
the Stxrb struct to derive Debug, Clone, and Copy, ensuring ExclusiveStore32Args
supports those derives as needed. Correct its documentation to describe the
status register, data register, and address operands instead of only a
destination and address.
harm/src/instructions/ldst/exclusive/stxp.rs (1)

15-36: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add #[derive(Debug, Clone, Copy)], fix the doc comment, and add #[inline] to accessors.

The struct lacks derives that Ldxrh has (depends on ExclusivePairStoreArgs in exclusive_args.rs also deriving them). The doc comment says "a destination and an address" but STXP has a status register, two data registers, and an address. The accessor methods also lack #[inline] unlike their counterparts in stxr.rs, stxrb.rs, stxrh.rs, and ldxrh.rs.

♻️ Proposed fix
-/// A `stxp` instruction with a destination and an address.
+/// A `stxp` instruction with a status, two data registers, and an address.
+#[derive(Debug, Clone, Copy)]
 pub struct Stxp<Rt> {
     args: ExclusivePairStoreArgs<Rt>,
 }
 
 impl<Rt: Copy> Stxp<Rt> {
+    #[inline]
     pub fn status(&self) -> RegOrZero32 {
         self.args.status
     }
 
+    #[inline]
     pub fn rt1(&self) -> Rt {
         self.args.reg1
     }
 
+    #[inline]
     pub fn rt2(&self) -> Rt {
         self.args.reg2
     }
 
+    #[inline]
     pub fn addr(&self) -> RegOrSp64 {
         self.args.addr
     }
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@harm/src/instructions/ldst/exclusive/stxp.rs` around lines 15 - 36, Update
the Stxp struct to derive Debug, Clone, and Copy, ensuring
ExclusivePairStoreArgs supports the same derives. Correct its documentation to
describe the status register, two data registers, and address, and add #[inline]
to status, rt1, rt2, and addr accessors consistent with the related exclusive
instruction types.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@harm/src/instructions/ldst/exclusive/exclusive_args.rs`:
- Around line 78-104: Resolve the dead_code lint for ExclusiveStore64Args and
MakeExclusiveStore64Args by either integrating them into the 64-bit
exclusive-store path or adding #[allow(dead_code)] consistent with the
Reg64Addr/MakeReg64Addr pattern. Keep their existing conversions and
construction behavior unchanged.

---

Nitpick comments:
In `@harm/src/instructions/ldst/exclusive/exclusive_args.rs`:
- Around line 6-201: Add #[derive(Debug, Clone, Copy)] to the five argument
structs ExclusiveStoreArgs, ExclusiveStore32Args, ExclusiveStore64Args,
ExclusivePairLoadArgs, and ExclusivePairStoreArgs. Leave their fields and
constructor implementations unchanged so the related instruction wrappers can
derive the same traits consistently.

In `@harm/src/instructions/ldst/exclusive/ldxp.rs`:
- Around line 16-18: Add #[derive(Debug, Clone, Copy)] to the Ldxp struct,
matching the existing derives on Ldxrb and the Rt: Copy constraint in its
implementation. Ensure the wrapper remains otherwise unchanged.

In `@harm/src/instructions/ldst/exclusive/ldxr.rs`:
- Around line 16-28: Add Debug, Clone, and Copy derives to the Ldxr struct,
matching the existing Ldxrb and Ldxp wrapper conventions. Preserve the current
Rt: Copy bound, which supports the derived Copy implementation.

In `@harm/src/instructions/ldst/exclusive/stxp.rs`:
- Around line 15-36: Update the Stxp struct to derive Debug, Clone, and Copy,
ensuring ExclusivePairStoreArgs supports the same derives. Correct its
documentation to describe the status register, two data registers, and address,
and add #[inline] to status, rt1, rt2, and addr accessors consistent with the
related exclusive instruction types.

In `@harm/src/instructions/ldst/exclusive/stxr.rs`:
- Around line 15-18: Update the Stxr struct to derive Debug, Clone, and Copy,
ensuring ExclusiveStoreArgs supports those derives as required. Revise its
documentation to describe the status register, data register, and address
operands instead of only a destination and address.

In `@harm/src/instructions/ldst/exclusive/stxrb.rs`:
- Around line 12-15: Update the Stxrb struct to derive Debug, Clone, and Copy,
ensuring ExclusiveStore32Args supports those derives as needed. Correct its
documentation to describe the status register, data register, and address
operands instead of only a destination and address.

In `@harm/src/instructions/ldst/exclusive/stxrh.rs`:
- Around line 12-15: Update the Stxrh struct declaration to derive Debug, Clone,
and Copy, ensuring ExclusiveStore32Args supports those derives as required.
Correct its documentation to describe the status register, data register, and
address operands rather than a generic destination and address.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b790f8f5-cef0-425e-9205-dc6120dfc3cb

📥 Commits

Reviewing files that changed from the base of the PR and between 302ead5 and 3139fe7.

📒 Files selected for processing (13)
  • harm/src/instructions/ldst.rs
  • harm/src/instructions/ldst/args.rs
  • harm/src/instructions/ldst/args/reg_addr.rs
  • harm/src/instructions/ldst/exclusive.rs
  • harm/src/instructions/ldst/exclusive/exclusive_args.rs
  • harm/src/instructions/ldst/exclusive/ldxp.rs
  • harm/src/instructions/ldst/exclusive/ldxr.rs
  • harm/src/instructions/ldst/exclusive/ldxrb.rs
  • harm/src/instructions/ldst/exclusive/ldxrh.rs
  • harm/src/instructions/ldst/exclusive/stxp.rs
  • harm/src/instructions/ldst/exclusive/stxr.rs
  • harm/src/instructions/ldst/exclusive/stxrb.rs
  • harm/src/instructions/ldst/exclusive/stxrh.rs

Comment thread harm/src/instructions/ldst/exclusive/exclusive_args.rs Outdated
@monoid
monoid merged commit e52715d into master Jul 12, 2026
2 checks passed
@monoid
monoid deleted the feat/exclusive branch July 12, 2026 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request harm The `harm` dynamic assembler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant