nak: s/HashMap::new()/Default::default()/
wherever this doesn't result in type inference failing. Using default() makes it easier to swap out the underlying type. Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34865>
This commit is contained in:
@@ -143,7 +143,7 @@ impl SSAUseMap {
|
||||
|
||||
pub fn for_block(b: &BasicBlock) -> SSAUseMap {
|
||||
let mut am = SSAUseMap {
|
||||
ssa_map: HashMap::new(),
|
||||
ssa_map: Default::default(),
|
||||
};
|
||||
am.add_block(b);
|
||||
am
|
||||
@@ -207,7 +207,7 @@ impl PhiWebs {
|
||||
|
||||
PhiWebs {
|
||||
uf,
|
||||
assignments: HashMap::new(),
|
||||
assignments: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ impl RegAllocator {
|
||||
used: BitSet::new(),
|
||||
pinned: BitSet::new(),
|
||||
reg_ssa: Vec::new(),
|
||||
ssa_reg: HashMap::new(),
|
||||
ssa_reg: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -496,7 +496,7 @@ impl<'a> VecRegAllocator<'a> {
|
||||
ra,
|
||||
pcopy: OpParCopy::new(),
|
||||
pinned,
|
||||
evicted: HashMap::new(),
|
||||
evicted: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -933,7 +933,7 @@ impl AssignRegsBlock {
|
||||
}),
|
||||
pcopy_tmp_gprs: pcopy_tmp_gprs,
|
||||
live_in: Vec::new(),
|
||||
phi_out: HashMap::new(),
|
||||
phi_out: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,8 +74,8 @@ impl DepGraph {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
deps: Vec::new(),
|
||||
instr_deps: HashMap::new(),
|
||||
instr_waits: HashMap::new(),
|
||||
instr_deps: Default::default(),
|
||||
instr_waits: Default::default(),
|
||||
active: HashSet::new(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ pub struct ConstTracker {
|
||||
impl ConstTracker {
|
||||
pub fn new() -> Self {
|
||||
ConstTracker {
|
||||
map: HashMap::new(),
|
||||
map: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -199,7 +199,7 @@ impl<'a> PhiAllocMap<'a> {
|
||||
fn new(alloc: &'a mut PhiAllocator) -> PhiAllocMap<'a> {
|
||||
PhiAllocMap {
|
||||
alloc: alloc,
|
||||
map: HashMap::new(),
|
||||
map: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,13 +345,13 @@ impl<'a> ShaderFromNir<'a> {
|
||||
float_ctl: ShaderFloatControls::from_nir(nir),
|
||||
cfg: CFGBuilder::new(),
|
||||
label_alloc: LabelAllocator::new(),
|
||||
block_label: HashMap::new(),
|
||||
bar_label: HashMap::new(),
|
||||
block_label: Default::default(),
|
||||
bar_label: Default::default(),
|
||||
sync_blocks: HashSet::new(),
|
||||
crs: Vec::new(),
|
||||
fs_out_regs: [None; 34],
|
||||
end_block_id: 0,
|
||||
ssa_map: HashMap::new(),
|
||||
ssa_map: Default::default(),
|
||||
saturated: HashSet::new(),
|
||||
nir_instr_printer: NirInstrPrinter::new().unwrap(),
|
||||
}
|
||||
|
||||
@@ -439,7 +439,7 @@ fn legalize_instr(
|
||||
|
||||
sm.legalize_op(b, &mut instr.op);
|
||||
|
||||
let mut vec_src_map: HashMap<SSARef, SSARef> = HashMap::new();
|
||||
let mut vec_src_map: HashMap<SSARef, SSARef> = Default::default();
|
||||
let mut vec_comps = HashSet::new();
|
||||
for src in instr.srcs_mut() {
|
||||
if let SrcRef::SSA(vec) = &src.src_ref {
|
||||
|
||||
@@ -240,7 +240,7 @@ impl SimpleBlockLiveness {
|
||||
Self {
|
||||
defs: BitSet::new(),
|
||||
uses: BitSet::new(),
|
||||
last_use: HashMap::new(),
|
||||
last_use: Default::default(),
|
||||
live_in: BitSet::new(),
|
||||
live_out: BitSet::new(),
|
||||
}
|
||||
@@ -284,7 +284,7 @@ pub struct SimpleLiveness {
|
||||
impl SimpleLiveness {
|
||||
pub fn for_function(func: &Function) -> SimpleLiveness {
|
||||
let mut l = SimpleLiveness {
|
||||
ssa_block_ip: HashMap::new(),
|
||||
ssa_block_ip: Default::default(),
|
||||
blocks: Vec::new(),
|
||||
};
|
||||
let mut live_in = Vec::new();
|
||||
@@ -406,7 +406,7 @@ impl NextUseBlockLiveness {
|
||||
fn new(num_instrs: usize) -> Self {
|
||||
Self {
|
||||
num_instrs: num_instrs,
|
||||
ssa_map: HashMap::new(),
|
||||
ssa_map: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ struct PhiMap {
|
||||
impl PhiMap {
|
||||
pub fn new() -> PhiMap {
|
||||
PhiMap {
|
||||
ssa_phi: HashMap::new(),
|
||||
phi_ssa: HashMap::new(),
|
||||
ssa_phi: Default::default(),
|
||||
phi_ssa: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ struct BarPropPass {
|
||||
impl BarPropPass {
|
||||
pub fn new() -> BarPropPass {
|
||||
BarPropPass {
|
||||
ssa_map: HashMap::new(),
|
||||
ssa_map: Default::default(),
|
||||
phi_is_bar: BitSet::new(),
|
||||
phi_is_not_bar: BitSet::new(),
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ impl<'a> CopyPropPass<'a> {
|
||||
pub fn new(sm: &'a dyn ShaderModel) -> Self {
|
||||
CopyPropPass {
|
||||
sm: sm,
|
||||
ssa_map: HashMap::new(),
|
||||
ssa_map: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ fn jump_thread(func: &mut Function) -> bool {
|
||||
let mut progress = false;
|
||||
|
||||
// A branch to label can be replaced with Op
|
||||
let mut replacements: HashMap<Label, Op> = HashMap::new();
|
||||
let mut replacements: HashMap<Label, Op> = Default::default();
|
||||
|
||||
// Invariant 1: At the end of each loop iteration,
|
||||
// every trivial block with an index in [i, blocks.len())
|
||||
|
||||
@@ -49,7 +49,7 @@ impl LopPass {
|
||||
}
|
||||
LopPass {
|
||||
use_counts: use_counts,
|
||||
ssa_lop: HashMap::new(),
|
||||
ssa_lop: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ struct PrmtPass {
|
||||
impl PrmtPass {
|
||||
fn new() -> PrmtPass {
|
||||
PrmtPass {
|
||||
ssa_prmt: HashMap::new(),
|
||||
ssa_prmt: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ fn propagate_r2ur(
|
||||
impl Shader<'_> {
|
||||
pub fn opt_uniform_instrs(&mut self) {
|
||||
let sm = self.sm;
|
||||
let mut r2ur = HashMap::new();
|
||||
let mut r2ur = Default::default();
|
||||
let mut propagated_r2ur = false;
|
||||
self.map_instrs(|mut instr, alloc| {
|
||||
if matches!(
|
||||
|
||||
@@ -87,7 +87,7 @@ fn get_ssa_or_phi(
|
||||
idx: phi_idx,
|
||||
orig: ssa,
|
||||
dst: phi_ssa,
|
||||
srcs: HashMap::new(),
|
||||
srcs: Default::default(),
|
||||
};
|
||||
for &p_idx in &b.pred {
|
||||
if p_idx >= b_idx {
|
||||
@@ -192,7 +192,7 @@ impl Function {
|
||||
blocks.push(DefTrackerBlock {
|
||||
pred: cfg.pred_indices(b_idx).to_vec(),
|
||||
succ: cfg.succ_indices(b_idx).to_vec(),
|
||||
defs: RefCell::new(HashMap::new()),
|
||||
defs: RefCell::new(Default::default()),
|
||||
phis: RefCell::new(Vec::new()),
|
||||
});
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ struct PhiDstMap {
|
||||
impl PhiDstMap {
|
||||
fn new() -> PhiDstMap {
|
||||
PhiDstMap {
|
||||
ssa_phi: HashMap::new(),
|
||||
ssa_phi: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ struct PhiSrcMap {
|
||||
impl PhiSrcMap {
|
||||
fn new() -> PhiSrcMap {
|
||||
PhiSrcMap {
|
||||
phi_src: HashMap::new(),
|
||||
phi_src: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,7 +292,7 @@ impl<'a, S: Spill> SpillCache<'a, S> {
|
||||
alloc: alloc,
|
||||
spill: spill,
|
||||
const_tracker: ConstTracker::new(),
|
||||
val_spill: HashMap::new(),
|
||||
val_spill: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -592,7 +592,7 @@ fn spill_values<S: Spill>(
|
||||
num_preds: usize,
|
||||
next_use: usize,
|
||||
}
|
||||
let mut live: HashMap<SSAValue, SSAPredInfo> = HashMap::new();
|
||||
let mut live: HashMap<SSAValue, SSAPredInfo> = Default::default();
|
||||
|
||||
for p_idx in &preds {
|
||||
let phi_src_map = &phi_src_maps[*p_idx];
|
||||
|
||||
@@ -82,8 +82,8 @@ impl<'a> CoalesceGraph<'a> {
|
||||
live: live,
|
||||
nodes: Vec::new(),
|
||||
sets: Vec::new(),
|
||||
ssa_node: HashMap::new(),
|
||||
phi_node_file: HashMap::new(),
|
||||
ssa_node: Default::default(),
|
||||
phi_node_file: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ impl<X: Copy + Hash + Eq> UnionFind<X> {
|
||||
/// At initialization, each possible value is in its own set
|
||||
pub fn new() -> Self {
|
||||
UnionFind {
|
||||
idx_map: HashMap::new(),
|
||||
idx_map: Default::default(),
|
||||
nodes: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user