glsl2: Give IR nodes a type field.
This is a big deal for debugging if nothing else ("what class is this
ir_instruction, really?"), but is also nice for avoiding building a
whole visitor or an if (node->as_whatever() || node->as_other_thing())
chain.
diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp
index 4284f6b..8a56795 100644
--- a/src/glsl/ir_validate.cpp
+++ b/src/glsl/ir_validate.cpp
@@ -173,9 +173,24 @@
}
void
+check_node_type(ir_instruction *ir, void *data)
+{
+ if (ir->ir_type <= ir_type_unset || ir->ir_type >= ir_type_max) {
+ printf("Instruction node with unset type\n");
+ ir->print(); printf("\n");
+ }
+}
+
+void
validate_ir_tree(exec_list *instructions)
{
ir_validate v;
v.run(instructions);
+
+ foreach_iter(exec_list_iterator, iter, *instructions) {
+ ir_instruction *ir = (ir_instruction *)iter.get();
+
+ visit_tree(ir, check_node_type, NULL);
+ }
}