diff --git a/src/nouveau/compiler/nak_from_nir.rs b/src/nouveau/compiler/nak_from_nir.rs index 9c7553eb30e..a4c20f0aba5 100644 --- a/src/nouveau/compiler/nak_from_nir.rs +++ b/src/nouveau/compiler/nak_from_nir.rs @@ -44,7 +44,7 @@ impl<'a> ShaderFromNir<'a> { } pub fn alloc_ssa(&mut self, file: RegFile, comps: u8) -> SSAValue { - self.func.as_mut().unwrap().alloc_ssa(file, comps) + self.func.as_mut().unwrap().ssa_alloc.alloc(file, comps) } fn get_ssa(&self, def: &nir_def) -> SSAValue { diff --git a/src/nouveau/compiler/nak_ir.rs b/src/nouveau/compiler/nak_ir.rs index 7bb17176248..decd82d2b78 100644 --- a/src/nouveau/compiler/nak_ir.rs +++ b/src/nouveau/compiler/nak_ir.rs @@ -128,6 +128,24 @@ impl fmt::Display for SSAValue { } } +pub struct SSAValueAllocator { + count: u32, +} + +impl SSAValueAllocator { + pub fn new(initial_count: u32) -> SSAValueAllocator { + SSAValueAllocator { + count: initial_count, + } + } + + pub fn alloc(&mut self, file: RegFile, comps: u8) -> SSAValue { + let idx = self.count; + self.count += 1; + SSAValue::new(file, idx, comps) + } +} + #[derive(Clone, Copy, Eq, Hash, PartialEq)] pub struct RegRef { packed: u16, @@ -1887,7 +1905,7 @@ impl fmt::Display for BasicBlock { pub struct Function { id: u32, - pub ssa_count: u32, + pub ssa_alloc: SSAValueAllocator, pub blocks: Vec, } @@ -1895,17 +1913,11 @@ impl Function { pub fn new(id: u32, reserved_ssa_count: u32) -> Function { Function { id: id, - ssa_count: reserved_ssa_count, + ssa_alloc: SSAValueAllocator::new(reserved_ssa_count), blocks: Vec::new(), } } - pub fn alloc_ssa(&mut self, file: RegFile, comps: u8) -> SSAValue { - let idx = self.ssa_count; - self.ssa_count += 1; - SSAValue::new(file, idx, comps) - } - pub fn map_instrs Vec>(&mut self, map: &F) { for b in &mut self.blocks { b.map_instrs(map);