nak/sm50: Properly legalize OpSel and drop an assert

While we're here, update sm70 to be a bit more modern.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26587>
This commit is contained in:
Faith Ekstrand 2023-12-19 13:01:11 -06:00 committed by Marge Bot
parent 7f5c6642d8
commit 1a7e83c87f
2 changed files with 8 additions and 6 deletions

View file

@ -285,8 +285,6 @@ impl SM50Instr {
}
fn encode_sel(&mut self, op: &OpSel) {
assert!(op.srcs[1].is_reg_or_zero());
match &op.srcs[1].src_ref {
SrcRef::Imm32(imm32) => {
self.set_opcode(0x38a0);

View file

@ -261,7 +261,12 @@ fn legalize_sm50_instr(
copy_alu_src_if_not_reg(b, &mut op.src, SrcType::GPR);
}
Op::Sel(op) => {
copy_alu_src_if_not_reg(b, &mut op.srcs[1], SrcType::GPR);
let [ref mut src0, ref mut src1] = op.srcs;
if swap_srcs_if_not_reg(src0, src1) {
op.cond = op.cond.bnot();
}
copy_alu_src_if_not_reg(b, src0, SrcType::ALU);
copy_alu_src_if_i20_overflow(b, src1, SrcType::ALU);
}
Op::Shfl(op) => {
copy_alu_src_if_not_reg(b, &mut op.src, SrcType::GPR);
@ -529,9 +534,8 @@ fn legalize_sm70_instr(
}
Op::Sel(op) => {
let [ref mut src0, ref mut src1] = op.srcs;
if !src_is_reg(src0) && src_is_reg(src1) {
std::mem::swap(src0, src1);
op.cond.src_mod = op.cond.src_mod.bnot();
if swap_srcs_if_not_reg(src0, src1) {
op.cond = op.cond.bnot();
}
copy_alu_src_if_not_reg(b, src0, SrcType::ALU);
}