upstream rustc_codegen_llvm changes for enzyme/autodiff
This commit is contained in:
parent
372442fe5f
commit
d753cbf779
17 changed files with 610 additions and 28 deletions
|
@ -1,6 +1,6 @@
|
|||
use std::borrow::Borrow;
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::ffi::{CStr, c_uint};
|
||||
use std::ffi::{CStr, c_char, c_uint};
|
||||
use std::str;
|
||||
|
||||
use rustc_abi::{HasDataLayout, TargetDataLayout, VariantIdx};
|
||||
|
@ -600,6 +600,31 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
|
|||
llvm::set_section(g, c"llvm.metadata");
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn get_metadata_value(&self, metadata: &'ll Metadata) -> &'ll Value {
|
||||
unsafe { llvm::LLVMMetadataAsValue(self.llcx, metadata) }
|
||||
}
|
||||
|
||||
pub(crate) fn get_function(&self, name: &str) -> Option<&'ll Value> {
|
||||
let name = SmallCStr::new(name);
|
||||
unsafe { llvm::LLVMGetNamedFunction(self.llmod, name.as_ptr()) }
|
||||
}
|
||||
|
||||
pub(crate) fn get_md_kind_id(&self, name: &str) -> u32 {
|
||||
unsafe {
|
||||
llvm::LLVMGetMDKindIDInContext(
|
||||
self.llcx,
|
||||
name.as_ptr() as *const c_char,
|
||||
name.len() as c_uint,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn create_metadata(&self, name: String) -> Option<&'ll Metadata> {
|
||||
Some(unsafe {
|
||||
llvm::LLVMMDStringInContext2(self.llcx, name.as_ptr() as *const c_char, name.len())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ll, 'tcx> MiscCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue