Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: no_std rustc_hash::{FxHashMap, FxHashSet} aliases #9975

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion cranelift/codegen/src/alias_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ use crate::{
ir::{immediates::Offset32, AliasRegion, Block, Function, Inst, Opcode, Type, Value},
trace,
};
use crate::{FxHashMap, FxHashSet};
use cranelift_entity::{packed_option::PackedOption, EntityRef};
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.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ use crate::scoped_hash_map::{Entry as ScopedEntry, ScopedHashMap};
use crate::settings::Flags;
use crate::trace;
use crate::unionfind::UnionFind;
use crate::FxHashSet;
use core::cmp::Ordering;
use cranelift_control::ControlPlane;
use cranelift_entity::packed_option::ReservedValue;
use cranelift_entity::SecondaryMap;
use rustc_hash::FxHashSet;
use smallvec::SmallVec;
use std::hash::Hasher;

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 @@ -10,10 +10,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::{packed_option::ReservedValue, SecondaryMap};
use rustc_hash::{FxHashMap, FxHashSet};
use smallvec::{smallvec, SmallVec};

pub(crate) struct Elaborator<'a> {
Expand Down
7 changes: 7 additions & 0 deletions cranelift/codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ use hashbrown::{hash_map, HashMap};
#[cfg(feature = "std")]
use std::collections::{hash_map, HashMap};

#[cfg(feature = "std")]
pub use rustc_hash::{FxHashMap, FxHashSet};
#[cfg(not(feature = "std"))]
pub type FxHashMap<K, V> = HashMap<K, V, core::hash::BuildHasherDefault<rustc_hash::FxHasher>>;
#[cfg(not(feature = "std"))]
pub type FxHashSet<V> = HashSet<V, core::hash::BuildHasherDefault<rustc_hash::FxHasher>>;
JonasKruckenberg marked this conversation as resolved.
Show resolved Hide resolved

pub use crate::context::Context;
pub use crate::value_label::{LabelValueLoc, ValueLabelsRanges, ValueLocRange};
pub use crate::verifier::verify_function;
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 @@ -104,10 +104,10 @@ use crate::ir::{ArgumentExtension, ArgumentPurpose, Signature};
use crate::isa::TargetIsa;
use crate::settings::ProbestackStrategy;
use crate::CodegenError;
use crate::FxHashMap;
use crate::{ir, isa};
use crate::{machinst::*, trace};
use regalloc2::{MachineEnv, PReg, PRegSet};
use rustc_hash::FxHashMap;
use smallvec::smallvec;
use std::collections::HashMap;
use std::marker::PhantomData;
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 @@ -65,7 +65,7 @@ use crate::entity::SecondaryMap;
use crate::inst_predicates::visit_block_succs;
use crate::ir::{Block, Function, Inst, Opcode};
use crate::{machinst::*, trace};
use rustc_hash::{FxHashMap, FxHashSet};
use crate::{FxHashMap, FxHashSet};

/// Mapping from CLIF BBs to VCode BBs.
#[derive(Debug)]
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 @@ -21,9 +21,9 @@ use crate::machinst::{
};
use crate::settings::Flags;
use crate::{trace, CodegenError, CodegenResult};
use crate::{FxHashMap, FxHashSet};
use alloc::vec::Vec;
use cranelift_control::ControlPlane;
use rustc_hash::{FxHashMap, FxHashSet};
use smallvec::{smallvec, SmallVec};
use std::fmt::Debug;

Expand Down
2 changes: 1 addition & 1 deletion cranelift/codegen/src/machinst/vcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ use crate::ranges::Ranges;
use crate::timing;
use crate::trace;
use crate::CodegenError;
use crate::FxHashMap;
use crate::{LabelValueLoc, ValueLocRange};
use regalloc2::{
Edit, Function as RegallocFunction, InstOrEdit, InstRange, MachineEnv, Operand,
OperandConstraint, OperandKind, PRegSet, RegClass,
};
use rustc_hash::FxHashMap;

use core::mem::take;
use cranelift_entity::{entity_impl, Keys};
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, 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 cranelift/codegen/src/scoped_hash_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
//! container that has a concept of scopes that can be entered and exited, such that
//! values inserted while inside a scope aren't visible outside the scope.

use crate::FxHashMap;
use core::hash::Hash;
use rustc_hash::FxHashMap;
use smallvec::{smallvec, SmallVec};

#[cfg(not(feature = "std"))]
use crate::fx::FxHasher;
use rustc_hash::FxHasher;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like FxHasher or Hasher are used anywhere in this module, and they aren't exported -- can we remove them instead?

#[cfg(not(feature = "std"))]
type Hasher = core::hash::BuildHasherDefault<FxHasher>;

Expand Down
Loading