intel/compiler: Get rid of struct gen_disasm
authorJason Ekstrand <jason@jlekstrand.net>
Tue, 1 Sep 2020 23:39:54 +0000 (18:39 -0500)
committerMarge Bot <eric+marge@anholt.net>
Wed, 2 Sep 2020 19:48:44 +0000 (19:48 +0000)
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 <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6244>

src/intel/common/gen_batch_decoder.c
src/intel/common/gen_decoder.h
src/intel/common/gen_disasm.c
src/intel/common/gen_disasm.h
src/intel/tools/aubinator_viewer.cpp
src/intel/tools/aubinator_viewer.h
src/intel/tools/aubinator_viewer_decoder.cpp
src/intel/vulkan/anv_pipeline.c

index 3d80b4e6bae90d00b22532d5688fd8192049bf0d..ad9cc43e3f7280917c8181d8a2ad9b57cc47aca7 100644 (file)
@@ -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
index 0b770ee36913a47f43946b5d6d5f07299c2d6719..5a7409182ce821a711757b037738e5986dac2a2b 100644 (file)
@@ -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;
index 97ca1b659be67e4ae0ea771fc3e28d1b0526f8a9..5ec9d371663e3ae1e93d3f3f0caea5345581151a 100644 (file)
 
 #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);
-}
index d979114588d5d6532c56f09c70b57f6a184ff8ca..9e6c75846bc7a869158edfb744ea1d30042b1e97 100644 (file)
 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
 }
index 46ab9238ce14355a8f30267b10536b461c2fa7ad..6369b817a0c20d08ddb8c85713ebf6fc77161635 100644 (file)
@@ -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);
index 65c679f85dea09c42c1d00f9503c7649d36a6d17..705c85e79ee6dcba888930cbc9b4d9b4896c7cbb 100644 (file)
@@ -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);
index 44038a9b226957d130c53f16d9b4136abf46387e..8d63eaa6b06439edea8f1a42bac2b7dc7b228478 100644 (file)
@@ -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
index cafe5668f1f45440d7123cc67337889679a55376..8313f471a67c12f6ebb5d43be713f6a5c7c0c578 100644 (file)
@@ -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);