From 43f0a10051337c08d4c74e4c205dc75336d00ef9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Mon, 9 Apr 2018 18:35:45 -0400 Subject: [PATCH] radeonsi: add triple into si_compiler MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Timothy Arceri Tested-by: Benedikt Schemmer Reviewed-by: Nicolai Hähnle --- src/amd/common/ac_llvm_util.c | 6 +++++- src/amd/common/ac_llvm_util.h | 4 +++- src/amd/vulkan/radv_shader.c | 2 +- src/gallium/drivers/radeonsi/si_pipe.c | 3 ++- src/gallium/drivers/radeonsi/si_shader.h | 1 + src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c | 2 +- 6 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/amd/common/ac_llvm_util.c b/src/amd/common/ac_llvm_util.c index 5b52381a7f1..a06c83a2963 100644 --- a/src/amd/common/ac_llvm_util.c +++ b/src/amd/common/ac_llvm_util.c @@ -123,7 +123,9 @@ 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) +LLVMTargetMachineRef ac_create_target_machine(enum radeon_family family, + enum ac_target_machine_options tm_options, + const char **out_triple) { assert(family >= CHIP_TAHITI); char features[256]; @@ -146,6 +148,8 @@ LLVMTargetMachineRef ac_create_target_machine(enum radeon_family family, enum ac LLVMRelocDefault, LLVMCodeModelDefault); + if (out_triple) + *out_triple = triple; return tm; } diff --git a/src/amd/common/ac_llvm_util.h b/src/amd/common/ac_llvm_util.h index 9c6b89bf6c1..0aa803c5bc1 100644 --- a/src/amd/common/ac_llvm_util.h +++ b/src/amd/common/ac_llvm_util.h @@ -68,7 +68,9 @@ enum ac_float_mode { }; 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); +LLVMTargetMachineRef ac_create_target_machine(enum radeon_family family, + enum ac_target_machine_options tm_options, + const char **out_triple); LLVMTargetRef ac_get_llvm_target(const char *triple); void ac_add_attr_dereferenceable(LLVMValueRef val, uint64_t bytes); diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c index aaa67029755..014ed78c228 100644 --- a/src/amd/vulkan/radv_shader.c +++ b/src/amd/vulkan/radv_shader.c @@ -491,7 +491,7 @@ shader_variant_create(struct radv_device *device, tm_options |= AC_TM_SUPPORTS_SPILL; if (device->instance->perftest_flags & RADV_PERFTEST_SISCHED) tm_options |= AC_TM_SISCHED; - tm = ac_create_target_machine(chip_family, tm_options); + tm = ac_create_target_machine(chip_family, tm_options, NULL); if (gs_copy_shader) { assert(shader_count == 1); diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index 60bc189e4f1..dbfb9c8fdea 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -111,7 +111,8 @@ static void si_init_compiler(struct si_screen *sscreen, (sscreen->info.chip_class < GFX9 ? AC_TM_FORCE_DISABLE_XNACK : 0) | (!sscreen->llvm_has_working_vgpr_indexing ? AC_TM_PROMOTE_ALLOCA_TO_SCRATCH : 0); - compiler->tm = ac_create_target_machine(sscreen->info.family, tm_options); + compiler->tm = ac_create_target_machine(sscreen->info.family, + tm_options, &compiler->triple); } static void si_destroy_compiler(struct si_compiler *compiler) diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h index 8c479d638a9..e6205a204c1 100644 --- a/src/gallium/drivers/radeonsi/si_shader.h +++ b/src/gallium/drivers/radeonsi/si_shader.h @@ -314,6 +314,7 @@ struct si_shader; /* Per-thread persistent LLVM objects. */ struct si_compiler { LLVMTargetMachineRef tm; + const char *triple; }; /* State of the context creating the shader object. */ diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c index d0332a6078c..cad81487d7e 100644 --- a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c +++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c @@ -1009,7 +1009,7 @@ void si_llvm_context_init(struct si_shader_context *ctx, ctx->gallivm.context = LLVMContextCreate(); ctx->gallivm.module = LLVMModuleCreateWithNameInContext("tgsi", ctx->gallivm.context); - LLVMSetTarget(ctx->gallivm.module, "amdgcn--"); + LLVMSetTarget(ctx->gallivm.module, compiler->triple); LLVMTargetDataRef data_layout = LLVMCreateTargetDataLayout(compiler->tm); char *data_layout_str = LLVMCopyStringRepOfTargetData(data_layout); -- 2.30.2