From 9a188b2e94007422cbc16a858cb56c96c726bf73 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Fri, 25 Nov 2011 22:00:43 -0800 Subject: rustc: Fall back to intrinsics.ll if we can't parse the bc This will allow us to transition to the new bitcode format. --- src/rustllvm/RustWrapper.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/rustllvm/RustWrapper.cpp') 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(&LLVMRustError)) -- cgit 1.4.1-3-g733a5