ac: import lp_create_builder() from gallivm
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 15 Jan 2018 13:51:43 +0000 (14:51 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Tue, 16 Jan 2018 20:39:53 +0000 (21:39 +0100)
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/common/ac_llvm_helper.cpp
src/amd/common/ac_llvm_util.h
src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
src/gallium/auxiliary/gallivm/lp_bld_misc.h
src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c

index 4db703622ca988acc653952cef07406eba31c6c2..e42d00280bc71bc24f05d99bd0ada169308b9dbf 100644 (file)
@@ -35,6 +35,7 @@
 #include <llvm/ExecutionEngine/ExecutionEngine.h>
 #include <llvm/IR/Attributes.h>
 #include <llvm/IR/CallSite.h>
+#include <llvm/IR/IRBuilder.h>
 
 #if HAVE_LLVM < 0x0500
 namespace llvm {
@@ -80,3 +81,32 @@ bool ac_llvm_is_function(LLVMValueRef v)
        return llvm::isa<llvm::Function>(llvm::unwrap(v));
 #endif
 }
+
+LLVMBuilderRef ac_create_builder(LLVMContextRef ctx,
+                                enum ac_float_mode float_mode)
+{
+       LLVMBuilderRef builder = LLVMCreateBuilderInContext(ctx);
+
+#if HAVE_LLVM >= 0x0308
+       llvm::FastMathFlags flags;
+
+       switch (float_mode) {
+       case AC_FLOAT_MODE_DEFAULT:
+               break;
+       case AC_FLOAT_MODE_NO_SIGNED_ZEROS_FP_MATH:
+               flags.setNoSignedZeros();
+               llvm::unwrap(builder)->setFastMathFlags(flags);
+               break;
+       case AC_FLOAT_MODE_UNSAFE_FP_MATH:
+#if HAVE_LLVM >= 0x0600
+               flags.setFast();
+#else
+               flags.setUnsafeAlgebra();
+#endif
+               llvm::unwrap(builder)->setFastMathFlags(flags);
+               break;
+       }
+#endif
+
+       return builder;
+}
index 61bcc4e54edf99b04fc2cf62a81ee647cadf2404..84fcbf111cf125fc0aca01e7daf1db077ed5b2d7 100644 (file)
@@ -62,6 +62,12 @@ enum ac_target_machine_options {
        AC_TM_PROMOTE_ALLOCA_TO_SCRATCH = (1 << 4),
 };
 
+enum ac_float_mode {
+       AC_FLOAT_MODE_DEFAULT,
+       AC_FLOAT_MODE_NO_SIGNED_ZEROS_FP_MATH,
+       AC_FLOAT_MODE_UNSAFE_FP_MATH,
+};
+
 const char *ac_get_llvm_processor_name(enum radeon_family family);
 LLVMTargetMachineRef ac_create_target_machine(enum radeon_family family, enum ac_target_machine_options tm_options);
 
@@ -77,6 +83,9 @@ void ac_dump_module(LLVMModuleRef module);
 LLVMValueRef ac_llvm_get_called_value(LLVMValueRef call);
 bool ac_llvm_is_function(LLVMValueRef v);
 
+LLVMBuilderRef ac_create_builder(LLVMContextRef ctx,
+                                enum ac_float_mode float_mode);
+
 void
 ac_llvm_add_target_dep_function_attr(LLVMValueRef F,
                                     const char *name, int value);
index 13194072902a1302eb99f859c12c35822087423b..79dbedbb565bc195b486d42d70afc9248f9eb9fd 100644 (file)
@@ -813,32 +813,3 @@ lp_is_function(LLVMValueRef v)
        return llvm::isa<llvm::Function>(llvm::unwrap(v));
 #endif
 }
-
-extern "C" LLVMBuilderRef
-lp_create_builder(LLVMContextRef ctx, enum lp_float_mode float_mode)
-{
-   LLVMBuilderRef builder = LLVMCreateBuilderInContext(ctx);
-
-#if HAVE_LLVM >= 0x0308
-   llvm::FastMathFlags flags;
-
-   switch (float_mode) {
-   case LP_FLOAT_MODE_DEFAULT:
-      break;
-   case LP_FLOAT_MODE_NO_SIGNED_ZEROS_FP_MATH:
-      flags.setNoSignedZeros();
-      llvm::unwrap(builder)->setFastMathFlags(flags);
-      break;
-   case LP_FLOAT_MODE_UNSAFE_FP_MATH:
-#if HAVE_LLVM >= 0x0600
-      flags.setFast();
-#else
-      flags.setUnsafeAlgebra();
-#endif
-      llvm::unwrap(builder)->setFastMathFlags(flags);
-      break;
-   }
-#endif
-
-   return builder;
-}
index 1b725d10d7ca5882492a7cc69eab94a24f04654f..ca5ba5c44f2ba3e15c7a1610e53340e669cfb0e2 100644 (file)
@@ -76,15 +76,6 @@ lp_get_called_value(LLVMValueRef call);
 extern bool
 lp_is_function(LLVMValueRef v);
 
-enum lp_float_mode {
-   LP_FLOAT_MODE_DEFAULT,
-   LP_FLOAT_MODE_NO_SIGNED_ZEROS_FP_MATH,
-   LP_FLOAT_MODE_UNSAFE_FP_MATH,
-};
-
-extern LLVMBuilderRef
-lp_create_builder(LLVMContextRef ctx, enum lp_float_mode float_mode);
-
 #ifdef __cplusplus
 }
 #endif
index 2ca036e67d366c90c8a25f4b8ce32659a0c4fd15..fc141ca1e03cc68be298f4a02d4d450f87190a97 100644 (file)
@@ -1160,11 +1160,11 @@ void si_llvm_context_init(struct si_shader_context *ctx,
        LLVMDisposeMessage(data_layout_str);
 
        bool unsafe_fpmath = (sscreen->debug_flags & DBG(UNSAFE_MATH)) != 0;
-       enum lp_float_mode float_mode =
-               unsafe_fpmath ? LP_FLOAT_MODE_UNSAFE_FP_MATH :
-                               LP_FLOAT_MODE_NO_SIGNED_ZEROS_FP_MATH;
+       enum ac_float_mode float_mode =
+               unsafe_fpmath ? AC_FLOAT_MODE_UNSAFE_FP_MATH :
+                               AC_FLOAT_MODE_NO_SIGNED_ZEROS_FP_MATH;
 
-       ctx->gallivm.builder = lp_create_builder(ctx->gallivm.context,
+       ctx->gallivm.builder = ac_create_builder(ctx->gallivm.context,
                                                 float_mode);
 
        ac_llvm_context_init(&ctx->ac, ctx->gallivm.context,