isle struct support#13319
Conversation
| match variant { | ||
| None => Constraint::Struct { | ||
| fields, | ||
| ty: input_ty, | ||
| }, | ||
| Some(variant) => Constraint::Variant { | ||
| fields, | ||
| ty: input_ty, | ||
| variant, | ||
| }, |
There was a problem hiding this 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.
cfallin
left a comment
There was a problem hiding this comment.
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.
| let tempdir = tempfile::tempdir().unwrap(); | ||
| let code = build(isle_filename).unwrap(); | ||
|
|
||
| fn build_and_link_isle(isle_filename: &str) -> (PathBuf, PathBuf) { |
There was a problem hiding this comment.
The changes here seem unrelated to struct support?
There was a problem hiding this 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.
Also squashed in a minor fixup into that commit, removing the tempdir dep from [dev-dependencies], that is if you want to keep this change.
Subscribe to Label ActionDetailsThis 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 |
Using system tmp and deleting it even if the test failed makes it hard to debug broken rust code emissions
|
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. |
I have a code generator that creates rust code similar to this:
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:
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.