nak: Rework integer compare ops

Rename to IntCmpOp and make it trivially copyable.  While we're at it,
rename and rework set_int_cmp_op() in the emit code too.

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 3a17c943da
commit d11c8268a2
3 changed files with 25 additions and 24 deletions

View file

@ -311,17 +311,17 @@ impl SM75Instr {
self.set_pred_src(84..87, op.carry[1]);
}
fn set_cmp_op(&mut self, range: Range<usize>, op: &CmpOp) {
fn set_int_cmp_op(&mut self, range: Range<usize>, op: IntCmpOp) {
assert!(range.len() == 3);
self.set_field(
range,
match op {
CmpOp::Eq => 2_u8,
CmpOp::Ne => 5_u8,
CmpOp::Lt => 1_u8,
CmpOp::Le => 3_u8,
CmpOp::Gt => 4_u8,
CmpOp::Ge => 6_u8,
IntCmpOp::Eq => 2_u8,
IntCmpOp::Ne => 5_u8,
IntCmpOp::Lt => 1_u8,
IntCmpOp::Le => 3_u8,
IntCmpOp::Gt => 4_u8,
IntCmpOp::Ge => 6_u8,
},
);
}
@ -343,7 +343,7 @@ impl SM75Instr {
},
);
self.set_field(74..76, 0_u32); /* pred combine op */
self.set_cmp_op(76..79, &op.cmp_op);
self.set_int_cmp_op(76..79, op.cmp_op);
self.set_pred_dst(81..84, op.dst);
self.set_field(84..87, 7_u32); /* dst1 */

View file

@ -126,7 +126,7 @@ impl<'a> ShaderFromNir<'a> {
self.instrs.push(Instr::new_isetp(
dst,
IntCmpType::I32,
CmpOp::Eq,
IntCmpOp::Eq,
srcs[0],
srcs[1],
));
@ -135,7 +135,7 @@ impl<'a> ShaderFromNir<'a> {
self.instrs.push(Instr::new_isetp(
dst,
IntCmpType::I32,
CmpOp::Ge,
IntCmpOp::Ge,
srcs[0],
srcs[1],
));
@ -144,7 +144,7 @@ impl<'a> ShaderFromNir<'a> {
self.instrs.push(Instr::new_isetp(
dst,
IntCmpType::I32,
CmpOp::Lt,
IntCmpOp::Lt,
srcs[0],
srcs[1],
));
@ -153,7 +153,7 @@ impl<'a> ShaderFromNir<'a> {
self.instrs.push(Instr::new_isetp(
dst,
IntCmpType::I32,
CmpOp::Ne,
IntCmpOp::Ne,
srcs[0],
srcs[1],
));
@ -209,7 +209,7 @@ impl<'a> ShaderFromNir<'a> {
self.instrs.push(Instr::new_isetp(
dst,
IntCmpType::U32,
CmpOp::Ge,
IntCmpOp::Ge,
srcs[0],
srcs[1],
));
@ -218,7 +218,7 @@ impl<'a> ShaderFromNir<'a> {
self.instrs.push(Instr::new_isetp(
dst,
IntCmpType::U32,
CmpOp::Lt,
IntCmpOp::Lt,
srcs[0],
srcs[1],
));

View file

@ -454,7 +454,8 @@ pub enum PredSetOp {
XorNot,
}
pub enum CmpOp {
#[derive(Clone, Copy, Eq, Hash, PartialEq)]
pub enum IntCmpOp {
Eq,
Ne,
Lt,
@ -463,15 +464,15 @@ pub enum CmpOp {
Ge,
}
impl fmt::Display for CmpOp {
impl fmt::Display for IntCmpOp {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
CmpOp::Eq => write!(f, "EQ"),
CmpOp::Ne => write!(f, "NE"),
CmpOp::Lt => write!(f, "LT"),
CmpOp::Le => write!(f, "LE"),
CmpOp::Gt => write!(f, "GT"),
CmpOp::Ge => write!(f, "GE"),
IntCmpOp::Eq => write!(f, "EQ"),
IntCmpOp::Ne => write!(f, "NE"),
IntCmpOp::Lt => write!(f, "LT"),
IntCmpOp::Le => write!(f, "LE"),
IntCmpOp::Gt => write!(f, "GT"),
IntCmpOp::Ge => write!(f, "GE"),
}
}
}
@ -817,7 +818,7 @@ impl fmt::Display for OpIAdd3 {
pub struct OpISetP {
pub dst: Dst,
pub cmp_op: CmpOp,
pub cmp_op: IntCmpOp,
pub cmp_type: IntCmpType,
pub srcs: [Src; 2],
@ -1361,7 +1362,7 @@ impl Instr {
pub fn new_isetp(
dst: Dst,
cmp_type: IntCmpType,
cmp_op: CmpOp,
cmp_op: IntCmpOp,
x: Src,
y: Src,
) -> Instr {