Skip to content

Cranelift: ISLE: add type parameters to most clif terms in lower#12717

Open
avanhatt wants to merge 5 commits intobytecodealliance:mainfrom
avanhatt:ty-params-3-4
Open

Cranelift: ISLE: add type parameters to most clif terms in lower#12717
avanhatt wants to merge 5 commits intobytecodealliance:mainfrom
avanhatt:ty-params-3-4

Conversation

@avanhatt
Copy link
Member

@avanhatt avanhatt commented Mar 4, 2026

Discussed in issue #12716.

Right now in ISLE, most clif instructions have a type parameter in opt for the midend, but not in lowering (e.g., iadd ty x y) vs (iadd x y). From our previous discussions (@cfallin @fitzgen), this is mostly due to the order of implementation rather than a design decision. For our verification work, it's useful to also have the type parameters in the lowering terms, as well, if they produce values (e.g., excluding things like store).

This changes uses scripting to automatically change the many relevant rules, by programmatically adding _. Over time, we can update rules to remove now-simplifiable has_ty terms.

This is based on an earlier commit/script from @mmcloughlin , with changes to merge into upstream after #10524.

avanhatt added 2 commits March 4, 2026 12:15
Right now in ISLE, most clif instructions have a type parameter in opt for the midend, but not in lowering. From our previous discussions, this is mostly due to the order of implementation rather than a design deciscion. For our verification work, it's useful to also have the type parameters in the lowering terms, as well, if they produce values (e.g., excluding things like `store`). This is based on an earlier commit from @mmcloughlin, with changes to merge into upstream after bytecodealliance#10524.
@avanhatt avanhatt requested a review from a team as a code owner March 4, 2026 17:30
@avanhatt avanhatt requested review from alexcrichton and removed request for a team March 4, 2026 17:30
let mut s = format!(
"({inst_data_etor} {}(InstructionData.{} (Opcode.{})",
if ty_in_decl { "ty " } else { "" },
if ty_in_decl { "ty " } else if isle_target == IsleTarget::Lower { "_" } else { "" },
Copy link
Member Author

Choose a reason for hiding this comment

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

CC @fitzgen this is not the cleanest, but I wasn't sure about adding another result to the match tuple creation you added above. The alternative is to add another inst_data_value variant to the backend with a distinct signature. Thoughts?

@avanhatt avanhatt marked this pull request as draft March 4, 2026 17:37
@avanhatt
Copy link
Member Author

avanhatt commented Mar 4, 2026

Oops, hadn't built the pulley_shared target locally, converting to draft.

@avanhatt avanhatt marked this pull request as ready for review March 4, 2026 18:03
@alexcrichton alexcrichton requested review from cfallin and removed request for alexcrichton March 4, 2026 18:11
Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

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

LGTM

Co-authored-by: Nick Fitzgerald <fitzgen@gmail.com>
@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator cranelift:area:machinst Issues related to instruction selection and the new MachInst backend. cranelift:area:aarch64 Issues related to AArch64 backend. cranelift:area:x64 Issues related to x64 codegen cranelift:meta Everything related to the meta-language. labels Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cranelift:area:aarch64 Issues related to AArch64 backend. cranelift:area:machinst Issues related to instruction selection and the new MachInst backend. cranelift:area:x64 Issues related to x64 codegen cranelift:meta Everything related to the meta-language. cranelift Issues related to the Cranelift code generator

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants