spirv: Make vtn_function a vtn_cf_node

Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3820>
This commit is contained in:
Jason Ekstrand 2020-02-12 15:28:46 -06:00 committed by Marge Bot
parent 255aacbec1
commit d94e464a9f
3 changed files with 11 additions and 6 deletions

View 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);

View 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);
}

View 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;