spirv: Make vtn_function a vtn_cf_node
authorJason Ekstrand <jason@jlekstrand.net>
Wed, 12 Feb 2020 21:28:46 +0000 (15:28 -0600)
committerMarge Bot <eric+marge@anholt.net>
Fri, 3 Apr 2020 20:54:00 +0000 (20:54 +0000)
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3820>

src/compiler/spirv/spirv_to_nir.c
src/compiler/spirv/vtn_cfg.c
src/compiler/spirv/vtn_private.h

index 61abc7272783926fc14aaa30af530a419a9d7946..3ebe85e46ab6958b85901746cab1782dd9ec3317 100644 (file)
@@ -5148,7 +5148,7 @@ vtn_create_builder(const uint32_t *words, size_t word_count,
    b->file = NULL;
    b->line = -1;
    b->col = -1;
-   exec_list_make_empty(&b->functions);
+   list_inithead(&b->functions);
    b->entry_point_stage = stage;
    b->entry_point_name = entry_point_name;
    b->options = dup_options;
@@ -5346,7 +5346,8 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
    bool progress;
    do {
       progress = false;
-      foreach_list_typed(struct vtn_function, func, node, &b->functions) {
+      vtn_foreach_cf_node(node, &b->functions) {
+         struct vtn_function *func = vtn_cf_node_as_function(node);
          if (func->referenced && !func->emitted) {
             b->const_table = _mesa_pointer_hash_table_create(b);
 
index 4e42eb1dbcadf79964cbf2cc69578ca08322c748..a26566cb2adf5f5a7d95d7c9bb92c701f1ff5d05 100644 (file)
@@ -251,6 +251,7 @@ vtn_cfg_handle_prepass_instruction(struct vtn_builder *b, SpvOp opcode,
       vtn_assert(b->func == NULL);
       b->func = rzalloc(b, struct vtn_function);
 
+      b->func->node.type = vtn_cf_node_type_function;
       list_inithead(&b->func->body);
       b->func->control = w[3];
 
@@ -364,7 +365,7 @@ vtn_cfg_handle_prepass_instruction(struct vtn_builder *b, SpvOp opcode,
           * implemented functions that we'll walk later.
           */
          b->func->start_block = b->block;
-         exec_list_push_tail(&b->functions, &b->func->node);
+         list_addtail(&b->func->node.link, &b->functions);
       }
       break;
    }
@@ -756,7 +757,8 @@ vtn_build_cfg(struct vtn_builder *b, const uint32_t *words, const uint32_t *end)
    vtn_foreach_instruction(b, words, end,
                            vtn_cfg_handle_prepass_instruction);
 
-   foreach_list_typed(struct vtn_function, func, node, &b->functions) {
+   vtn_foreach_cf_node(node, &b->functions) {
+      struct vtn_function *func = vtn_cf_node_as_function(node);
       vtn_cfg_walk_blocks(b, &func->body, func->start_block,
                           NULL, NULL, NULL, NULL, NULL);
    }
index 1c84a2c01ee954dc69f8b99d0f70624b990790b3..d709c39a699bae6412804ec2bdd3398ad85cf70f 100644 (file)
@@ -137,6 +137,7 @@ enum vtn_cf_node_type {
    vtn_cf_node_type_loop,
    vtn_cf_node_type_case,
    vtn_cf_node_type_switch,
+   vtn_cf_node_type_function,
 };
 
 struct vtn_cf_node {
@@ -226,7 +227,7 @@ struct vtn_block {
 };
 
 struct vtn_function {
-   struct exec_node node;
+   struct vtn_cf_node node;
 
    struct vtn_type *type;
 
@@ -256,6 +257,7 @@ VTN_DECL_CF_NODE_CAST(loop)
 VTN_DECL_CF_NODE_CAST(if)
 VTN_DECL_CF_NODE_CAST(case)
 VTN_DECL_CF_NODE_CAST(switch)
+VTN_DECL_CF_NODE_CAST(function)
 
 #define vtn_foreach_cf_node(node, cf_list) \
    list_for_each_entry(struct vtn_cf_node, node, cf_list, link)
@@ -654,7 +656,7 @@ struct vtn_builder {
    bool variable_pointers;
 
    struct vtn_function *func;
-   struct exec_list functions;
+   struct list_head functions;
 
    /* Current function parameter index */
    unsigned func_param_idx;