nak: SrcRef is no longer Copy
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34794>
This commit is contained in:
@@ -1024,7 +1024,7 @@ impl AssignRegsBlock {
|
||||
let reg = self.get_scalar(ssa[0]);
|
||||
self.phi_out.insert(*id, reg.into());
|
||||
} else {
|
||||
self.phi_out.insert(*id, src.src_ref);
|
||||
self.phi_out.insert(*id, src.src_ref.clone());
|
||||
}
|
||||
}
|
||||
assert!(dsts_killed.is_empty());
|
||||
@@ -1376,7 +1376,7 @@ impl AssignRegsBlock {
|
||||
for lv in &target.live_in {
|
||||
let src = match lv.live_ref {
|
||||
LiveRef::SSA(ssa) => SrcRef::from(self.get_scalar(ssa)),
|
||||
LiveRef::Phi(phi) => *self.phi_out.get(&phi).unwrap(),
|
||||
LiveRef::Phi(phi) => self.phi_out.get(&phi).unwrap().clone(),
|
||||
};
|
||||
let dst = lv.reg_ref;
|
||||
if let SrcRef::Reg(src_reg) = src {
|
||||
|
||||
@@ -43,7 +43,7 @@ impl ConstTracker {
|
||||
};
|
||||
|
||||
if is_const {
|
||||
self.map.insert(dst, op.src.src_ref);
|
||||
self.map.insert(dst, op.src.src_ref.clone());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -785,7 +785,7 @@ impl fmt::Display for CBufRef {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Eq, Hash, PartialEq)]
|
||||
#[derive(Clone, Eq, Hash, PartialEq)]
|
||||
pub enum SrcRef {
|
||||
Zero,
|
||||
True,
|
||||
@@ -1125,7 +1125,7 @@ impl Src {
|
||||
b.into()
|
||||
}
|
||||
|
||||
pub fn fabs(&self) -> Src {
|
||||
pub fn fabs(self) -> Src {
|
||||
Src {
|
||||
src_ref: self.src_ref,
|
||||
src_mod: self.src_mod.fabs(),
|
||||
@@ -1133,7 +1133,7 @@ impl Src {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fneg(&self) -> Src {
|
||||
pub fn fneg(self) -> Src {
|
||||
Src {
|
||||
src_ref: self.src_ref,
|
||||
src_mod: self.src_mod.fneg(),
|
||||
@@ -1141,7 +1141,7 @@ impl Src {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ineg(&self) -> Src {
|
||||
pub fn ineg(self) -> Src {
|
||||
Src {
|
||||
src_ref: self.src_ref,
|
||||
src_mod: self.src_mod.ineg(),
|
||||
@@ -1149,7 +1149,7 @@ impl Src {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn bnot(&self) -> Src {
|
||||
pub fn bnot(self) -> Src {
|
||||
Src {
|
||||
src_ref: self.src_ref,
|
||||
src_mod: self.src_mod.bnot(),
|
||||
|
||||
@@ -144,7 +144,7 @@ pub trait LegalizeBuildHelpers: SSABuilder {
|
||||
}
|
||||
|
||||
if val.comps() == 1 {
|
||||
self.copy_to(val.into(), src.src_ref.into());
|
||||
self.copy_to(val.into(), src.src_ref.clone().into());
|
||||
} else {
|
||||
match src.src_ref {
|
||||
SrcRef::Imm32(u) => {
|
||||
|
||||
@@ -111,16 +111,16 @@ fn lower_par_copy(pc: OpParCopy, sm: &dyn ShaderModel) -> MappedInstrs {
|
||||
|
||||
for (dst_idx, (_, src)) in pc.dsts_srcs.iter().enumerate() {
|
||||
assert!(src.src_mod.is_none());
|
||||
let src = src.src_ref;
|
||||
let src = &src.src_ref;
|
||||
|
||||
let src_idx = if let SrcRef::Reg(reg) = src {
|
||||
// Everything must be scalar
|
||||
assert!(reg.comps() == 1);
|
||||
|
||||
*reg_to_idx.entry(reg).or_insert_with(|| {
|
||||
*reg_to_idx.entry(*reg).or_insert_with(|| {
|
||||
let node_idx = graph.add_node();
|
||||
assert!(node_idx == vals.len());
|
||||
vals.push(src);
|
||||
vals.push(src.clone());
|
||||
node_idx
|
||||
})
|
||||
} else {
|
||||
@@ -130,7 +130,7 @@ fn lower_par_copy(pc: OpParCopy, sm: &dyn ShaderModel) -> MappedInstrs {
|
||||
|
||||
let node_idx = graph.add_node();
|
||||
assert!(node_idx == vals.len());
|
||||
vals.push(src);
|
||||
vals.push(src.clone());
|
||||
node_idx
|
||||
};
|
||||
|
||||
@@ -150,7 +150,7 @@ fn lower_par_copy(pc: OpParCopy, sm: &dyn ShaderModel) -> MappedInstrs {
|
||||
while let Some(dst_idx) = ready.pop() {
|
||||
if let Some(src_idx) = graph.src(dst_idx) {
|
||||
let dst = *vals[dst_idx].as_reg().unwrap();
|
||||
let src = vals[src_idx];
|
||||
let src = vals[src_idx].clone();
|
||||
if copy_needs_tmp(&dst, &src) {
|
||||
let tmp = pc.tmp.expect("This copy needs a temporary").comp(0);
|
||||
b.copy_to(tmp.into(), src.into());
|
||||
|
||||
@@ -280,7 +280,7 @@ impl CopyPropPass {
|
||||
return;
|
||||
}
|
||||
|
||||
src.src_ref = entry.src.src_ref;
|
||||
src.src_ref = entry.src.src_ref.clone();
|
||||
src.src_mod = entry.src.src_mod.modify(src.src_mod);
|
||||
}
|
||||
CopyPropEntry::Prmt(entry) => {
|
||||
@@ -347,7 +347,7 @@ impl CopyPropPass {
|
||||
}
|
||||
};
|
||||
|
||||
src.src_ref = entry_src.src_ref;
|
||||
src.src_ref = entry_src.src_ref.clone();
|
||||
src.src_mod = entry_src.src_mod.modify(src.src_mod);
|
||||
src.src_swizzle = new_swizzle;
|
||||
}
|
||||
@@ -365,7 +365,7 @@ impl CopyPropPass {
|
||||
return;
|
||||
};
|
||||
|
||||
src.src_ref = par_entry.src.src_ref;
|
||||
src.src_ref = par_entry.src.src_ref.clone();
|
||||
src.src_mod = par_entry.src.src_mod.modify(src.src_mod);
|
||||
if entry.inverted {
|
||||
src.src_mod = src.src_mod.bnot();
|
||||
|
||||
@@ -17,16 +17,16 @@ struct PrmtSrcs {
|
||||
impl PrmtSrcs {
|
||||
fn new() -> PrmtSrcs {
|
||||
PrmtSrcs {
|
||||
srcs: [SrcRef::Zero; 2],
|
||||
srcs: [const { SrcRef::Zero }; 2],
|
||||
num_srcs: 0,
|
||||
imm_src: usize::MAX,
|
||||
num_imm_bytes: 0,
|
||||
}
|
||||
}
|
||||
|
||||
fn try_add_src(&mut self, src: SrcRef) -> Option<usize> {
|
||||
fn try_add_src(&mut self, src: &SrcRef) -> Option<usize> {
|
||||
for i in 0..self.num_srcs {
|
||||
if self.srcs[i] == src {
|
||||
if self.srcs[i] == *src {
|
||||
return Some(i);
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ impl PrmtSrcs {
|
||||
if self.num_srcs < 2 {
|
||||
let i = self.num_srcs;
|
||||
self.num_srcs += 1;
|
||||
self.srcs[i] = src;
|
||||
self.srcs[i] = src.clone();
|
||||
Some(i)
|
||||
} else {
|
||||
None
|
||||
@@ -105,7 +105,7 @@ impl PrmtPass {
|
||||
|
||||
debug_assert!(op.srcs[0].src_mod.is_none());
|
||||
debug_assert!(op.srcs[1].src_mod.is_none());
|
||||
let srcs = [op.srcs[0].src_ref, op.srcs[1].src_ref];
|
||||
let srcs = [op.srcs[0].src_ref.clone(), op.srcs[1].src_ref.clone()];
|
||||
|
||||
self.ssa_prmt.insert(dst_ssa, PrmtEntry { sel, srcs });
|
||||
}
|
||||
@@ -166,7 +166,7 @@ impl PrmtPass {
|
||||
// This source is unused
|
||||
op.srcs[src_idx] = 0.into();
|
||||
} else {
|
||||
op.srcs[src_idx] = src_prmt.srcs[src_prmt_src].into();
|
||||
op.srcs[src_idx] = src_prmt.srcs[src_prmt_src].clone().into();
|
||||
}
|
||||
true
|
||||
}
|
||||
@@ -200,7 +200,7 @@ impl PrmtPass {
|
||||
new_sel[i] =
|
||||
PrmtSelByte::new(srcs.imm_src, byte_idx, false);
|
||||
} else {
|
||||
let Some(src_idx) = srcs.try_add_src(*src_prmt_src) else {
|
||||
let Some(src_idx) = srcs.try_add_src(src_prmt_src) else {
|
||||
return false;
|
||||
};
|
||||
|
||||
@@ -219,7 +219,7 @@ impl PrmtPass {
|
||||
new_sel[i] = PrmtSelByte::new(srcs.imm_src, byte_idx, false);
|
||||
} else {
|
||||
debug_assert!(src.src_mod.is_none());
|
||||
let Some(src_idx) = srcs.try_add_src(src.src_ref) else {
|
||||
let Some(src_idx) = srcs.try_add_src(&src.src_ref) else {
|
||||
return false;
|
||||
};
|
||||
|
||||
@@ -240,8 +240,9 @@ impl PrmtPass {
|
||||
}
|
||||
|
||||
op.sel = new_sel.into();
|
||||
op.srcs[0] = srcs.srcs[0].into();
|
||||
op.srcs[1] = srcs.srcs[1].into();
|
||||
let [srcs0, srcs1] = srcs.srcs;
|
||||
op.srcs[0] = srcs0.into();
|
||||
op.srcs[1] = srcs1.into();
|
||||
true
|
||||
}
|
||||
|
||||
|
||||
@@ -1603,7 +1603,7 @@ impl SM20Op for OpSel {
|
||||
use RegFile::GPR;
|
||||
let [src0, src1] = &mut self.srcs;
|
||||
if swap_srcs_if_not_reg(src0, src1, GPR) {
|
||||
self.cond = self.cond.bnot();
|
||||
self.cond = self.cond.clone().bnot();
|
||||
}
|
||||
b.copy_alu_src_if_not_reg(src0, GPR, SrcType::ALU);
|
||||
b.copy_alu_src_if_i20_overflow(src1, GPR, SrcType::ALU);
|
||||
|
||||
@@ -1304,7 +1304,7 @@ impl SM50Op for OpIAdd2X {
|
||||
}
|
||||
|
||||
fn encode(&self, e: &mut SM50Encoder<'_>) {
|
||||
match self.carry_in.src_ref {
|
||||
match &self.carry_in.src_ref {
|
||||
SrcRef::Reg(reg) if reg.file() == RegFile::Carry => (),
|
||||
src => panic!("Invalid iadd.x carry_in: {src}"),
|
||||
}
|
||||
@@ -2004,7 +2004,7 @@ impl SM50Op for OpSel {
|
||||
use RegFile::GPR;
|
||||
let [src0, src1] = &mut self.srcs;
|
||||
if swap_srcs_if_not_reg(src0, src1, GPR) {
|
||||
self.cond = self.cond.bnot();
|
||||
self.cond = self.cond.clone().bnot();
|
||||
}
|
||||
b.copy_alu_src_if_not_reg(src0, GPR, SrcType::ALU);
|
||||
b.copy_alu_src_if_i20_overflow(src1, GPR, SrcType::ALU);
|
||||
|
||||
@@ -2059,7 +2059,7 @@ impl SM70Op for OpSel {
|
||||
}
|
||||
let [src0, src1] = &mut self.srcs;
|
||||
if swap_srcs_if_not_reg(src0, src1, gpr) {
|
||||
self.cond = self.cond.bnot();
|
||||
self.cond = self.cond.clone().bnot();
|
||||
}
|
||||
b.copy_alu_src_if_not_reg(src0, gpr, SrcType::ALU);
|
||||
}
|
||||
|
||||
@@ -323,7 +323,7 @@ impl<'a, S: Spill> SpillCache<'a, S> {
|
||||
|
||||
fn spill(&mut self, ssa: SSAValue) -> Box<Instr> {
|
||||
if let Some(c) = self.const_tracker.get(&ssa) {
|
||||
self.spill_src(ssa, (*c).into())
|
||||
self.spill_src(ssa, c.clone().into())
|
||||
} else {
|
||||
self.spill_src(ssa, ssa.into())
|
||||
}
|
||||
@@ -338,7 +338,7 @@ impl<'a, S: Spill> SpillCache<'a, S> {
|
||||
if let Some(c) = self.const_tracker.get(&ssa) {
|
||||
Instr::new_boxed(OpCopy {
|
||||
dst: ssa.into(),
|
||||
src: (*c).into(),
|
||||
src: c.clone().into(),
|
||||
})
|
||||
} else {
|
||||
self.fill_dst(ssa.into(), ssa)
|
||||
|
||||
Reference in New Issue
Block a user