diff --git a/src/nouveau/compiler/nak/ir.rs b/src/nouveau/compiler/nak/ir.rs index c91c1de80af..566edf4e468 100644 --- a/src/nouveau/compiler/nak/ir.rs +++ b/src/nouveau/compiler/nak/ir.rs @@ -236,6 +236,19 @@ pub trait HasRegFile { } } +impl HasRegFile for &[SSAValue] { + fn file(&self) -> RegFile { + let comps = self.len(); + let file = self[0].file(); + for i in 1..comps { + if self[i].file() != file { + panic!("Illegal mix of RegFiles") + } + } + file + } +} + #[derive(Clone)] pub struct RegFileSet { bits: u8, diff --git a/src/nouveau/compiler/nak/ssa_value.rs b/src/nouveau/compiler/nak/ssa_value.rs index cc9c7c664f2..fd29511e4eb 100644 --- a/src/nouveau/compiler/nak/ssa_value.rs +++ b/src/nouveau/compiler/nak/ssa_value.rs @@ -204,49 +204,6 @@ impl SSARef { } } - /// Returns the register file for this SSA reference, assuming all SSA - /// values have the same register file. - pub fn file(&self) -> RegFile { - let comps = usize::from(self.comps()); - let file = self[0].file(); - for i in 1..comps { - if self[i].file() != file { - panic!("SSARef mixes RegFiles") - } - } - file - } - - /// Returns true if this SSA reference is known to be uniform. - pub fn is_uniform(&self) -> bool { - for ssa in &self[..] { - if !ssa.is_uniform() { - return false; - } - } - true - } - - pub fn is_gpr(&self) -> bool { - for ssa in &self[..] { - if !ssa.is_gpr() { - return false; - } - } - true - } - - pub fn is_predicate(&self) -> bool { - if self[0].is_predicate() { - true - } else { - for ssa in &self[..] { - debug_assert!(!ssa.is_predicate()); - } - false - } - } - #[cold] #[inline] fn cold() {} @@ -337,6 +294,12 @@ impl fmt::Display for SSARef { } } +impl HasRegFile for SSARef { + fn file(&self) -> RegFile { + (&self[..]).file() + } +} + #[test] fn test_ssa_ref_round_trip() { for len in 1..16 {