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,
)
| 310 | /// the LLVM bitcode we then add to the NVVM program and feed to libnvvm. |
| 311 | /// LLVM's codegen is never actually called. |
| 312 | pub(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 |
| 330 | pub struct LlvmMod { |
no test coverage detected