radeonsi: use ac_create_target_machine
authorMarek Olšák <marek.olsak@amd.com>
Tue, 7 Nov 2017 02:50:19 +0000 (03:50 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 7 Nov 2017 16:58:38 +0000 (17:58 +0100)
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

index fb2bc11874398cf04130e319c8776e83ae271f8d..429904c04036399366f2029398e269a3aa24d883 100644 (file)
@@ -128,8 +128,11 @@ LLVMTargetMachineRef ac_create_target_machine(enum radeon_family family, enum ac
        LLVMTargetRef target = ac_get_llvm_target(triple);
 
        snprintf(features, sizeof(features),
-                "+DumpCode,+vgpr-spilling,-fp32-denormals%s",
-                tm_options & AC_TM_SISCHED ? ",+si-scheduler" : "");
+                "+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" : "",
+                tm_options & AC_TM_FORCE_DISABLE_XNACK ? ",-xnack" : "",
+                tm_options & AC_TM_PROMOTE_ALLOCA_TO_SCRATCH ? ",-promote-alloca" : "");
        
        LLVMTargetMachineRef tm = LLVMCreateTargetMachine(
                                     target,
index d4b3915ffa9b9b5dbb687ff4be60a9f7f4f39d2c..7c8b6b0a13065ad66b9e5b7e3b19c9b58a384186 100644 (file)
@@ -57,6 +57,9 @@ enum ac_func_attr {
 enum ac_target_machine_options {
        AC_TM_SUPPORTS_SPILL = (1 << 0),
        AC_TM_SISCHED = (1 << 1),
+       AC_TM_FORCE_ENABLE_XNACK = (1 << 2),
+       AC_TM_FORCE_DISABLE_XNACK = (1 << 3),
+       AC_TM_PROMOTE_ALLOCA_TO_SCRATCH = (1 << 4),
 };
 
 const char *ac_get_llvm_processor_name(enum radeon_family family);
index e96380ce40aefbe57e91f9dd3ca593b34cfdf505..1ca5ca38df3c7581395fb6c60ff8f4c63c7bc0de 100644 (file)
@@ -145,21 +145,13 @@ static void si_emit_string_marker(struct pipe_context *ctx,
 static LLVMTargetMachineRef
 si_create_llvm_target_machine(struct si_screen *sscreen)
 {
-       const char *triple = "amdgcn--";
-       char features[256];
-
-       snprintf(features, sizeof(features),
-                "+DumpCode,+vgpr-spilling,-fp32-denormals,+fp64-denormals%s%s%s",
-                sscreen->b.chip_class >= GFX9 ? ",+xnack" : ",-xnack",
-                sscreen->llvm_has_working_vgpr_indexing ? "" : ",-promote-alloca",
-                sscreen->b.debug_flags & DBG(SI_SCHED) ? ",+si-scheduler" : "");
-
-       return LLVMCreateTargetMachine(ac_get_llvm_target(triple), triple,
-                                      ac_get_llvm_processor_name(sscreen->b.family),
-                                      features,
-                                      LLVMCodeGenLevelDefault,
-                                      LLVMRelocDefault,
-                                      LLVMCodeModelDefault);
+       enum ac_target_machine_options tm_options =
+               (sscreen->b.debug_flags & DBG(SI_SCHED) ? AC_TM_SISCHED : 0) |
+               (sscreen->b.chip_class >= GFX9 ? AC_TM_FORCE_ENABLE_XNACK : 0) |
+               (sscreen->b.chip_class < GFX9 ? AC_TM_FORCE_DISABLE_XNACK : 0) |
+               (!sscreen->llvm_has_working_vgpr_indexing ? AC_TM_PROMOTE_ALLOCA_TO_SCRATCH : 0);
+
+       return ac_create_target_machine(sscreen->b.family, tm_options);
 }
 
 static void si_set_log_context(struct pipe_context *ctx,