Mesa (master): spirv: Make vtn_case a vtn_cf_node

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Apr 3 21:11:49 UTC 2020


Module: Mesa
Branch: master
Commit: 255aacbec14c2d11d7756ec94b95244165120ff6
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=255aacbec14c2d11d7756ec94b95244165120ff6

Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Wed Feb 12 15:19:20 2020 -0600

spirv: Make vtn_case a vtn_cf_node

Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3820>

---

 src/compiler/spirv/vtn_cfg.c     | 19 ++++++++++++-------
 src/compiler/spirv/vtn_private.h |  4 +++-
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/src/compiler/spirv/vtn_cfg.c b/src/compiler/spirv/vtn_cfg.c
index 107755d96ac..4e42eb1dbca 100644
--- a/src/compiler/spirv/vtn_cfg.c
+++ b/src/compiler/spirv/vtn_cfg.c
@@ -409,6 +409,7 @@ vtn_add_case(struct vtn_builder *b, struct vtn_switch *swtch,
    if (case_block->switch_case == NULL) {
       struct vtn_case *c = ralloc(b, struct vtn_case);
 
+      c->node.type = vtn_cf_node_type_case;
       list_inithead(&c->body);
       c->start_block = case_block;
       c->fallthrough = NULL;
@@ -416,7 +417,7 @@ vtn_add_case(struct vtn_builder *b, struct vtn_switch *swtch,
       c->is_default = false;
       c->visited = false;
 
-      list_addtail(&c->link, &swtch->cases);
+      list_addtail(&c->node.link, &swtch->cases);
 
       case_block->switch_case = c;
    }
@@ -439,7 +440,7 @@ vtn_order_case(struct vtn_switch *swtch, struct vtn_case *cse)
 
    cse->visited = true;
 
-   list_del(&cse->link);
+   list_del(&cse->node.link);
 
    if (cse->fallthrough) {
       vtn_order_case(swtch, cse->fallthrough);
@@ -451,9 +452,9 @@ vtn_order_case(struct vtn_switch *swtch, struct vtn_case *cse)
        * can't break ordering because the DFS ensures that this case is
        * visited before anything that falls through to it.
        */
-      list_addtail(&cse->link, &cse->fallthrough->link);
+      list_addtail(&cse->node.link, &cse->fallthrough->node.link);
    } else {
-      list_add(&cse->link, &swtch->cases);
+      list_add(&cse->node.link, &swtch->cases);
    }
 }
 
@@ -695,7 +696,8 @@ vtn_cfg_walk_blocks(struct vtn_builder *b, struct list_head *cf_list,
           * the blocks, we also gather the much-needed fall-through
           * information.
           */
-         list_for_each_entry(struct vtn_case, cse, &swtch->cases, link) {
+         vtn_foreach_cf_node(case_node, &swtch->cases) {
+            struct vtn_case *cse = vtn_cf_node_as_case(case_node);
             vtn_assert(cse->start_block != break_block);
             vtn_cfg_walk_blocks(b, &cse->body, cse->start_block, cse,
                                 break_block, loop_break, loop_cont, NULL);
@@ -859,7 +861,8 @@ vtn_switch_case_condition(struct vtn_builder *b, struct vtn_switch *swtch,
 {
    if (cse->is_default) {
       nir_ssa_def *any = nir_imm_false(&b->nb);
-      list_for_each_entry(struct vtn_case, other, &swtch->cases, link) {
+      vtn_foreach_cf_node(other_node, &swtch->cases) {
+         struct vtn_case *other = vtn_cf_node_as_case(other_node);
          if (other->is_default)
             continue;
 
@@ -1048,7 +1051,9 @@ vtn_emit_cf_list(struct vtn_builder *b, struct list_head *cf_list,
          nir_ssa_def *sel = vtn_ssa_value(b, vtn_switch->selector)->def;
 
          /* Now we can walk the list of cases and actually emit code */
-         list_for_each_entry(struct vtn_case, cse, &vtn_switch->cases, link) {
+         vtn_foreach_cf_node(case_node, &vtn_switch->cases) {
+            struct vtn_case *cse = vtn_cf_node_as_case(case_node);
+
             /* Figure out the condition */
             nir_ssa_def *cond =
                vtn_switch_case_condition(b, vtn_switch, sel, cse);
diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h
index a042afe4bbe..1c84a2c01ee 100644
--- a/src/compiler/spirv/vtn_private.h
+++ b/src/compiler/spirv/vtn_private.h
@@ -135,6 +135,7 @@ enum vtn_cf_node_type {
    vtn_cf_node_type_block,
    vtn_cf_node_type_if,
    vtn_cf_node_type_loop,
+   vtn_cf_node_type_case,
    vtn_cf_node_type_switch,
 };
 
@@ -172,7 +173,7 @@ struct vtn_if {
 };
 
 struct vtn_case {
-   struct list_head link;
+   struct vtn_cf_node node;
 
    struct list_head body;
 
@@ -253,6 +254,7 @@ vtn_cf_node_as_##_type(struct vtn_cf_node *node)   \
 VTN_DECL_CF_NODE_CAST(block)
 VTN_DECL_CF_NODE_CAST(loop)
 VTN_DECL_CF_NODE_CAST(if)
+VTN_DECL_CF_NODE_CAST(case)
 VTN_DECL_CF_NODE_CAST(switch)
 
 #define vtn_foreach_cf_node(node, cf_list) \



More information about the mesa-commit mailing list