diff --git a/src/nouveau/compiler/bitset.rs b/src/nouveau/compiler/bitview.rs similarity index 88% rename from src/nouveau/compiler/bitset.rs rename to src/nouveau/compiler/bitview.rs index 05f8758b3ba..2d3bc5e9d78 100644 --- a/src/nouveau/compiler/bitset.rs +++ b/src/nouveau/compiler/bitview.rs @@ -9,13 +9,13 @@ use crate::util::DivCeil; use std::ops::Range; -pub trait BitSetViewable { +pub trait BitViewable { fn bits(&self) -> usize; fn get_bit_range_u64(&self, range: Range) -> u64; } -pub trait BitSetMutViewable: BitSetViewable { +pub trait BitMutViewable: BitViewable { fn set_bit_range_u64(&mut self, range: Range, val: u64); } @@ -26,7 +26,7 @@ fn u64_mask_for_bits(bits: usize) -> u64 { macro_rules! decl_bit_set_viewable_for_uint { ($ty: ty) => { - impl BitSetViewable for $ty { + impl BitViewable for $ty { fn bits(&self) -> usize { <$ty>::BITS as usize } @@ -40,7 +40,7 @@ macro_rules! decl_bit_set_viewable_for_uint { } } - impl BitSetMutViewable for $ty { + impl BitMutViewable for $ty { fn set_bit_range_u64(&mut self, range: Range, val: u64) { assert!(!range.is_empty()); assert!(range.end <= self.bits()); @@ -54,7 +54,7 @@ macro_rules! decl_bit_set_viewable_for_uint { } } - impl BitSetViewable for [$ty] { + impl BitViewable for [$ty] { fn bits(&self) -> usize { self.len() * (<$ty>::BITS as usize) } @@ -83,7 +83,7 @@ macro_rules! decl_bit_set_viewable_for_uint { } } - impl BitSetMutViewable for [$ty] { + impl BitMutViewable for [$ty] { fn set_bit_range_u64(&mut self, range: Range, val: u64) { assert!(!range.is_empty()); assert!(range.end <= self.bits()); @@ -110,7 +110,7 @@ macro_rules! decl_bit_set_viewable_for_uint { } } - impl BitSetViewable for [$ty; N] { + impl BitViewable for [$ty; N] { fn bits(&self) -> usize { N * (<$ty>::BITS as usize) } @@ -120,7 +120,7 @@ macro_rules! decl_bit_set_viewable_for_uint { } } - impl BitSetMutViewable for [$ty; N] { + impl BitMutViewable for [$ty; N] { fn set_bit_range_u64(&mut self, range: Range, val: u64) { self[..].set_bit_range_u64(range, val); } @@ -133,12 +133,12 @@ decl_bit_set_viewable_for_uint!(u16); decl_bit_set_viewable_for_uint!(u32); decl_bit_set_viewable_for_uint!(u64); -pub struct BitSetView<'a, BS: BitSetViewable + ?Sized> { +pub struct BitView<'a, BS: BitViewable + ?Sized> { parent: &'a BS, range: Range, } -impl<'a, BS: BitSetViewable + ?Sized> BitSetView<'a, BS> { +impl<'a, BS: BitViewable + ?Sized> BitView<'a, BS> { pub fn new(parent: &'a BS) -> Self { let len = parent.bits(); Self { @@ -158,8 +158,8 @@ impl<'a, BS: BitSetViewable + ?Sized> BitSetView<'a, BS> { pub fn subset( &'a self, range: Range, - ) -> BitSetView<'a, BitSetView<'a, BS>> { - BitSetView::new_subset(self, range) + ) -> BitView<'a, BitView<'a, BS>> { + BitView::new_subset(self, range) } fn range_in_parent(&self, range: Range) -> Range { @@ -174,7 +174,7 @@ impl<'a, BS: BitSetViewable + ?Sized> BitSetView<'a, BS> { } } -impl<'a, BS: BitSetViewable + ?Sized> BitSetViewable for BitSetView<'a, BS> { +impl<'a, BS: BitViewable + ?Sized> BitViewable for BitView<'a, BS> { fn bits(&self) -> usize { self.range.end - self.range.start } @@ -184,12 +184,12 @@ impl<'a, BS: BitSetViewable + ?Sized> BitSetViewable for BitSetView<'a, BS> { } } -pub struct BitSetMutView<'a, BS: BitSetMutViewable + ?Sized> { +pub struct BitMutView<'a, BS: BitMutViewable + ?Sized> { parent: &'a mut BS, range: Range, } -impl<'a, BS: BitSetMutViewable + ?Sized> BitSetMutView<'a, BS> { +impl<'a, BS: BitMutViewable + ?Sized> BitMutView<'a, BS> { pub fn new(parent: &'a mut BS) -> Self { let len = parent.bits(); Self { @@ -209,8 +209,8 @@ impl<'a, BS: BitSetMutViewable + ?Sized> BitSetMutView<'a, BS> { pub fn subset_mut<'b>( &'b mut self, range: Range, - ) -> BitSetMutView<'b, BitSetMutView<'a, BS>> { - BitSetMutView::new_subset(self, range) + ) -> BitMutView<'b, BitMutView<'a, BS>> { + BitMutView::new_subset(self, range) } fn range_in_parent(&self, range: Range) -> Range { @@ -229,9 +229,7 @@ impl<'a, BS: BitSetMutViewable + ?Sized> BitSetMutView<'a, BS> { } } -impl<'a, BS: BitSetMutViewable + ?Sized> BitSetViewable - for BitSetMutView<'a, BS> -{ +impl<'a, BS: BitMutViewable + ?Sized> BitViewable for BitMutView<'a, BS> { fn bits(&self) -> usize { self.range.end - self.range.start } @@ -241,9 +239,7 @@ impl<'a, BS: BitSetMutViewable + ?Sized> BitSetViewable } } -impl<'a, BS: BitSetMutViewable + ?Sized> BitSetMutViewable - for BitSetMutView<'a, BS> -{ +impl<'a, BS: BitMutViewable + ?Sized> BitMutViewable for BitMutView<'a, BS> { fn set_bit_range_u64(&mut self, range: Range, val: u64) { self.parent .set_bit_range_u64(self.range_in_parent(range), val); @@ -254,7 +250,7 @@ pub trait SetFieldU64 { fn set_field_u64(&mut self, range: Range, val: u64); } -impl<'a, BS: BitSetMutViewable + ?Sized> SetFieldU64 for BitSetMutView<'a, BS> { +impl<'a, BS: BitMutViewable + ?Sized> SetFieldU64 for BitMutView<'a, BS> { fn set_field_u64(&mut self, range: Range, val: u64) { let bits = range.end - range.start; diff --git a/src/nouveau/compiler/nak.rs b/src/nouveau/compiler/nak.rs index 0ac6983d52b..531457bc9f4 100644 --- a/src/nouveau/compiler/nak.rs +++ b/src/nouveau/compiler/nak.rs @@ -3,7 +3,7 @@ * SPDX-License-Identifier: MIT */ -mod bitset; +mod bitview; mod nak_assign_regs; mod nak_calc_instr_deps; mod nak_encode_sm75; @@ -17,7 +17,7 @@ mod nir; mod union_find; mod util; -use bitset::*; +use bitview::*; use nak_bindings::*; use nak_from_nir::*; use std::os::raw::c_void; @@ -120,7 +120,7 @@ fn encode_hdr_for_nir(nir: &nir_shader, tls_size: u32) -> [u32; 32] { } let mut hdr = [0_u32; 32]; - let mut hdr_view = BitSetMutView::new(&mut hdr); + let mut hdr_view = BitMutView::new(&mut hdr); /* [0, 31]: CommonWord0 */ let mut cw0 = hdr_view.subset_mut(0..32); @@ -192,7 +192,7 @@ fn encode_hdr_for_nir(nir: &nir_shader, tls_size: u32) -> [u32; 32] { cw4.set_field(20..24, 0_u32 /* Reserved */); cw4.set_field(24..32, 0_u32 /* TODO: StoreReqEnd */); - let nir_sv = BitSetView::new(&nir.info.system_values_read); + let nir_sv = BitView::new(&nir.info.system_values_read); if nir.info.stage() != MESA_SHADER_FRAGMENT { assert!(sph_type == 1); @@ -211,7 +211,7 @@ fn encode_hdr_for_nir(nir: &nir_shader, tls_size: u32) -> [u32; 32] { /* [192, 319]: ImapGenericVector[32] */ let mut imap_g = hdr_view.subset_mut(192..320); - let nir_ir = BitSetView::new(&nir.info.inputs_read); + let nir_ir = BitView::new(&nir.info.inputs_read); let input0: usize = if nir.info.stage() == MESA_SHADER_VERTEX { VERT_ATTRIB_GENERIC0.try_into().unwrap() } else { @@ -228,7 +228,7 @@ fn encode_hdr_for_nir(nir: &nir_shader, tls_size: u32) -> [u32; 32] { /* [352, 391]: ImapFixedFncTexture[10] */ /* [392, 399]: ImapReserved */ - let nir_ow = BitSetView::new(&nir.info.outputs_written); + let nir_ow = BitView::new(&nir.info.outputs_written); /* [400, 423]: TODO: OmapSystemValuesA */ @@ -282,7 +282,7 @@ fn encode_hdr_for_nir(nir: &nir_shader, tls_size: u32) -> [u32; 32] { /* [576, 607]: OmapTarget[8] */ let mut omap_color = hdr_view.subset_mut(576..608); - let nir_ow = BitSetView::new(&nir.info.outputs_written); + let nir_ow = BitView::new(&nir.info.outputs_written); let output0 = usize::try_from(FRAG_RESULT_DATA0).unwrap(); for i in 0..8 { if nir_ow.get_bit(output0 + i) { diff --git a/src/nouveau/compiler/nak_encode_sm75.rs b/src/nouveau/compiler/nak_encode_sm75.rs index 2c6329013ed..d4b80e38647 100644 --- a/src/nouveau/compiler/nak_encode_sm75.rs +++ b/src/nouveau/compiler/nak_encode_sm75.rs @@ -3,7 +3,7 @@ * SPDX-License-Identifier: MIT */ -use crate::bitset::*; +use crate::bitview::*; use crate::nak_ir::*; use std::collections::HashMap; @@ -91,31 +91,31 @@ struct SM75Instr { sm: u8, } -impl BitSetViewable for SM75Instr { +impl BitViewable for SM75Instr { fn bits(&self) -> usize { - BitSetView::new(&self.inst).bits() + BitView::new(&self.inst).bits() } fn get_bit_range_u64(&self, range: Range) -> u64 { - BitSetView::new(&self.inst).get_bit_range_u64(range) + BitView::new(&self.inst).get_bit_range_u64(range) } } -impl BitSetMutViewable for SM75Instr { +impl BitMutViewable for SM75Instr { fn set_bit_range_u64(&mut self, range: Range, val: u64) { - BitSetMutView::new(&mut self.inst).set_bit_range_u64(range, val); + BitMutView::new(&mut self.inst).set_bit_range_u64(range, val); } } impl SetFieldU64 for SM75Instr { fn set_field_u64(&mut self, range: Range, val: u64) { - BitSetMutView::new(&mut self.inst).set_field_u64(range, val); + BitMutView::new(&mut self.inst).set_field_u64(range, val); } } impl SM75Instr { fn set_bit(&mut self, bit: usize, val: bool) { - BitSetMutView::new(&mut self.inst).set_bit(bit, val); + BitMutView::new(&mut self.inst).set_bit(bit, val); } fn set_src_imm(&mut self, range: Range, u: &u32) { @@ -190,7 +190,7 @@ impl SM75Instr { } fn set_src_cb(&mut self, range: Range, cb: &CBufRef) { - let mut v = BitSetMutView::new_subset(self, range); + let mut v = BitMutView::new_subset(self, range); v.set_field(0..16, cb.offset); if let CBuf::Binding(idx) = cb.buf { v.set_field(16..21, idx); @@ -200,7 +200,7 @@ impl SM75Instr { } fn set_src_cx(&mut self, range: Range, cb: &CBufRef) { - let mut v = BitSetMutView::new_subset(self, range); + let mut v = BitMutView::new_subset(self, range); if let CBuf::BindlessGPR(reg) = cb.buf { assert!(reg.base_idx() <= 63); assert!(reg.file() == RegFile::UGPR); diff --git a/src/nouveau/compiler/nvfuzz.rs b/src/nouveau/compiler/nvfuzz.rs index 69e8c884b25..fc3eb7b6c2c 100644 --- a/src/nouveau/compiler/nvfuzz.rs +++ b/src/nouveau/compiler/nvfuzz.rs @@ -3,10 +3,10 @@ * SPDX-License-Identifier: MIT */ -mod bitset; +mod bitview; mod util; -use crate::bitset::*; +use crate::bitview::*; use std::fs; use std::io::Write; @@ -72,7 +72,7 @@ fn main() { let cuda_path = find_cuda().expect("Failed to find CUDA"); for bits in 0..(1_u64 << range.len()) { - BitSetMutView::new(&mut instr).set_field(range.clone(), bits); + BitMutView::new(&mut instr).set_field(range.clone(), bits); print!("With {:#x} in {}..{}:", bits, range.start, range.end); for dw in instr {