MCPcopy Create free account
hub / github.com/Rust-GPU/rust-cuda / static_addrspace

Method static_addrspace

crates/rustc_codegen_nvvm/src/context.rs:267–282  ·  view source on GitHub ↗

Computes the address space for a static.

(&self, instance: Instance<'tcx>)

Source from the content-addressed store, hash-verified

265impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
266 /// Computes the address space for a static.
267 pub fn static_addrspace(&self, instance: Instance<'tcx>) -> AddressSpace {
268 let ty = instance.ty(self.tcx, ty::ParamEnv::reveal_all());
269 let is_mutable = self.tcx().is_mutable_static(instance.def_id());
270 let attrs = self.tcx.get_attrs(instance.def_id());
271 let nvvm_attrs = NvvmAttributes::parse(self, attrs);
272
273 if let Some(addr) = nvvm_attrs.addrspace {
274 return AddressSpace(addr as u32);
275 }
276
277 if !is_mutable && self.type_is_freeze(ty) {
278 AddressSpace(4)
279 } else {
280 AddressSpace::DATA
281 }
282 }
283
284 /// Declare a global value, returns the existing value if it was already declared.
285 pub fn declare_global(

Callers 4

predefine_staticMethod · 0.80
check_and_apply_linkageFunction · 0.80
get_staticMethod · 0.80
codegen_staticMethod · 0.80

Calls 2

AddressSpaceEnum · 0.85
tcxMethod · 0.45

Tested by

no test coverage detected