Stream: git-wasmtime

Topic: wasmtime / PR #13319 isle `struct` support


view this post on Zulip Wasmtime GitHub notifications bot (May 07 2026 at 19:14):

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.

view this post on Zulip Wasmtime GitHub notifications bot (May 07 2026 at 19:14):

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.

view this post on Zulip Wasmtime GitHub notifications bot (May 07 2026 at 19:20):

:memo: Firestar99 submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (May 07 2026 at 19:20):

: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 VariantId optional everywhere. This is the only place where anything actually matches on it, which allows my code changes to be quite minimal in this area.

view this post on Zulip Wasmtime GitHub notifications bot (May 07 2026 at 19:25):

: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.

view this post on Zulip Wasmtime GitHub notifications bot (May 07 2026 at 19:25):

:speech_balloon: cfallin created PR review comment:

LIkewise here -- let's model the domain a bit more closely.

view this post on Zulip Wasmtime GitHub notifications bot (May 07 2026 at 19:25):

:speech_balloon: cfallin created PR review comment:

Likewise here, let's not overload the meaning of Some/None in a somewhat ad-hoc way. Maybe we should have a StructOrEnumVariant enum, take that here, and use that in the EnumVariant enum arm above?

view this post on Zulip Wasmtime GitHub notifications bot (May 07 2026 at 19:25):

:speech_balloon: cfallin created PR review comment:

Rather than overload EnumVariant here and give it no inner information for structs, let's add a Struct TermKind.

view this post on Zulip Wasmtime GitHub notifications bot (May 07 2026 at 19:25):

:speech_balloon: cfallin created PR review comment:

If we separate out the struct case here, why do we make the variant IDs Options above?

view this post on Zulip Wasmtime GitHub notifications bot (May 07 2026 at 19:25):

:speech_balloon: cfallin created PR review comment:

The changes here seem unrelated to struct support?

view this post on Zulip Wasmtime GitHub notifications bot (May 07 2026 at 22:03):

github-actions[bot] added the label cranelift on PR #13319.

view this post on Zulip Wasmtime GitHub notifications bot (May 07 2026 at 22:03):

github-actions[bot] added the label isle on PR #13319.

view this post on Zulip Wasmtime GitHub notifications bot (May 07 2026 at 22:03):

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:

To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.

Learn more.
</details>

view this post on Zulip Wasmtime GitHub notifications bot (May 08 2026 at 09:01):

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.

view this post on Zulip Wasmtime GitHub notifications bot (May 08 2026 at 09:03):

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>/ (via CARGO_TARGET_TMPDIR env). Using system tmp and deleting it regardless of test failure makes it hard to debug broken rust code emissions.

view this post on Zulip Wasmtime GitHub notifications bot (May 08 2026 at 09:03):

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>/ (via CARGO_TARGET_TMPDIR env). Using system tmp and deleting it regardless of test failure makes it hard to debug broken rust code emissions.

view this post on Zulip Wasmtime GitHub notifications bot (May 08 2026 at 09:04):

:memo: Firestar99 submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (May 08 2026 at 09:04):

: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>/ (via CARGO_TARGET_TMPDIR env). Using system tmp and deleting it regardless of test failure makes it hard to debug broken rust code emissions.

view this post on Zulip Wasmtime GitHub notifications bot (May 08 2026 at 09:24):

:speech_balloon: Firestar99 edited PR review comment.

view this post on Zulip Wasmtime GitHub notifications bot (May 08 2026 at 10:00):

Firestar99 updated PR #13319.

view this post on Zulip Wasmtime GitHub notifications bot (May 08 2026 at 10:05):

Firestar99 updated PR #13319.

view this post on Zulip Wasmtime GitHub notifications bot (May 08 2026 at 10:05):

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.

view this post on Zulip Wasmtime GitHub notifications bot (May 08 2026 at 10:06):

:speech_balloon: Firestar99 edited PR review comment.

view this post on Zulip Wasmtime GitHub notifications bot (May 08 2026 at 10:06):

:speech_balloon: Firestar99 edited PR review comment.

view this post on Zulip Wasmtime GitHub notifications bot (May 11 2026 at 16:39):

Firestar99 updated PR #13319.

view this post on Zulip Wasmtime GitHub notifications bot (May 11 2026 at 16:49):

Firestar99 has marked PR #13319 as ready for review.

view this post on Zulip Wasmtime GitHub notifications bot (May 11 2026 at 16:49):

Firestar99 requested uweigand for a review on PR #13319.

view this post on Zulip Wasmtime GitHub notifications bot (May 11 2026 at 16:49):

Firestar99 requested wasmtime-compiler-reviewers for a review on PR #13319.

view this post on Zulip Wasmtime GitHub notifications bot (May 11 2026 at 16:49):

Firestar99 requested alexcrichton for a review on PR #13319.

view this post on Zulip Wasmtime GitHub notifications bot (May 11 2026 at 16:49):

Firestar99 requested wasmtime-default-reviewers for a review on PR #13319.

view this post on Zulip Wasmtime GitHub notifications bot (May 11 2026 at 19:47):

alexcrichton unassigned uweigand from PR #13319 isle struct support.

view this post on Zulip Wasmtime GitHub notifications bot (May 11 2026 at 19:47):

alexcrichton unassigned alexcrichton from PR #13319 isle struct support.

view this post on Zulip Wasmtime GitHub notifications bot (May 11 2026 at 19:47):

alexcrichton requested cfallin for a review on PR #13319.

view this post on Zulip Wasmtime GitHub notifications bot (May 12 2026 at 16:31):

: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.

view this post on Zulip Wasmtime GitHub notifications bot (May 12 2026 at 16:31):

:speech_balloon: cfallin created PR review comment:

blank line -- remove?

view this post on Zulip Wasmtime GitHub notifications bot (May 12 2026 at 16:31):

:speech_balloon: cfallin created PR review comment:

s/rust/Rust/ (and below)

view this post on Zulip Wasmtime GitHub notifications bot (May 12 2026 at 16:31):

:speech_balloon: cfallin created PR review comment:

Ah, OK, that makes sense -- thanks.

view this post on Zulip Wasmtime GitHub notifications bot (May 12 2026 at 16:31):

:speech_balloon: cfallin created PR review comment:

s/emum/enum/

view this post on Zulip Wasmtime GitHub notifications bot (May 17 2026 at 10:05):

Firestar99 updated PR #13319.

view this post on Zulip Wasmtime GitHub notifications bot (May 17 2026 at 10:11):

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.

view this post on Zulip Wasmtime GitHub notifications bot (May 18 2026 at 19:16):

:thumbs_up: cfallin submitted PR review:

Thanks!

view this post on Zulip Wasmtime GitHub notifications bot (May 18 2026 at 19:16):

cfallin added PR #13319 isle struct support to the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (May 18 2026 at 19:41):

:check: cfallin merged PR #13319.

view this post on Zulip Wasmtime GitHub notifications bot (May 18 2026 at 19:41):

cfallin removed PR #13319 isle struct support from the merge queue.


Last updated: Jun 01 2026 at 09:49 UTC