about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-11-25 22:00:43 -0800
committerBrian Anderson <banderson@mozilla.com>2011-11-25 22:54:10 -0800
commit9a188b2e94007422cbc16a858cb56c96c726bf73 (patch)
tree9fdef3ab96fddeb21d42ce389c8fdb03cf7399a0 /src/rustllvm/RustWrapper.cpp
parent143f87899b0548700d5b799efd53594602114195 (diff)
downloadrust-9a188b2e94007422cbc16a858cb56c96c726bf73.tar.gz
rust-9a188b2e94007422cbc16a858cb56c96c726bf73.zip
rustc: Fall back to intrinsics.ll if we can't parse the bc
This will allow us to transition to the new bitcode format.
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
-rw-r--r--src/rustllvm/RustWrapper.cpp15
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))