i965/vec4: split VEC4_OPCODE_FROM_DOUBLE into one opcode per destination's type
[mesa.git] / src / compiler / glsl / ir_validate.cpp
index 2ec5a3f73f73adcca33bbfe6db354e3eaf5a3fcd..76a4ed17e775d7e7325aaaf8e74d21a876649d84 100644 (file)
@@ -246,11 +246,23 @@ ir_validate::visit_leave(ir_expression *ir)
       break;
 
    case ir_unop_neg:
+      assert(ir->type == ir->operands[0]->type);
+      break;
+
    case ir_unop_abs:
    case ir_unop_sign:
+      assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT ||
+             ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT ||
+             ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE ||
+             ir->operands[0]->type->base_type == GLSL_TYPE_INT64);
+      assert(ir->type == ir->operands[0]->type);
+      break;
+
    case ir_unop_rcp:
    case ir_unop_rsq:
    case ir_unop_sqrt:
+      assert(ir->type->base_type == GLSL_TYPE_FLOAT ||
+             ir->type->base_type == GLSL_TYPE_DOUBLE);
       assert(ir->type == ir->operands[0]->type);
       break;
 
@@ -320,6 +332,102 @@ ir_validate::visit_leave(ir_expression *ir)
       assert(ir->type->base_type == GLSL_TYPE_UINT);
       break;
 
+   case ir_unop_bitcast_u642d:
+      assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT64);
+      assert(ir->type->base_type == GLSL_TYPE_DOUBLE);
+      break;
+   case ir_unop_bitcast_i642d:
+      assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT64);
+      assert(ir->type->base_type == GLSL_TYPE_DOUBLE);
+      break;
+   case ir_unop_bitcast_d2u64:
+      assert(ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE);
+      assert(ir->type->base_type == GLSL_TYPE_UINT64);
+      break;
+   case ir_unop_bitcast_d2i64:
+      assert(ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE);
+      assert(ir->type->base_type == GLSL_TYPE_INT64);
+      break;
+   case ir_unop_i642i:
+      assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT64);
+      assert(ir->type->base_type == GLSL_TYPE_INT);
+      break;
+   case ir_unop_u642i:
+      assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT64);
+      assert(ir->type->base_type == GLSL_TYPE_INT);
+      break;
+   case ir_unop_i642u:
+      assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT64);
+      assert(ir->type->base_type == GLSL_TYPE_UINT);
+      break;
+   case ir_unop_u642u:
+      assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT64);
+      assert(ir->type->base_type == GLSL_TYPE_UINT);
+      break;
+   case ir_unop_i642b:
+      assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT64);
+      assert(ir->type->base_type == GLSL_TYPE_BOOL);
+      break;
+   case ir_unop_i642f:
+      assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT64);
+      assert(ir->type->base_type == GLSL_TYPE_FLOAT);
+      break;
+   case ir_unop_u642f:
+      assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT64);
+      assert(ir->type->base_type == GLSL_TYPE_FLOAT);
+      break;
+   case ir_unop_i642d:
+      assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT64);
+      assert(ir->type->base_type == GLSL_TYPE_DOUBLE);
+      break;
+   case ir_unop_u642d:
+      assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT64);
+      assert(ir->type->base_type == GLSL_TYPE_DOUBLE);
+      break;
+   case ir_unop_i2i64:
+      assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
+      assert(ir->type->base_type == GLSL_TYPE_INT64);
+      break;
+   case ir_unop_u2i64:
+      assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT);
+      assert(ir->type->base_type == GLSL_TYPE_INT64);
+      break;
+   case ir_unop_b2i64:
+      assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL);
+      assert(ir->type->base_type == GLSL_TYPE_INT64);
+      break;
+   case ir_unop_f2i64:
+      assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT);
+      assert(ir->type->base_type == GLSL_TYPE_INT64);
+      break;
+   case ir_unop_d2i64:
+      assert(ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE);
+      assert(ir->type->base_type == GLSL_TYPE_INT64);
+      break;
+   case ir_unop_i2u64:
+      assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
+      assert(ir->type->base_type == GLSL_TYPE_UINT64);
+      break;
+   case ir_unop_u2u64:
+      assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT);
+      assert(ir->type->base_type == GLSL_TYPE_UINT64);
+      break;
+   case ir_unop_f2u64:
+      assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT);
+      assert(ir->type->base_type == GLSL_TYPE_UINT64);
+      break;
+   case ir_unop_d2u64:
+      assert(ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE);
+      assert(ir->type->base_type == GLSL_TYPE_UINT64);
+      break;
+   case ir_unop_u642i64:
+      assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT64);
+      assert(ir->type->base_type == GLSL_TYPE_INT64);
+      break;
+   case ir_unop_i642u64:
+      assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT64);
+      assert(ir->type->base_type == GLSL_TYPE_UINT64);
+      break;
    case ir_unop_trunc:
    case ir_unop_round_even:
    case ir_unop_ceil:
@@ -359,6 +467,16 @@ ir_validate::visit_leave(ir_expression *ir)
       assert(ir->operands[0]->type == glsl_type::uvec2_type);
       break;
 
+   case ir_unop_pack_int_2x32:
+      assert(ir->type == glsl_type::int64_t_type);
+      assert(ir->operands[0]->type == glsl_type::ivec2_type);
+      break;
+
+   case ir_unop_pack_uint_2x32:
+      assert(ir->type == glsl_type::uint64_t_type);
+      assert(ir->operands[0]->type == glsl_type::uvec2_type);
+      break;
+
    case ir_unop_unpack_snorm_2x16:
    case ir_unop_unpack_unorm_2x16:
    case ir_unop_unpack_half_2x16:
@@ -377,6 +495,16 @@ ir_validate::visit_leave(ir_expression *ir)
       assert(ir->operands[0]->type == glsl_type::double_type);
       break;
 
+   case ir_unop_unpack_int_2x32:
+      assert(ir->type == glsl_type::ivec2_type);
+      assert(ir->operands[0]->type == glsl_type::int64_t_type);
+      break;
+
+   case ir_unop_unpack_uint_2x32:
+      assert(ir->type == glsl_type::uvec2_type);
+      assert(ir->operands[0]->type == glsl_type::uint64_t_type);
+      break;
+
    case ir_unop_bitfield_reverse:
       assert(ir->operands[0]->type == ir->type);
       assert(ir->type->is_integer());
@@ -453,6 +581,30 @@ ir_validate::visit_leave(ir_expression *ir)
       assert(ir->operands[0]->type->base_type == GLSL_TYPE_SUBROUTINE);
       assert(ir->type->base_type == GLSL_TYPE_INT);
       break;
+
+   case ir_unop_ballot:
+      assert(ir->type == glsl_type::uint64_t_type);
+      assert(ir->operands[0]->type == glsl_type::bool_type);
+      break;
+
+   case ir_binop_read_invocation:
+      assert(ir->operands[1]->type == glsl_type::uint_type);
+      /* fall-through */
+   case ir_unop_read_first_invocation:
+      assert(ir->type == ir->operands[0]->type);
+      assert(ir->type->is_scalar() || ir->type->is_vector());
+      assert(ir->type->base_type == GLSL_TYPE_FLOAT ||
+             ir->type->base_type == GLSL_TYPE_INT ||
+             ir->type->base_type == GLSL_TYPE_UINT);
+      break;
+
+   case ir_unop_vote_any:
+   case ir_unop_vote_all:
+   case ir_unop_vote_eq:
+      assert(ir->type == glsl_type::bool_type);
+      assert(ir->operands[0]->type == glsl_type::bool_type);
+      break;
+
    case ir_binop_add:
    case ir_binop_sub:
    case ir_binop_mul:
@@ -518,7 +670,7 @@ ir_validate::visit_leave(ir_expression *ir)
 
    case ir_binop_lshift:
    case ir_binop_rshift:
-      assert(ir->operands[0]->type->is_integer() &&
+      assert(ir->operands[0]->type->is_integer_32_64() &&
              ir->operands[1]->type->is_integer());
       if (ir->operands[0]->type->is_scalar()) {
           assert(ir->operands[1]->type->is_scalar());
@@ -536,7 +688,7 @@ ir_validate::visit_leave(ir_expression *ir)
    case ir_binop_bit_or:
        assert(ir->operands[0]->type->base_type ==
               ir->operands[1]->type->base_type);
-       assert(ir->type->is_integer());
+       assert(ir->type->is_integer_32_64());
        if (ir->operands[0]->type->is_vector() &&
            ir->operands[1]->type->is_vector()) {
            assert(ir->operands[0]->type->vector_elements ==
@@ -727,7 +879,7 @@ ir_validate::visit(ir_variable *ir)
     * to be out of bounds.
     */
    if (ir->type->array_size() > 0) {
-      if (ir->data.max_array_access >= ir->type->length) {
+      if (ir->data.max_array_access >= (int)ir->type->length) {
         printf("ir_variable has maximum access out of bounds (%d vs %d)\n",
                ir->data.max_array_access, ir->type->length - 1);
         ir->print();
@@ -743,13 +895,14 @@ ir_validate::visit(ir_variable *ir)
       const glsl_struct_field *fields =
          ir->get_interface_type()->fields.structure;
       for (unsigned i = 0; i < ir->get_interface_type()->length; i++) {
-         if (fields[i].type->array_size() > 0) {
-            const unsigned *const max_ifc_array_access =
+         if (fields[i].type->array_size() > 0 &&
+             !fields[i].implicit_sized_array) {
+            const int *const max_ifc_array_access =
                ir->get_max_ifc_array_access();
 
             assert(max_ifc_array_access != NULL);
 
-            if (max_ifc_array_access[i] >= fields[i].type->length) {
+            if (max_ifc_array_access[i] >= (int)fields[i].type->length) {
                printf("ir_variable has maximum access out of bounds for "
                       "field %s (%d vs %d)\n", fields[i].name,
                       max_ifc_array_access[i], fields[i].type->length);
@@ -831,8 +984,8 @@ ir_validate::visit_enter(ir_call *ir)
       abort();
    }
 
-   const exec_node *formal_param_node = callee->parameters.head;
-   const exec_node *actual_param_node = ir->actual_parameters.head;
+   const exec_node *formal_param_node = callee->parameters.get_head_raw();
+   const exec_node *actual_param_node = ir->actual_parameters.get_head_raw();
    while (true) {
       if (formal_param_node->is_tail_sentinel()
           != actual_param_node->is_tail_sentinel()) {