summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Stellard <[email protected]>2013-03-07 16:51:09 -0500
committerTom Stellard <[email protected]>2013-03-13 16:01:30 +0000
commit7e9abbea15bf6ff717c1908870d9c2de219d69b4 (patch)
tree79d69763eec843d4a0e29f36321107efe3c41b55
parent97bfcddde0a0e827cb868b38c7da8d8692da6cce (diff)
radeon/llvm: Implement radeon_llvm_parse_bitcode() using C API
Also make the function static since it is not used anywhere else.
-rw-r--r--src/gallium/drivers/radeon/radeon_llvm_util.cpp18
-rw-r--r--src/gallium/drivers/radeon/radeon_llvm_util.h1
2 files changed, 11 insertions, 8 deletions
diff --git a/src/gallium/drivers/radeon/radeon_llvm_util.cpp b/src/gallium/drivers/radeon/radeon_llvm_util.cpp
index 22c6dc6f65c..5f63ed7a9c6 100644
--- a/src/gallium/drivers/radeon/radeon_llvm_util.cpp
+++ b/src/gallium/drivers/radeon/radeon_llvm_util.cpp
@@ -10,18 +10,22 @@
#include <llvm/Support/MemoryBuffer.h>
#include <llvm/Support/SourceMgr.h>
#include <llvm/Transforms/IPO.h>
+#include <llvm-c/BitReader.h>
+#include <llvm-c/Core.h>
#include "radeon_llvm_util.h"
-extern "C" LLVMModuleRef radeon_llvm_parse_bitcode(const unsigned char * bitcode, unsigned bitcode_len)
+static LLVMModuleRef radeon_llvm_parse_bitcode(const unsigned char * bitcode,
+ unsigned bitcode_len)
{
- llvm::OwningPtr<llvm::Module> M;
- llvm::StringRef str((const char*)bitcode, bitcode_len);
- llvm::MemoryBuffer* buffer = llvm::MemoryBuffer::getMemBufferCopy(str);
- llvm::SMDiagnostic Err;
- M.reset(llvm::ParseIR(buffer, Err, llvm::getGlobalContext()));
- return wrap(M.take());
+ LLVMMemoryBufferRef buf;
+ LLVMModuleRef module = LLVMModuleCreateWithName("radeon");
+
+ buf = LLVMCreateMemoryBufferWithMemoryRangeCopy((const char*)bitcode,
+ bitcode_len, "radeon");
+ LLVMParseBitcode(buf, &module, NULL);
+ return module;
}
extern "C" void radeon_llvm_strip_unused_kernels(LLVMModuleRef mod, const char *kernel_name)
diff --git a/src/gallium/drivers/radeon/radeon_llvm_util.h b/src/gallium/drivers/radeon/radeon_llvm_util.h
index a7dfa9baf56..e144164b759 100644
--- a/src/gallium/drivers/radeon/radeon_llvm_util.h
+++ b/src/gallium/drivers/radeon/radeon_llvm_util.h
@@ -7,7 +7,6 @@
extern "C" {
#endif
-LLVMModuleRef radeon_llvm_parse_bitcode(const unsigned char * bitcode, unsigned bitcode_len);
void radeon_llvm_strip_unused_kernels(LLVMModuleRef mod, const char *kernel_name);
unsigned radeon_llvm_get_num_kernels(const unsigned char *bitcode, unsigned bitcode_len);
LLVMModuleRef radeon_llvm_get_kernel_module(unsigned index,