nir: Make nir_foo_first/last_cf_node return a block instead
One of NIR's invariants is that control flow lists always start and end with blocks. There's no good reason why we should return a cf_node from these functions since we know that it's always a block. Making it a block lets us remove a bunch of code. Signed-off-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
This commit is contained in:
@@ -1537,52 +1537,12 @@ typedef struct nir_if {
|
||||
struct exec_list else_list; /** < list of nir_cf_node */
|
||||
} nir_if;
|
||||
|
||||
static inline nir_cf_node *
|
||||
nir_if_first_then_node(nir_if *if_stmt)
|
||||
{
|
||||
struct exec_node *head = exec_list_get_head(&if_stmt->then_list);
|
||||
return exec_node_data(nir_cf_node, head, node);
|
||||
}
|
||||
|
||||
static inline nir_cf_node *
|
||||
nir_if_last_then_node(nir_if *if_stmt)
|
||||
{
|
||||
struct exec_node *tail = exec_list_get_tail(&if_stmt->then_list);
|
||||
return exec_node_data(nir_cf_node, tail, node);
|
||||
}
|
||||
|
||||
static inline nir_cf_node *
|
||||
nir_if_first_else_node(nir_if *if_stmt)
|
||||
{
|
||||
struct exec_node *head = exec_list_get_head(&if_stmt->else_list);
|
||||
return exec_node_data(nir_cf_node, head, node);
|
||||
}
|
||||
|
||||
static inline nir_cf_node *
|
||||
nir_if_last_else_node(nir_if *if_stmt)
|
||||
{
|
||||
struct exec_node *tail = exec_list_get_tail(&if_stmt->else_list);
|
||||
return exec_node_data(nir_cf_node, tail, node);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
nir_cf_node cf_node;
|
||||
|
||||
struct exec_list body; /** < list of nir_cf_node */
|
||||
} nir_loop;
|
||||
|
||||
static inline nir_cf_node *
|
||||
nir_loop_first_cf_node(nir_loop *loop)
|
||||
{
|
||||
return exec_node_data(nir_cf_node, exec_list_get_head(&loop->body), node);
|
||||
}
|
||||
|
||||
static inline nir_cf_node *
|
||||
nir_loop_last_cf_node(nir_loop *loop)
|
||||
{
|
||||
return exec_node_data(nir_cf_node, exec_list_get_tail(&loop->body), node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Various bits of metadata that can may be created or required by
|
||||
* optimization and analysis passes
|
||||
@@ -1683,6 +1643,48 @@ NIR_DEFINE_CAST(nir_cf_node_as_loop, nir_cf_node, nir_loop, cf_node,
|
||||
NIR_DEFINE_CAST(nir_cf_node_as_function, nir_cf_node,
|
||||
nir_function_impl, cf_node, type, nir_cf_node_function)
|
||||
|
||||
static inline nir_block *
|
||||
nir_if_first_then_block(nir_if *if_stmt)
|
||||
{
|
||||
struct exec_node *head = exec_list_get_head(&if_stmt->then_list);
|
||||
return nir_cf_node_as_block(exec_node_data(nir_cf_node, head, node));
|
||||
}
|
||||
|
||||
static inline nir_block *
|
||||
nir_if_last_then_block(nir_if *if_stmt)
|
||||
{
|
||||
struct exec_node *tail = exec_list_get_tail(&if_stmt->then_list);
|
||||
return nir_cf_node_as_block(exec_node_data(nir_cf_node, tail, node));
|
||||
}
|
||||
|
||||
static inline nir_block *
|
||||
nir_if_first_else_block(nir_if *if_stmt)
|
||||
{
|
||||
struct exec_node *head = exec_list_get_head(&if_stmt->else_list);
|
||||
return nir_cf_node_as_block(exec_node_data(nir_cf_node, head, node));
|
||||
}
|
||||
|
||||
static inline nir_block *
|
||||
nir_if_last_else_block(nir_if *if_stmt)
|
||||
{
|
||||
struct exec_node *tail = exec_list_get_tail(&if_stmt->else_list);
|
||||
return nir_cf_node_as_block(exec_node_data(nir_cf_node, tail, node));
|
||||
}
|
||||
|
||||
static inline nir_block *
|
||||
nir_loop_first_block(nir_loop *loop)
|
||||
{
|
||||
struct exec_node *head = exec_list_get_head(&loop->body);
|
||||
return nir_cf_node_as_block(exec_node_data(nir_cf_node, head, node));
|
||||
}
|
||||
|
||||
static inline nir_block *
|
||||
nir_loop_last_block(nir_loop *loop)
|
||||
{
|
||||
struct exec_node *tail = exec_list_get_tail(&loop->body);
|
||||
return nir_cf_node_as_block(exec_node_data(nir_cf_node, tail, node));
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
nir_parameter_in,
|
||||
nir_parameter_out,
|
||||
|
Reference in New Issue
Block a user