Firestar99 opened PR #13319 from Firestar99:isle_struct to bytecodealliance:main:
I have a code generator that creates rust code similar to this:
pub struct IAdd { pub out: WriteableReg, pub a: Reg, pub b: Reg, } pub struct IConst { pub out: WriteableReg, pub imm: Imm, } pub enum MInst { IAdd(IAdd), IConst(IConst), }I would like to modify my code generator to also emit isle that matches this particular style of codegen. But isle only supports enums, so this PR adds support for structs:
(type IAdd extern (struct (out WriteableReg) (a Reg) (b Reg))) (type IConst extern (struct (out WriteableReg) (imm Imm))) (type MInst extern (enum (IAdd (x IAdd)) (IConst (x IConst))))This is not quite sufficient to properly map it this example, as isle doesn't support tuple-like enum variants. But that can be a follow up PR some other day.
Firestar99 edited PR #13319:
I have a code generator that creates rust code similar to this:
pub struct IAdd { pub out: WriteableReg, pub a: Reg, pub b: Reg, } pub struct IConst { pub out: WriteableReg, pub imm: Imm, } pub enum MInst { IAdd(IAdd), IConst(IConst), }I would like to modify my code generator to also emit isle that matches this particular style of codegen. But isle only supports enums, so this PR adds support for structs:
(type IAdd extern (struct (out WriteableReg) (a Reg) (b Reg))) (type IConst extern (struct (out WriteableReg) (imm Imm))) (type MInst extern (enum (IAdd (x IAdd)) (IConst (x IConst))))This is not quite sufficient to properly map it this example, as isle doesn't support tuple-like enum variants. But that can be a follow up PR some other day.
:memo: Firestar99 submitted PR review.
:speech_balloon: Firestar99 created PR review comment:
While in the front end (ast and sema) I added a separate struct variant everywhere, when it proceeds to adding rules and match statements, I start reusing enum's variants by making the
VariantIdoptional everywhere. This is the only place where anything actually matches on it, which allows my code changes to be quite minimal in this area.
:memo: cfallin submitted PR review:
Thanks! This is a nice extension of ISLE and will certainly make it more useful in binding to other environments.
A few thoughts on the data-structure design below. Overall shape (reusing
enum's code as much as possible) seems right, though.Also cc @mmcloughlin / @avanhatt as they have some (not-yet-upstreamed) additions to ISLE and will probably want to be aware of this.
:speech_balloon: cfallin created PR review comment:
LIkewise here -- let's model the domain a bit more closely.
:speech_balloon: cfallin created PR review comment:
Likewise here, let's not overload the meaning of
Some/Nonein a somewhat ad-hoc way. Maybe we should have aStructOrEnumVariantenum, take that here, and use that in theEnumVariantenum arm above?
:speech_balloon: cfallin created PR review comment:
Rather than overload
EnumVarianthere and give it no inner information for structs, let's add aStructTermKind.
:speech_balloon: cfallin created PR review comment:
If we separate out the struct case here, why do we make the variant IDs
Options above?
:speech_balloon: cfallin created PR review comment:
The changes here seem unrelated to
structsupport?
github-actions[bot] added the label cranelift on PR #13319.
github-actions[bot] added the label isle on PR #13319.
github-actions[bot] commented on PR #13319:
Subscribe to Label Action
cc @cfallin, @fitzgen
<details>
This issue or pull request has been labeled: "cranelift", "isle"Thus the following users have been cc'd because of the following labels:
- cfallin: isle
- fitzgen: isle
To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
Firestar99 edited PR #13319:
I have a code generator that creates rust code similar to this:
pub struct IAdd { pub out: WriteableReg, pub a: Reg, pub b: Reg, } pub struct IConst { pub out: WriteableReg, pub imm: Imm, } pub enum MInst { IAdd(IAdd), IConst(IConst), }I would like to modify my code generator to also emit isle that matches this particular style of codegen. But isle only supports enums, so this PR adds support for structs:
(type IAdd extern (struct (out WriteableReg) (a Reg) (b Reg))) (type IConst extern (struct (out WriteableReg) (imm Imm))) (type MInst extern (enum (IAdd (x IAdd)) (IConst (x IConst))))This is not quite sufficient to properly map it this example, as isle doesn't support tuple-like enum variants. But that can be a follow up PR some other day.
Also changes the temp directory for isle link and run tests to
./target/tmp/<test-name>/. Using system tmp and deleting it regardless of test failure makes it hard to debug broken rust code emissions.
Firestar99 edited PR #13319:
I have a code generator that creates rust code similar to this:
pub struct IAdd { pub out: WriteableReg, pub a: Reg, pub b: Reg, } pub struct IConst { pub out: WriteableReg, pub imm: Imm, } pub enum MInst { IAdd(IAdd), IConst(IConst), }I would like to modify my code generator to also emit isle that matches this particular style of codegen. But isle only supports enums, so this PR adds support for structs:
(type IAdd extern (struct (out WriteableReg) (a Reg) (b Reg))) (type IConst extern (struct (out WriteableReg) (imm Imm))) (type MInst extern (enum (IAdd (x IAdd)) (IConst (x IConst))))This is not quite sufficient to properly map it this example, as isle doesn't support tuple-like enum variants. But that can be a follow up PR some other day.
Minor changes
I'Ve changed the temp directory for isle link and run tests to
./target/tmp/<test-name>/(viaCARGO_TARGET_TMPDIRenv). Using system tmp and deleting it regardless of test failure makes it hard to debug broken rust code emissions.
Firestar99 edited PR #13319:
I have a code generator that creates rust code similar to this:
pub struct IAdd { pub out: WriteableReg, pub a: Reg, pub b: Reg, } pub struct IConst { pub out: WriteableReg, pub imm: Imm, } pub enum MInst { IAdd(IAdd), IConst(IConst), }I would like to modify my code generator to also emit isle that matches this particular style of codegen. But isle only supports enums, so this PR adds support for structs:
(type IAdd extern (struct (out WriteableReg) (a Reg) (b Reg))) (type IConst extern (struct (out WriteableReg) (imm Imm))) (type MInst extern (enum (IAdd (x IAdd)) (IConst (x IConst))))This is not quite sufficient to properly map it this example, as isle doesn't support tuple-like enum variants. But that can be a follow up PR some other day.
Minor changes
I've changed the temp directory for isle link and run tests to
./target/tmp/<test-name>/(viaCARGO_TARGET_TMPDIRenv). Using system tmp and deleting it regardless of test failure makes it hard to debug broken rust code emissions.
:memo: Firestar99 submitted PR review.
:speech_balloon: Firestar99 created PR review comment:
Forgot to describe this part in the PR description:
I've changed the temp directory for isle link and run tests to
./target/tmp/<test-name>/(viaCARGO_TARGET_TMPDIRenv). Using system tmp and deleting it regardless of test failure makes it hard to debug broken rust code emissions.
:speech_balloon: Firestar99 edited PR review comment.
Firestar99 updated PR #13319.
Firestar99 updated PR #13319.
Firestar99 commented on PR #13319:
Next iteration: propagate struct through sema's terms instead of reusing enums with no variant. This was surprisingly easy to do and found it to be cleaner than special-casing any enum variants already there.
:speech_balloon: Firestar99 edited PR review comment.
:speech_balloon: Firestar99 edited PR review comment.
Firestar99 updated PR #13319.
Firestar99 has marked PR #13319 as ready for review.
Firestar99 requested uweigand for a review on PR #13319.
Firestar99 requested wasmtime-compiler-reviewers for a review on PR #13319.
Firestar99 requested alexcrichton for a review on PR #13319.
Firestar99 requested wasmtime-default-reviewers for a review on PR #13319.
alexcrichton unassigned uweigand from PR #13319 isle struct support.
alexcrichton unassigned alexcrichton from PR #13319 isle struct support.
alexcrichton requested cfallin for a review on PR #13319.
:thumbs_up: cfallin submitted PR review:
Thanks! A few formatting nits but otherwise looks good to merge -- happy to do so once these are fixed.
:speech_balloon: cfallin created PR review comment:
blank line -- remove?
:speech_balloon: cfallin created PR review comment:
s/rust/Rust/ (and below)
:speech_balloon: cfallin created PR review comment:
Ah, OK, that makes sense -- thanks.
:speech_balloon: cfallin created PR review comment:
s/emum/enum/
Firestar99 updated PR #13319.
Firestar99 commented on PR #13319:
Cleaned up this and the tuple PR, though the latter may need a rebase after the merge. Not sure how available I'll be next week due to rustweek happening, but I'm sure I can squeeze in a rebase sometime.
:thumbs_up: cfallin submitted PR review:
Thanks!
cfallin added PR #13319 isle struct support to the merge queue.
:check: cfallin merged PR #13319.
cfallin removed PR #13319 isle struct support from the merge queue.
Last updated: Jun 01 2026 at 09:49 UTC