nak: Drop the PrmtSelection stuff

It's just a very fancy and verbose way to build an immediate.  I don't
think it's really gaining us all that much, especially when the
semantics are documented in the PTX docs.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26348>
This commit is contained in:
Faith Ekstrand 2023-11-22 14:40:56 -06:00 committed by Faith Ekstrand
parent 7dff232c09
commit d5693a590e
2 changed files with 1 additions and 117 deletions

View file

@ -811,31 +811,10 @@ impl<'a> ShaderFromNir<'a> {
high: false,
});
let dst = b.alloc_ssa(RegFile::GPR, 1);
let selection = PrmtSelectionEval::from([
PrmtSelection {
src: PrmtSrc::Byte5,
sign_extend: false,
},
PrmtSelection {
src: PrmtSrc::Byte4,
sign_extend: false,
},
PrmtSelection {
src: PrmtSrc::Byte1,
sign_extend: false,
},
PrmtSelection {
src: PrmtSrc::Byte0,
sign_extend: false,
},
]);
b.push_op(OpPrmt {
dst: dst.into(),
srcs: [low.into(), high.into()],
selection: selection.inner().into(),
selection: 0x5410.into(),
});
dst
}

View file

@ -2726,101 +2726,6 @@ impl DisplayOp for OpMov {
}
impl_display_for_op!(OpMov);
#[derive(Copy, Clone, Debug)]
pub enum PrmtSrc {
Byte0 = 0,
Byte1 = 1,
Byte2 = 2,
Byte3 = 3,
Byte4 = 4,
Byte5 = 5,
Byte6 = 6,
Byte7 = 7,
}
impl TryFrom<u32> for PrmtSrc {
type Error = String;
fn try_from(value: u32) -> Result<Self, Self::Error> {
match value {
0 => Ok(Self::Byte0),
1 => Ok(Self::Byte1),
2 => Ok(Self::Byte2),
3 => Ok(Self::Byte3),
4 => Ok(Self::Byte4),
5 => Ok(Self::Byte5),
6 => Ok(Self::Byte6),
7 => Ok(Self::Byte7),
_ => Err(format!("Invalid value {}", value)),
}
}
}
#[derive(Copy, Clone, Debug)]
pub struct PrmtSelection {
pub src: PrmtSrc,
pub sign_extend: bool,
}
impl From<PrmtSelectionEval> for [PrmtSelection; 4] {
fn from(value: PrmtSelectionEval) -> Self {
let sel0 = value.0 & 0x7;
let sel1 = (value.0 & 0x70) >> 4;
let sel2 = (value.0 & 0x700) >> 8;
let sel3 = (value.0 & 0x7000) >> 12;
let sign0 = value.0 & 0x8;
let sign1 = value.0 & 0x80;
let sign2 = value.0 & 0x800;
let sign3 = value.0 & 0x8000;
[
PrmtSelection {
src: sel3.try_into().unwrap(),
sign_extend: sign3 != 0,
},
PrmtSelection {
src: sel2.try_into().unwrap(),
sign_extend: sign2 != 0,
},
PrmtSelection {
src: sel1.try_into().unwrap(),
sign_extend: sign1 != 0,
},
PrmtSelection {
src: sel0.try_into().unwrap(),
sign_extend: sign0 != 0,
},
]
}
}
#[derive(Copy, Clone, Debug)]
pub struct PrmtSelectionEval(u32);
impl PrmtSelectionEval {
pub fn inner(&self) -> u32 {
self.0
}
}
impl From<[PrmtSelection; 4]> for PrmtSelectionEval {
fn from(selections: [PrmtSelection; 4]) -> Self {
let mut selection = 0;
for v in selections {
let src = if v.sign_extend {
v.src as u32 | 0x8
} else {
v.src as u32
};
selection = selection << 4 | src;
}
Self(selection)
}
}
#[repr(C)]
#[derive(SrcsAsSlice, DstsAsSlice)]
/// Permutes `srcs` into `dst` using `selection`.