Skip to content

Commit 30c8dcd

Browse files
committed
Add regalloc3 as an option for Cranelift's register allocator
1 parent b760c22 commit 30c8dcd

File tree

6 files changed

+63
-5
lines changed

6 files changed

+63
-5
lines changed

Cargo.lock

Lines changed: 53 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,3 +619,6 @@ debug = "line-tables-only"
619619
inherits = "release"
620620
codegen-units = 1
621621
lto = true
622+
623+
[patch.crates-io]
624+
regalloc2 = { git = "https://github.com/Amanieu/regalloc2.git", branch = "regalloc3" }

cranelift/codegen/meta/src/shared/settings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub(crate) fn define() -> SettingGroup {
4343
have adequate support for the kinds of allocations required by exception
4444
handling (https://github.com/bytecodealliance/regalloc2/issues/217).
4545
"#,
46-
vec!["backtracking"],
46+
vec!["backtracking", "regalloc3"],
4747
);
4848

4949
settings.add_enum(

cranelift/codegen/src/machinst/compile.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ pub fn compile<B: LowerBackend + TargetIsa>(
6666

6767
options.algorithm = match b.flags().regalloc_algorithm() {
6868
RegallocAlgorithm::Backtracking => Algorithm::Ion,
69+
RegallocAlgorithm::Regalloc3 => Algorithm::Regalloc3,
6970
// Note: single-pass is currently disabled
7071
// (https://github.com/bytecodealliance/regalloc2/issues/217).
7172
};

crates/cli-flags/src/opt.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ impl WasmtimeOptionValue for wasmtime::RegallocAlgorithm {
482482
fn parse(val: Option<&str>) -> Result<Self> {
483483
match String::parse(val)?.as_str() {
484484
"backtracking" => Ok(wasmtime::RegallocAlgorithm::Backtracking),
485+
"regalloc3" => Ok(wasmtime::RegallocAlgorithm::Regalloc3),
485486
other => bail!(
486487
"unknown regalloc algorithm`{}`, only backtracking,single-pass accepted",
487488
other

crates/wasmtime/src/config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,6 +1296,7 @@ impl Config {
12961296
pub fn cranelift_regalloc_algorithm(&mut self, algo: RegallocAlgorithm) -> &mut Self {
12971297
let val = match algo {
12981298
RegallocAlgorithm::Backtracking => "backtracking",
1299+
RegallocAlgorithm::Regalloc3 => "regalloc3",
12991300
};
13001301
self.compiler_config
13011302
.settings
@@ -2873,6 +2874,9 @@ pub enum RegallocAlgorithm {
28732874
/// results in better register utilization, producing fewer spills
28742875
/// and moves, but can cause super-linear compile runtime.
28752876
Backtracking,
2877+
2878+
/// New experimental register allocator.
2879+
Regalloc3,
28762880
}
28772881

28782882
/// Select which profiling technique to support.

0 commit comments

Comments
 (0)