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

Function create_module

crates/rustc_codegen_nvvm/src/lib.rs:312–327  ·  view source on GitHub ↗

Create the LLVM module for the rest of the compilation, this houses the LLVM bitcode we then add to the NVVM program and feed to libnvvm. LLVM's codegen is never actually called.

(
    llcx: &'ll llvm::Context,
    mod_name: &str,
)

Source from the content-addressed store, hash-verified

310/// the LLVM bitcode we then add to the NVVM program and feed to libnvvm.
311/// LLVM's codegen is never actually called.
312pub(crate) unsafe fn create_module<'ll>(
313 llcx: &'ll llvm::Context,
314 mod_name: &str,
315) -> &'ll llvm::Module {
316 debug!("Creating llvm module with name `{}`", mod_name);
317 let mod_name = CString::new(mod_name).expect("nul in module name");
318 let llmod = llvm::LLVMModuleCreateWithNameInContext(mod_name.as_ptr(), llcx);
319
320 let data_layout = CString::new(target::data_layout()).unwrap();
321 llvm::LLVMSetDataLayout(llmod, data_layout.as_ptr());
322
323 let target = CString::new(target::target_triple()).unwrap();
324 llvm::LLVMSetTarget(llmod, target.as_ptr());
325
326 llmod
327}
328
329/// Wrapper over raw llvm structures
330pub struct LlvmMod {

Callers 2

newMethod · 0.85
merge_llvm_modulesFunction · 0.85

Calls 5

newFunction · 0.85
data_layoutFunction · 0.85
target_tripleFunction · 0.85
as_ptrMethod · 0.80
expectMethod · 0.45

Tested by

no test coverage detected