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

Method declare_global

crates/rustc_codegen_nvvm/src/context.rs:285–303  ·  view source on GitHub ↗

Declare a global value, returns the existing value if it was already declared.

(
        &self,
        name: &str,
        ty: &'ll Type,
        address_space: AddressSpace,
    )

Source from the content-addressed store, hash-verified

283
284 /// Declare a global value, returns the existing value if it was already declared.
285 pub fn declare_global(
286 &self,
287 name: &str,
288 ty: &'ll Type,
289 address_space: AddressSpace,
290 ) -> &'ll Value {
291 // NVVM doesnt allow `.` inside of globals, this should be sound, at worst it should result in an nvvm error if something goes wrong.
292 let name = sanitize_global_ident(name);
293 trace!("Declaring global `{}`", name);
294 unsafe {
295 llvm::LLVMRustGetOrInsertGlobal(
296 self.llmod,
297 name.as_ptr().cast(),
298 name.len(),
299 ty,
300 address_space.0,
301 )
302 }
303 }
304
305 /// Declare a function. All functions use the default ABI, NVVM ignores any calling convention markers.
306 /// All functions calls are generated according to the PTX calling convention.

Callers 3

check_and_apply_linkageFunction · 0.80
get_staticMethod · 0.80
define_globalMethod · 0.80

Calls 5

sanitize_global_identFunction · 0.85
as_ptrMethod · 0.80
castMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected