-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stub of a new isel backend for x64 #1605
Conversation
Subscribe to Label Actioncc @bnjbvr
This issue or pull request has been labeled: "cranelift", "cranelift:meta"
Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
Overall this looks fine to me. My only real request is: I'd prefer that the instruction-fragment definitions ( |
I did quite like the separation of it, since the |
Hi @bnjbvr. Do you think any example should show some signs of life here? I tried a simple module that adds to numbers with the current isel and got what I assume is expected results but running through the new isel there were no error messages or panics .. it just hung. Is this expected? |
It's likely I went through compilation, but not actually running the code in wasmtime (since there seems to be no way to pass Cranelift CLI args through wasmtime runner). I have used the following simple wasm module:
compiled to wasm binary, and then, from Cranelift's directory (so as to use
|
Thanks all for the first round of comments! Many things we could do later on so as to improve this code (especially with respect to naming, and respecting Rust standards in general). I just checked, and the simple module from the above comment works in Spidermonkey (with a few tweaks on the Spidermonkey side to make it use the new backend), which is a good sign. |
cranelift/codegen/src/isa/x64/abi.rs
Outdated
for param in &f.signature.params { | ||
match param.purpose { | ||
ir::ArgumentPurpose::VMContext if f.signature.call_conv.extends_baldrdash() => { | ||
// VmContext is r14 in Baldrdash. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// VmContext is r14 in Baldrdash. | |
// `VMContext` is `r14` in Baldrdash. |
pub(crate) fn get_enc(&self) -> u8 { | ||
*self as u8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub(crate) fn get_enc(&self) -> u8 { | |
*self as u8 | |
pub(crate) fn get_enc(self) -> u8 { | |
self as u8 |
CC
is copy
Ahh thanks ... this worked. The difference was the ordering of the parameters. This works:
While this hung:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @bnjbvr said, there are plenty of things to improve but this seems like a good start. Once merged, it will be easier to iterate on this since the PRs should be fewer lines.
What's the plan for supporting x86_32? The old backend was generic over the word size; this one doesn't seem to be. Does the new approach allow to make such a generic backend, or is it necessary to duplicate all the shared code? |
This question is still open for design. In my opinion, if it doesn't imply a huge cost on the x64 backend in terms of maintainability and readability, we should try to share and reuse as much as we can. |
…election; Most of the work is credited to Julian Seward. Co-authored-by: Julian Seward <[email protected]> Co-authored-by: Chris Fallin <[email protected]>
Thanks for the reviews and new comments again! Will merge if CI passes. |
This is a draft-ish PR containing a rebase of Julian's x64 work on the new isel backend, including quite a few refactorings of mine. During today's Cranelift meeting, we agreed that it might make sense to add the incomplete backend here, allowing incremental development by more contributors.
I've tried to split the files in a way that was similar to the aarch64 backend, but some things might still be wobbly; I might check this a bit further more tomorrow. Of course, that's also something we could do as follow-up PRs.
The new x64 backend is controlled by a new Cargo feature
x64
(which also requiresx86
). Then, users ofclif-util
can use the--target x86_64
argument, and:--set use_new_backend
and this will use the new isel backend. (Expect panics, unimplemented errors, etc.)Second (small) commit is what allows passing ISA-specific flags to
--set
, which wasn't implemented yet.