summaryrefslogtreecommitdiff
path: root/ir_constant_expression.cpp
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2010-04-06 09:55:45 -0700
committerEric Anholt <eric@anholt.net>2010-04-06 11:42:34 -0700
commit85171c2dd8c7050511cb7708d75e574005262bf0 (patch)
tree3b9b03df64b6b31ad1eba809104d15e560184bc9 /ir_constant_expression.cpp
parent62735694a1dfc09a16ea32312877cd49c7982118 (diff)
Add ir_constant_expression.cpp support for <, >, <=, >=.
This results in folding one more constant expression in CorrectParse2.frag.
Diffstat (limited to 'ir_constant_expression.cpp')
-rw-r--r--ir_constant_expression.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp
index 69a3613080..f90c69b72c 100644
--- a/ir_constant_expression.cpp
+++ b/ir_constant_expression.cpp
@@ -252,6 +252,72 @@ ir_constant_visitor::visit(ir_expression *ir)
for (c = 0; c < ir->operands[0]->type->components(); c++)
b[c] = op[0]->value.b[c] || op[1]->value.b[c];
break;
+
+ case ir_binop_less:
+ type = glsl_type::bool_type;
+ switch (ir->operands[0]->type->base_type) {
+ case GLSL_TYPE_UINT:
+ b[0] = op[0]->value.u[0] < op[1]->value.u[0];
+ break;
+ case GLSL_TYPE_INT:
+ b[0] = op[0]->value.i[0] < op[1]->value.i[0];
+ break;
+ case GLSL_TYPE_FLOAT:
+ b[0] = op[0]->value.f[0] < op[1]->value.f[0];
+ break;
+ default:
+ assert(0);
+ }
+ break;
+ case ir_binop_greater:
+ type = glsl_type::bool_type;
+ switch (ir->operands[0]->type->base_type) {
+ case GLSL_TYPE_UINT:
+ b[0] = op[0]->value.u[0] > op[1]->value.u[0];
+ break;
+ case GLSL_TYPE_INT:
+ b[0] = op[0]->value.i[0] > op[1]->value.i[0];
+ break;
+ case GLSL_TYPE_FLOAT:
+ b[0] = op[0]->value.f[0] > op[1]->value.f[0];
+ break;
+ default:
+ assert(0);
+ }
+ break;
+ case ir_binop_lequal:
+ type = glsl_type::bool_type;
+ switch (ir->operands[0]->type->base_type) {
+ case GLSL_TYPE_UINT:
+ b[0] = op[0]->value.u[0] <= op[1]->value.u[0];
+ break;
+ case GLSL_TYPE_INT:
+ b[0] = op[0]->value.i[0] <= op[1]->value.i[0];
+ break;
+ case GLSL_TYPE_FLOAT:
+ b[0] = op[0]->value.f[0] <= op[1]->value.f[0];
+ break;
+ default:
+ assert(0);
+ }
+ break;
+ case ir_binop_gequal:
+ type = glsl_type::bool_type;
+ switch (ir->operands[0]->type->base_type) {
+ case GLSL_TYPE_UINT:
+ b[0] = op[0]->value.u[0] >= op[1]->value.u[0];
+ break;
+ case GLSL_TYPE_INT:
+ b[0] = op[0]->value.i[0] >= op[1]->value.i[0];
+ break;
+ case GLSL_TYPE_FLOAT:
+ b[0] = op[0]->value.f[0] >= op[1]->value.f[0];
+ break;
+ default:
+ assert(0);
+ }
+ break;
+
default:
break;
}