From 69fb9e3188deeb0de9706d05e198ca178b2fecbe Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Wed, 21 Sep 2022 13:52:08 +0300 Subject: [PATCH] Keep `PassMode` by reference instead of value. --- .../src/builder/byte_addressable_buffer.rs | 8 ++++---- crates/rustc_codegen_spirv/src/codegen_cx/declare.rs | 4 ++-- crates/rustc_codegen_spirv/src/codegen_cx/mod.rs | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/rustc_codegen_spirv/src/builder/byte_addressable_buffer.rs b/crates/rustc_codegen_spirv/src/builder/byte_addressable_buffer.rs index 692bdcdfae..ceb38c43a3 100644 --- a/crates/rustc_codegen_spirv/src/builder/byte_addressable_buffer.rs +++ b/crates/rustc_codegen_spirv/src/builder/byte_addressable_buffer.rs @@ -170,7 +170,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { &mut self, result_type: Word, args: &[SpirvValue], - pass_mode: PassMode, + pass_mode: &PassMode, ) -> SpirvValue { match pass_mode { PassMode::Ignore => { @@ -181,7 +181,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } // PassMode::Pair is identical to PassMode::Direct - it's returned as a struct PassMode::Direct(_) | PassMode::Pair(_, _) => (), - PassMode::Cast(_) => { + PassMode::Cast(_, _) => { self.fatal("PassMode::Cast not supported in codegen_buffer_load_intrinsic") } PassMode::Indirect { .. } => { @@ -342,14 +342,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } /// Note: DOES NOT do bounds checking! Bounds checking is expected to be done in the caller. - pub fn codegen_buffer_store_intrinsic(&mut self, args: &[SpirvValue], pass_mode: PassMode) { + pub fn codegen_buffer_store_intrinsic(&mut self, args: &[SpirvValue], pass_mode: &PassMode) { // Signature: fn store(array: &[u32], index: u32, value: T); let is_pair = match pass_mode { // haha shrug PassMode::Ignore => return, PassMode::Direct(_) => false, PassMode::Pair(_, _) => true, - PassMode::Cast(_) => { + PassMode::Cast(_, _) => { self.fatal("PassMode::Cast not supported in codegen_buffer_store_intrinsic") } PassMode::Indirect { .. } => { diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs b/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs index d55117968a..a8d7e2093f 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs @@ -121,13 +121,13 @@ impl<'tcx> CodegenCx<'tcx> { self.unroll_loops_decorations.borrow_mut().insert(fn_id); } if attrs.buffer_load_intrinsic.is_some() { - let mode = fn_abi.ret.mode; + let mode = &fn_abi.ret.mode; self.buffer_load_intrinsic_fn_id .borrow_mut() .insert(fn_id, mode); } if attrs.buffer_store_intrinsic.is_some() { - let mode = fn_abi.args.last().unwrap().mode; + let mode = &fn_abi.args.last().unwrap().mode; self.buffer_store_intrinsic_fn_id .borrow_mut() .insert(fn_id, mode); diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs b/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs index 28f656d8f4..110dab2411 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs @@ -67,9 +67,9 @@ pub struct CodegenCx<'tcx> { /// Simple `panic!("...")` and builtin panics (from MIR `Assert`s) call `#[lang = "panic"]`. pub panic_fn_id: Cell>, /// Intrinsic for loading a from a &[u32]. The PassMode is the mode of the . - pub buffer_load_intrinsic_fn_id: RefCell>, + pub buffer_load_intrinsic_fn_id: RefCell>, /// Intrinsic for storing a into a &[u32]. The PassMode is the mode of the . - pub buffer_store_intrinsic_fn_id: RefCell>, + pub buffer_store_intrinsic_fn_id: RefCell>, /// Builtin bounds-checking panics (from MIR `Assert`s) call `#[lang = "panic_bounds_check"]`. pub panic_bounds_check_fn_id: Cell>,