Skip to content

x64: remove Inst::AluRmiR #10687

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

abrown
Copy link
Contributor

@abrown abrown commented Apr 28, 2025

This change completely removes the Inst::AluRmiR variant along with associated code. It updates ABI code to use new Inst helpers and switches Winch to use the new assembler directly. More details in each commit; note that this significantly changes the disassembly tests.

abrown added 4 commits April 28, 2025 11:16
This change completely removes the `Inst::AluRmiR` variant along with
associated code. The only remaining place this was used was via the
`Inst::alu_rmi_r` helper, which is replaced by `Inst::add|sub|and|or...`
helpers.

The lowering, implemented here in Rust, is meant to mimic the behavior
also-encoded in ISLE. In discussions about this in the Cranelift
meeting, this duplication was of low concern. Nevertheless, this could
be improved in the future. In any case, this commit clearly identifies
the locations that build an ALU instruction in Rust: ABI logic, Winch,
and long-ish lowering sequences.
Up until now, Winch had been using the `Inst::alu_rmi_r` for generating
the instructions it needed to emit. With this helper now gone, we have a
chose: (a) continue using `Inst` helpers that use the new assembler or
(b) use the new assembler directly. This change adopts option (b).

Because of how `cranelift-codegen`'s register allocation works, we have
been passing a `PairedGpr` into the read-write slots of the new
assembler (this enables us to separate out the read-side and write-side
as separate virtual registers). For Winch to use this, we have to expose
`PairedGpr` via the now-public `isa::x64::inst::external` module.
@@ -31,6 +32,7 @@ use cranelift_codegen::{
};

use crate::reg::WritableReg;
use cranelift_assembler_x64 as asm;
Copy link
Contributor Author

@abrown abrown Apr 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@saulecabrera, this line is causing issues like the following:

error[E0432]: unresolved import `cranelift_assembler_x64`
  --> winch/codegen/src/isa/x64/asm.rs:35:5
   |
35 | use cranelift_assembler_x64 as asm;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no external crate `cranelift_assembler_x64`

For more information about this error, try `rustc --explain E0432`.

I believe this is because the cranelift-assembler-x64 dependency is optional and setting a feature in build.rs is too late for Cargo. What do you want to do? One option is to depend on cranelift-assembler-x64 unconditionally; another is just to set all-arch as a default feature. What do you think?

(I'm also interested in your comments on the rest of these Winch changes...)

@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator cranelift:area:x64 Issues related to x64 codegen labels Apr 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cranelift:area:x64 Issues related to x64 codegen cranelift Issues related to the Cranelift code generator
1 participant