summaryrefslogtreecommitdiff
path: root/src/glsl
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-08-26 15:22:06 -0700
committerIan Romanick <ian.d.romanick@intel.com>2010-09-03 11:55:21 -0700
commit53acbd87d712555f9e7a1c304843be7b39641413 (patch)
treef6d00bbac3c02bd212594768d792a999dc60b4c5 /src/glsl
parent3b85f1cc6cb12e9d4931e12cf29adde578f389fd (diff)
ir_validate: Validate loop control fields in ir_loop
Diffstat (limited to 'src/glsl')
-rw-r--r--src/glsl/ir_validate.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp
index 9ea11dd400..8e82590364 100644
--- a/src/glsl/ir_validate.cpp
+++ b/src/glsl/ir_validate.cpp
@@ -61,6 +61,7 @@ public:
virtual ir_visitor_status visit(ir_dereference_variable *ir);
virtual ir_visitor_status visit(ir_if *ir);
+ virtual ir_visitor_status visit_leave(ir_loop *ir);
virtual ir_visitor_status visit_enter(ir_function *ir);
virtual ir_visitor_status visit_leave(ir_function *ir);
virtual ir_visitor_status visit_enter(ir_function_signature *ir);
@@ -114,6 +115,40 @@ ir_validate::visit(ir_if *ir)
ir_visitor_status
+ir_validate::visit_leave(ir_loop *ir)
+{
+ if (ir->counter != NULL) {
+ if ((ir->from == NULL) || (ir->from == NULL) || (ir->increment == NULL)) {
+ printf("ir_loop has invalid loop controls:\n"
+ " counter: %p\n"
+ " from: %p\n"
+ " to: %p\n"
+ " increment: %p\n",
+ ir->counter, ir->from, ir->to, ir->increment);
+ abort();
+ }
+
+ if ((ir->cmp < ir_binop_less) || (ir->cmp > ir_binop_nequal)) {
+ printf("ir_loop has invalid comparitor %d\n", ir->cmp);
+ abort();
+ }
+ } else {
+ if ((ir->from != NULL) || (ir->from != NULL) || (ir->increment != NULL)) {
+ printf("ir_loop has invalid loop controls:\n"
+ " counter: %p\n"
+ " from: %p\n"
+ " to: %p\n"
+ " increment: %p\n",
+ ir->counter, ir->from, ir->to, ir->increment);
+ abort();
+ }
+ }
+
+ return visit_continue;
+}
+
+
+ir_visitor_status
ir_validate::visit_enter(ir_function *ir)
{
/* Function definitions cannot be nested.