summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir.h
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2016-03-25 14:07:41 -0700
committerJason Ekstrand <[email protected]>2016-03-28 18:32:48 -0700
commit38de85f9a5f3daae65ebe715f29fe2783e4ea146 (patch)
tree003e6542c0429b12611d907e6a92172453eae215 /src/compiler/nir/nir.h
parent49be812be60e7fab949bcd352583649a1dbf06b4 (diff)
nir: Add a helper for getting the unique function in a shader
Reviewed-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir.h')
-rw-r--r--src/compiler/nir/nir.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 6bd871dc43a..cab304814a2 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -1761,6 +1761,17 @@ 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);
+ assert(func->return_type == glsl_void_type());
+ assert(func->num_params == 0);
+ return func;
+}
+
#define nir_foreach_function(shader, func) \
foreach_list_typed(nir_function, func, node, &(shader)->functions)