nak: Support uniform regs in lower_copy_swap()

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
This commit is contained in:
Faith Ekstrand 2024-05-23 15:02:28 -05:00 committed by Marge Bot
parent 130392e7ab
commit e244f7bb44

View file

@ -28,19 +28,38 @@ impl LowerCopySwap {
assert!(copy.src.is_uniform() || !dst_reg.is_uniform());
match dst_reg.file() {
RegFile::GPR => match copy.src.src_ref {
SrcRef::Zero | SrcRef::Imm32(_) | SrcRef::CBuf(_) => {
RegFile::GPR | RegFile::UGPR => match copy.src.src_ref {
SrcRef::Zero | SrcRef::Imm32(_) => {
b.push_op(OpMov {
dst: copy.dst,
src: copy.src,
quad_lanes: 0xf,
});
}
SrcRef::CBuf(_) => match dst_reg.file() {
RegFile::GPR => {
b.push_op(OpMov {
dst: copy.dst,
src: copy.src,
quad_lanes: 0xf,
});
}
RegFile::UGPR => {
b.push_op(OpLdc {
dst: copy.dst,
cb: copy.src,
offset: 0.into(),
mode: LdcMode::Indexed,
mem_type: MemType::B32,
});
}
_ => panic!("Invalid cbuf destination"),
},
SrcRef::True | SrcRef::False => {
panic!("Cannot copy to GPR");
}
SrcRef::Reg(src_reg) => match src_reg.file() {
RegFile::GPR => {
RegFile::GPR | RegFile::UGPR => {
b.push_op(OpMov {
dst: copy.dst,
src: copy.src,
@ -74,7 +93,7 @@ impl LowerCopySwap {
},
SrcRef::SSA(_) => panic!("Should be run after RA"),
},
RegFile::Pred => match copy.src.src_ref {
RegFile::Pred | RegFile::UPred => match copy.src.src_ref {
SrcRef::Zero | SrcRef::Imm32(_) | SrcRef::CBuf(_) => {
panic!("Cannot copy to Pred");
}
@ -103,13 +122,24 @@ impl LowerCopySwap {
copy.src,
);
}
RegFile::UPred => {
// PLOP3 supports a UPred in src[2]
b.push_op(OpPLop3 {
dsts: [copy.dst, Dst::None],
srcs: [true.into(), true.into(), copy.src],
ops: [
LogicOp3::new_lut(&|_, _, z| z),
LogicOp3::new_const(false),
],
});
}
_ => panic!("Cannot copy to Pred"),
},
SrcRef::SSA(_) => panic!("Should be run after RA"),
},
RegFile::Bar => match copy.src.src_ref {
SrcRef::Reg(src_reg) => match src_reg.file() {
RegFile::GPR => {
RegFile::GPR | RegFile::UGPR => {
b.push_op(OpBMov {
dst: copy.dst,
src: copy.src,