MCPcopy Create free account
hub / github.com/Rust-GPU/rust-gpu / emit_access_chain

Method emit_access_chain

crates/rustc_codegen_spirv/src/builder/mod.rs:184–215  ·  view source on GitHub ↗
(
        &self,
        result_type: spirv::Word,
        pointer: spirv::Word,
        base: SpirvValue,
        indices: Vec<spirv::Word>,
        is_inbounds: bool,
    )

Source from the content-addressed store, hash-verified

182 }
183
184 fn emit_access_chain(
185 &self,
186 result_type: spirv::Word,
187 pointer: spirv::Word,
188 base: SpirvValue,
189 indices: Vec<spirv::Word>,
190 is_inbounds: bool,
191 ) -> SpirvValue {
192 let mut emit = self.emit();
193 if self.builder.lookup_const_u64(base) == Some(0) {
194 if is_inbounds {
195 emit.in_bounds_access_chain(result_type, None, pointer, indices)
196 } else {
197 emit.access_chain(result_type, None, pointer, indices)
198 }
199 .unwrap()
200 .with_type(result_type)
201 } else {
202 let result = if is_inbounds {
203 emit.in_bounds_ptr_access_chain(result_type, None, pointer, base.def(self), indices)
204 } else {
205 emit.ptr_access_chain(result_type, None, pointer, base.def(self), indices)
206 }
207 .unwrap()
208 .with_type(result_type);
209 self.zombie(
210 result.def(self),
211 "cannot offset a pointer to an arbitrary element",
212 );
213 result
214 }
215 }
216
217 // TODO: Definitely add tests to make sure this impl is right.
218 fn rotate(&mut self, value: SpirvValue, shift: SpirvValue, is_left: bool) -> SpirvValue {

Callers 1

gep_helpMethod · 0.80

Calls 5

lookup_const_u64Method · 0.80
with_typeMethod · 0.80
zombieMethod · 0.80
emitMethod · 0.45
defMethod · 0.45

Tested by

no test coverage detected