Skip to content

Feat: Supporting immediate values without # #290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 1, 2025

Conversation

willieyz
Copy link
Collaborator

@willieyz willieyz commented Jul 31, 2025

  1. The imm_pattern was updated to recognize immediate values regardless of the presence of #, and the <imm> prefix strip off logic was adjusted accordingly.
  2. Additionally, commas , were removed from imm_pattern to avoid misinterpreting operands like q2, UXTW 2 as a single immediate:
.syntax unified
start:
vstrw.32 q0, [r0, #16]
vstrw.u32 q0, [r0, q2, UXTW 2].
end:
  1. To support symbolic aliases like #(SHIFT), used in instructions such as follow, we now combine the old symbolic-style and the new numeric literal patterns. This allows both formats to be parsed properly.
vrshr.s32 q0, q1, #(SHIFT)

@willieyz willieyz force-pushed the feat-sup-imm-WO-hashtahPrefix branch 5 times, most recently from 41f1118 to b6c27ec Compare July 31, 2025 16:39
@willieyz willieyz marked this pull request as ready for review July 31, 2025 17:28
@willieyz willieyz force-pushed the feat-sup-imm-WO-hashtahPrefix branch 4 times, most recently from 1a499ae to b4e08a3 Compare August 1, 2025 05:13
@willieyz willieyz requested a review from mkannwischer August 1, 2025 05:59
@mkannwischer mkannwischer force-pushed the feat-sup-imm-WO-hashtahPrefix branch from b4e08a3 to f3aa07b Compare August 1, 2025 06:07
Copy link
Collaborator

@mkannwischer mkannwischer left a comment

Choose a reason for hiding this comment

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

Thanks @willieyz. Great & simple improvement that is long overdue.

- This commit suppoting immediate values without #
- Following model are supported:
  - aarch64
  - arch_v7m
  - arch_v81m

1. The imm_pattern was updated to recognize immediate values regardless of the presence of #, and the <imm> prefix strip off logic was adjusted accordingly.
Additionally, commas `,` were removed from `imm_pattern` to avoid misinterpreting operands like `q2, UXTW 2` as a single immediate:
```
.syntax unified
start:
vstrw.32 q0, [r0, #16]
vstrw.u32 q0, [r0, q2, UXTW 2].
end:
```
2. Also, since we now allow immediate values both with and without #,
   we need a way to distinguish true immediates from registers.
```
add x0, x1, x2   ; x2 is a register
add x0, x1, 123  ; 123 is an immediate
```
In the current pattern, x2 could be incorrectly interpreted as an immediate, which is unacceptable.
To resolve this, we replace `\w+` with a stricter pattern:
`(0[xb])?[0-9a-fA-F]+`
This ensures only valid numeric literals (decimal or hex) are treated as immediates.

3. For the immediate value example: `vrshr.s32   q0, q1, #(SHIFT)`,
in order to support the alias like this, the old and new immediate patterns are now combined, enabling both literal and symbolic forms.

Signed-off-by: willieyz <[email protected]>
@mkannwischer mkannwischer force-pushed the feat-sup-imm-WO-hashtahPrefix branch from f3aa07b to a29dbf6 Compare August 1, 2025 06:10
@mkannwischer mkannwischer merged commit 177fcf5 into main Aug 1, 2025
36 checks passed
@mkannwischer mkannwischer deleted the feat-sup-imm-WO-hashtahPrefix branch August 1, 2025 07:24
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.

AArch64: Consider supporting immediate values without #
2 participants