From bc58881b9ff075c1e2adeb0341a4fbdb1c9137f6 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Wed, 31 Jul 2024 11:31:16 -0500 Subject: [PATCH] nak: Move DstsAsSlice::is_uniform() to its own trait Reviewed-by: Christian Gmeiner Part-of: --- src/nouveau/compiler/nak/ir.rs | 10 ++++++---- src/nouveau/compiler/nak/ir_proc.rs | 18 ------------------ 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/src/nouveau/compiler/nak/ir.rs b/src/nouveau/compiler/nak/ir.rs index 95cd69ea4d6..6f9e2dc7bf7 100644 --- a/src/nouveau/compiler/nak/ir.rs +++ b/src/nouveau/compiler/nak/ir.rs @@ -1493,7 +1493,13 @@ pub trait DstsAsSlice { assert!(r.contains(&(dst as *const Dst))); unsafe { (dst as *const Dst).offset_from(r.start) as usize } } +} +pub trait IsUniform { + fn is_uniform(&self) -> bool; +} + +impl IsUniform for T { fn is_uniform(&self) -> bool { all_dsts_uniform(self.dsts_as_slice()) } @@ -5827,10 +5833,6 @@ impl DstsAsSlice for OpPhiDsts { fn dst_types(&self) -> DstTypeList { DstTypeList::Uniform(DstType::Vec) } - - fn is_uniform(&self) -> bool { - false - } } impl DisplayOp for OpPhiDsts { diff --git a/src/nouveau/compiler/nak/ir_proc.rs b/src/nouveau/compiler/nak/ir_proc.rs index fbd96dbffc9..470547af4d2 100644 --- a/src/nouveau/compiler/nak/ir_proc.rs +++ b/src/nouveau/compiler/nak/ir_proc.rs @@ -184,7 +184,6 @@ fn derive_as_slice( let mut as_slice_cases = TokenStream2::new(); let mut as_mut_slice_cases = TokenStream2::new(); let mut types_cases = TokenStream2::new(); - let mut is_uniform_cases = TokenStream2::new(); for v in e.variants { let case = v.ident; as_slice_cases.extend(quote! { @@ -196,23 +195,7 @@ fn derive_as_slice( types_cases.extend(quote! { #ident::#case(x) => x.#types_fn(), }); - if search_type == "Dst" { - is_uniform_cases.extend(quote! { - #ident::#case(x) => x.is_uniform(), - }); - } } - let is_uniform_func = if search_type == "Dst" { - quote! { - fn is_uniform(&self) -> bool { - match self { - #is_uniform_cases - } - } - } - } else { - TokenStream2::new() - }; quote! { impl #trait_name for #ident { fn #as_slice(&self) -> &[#elem_type] { @@ -232,7 +215,6 @@ fn derive_as_slice( #types_cases } } - #is_uniform_func } } .into()