Allow building without std (#1069)
Closes https://github.com/CraneStation/cranelift/issues/1067
This commit is contained in:
committed by
Benjamin Bouvier
parent
40f6d3b753
commit
a1f6457e8a
@@ -99,7 +99,7 @@ impl<'a> MemoryCodeSink<'a> {
|
||||
unsafe {
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(clippy::cast_ptr_alignment))]
|
||||
write_unaligned(self.data.offset(self.offset) as *mut T, x);
|
||||
self.offset += std::mem::size_of::<T>() as isize;
|
||||
self.offset += core::mem::size_of::<T>() as isize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ use crate::isa::TargetIsa;
|
||||
use std::vec::Vec;
|
||||
|
||||
type Num = u32;
|
||||
const NUM_BITS: usize = std::mem::size_of::<Num>() * 8;
|
||||
const NUM_BITS: usize = core::mem::size_of::<Num>() * 8;
|
||||
|
||||
/// Wrapper class for longer bit vectors that cannot be represented by a single BitSet.
|
||||
#[derive(Clone, Debug)]
|
||||
@@ -20,7 +20,7 @@ impl Stackmap {
|
||||
isa: &dyn TargetIsa,
|
||||
) -> Self {
|
||||
let loc = &func.locations;
|
||||
let mut live_ref_in_stack_slot = std::collections::HashSet::new();
|
||||
let mut live_ref_in_stack_slot = crate::HashSet::new();
|
||||
// References can be in registers, and live registers values are pushed onto the stack before calls and traps.
|
||||
// TODO: Implement register maps. If a register containing a reference is spilled and reused after a safepoint,
|
||||
// it could contain a stale reference value if the garbage collector relocated the value.
|
||||
|
||||
@@ -1078,8 +1078,6 @@ mod tests {
|
||||
d -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
assert_eq!(n_tests_done, 50_148_000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
//! - bucketing constants by size.
|
||||
|
||||
use crate::ir::Constant;
|
||||
use crate::HashMap;
|
||||
use cranelift_entity::EntityRef;
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
use std::collections::BTreeMap;
|
||||
use std::vec::Vec;
|
||||
|
||||
/// This type describes the actual constant data.
|
||||
|
||||
@@ -13,12 +13,12 @@ use crate::ir::{
|
||||
use crate::isa::TargetIsa;
|
||||
use crate::packed_option::ReservedValue;
|
||||
use crate::write::write_operands;
|
||||
use crate::HashMap;
|
||||
use core::fmt;
|
||||
use core::iter;
|
||||
use core::mem;
|
||||
use core::ops::{Index, IndexMut};
|
||||
use core::u16;
|
||||
use std::collections::HashMap;
|
||||
use std::vec::Vec;
|
||||
|
||||
/// A data flow graph defines all instructions and extended basic blocks in a function as well as
|
||||
|
||||
@@ -50,7 +50,7 @@ extern crate alloc as std;
|
||||
extern crate std;
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
use hashmap_core::{map as hash_map, HashMap, HashSet};
|
||||
use hashbrown::{hash_map, HashMap, HashSet};
|
||||
#[cfg(feature = "std")]
|
||||
use std::collections::{hash_map, HashMap, HashSet};
|
||||
|
||||
|
||||
@@ -8,6 +8,11 @@ use crate::fx::FxHashMap;
|
||||
use core::hash::Hash;
|
||||
use core::mem;
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
use crate::fx::FxHasher;
|
||||
#[cfg(not(feature = "std"))]
|
||||
type Hasher = core::hash::BuildHasherDefault<FxHasher>;
|
||||
|
||||
struct Val<K, V> {
|
||||
value: V,
|
||||
next_key: Option<K>,
|
||||
@@ -16,7 +21,10 @@ struct Val<K, V> {
|
||||
|
||||
/// A view into an occupied entry in a `ScopedHashMap`. It is part of the `Entry` enum.
|
||||
pub struct OccupiedEntry<'a, K: 'a, V: 'a> {
|
||||
#[cfg(feature = "std")]
|
||||
entry: super::hash_map::OccupiedEntry<'a, K, Val<K, V>>,
|
||||
#[cfg(not(feature = "std"))]
|
||||
entry: super::hash_map::OccupiedEntry<'a, K, Val<K, V>, Hasher>,
|
||||
}
|
||||
|
||||
impl<'a, K, V> OccupiedEntry<'a, K, V> {
|
||||
@@ -28,12 +36,15 @@ impl<'a, K, V> OccupiedEntry<'a, K, V> {
|
||||
|
||||
/// A view into a vacant entry in a `ScopedHashMap`. It is part of the `Entry` enum.
|
||||
pub struct VacantEntry<'a, K: 'a, V: 'a> {
|
||||
#[cfg(feature = "std")]
|
||||
entry: super::hash_map::VacantEntry<'a, K, Val<K, V>>,
|
||||
#[cfg(not(feature = "std"))]
|
||||
entry: super::hash_map::VacantEntry<'a, K, Val<K, V>, Hasher>,
|
||||
next_key: Option<K>,
|
||||
depth: usize,
|
||||
}
|
||||
|
||||
impl<'a, K, V> VacantEntry<'a, K, V> {
|
||||
impl<'a, K: Hash, V> VacantEntry<'a, K, V> {
|
||||
/// Sets the value of the entry with the `VacantEntry`'s key.
|
||||
pub fn insert(self, value: V) {
|
||||
self.entry.insert(Val {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
use crate::ir::{Function, SourceLoc, Value, ValueLabel, ValueLabelAssignments, ValueLoc};
|
||||
use crate::isa::TargetIsa;
|
||||
use crate::regalloc::{Context, RegDiversions};
|
||||
use std::cmp::Ordering;
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
use std::iter::Iterator;
|
||||
use std::ops::Bound::*;
|
||||
use std::ops::Deref;
|
||||
use crate::HashMap;
|
||||
use core::cmp::Ordering;
|
||||
use core::iter::Iterator;
|
||||
use core::ops::Bound::*;
|
||||
use core::ops::Deref;
|
||||
use std::collections::BTreeMap;
|
||||
use std::vec::Vec;
|
||||
|
||||
#[cfg(feature = "enable-serde")]
|
||||
|
||||
@@ -13,8 +13,8 @@ use crate::ir::{
|
||||
use crate::isa::{RegInfo, TargetIsa};
|
||||
use crate::packed_option::ReservedValue;
|
||||
use crate::value_label::ValueLabelsRanges;
|
||||
use crate::HashSet;
|
||||
use core::fmt::{self, Write};
|
||||
use std::collections::HashSet;
|
||||
use std::string::String;
|
||||
use std::vec::Vec;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user