mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-21 20:10:14 +01:00
nak/legalize: Add a helper for lowering ineg
This is similar to the helper we have for lowering float modifiers. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34536>
This commit is contained in:
parent
d16e75e55f
commit
af6093a712
3 changed files with 25 additions and 14 deletions
|
|
@ -269,6 +269,29 @@ pub trait LegalizeBuildHelpers: SSABuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn copy_alu_src_and_lower_ineg(
|
||||||
|
&mut self,
|
||||||
|
src: &mut Src,
|
||||||
|
src_type: SrcType,
|
||||||
|
) {
|
||||||
|
assert!(src_type == SrcType::I32);
|
||||||
|
let val = self.alloc_ssa(RegFile::GPR, 1);
|
||||||
|
if self.sm() >= 70 {
|
||||||
|
self.push_op(OpIAdd3 {
|
||||||
|
srcs: [Src::new_zero(), *src, Src::new_zero()],
|
||||||
|
overflow: [Dst::None; 2],
|
||||||
|
dst: val.into(),
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
self.push_op(OpIAdd2 {
|
||||||
|
dst: val.into(),
|
||||||
|
carry_out: Dst::None,
|
||||||
|
srcs: [Src::new_zero(), *src],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
*src = val.into();
|
||||||
|
}
|
||||||
|
|
||||||
fn copy_ssa_ref_if_uniform(&mut self, ssa_ref: &mut SSARef) {
|
fn copy_ssa_ref_if_uniform(&mut self, ssa_ref: &mut SSARef) {
|
||||||
for ssa in &mut ssa_ref[..] {
|
for ssa in &mut ssa_ref[..] {
|
||||||
if ssa.is_uniform() {
|
if ssa.is_uniform() {
|
||||||
|
|
|
||||||
|
|
@ -1265,13 +1265,7 @@ impl SM50Op for OpIAdd2 {
|
||||||
swap_srcs_if_not_reg(src0, src1, GPR);
|
swap_srcs_if_not_reg(src0, src1, GPR);
|
||||||
if src0.src_mod.is_ineg() && src1.src_mod.is_ineg() {
|
if src0.src_mod.is_ineg() && src1.src_mod.is_ineg() {
|
||||||
assert!(self.carry_out.is_none());
|
assert!(self.carry_out.is_none());
|
||||||
let val = b.alloc_ssa(GPR, 1);
|
b.copy_alu_src_and_lower_ineg(src0, SrcType::I32);
|
||||||
b.push_op(OpIAdd2 {
|
|
||||||
dst: val.into(),
|
|
||||||
carry_out: Dst::None,
|
|
||||||
srcs: [Src::new_zero(), *src0],
|
|
||||||
});
|
|
||||||
*src0 = val.into();
|
|
||||||
}
|
}
|
||||||
b.copy_alu_src_if_not_reg(src0, GPR, SrcType::I32);
|
b.copy_alu_src_if_not_reg(src0, GPR, SrcType::I32);
|
||||||
if !self.carry_out.is_none() {
|
if !self.carry_out.is_none() {
|
||||||
|
|
|
||||||
|
|
@ -1350,13 +1350,7 @@ impl SM70Op for OpIAdd3 {
|
||||||
if !src0.src_mod.is_none() && !src1.src_mod.is_none() {
|
if !src0.src_mod.is_none() && !src1.src_mod.is_none() {
|
||||||
assert!(self.overflow[0].is_none());
|
assert!(self.overflow[0].is_none());
|
||||||
assert!(self.overflow[1].is_none());
|
assert!(self.overflow[1].is_none());
|
||||||
let val = b.alloc_ssa(gpr, 1);
|
b.copy_alu_src_and_lower_ineg(src0, SrcType::I32);
|
||||||
b.push_op(OpIAdd3 {
|
|
||||||
srcs: [Src::new_zero(), *src0, Src::new_zero()],
|
|
||||||
overflow: [Dst::None; 2],
|
|
||||||
dst: val.into(),
|
|
||||||
});
|
|
||||||
*src0 = val.into();
|
|
||||||
}
|
}
|
||||||
b.copy_alu_src_if_not_reg(src0, gpr, SrcType::I32);
|
b.copy_alu_src_if_not_reg(src0, gpr, SrcType::I32);
|
||||||
b.copy_alu_src_if_both_not_reg(src1, src2, gpr, SrcType::I32);
|
b.copy_alu_src_if_both_not_reg(src1, src2, gpr, SrcType::I32);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue