From 372774367cf5e62f49209716faa80b3ecd932746 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Tue, 1 Sep 2020 18:39:54 -0500 Subject: [PATCH] intel/compiler: Get rid of struct gen_disasm It's just a container around a devinfo. The one useful purpose it did serve is that gen_disasm_create initialized the compaction table singletons. Now that those no longer exist, this isn't necessary. Reviewed-by: Kenneth Graunke Part-of: --- src/intel/common/gen_batch_decoder.c | 5 ++- src/intel/common/gen_decoder.h | 3 +- src/intel/common/gen_disasm.c | 34 +++----------------- src/intel/common/gen_disasm.h | 9 ++---- src/intel/tools/aubinator_viewer.cpp | 10 +++--- src/intel/tools/aubinator_viewer.h | 4 +-- src/intel/tools/aubinator_viewer_decoder.cpp | 4 +-- src/intel/vulkan/anv_pipeline.c | 5 ++- 8 files changed, 19 insertions(+), 55 deletions(-) diff --git a/src/intel/common/gen_batch_decoder.c b/src/intel/common/gen_batch_decoder.c index 3d80b4e6bae..ad9cc43e3f7 100644 --- a/src/intel/common/gen_batch_decoder.c +++ b/src/intel/common/gen_batch_decoder.c @@ -42,6 +42,7 @@ gen_batch_decode_ctx_init(struct gen_batch_decode_ctx *ctx, { memset(ctx, 0, sizeof(*ctx)); + ctx->devinfo = *devinfo; ctx->get_bo = get_bo; ctx->get_state_size = get_state_size; ctx->user_data = user_data; @@ -54,14 +55,12 @@ gen_batch_decode_ctx_init(struct gen_batch_decode_ctx *ctx, ctx->spec = gen_spec_load(devinfo); else ctx->spec = gen_spec_load_from_path(devinfo, xml_path); - ctx->disasm = gen_disasm_create(devinfo); } void gen_batch_decode_ctx_finish(struct gen_batch_decode_ctx *ctx) { gen_spec_destroy(ctx->spec); - gen_disasm_destroy(ctx->disasm); } #define CSI "\e[" @@ -138,7 +137,7 @@ ctx_disassemble_program(struct gen_batch_decode_ctx *ctx, return; fprintf(ctx->fp, "\nReferenced %s:\n", type); - gen_disasm_disassemble(ctx->disasm, bo.map, 0, ctx->fp); + gen_disassemble(&ctx->devinfo, bo.map, 0, ctx->fp); } /* Heuristic to determine whether a uint32_t is probably actually a float diff --git a/src/intel/common/gen_decoder.h b/src/intel/common/gen_decoder.h index 0b770ee3691..5a7409182ce 100644 --- a/src/intel/common/gen_decoder.h +++ b/src/intel/common/gen_decoder.h @@ -236,11 +236,10 @@ struct gen_batch_decode_ctx { void *user_data; FILE *fp; + struct gen_device_info devinfo; struct gen_spec *spec; enum gen_batch_decode_flags flags; - struct gen_disasm *disasm; - uint64_t surface_base; uint64_t dynamic_base; uint64_t instruction_base; diff --git a/src/intel/common/gen_disasm.c b/src/intel/common/gen_disasm.c index 97ca1b659be..5ec9d371663 100644 --- a/src/intel/common/gen_disasm.c +++ b/src/intel/common/gen_disasm.c @@ -28,10 +28,6 @@ #include "gen_disasm.h" -struct gen_disasm { - struct gen_device_info devinfo; -}; - static bool is_send(uint32_t opcode) { @@ -42,10 +38,9 @@ is_send(uint32_t opcode) } static int -gen_disasm_find_end(struct gen_disasm *disasm, +gen_disasm_find_end(const struct gen_device_info *devinfo, const void *assembly, int start) { - struct gen_device_info *devinfo = &disasm->devinfo; int offset = start; /* This loop exits when send-with-EOT or when opcode is 0 */ @@ -69,11 +64,10 @@ gen_disasm_find_end(struct gen_disasm *disasm, } void -gen_disasm_disassemble(struct gen_disasm *disasm, const void *assembly, - int start, FILE *out) +gen_disassemble(const struct gen_device_info *devinfo, + const void *assembly, int start, FILE *out) { - struct gen_device_info *devinfo = &disasm->devinfo; - int end = gen_disasm_find_end(disasm, assembly, start); + int end = gen_disasm_find_end(devinfo, assembly, start); /* Make a dummy disasm structure that brw_validate_instructions * can work from. @@ -111,23 +105,3 @@ gen_disasm_disassemble(struct gen_disasm *disasm, const void *assembly, ralloc_free(mem_ctx); ralloc_free(disasm_info); } - -struct gen_disasm * -gen_disasm_create(const struct gen_device_info *devinfo) -{ - struct gen_disasm *gd; - - gd = malloc(sizeof *gd); - if (gd == NULL) - return NULL; - - gd->devinfo = *devinfo; - - return gd; -} - -void -gen_disasm_destroy(struct gen_disasm *disasm) -{ - free(disasm); -} diff --git a/src/intel/common/gen_disasm.h b/src/intel/common/gen_disasm.h index d979114588d..9e6c75846bc 100644 --- a/src/intel/common/gen_disasm.h +++ b/src/intel/common/gen_disasm.h @@ -30,13 +30,8 @@ extern "C" { #endif -struct gen_disasm; - -struct gen_disasm *gen_disasm_create(const struct gen_device_info *devinfo); -void gen_disasm_disassemble(struct gen_disasm *disasm, - const void *assembly, int start, FILE *out); - -void gen_disasm_destroy(struct gen_disasm *disasm); +void gen_disassemble(const struct gen_device_info *devinfo, + const void *assembly, int start, FILE *out); #ifdef __cplusplus } diff --git a/src/intel/tools/aubinator_viewer.cpp b/src/intel/tools/aubinator_viewer.cpp index 46ab9238ce1..6369b817a0c 100644 --- a/src/intel/tools/aubinator_viewer.cpp +++ b/src/intel/tools/aubinator_viewer.cpp @@ -63,7 +63,6 @@ struct aub_file { /* Device state */ struct gen_device_info devinfo; struct gen_spec *spec; - struct gen_disasm *disasm; }; static void @@ -131,7 +130,6 @@ handle_info(void *user_data, int pci_id, const char *app_name) exit(EXIT_FAILURE); } file->spec = gen_spec_load(&file->devinfo); - file->disasm = gen_disasm_create(&file->devinfo); } static void @@ -394,9 +392,9 @@ new_shader_window(struct aub_mem *mem, uint64_t address, const char *desc) if (shader_bo.map) { FILE *f = open_memstream(&window->shader, &window->shader_size); if (f) { - gen_disasm_disassemble(context.file->disasm, - (const uint8_t *) shader_bo.map + - (address - shader_bo.addr), 0, f); + gen_disassemble(&context.file->devinfo, + (const uint8_t *) shader_bo.map + + (address - shader_bo.addr), 0, f); fclose(f); } } @@ -818,8 +816,8 @@ new_batch_window(int exec_idx) aub_viewer_decode_ctx_init(&window->decode_ctx, &context.cfg, &window->decode_cfg, + &context.file->devinfo, context.file->spec, - context.file->disasm, batch_get_bo, NULL, window); diff --git a/src/intel/tools/aubinator_viewer.h b/src/intel/tools/aubinator_viewer.h index 65c679f85de..705c85e79ee 100644 --- a/src/intel/tools/aubinator_viewer.h +++ b/src/intel/tools/aubinator_viewer.h @@ -68,8 +68,8 @@ struct aub_viewer_decode_ctx { void *user_data; + const struct gen_device_info *devinfo; struct gen_spec *spec; - struct gen_disasm *disasm; enum drm_i915_gem_engine_class engine; struct aub_viewer_cfg *cfg; @@ -89,8 +89,8 @@ struct aub_viewer_decode_ctx { void aub_viewer_decode_ctx_init(struct aub_viewer_decode_ctx *ctx, struct aub_viewer_cfg *cfg, struct aub_viewer_decode_cfg *decode_cfg, + const struct gen_device_info *devinfo, struct gen_spec *spec, - struct gen_disasm *disasm, struct gen_batch_decode_bo (*get_bo)(void *, bool, uint64_t), unsigned (*get_state_size)(void *, uint32_t), void *user_data); diff --git a/src/intel/tools/aubinator_viewer_decoder.cpp b/src/intel/tools/aubinator_viewer_decoder.cpp index 44038a9b226..8d63eaa6b06 100644 --- a/src/intel/tools/aubinator_viewer_decoder.cpp +++ b/src/intel/tools/aubinator_viewer_decoder.cpp @@ -31,8 +31,8 @@ void aub_viewer_decode_ctx_init(struct aub_viewer_decode_ctx *ctx, struct aub_viewer_cfg *cfg, struct aub_viewer_decode_cfg *decode_cfg, + const struct gen_device_info *devinfo, struct gen_spec *spec, - struct gen_disasm *disasm, struct gen_batch_decode_bo (*get_bo)(void *, bool, uint64_t), unsigned (*get_state_size)(void *, uint32_t), void *user_data) @@ -42,12 +42,12 @@ aub_viewer_decode_ctx_init(struct aub_viewer_decode_ctx *ctx, ctx->get_bo = get_bo; ctx->get_state_size = get_state_size; ctx->user_data = user_data; + ctx->devinfo = devinfo; ctx->engine = I915_ENGINE_CLASS_RENDER; ctx->cfg = cfg; ctx->decode_cfg = decode_cfg; ctx->spec = spec; - ctx->disasm = disasm; } static void diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c index cafe5668f1f..8313f471a67 100644 --- a/src/intel/vulkan/anv_pipeline.c +++ b/src/intel/vulkan/anv_pipeline.c @@ -1186,9 +1186,8 @@ anv_pipeline_add_executable(struct anv_pipeline *pipeline, /* Creating this is far cheaper than it looks. It's perfectly fine to * do it for every binary. */ - struct gen_disasm *d = gen_disasm_create(&pipeline->device->info); - gen_disasm_disassemble(d, stage->code, code_offset, stream); - gen_disasm_destroy(d); + gen_disassemble(&pipeline->device->info, + stage->code, code_offset, stream); fclose(stream); -- 2.30.2