From: Marek Olšák Date: Sun, 24 May 2020 12:30:39 +0000 (-0400) Subject: ac: add helper ac_get_register_name X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=dc3dade47509b4b620d88dde4718f1d66bef90a2;p=mesa.git ac: add helper ac_get_register_name Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- diff --git a/src/amd/common/ac_debug.c b/src/amd/common/ac_debug.c index b81897811a1..f095b0b45da 100644 --- a/src/amd/common/ac_debug.c +++ b/src/amd/common/ac_debug.c @@ -99,10 +99,37 @@ static void print_named_value(FILE *file, const char *name, uint32_t value, print_value(file, value, bits); } -static const struct si_reg *find_register(const struct si_reg *table, - unsigned table_size, - unsigned offset) +static const struct si_reg *find_register(enum chip_class chip_class, unsigned offset) { + const struct si_reg *table; + unsigned table_size; + + switch (chip_class) { + case GFX10_3: + case GFX10: + table = gfx10_reg_table; + table_size = ARRAY_SIZE(gfx10_reg_table); + break; + case GFX9: + table = gfx9_reg_table; + table_size = ARRAY_SIZE(gfx9_reg_table); + break; + case GFX8: + table = gfx8_reg_table; + table_size = ARRAY_SIZE(gfx8_reg_table); + break; + case GFX7: + table = gfx7_reg_table; + table_size = ARRAY_SIZE(gfx7_reg_table); + break; + case GFX6: + table = gfx6_reg_table; + table_size = ARRAY_SIZE(gfx6_reg_table); + break; + default: + return NULL; + } + for (unsigned i = 0; i < table_size; i++) { const struct si_reg *reg = &table[i]; @@ -113,21 +140,17 @@ static const struct si_reg *find_register(const struct si_reg *table, return NULL; } +const char *ac_get_register_name(enum chip_class chip_class, unsigned offset) +{ + const struct si_reg *reg = find_register(chip_class, offset); + + return reg ? sid_strings + reg->name_offset : "(no name)"; +} + void ac_dump_reg(FILE *file, enum chip_class chip_class, unsigned offset, uint32_t value, uint32_t field_mask) { - const struct si_reg *reg = NULL; - - if (chip_class >= GFX10) - reg = find_register(gfx10_reg_table, ARRAY_SIZE(gfx10_reg_table), offset); - else if (chip_class >= GFX9) - reg = find_register(gfx9_reg_table, ARRAY_SIZE(gfx9_reg_table), offset); - else if (chip_class >= GFX8) - reg = find_register(gfx8_reg_table, ARRAY_SIZE(gfx8_reg_table), offset); - else if (chip_class >= GFX7) - reg = find_register(gfx7_reg_table, ARRAY_SIZE(gfx7_reg_table), offset); - else - reg = find_register(gfx6_reg_table, ARRAY_SIZE(gfx6_reg_table), offset); + const struct si_reg *reg = find_register(chip_class, offset); if (reg) { const char *reg_name = sid_strings + reg->name_offset; diff --git a/src/amd/common/ac_debug.h b/src/amd/common/ac_debug.h index ffcba875536..e66abb940c3 100644 --- a/src/amd/common/ac_debug.h +++ b/src/amd/common/ac_debug.h @@ -56,6 +56,7 @@ struct ac_wave_info { typedef void *(*ac_debug_addr_callback)(void *data, uint64_t addr); +const char *ac_get_register_name(enum chip_class chip_class, unsigned offset); void ac_dump_reg(FILE *file, enum chip_class chip_class, unsigned offset, uint32_t value, uint32_t field_mask); void ac_parse_ib_chunk(FILE *f, uint32_t *ib, int num_dw, const int *trace_ids,