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

Method const_struct

crates/rustc_codegen_spirv/src/codegen_cx/constant.rs:190–205  ·  view source on GitHub ↗
(&self, elts: &[Self::Value], _packed: bool)

Source from the content-addressed store, hash-verified

188 )
189 }
190 fn const_struct(&self, elts: &[Self::Value], _packed: bool) -> Self::Value {
191 // Presumably this will get bitcasted to the right type?
192 // FIXME(eddyb) use `AccumulateVec`s just like `rustc` itself does.
193 let field_types = elts.iter().map(|f| f.ty).collect::<Vec<_>>();
194 let (field_offsets, size, align) = crate::abi::auto_struct_layout(self, &field_types);
195 let struct_ty = SpirvType::Adt {
196 def_id: None,
197 size,
198 align,
199 field_types: &field_types,
200 field_offsets: &field_offsets,
201 field_names: None,
202 }
203 .def(DUMMY_SP, self);
204 self.constant_composite(struct_ty, elts.iter().map(|f| f.def_cx(self)))
205 }
206
207 fn const_to_opt_uint(&self, v: Self::Value) -> Option<u64> {
208 self.builder.lookup_const_u64(v)

Callers

nothing calls this directly

Calls 5

auto_struct_layoutFunction · 0.85
iterMethod · 0.80
constant_compositeMethod · 0.80
def_cxMethod · 0.80
defMethod · 0.45

Tested by

no test coverage detected