nak: Allow iadd3 to take an immediate in srcs[2]

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
This commit is contained in:
Faith Ekstrand 2023-01-30 20:53:18 -06:00 committed by Marge Bot
parent 811ccc6917
commit 5ad06de4d3
2 changed files with 26 additions and 7 deletions

View file

@ -336,13 +336,25 @@ impl SM75Instr {
}
fn encode_iadd3(&mut self, op: &OpIAdd3) {
self.encode_alu(
0x010,
Some(op.dst),
Some(op.mod_src(0)),
op.mod_src(1),
Some(op.mod_src(2)),
);
/* TODO: This should happen as part of a legalization pass */
assert!(op.srcs[0].is_reg_or_zero());
if op.srcs[2].is_reg_or_zero() {
self.encode_alu(
0x010,
Some(op.dst),
Some(op.mod_src(0)),
op.mod_src(1),
Some(op.mod_src(2)),
);
} else {
self.encode_alu(
0x010,
Some(op.dst),
Some(op.mod_src(0)),
op.mod_src(2),
Some(op.mod_src(1)),
);
}
self.set_pred_src(81..84, op.carry[0]);
self.set_pred_src(84..87, op.carry[1]);

View file

@ -277,6 +277,13 @@ impl Ref {
Src::SSA(ssa) => Some(ssa),
}
}
pub fn is_reg_or_zero(&self) -> bool {
match self {
Ref::Zero | Ref::SSA(_) | Ref::Reg(_) => true,
Ref::Imm(_) | Ref::CBuf(_) => false,
}
}
}
impl fmt::Display for Ref {