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.
This commit is contained in:
Eric Anholt
2010-07-19 09:05:42 -07:00
parent ee7b2b3f44
commit d16044ad4d
3 changed files with 70 additions and 10 deletions

View File

@@ -172,10 +172,25 @@ ir_validate::validate_ir(ir_instruction *ir, void *data)
hash_table_insert(ht, ir, ir);
}
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);
}
}