glsl: Consolidate ir_expression constructors that use explicit types.
[mesa.git] / src / glsl / ir.cpp
index 4c5115b98cfe54bf78a02b04bdb75233df0a3a3a..4ccdc42dce00ad308edbd0a2e13f95048bb11161 100644 (file)
@@ -195,34 +195,6 @@ ir_assignment::ir_assignment(ir_rvalue *lhs, ir_rvalue *rhs,
    this->set_lhs(lhs);
 }
 
-
-ir_expression::ir_expression(int op, const struct glsl_type *type,
-                            ir_rvalue *op0)
-{
-   assert(get_num_operands(ir_expression_operation(op)) == 1);
-   this->ir_type = ir_type_expression;
-   this->type = type;
-   this->operation = ir_expression_operation(op);
-   this->operands[0] = op0;
-   this->operands[1] = NULL;
-   this->operands[2] = NULL;
-   this->operands[3] = NULL;
-}
-
-ir_expression::ir_expression(int op, const struct glsl_type *type,
-                            ir_rvalue *op0, ir_rvalue *op1)
-{
-   assert(((op1 == NULL) && (get_num_operands(ir_expression_operation(op)) == 1))
-         || (get_num_operands(ir_expression_operation(op)) == 2));
-   this->ir_type = ir_type_expression;
-   this->type = type;
-   this->operation = ir_expression_operation(op);
-   this->operands[0] = op0;
-   this->operands[1] = op1;
-   this->operands[2] = NULL;
-   this->operands[3] = NULL;
-}
-
 ir_expression::ir_expression(int op, const struct glsl_type *type,
                             ir_rvalue *op0, ir_rvalue *op1,
                             ir_rvalue *op2, ir_rvalue *op3)
@@ -234,6 +206,12 @@ ir_expression::ir_expression(int op, const struct glsl_type *type,
    this->operands[1] = op1;
    this->operands[2] = op2;
    this->operands[3] = op3;
+#ifndef NDEBUG
+   int num_operands = get_num_operands(this->operation);
+   for (int i = num_operands; i < 4; i++) {
+      assert(this->operands[i] == NULL);
+   }
+#endif
 }
 
 ir_expression::ir_expression(int op, ir_rvalue *op0)
@@ -316,7 +294,9 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
       break;
 
    case ir_unop_pack_snorm_2x16:
+   case ir_unop_pack_snorm_4x8:
    case ir_unop_pack_unorm_2x16:
+   case ir_unop_pack_unorm_4x8:
    case ir_unop_pack_half_2x16:
       this->type = glsl_type::uint_type;
       break;
@@ -327,6 +307,11 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
       this->type = glsl_type::vec2_type;
       break;
 
+   case ir_unop_unpack_snorm_4x8:
+   case ir_unop_unpack_unorm_4x8:
+      this->type = glsl_type::vec4_type;
+      break;
+
    default:
       assert(!"not reached: missing automatic type setup for ir_expression");
       this->type = op0->type;
@@ -478,10 +463,14 @@ static const char *const operator_strs[] = {
    "dFdx",
    "dFdy",
    "packSnorm2x16",
+   "packSnorm4x8",
    "packUnorm2x16",
+   "packUnorm4x8",
    "packHalf2x16",
    "unpackSnorm2x16",
+   "unpackSnorm4x8",
    "unpackUnorm2x16",
+   "unpackUnorm4x8",
    "unpackHalf2x16",
    "unpackHalf2x16_split_x",
    "unpackHalf2x16_split_y",