kraid/v9: Allow immediates in logic ops
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/42154>
This commit is contained in:
Faith Ekstrand 2026-06-10 11:28:49 -04:00 committed by Marge Bot
parent 1ef1039d77
commit e74b92b3da

View file

@ -648,13 +648,23 @@ impl V9Instr for OpNop {
macro_rules! encode_lop {
($e:expr, $op:expr, $Instr:ident) => {
paste! {
$e.encode(v9::$Instr {
variant: $op.dst_type.try_into().unwrap(),
dst: op_encode_dst($op, &$op.dst),
not_result: $op.not_result.into(),
src0: op_encode_src($op, &$op.src0),
src2: op_encode_src($op, &$op.src2),
})
if let SrcRef::Imm32(imm) = &$op.src2.src_ref {
assert!(!$op.not_result);
$e.encode(v9::[<$Instr Imm>] {
variant: $op.dst_type.try_into().unwrap(),
dst: op_encode_dst($op, &$op.dst),
src0: op_encode_src($op, &$op.src0),
imm1w: (*imm).into(),
})
} else {
$e.encode(v9::$Instr {
variant: $op.dst_type.try_into().unwrap(),
dst: op_encode_dst($op, &$op.dst),
not_result: $op.not_result.into(),
src0: op_encode_src($op, &$op.src0),
src2: op_encode_src($op, &$op.src2),
})
}
}
};
}
@ -722,6 +732,23 @@ impl V9Instr for OpShiftLop {
}
}
fn src_supports_imm32(&self, src: &Src, arch: u8) -> bool {
if !self.shift_op.is_none() {
return false;
}
if !ptr_eq(src, &self.src2) || self.not_result {
return false;
}
match self.logic_op {
LogicOp::None => v9::Or::is_supported(self.dst_type, arch),
LogicOp::And => v9::And::is_supported(self.dst_type, arch),
LogicOp::Or => v9::Or::is_supported(self.dst_type, arch),
LogicOp::Xor => v9::Xor::is_supported(self.dst_type, arch),
}
}
fn encode(&self, e: V9Encoder) -> EncodedInstr {
use LogicOp::*;
use ShiftOp::*;