nir: Add a helper for getting the one function from a shader
authorJason Ekstrand <jason.ekstrand@intel.com>
Wed, 17 Feb 2016 21:46:25 +0000 (13:46 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 18 Feb 2016 02:04:39 +0000 (18:04 -0800)
src/compiler/nir/nir.h

index 932cab62e645cec4cc22cd026e75b1fe49094233..0f8c78100bf9cd3416ce8ea216efeca201500d5a 100644 (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)