mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 19:30:11 +01:00
nak: Add an SSAComp struct
This is useful in RA for referring to a single component of an SSA value. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
This commit is contained in:
parent
552faf2864
commit
ef45379bfa
1 changed files with 37 additions and 0 deletions
|
|
@ -105,6 +105,16 @@ impl SSAValue {
|
|||
pub fn comps(&self) -> u8 {
|
||||
(((self.packed >> 27) & 0x7) + 1).try_into().unwrap()
|
||||
}
|
||||
|
||||
pub fn comp(&self, comp: u8) -> SSAComp {
|
||||
assert!(comp < self.comps());
|
||||
SSAComp::new(self.file(), self.idx(), comp)
|
||||
}
|
||||
|
||||
pub fn as_comp(&self) -> SSAComp {
|
||||
assert!(self.comps() == 1);
|
||||
SSAComp::new(self.file(), self.idx(), 0)
|
||||
}
|
||||
}
|
||||
|
||||
impl HasRegFile for SSAValue {
|
||||
|
|
@ -123,6 +133,33 @@ impl fmt::Display for SSAValue {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Eq, Hash, PartialEq)]
|
||||
pub struct SSAComp {
|
||||
v: SSAValue,
|
||||
}
|
||||
|
||||
impl SSAComp {
|
||||
pub fn new(file: RegFile, idx: u32, comp: u8) -> SSAComp {
|
||||
SSAComp {
|
||||
v: SSAValue::new(file, idx, comp + 1),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn idx(&self) -> u32 {
|
||||
self.v.idx()
|
||||
}
|
||||
|
||||
pub fn comp(&self) -> u8 {
|
||||
self.v.comps() - 1
|
||||
}
|
||||
}
|
||||
|
||||
impl HasRegFile for SSAComp {
|
||||
fn file(&self) -> RegFile {
|
||||
self.v.file()
|
||||
}
|
||||
}
|
||||
|
||||
pub struct SSAValueAllocator {
|
||||
count: u32,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue