From: Marek Olšák <marek.ol...@amd.com>

---
 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 f3db1c5a4a4..c580d822ad4 100644
--- a/src/amd/common/ac_llvm_util.c
+++ b/src/amd/common/ac_llvm_util.c
@@ -115,21 +115,23 @@ const char *ac_get_llvm_processor_name(enum radeon_family 
family)
                return "polaris11";
        case CHIP_VEGA10:
        case CHIP_VEGA12:
        case CHIP_RAVEN:
                return "gfx900";
        default:
                return "";
        }
 }
 
-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];
        const char *triple = (tm_options & AC_TM_SUPPORTS_SPILL) ? 
"amdgcn-mesa-mesa3d" : "amdgcn--";
        LLVMTargetRef target = ac_get_llvm_target(triple);
 
        snprintf(features, sizeof(features),
                 
"+DumpCode,+vgpr-spilling,-fp32-denormals,+fp64-denormals%s%s%s%s",
                 tm_options & AC_TM_SISCHED ? ",+si-scheduler" : "",
                 tm_options & AC_TM_FORCE_ENABLE_XNACK ? ",+xnack" : "",
@@ -138,20 +140,22 @@ LLVMTargetMachineRef ac_create_target_machine(enum 
radeon_family family, enum ac
        
        LLVMTargetMachineRef tm = LLVMCreateTargetMachine(
                                     target,
                                     triple,
                                     ac_get_llvm_processor_name(family),
                                     features,
                                     LLVMCodeGenLevelDefault,
                                     LLVMRelocDefault,
                                     LLVMCodeModelDefault);
 
+       if (out_triple)
+               *out_triple = triple;
        return tm;
 }
 
 static const char *attr_to_str(enum ac_func_attr attr)
 {
    switch (attr) {
    case AC_FUNC_ATTR_ALWAYSINLINE: return "alwaysinline";
    case AC_FUNC_ATTR_INREG: return "inreg";
    case AC_FUNC_ATTR_NOALIAS: return "noalias";
    case AC_FUNC_ATTR_NOUNWIND: return "nounwind";
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
@@ -61,21 +61,23 @@ 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);
+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);
 bool ac_is_sgpr_param(LLVMValueRef param);
 void ac_add_function_attr(LLVMContextRef ctx, LLVMValueRef function,
                           int attr_idx, enum ac_func_attr attr);
 void ac_add_func_attributes(LLVMContextRef ctx, LLVMValueRef function,
                            unsigned attrib_mask);
 void ac_dump_module(LLVMModuleRef module);
 
diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c
index 9d49bc02a81..2e652f7b11e 100644
--- a/src/amd/vulkan/radv_shader.c
+++ b/src/amd/vulkan/radv_shader.c
@@ -482,21 +482,21 @@ shader_variant_create(struct radv_device *device,
        options->dump_shader = radv_can_dump_shader(device, module);
        options->dump_preoptir = options->dump_shader &&
                                 device->instance->debug_flags & 
RADV_DEBUG_PREOPTIR;
        options->record_llvm_ir = device->keep_shader_info;
        options->tess_offchip_block_dw_size = 
device->tess_offchip_block_dw_size;
 
        if (options->supports_spill)
                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);
                radv_compile_gs_copy_shader(tm, *shaders, &binary,
                                            &variant->config, &variant->info,
                                            options);
        } else {
                radv_compile_nir_shader(tm, &binary, &variant->config,
                                        &variant->info, shaders, shader_count,
                                        options);
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c 
b/src/gallium/drivers/radeonsi/si_pipe.c
index fcf3556bcc1..ad813888597 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -104,21 +104,22 @@ static const struct debug_named_value debug_options[] = {
 
 static void si_init_compiler(struct si_screen *sscreen,
                             struct si_compiler *compiler)
 {
        enum ac_target_machine_options tm_options =
                (sscreen->debug_flags & DBG(SI_SCHED) ? AC_TM_SISCHED : 0) |
                (sscreen->info.chip_class >= GFX9 ? AC_TM_FORCE_ENABLE_XNACK : 
0) |
                (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)
 {
        if (compiler->tm)
                LLVMDisposeTargetMachine(compiler->tm);
 }
 
 /*
  * pipe_context
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
@@ -307,20 +307,21 @@ enum {
        SI_FIX_FETCH_RGB_8_INT, /* A = 1 */
        SI_FIX_FETCH_RGB_16,
        SI_FIX_FETCH_RGB_16_INT,
 };
 
 struct si_shader;
 
 /* Per-thread persistent LLVM objects. */
 struct si_compiler {
        LLVMTargetMachineRef            tm;
+       const char                      *triple;
 };
 
 /* State of the context creating the shader object. */
 struct si_compiler_ctx_state {
        /* Should only be used by si_init_shader_selector_async and
         * si_build_shader_variant if thread_index == -1 (non-threaded). */
        struct si_compiler              *compiler;
 
        /* Used if thread_index == -1 or if debug.async is true. */
        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 d0332a6078c..cad81487d7e 100644
--- a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
+++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
@@ -1002,21 +1002,21 @@ void si_llvm_context_init(struct si_shader_context *ctx,
         * This should be enough for us to be able to pass our gallivm struct 
to the
         * helper functions in the gallivm module.
         */
        memset(ctx, 0, sizeof(*ctx));
        ctx->screen = sscreen;
        ctx->compiler = compiler;
 
        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);
        LLVMSetDataLayout(ctx->gallivm.module, data_layout_str);
        LLVMDisposeTargetData(data_layout);
        LLVMDisposeMessage(data_layout_str);
 
        bool unsafe_fpmath = (sscreen->debug_flags & DBG(UNSAFE_MATH)) != 0;
        enum ac_float_mode float_mode =
                unsafe_fpmath ? AC_FLOAT_MODE_UNSAFE_FP_MATH :
-- 
2.17.0

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to