aco: remove radeon_family from aco::Program
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38701>
This commit is contained in:
Daniel Schürmann 2025-11-27 15:19:08 +01:00 committed by Marge Bot
parent 1e8d367537
commit 7b1f6fa6fc
5 changed files with 29 additions and 25 deletions

View file

@ -31,7 +31,8 @@ validate(Program* program)
}
static std::string
get_disasm_string(Program* program, std::vector<uint32_t>& code, unsigned exec_size)
get_disasm_string(Program* program, enum radeon_family family, std::vector<uint32_t>& code,
unsigned exec_size)
{
std::string disasm;
@ -40,8 +41,8 @@ get_disasm_string(Program* program, std::vector<uint32_t>& code, unsigned exec_s
struct u_memstream mem;
if (u_memstream_open(&mem, &data, &disasm_size)) {
FILE* const memf = u_memstream_get(&mem);
if (check_print_asm_support(program)) {
print_asm(program, code, exec_size / 4u, memf);
if (check_print_asm_support(program, family)) {
print_asm(program, family, code, exec_size / 4u, memf);
} else {
fprintf(memf, "Shader disassembly is not supported in the current configuration"
#if !AMD_LLVM_AVAILABLE
@ -219,7 +220,7 @@ aco_compile_shader_part(const struct aco_compiler_options* options,
std::string disasm;
if (options->record_asm)
disasm = get_disasm_string(program.get(), code, exec_size);
disasm = get_disasm_string(program.get(), options->family, code, exec_size);
(*build_binary)(binary, config.num_sgprs, config.num_vgprs, code.data(), code.size(),
disasm.data(), disasm.size());
@ -262,7 +263,7 @@ aco_compile_shader(const struct aco_compiler_options* options, const struct aco_
std::string disasm;
if (options->record_asm)
disasm = get_disasm_string(program.get(), code, exec_size);
disasm = get_disasm_string(program.get(), options->family, code, exec_size);
(*build_binary)(binary, &config, llvm_ir.c_str(), llvm_ir.size(), disasm.c_str(), disasm.size(),
&program->statistics, exec_size, code.data(), code.size(), symbols.data(),
@ -305,7 +306,7 @@ aco_compile_rt_prolog(const struct aco_compiler_options* options,
std::string disasm;
if (options->record_asm)
disasm = get_disasm_string(program.get(), code, exec_size);
disasm = get_disasm_string(program.get(), options->family, code, exec_size);
(*build_prolog)(binary, &config, NULL, 0, disasm.c_str(), disasm.size(), NULL, exec_size,
code.data(), code.size(), NULL, 0, NULL, 0);
@ -343,7 +344,7 @@ aco_compile_vs_prolog(const struct aco_compiler_options* options,
std::string disasm;
if (options->record_asm)
disasm = get_disasm_string(program.get(), code, exec_size);
disasm = get_disasm_string(program.get(), options->family, code, exec_size);
(*build_prolog)(binary, config.num_sgprs, config.num_vgprs, code.data(), code.size(),
disasm.data(), disasm.size());
@ -405,7 +406,7 @@ aco_compile_trap_handler(const struct aco_compiler_options* options,
std::string disasm;
if (options->record_asm)
disasm = get_disasm_string(program.get(), code, exec_size);
disasm = get_disasm_string(program.get(), options->family, code, exec_size);
(*build_binary)(binary, &config, NULL, 0, disasm.c_str(), disasm.size(), NULL, exec_size,
code.data(), code.size(), NULL, 0, NULL, 0);
@ -450,9 +451,8 @@ aco_print_asm(const struct radeon_info *info, unsigned wave_size,
aco::Program prog;
prog.gfx_level = info->gfx_level;
prog.family = info->family;
prog.wave_size = wave_size;
prog.blocks.push_back(aco::Block());
aco::print_asm(&prog, binarray, num_dw, stderr);
aco::print_asm(&prog, info->family, binarray, num_dw, stderr);
}

View file

@ -70,7 +70,6 @@ init_program(Program* program, Stage stage, const struct aco_shader_info* info,
program->config = config;
program->info = *info;
program->gfx_level = options->gfx_level;
program->family = options->family;
program->wave_size = info->wave_size;
program->lane_mask = program->wave_size == 32 ? s1 : s2;

View file

@ -2278,7 +2278,6 @@ public:
ac_shader_config* config;
struct aco_shader_info info;
enum amd_gfx_level gfx_level;
enum radeon_family family;
DeviceInfo dev;
unsigned wave_size;
RegClass lane_mask;
@ -2452,8 +2451,9 @@ unsigned emit_program(Program* program, std::vector<uint32_t>& code,
* Returns true if print_asm can disassemble the given program for the current build/runtime
* configuration
*/
bool check_print_asm_support(Program* program);
bool print_asm(Program* program, std::vector<uint32_t>& binary, unsigned exec_size, FILE* output);
bool check_print_asm_support(Program* program, enum radeon_family family);
bool print_asm(Program* program, enum radeon_family family, std::vector<uint32_t>& binary,
unsigned exec_size, FILE* output);
bool validate_ir(Program* program);
bool validate_cfg(Program* program);
bool validate_ra(Program* program);

View file

@ -8,6 +8,8 @@
#include "util/u_debug.h"
#include "amd_family.h"
#if AMD_LLVM_AVAILABLE
#if defined(_MSC_VER) && defined(restrict)
#undef restrict
@ -159,7 +161,8 @@ get_branch_target(char** output, Program* program, const std::vector<bool>& refe
#endif
bool
print_asm_clrx(Program* program, std::vector<uint32_t>& binary, unsigned exec_size, FILE* output)
print_asm_clrx(Program* program, enum radeon_family family, std::vector<uint32_t>& binary,
unsigned exec_size, FILE* output)
{
#ifdef _WIN32
return true;
@ -170,7 +173,7 @@ print_asm_clrx(Program* program, std::vector<uint32_t>& binary, unsigned exec_si
FILE* p;
int fd;
const char* gpu_type = to_clrx_device_name(program->gfx_level, program->family);
const char* gpu_type = to_clrx_device_name(program->gfx_level, family);
/* Dump the binary into a temporary file. */
fd = mkstemp(path);
@ -301,7 +304,8 @@ disasm_instr(amd_gfx_level gfx_level, LLVMDisasmContextRef disasm, uint32_t* bin
}
bool
print_asm_llvm(Program* program, std::vector<uint32_t>& binary, unsigned exec_size, FILE* output)
print_asm_llvm(Program* program, enum radeon_family family, std::vector<uint32_t>& binary,
unsigned exec_size, FILE* output)
{
std::vector<bool> referenced_blocks = get_referenced_blocks(program);
@ -333,7 +337,7 @@ print_asm_llvm(Program* program, std::vector<uint32_t>& binary, unsigned exec_si
#endif
LLVMDisasmContextRef disasm =
LLVMCreateDisasmCPUFeatures("amdgcn-mesa-mesa3d", ac_get_llvm_processor_name(program->family),
LLVMCreateDisasmCPUFeatures("amdgcn-mesa-mesa3d", ac_get_llvm_processor_name(family),
features.c_str(), &symbols, 0, NULL, NULL);
size_t pos = 0;
@ -387,12 +391,12 @@ print_asm_llvm(Program* program, std::vector<uint32_t>& binary, unsigned exec_si
} /* end namespace */
bool
check_print_asm_support(Program* program)
check_print_asm_support(Program* program, enum radeon_family family)
{
#if AMD_LLVM_AVAILABLE
if (program->gfx_level >= GFX8) {
/* LLVM disassembler only supports GFX8+ */
const char* name = ac_get_llvm_processor_name(program->family);
const char* name = ac_get_llvm_processor_name(family);
const char* triple = "amdgcn--";
LLVMTargetRef target = ac_get_llvm_target(triple);
@ -409,7 +413,7 @@ check_print_asm_support(Program* program)
#ifndef _WIN32
/* Check if CLRX disassembler binary is available and can disassemble the program */
return to_clrx_device_name(program->gfx_level, program->family) &&
return to_clrx_device_name(program->gfx_level, family) &&
system("clrxdisasm --version > /dev/null 2>&1") == 0;
#else
return false;
@ -418,15 +422,16 @@ check_print_asm_support(Program* program)
/* Returns true on failure */
bool
print_asm(Program* program, std::vector<uint32_t>& binary, unsigned exec_size, FILE* output)
print_asm(Program* program, enum radeon_family family, std::vector<uint32_t>& binary,
unsigned exec_size, FILE* output)
{
#if AMD_LLVM_AVAILABLE
if (program->gfx_level >= GFX8) {
return print_asm_llvm(program, binary, exec_size, output);
return print_asm_llvm(program, family, binary, exec_size, output);
}
#endif
return print_asm_clrx(program, binary, exec_size, output);
return print_asm_clrx(program, family, binary, exec_size, output);
}
} // namespace aco

View file

@ -391,7 +391,7 @@ finish_assembler_test()
/* we could use CLRX for disassembly but that would require it to be
* installed */
if (program->gfx_level >= GFX8) {
print_asm(program.get(), binary, exec_size / 4u, output);
print_asm(program.get(), rad_info.family, binary, exec_size / 4u, output);
} else {
// TODO: maybe we should use CLRX and skip this test if it's not available?
for (uint32_t dword : binary)