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

Method store

crates/rustc_codegen_spirv/src/builder/builder_methods.rs:1236–1261  ·  view source on GitHub ↗
(&mut self, val: Self::Value, ptr: Self::Value, _align: Align)

Source from the content-addressed store, hash-verified

1234 }
1235
1236 fn store(&mut self, val: Self::Value, ptr: Self::Value, _align: Align) -> Self::Value {
1237 let ptr_elem_ty = match self.lookup_type(ptr.ty) {
1238 SpirvType::Pointer { pointee } => pointee,
1239 ty => self.fatal(&format!(
1240 "store called on variable that wasn't a pointer: {ty:?}"
1241 )),
1242 };
1243
1244 // HACK(eddyb) https://github.com/rust-lang/rust/pull/101483 accidentally
1245 // abused the fact that an `i1` LLVM value will be automatically `zext`'d
1246 // to `i8` by `from_immediate`, and so you can pretend that, from the
1247 // Rust perspective, a `bool` value has the type `u8`, as long as it will
1248 // be stored to memory (which intrinsics all do, for historical reasons)
1249 // - but we don't do that in `from_immediate`, so it's emulated here.
1250 let val = match (self.lookup_type(val.ty), self.lookup_type(ptr_elem_ty)) {
1251 (SpirvType::Bool, SpirvType::Integer(8, false)) => self.zext(val, ptr_elem_ty),
1252
1253 _ => val,
1254 };
1255
1256 assert_ty_eq!(self, ptr_elem_ty, val.ty);
1257 self.emit()
1258 .store(ptr.def(self), val.def(self), None, empty())
1259 .unwrap();
1260 val
1261 }
1262
1263 fn store_with_flags(
1264 &mut self,

Callers 10

codegen_asmMethod · 0.45
store_fn_argMethod · 0.45
store_argMethod · 0.45
store_u32Method · 0.45
memset_constant_sizeMethod · 0.45
memset_dynamic_sizeMethod · 0.45
store_with_flagsMethod · 0.45
memcpyMethod · 0.45

Calls 5

lookup_typeMethod · 0.80
fatalMethod · 0.80
zextMethod · 0.80
emitMethod · 0.45
defMethod · 0.45

Tested by

no test coverage detected