diff options
author | Marek Olšák <[email protected]> | 2017-07-04 22:38:37 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2017-07-17 10:50:39 -0400 |
commit | 4560f2b90a2a5551166fb21d97c646614c91fb77 (patch) | |
tree | e3fe0c297f74e78344539029ec501779b4b6881e | |
parent | c351037d6c097427a7f80da8a86e42c224c2f260 (diff) |
radeonsi: merge si_llvm_get_amdgpu_target into ac_get_llvm_target
Reviewed-by: Nicolai Hähnle <[email protected]>
-rw-r--r-- | src/amd/common/ac_llvm_util.c | 18 | ||||
-rw-r--r-- | src/amd/common/ac_llvm_util.h | 1 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_pipe.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_shader_internal.h | 2 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c | 42 |
5 files changed, 12 insertions, 53 deletions
diff --git a/src/amd/common/ac_llvm_util.c b/src/amd/common/ac_llvm_util.c index ea752e031ef..675926ea679 100644 --- a/src/amd/common/ac_llvm_util.c +++ b/src/amd/common/ac_llvm_util.c @@ -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; diff --git a/src/amd/common/ac_llvm_util.h b/src/amd/common/ac_llvm_util.h index 21f3e837747..cc4fe3bd632 100644 --- a/src/amd/common/ac_llvm_util.h +++ b/src/amd/common/ac_llvm_util.h @@ -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, diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index 5f3b7e112ce..afb2bcbf078 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -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, diff --git a/src/gallium/drivers/radeonsi/si_shader_internal.h b/src/gallium/drivers/radeonsi/si_shader_internal.h index 3556e69cd0e..6e86e0b56dc 100644 --- a/src/gallium/drivers/radeonsi/si_shader_internal.h +++ b/src/gallium/drivers/radeonsi/si_shader_internal.h @@ -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); diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c index 3f20cd1d03d..b37d4b232b1 100644 --- a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c +++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c @@ -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; |