radeonsi: merge si_llvm_get_amdgpu_target into ac_get_llvm_target
authorMarek Olšák <marek.olsak@amd.com>
Tue, 4 Jul 2017 20:38:37 +0000 (22:38 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 17 Jul 2017 14:50:39 +0000 (10:50 -0400)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/amd/common/ac_llvm_util.c
src/amd/common/ac_llvm_util.h
src/gallium/drivers/radeonsi/si_pipe.c
src/gallium/drivers/radeonsi/si_shader_internal.h
src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c

index ea752e031ef11f98400cfbcc9f26996574956097..675926ea679bf64580a38d0e65417713d0a32b82 100644 (file)
@@ -40,21 +40,23 @@ static void ac_init_llvm_target()
        LLVMInitializeAMDGPUTargetMC();
        LLVMInitializeAMDGPUAsmPrinter();
 
-       /*
-        * Workaround for bug in llvm 4.0 that causes image intrinsics
+       /* For inline assembly. */
+       LLVMInitializeAMDGPUAsmParser();
+
+       /* Workaround for bug in llvm 4.0 that causes image intrinsics
         * to disappear.
         * https://reviews.llvm.org/D26348
         */
-#if HAVE_LLVM >= 0x0400
-       const char *argv[2] = {"mesa", "-simplifycfg-sink-common=false"};
-       LLVMParseCommandLineOptions(2, argv, NULL);
-#endif
-
+       if (HAVE_LLVM >= 0x0400) {
+               /* "mesa" is the prefix for error messages */
+               const char *argv[2] = { "mesa", "-simplifycfg-sink-common=false" };
+               LLVMParseCommandLineOptions(2, argv, NULL);
+       }
 }
 
 static once_flag ac_init_llvm_target_once_flag = ONCE_FLAG_INIT;
 
-static LLVMTargetRef ac_get_llvm_target(const char *triple)
+LLVMTargetRef ac_get_llvm_target(const char *triple)
 {
        LLVMTargetRef target = NULL;
        char *err_message = NULL;
index 21f3e8377476fd8741a5be143a9e5b9e750951be..cc4fe3bd632c8ae775c7215d9b5030d13575d542 100644 (file)
@@ -60,6 +60,7 @@ enum ac_target_machine_options {
 };
 LLVMTargetMachineRef ac_create_target_machine(enum radeon_family family, enum ac_target_machine_options tm_options);
 
+LLVMTargetRef ac_get_llvm_target(const char *triple);
 void ac_add_attr_dereferenceable(LLVMValueRef val, uint64_t bytes);
 bool ac_is_sgpr_param(LLVMValueRef param);
 void ac_add_function_attr(LLVMContextRef ctx, LLVMValueRef function,
index 5f3b7e112ce1d026d5484838a3df3b9ccae7708b..afb2bcbf078620b04599adfec8982eceaff66ed6 100644 (file)
@@ -145,7 +145,7 @@ si_create_llvm_target_machine(struct si_screen *sscreen)
                 sscreen->b.chip_class >= GFX9 ? ",+xnack" : ",-xnack",
                 sscreen->b.debug_flags & DBG_SI_SCHED ? ",+si-scheduler" : "");
 
-       return LLVMCreateTargetMachine(si_llvm_get_amdgpu_target(triple), triple,
+       return LLVMCreateTargetMachine(ac_get_llvm_target(triple), triple,
                                       r600_get_llvm_processor_name(sscreen->b.family),
                                       features,
                                       LLVMCodeGenLevelDefault,
index 3556e69cd0e080e28b686b73732fb35ad10b2a06..6e86e0b56dc83992c2708c519219e56b6647bea9 100644 (file)
@@ -246,8 +246,6 @@ si_shader_context(struct lp_build_tgsi_context *bld_base)
 
 void si_llvm_add_attribute(LLVMValueRef F, const char *name, int value);
 
-LLVMTargetRef si_llvm_get_amdgpu_target(const char *triple);
-
 unsigned si_llvm_compile(LLVMModuleRef M, struct ac_shader_binary *binary,
                         LLVMTargetMachineRef tm,
                         struct pipe_debug_callback *debug);
index 3f20cd1d03ddbb2f9c9116cdc7036b22f8bd608a..b37d4b232b15ffef73ce6a30bba034d5780a2b2d 100644 (file)
@@ -40,7 +40,6 @@
 #include <stdio.h>
 #include <llvm-c/Transforms/IPO.h>
 #include <llvm-c/Transforms/Scalar.h>
-#include <llvm-c/Support.h>
 
 /* Data for if/else/endif and bgnloop/endloop control flow structures.
  */
@@ -66,47 +65,6 @@ void si_llvm_add_attribute(LLVMValueRef F, const char *name, int value)
        LLVMAddTargetDependentFunctionAttr(F, name, str);
 }
 
-static void init_amdgpu_target()
-{
-       LLVMInitializeAMDGPUTargetInfo();
-       LLVMInitializeAMDGPUTarget();
-       LLVMInitializeAMDGPUTargetMC();
-       LLVMInitializeAMDGPUAsmPrinter();
-
-       /* For inline assembly. */
-       LLVMInitializeAMDGPUAsmParser();
-
-       if (HAVE_LLVM >= 0x0400) {
-               /*
-                * Workaround for bug in llvm 4.0 that causes image intrinsics
-                * to disappear.
-                * https://reviews.llvm.org/D26348
-                */
-               const char *argv[2] = {"mesa", "-simplifycfg-sink-common=false"};
-               LLVMParseCommandLineOptions(2, argv, NULL);
-       }
-}
-
-static once_flag init_amdgpu_target_once_flag = ONCE_FLAG_INIT;
-
-LLVMTargetRef si_llvm_get_amdgpu_target(const char *triple)
-{
-       LLVMTargetRef target = NULL;
-       char *err_message = NULL;
-
-       call_once(&init_amdgpu_target_once_flag, init_amdgpu_target);
-
-       if (LLVMGetTargetFromTriple(triple, &target, &err_message)) {
-               fprintf(stderr, "Cannot find target for triple %s ", triple);
-               if (err_message) {
-                       fprintf(stderr, "%s\n", err_message);
-               }
-               LLVMDisposeMessage(err_message);
-               return NULL;
-       }
-       return target;
-}
-
 struct si_llvm_diagnostics {
        struct pipe_debug_callback *debug;
        unsigned retval;