nir: Add a helper for getting the one function from a shader

This commit is contained in:
Jason Ekstrand 2016-02-17 13:46:25 -08:00
parent 8c05b44bbb
commit 979732fafc
1 changed files with 9 additions and 0 deletions

View File

@ -1756,6 +1756,15 @@ typedef struct nir_shader {
gl_shader_stage stage;
} nir_shader;
static inline nir_function *
nir_shader_get_entrypoint(nir_shader *shader)
{
assert(exec_list_length(&shader->functions) == 1);
struct exec_node *func_node = exec_list_get_head(&shader->functions);
nir_function *func = exec_node_data(nir_function, func_node, node);
return func;
}
#define nir_foreach_function(shader, func) \
foreach_list_typed(nir_function, func, node, &(shader)->functions)