diff options
author | Tom Stellard <[email protected]> | 2013-03-07 16:51:11 -0500 |
---|---|---|
committer | Tom Stellard <[email protected]> | 2013-03-13 16:01:31 +0000 |
commit | 2ace79dce5b6df453a903eb1ab51b688e0c00dd6 (patch) | |
tree | 9de285a6cbc80c6468789f532bb5377bebbd0b99 /src/gallium/drivers/radeon | |
parent | b34b8576ecde91c4d1898e7b9cd35f87b4ec2aa5 (diff) |
radeon/llvm: Implement radeon_llvm_get_kernel_module() using the C API
Diffstat (limited to 'src/gallium/drivers/radeon')
-rw-r--r-- | src/gallium/drivers/radeon/Makefile.am | 1 | ||||
-rw-r--r-- | src/gallium/drivers/radeon/radeon_llvm_util.cpp | 21 |
2 files changed, 15 insertions, 7 deletions
diff --git a/src/gallium/drivers/radeon/Makefile.am b/src/gallium/drivers/radeon/Makefile.am index e6eb2419d86..678a0cb31d9 100644 --- a/src/gallium/drivers/radeon/Makefile.am +++ b/src/gallium/drivers/radeon/Makefile.am @@ -14,6 +14,7 @@ noinst_LTLIBRARIES = libllvmradeon@[email protected] endif AM_CXXFLAGS = \ + $(GALLIUM_CFLAGS) \ $(filter-out -DDEBUG, $(LLVM_CXXFLAGS)) \ $(DEFINES) diff --git a/src/gallium/drivers/radeon/radeon_llvm_util.cpp b/src/gallium/drivers/radeon/radeon_llvm_util.cpp index fcfb6d8966d..17a31228087 100644 --- a/src/gallium/drivers/radeon/radeon_llvm_util.cpp +++ b/src/gallium/drivers/radeon/radeon_llvm_util.cpp @@ -14,6 +14,7 @@ #include <llvm-c/Core.h> #include "radeon_llvm_util.h" +#include "util/u_memory.h" static LLVMModuleRef radeon_llvm_parse_bitcode(const unsigned char * bitcode, @@ -49,13 +50,19 @@ extern "C" unsigned radeon_llvm_get_num_kernels(const unsigned char *bitcode, extern "C" LLVMModuleRef radeon_llvm_get_kernel_module(unsigned index, const unsigned char *bitcode, unsigned bitcode_len) { - LLVMModuleRef mod = radeon_llvm_parse_bitcode(bitcode, bitcode_len); - llvm::Module *M = llvm::unwrap(mod); - const llvm::NamedMDNode *kernel_node = - M->getNamedMetadata("opencl.kernels"); - const char* kernel_name = kernel_node->getOperand(index)-> - getOperand(0)->getName().data(); + LLVMModuleRef mod; + unsigned num_kernels; + LLVMValueRef *kernel_metadata; + LLVMValueRef kernel_signature, kernel_function; + + mod = radeon_llvm_parse_bitcode(bitcode, bitcode_len); + num_kernels = LLVMGetNamedMetadataNumOperands(mod, "opencl.kernels"); + kernel_metadata = (LLVMValueRef*)MALLOC(num_kernels * sizeof(LLVMValueRef)); + LLVMGetNamedMetadataOperands(mod, "opencl.kernels", kernel_metadata); + kernel_signature = kernel_metadata[index]; + LLVMGetMDNodeOperands(kernel_signature, &kernel_function); + const char* kernel_name = LLVMGetValueName(kernel_function); radeon_llvm_strip_unused_kernels(mod, kernel_name); + FREE(kernel_metadata); return mod; - } |