saulecabrera opened PR #4907 from winch-skeleton
to main
:
Ref: https://github.com/bytecodealliance/rfcs/pull/28
This change introduces the initial skeleton for Winch, the "baseline" compiler.
This skeleton contains mostly setup code for the ISA, ABI, registers, and compilation environment abstractions. It also includes the calculation of function local slots.
As of the first commit, the structure of these abstractions looks like the following:
+------------------------+ | v +----------+ +-----+ +-----------+-----+-----------------+ | Compiler | --> | ISA | --> | Registers | ABI | Compilation Env | +----------+ +-----+ +-----------+-----+-----------------+ | ^ +------------------------------+
I'm opening this as a draft, since there are several items that I'd like to finish before continuing to iterate in-tree, namely:
- [ ] Prologue
- [ ] Function body with (debug)
i32.add
support- [ ] Epilogue
- [ ] Initial skeleton of a (debug) Assembler interface
- [ ] Increase test coverage and include unit tests in CI
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
saulecabrera updated PR #4907 from winch-skeleton
to main
.
saulecabrera updated PR #4907 from winch-skeleton
to main
.
bjorn3 created PR review comment:
This should probably replaced with features on winch that enable the respective feature of cranelift-codegen and additionally enabling the target architecture if no architecture is selected, just like for cranelift-codegen.
bjorn3 submitted PR review.
saulecabrera updated PR #4907 from winch-skeleton
to main
.
saulecabrera updated PR #4907 from winch-skeleton
to main
.
saulecabrera updated PR #4907 from winch-skeleton
to main
.
saulecabrera updated PR #4907 from winch-skeleton
to main
.
saulecabrera updated PR #4907 from winch-skeleton
to main
.
saulecabrera updated PR #4907 from winch-skeleton
to main
.
saulecabrera updated PR #4907 from winch-skeleton
to main
.
saulecabrera updated PR #4907 from winch-skeleton
to main
.
saulecabrera updated PR #4907 from winch-skeleton
to main
.
saulecabrera updated PR #4907 from winch-skeleton
to main
.
saulecabrera updated PR #4907 from winch-skeleton
to main
.
saulecabrera updated PR #4907 from winch-skeleton
to main
.
saulecabrera edited PR #4907 from winch-skeleton
to main
:
Ref: https://github.com/bytecodealliance/rfcs/pull/28
This change introduces the initial skeleton for Winch, the "baseline" compiler.
This skeleton contains mostly setup code for the ISA, ABI, registers, and compilation environment abstractions. It also includes the calculation of function local slots.
As of the first commit, the structure of these abstractions looks like the following:
+------------------------+ | v +----------+ +-----+ +-----------+-----+-----------------+ | Compiler | --> | ISA | --> | Registers | ABI | Compilation Env | +----------+ +-----+ +-----------+-----+-----------------+ | ^ +------------------------------+
I'm opening this as a draft, since there are several items that I'd like to finish before continuing to iterate in-tree, namely:
- [x] Prologue
- [ ] Function body with (debug)
i32.add
support- [ ] Epilogue
- [ ] Initial skeleton of a (debug) Assembler interface
- [ ] Increase test coverage and include unit tests in CI
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
saulecabrera edited PR #4907 from winch-skeleton
to main
:
Ref: https://github.com/bytecodealliance/rfcs/pull/28
This change introduces the initial skeleton for Winch, the "baseline" compiler.
This skeleton contains mostly setup code for the ISA, ABI, registers, and compilation environment abstractions. It also includes the calculation of function local slots.
As of the first commit, the structure of these abstractions looks like the following:
+------------------------+ | v +----------+ +-----+ +-----------+-----+-----------------+ | Compiler | --> | ISA | --> | Registers | ABI | Compilation Env | +----------+ +-----+ +-----------+-----+-----------------+ | ^ +------------------------------+
I'm opening this as a draft, since there are several items that I'd like to finish before continuing to iterate in-tree, namely:
- [x] Prologue
- [x] Function body with (debug)
i32.add
support- [ ] Epilogue
- [ ] Initial skeleton of a (debug) Assembler interface
- [ ] Increase test coverage and include unit tests in CI
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
saulecabrera edited PR #4907 from winch-skeleton
to main
:
Ref: https://github.com/bytecodealliance/rfcs/pull/28
This change introduces the initial skeleton for Winch, the "baseline" compiler.
This skeleton contains mostly setup code for the ISA, ABI, registers, and compilation environment abstractions. It also includes the calculation of function local slots.
As of the first commit, the structure of these abstractions looks like the following:
+------------------------+ | v +----------+ +-----+ +-----------+-----+-----------------+ | Compiler | --> | ISA | --> | Registers | ABI | Compilation Env | +----------+ +-----+ +-----------+-----+-----------------+ | ^ +------------------------------+
I'm opening this as a draft, since there are several items that I'd like to finish before continuing to iterate in-tree, namely:
- [x] Prologue
- [x] Function body with (debug)
i32.add
support- [x] Epilogue
- [ ] Initial skeleton of a (debug) Assembler interface
- [ ] Increase test coverage and include unit tests in CI
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
saulecabrera edited PR #4907 from winch-skeleton
to main
:
Ref: https://github.com/bytecodealliance/rfcs/pull/28
This change introduces the initial skeleton for Winch, the "baseline" compiler.
This skeleton contains mostly setup code for the ISA, ABI, registers, and compilation environment abstractions. It also includes the calculation of function local slots.
As of the first commit, the structure of these abstractions looks like the following:
+------------------------+ | v +----------+ +-----+ +-----------+-----+-----------------+ | Compiler | --> | ISA | --> | Registers | ABI | Compilation Env | +----------+ +-----+ +-----------+-----+-----------------+ | ^ +------------------------------+
I'm opening this as a draft, since there are several items that I'd like to finish before continuing to iterate in-tree, namely:
- [x] Prologue
- [x] Function body with (debug)
i32.add
support- [x] Epilogue
- [x] Initial skeleton of a (debug) Assembler interface
- [ ] Increase test coverage and include unit tests in CI
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
saulecabrera updated PR #4907 from winch-skeleton
to main
.
saulecabrera updated PR #4907 from winch-skeleton
to main
.
saulecabrera edited PR #4907 from winch-skeleton
to main
:
Ref: https://github.com/bytecodealliance/rfcs/pull/28
This change introduces the initial skeleton for Winch, the "baseline" compiler.
This skeleton contains mostly setup code for the ISA, ABI, registers, and compilation environment abstractions. It also includes the calculation of function local slots.
As of the first commit, the structure of these abstractions looks like the following:
+------------------------+ | v +----------+ +-----+ +-----------+-----+-----------------+ | Compiler | --> | ISA | --> | Registers | ABI | Compilation Env | +----------+ +-----+ +-----------+-----+-----------------+ | ^ +------------------------------+
I'm opening this as a draft, since there are several items that I'd like to finish before continuing to iterate in-tree, namely:
- [x] Prologue
- [x] Function body with (debug)
i32.add
support- [x] Epilogue
- [x] Initial skeleton of a (debug) Assembler interface
<!--Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
saulecabrera edited PR #4907 from winch-skeleton
to main
:
Ref: https://github.com/bytecodealliance/rfcs/pull/28
This change introduces the initial skeleton for Winch, the "baseline" compiler.
This skeleton contains mostly setup code for the ISA, ABI, registers, and compilation environment abstractions. It also includes the calculation of function local slots.
As of the first commit, the structure of these abstractions looks like the following:
+------------------------+ | v +----------+ +-----+ +-----------+-----+-----------------+ | Compiler | --> | ISA | --> | Registers | ABI | Compilation Env | +----------+ +-----+ +-----------+-----+-----------------+ | ^ +------------------------------+
I'm opening this as a draft, since there are several items that I'd like to finish before continuing to iterate in-tree, namely:
- [x] Prologue
- [x] Function body with (debug)
i32.add
,local.get
andlocal.set
support- [x] Epilogue
- [x] Initial skeleton of a (debug) MacroAssembler and Assembler (x64) interface
<!--Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
saulecabrera edited PR #4907 from winch-skeleton
to main
:
This change introduces the initial skeleton for Winch, the "baseline" compiler, discussed https://github.com/bytecodealliance/rfcs/pull/28
The skeleton contains the just the necessary code for the main abstractions to support the following:
- Function prologue and epilogue (excluding stack checks)
- Calculation of local slots
- An initial pass on a generic MacroAssembler interface
- An initial pass on a x64 Assembler
- A simple CLI tools to compile WebAssembly programs (
crates/winch/src/main.rs
)- String based emission for programs that use the following WebAssembly instructions:
i32.add
,local.get
,local.set
As of this change, the high-level structure of the compiler is as follows:
+-----------------------+ | | | +-----------+ +---------------------+ | | Compiler | ---> | ISA | ---------------------------------------------------------------+ | +-----------+ +---------------------+ | | | | | | | | v | | +-----------+-----+----------------------+ +----------------+ +-------+----------------+-------+ | +> | Registers | ABI | CodeGen | --> | CodeGenContext | --> | Frame | MacroAssembler | Stack | | +-----------+-----+----------------------+ +----------------+ +-------+----------------+-------+ | ^ | | +-----+------------------------------------------------------------------------------------+ | | | v +---------------------+ | Register Allocation | +---------------------+
Next steps
As mentioned above, this change doesn't use any of Cranelift's backends for code emission, yet. These are the immediate next steps after landing this change:
- Extract the relevant Cranelift pieces into the
cranelift_asm
crate, which will be used by Winch- Swap the string based implementation of the x64 assembler and use the assembler provided by
cranelift_asm
- Add initial support for arm64 through
cranelift_asm
- Increase test coverage
Misc
Winch's CLI can be used by running `cargo run -- path/to/file.wat --target=<target>
Here's a set of WebAssembly programs and their corresponding x64 output:
<details>
<summary>Basic i32 add</summary>(module (export "main" (func $main)) (func $main (result i32) (i32.const 10) (i32.const 20) i32.add) )
push rbp mov rbp, rsp mov eax, 10 add eax, 20 pop rbp ret
</details>
<details>
<summary> i32 add with local operators </summary>(module (export "main" (func $main)) (func $main (result i32) (local $foo i32) (local $bar i32) (i32.const 10) (local.set $foo) (i32.const 20) (local.set $bar) (local.get $foo) (local.get $bar) i32.add ) )
push rbp mov rbp, rsp sub rsp, 8 mov qword [rsp], 0 mov eax, 10 mov [rsp + 4], eax mov ecx, 20 mov [rsp], ecx mov eax, [rsp] mov edx, [rsp + 4] add edx, eax mov rax, rdx add rsp, 8 pop rbp ret
</details>
<details>
<summary>Basic i32 with function arguments </summary>(module (export "main" (func $main)) (func $main (param i32) (param i32) (result i32) (local.get 0) (local.get 1) i32.add ) )
push rbp mov rbp, rsp sub rsp, 8 mov [rsp + 4], edi mov [rsp], esi mov eax, [rsp] mov ecx, [rsp + 4] add ecx, eax mov rax, rcx add rsp, 8 pop rbp ret
</details>
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
- [ ] This has been discussed in issue #..., or if not, please tell us why
here.- [ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.- [ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the
[message truncated]
Last updated: Nov 22 2024 at 17:03 UTC