Home | History | Annotate | Download | only in r600
      1 #include <llvm/ADT/OwningPtr.h>
      2 #include <llvm/ADT/StringRef.h>
      3 #include <llvm/LLVMContext.h>
      4 #include <llvm/Support/IRReader.h>
      5 #include <llvm/Support/MemoryBuffer.h>
      6 #include <llvm/Support/SourceMgr.h>
      7 
      8 #include "llvm_wrapper.h"
      9 
     10 
     11 extern "C" LLVMModuleRef llvm_parse_bitcode(const unsigned char * bitcode, unsigned bitcode_len)
     12 {
     13 	llvm::OwningPtr<llvm::Module> M;
     14 	llvm::StringRef str((const char*)bitcode, bitcode_len);
     15 	llvm::MemoryBuffer*  buffer = llvm::MemoryBuffer::getMemBufferCopy(str);
     16 	llvm::SMDiagnostic Err;
     17 	M.reset(llvm::ParseIR(buffer, Err, llvm::getGlobalContext()));
     18 	return wrap(M.take());
     19 }
     20