mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-28 06:00:10 +01:00
ir3-disasm: add options to specify GPU by chip ID or name
Signed-off-by: Job Noorman <jnoorman@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28457>
This commit is contained in:
parent
86468ab8af
commit
7eeb781c8b
5 changed files with 76 additions and 2 deletions
|
|
@ -106,6 +106,18 @@ fd_dev_info(const struct fd_dev_id *id)
|
|||
return modified;
|
||||
}
|
||||
|
||||
const struct fd_dev_info *
|
||||
fd_dev_info_raw_by_name(const char *name)
|
||||
{
|
||||
for (int i = 0; i < ARRAY_SIZE(fd_dev_recs); i++) {
|
||||
if (!strcmp(fd_dev_recs[i].name, name)) {
|
||||
return fd_dev_recs[i].info;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *
|
||||
fd_dev_name(const struct fd_dev_id *id)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -269,6 +269,8 @@ const struct fd_dev_info *fd_dev_info_raw(const struct fd_dev_id *id);
|
|||
/* Final dev info with dbg options and everything else applied. */
|
||||
const struct fd_dev_info fd_dev_info(const struct fd_dev_id *id);
|
||||
|
||||
const struct fd_dev_info *fd_dev_info_raw_by_name(const char *name);
|
||||
|
||||
static uint8_t
|
||||
fd_dev_gen(const struct fd_dev_id *id)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -56,4 +56,5 @@ libfreedreno_common = static_library(
|
|||
|
||||
idep_libfreedreno_common = declare_dependency(
|
||||
link_with: [libfreedreno_common],
|
||||
include_directories : [inc_freedreno, inc_include, inc_src],
|
||||
)
|
||||
|
|
|
|||
|
|
@ -21,11 +21,15 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "util/os_file.h"
|
||||
|
||||
#include "freedreno_dev_info.h"
|
||||
#include "ir3-isa.h"
|
||||
|
||||
static void
|
||||
|
|
@ -35,17 +39,72 @@ disasm_instr_cb(void *d, unsigned n, void *instr)
|
|||
printf("%3d[%08x_%08x] ", n, dwords[1], dwords[0]);
|
||||
}
|
||||
|
||||
static void
|
||||
usage(const char *prog)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: %s [-g GPU_ID | -c CHIP_ID] FILE\n"
|
||||
" -g GPU_ID: specify GPU ID\n"
|
||||
" -c CHIP_ID: specify GPU chip ID in hex\n",
|
||||
prog);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
size_t sz;
|
||||
void *raw = os_read_file(argv[1], &sz);
|
||||
void *raw = NULL;
|
||||
const struct fd_dev_info *info = NULL;
|
||||
int opt;
|
||||
|
||||
while ((opt = getopt(argc, argv, "g:c:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'g':
|
||||
info = fd_dev_info_raw_by_name(optarg);
|
||||
if (!info) {
|
||||
fprintf(stderr, "Unknown GPU name: %s\n", optarg);
|
||||
usage(argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
break;
|
||||
case 'c': {
|
||||
uint64_t chip_id;
|
||||
if (sscanf(optarg, "%" PRIx64, &chip_id) != 1) {
|
||||
fprintf(stderr, "Invalid chip ID: %s\n", optarg);
|
||||
usage(argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
struct fd_dev_id id = {.chip_id = chip_id};
|
||||
info = fd_dev_info_raw(&id);
|
||||
if (!info) {
|
||||
fprintf(stderr, "Unknown chip ID: %s\n", optarg);
|
||||
usage(argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
usage(argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (optind >= argc) {
|
||||
fprintf(stderr, "No file specified\n");
|
||||
usage(argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
raw = os_read_file(argv[optind], &sz);
|
||||
unsigned chip = info ? info->chip : 7;
|
||||
|
||||
ir3_isa_disasm(raw, sz, stdout,
|
||||
&(struct isa_decode_options){
|
||||
.show_errors = true,
|
||||
.branch_labels = true,
|
||||
.pre_instr_cb = disasm_instr_cb,
|
||||
.gpu_id = chip * 100,
|
||||
});
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ idep_libir3decode = declare_dependency(
|
|||
ir3disasm = executable(
|
||||
'ir3-disasm',
|
||||
['ir3-disasm.c'],
|
||||
dependencies: [idep_libir3decode],
|
||||
dependencies: [idep_libir3decode, idep_libfreedreno_common],
|
||||
build_by_default: with_tools.contains('freedreno'),
|
||||
include_directories: [
|
||||
inc_src,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue