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

Method predefine_static

crates/rustc_codegen_spirv/src/codegen_cx/declare.rs:267–295  ·  view source on GitHub ↗
(
        &self,
        def_id: DefId,
        linkage: Linkage,
        _visibility: Visibility,
        symbol_name: &str,
    )

Source from the content-addressed store, hash-verified

265
266impl<'tcx> PreDefineMethods<'tcx> for CodegenCx<'tcx> {
267 fn predefine_static(
268 &self,
269 def_id: DefId,
270 linkage: Linkage,
271 _visibility: Visibility,
272 symbol_name: &str,
273 ) {
274 let instance = Instance::mono(self.tcx, def_id);
275 let ty = instance.ty(self.tcx, ParamEnv::reveal_all());
276 let span = self.tcx.def_span(def_id);
277 let spvty = self.layout_of(ty).spirv_type(span, self);
278 let linkage = match linkage {
279 Linkage::External => Some(LinkageType::Export),
280 Linkage::Internal => None,
281 other => {
282 self.tcx.sess.err(format!(
283 "TODO: Linkage type {other:?} not supported yet for static var symbol {symbol_name}"
284 ));
285 None
286 }
287 };
288
289 let g = self.declare_global(span, spvty);
290
291 self.instances.borrow_mut().insert(instance, g);
292 if let Some(linkage) = linkage {
293 self.set_linkage(g.def_cx(self), symbol_name.to_string(), linkage);
294 }
295 }
296
297 fn predefine_fn(
298 &self,

Callers

nothing calls this directly

Calls 7

tyMethod · 0.80
spirv_typeMethod · 0.80
errMethod · 0.80
declare_globalMethod · 0.80
insertMethod · 0.80
set_linkageMethod · 0.80
def_cxMethod · 0.80

Tested by

no test coverage detected