nak: Add tests for OpPopC and enable SrcMod::BNot

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30402>
This commit is contained in:
Faith Ekstrand
2024-07-27 02:52:28 -05:00
committed by Marge Bot
parent 27ee9027da
commit ec84d7ce74
2 changed files with 23 additions and 2 deletions
+13
View File
@@ -784,6 +784,19 @@ fn test_op_lop3() {
}
}
#[test]
fn test_op_popc() {
let src_mods = [SrcMod::None, SrcMod::BNot];
for src_mod in src_mods {
let mut op = OpPopC {
dst: Dst::None,
src: 0.into(),
};
op.src.src_mod = src_mod;
test_foldable_op(op);
}
}
#[test]
fn test_op_shf() {
let sm = &RunSingleton::get().sm;
+10 -2
View File
@@ -4529,15 +4529,23 @@ impl DisplayOp for OpPSetP {
}
#[repr(C)]
#[derive(SrcsAsSlice, DstsAsSlice)]
#[derive(Clone, SrcsAsSlice, DstsAsSlice)]
pub struct OpPopC {
#[dst_type(GPR)]
pub dst: Dst,
#[src_type(ALU)]
#[src_type(B32)]
pub src: Src,
}
impl Foldable for OpPopC {
fn fold(&self, _sm: &dyn ShaderModel, f: &mut OpFoldData<'_>) {
let src = f.get_u32_bnot_src(self, &self.src);
let dst = src.count_ones();
f.set_u32_dst(self, &self.dst, dst);
}
}
impl DisplayOp for OpPopC {
fn fmt_op(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "popc {}", self.src,)