#include "ir.h"
#include "ir_hierarchical_visitor.h"
#include "util/hash_table.h"
+#include "util/macros.h"
#include "util/set.h"
#include "compiler/glsl_types.h"
ir_visitor_status
ir_validate::visit_leave(ir_expression *ir)
{
+ for (unsigned i = ir->num_operands; i < 4; i++) {
+ assert(ir->operands[i] == NULL);
+ }
+
+ for (unsigned i = 0; i < ir->num_operands; i++) {
+ assert(ir->operands[i] != NULL);
+ }
+
switch (ir->operation) {
case ir_unop_bit_not:
assert(ir->operands[0]->type == ir->type);
break;
case ir_unop_logic_not:
- assert(ir->type->base_type == GLSL_TYPE_BOOL);
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL);
+ assert(ir->type->is_boolean());
+ assert(ir->operands[0]->type->is_boolean());
break;
case ir_unop_neg:
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->is_float() ||
+ ir->operands[0]->type->is_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->is_float() ||
+ ir->type->is_double());
assert(ir->type == ir->operands[0]->type);
break;
case ir_unop_exp2:
case ir_unop_log2:
case ir_unop_saturate:
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT);
+ assert(ir->operands[0]->type->is_float());
assert(ir->type == ir->operands[0]->type);
break;
case ir_unop_f2i:
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT);
+ assert(ir->operands[0]->type->is_float());
assert(ir->type->base_type == GLSL_TYPE_INT);
break;
case ir_unop_f2u:
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT);
+ assert(ir->operands[0]->type->is_float());
assert(ir->type->base_type == GLSL_TYPE_UINT);
break;
case ir_unop_i2f:
assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
- assert(ir->type->base_type == GLSL_TYPE_FLOAT);
+ assert(ir->type->is_float());
break;
case ir_unop_f2b:
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT);
- assert(ir->type->base_type == GLSL_TYPE_BOOL);
+ assert(ir->operands[0]->type->is_float());
+ assert(ir->type->is_boolean());
break;
case ir_unop_b2f:
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL);
- assert(ir->type->base_type == GLSL_TYPE_FLOAT);
+ assert(ir->operands[0]->type->is_boolean());
+ assert(ir->type->is_float());
break;
case ir_unop_i2b:
assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
- assert(ir->type->base_type == GLSL_TYPE_BOOL);
+ assert(ir->type->is_boolean());
break;
case ir_unop_b2i:
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL);
+ assert(ir->operands[0]->type->is_boolean());
assert(ir->type->base_type == GLSL_TYPE_INT);
break;
case ir_unop_u2f:
assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT);
- assert(ir->type->base_type == GLSL_TYPE_FLOAT);
+ assert(ir->type->is_float());
break;
case ir_unop_i2u:
assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
break;
case ir_unop_bitcast_i2f:
assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
- assert(ir->type->base_type == GLSL_TYPE_FLOAT);
+ assert(ir->type->is_float());
break;
case ir_unop_bitcast_f2i:
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT);
+ assert(ir->operands[0]->type->is_float());
assert(ir->type->base_type == GLSL_TYPE_INT);
break;
case ir_unop_bitcast_u2f:
assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT);
- assert(ir->type->base_type == GLSL_TYPE_FLOAT);
+ assert(ir->type->is_float());
break;
case ir_unop_bitcast_f2u:
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT);
+ assert(ir->operands[0]->type->is_float());
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);
+ assert(ir->type->is_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);
+ assert(ir->type->is_double());
break;
case ir_unop_bitcast_d2u64:
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE);
+ assert(ir->operands[0]->type->is_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->operands[0]->type->is_double());
assert(ir->type->base_type == GLSL_TYPE_INT64);
break;
case ir_unop_i642i:
break;
case ir_unop_i642b:
assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT64);
- assert(ir->type->base_type == GLSL_TYPE_BOOL);
+ assert(ir->type->is_boolean());
break;
case ir_unop_i642f:
assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT64);
- assert(ir->type->base_type == GLSL_TYPE_FLOAT);
+ assert(ir->type->is_float());
break;
case ir_unop_u642f:
assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT64);
- assert(ir->type->base_type == GLSL_TYPE_FLOAT);
+ assert(ir->type->is_float());
break;
case ir_unop_i642d:
assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT64);
- assert(ir->type->base_type == GLSL_TYPE_DOUBLE);
+ assert(ir->type->is_double());
break;
case ir_unop_u642d:
assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT64);
- assert(ir->type->base_type == GLSL_TYPE_DOUBLE);
+ assert(ir->type->is_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_b2i64:
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL);
+ assert(ir->operands[0]->type->is_boolean());
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->operands[0]->type->is_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->operands[0]->type->is_double());
assert(ir->type->base_type == GLSL_TYPE_INT64);
break;
case ir_unop_i2u64:
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->operands[0]->type->is_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->operands[0]->type->is_double());
assert(ir->type->base_type == GLSL_TYPE_UINT64);
break;
case ir_unop_u642i64:
case ir_unop_ceil:
case ir_unop_floor:
case ir_unop_fract:
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT ||
- ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE);
+ assert(ir->operands[0]->type->is_float() ||
+ ir->operands[0]->type->is_double());
assert(ir->operands[0]->type == ir->type);
break;
case ir_unop_sin:
case ir_unop_dFdy:
case ir_unop_dFdy_coarse:
case ir_unop_dFdy_fine:
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT);
+ assert(ir->operands[0]->type->is_float());
assert(ir->operands[0]->type == ir->type);
break;
assert(ir->operands[0]->type == glsl_type::uvec2_type);
break;
+ case ir_unop_pack_sampler_2x32:
+ assert(ir->type->is_sampler());
+ assert(ir->operands[0]->type == glsl_type::uvec2_type);
+ break;
+
+ case ir_unop_pack_image_2x32:
+ assert(ir->type->is_image());
+ 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:
assert(ir->operands[0]->type == glsl_type::uint64_t_type);
break;
+ case ir_unop_unpack_sampler_2x32:
+ assert(ir->type == glsl_type::uvec2_type);
+ assert(ir->operands[0]->type->is_sampler());
+ break;
+
+ case ir_unop_unpack_image_2x32:
+ assert(ir->type == glsl_type::uvec2_type);
+ assert(ir->operands[0]->type->is_image());
+ break;
+
case ir_unop_bitfield_reverse:
assert(ir->operands[0]->type == ir->type);
assert(ir->type->is_integer());
break;
case ir_unop_d2f:
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE);
- assert(ir->type->base_type == GLSL_TYPE_FLOAT);
+ assert(ir->operands[0]->type->is_double());
+ assert(ir->type->is_float());
break;
case ir_unop_f2d:
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT);
- assert(ir->type->base_type == GLSL_TYPE_DOUBLE);
+ assert(ir->operands[0]->type->is_float());
+ assert(ir->type->is_double());
break;
case ir_unop_d2i:
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE);
+ assert(ir->operands[0]->type->is_double());
assert(ir->type->base_type == GLSL_TYPE_INT);
break;
case ir_unop_i2d:
assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
- assert(ir->type->base_type == GLSL_TYPE_DOUBLE);
+ assert(ir->type->is_double());
break;
case ir_unop_d2u:
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE);
+ assert(ir->operands[0]->type->is_double());
assert(ir->type->base_type == GLSL_TYPE_UINT);
break;
case ir_unop_u2d:
assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT);
- assert(ir->type->base_type == GLSL_TYPE_DOUBLE);
+ assert(ir->type->is_double());
break;
case ir_unop_d2b:
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE);
- assert(ir->type->base_type == GLSL_TYPE_BOOL);
+ assert(ir->operands[0]->type->is_double());
+ assert(ir->type->is_boolean());
break;
case ir_unop_frexp_sig:
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT ||
- ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE);
- assert(ir->type->base_type == GLSL_TYPE_DOUBLE);
+ assert(ir->operands[0]->type->is_float() ||
+ ir->operands[0]->type->is_double());
+ assert(ir->type->is_double());
break;
case ir_unop_frexp_exp:
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT ||
- ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE);
+ assert(ir->operands[0]->type->is_float() ||
+ ir->operands[0]->type->is_double());
assert(ir->type->base_type == GLSL_TYPE_INT);
break;
case ir_unop_subroutine_to_int:
assert(ir->type->base_type == GLSL_TYPE_INT);
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:
* comparison on scalar or vector types and return a boolean scalar or
* vector type of the same size.
*/
- assert(ir->type->base_type == GLSL_TYPE_BOOL);
+ assert(ir->type->is_boolean());
assert(ir->operands[0]->type == ir->operands[1]->type);
assert(ir->operands[0]->type->is_vector()
|| ir->operands[0]->type->is_scalar());
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());
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 ==
case ir_binop_logic_and:
case ir_binop_logic_xor:
case ir_binop_logic_or:
- assert(ir->type->base_type == GLSL_TYPE_BOOL);
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL);
- assert(ir->operands[1]->type->base_type == GLSL_TYPE_BOOL);
+ assert(ir->type->is_boolean());
+ assert(ir->operands[0]->type->is_boolean());
+ assert(ir->operands[1]->type->is_boolean());
break;
case ir_binop_dot:
assert(ir->type == glsl_type::float_type ||
ir->type == glsl_type::double_type);
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT ||
- ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE);
+ assert(ir->operands[0]->type->is_float() ||
+ ir->operands[0]->type->is_double());
assert(ir->operands[0]->type->is_vector());
assert(ir->operands[0]->type == ir->operands[1]->type);
break;
break;
case ir_triop_fma:
- assert(ir->type->base_type == GLSL_TYPE_FLOAT ||
- ir->type->base_type == GLSL_TYPE_DOUBLE);
+ assert(ir->type->is_float() ||
+ ir->type->is_double());
assert(ir->type == ir->operands[0]->type);
assert(ir->type == ir->operands[1]->type);
assert(ir->type == ir->operands[2]->type);
break;
case ir_triop_lrp:
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT ||
- ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE);
+ assert(ir->operands[0]->type->is_float() ||
+ ir->operands[0]->type->is_double());
assert(ir->operands[0]->type == ir->operands[1]->type);
assert(ir->operands[2]->type == ir->operands[0]->type ||
ir->operands[2]->type == glsl_type::float_type ||
break;
case ir_triop_csel:
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL);
+ assert(ir->operands[0]->type->is_boolean());
assert(ir->type->vector_elements == ir->operands[0]->type->vector_elements);
assert(ir->type == ir->operands[1]->type);
assert(ir->type == ir->operands[2]->type);
_mesa_set_add(ir_set, ir);
}
-void
+MAYBE_UNUSED static void
check_node_type(ir_instruction *ir, void *data)
{
(void) data;