Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions cranelift/codegen/meta/src/gen_inst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ fn gen_instruction_data_impl(formats: &[Rc<InstructionFormat>], fmt: &mut Format
(Some("args.as_slice(pool)"), "args.len(pool)")
} else if format.num_value_operands == 1 {
members.push("ref arg");
(Some("std::slice::from_ref(arg)"), "1")
(Some("core::slice::from_ref(arg)"), "1")
} else if format.num_value_operands > 0 {
members.push("ref args");
(Some("args"), "args.len()")
Expand All @@ -324,7 +324,7 @@ fn gen_instruction_data_impl(formats: &[Rc<InstructionFormat>], fmt: &mut Format
0 => None,
1 => {
members.push("ref destination");
Some(("std::slice::from_ref(destination)", "1"))
Some(("core::slice::from_ref(destination)", "1"))
}
_ => {
members.push("ref blocks");
Expand Down
3 changes: 2 additions & 1 deletion cranelift/codegen/shared/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
//! `cranelift-codegen-meta` libraries.

#![deny(missing_docs)]
#![no_std]

pub mod constant_hash;
pub mod constants;

/// Version number of this crate.
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub const VERSION: &str = core::env!("CARGO_PKG_VERSION");
4 changes: 2 additions & 2 deletions cranelift/codegen/src/ctxhash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
//! node-internal data references some other storage (e.g., offsets into
//! an array or pool of shared data).

use core::hash::{Hash, Hasher};
use hashbrown::hash_table::HashTable;
use std::hash::{Hash, Hasher};

/// Trait that allows for equality comparison given some external
/// context.
Expand Down Expand Up @@ -92,7 +92,7 @@ impl<K, V> CtxHashMap<K, V> {
match self.raw.find_mut(hash as u64, |bucket| {
hash == bucket.hash && ctx.ctx_eq(&bucket.k, &k)
}) {
Some(bucket) => Some(std::mem::replace(&mut bucket.v, v)),
Some(bucket) => Some(core::mem::replace(&mut bucket.v, v)),
None => {
let data = BucketData { hash, k, v };
self.raw
Expand Down
6 changes: 3 additions & 3 deletions cranelift/codegen/src/data_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,13 @@ impl DataValue {
/// Write a [DataValue] to a memory location in native-endian byte order.
pub unsafe fn write_value_to(&self, p: *mut u128) {
let size = self.ty().bytes() as usize;
self.write_to_slice_ne(unsafe { std::slice::from_raw_parts_mut(p as *mut u8, size) });
self.write_to_slice_ne(unsafe { core::slice::from_raw_parts_mut(p as *mut u8, size) });
}

/// Read a [DataValue] from a memory location using a given [Type] in native-endian byte order.
pub unsafe fn read_value_from(p: *const u128, ty: Type) -> Self {
DataValue::read_from_slice_ne(
unsafe { std::slice::from_raw_parts(p as *const u8, ty.bytes() as usize) },
unsafe { core::slice::from_raw_parts(p as *const u8, ty.bytes() as usize) },
ty,
)
}
Expand Down Expand Up @@ -290,7 +290,7 @@ pub enum DataValueCastFailure {

// This is manually implementing Error and Display instead of using thiserror to reduce the amount
// of dependencies used by Cranelift.
impl std::error::Error for DataValueCastFailure {}
impl core::error::Error for DataValueCastFailure {}

impl Display for DataValueCastFailure {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
Expand Down
6 changes: 3 additions & 3 deletions cranelift/codegen/src/dominator_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ impl SpanningTree {
}
}

impl std::ops::Index<u32> for SpanningTree {
impl core::ops::Index<u32> for SpanningTree {
type Output = SpanningTreeNode;

fn index(&self, idx: u32) -> &Self::Output {
&self.nodes[idx as usize]
}
}

impl std::ops::IndexMut<u32> for SpanningTree {
impl core::ops::IndexMut<u32> for SpanningTree {
fn index_mut(&mut self, idx: u32) -> &mut Self::Output {
&mut self.nodes[idx as usize]
}
Expand Down Expand Up @@ -439,7 +439,7 @@ impl DominatorTree {
}

let semi_candidate = self.eval(self.nodes[pred].pre_number, last_linked);
semi = std::cmp::min(semi, semi_candidate);
semi = core::cmp::min(semi, semi_candidate);
}

let w_node = &mut self.stree[w];
Expand Down
4 changes: 2 additions & 2 deletions cranelift/codegen/src/egraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ where

let old_vals = ctx.func.dfg.inst_results(inst);
let new_vals = if let Some(val) = new_val.as_ref() {
std::slice::from_ref(val)
core::slice::from_ref(val)
} else {
ctx.func.dfg.inst_results(new_inst)
};
Expand Down Expand Up @@ -1075,7 +1075,7 @@ impl<'a> CtxEq<(Type, InstructionData), (Type, InstructionData)> for GVNContext<

impl<'a> CtxHash<(Type, InstructionData)> for GVNContext<'a> {
fn ctx_hash<H: Hasher>(&self, state: &mut H, (ty, inst): &(Type, InstructionData)) {
std::hash::Hash::hash(&ty, state);
core::hash::Hash::hash(&ty, state);
inst.hash(state, self.value_lists);
}
}
Expand Down
12 changes: 6 additions & 6 deletions cranelift/codegen/src/egraph/cost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl core::fmt::Debug for Cost {

impl Ord for Cost {
#[inline]
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
fn cmp(&self, other: &Self) -> core::cmp::Ordering {
// We make sure that the high bits are the op cost and the low bits are
// the depth. This means that we can use normal integer comparison to
// order by op cost and then depth.
Expand All @@ -65,7 +65,7 @@ impl Ord for Cost {

impl PartialOrd for Cost {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
Some(self.cmp(other))
}
}
Expand Down Expand Up @@ -172,24 +172,24 @@ impl Cost {
}
}

impl std::iter::Sum<Cost> for Cost {
impl core::iter::Sum<Cost> for Cost {
fn sum<I: Iterator<Item = Cost>>(iter: I) -> Self {
iter.fold(Self::zero(), |a, b| a + b)
}
}

impl std::default::Default for Cost {
impl core::default::Default for Cost {
fn default() -> Cost {
Cost::zero()
}
}

impl std::ops::Add<Cost> for Cost {
impl core::ops::Add<Cost> for Cost {
type Output = Cost;

fn add(self, other: Cost) -> Cost {
let op_cost = self.op_cost().saturating_add(other.op_cost());
let depth = std::cmp::max(self.depth(), other.depth());
let depth = core::cmp::max(self.depth(), other.depth());
Cost::new(op_cost, depth)
}
}
Expand Down
6 changes: 3 additions & 3 deletions cranelift/codegen/src/egraph/elaborate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl PartialOrd for BestEntry {

impl Ord for BestEntry {
#[inline]
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
fn cmp(&self, other: &Self) -> core::cmp::Ordering {
self.0.cmp(&other.0).then_with(|| {
// Note that this comparison is reversed. When costs are equal,
// prefer the value with the bigger index. This is a heuristic that
Expand Down Expand Up @@ -321,9 +321,9 @@ impl<'a> Elaborator<'a> {
debug_assert!(!best[x].1.is_reserved_value());
debug_assert!(!best[y].1.is_reserved_value());
best[value] = if use_worst {
std::cmp::max(best[x], best[y])
core::cmp::max(best[x], best[y])
} else {
std::cmp::min(best[x], best[y])
core::cmp::min(best[x], best[y])
};
trace!(
" -> best of union({:?}, {:?}) = {:?}",
Expand Down
2 changes: 1 addition & 1 deletion cranelift/codegen/src/incremental_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pub trait CacheKvStore {
#[derive(Clone, Hash, PartialEq, Eq)]
pub struct CacheKeyHash([u8; 32]);

impl std::fmt::Display for CacheKeyHash {
impl core::fmt::Display for CacheKeyHash {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "CacheKeyHash:{:?}", self.0)
}
Expand Down
2 changes: 1 addition & 1 deletion cranelift/codegen/src/ir/condcodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ impl FromStr for FloatCC {
#[cfg(test)]
mod tests {
use super::*;
use std::string::ToString;
use alloc::string::ToString;

#[test]
fn int_complement() {
Expand Down
2 changes: 1 addition & 1 deletion cranelift/codegen/src/ir/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ impl ConstantPool {
#[cfg(test)]
mod tests {
use super::*;
use std::string::ToString;
use alloc::string::ToString;

#[test]
fn empty() {
Expand Down
2 changes: 1 addition & 1 deletion cranelift/codegen/src/ir/extname.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub struct TestcaseName(Box<[u8]>);
impl fmt::Display for TestcaseName {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_char('%')?;
f.write_str(std::str::from_utf8(&self.0).unwrap())
f.write_str(core::str::from_utf8(&self.0).unwrap())
}
}

Expand Down
6 changes: 3 additions & 3 deletions cranelift/codegen/src/ir/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ impl InstructionData {
exception_tables: &'a ir::ExceptionTables,
) -> &'a [BlockCall] {
match self {
Self::Jump { destination, .. } => std::slice::from_ref(destination),
Self::Jump { destination, .. } => core::slice::from_ref(destination),
Self::Brif { blocks, .. } => blocks.as_slice(),
Self::BranchTable { table, .. } => jump_tables.get(*table).unwrap().all_branches(),
Self::TryCall { exception, .. } | Self::TryCallIndirect { exception, .. } => {
Expand All @@ -451,7 +451,7 @@ impl InstructionData {
exception_tables: &'a mut ir::ExceptionTables,
) -> &'a mut [BlockCall] {
match self {
Self::Jump { destination, .. } => std::slice::from_mut(destination),
Self::Jump { destination, .. } => core::slice::from_mut(destination),
Self::Brif { blocks, .. } => blocks.as_mut_slice(),
Self::BranchTable { table, .. } => {
jump_tables.get_mut(*table).unwrap().all_branches_mut()
Expand Down Expand Up @@ -1162,7 +1162,7 @@ mod tests {
fn inst_data_size() {
// The size of `InstructionData` is performance sensitive, so make sure
// we don't regress it unintentionally.
assert_eq!(std::mem::size_of::<InstructionData>(), 16);
assert_eq!(core::mem::size_of::<InstructionData>(), 16);
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions cranelift/codegen/src/ir/jumptable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl JumpTableData {
/// Create a new jump table with the provided blocks.
pub fn new(def: BlockCall, table: &[BlockCall]) -> Self {
Self {
table: std::iter::once(def).chain(table.iter().copied()).collect(),
table: core::iter::once(def).chain(table.iter().copied()).collect(),
}
}

Expand Down Expand Up @@ -114,8 +114,8 @@ mod tests {
use crate::entity::EntityRef;
use crate::ir::instructions::ValueListPool;
use crate::ir::{Block, BlockArg, BlockCall, Value};
use alloc::string::ToString;
use alloc::vec::Vec;
use std::string::ToString;

#[test]
fn empty() {
Expand Down
6 changes: 3 additions & 3 deletions cranelift/codegen/src/ir/memtype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ pub enum MemoryTypeData {
Empty,
}

impl std::default::Default for MemoryTypeData {
impl core::default::Default for MemoryTypeData {
fn default() -> Self {
Self::Empty
}
}

impl std::fmt::Display for MemoryTypeData {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
impl core::fmt::Display for MemoryTypeData {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self {
Self::Struct { size, fields } => {
write!(f, "struct {size} {{")?;
Expand Down
18 changes: 9 additions & 9 deletions cranelift/codegen/src/ir/pcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ use crate::ir::types::*;
use crate::isa::TargetIsa;
use crate::machinst::{BlockIndex, LowerBackend, VCode};
use crate::trace;
use core::fmt;
use regalloc2::Function as _;
use std::fmt;

#[cfg(feature = "enable-serde")]
use serde_derive::{Deserialize, Serialize};

/// The result of checking proof-carrying-code facts.
pub type PccResult<T> = std::result::Result<T, PccError>;
pub type PccResult<T> = core::result::Result<T, PccError>;

/// An error or inconsistency discovered when checking proof-carrying
/// code.
Expand Down Expand Up @@ -332,7 +332,7 @@ impl Expr {
} else {
Expr {
base: BaseExpr::min(&lhs.base, &rhs.base),
offset: std::cmp::min(lhs.offset, rhs.offset),
offset: core::cmp::min(lhs.offset, rhs.offset),
}
}
}
Expand All @@ -347,7 +347,7 @@ impl Expr {
} else {
Expr {
base: BaseExpr::max(&lhs.base, &rhs.base),
offset: std::cmp::max(lhs.offset, rhs.offset),
offset: core::cmp::max(lhs.offset, rhs.offset),
}
}
}
Expand Down Expand Up @@ -651,8 +651,8 @@ impl Fact {
},
) if bw_lhs == bw_rhs && max_lhs >= min_rhs && max_rhs >= min_lhs => Fact::Range {
bit_width: *bw_lhs,
min: std::cmp::max(*min_lhs, *min_rhs),
max: std::cmp::min(*max_lhs, *max_rhs),
min: core::cmp::max(*min_lhs, *min_rhs),
max: core::cmp::min(*max_lhs, *max_rhs),
},

(
Expand Down Expand Up @@ -693,8 +693,8 @@ impl Fact {
{
Fact::Mem {
ty: *ty_lhs,
min_offset: std::cmp::max(*min_offset_lhs, *min_offset_rhs),
max_offset: std::cmp::min(*max_offset_lhs, *max_offset_rhs),
min_offset: core::cmp::max(*min_offset_lhs, *min_offset_rhs),
max_offset: core::cmp::min(*max_offset_lhs, *max_offset_rhs),
nullable: *nullable_lhs && *nullable_rhs,
}
}
Expand Down Expand Up @@ -910,7 +910,7 @@ impl<'a> FactContext<'a> {
) if bw_lhs == bw_rhs && add_width >= *bw_lhs => {
let computed_min = min_lhs.checked_add(*min_rhs)?;
let computed_max = max_lhs.checked_add(*max_rhs)?;
let computed_max = std::cmp::min(max_value_for_width(add_width), computed_max);
let computed_max = core::cmp::min(max_value_for_width(add_width), computed_max);
Some(Fact::Range {
bit_width: *bw_lhs,
min: computed_min,
Expand Down
4 changes: 2 additions & 2 deletions cranelift/codegen/src/isa/aarch64/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ use crate::isa::unwind::UnwindInst;
use crate::isa::winch;
use crate::machinst::*;
use crate::settings;
use alloc::borrow::ToOwned;
use alloc::boxed::Box;
use alloc::vec::Vec;
use regalloc2::{MachineEnv, PReg, PRegSet};
use smallvec::{SmallVec, smallvec};
use std::borrow::ToOwned;
use std::sync::OnceLock;

// We use a generic implementation that factors out AArch64 and x64 ABI commonalities, because
Expand Down Expand Up @@ -348,7 +348,7 @@ impl ABIMachineSpec for AArch64MachineDeps {
} else {
// Every arg takes a minimum slot of 8 bytes. (16-byte stack
// alignment happens separately after all args.)
std::cmp::max(size, 8)
core::cmp::max(size, 8)
};

if !is_winch_return {
Expand Down
2 changes: 1 addition & 1 deletion cranelift/codegen/src/isa/aarch64/inst/imms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::ir::types::*;
use crate::isa::aarch64::inst::{OperandSize, ScalarSize};
use crate::machinst::PrettyPrint;

use std::string::String;
use alloc::string::String;

/// An immediate that represents the NZCV flags.
#[derive(Clone, Copy, Debug)]
Expand Down
Loading
Loading