Skip to content

Add ARM NEON instructions BIF and REV32 (vector)#406

Open
nebeid wants to merge 2 commits into
awslabs:mainfrom
nebeid:arm-decoder-crypto-extensions
Open

Add ARM NEON instructions BIF and REV32 (vector)#406
nebeid wants to merge 2 commits into
awslabs:mainfrom
nebeid:arm-decoder-crypto-extensions

Conversation

@nebeid
Copy link
Copy Markdown
Contributor

@nebeid nebeid commented May 12, 2026

Adds decode + semantics + simulator entries for two ARM NEON instructions
needed for verification of the AES-GCM optimised implementation:

  • BIF (Bitwise Insert if False) — 0q101110111 Rm 000111 Rn Rd
  • REV32 (vector, reverse within 32-bit elements) — 0q101110 size 100000000010 Rn Rd

Changes

  • arm/proofs/decode.ml: bit-pattern decode entries
  • arm/proofs/instruction.ml: semantic definitions, ALT rules, operation list
  • arm/proofs/simulator_iclasses.ml: sematest entries

Testing

Focused sematest (only BIF + REV32 in iclasses): 13,413 random instances
across 4 parallel processes, 0 failures. Cosimulated against hardware on
AArch64.

Add decode patterns, semantic definitions, and simulator entries for:
- BIF (Bitwise Insert if False): complement of BIT, inserts source
  bits where mask is 0. Supports 64-bit and 128-bit datasize.
- REV32 (vector): reverses byte/halfword order within each 32-bit
  element. Supports esize=8 and esize=16, Q=1 (128-bit) only.

These are needed for verification of the AES-GCM optimised implementation.

Tested: focused sematest with 13,413 random instances (4 processes),
0 failures. Both instructions match hardware cosimulation on AArch64.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@nebeid nebeid force-pushed the arm-decoder-crypto-extensions branch from d1e80c4 to 47174ef Compare May 12, 2026 23:50
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@nebeid nebeid force-pushed the arm-decoder-crypto-extensions branch from 47174ef to f24e276 Compare May 22, 2026 20:55
@jargh
Copy link
Copy Markdown
Contributor

jargh commented May 26, 2026

I believe this is all absolutely functionally correct, thank you! However, I would like to suggest a stylistic modification to the core arm_REV32_VEC function as follows:

let arm_REV32_VEC = define
 `arm_REV32_VEC Rd Rn esize =
    \s. let n:(128)word = read Rn (s:armstate) in
        let n_reversed = usimd4 (word_reversefields esize) n in
        (Rd := n_reversed) s`;;

This is using the word library's word_reversefields, which I think gives a more clear and simple implementation than the explicit word joining used currently.

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