nir/builder: Add a nir_ssa_undef helper
authorJason Ekstrand <jason.ekstrand@intel.com>
Sat, 14 Nov 2015 00:25:24 +0000 (16:25 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Sat, 14 Nov 2015 01:54:43 +0000 (17:54 -0800)
src/glsl/nir/nir_builder.h

index bf45d0373c08a441d43207b76d7359ae60caf01e..205aa067b0b8f3b578ebd556a950aa14c106ab4e 100644 (file)
@@ -58,6 +58,20 @@ nir_builder_cf_insert(nir_builder *build, nir_cf_node *cf)
    nir_cf_node_insert(build->cursor, cf);
 }
 
+static inline nir_ssa_def *
+nir_ssa_undef(nir_builder *build, unsigned num_components)
+{
+   nir_ssa_undef_instr *undef =
+      nir_ssa_undef_instr_create(build->shader, num_components);
+   if (!undef)
+      return NULL;
+
+   nir_instr_insert(nir_before_block(nir_start_block(build->impl)),
+                    &undef->instr);
+
+   return &undef->def;
+}
+
 static inline nir_ssa_def *
 nir_build_imm(nir_builder *build, unsigned num_components, nir_const_value value)
 {