gallivm: Add helpers for creating and destroying TargetLibraryInfo
authorTom Stellard <thomas.stellard@amd.com>
Thu, 4 Feb 2016 19:36:50 +0000 (19:36 +0000)
committerTom Stellard <thomas.stellard@amd.com>
Wed, 17 Feb 2016 19:06:41 +0000 (19:06 +0000)
This functionality is not exposed via the LLVM C API.

Tested-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
src/gallium/auxiliary/gallivm/lp_bld_misc.h

index 3ee708f4fad63ebf3cca9ea8c65d43cb17d09cb7..30ef37c9d224dd54da650d60c71fb04405734ca7 100644 (file)
 #include <llvm/Target/TargetOptions.h>
 #include <llvm/ExecutionEngine/ExecutionEngine.h>
 #include <llvm/ADT/Triple.h>
+#if HAVE_LLVM >= 0x0307
+#include <llvm/Analysis/TargetLibraryInfo.h>
+#else
+#include <llvm/Target/TargetLibraryInfo.h>
+#endif
 #if HAVE_LLVM < 0x0306
 #include <llvm/ExecutionEngine/JITMemoryManager.h>
 #else
@@ -147,6 +152,31 @@ lp_set_target_options(void)
    gallivm_init_llvm_targets();
 }
 
+extern "C"
+LLVMTargetLibraryInfoRef
+gallivm_create_target_library_info(const char *triple)
+{
+   return reinterpret_cast<LLVMTargetLibraryInfoRef>(
+#if HAVE_LLVM < 0x0307
+   new llvm::TargetLibraryInfo(
+#else
+   new llvm::TargetLibraryInfoImpl(
+#endif
+   llvm::Triple(triple)));
+}
+
+extern "C"
+void
+gallivm_dispose_target_library_info(LLVMTargetLibraryInfoRef library_info)
+{
+   delete reinterpret_cast<
+#if HAVE_LLVM < 0x0307
+   llvm::TargetLibraryInfo
+#else
+   llvm::TargetLibraryInfoImpl
+#endif
+   *>(library_info);
+}
 
 extern "C"
 LLVMValueRef
index 86d2f86ac45a1f32ff5fcf1b5a34ccb5bfbe50f0..30b7b1674af97a1bbfa4dc4bb1aeefa6e608b65d 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "lp_bld.h"
 #include <llvm-c/ExecutionEngine.h>
+#include <llvm-c/Target.h>
 
 
 #ifdef __cplusplus
@@ -44,6 +45,12 @@ struct lp_generated_code;
 extern void
 gallivm_init_llvm_targets(void);
 
+extern LLVMTargetLibraryInfoRef
+gallivm_create_target_library_info(const char *triple);
+
+extern void
+gallivm_dispose_target_library_info(LLVMTargetLibraryInfoRef library_info);
+
 extern void
 lp_set_target_options(void);