mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-03 09:20:13 +01:00
nak: Add a Src::supports_src_type() helper
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
This commit is contained in:
parent
42d31b4bfd
commit
9bc2bdd78f
1 changed files with 73 additions and 0 deletions
|
|
@ -28,6 +28,13 @@ impl RegFile {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn is_gpr(&self) -> bool {
|
||||
match self {
|
||||
RegFile::GPR | RegFile::UGPR => true,
|
||||
RegFile::Pred | RegFile::UPred => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_predicate(&self) -> bool {
|
||||
match self {
|
||||
RegFile::GPR | RegFile::UGPR => false,
|
||||
|
|
@ -100,6 +107,10 @@ pub trait HasRegFile {
|
|||
self.file().is_uniform()
|
||||
}
|
||||
|
||||
fn is_gpr(&self) -> bool {
|
||||
self.file().is_gpr()
|
||||
}
|
||||
|
||||
fn is_predicate(&self) -> bool {
|
||||
self.file().is_predicate()
|
||||
}
|
||||
|
|
@ -425,6 +436,15 @@ pub enum SrcRef {
|
|||
}
|
||||
|
||||
impl SrcRef {
|
||||
pub fn is_alu(&self) -> bool {
|
||||
match self {
|
||||
SrcRef::Zero | SrcRef::Imm32(_) | SrcRef::CBuf(_) => true,
|
||||
SrcRef::SSA(ssa) => ssa.is_gpr(),
|
||||
SrcRef::Reg(reg) => reg.is_gpr(),
|
||||
SrcRef::True | SrcRef::False => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_predicate(&self) -> bool {
|
||||
match self {
|
||||
SrcRef::Zero | SrcRef::Imm32(_) | SrcRef::CBuf(_) => false,
|
||||
|
|
@ -727,6 +747,59 @@ impl Src {
|
|||
| SrcRef::CBuf(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn supports_type(&self, src_type: &SrcType) -> bool {
|
||||
match src_type {
|
||||
SrcType::SSA => {
|
||||
if !self.src_mod.is_none() {
|
||||
return false;
|
||||
}
|
||||
|
||||
match self.src_ref {
|
||||
SrcRef::SSA(_) | SrcRef::Reg(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
SrcType::GPR => {
|
||||
if !self.src_mod.is_none() {
|
||||
return false;
|
||||
}
|
||||
|
||||
match self.src_ref {
|
||||
SrcRef::Zero | SrcRef::SSA(_) | SrcRef::Reg(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
SrcType::ALU => self.src_mod.is_none() && self.src_ref.is_alu(),
|
||||
SrcType::F32 | SrcType::F64 => {
|
||||
match self.src_mod {
|
||||
SrcMod::None
|
||||
| SrcMod::FAbs
|
||||
| SrcMod::FNeg
|
||||
| SrcMod::FNegAbs => (),
|
||||
_ => return false,
|
||||
}
|
||||
|
||||
self.src_ref.is_alu()
|
||||
}
|
||||
SrcType::I32 => {
|
||||
match self.src_mod {
|
||||
SrcMod::None | SrcMod::INeg => (),
|
||||
_ => return false,
|
||||
}
|
||||
|
||||
self.src_ref.is_alu()
|
||||
}
|
||||
SrcType::Pred => {
|
||||
match self.src_mod {
|
||||
SrcMod::None | SrcMod::BNot => (),
|
||||
_ => return false,
|
||||
}
|
||||
|
||||
self.src_ref.is_predicate()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Into<SrcRef>> From<T> for Src {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue