-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cranelift: Add a new backend for emitting Pulley bytecode (#9089)
* Cranelift: Add a new backend for emitting Pulley bytecode This commit adds two new backends for Cranelift that emits 32- and 64-bit Pulley bytecode. The backends are both actually the same, with a common implementation living in `cranelift/codegen/src/isa/pulley_shared`. Each backend configures an ISA flag that determines the pointer size, and lowering inspects this flag's value when lowering memory accesses. To avoid multiple ISLE compilation units, and to avoid compiling duplicate copies of Pulley's generated `MInst`, I couldn't use `MInst` as the `MachInst` implementation directly. Instead, there is an `InstAndKind` type that is a newtype over the generated `MInst` but which also carries a phantom type parameter that implements the `PulleyTargetKind` trait. There are two implementations of this trait, a 32- and 64-bit version. This is necessary because there are various static trait methods for the mach backend which we must implement, and which return the pointer width, but don't have access to any `self`. Therefore, we are forced to monomorphize some amount of code. This type parameter is fairly infectious, and all the "big" backend types (`PulleyBackend<P>`, `PulleyABICallSite<P>`, etc...) are parameterized over it. Nonetheless, not everything is parameterized over a `PulleyTargetKind`, and we manage to avoid duplicate `MInst` definitions and lowering code. Note that many methods are still stubbed out with `todo!`s. It is expected that we will fill in those implementations as the work on Pulley progresses. * Trust the `pulley-interpreter` crate, as it is part of our workspace * fix some clippy warnings * Fix a dead-code warning from inside generated code * Use a helper for emitting br_if+comparison instructions * Add a helper for converting `Reg` to `pulley_interpreter::XReg` * Add version to pulley workspace dependency * search the pulley directory for crates in the publish script
- Loading branch information
Showing
60 changed files
with
8,081 additions
and
22 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use crate::cdsl::{isa::TargetIsa, settings::SettingGroupBuilder}; | ||
|
||
pub(crate) fn define() -> TargetIsa { | ||
let mut settings = SettingGroupBuilder::new("pulley"); | ||
settings.add_enum( | ||
"pointer_width", | ||
"The width of pointers for this Pulley target", | ||
"Supported values:\n\ | ||
* 'pointer32'\n\ | ||
* 'pointer64'\n", | ||
vec!["pointer32", "pointer64"], | ||
); | ||
TargetIsa::new("pulley", settings.build()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
pub use super::pulley_shared::isa_builder; | ||
|
||
use super::pulley_shared::PulleyTargetKind; | ||
use crate::isa::pulley_shared::PointerWidth; | ||
|
||
#[derive(Debug, Default, Clone, Copy)] | ||
pub(crate) struct Pulley32; | ||
|
||
impl PulleyTargetKind for Pulley32 { | ||
fn pointer_width() -> PointerWidth { | ||
PointerWidth::PointerWidth32 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
pub use super::pulley_shared::isa_builder; | ||
|
||
use super::pulley_shared::PulleyTargetKind; | ||
use crate::isa::pulley_shared::PointerWidth; | ||
|
||
#[derive(Debug, Default, Clone, Copy)] | ||
pub(crate) struct Pulley64; | ||
|
||
impl PulleyTargetKind for Pulley64 { | ||
fn pointer_width() -> PointerWidth { | ||
PointerWidth::PointerWidth64 | ||
} | ||
} |
Oops, something went wrong.