diff --git a/src/amd/compiler/aco_print_asm.cpp b/src/amd/compiler/aco_print_asm.cpp index 0d6cf856330..b37cccca2bc 100644 --- a/src/amd/compiler/aco_print_asm.cpp +++ b/src/amd/compiler/aco_print_asm.cpp @@ -37,9 +37,62 @@ namespace aco { namespace { -/* LLVM disassembler only supports GFX8+, try to disassemble with CLRXdisasm - * for GFX6-GFX7 if found on the system, this is better than nothing. +/** + * Determines the GPU type to use for CLRXdisasm */ +const char* +to_clrx_device_name(chip_class cc, radeon_family family) +{ + switch (cc) { + case GFX6: + switch (family) { + case CHIP_TAHITI: return "tahiti"; + case CHIP_PITCAIRN: return "pitcairn"; + case CHIP_VERDE: return "capeverde"; + case CHIP_OLAND: return "oland"; + case CHIP_HAINAN: return "hainan"; + default: return nullptr; + } + case GFX7: + switch (family) { + case CHIP_BONAIRE: return "bonaire"; + case CHIP_KAVERI: return "gfx700"; + case CHIP_HAWAII: return "hawaii"; + default: return nullptr; + } + case GFX8: + switch (family) { + case CHIP_TONGA: return "tonga"; + case CHIP_ICELAND: return "iceland"; + case CHIP_CARRIZO: return "carrizo"; + case CHIP_FIJI: return "fiji"; + case CHIP_STONEY: return "stoney"; + case CHIP_POLARIS10: return "polaris10"; + case CHIP_POLARIS11: return "polaris11"; + case CHIP_POLARIS12: return "polaris12"; + case CHIP_VEGAM: return "polaris11"; + default: return nullptr; + } + case GFX9: + switch (family) { + case CHIP_VEGA10: return "vega10"; + case CHIP_VEGA12: return "vega12"; + case CHIP_VEGA20: return "vega20"; + case CHIP_RAVEN: return "raven"; + default: return nullptr; + } + case GFX10: + switch (family) { + case CHIP_NAVI10: return "gfx1010"; + case CHIP_NAVI12: return "gfx1011"; + default: return nullptr; + } + case GFX10_3: + return nullptr; + default: unreachable("Invalid chip class!"); return nullptr; + } +} + bool print_asm_clrx(Program* program, std::vector& binary, FILE* output) { @@ -48,10 +101,11 @@ print_asm_clrx(Program* program, std::vector& binary, FILE* output) #else char path[] = "/tmp/fileXXXXXX"; char line[2048], command[128]; - const char* gpu_type; FILE* p; int fd; + const char* gpu_type = to_clrx_device_name(program->chip_class, program->family); + /* Dump the binary into a temporary file. */ fd = mkstemp(path); if (fd < 0) @@ -62,24 +116,6 @@ print_asm_clrx(Program* program, std::vector& binary, FILE* output) goto fail; } - /* Determine the GPU type for CLRXdisasm. Use the family for GFX6 chips - * because it doesn't allow to use gfx600 directly. - */ - switch (program->chip_class) { - case GFX6: - switch (program->family) { - case CHIP_TAHITI: gpu_type = "tahiti"; break; - case CHIP_PITCAIRN: gpu_type = "pitcairn"; break; - case CHIP_VERDE: gpu_type = "capeverde"; break; - case CHIP_OLAND: gpu_type = "oland"; break; - case CHIP_HAINAN: gpu_type = "hainan"; break; - default: unreachable("Invalid GFX6 family!"); - } - break; - case GFX7: gpu_type = "gfx700"; break; - default: unreachable("Invalid chip class!"); - } - sprintf(command, "clrxdisasm --gpuType=%s -r %s", gpu_type, path); p = popen(command, "r"); @@ -254,13 +290,11 @@ print_asm_llvm(Program* program, std::vector& binary, unsigned exec_si bool print_asm(Program* program, std::vector& binary, unsigned exec_size, FILE* output) { - if (program->chip_class <= GFX7) { - /* Do not abort if clrxdisasm isn't found. */ - print_asm_clrx(program, binary, output); - return false; - } else { + if (program->chip_class >= GFX8) { return print_asm_llvm(program, binary, exec_size, output); } + + return print_asm_clrx(program, binary, output); } } // namespace aco