aco: use ac_is_llvm_processor_supported() for checking LLVM asm support
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 13 May 2022 09:19:21 +0000 (11:19 +0200)
committerMarge Bot <emma+marge@anholt.net>
Tue, 17 May 2022 17:14:21 +0000 (17:14 +0000)
It seems more universal but it's needed to create a temporary TM.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16494>

src/amd/compiler/aco_print_asm.cpp
src/amd/llvm/ac_llvm_util.c
src/amd/llvm/ac_llvm_util.h

index 2535de2..974ef76 100644 (file)
@@ -407,7 +407,18 @@ check_print_asm_support(Program* program)
 #ifdef LLVM_AVAILABLE
    if (program->gfx_level >= GFX8) {
       /* LLVM disassembler only supports GFX8+ */
-      return true;
+      const char* name = ac_get_llvm_processor_name(program->family);
+      const char* triple = "amdgcn--";
+      LLVMTargetRef target = ac_get_llvm_target(triple);
+
+      LLVMTargetMachineRef tm = LLVMCreateTargetMachine(
+         target, triple, name, "", LLVMCodeGenLevelDefault, LLVMRelocDefault, LLVMCodeModelDefault);
+
+      bool supported = ac_is_llvm_processor_supported(tm, name);
+      LLVMDisposeTargetMachine(tm);
+
+      if (supported)
+         return true;
    }
 #endif
 
index d83d82b..561ef53 100644 (file)
@@ -87,7 +87,7 @@ void ac_init_llvm_once(void)
 #endif
 }
 
-static LLVMTargetRef ac_get_llvm_target(const char *triple)
+LLVMTargetRef ac_get_llvm_target(const char *triple)
 {
    LLVMTargetRef target = NULL;
    char *err_message = NULL;
index 79bab02..546f9e2 100644 (file)
@@ -89,6 +89,7 @@ struct ac_llvm_compiler {
    struct ac_compiler_passes *low_opt_passes;
 };
 
+LLVMTargetRef ac_get_llvm_target(const char *triple);
 const char *ac_get_llvm_processor_name(enum radeon_family family);
 bool ac_is_llvm_processor_supported(LLVMTargetMachineRef tm, const char *processor);
 void ac_add_attr_dereferenceable(LLVMValueRef val, uint64_t bytes);