Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
97f1e92
Move most things from std to core and alloc
the-ssd Dec 27, 2025
5301ec9
Port assembler_x64 to no_std
the-ssd Dec 27, 2025
d064db4
before adding prelude to each file
the-ssd Dec 27, 2025
f9b41c9
Most of the files now work with no_std
the-ssd Dec 27, 2025
a04639f
update isle to use alloc and core
the-ssd Dec 27, 2025
610034c
some instances shouldn't have been renamed, fixes cargo test
the-ssd Dec 27, 2025
8579235
add cranelift-assembler-x64 (no_std) to CI
the-ssd Dec 27, 2025
8a5fd53
fix codegen_meta, missed one spot with std::slice
the-ssd Dec 27, 2025
35ee796
automatically remove prelude with cargo fix
the-ssd Dec 27, 2025
3ca13bb
update isle changes
the-ssd Jan 1, 2026
cfb7501
update assembler changes
the-ssd Jan 1, 2026
339093c
update assembler changes
the-ssd Jan 1, 2026
4e3c723
use latest codegen changes + fix FxHash problem
the-ssd Jan 2, 2026
273766f
add imports
the-ssd Jan 2, 2026
97db7e2
fix floating issues with libm
the-ssd Jan 2, 2026
56f9077
remove unused import
the-ssd Jan 2, 2026
57f8847
temporarily remove OnceLock
the-ssd Jan 2, 2026
04a592c
add no_std arm support and add it into CI
the-ssd Jan 2, 2026
8a6fcfd
Move most things from std to core and alloc
the-ssd Dec 27, 2025
e1bf66f
Port assembler_x64 to no_std
the-ssd Dec 27, 2025
b027b8e
before adding prelude to each file
the-ssd Dec 27, 2025
cf49e28
Most of the files now work with no_std
the-ssd Dec 27, 2025
0e909fe
update isle to use alloc and core
the-ssd Dec 27, 2025
88fb4fd
some instances shouldn't have been renamed, fixes cargo test
the-ssd Dec 27, 2025
6d85585
add cranelift-assembler-x64 (no_std) to CI
the-ssd Dec 27, 2025
fe3194e
automatically remove prelude with cargo fix
the-ssd Dec 27, 2025
5624c4d
update isle changes
the-ssd Jan 1, 2026
5c37b88
update assembler changes
the-ssd Jan 1, 2026
775a0fc
update assembler changes
the-ssd Jan 1, 2026
d2eca41
use latest codegen changes + fix FxHash problem
the-ssd Jan 2, 2026
9e39486
add imports
the-ssd Jan 2, 2026
679d3ef
fix floating issues with libm
the-ssd Jan 2, 2026
dfe43e8
remove unused import
the-ssd Jan 2, 2026
74c85e8
temporarily remove OnceLock
the-ssd Jan 2, 2026
32c540e
add no_std arm support and add it into CI
the-ssd Jan 2, 2026
10e4f5d
Merge remote-tracking branch 'refs/remotes/origin/cranelift-nostd' in…
the-ssd Jan 3, 2026
bbbc105
Merge branch 'main' into cranelift-nostd
the-ssd Jan 5, 2026
c047e01
Move most things from std to core and alloc
the-ssd Dec 27, 2025
073a20c
Port assembler_x64 to no_std
the-ssd Dec 27, 2025
40a81e6
before adding prelude to each file
the-ssd Dec 27, 2025
8ebb4ef
Most of the files now work with no_std
the-ssd Dec 27, 2025
3ccba9f
update isle to use alloc and core
the-ssd Dec 27, 2025
6e2f58d
add cranelift-assembler-x64 (no_std) to CI
the-ssd Dec 27, 2025
3d88bcf
automatically remove prelude with cargo fix
the-ssd Dec 27, 2025
9163917
update isle changes
the-ssd Jan 1, 2026
d632990
update assembler changes
the-ssd Jan 1, 2026
135931b
use latest codegen changes + fix FxHash problem
the-ssd Jan 2, 2026
0d59194
add imports
the-ssd Jan 2, 2026
823dbba
fix floating issues with libm
the-ssd Jan 2, 2026
1d8bcd2
temporarily remove OnceLock
the-ssd Jan 2, 2026
9b01fa2
add no_std arm support and add it into CI
the-ssd Jan 2, 2026
723f889
revert Cargo.toml formating
the-ssd Jan 5, 2026
39c067d
remove prelude and fix cargo.toml
the-ssd Jan 5, 2026
8179d2c
cargo fmt
the-ssd Jan 5, 2026
48e2bd3
remove empty lines
the-ssd Jan 5, 2026
cea863f
bad renames
the-ssd Jan 5, 2026
4436bbf
macro_use only on no_std
the-ssd Jan 5, 2026
6eae76c
revert OnceLock change
the-ssd Jan 5, 2026
9b1b89d
only use stable libm features
the-ssd Jan 5, 2026
0f752f3
update regalloc2
the-ssd Jan 7, 2026
4355ea8
update comment
the-ssd Jan 7, 2026
e459e06
use continue instead
the-ssd Jan 7, 2026
bec5313
Update vets
alexcrichton Jan 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ cranelift-jit = { path = "cranelift/jit", version = "0.129.0" }
cranelift-fuzzgen = { path = "cranelift/fuzzgen" }
cranelift-bforest = { path = "cranelift/bforest", version = "0.129.0" }
cranelift-bitset = { path = "cranelift/bitset", version = "0.129.0" }
cranelift-control = { path = "cranelift/control", version = "0.129.0" }
cranelift-control = { path = "cranelift/control", version = "0.129.0", default-features = false }
cranelift-srcgen = { path = "cranelift/srcgen", version = "0.129.0" }
cranelift = { path = "cranelift/umbrella", version = "0.129.0" }

Expand All @@ -322,7 +322,7 @@ component-async-tests = { path = "crates/misc/component-async-tests" }

# Bytecode Alliance maintained dependencies:
# ---------------------------
regalloc2 = "0.13.3"
regalloc2 = "0.13.4"
wasip1 = { version = "1.0.0", default-features = false }

# cap-std family:
Expand Down Expand Up @@ -414,7 +414,7 @@ tracing-subscriber = { version = "0.3.20", default-features = false, features =
url = "2.5.7"
postcard = { version = "1.1.3", default-features = false, features = ['alloc'] }
criterion = { version = "0.7.0", default-features = false, features = ["html_reports", "rayon"] }
rustc-hash = "2.1.1"
rustc-hash = { version = "2.1.1", default-features = false }
libtest-mimic = "0.8.1"
semver = { version = "1.0.27", default-features = false }
ittapi = "0.4.0"
Expand Down
7 changes: 4 additions & 3 deletions cranelift/codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,21 @@ cranelift-entity = { workspace = true }
cranelift-bforest = { workspace = true }
cranelift-bitset = { workspace = true }
cranelift-control = { workspace = true }
hashbrown = { workspace = true }
hashbrown = { workspace = true, features = ["default-hasher"] }
target-lexicon = { workspace = true }
log = { workspace = true }
serde = { workspace = true, optional = true }
serde_derive = { workspace = true, optional = true }
pulley-interpreter = { workspace = true, optional = true }
postcard = { workspace = true, optional = true }
gimli = { workspace = true, features = ["write", "std"], optional = true }
gimli = { workspace = true, features = ["write"], optional = true }
smallvec = { workspace = true }
regalloc2 = { workspace = true, features = ["checker"] }
souper-ir = { version = "2.1.0", optional = true }
sha2 = { version = "0.10.2", optional = true }
rustc-hash = { workspace = true }
wasmtime-math = { workspace = true }
libm = { workspace = true }
# It is a goal of the cranelift-codegen crate to have minimal external dependencies.
# Please don't add any unless they are essential to the task of creating binary
# machine code. Integration tests that need external dependencies can be
Expand All @@ -65,7 +66,7 @@ default = ["std", "unwind", "host-arch", "timing"]
# The "std" feature enables use of libstd. The "core" feature enables use
# of some minimal std-like replacement libraries. At least one of these two
# features need to be enabled.
std = ["serde?/std"]
std = ["serde?/std", "rustc-hash/std", "gimli/std", "cranelift-control/fuzz"]

# The "core" feature used to enable a hashmap workaround, but is now
# deprecated (we (i) always use hashbrown, and (ii) don't support a
Expand Down
2 changes: 1 addition & 1 deletion cranelift/codegen/src/alias_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
//! must be correct likely reduce the potential benefit, we don't yet
//! do this.

use crate::{FxHashMap, FxHashSet};
use crate::{
cursor::{Cursor, FuncCursor},
dominator_tree::DominatorTree,
Expand All @@ -71,7 +72,6 @@ use crate::{
trace,
};
use cranelift_entity::{EntityRef, packed_option::PackedOption};
use rustc_hash::{FxHashMap, FxHashSet};

/// For a given program point, the vector of last-store instruction
/// indices for each disjoint category of abstract state.
Expand Down
2 changes: 1 addition & 1 deletion cranelift/codegen/src/egraph/elaborate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ use crate::ir::{Block, Function, Inst, Value, ValueDef};
use crate::loop_analysis::{Loop, LoopAnalysis};
use crate::scoped_hash_map::ScopedHashMap;
use crate::trace;
use crate::{FxHashMap, FxHashSet};
use alloc::vec::Vec;
use cranelift_control::ControlPlane;
use cranelift_entity::{EntitySet, SecondaryMap, packed_option::ReservedValue};
use rustc_hash::{FxHashMap, FxHashSet};
use smallvec::{SmallVec, smallvec};

pub(crate) struct Elaborator<'a> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Support for egraphs represented in the DataFlowGraph.

use crate::FxHashSet;
use crate::alias_analysis::{AliasAnalysis, LastStores};
use crate::ctxhash::{CtxEq, CtxHash, NullCtx};
use crate::cursor::{Cursor, CursorPosition, FuncCursor};
Expand All @@ -24,7 +25,6 @@ use core::hash::Hasher;
use cranelift_control::ControlPlane;
use cranelift_entity::SecondaryMap;
use cranelift_entity::packed_option::ReservedValue;
use rustc_hash::FxHashSet;
use smallvec::SmallVec;

mod cost;
Expand Down
11 changes: 7 additions & 4 deletions cranelift/codegen/src/ir/immediates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use core::fmt::{self, Display, Formatter};
use core::ops::{Add, BitAnd, BitOr, BitXor, Div, Mul, Neg, Not, Sub};
use core::str::FromStr;
use core::{i32, u32};
use libm::Libm;
#[cfg(feature = "enable-serde")]
use serde_derive::{Deserialize, Serialize};

Expand Down Expand Up @@ -682,27 +683,29 @@ macro_rules! ieee_float {
$(
/// Returns the square root of `self`.
pub fn sqrt(self) -> Self {
Self::with_float(self.$as_float().sqrt())
Self::with_float(Libm::<$float_ty>::sqrt(self.$as_float()))
}

/// Returns the smallest integer greater than or equal to `self`.
pub fn ceil(self) -> Self {
Self::with_float(self.$as_float().ceil())
Self::with_float(Libm::<$float_ty>::ceil(self.$as_float()))
}

/// Returns the largest integer less than or equal to `self`.
pub fn floor(self) -> Self {
Self::with_float(self.$as_float().floor())
Self::with_float(Libm::<$float_ty>::floor(self.$as_float()))
}

/// Returns the integer part of `self`. This means that non-integer numbers are always truncated towards zero.
pub fn trunc(self) -> Self {
Self::with_float(self.$as_float().trunc())
Self::with_float(Libm::<$float_ty>::trunc(self.$as_float()))
}

/// Returns the nearest integer to `self`. Rounds half-way cases to the number
/// with an even least significant digit.
pub fn round_ties_even(self) -> Self {
// TODO: when libm v0.2.16 is published line below can be used instead
// Self::with_float(Libm::<$float_ty>::roundeven(self.$as_float()))
Self::with_float(self.$as_float().round_ties_even())
}
)?
Expand Down
1 change: 1 addition & 0 deletions cranelift/codegen/src/isa/unwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub mod winx64;
#[cfg(feature = "unwind")]
pub mod winarm64;

#[cfg(feature = "unwind")]
/// CFA-based unwind information used on SystemV.
pub type CfaUnwindInfo = systemv::UnwindInfo;

Expand Down
3 changes: 3 additions & 0 deletions cranelift/codegen/src/isa/x64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ mod lower;
mod pcc;
pub mod settings;

#[cfg(feature = "unwind")]
pub use inst::unwind::systemv::create_cie;

/// An X64 backend.
Expand Down Expand Up @@ -217,6 +218,7 @@ pub fn emit_unwind_info(
) -> CodegenResult<Option<crate::isa::unwind::UnwindInfo>> {
use crate::isa::unwind::{UnwindInfo, UnwindInfoKind};
Ok(match kind {
#[cfg(feature = "unwind")]
UnwindInfoKind::SystemV => {
let mapper = self::inst::unwind::systemv::RegisterMapper;
Some(UnwindInfo::SystemV(
Expand All @@ -227,6 +229,7 @@ pub fn emit_unwind_info(
)?,
))
}
#[cfg(feature = "unwind")]
UnwindInfoKind::Windows => Some(UnwindInfo::WindowsX64(
crate::isa::unwind::winx64::create_unwind_info_from_insts::<
self::inst::unwind::winx64::RegisterMapper,
Expand Down
8 changes: 7 additions & 1 deletion cranelift/codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
allow(dead_code, reason = "see comment above")
)]

#[cfg_attr(not(feature = "std"), macro_use)]
extern crate alloc;

#[cfg(feature = "std")]
Expand All @@ -23,7 +24,12 @@ extern crate std;
#[cfg(not(feature = "std"))]
use hashbrown::{HashMap, HashSet, hash_map};
#[cfg(feature = "std")]
use std::collections::{HashMap, hash_map};
use std::collections::{HashMap, HashSet, hash_map};

/// Type alias for a hash map that uses the Fx hashing algorithm.
pub type FxHashMap<K, V> = HashMap<K, V, rustc_hash::FxBuildHasher>;
/// Type alias for a hash set that uses the Fx hashing algorithm.
pub type FxHashSet<V> = HashSet<V, rustc_hash::FxBuildHasher>;

pub use crate::context::Context;
pub use crate::value_label::{LabelValueLoc, ValueLabelsRanges, ValueLocRange};
Expand Down
2 changes: 1 addition & 1 deletion cranelift/codegen/src/machinst/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
//! ABI. See each platform's `abi.rs` implementation for details.

use crate::CodegenError;
use crate::FxHashMap;
use crate::HashMap;
use crate::entity::SecondaryMap;
use crate::ir::{ArgumentExtension, ArgumentPurpose, ExceptionTag, Signature};
Expand All @@ -110,7 +111,6 @@ use crate::{machinst::*, trace};
use alloc::boxed::Box;
use core::marker::PhantomData;
use regalloc2::{MachineEnv, PReg, PRegSet};
use rustc_hash::FxHashMap;
use smallvec::smallvec;

/// A small vector of instructions (with some reasonable size); appropriate for
Expand Down
2 changes: 1 addition & 1 deletion cranelift/codegen/src/machinst/blockorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ use crate::dominator_tree::DominatorTree;
use crate::entity::SecondaryMap;
use crate::inst_predicates::visit_block_succs;
use crate::ir::{Block, Function, Inst, Opcode};
use crate::{FxHashMap, FxHashSet};
use crate::{machinst::*, trace};
use rustc_hash::{FxHashMap, FxHashSet};

/// Mapping from CLIF BBs to VCode BBs.
#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion cranelift/codegen/src/machinst/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub fn compile<B: LowerBackend + TargetIsa>(
// Run the regalloc checker, if requested.
if b.flags().regalloc_checker() {
let _tt = timing::regalloc_checker();
let mut checker = regalloc2::checker::Checker::new(&vcode, vcode.abi.machine_env());
let mut checker = regalloc2::checker::Checker::new(&vcode, &vcode.abi.machine_env());
checker.prepare(&regalloc_result);
checker
.run()
Expand Down
2 changes: 1 addition & 1 deletion cranelift/codegen/src/machinst/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ use crate::machinst::{
};
use crate::settings::Flags;
use crate::{CodegenError, CodegenResult, trace};
use crate::{FxHashMap, FxHashSet};
use alloc::vec::Vec;
use core::fmt::Debug;
use cranelift_control::ControlPlane;
use rustc_hash::{FxHashMap, FxHashSet};
use smallvec::{SmallVec, smallvec};

use super::{VCodeBuildDirection, VRegAllocator};
Expand Down
26 changes: 16 additions & 10 deletions cranelift/codegen/src/machinst/vcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
//! backend pipeline.

use crate::CodegenError;
use crate::FxHashMap;
use crate::ir::pcc::*;
use crate::ir::{self, Constant, ConstantData, ValueLabel, types};
use crate::ranges::Ranges;
Expand All @@ -29,7 +30,6 @@ use regalloc2::{
Edit, Function as RegallocFunction, InstOrEdit, InstPosition, InstRange, Operand,
OperandConstraint, OperandKind, PRegSet, ProgPoint, RegClass,
};
use rustc_hash::FxHashMap;

use crate::HashMap;
use crate::hash_map::Entry;
Expand Down Expand Up @@ -1274,15 +1274,21 @@ impl<I: VCodeInst> VCode<I> {
let loc = if let Some(preg) = alloc.as_reg() {
LabelValueLoc::Reg(Reg::from(preg))
} else {
let slot = alloc.as_stack().unwrap();
let slot_offset = self.abi.get_spillslot_offset(slot);
let slot_base_to_caller_sp_offset = self.abi.slot_base_to_caller_sp_offset();
let caller_sp_to_cfa_offset =
crate::isa::unwind::systemv::caller_sp_to_cfa_offset();
// NOTE: this is a negative offset because it's relative to the caller's SP
let cfa_to_sp_offset =
-((slot_base_to_caller_sp_offset + caller_sp_to_cfa_offset) as i64);
LabelValueLoc::CFAOffset(cfa_to_sp_offset + slot_offset)
#[cfg(not(feature = "unwind"))]
continue;

#[cfg(feature = "unwind")]
{
let slot = alloc.as_stack().unwrap();
let slot_offset = self.abi.get_spillslot_offset(slot);
let slot_base_to_caller_sp_offset = self.abi.slot_base_to_caller_sp_offset();
let caller_sp_to_cfa_offset =
crate::isa::unwind::systemv::caller_sp_to_cfa_offset();
// NOTE: this is a negative offset because it's relative to the caller's SP
let cfa_to_sp_offset =
-((slot_base_to_caller_sp_offset + caller_sp_to_cfa_offset) as i64);
LabelValueLoc::CFAOffset(cfa_to_sp_offset + slot_offset)
}
};

// Coalesce adjacent ranges that for the same location
Expand Down
2 changes: 1 addition & 1 deletion cranelift/codegen/src/remove_constant_phis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use crate::ir;
use crate::ir::Function;
use crate::ir::{Block, BlockArg, BlockCall, Inst, Value};
use crate::timing;
use crate::{FxHashMap, FxHashSet};
use bumpalo::Bump;
use cranelift_entity::SecondaryMap;
use rustc_hash::{FxHashMap, FxHashSet};
use smallvec::SmallVec;

// A note on notation. For the sake of clarity, this file uses the phrase
Expand Down
4 changes: 2 additions & 2 deletions supply-chain/imports.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1327,8 +1327,8 @@ user-login = "dtolnay"
user-name = "David Tolnay"

[[publisher.regalloc2]]
version = "0.13.3"
when = "2025-11-13"
version = "0.13.4"
when = "2026-01-06"
user-id = 3726
user-login = "cfallin"
user-name = "Chris Fallin"
Expand Down
Loading