nir: Add a helper for getting the unique function in a shader
authorJason Ekstrand <jason.ekstrand@intel.com>
Fri, 25 Mar 2016 21:07:41 +0000 (14:07 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Tue, 29 Mar 2016 01:32:48 +0000 (18:32 -0700)
Reviewed-by: Rob Clark <robdclark@gmail.com>
src/compiler/nir/nir.h

index 6bd871dc43adf02483e41380196df2333ab2949a..cab304814a204e3eb0a4d9dff51110a0690f45ec 100644 (file)
@@ -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)