diff options
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
| -rw-r--r-- | src/rustllvm/RustWrapper.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp index 635030fd0ad..edb87e99538 100644 --- a/src/rustllvm/RustWrapper.cpp +++ b/src/rustllvm/RustWrapper.cpp @@ -12,9 +12,11 @@ // //===----------------------------------------------------------------------=== +#include "llvm/LLVMContext.h" #include "llvm/Linker.h" #include "llvm/PassManager.h" #include "llvm/ADT/Triple.h" +#include "llvm/Assembly/Parser.h" #include "llvm/Assembly/PrintModulePass.h" #include "llvm/Support/FormattedStream.h" #include "llvm/Support/Timer.h" @@ -22,6 +24,7 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Support/TargetSelect.h" #include "llvm/Support/TargetRegistry.h" +#include "llvm/Support/SourceMgr.h" #include "llvm/Target/TargetOptions.h" #include "llvm/Support/Host.h" #include "llvm-c/Core.h" @@ -109,6 +112,18 @@ LLVMRustWriteOutputFile(LLVMPassManagerRef PMR, delete Target; } +extern "C" LLVMModuleRef LLVMRustParseAssemblyFile(const char *Filename) { + + SMDiagnostic d; + Module *m = ParseAssemblyFile(Filename, d, getGlobalContext()); + if (m) { + return wrap(m); + } else { + LLVMRustError = d.getMessage().c_str(); + return NULL; + } +} + extern "C" LLVMModuleRef LLVMRustParseBitcode(LLVMMemoryBufferRef MemBuf) { LLVMModuleRef M; return LLVMParseBitcode(MemBuf, &M, const_cast<char **>(&LLVMRustError)) |
