Skip to content

[v5] AArch64: print orr with a movz/movn immediate as orr, not mov - #3178

Merged
Rot127 merged 1 commit into
capstone-engine:v5from
0verflowme:v5-a64-orr-mov-alias
Nov 21, 2026
Merged

Rot127 merged 1 commit into
capstone-engine:v5from
0verflowme:v5-a64-orr-mov-alias

Conversation

@0verflowme

Copy link
Copy Markdown
Contributor

Your checklist for this pull request

  • I've documented or updated the documentation of every API function and struct this PR changes.
  • I've added tests that prove my fix is effective or that my feature works (if possible)

Detailed description

On v5, orr wd, wzr, #imm and orr xd, xzr, #imm always print as mov, even when the immediate also fits a movz/movn. The mov alias of ORR (immediate) is preferred only when no move-wide instruction can encode the value, so these read as a movz that is not the encoded instruction.

$ cstool arm64 e0030032
before: mov w0, #1
after:  orr w0, wzr, #1
$ cstool arm64 e0f30032
before/after: mov w0, #0x55555555

llvm-mc prints orr w0, wzr, #0x1, orr x0, xzr, #0x100000000 and mov w0, #1431655765 for these encodings. next already applies this check with AArch64_AM_isAnyMOVWMovAlias (arch/AArch64/AArch64InstPrinter.c:568); this backports it to the v5 printer.

Tests: three entries added to suite/MC/AArch64/basic-a64-instructions.s.cs. Across all 4403 AArch64 MC lines, only the two new orr lines change output.

@Rot127 Rot127 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please rebase to fix the CI.

@Rot127
Rot127 merged commit 2461ca7 into capstone-engine:v5 Nov 21, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants