rustc: Add a binding to LLVM's bitcode parser
This commit is contained in:
parent
6b742aec91
commit
5fb6e6364b
@ -16,6 +16,10 @@ tag output_type {
|
||||
output_type_object;
|
||||
}
|
||||
|
||||
fn link_intrinsics(session.session sess, ModuleRef llmod) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
mod Write {
|
||||
fn is_object_or_assembly(output_type ot) -> bool {
|
||||
if (ot == output_type_assembly) {
|
||||
@ -41,6 +45,8 @@ mod Write {
|
||||
}
|
||||
|
||||
fn run_passes(session.session sess, ModuleRef llmod, str output) {
|
||||
link_intrinsics(sess, llmod);
|
||||
|
||||
auto pm = mk_pass_manager();
|
||||
auto opts = sess.get_opts();
|
||||
|
||||
|
@ -848,6 +848,9 @@ native mod llvm = llvm_lib {
|
||||
call. */
|
||||
fn LLVMRustGetLastError() -> sbuf;
|
||||
|
||||
/** Parses the bitcode in the given memory buffer. */
|
||||
fn LLVMRustParseBitcode(MemoryBufferRef MemBuf) -> ModuleRef;
|
||||
|
||||
/** Links LLVM modules together. `Src` is destroyed by this call and
|
||||
must never be referenced again. */
|
||||
fn LLVMLinkModules(ModuleRef Dest, ModuleRef Src) -> Bool;
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "llvm/Target/TargetRegistry.h"
|
||||
#include "llvm/Target/TargetOptions.h"
|
||||
#include "llvm-c/Core.h"
|
||||
#include "llvm-c/BitReader.h"
|
||||
#include "llvm-c/Object.h"
|
||||
#include <cstdlib>
|
||||
|
||||
@ -98,3 +99,10 @@ extern "C" void LLVMRustWriteOutputFile(LLVMPassManagerRef PMR,
|
||||
(void)foo;
|
||||
PM->run(*unwrap(M));
|
||||
}
|
||||
|
||||
extern "C" LLVMModuleRef LLVMRustParseBitcode(LLVMMemoryBufferRef MemBuf) {
|
||||
LLVMModuleRef M;
|
||||
return LLVMParseBitcode(MemBuf, &M, const_cast<char **>(&LLVMRustError))
|
||||
? NULL : M;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
LLVMRustCreateMemoryBufferWithContentsOfFile
|
||||
LLVMRustWriteOutputFile
|
||||
LLVMRustGetLastError
|
||||
LLVMRustParseBitcode
|
||||
LLVMLinkModules
|
||||
LLVMCreateObjectFile
|
||||
LLVMDisposeObjectFile
|
||||
|
Loading…
x
Reference in New Issue
Block a user