intel/disasm: brw_label and support functions
authorDanylo Piliaiev <danylo.piliaiev@globallogic.com>
Mon, 3 Jun 2019 09:10:09 +0000 (12:10 +0300)
committerMarge Bot <eric+marge@anholt.net>
Wed, 2 Sep 2020 10:33:29 +0000 (10:33 +0000)
Pre-work for shader disassembly label support.

Introduction of the structures and functions used by the shader disassembly
jump target labeling.

From: "Lonnberg, Toni" <toni.lonnberg@intel.com>
Signed-off-by: Danylo Piliaiev <danylo.piliaiev@globallogic.com>
Reviewed-by: Sagar Ghuge <sagar.ghuge@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4245>

src/intel/compiler/brw_eu.cpp
src/intel/compiler/brw_eu.h
src/mesa/drivers/dri/i965/brw_context.h

index 78272f27fbfbe90a179cd3ecc10fa53a1c0652b4..596894e434e8faeefdf6da4249077a76e932cf74 100644 (file)
@@ -409,6 +409,54 @@ bool brw_try_override_assembly(struct brw_codegen *p, int start_offset,
    return true;
 }
 
+const struct brw_label *
+brw_find_label(const struct brw_label *root, int offset)
+{
+   const struct brw_label *curr = root;
+
+   if (curr != NULL)
+   {
+      do {
+         if (curr->offset == offset)
+            return curr;
+
+         curr = curr->next;
+      } while (curr != NULL);
+   }
+
+   return curr;
+}
+
+void
+brw_create_label(struct brw_label **labels, int offset, void *mem_ctx)
+{
+   if (*labels != NULL) {
+      struct brw_label *curr = *labels;
+      struct brw_label *prev;
+
+      do {
+         prev = curr;
+
+         if (curr->offset == offset)
+            return;
+
+         curr = curr->next;
+      } while (curr != NULL);
+
+      curr = ralloc(mem_ctx, struct brw_label);
+      curr->offset = offset;
+      curr->number = prev->number + 1;
+      curr->next = NULL;
+      prev->next = curr;
+   } else {
+      struct brw_label *root = ralloc(mem_ctx, struct brw_label);
+      root->number = 0;
+      root->offset = offset;
+      root->next = NULL;
+      *labels = root;
+   }
+}
+
 void
 brw_disassemble(const struct gen_device_info *devinfo,
                 const void *assembly, int start, int end, FILE *out)
index 18567155fd66336d385db4e4abb567eeeb6d021c..c08f3b877b94b7b6f36604a597983df38ea80ccb 100644 (file)
@@ -137,6 +137,12 @@ struct brw_codegen {
    int loop_stack_array_size;
 };
 
+struct brw_label {
+   int offset;
+   int number;
+   struct brw_label *next;
+};
+
 void brw_pop_insn_state( struct brw_codegen *p );
 void brw_push_insn_state( struct brw_codegen *p );
 unsigned brw_get_default_exec_size(struct brw_codegen *p);
@@ -164,6 +170,8 @@ void brw_init_codegen(const struct gen_device_info *, struct brw_codegen *p,
                      void *mem_ctx);
 bool brw_has_jip(const struct gen_device_info *devinfo, enum opcode opcode);
 bool brw_has_uip(const struct gen_device_info *devinfo, enum opcode opcode);
+const struct brw_label *brw_find_label(const struct brw_label *root, int offset);
+void brw_create_label(struct brw_label **labels, int offset, void *mem_ctx);
 int brw_disassemble_inst(FILE *file, const struct gen_device_info *devinfo,
                          const struct brw_inst *inst, bool is_compacted);
 void brw_disassemble(const struct gen_device_info *devinfo,
index 6cf3769c9a30ce6823406d0a42f4af9797dbde09..7d39ba881d86ba85044b3dfb498ea26627eb3a22 100644 (file)
@@ -147,6 +147,7 @@ struct brw_wm_prog_key;
 struct brw_wm_prog_data;
 struct brw_cs_prog_key;
 struct brw_cs_prog_data;
+struct brw_label;
 
 enum brw_pipeline {
    BRW_RENDER_PIPELINE,