glsl: Add type inference support for remaining expression opcodes.
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 7 Dec 2010 00:00:24 +0000 (16:00 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Wed, 12 Jan 2011 07:28:58 +0000 (23:28 -0800)
src/glsl/ir.cpp

index b8b0fed9d1cc760da6081add81b81810bc776702..742dd41b9f478c9d1440a91e2a0a3e2066d1562a 100644 (file)
@@ -261,12 +261,38 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
    case ir_unop_floor:
    case ir_unop_fract:
    case ir_unop_round_even:
+   case ir_unop_sin:
    case ir_unop_cos:
+   case ir_unop_sin_reduced:
+   case ir_unop_cos_reduced:
    case ir_unop_dFdx:
    case ir_unop_dFdy:
       this->type = op0->type;
       break;
 
+   case ir_unop_f2i:
+   case ir_unop_b2i:
+      this->type = glsl_type::get_instance(GLSL_TYPE_INT,
+                                          op0->type->vector_elements, 1);
+      break;
+
+   case ir_unop_b2f:
+   case ir_unop_i2f:
+   case ir_unop_u2f:
+      this->type = glsl_type::get_instance(GLSL_TYPE_FLOAT,
+                                          op0->type->vector_elements, 1);
+      break;
+
+   case ir_unop_f2b:
+   case ir_unop_i2b:
+      this->type = glsl_type::get_instance(GLSL_TYPE_BOOL,
+                                          op0->type->vector_elements, 1);
+      break;
+
+   case ir_unop_noise:
+      this->type = glsl_type::float_type;
+      break;
+
    case ir_unop_any:
       this->type = glsl_type::bool_type;
       break;
@@ -302,6 +328,8 @@ ir_expression::ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1)
    case ir_binop_max:
    case ir_binop_pow:
    case ir_binop_mul:
+   case ir_binop_div:
+   case ir_binop_mod:
       if (op0->type->is_scalar()) {
         this->type = op1->type;
       } else if (op1->type->is_scalar()) {
@@ -315,7 +343,11 @@ ir_expression::ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1)
       break;
 
    case ir_binop_logic_and:
+   case ir_binop_logic_xor:
    case ir_binop_logic_or:
+   case ir_binop_bit_and:
+   case ir_binop_bit_xor:
+   case ir_binop_bit_or:
       if (op0->type->is_scalar()) {
         this->type = op1->type;
       } else if (op1->type->is_scalar()) {
@@ -323,10 +355,26 @@ ir_expression::ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1)
       }
       break;
 
+   case ir_binop_equal:
+   case ir_binop_nequal:
+   case ir_binop_lequal:
+   case ir_binop_gequal:
+   case ir_binop_less:
+   case ir_binop_greater:
+      assert(op0->type == op1->type);
+      this->type = glsl_type::get_instance(GLSL_TYPE_BOOL,
+                                          op0->type->vector_elements, 1);
+      break;
+
    case ir_binop_dot:
       this->type = glsl_type::float_type;
       break;
 
+   case ir_binop_lshift:
+   case ir_binop_rshift:
+      this->type = op0->type;
+      break;
+
    default:
       assert(!"not reached: missing automatic type setup for ir_expression");
       this->type = glsl_type::float_type;