Add a safe wrapper for LLVMAppendModuleInlineAsm
This patch also changes the Rust-side declaration to take `*const c_uchar` instead of `*const c_char`, to avoid the need for `AsCCharPtr`.
This commit is contained in:
@@ -1014,8 +1014,12 @@ unsafe extern "C" {
|
||||
pub(crate) fn LLVMGetDataLayoutStr(M: &Module) -> *const c_char;
|
||||
pub(crate) fn LLVMSetDataLayout(M: &Module, Triple: *const c_char);
|
||||
|
||||
/// See Module::setModuleInlineAsm.
|
||||
pub(crate) fn LLVMAppendModuleInlineAsm(M: &Module, Asm: *const c_char, Len: size_t);
|
||||
/// Append inline assembly to a module. See `Module::appendModuleInlineAsm`.
|
||||
pub(crate) fn LLVMAppendModuleInlineAsm(
|
||||
M: &Module,
|
||||
Asm: *const c_uchar, // See "PTR_LEN_STR".
|
||||
Len: size_t,
|
||||
);
|
||||
|
||||
/// Create the specified uniqued inline asm string. See `InlineAsm::get()`.
|
||||
pub(crate) fn LLVMGetInlineAsm<'ll>(
|
||||
|
||||
@@ -440,3 +440,11 @@ pub(crate) fn set_dso_local<'ll>(v: &'ll Value) {
|
||||
LLVMRustSetDSOLocal(v, true);
|
||||
}
|
||||
}
|
||||
|
||||
/// Safe wrapper for `LLVMAppendModuleInlineAsm`, which delegates to
|
||||
/// `Module::appendModuleInlineAsm`.
|
||||
pub(crate) fn append_module_inline_asm<'ll>(llmod: &'ll Module, asm: &[u8]) {
|
||||
unsafe {
|
||||
LLVMAppendModuleInlineAsm(llmod, asm.as_ptr(), asm.len());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user