radeonsi: add triple into si_compiler
authorMarek Olšák <marek.olsak@amd.com>
Mon, 9 Apr 2018 22:35:45 +0000 (18:35 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 27 Apr 2018 21:56:04 +0000 (17:56 -0400)
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Tested-by: Benedikt Schemmer <ben at besd.de>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/amd/common/ac_llvm_util.c
src/amd/common/ac_llvm_util.h
src/amd/vulkan/radv_shader.c
src/gallium/drivers/radeonsi/si_pipe.c
src/gallium/drivers/radeonsi/si_shader.h
src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c

index 5b52381a7f17034be95e57ece3fe0dca0d47e999..a06c83a29633251233be6d72e5773ec54a6e60af 100644 (file)
@@ -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;
 }
 
index 9c6b89bf6c1502932678ab8534228a74e09532c7..0aa803c5bc1c6ac14b34efb7e9edb046551defca 100644 (file)
@@ -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);
index aaa670297551a60ba6bda06deaaf26aca3885dc6..014ed78c228b24355f9389b75f56093ede719ea2 100644 (file)
@@ -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);
index 60bc189e4f1b47d39f23385ff955102c6040d051..dbfb9c8fdea0d8f2f78ff2afa5a07c832a58e6e0 100644 (file)
@@ -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)
index 8c479d638a9f45ff9ea0cfb80888093a943cd057..e6205a204c1beefc333af5b215e5f089f180c5ea 100644 (file)
@@ -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. */
index d0332a6078c21e6e39583732b77079527e921ce7..cad81487d7e12dfae60b7cc56fdbdb4dbfb3a564 100644 (file)
@@ -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);