radeon/llvm: Make radeon_llvm_util.cpp a C file
authorTom Stellard <thomas.stellard@amd.com>
Thu, 7 Mar 2013 21:51:13 +0000 (16:51 -0500)
committerTom Stellard <thomas.stellard@amd.com>
Wed, 13 Mar 2013 16:01:31 +0000 (16:01 +0000)
All the functions in this file are now implemented in C.

src/gallium/drivers/radeon/Makefile.sources
src/gallium/drivers/radeon/radeon_llvm_util.c [new file with mode: 0644]
src/gallium/drivers/radeon/radeon_llvm_util.cpp [deleted file]
src/gallium/drivers/radeon/radeon_llvm_util.h

index aa327490f444b344f4582c329ee0970f77b06ce1..efe0e6bb4da6dd2e9355046bfa2866acf01d8017 100644 (file)
@@ -1,6 +1,6 @@
 CPP_FILES := \
-       radeon_llvm_emit.cpp \
-       radeon_llvm_util.cpp
+       radeon_llvm_emit.cpp
 
 C_FILES := \
-       radeon_setup_tgsi_llvm.c
+       radeon_setup_tgsi_llvm.c \
+       radeon_llvm_util.c
diff --git a/src/gallium/drivers/radeon/radeon_llvm_util.c b/src/gallium/drivers/radeon/radeon_llvm_util.c
new file mode 100644 (file)
index 0000000..3d30612
--- /dev/null
@@ -0,0 +1,49 @@
+#include "radeon_llvm_util.h"
+#include "util/u_memory.h"
+
+#include <llvm-c/BitReader.h>
+#include <llvm-c/Core.h>
+
+static LLVMModuleRef radeon_llvm_parse_bitcode(const unsigned char * bitcode,
+                                                       unsigned bitcode_len)
+{
+       LLVMMemoryBufferRef buf;
+       LLVMModuleRef module = LLVMModuleCreateWithName("radeon");
+
+       buf = LLVMCreateMemoryBufferWithMemoryRangeCopy((const char*)bitcode,
+                                                       bitcode_len, "radeon");
+       LLVMParseBitcode(buf, &module, NULL);
+       return module;
+}
+
+unsigned radeon_llvm_get_num_kernels(const unsigned char *bitcode,
+                               unsigned bitcode_len)
+{
+       LLVMModuleRef mod = radeon_llvm_parse_bitcode(bitcode, bitcode_len);
+       return LLVMGetNamedMetadataNumOperands(mod, "opencl.kernels");
+}
+
+LLVMModuleRef radeon_llvm_get_kernel_module(unsigned index,
+               const unsigned char *bitcode, unsigned bitcode_len)
+{
+       LLVMModuleRef mod;
+       unsigned num_kernels;
+       LLVMValueRef *kernel_metadata;
+       unsigned i;
+
+       mod = radeon_llvm_parse_bitcode(bitcode, bitcode_len);
+       num_kernels = LLVMGetNamedMetadataNumOperands(mod, "opencl.kernels");
+       kernel_metadata = MALLOC(num_kernels * sizeof(LLVMValueRef));
+       LLVMGetNamedMetadataOperands(mod, "opencl.kernels", kernel_metadata);
+       for (i = 0; i < num_kernels; i++) {
+               LLVMValueRef kernel_signature, kernel_function;
+               if (i == index) {
+                       continue;
+               }
+               kernel_signature = kernel_metadata[i];
+               LLVMGetMDNodeOperands(kernel_signature, &kernel_function);
+               LLVMDeleteFunction(kernel_function);
+       }
+       FREE(kernel_metadata);
+       return mod;
+}
diff --git a/src/gallium/drivers/radeon/radeon_llvm_util.cpp b/src/gallium/drivers/radeon/radeon_llvm_util.cpp
deleted file mode 100644 (file)
index aa9f3b3..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-#include <llvm/ADT/OwningPtr.h>
-#include <llvm/ADT/StringRef.h>
-#if HAVE_LLVM < 0x0303
-#include <llvm/LLVMContext.h>
-#else
-#include <llvm/IR/LLVMContext.h>
-#endif
-#include <llvm/PassManager.h>
-#include <llvm/Support/IRReader.h>
-#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"
-#include "util/u_memory.h"
-
-
-static LLVMModuleRef radeon_llvm_parse_bitcode(const unsigned char * bitcode,
-                                                       unsigned bitcode_len)
-{
-       LLVMMemoryBufferRef buf;
-       LLVMModuleRef module = LLVMModuleCreateWithName("radeon");
-
-       buf = LLVMCreateMemoryBufferWithMemoryRangeCopy((const char*)bitcode,
-                                                       bitcode_len, "radeon");
-       LLVMParseBitcode(buf, &module, NULL);
-       return module;
-}
-
-extern "C" unsigned radeon_llvm_get_num_kernels(const unsigned char *bitcode,
-                               unsigned bitcode_len)
-{
-       LLVMModuleRef mod = radeon_llvm_parse_bitcode(bitcode, bitcode_len);
-       return LLVMGetNamedMetadataNumOperands(mod, "opencl.kernels");
-}
-
-extern "C" LLVMModuleRef radeon_llvm_get_kernel_module(unsigned index,
-               const unsigned char *bitcode, unsigned bitcode_len)
-{
-       LLVMModuleRef mod;
-       unsigned num_kernels;
-       LLVMValueRef *kernel_metadata;
-       unsigned i;
-
-       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);
-       for (i = 0; i < num_kernels; i++) {
-               LLVMValueRef kernel_signature, kernel_function;
-               if (i == index) {
-                       continue;
-               }
-               kernel_signature = kernel_metadata[i];
-               LLVMGetMDNodeOperands(kernel_signature, &kernel_function);
-               LLVMDeleteFunction(kernel_function);
-       }
-       FREE(kernel_metadata);
-       return mod;
-}
index 1e827ba0d7ced7cdc4ffdcabedf337e71827655c..a5870306195214eb4efc1521f71fd16cba22a198 100644 (file)
@@ -3,16 +3,8 @@
 
 #include <llvm-c/Core.h>
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 unsigned radeon_llvm_get_num_kernels(const unsigned char *bitcode, unsigned bitcode_len);
 LLVMModuleRef radeon_llvm_get_kernel_module(unsigned index,
                        const unsigned char *bitcode, unsigned bitcode_len);
 
-#ifdef __cplusplus
-}
-#endif
-
 #endif