Mesa (main): util/dag: Make edge data a uintptr_t

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Nov 17 14:16:15 UTC 2021


Module: Mesa
Branch: main
Commit: 508f917d8c53c25a1e656409e3228ad067c9369f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=508f917d8c53c25a1e656409e3228ad067c9369f

Author: Connor Abbott <cwabbott0 at gmail.com>
Date:   Mon Nov  8 15:06:33 2021 +0100

util/dag: Make edge data a uintptr_t

Nobody was actually using it as a pointer, and I'm going to introduce a
shared function which relies on it not being a pointer so let's fix this
once and for all.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13722>

---

 src/broadcom/compiler/qpu_schedule.c       |  2 +-
 src/compiler/nir/nir_schedule.c            |  4 ++--
 src/freedreno/ir3/ir3_postsched.c          | 10 +++++-----
 src/freedreno/ir3/ir3_sched.c              |  2 +-
 src/gallium/drivers/vc4/vc4_qir_schedule.c |  2 +-
 src/gallium/drivers/vc4/vc4_qpu_schedule.c |  2 +-
 src/util/dag.c                             |  4 ++--
 src/util/dag.h                             |  4 ++--
 src/util/tests/dag_test.cpp                |  2 +-
 9 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/broadcom/compiler/qpu_schedule.c b/src/broadcom/compiler/qpu_schedule.c
index 055ad1f77d7..f987766a1b9 100644
--- a/src/broadcom/compiler/qpu_schedule.c
+++ b/src/broadcom/compiler/qpu_schedule.c
@@ -97,7 +97,7 @@ add_dep(struct schedule_state *state,
         bool write)
 {
         bool write_after_read = !write && state->dir == R;
-        void *edge_data = (void *)(uintptr_t)write_after_read;
+        uintptr_t edge_data = write_after_read;
 
         if (!before || !after)
                 return;
diff --git a/src/compiler/nir/nir_schedule.c b/src/compiler/nir/nir_schedule.c
index d13623217de..8ae4fb2f1d8 100644
--- a/src/compiler/nir/nir_schedule.c
+++ b/src/compiler/nir/nir_schedule.c
@@ -212,9 +212,9 @@ add_dep(nir_deps_state *state,
    assert(before != after);
 
    if (state->dir == F)
-      dag_add_edge(&before->dag, &after->dag, NULL);
+      dag_add_edge(&before->dag, &after->dag, 0);
    else
-      dag_add_edge(&after->dag, &before->dag, NULL);
+      dag_add_edge(&after->dag, &before->dag, 0);
 }
 
 
diff --git a/src/freedreno/ir3/ir3_postsched.c b/src/freedreno/ir3/ir3_postsched.c
index 507302a0090..162c2dccb6c 100644
--- a/src/freedreno/ir3/ir3_postsched.c
+++ b/src/freedreno/ir3/ir3_postsched.c
@@ -382,9 +382,9 @@ add_dep(struct ir3_postsched_deps_state *state,
    assert(before != after);
 
    if (state->direction == F) {
-      dag_add_edge(&before->dag, &after->dag, NULL);
+      dag_add_edge(&before->dag, &after->dag, 0);
    } else {
-      dag_add_edge(&after->dag, &before->dag, NULL);
+      dag_add_edge(&after->dag, &before->dag, 0);
    }
 }
 
@@ -593,7 +593,7 @@ sched_dag_init(struct ir3_postsched_ctx *ctx)
          if (src->block != instr->block)
             continue;
 
-         dag_add_edge(&sn->dag, &n->dag, NULL);
+         dag_add_edge(&sn->dag, &n->dag, 0);
       }
 
       if (is_input(instr)) {
@@ -602,14 +602,14 @@ sched_dag_init(struct ir3_postsched_ctx *ctx)
          util_dynarray_foreach (&inputs, struct ir3_instruction *, instrp) {
             struct ir3_instruction *input = *instrp;
             struct ir3_postsched_node *in = input->data;
-            dag_add_edge(&in->dag, &n->dag, NULL);
+            dag_add_edge(&in->dag, &n->dag, 0);
          }
          util_dynarray_append(&kills, struct ir3_instruction *, instr);
       } else if (is_tex(instr) || is_mem(instr)) {
          util_dynarray_foreach (&kills, struct ir3_instruction *, instrp) {
             struct ir3_instruction *kill = *instrp;
             struct ir3_postsched_node *kn = kill->data;
-            dag_add_edge(&kn->dag, &n->dag, NULL);
+            dag_add_edge(&kn->dag, &n->dag, 0);
          }
       }
    }
diff --git a/src/freedreno/ir3/ir3_sched.c b/src/freedreno/ir3/ir3_sched.c
index c6893747118..6be356d17b0 100644
--- a/src/freedreno/ir3/ir3_sched.c
+++ b/src/freedreno/ir3/ir3_sched.c
@@ -994,7 +994,7 @@ sched_node_add_dep(struct ir3_instruction *instr, struct ir3_instruction *src,
    if (instr->opc == OPC_META_COLLECT)
       sn->collect = instr;
 
-   dag_add_edge(&sn->dag, &n->dag, NULL);
+   dag_add_edge(&sn->dag, &n->dag, 0);
 
    unsigned d = ir3_delayslots(src, instr, i, true);
 
diff --git a/src/gallium/drivers/vc4/vc4_qir_schedule.c b/src/gallium/drivers/vc4/vc4_qir_schedule.c
index fdd922fde4d..7286f731ff5 100644
--- a/src/gallium/drivers/vc4/vc4_qir_schedule.c
+++ b/src/gallium/drivers/vc4/vc4_qir_schedule.c
@@ -96,7 +96,7 @@ add_dep(enum direction dir,
                 after = t;
         }
 
-        dag_add_edge(&after->dag, &before->dag, NULL);
+        dag_add_edge(&after->dag, &before->dag, 0);
 }
 
 static void
diff --git a/src/gallium/drivers/vc4/vc4_qpu_schedule.c b/src/gallium/drivers/vc4/vc4_qpu_schedule.c
index cfacc23b3b1..055bd0395ba 100644
--- a/src/gallium/drivers/vc4/vc4_qpu_schedule.c
+++ b/src/gallium/drivers/vc4/vc4_qpu_schedule.c
@@ -99,7 +99,7 @@ add_dep(struct schedule_state *state,
         bool write)
 {
         bool write_after_read = !write && state->dir == R;
-        void *edge_data = (void *)(uintptr_t)write_after_read;
+        uintptr_t edge_data = write_after_read;
 
         if (!before || !after)
                 return;
diff --git a/src/util/dag.c b/src/util/dag.c
index 8e8d2d68506..97fd7386a49 100644
--- a/src/util/dag.c
+++ b/src/util/dag.c
@@ -31,7 +31,7 @@
  * list may contain multiple edges to the same child with different data.
  */
 void
-dag_add_edge(struct dag_node *parent, struct dag_node *child, void *data)
+dag_add_edge(struct dag_node *parent, struct dag_node *child, uintptr_t data)
 {
    util_dynarray_foreach(&parent->edges, struct dag_edge, edge) {
       if (edge->child == child && edge->data == data)
@@ -67,7 +67,7 @@ dag_remove_edge(struct dag *dag, struct dag_edge *edge)
       list_addtail(&child->link, &dag->heads);
 
    edge->child = NULL;
-   edge->data = NULL;
+   edge->data = 0;
 }
 
 /**
diff --git a/src/util/dag.h b/src/util/dag.h
index bb46b483972..fbc3ed93d48 100644
--- a/src/util/dag.h
+++ b/src/util/dag.h
@@ -35,7 +35,7 @@ extern "C" {
 struct dag_edge {
    struct dag_node *child;
    /* User-defined data associated with the edge. */
-   void *data;
+   uintptr_t data;
 };
 
 struct dag_node {
@@ -52,7 +52,7 @@ struct dag {
 
 struct dag *dag_create(void *mem_ctx);
 void dag_init_node(struct dag *dag, struct dag_node *node);
-void dag_add_edge(struct dag_node *parent, struct dag_node *child, void *data);
+void dag_add_edge(struct dag_node *parent, struct dag_node *child, uintptr_t data);
 void dag_remove_edge(struct dag *dag, struct dag_edge *edge);
 void dag_traverse_bottom_up(struct dag *dag, void (*cb)(struct dag_node *node,
                                                         void *data), void *data);
diff --git a/src/util/tests/dag_test.cpp b/src/util/tests/dag_test.cpp
index f807962f793..d8c2ae9483c 100644
--- a/src/util/tests/dag_test.cpp
+++ b/src/util/tests/dag_test.cpp
@@ -53,7 +53,7 @@ struct node: public dag_node {
    /* Overload >> to make describing our test case graphs easier to read */
    struct node &operator>>(struct node &child) {
       dag_add_edge(static_cast<struct dag_node *>(this),
-                   static_cast<struct dag_node *>(&child), NULL);
+                   static_cast<struct dag_node *>(&child), 0);
       return child;
    }
 };



More information about the mesa-commit mailing list