alexcrichton opened PR #9760 from alexcrichton:pulley-generate-isle
to bytecodealliance:main
:
This commit is an integration of the
for_each_op!
macro (and extended ops) for Cranelift. This procedurally generates a few new items for Cranelift's Pulley backend to use:
RawInst
- a raw enumeration of instructions as-is.- ISLE constructors (e.g.
pulley_*
ctors) - generated for all of theRawInst
variants.- Register allocation methods for
RawInst
- Pretty printing methods for
RawInst
- Emission methods for
RawInst
The
Inst
enum now has aRaw
variant which contains aRawInst
. In this manner the mainInst
enum can still have pseudo-insts likeCall
, polymorphic instructions like loads/stores (probably gonna get refactored in the future though), and slightly different representations such asInst::Trap
having aTrapCode
andRawInst::Trap
wouldn't.The goal of this commit is to lower the amount of effort to quickly add and experiment with new instructions in Pulley. Ideally it's now just (a) define them in the pulley macro, (b) implement a direct lowering rule, and (c) implement it in the interpreter. Ideally no need to implement anything else inside of Cranelift as everything should be auto-generated.
Many existing
Inst
variants have been deleted in favor of their equivalents inRawInst
now. This undeniably increases the complexity of the Pulley backend but at least for me I find it well worth it to have all this boilerplate generated automatically.<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
alexcrichton requested wasmtime-default-reviewers for a review on PR #9760.
alexcrichton requested abrown for a review on PR #9760.
alexcrichton requested wasmtime-compiler-reviewers for a review on PR #9760.
alexcrichton commented on PR #9760:
Heh I was going to cc you @abrown on this as it's definitely related to your assembler work for x64 which I haven't reviewed myself yet. You're tagged as a reviewer here though so works well :)
If you've tried out various patterns for x64 that work well I'd be happy to update Pulley to match said patterns as well.
alexcrichton updated PR #9760.
alexcrichton updated PR #9760.
alexcrichton updated PR #9760.
alexcrichton commented on PR #9760:
The final commit of https://github.com/bytecodealliance/wasmtime/pull/9765 is an example of how adding a new instruction after this PR requires relatively minimal boilerplate (yay!)
fitzgen submitted PR review:
This looks great -- I'm going to go ahead and merge and if @abrown has feedback on the meta generation approach, we can address it in follow ups. This unblocks more pulley work, and the guide, and all that though, so I think it is important to move forward here now.
fitzgen merged PR #9760.
Yeah, I recognize a lot of the same needs as in what I'm doing (
assembler-collaborate
). The assembler might get more involved but essentially I'll be doing similar things; I need to remember that this is where I put my newly-generated ISLE!
Last updated: Dec 23 2024 at 12:05 UTC