[Mesa-dev] [PATCH 4/6] i965/disasm: Label support functions

Toni Lönnberg toni.lonnberg at intel.com
Mon Feb 20 13:27:16 UTC 2017


From: "Lonnberg, Toni" <toni.lonnberg at intel.com>

Pre-work for shader disassembly label support.

Introduction of the structures and functions used by the shader disassembly
jump target labeling.
---
 src/mesa/drivers/dri/i965/brw_context.h |  1 +
 src/mesa/drivers/dri/i965/brw_eu.c      | 46 +++++++++++++++++++++++++++++++++
 src/mesa/drivers/dri/i965/brw_eu.h      |  8 ++++++
 3 files changed, 55 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 01e651b..ec5c16c 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -154,6 +154,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,
diff --git a/src/mesa/drivers/dri/i965/brw_eu.c b/src/mesa/drivers/dri/i965/brw_eu.c
index 6a422bb..1061799 100644
--- a/src/mesa/drivers/dri/i965/brw_eu.c
+++ b/src/mesa/drivers/dri/i965/brw_eu.c
@@ -365,6 +365,52 @@ const unsigned *brw_get_program( struct brw_codegen *p,
    return (const unsigned *)p->store;
 }
 
+const struct brw_label *
+brw_find_label(struct brw_label *root, int offset) {
+   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,
                 void *assembly, int start, int end, FILE *out)
diff --git a/src/mesa/drivers/dri/i965/brw_eu.h b/src/mesa/drivers/dri/i965/brw_eu.h
index fbf9123..cd7b9db 100644
--- a/src/mesa/drivers/dri/i965/brw_eu.h
+++ b/src/mesa/drivers/dri/i965/brw_eu.h
@@ -94,6 +94,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 );
 void brw_set_default_exec_size(struct brw_codegen *p, unsigned value);
@@ -116,6 +122,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(struct brw_label *root, int offset);
+void brw_create_label(struct brw_label **labels, int offset, void *mem_ctx);
 void brw_disassemble(const struct gen_device_info *devinfo, void *assembly,
                      int start, int end, FILE *out);
 const unsigned *brw_get_program( struct brw_codegen *p, unsigned *sz );
-- 
2.7.4



More information about the mesa-dev mailing list