#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"
public:
ir_validate()
{
- this->ir_set = _mesa_set_create(NULL, _mesa_hash_pointer,
- _mesa_key_pointer_equal);
+ this->ir_set = _mesa_pointer_set_create(NULL);
this->current_function = NULL;
abort();
}
- if (!ir->array_index->type->is_integer()) {
+ if (!ir->array_index->type->is_integer_16_32()) {
printf("ir_dereference_array @ %p does not have integer index: %s\n",
(void *) ir, ir->array_index->type->name);
abort();
case ir_unop_abs:
case ir_unop_sign:
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT ||
- ir->operands[0]->type->is_float() ||
- ir->operands[0]->type->is_double() ||
- ir->operands[0]->type->base_type == GLSL_TYPE_INT64);
+ assert(ir->operands[0]->type->is_int_16_32_64() ||
+ ir->operands[0]->type->is_float_16_32_64());
assert(ir->type == ir->operands[0]->type);
break;
case ir_unop_rcp:
case ir_unop_rsq:
case ir_unop_sqrt:
- assert(ir->type->is_float() ||
- ir->type->is_double());
+ assert(ir->type->is_float_16_32_64());
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->is_float());
+ assert(ir->operands[0]->type->is_float_16_32());
assert(ir->type == ir->operands[0]->type);
break;
case ir_unop_f2i:
- assert(ir->operands[0]->type->is_float());
- assert(ir->type->base_type == GLSL_TYPE_INT);
+ assert(ir->operands[0]->type->is_float_16_32());
+ assert(ir->type->is_int_16_32());
break;
case ir_unop_f2u:
- assert(ir->operands[0]->type->is_float());
- assert(ir->type->base_type == GLSL_TYPE_UINT);
+ assert(ir->operands[0]->type->is_float_16_32());
+ assert(ir->type->is_uint_16_32());
break;
case ir_unop_i2f:
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
- assert(ir->type->is_float());
+ assert(ir->operands[0]->type->is_int_16_32());
+ assert(ir->type->is_float_16_32());
break;
case ir_unop_f2b:
- assert(ir->operands[0]->type->is_float());
+ assert(ir->operands[0]->type->is_float_16_32());
+ assert(ir->type->is_boolean());
+ break;
+ case ir_unop_f162b:
+ assert(ir->operands[0]->type->base_type ==
+ GLSL_TYPE_FLOAT16);
assert(ir->type->is_boolean());
break;
case ir_unop_b2f:
assert(ir->operands[0]->type->is_boolean());
- assert(ir->type->is_float());
+ assert(ir->type->is_float_16_32());
+ break;
+ case ir_unop_b2f16:
+ assert(ir->operands[0]->type->is_boolean());
+ assert(ir->type->base_type == GLSL_TYPE_FLOAT16);
break;
case ir_unop_i2b:
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
+ assert(ir->operands[0]->type->is_int_16_32());
assert(ir->type->is_boolean());
break;
case ir_unop_b2i:
assert(ir->operands[0]->type->is_boolean());
- assert(ir->type->base_type == GLSL_TYPE_INT);
+ assert(ir->type->is_int_16_32());
break;
case ir_unop_u2f:
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT);
- assert(ir->type->is_float());
+ assert(ir->operands[0]->type->is_uint_16_32());
+ assert(ir->type->is_float_16_32());
break;
case ir_unop_i2u:
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
- assert(ir->type->base_type == GLSL_TYPE_UINT);
+ assert(ir->operands[0]->type->is_int_16_32());
+ assert(ir->type->is_uint_16_32());
break;
case ir_unop_u2i:
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT);
- assert(ir->type->base_type == GLSL_TYPE_INT);
+ assert(ir->operands[0]->type->is_uint_16_32());
+ assert(ir->type->is_int_16_32());
break;
case ir_unop_bitcast_i2f:
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
- assert(ir->type->is_float());
+ assert(ir->operands[0]->type->is_int_16_32());
+ assert(ir->type->is_float_16_32());
break;
case ir_unop_bitcast_f2i:
- assert(ir->operands[0]->type->is_float());
- assert(ir->type->base_type == GLSL_TYPE_INT);
+ assert(ir->operands[0]->type->is_float_16_32());
+ assert(ir->type->is_int_16_32());
break;
case ir_unop_bitcast_u2f:
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT);
- assert(ir->type->is_float());
+ assert(ir->operands[0]->type->is_uint_16_32());
+ assert(ir->type->is_float_16_32());
break;
case ir_unop_bitcast_f2u:
- assert(ir->operands[0]->type->is_float());
- assert(ir->type->base_type == GLSL_TYPE_UINT);
+ assert(ir->operands[0]->type->is_float_16_32());
+ assert(ir->type->is_uint_16_32());
break;
case ir_unop_bitcast_u642d:
break;
case ir_unop_i642i:
assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT64);
- assert(ir->type->base_type == GLSL_TYPE_INT);
+ assert(ir->type->is_int_16_32());
break;
case ir_unop_u642i:
assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT64);
- assert(ir->type->base_type == GLSL_TYPE_INT);
+ assert(ir->type->is_int_16_32());
break;
case ir_unop_i642u:
assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT64);
- assert(ir->type->base_type == GLSL_TYPE_UINT);
+ assert(ir->type->is_uint_16_32());
break;
case ir_unop_u642u:
assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT64);
- assert(ir->type->base_type == GLSL_TYPE_UINT);
+ assert(ir->type->is_uint_16_32());
break;
case ir_unop_i642b:
assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT64);
assert(ir->type->is_double());
break;
case ir_unop_i2i64:
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
+ assert(ir->operands[0]->type->is_int_16_32());
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->operands[0]->type->is_uint_16_32());
assert(ir->type->base_type == GLSL_TYPE_INT64);
break;
case ir_unop_b2i64:
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->operands[0]->type->is_int_16_32());
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->operands[0]->type->is_uint_16_32());
assert(ir->type->base_type == GLSL_TYPE_UINT64);
break;
case ir_unop_f2u64:
case ir_unop_ceil:
case ir_unop_floor:
case ir_unop_fract:
- assert(ir->operands[0]->type->is_float() ||
- ir->operands[0]->type->is_double());
+ assert(ir->operands[0]->type->is_float_16_32_64());
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->is_float());
+ assert(ir->operands[0]->type->is_float_16_32());
assert(ir->operands[0]->type == ir->type);
break;
case ir_unop_bitfield_reverse:
assert(ir->operands[0]->type == ir->type);
- assert(ir->type->is_integer());
+ assert(ir->type->is_integer_16_32());
break;
case ir_unop_bit_count:
case ir_unop_find_msb:
case ir_unop_find_lsb:
assert(ir->operands[0]->type->vector_elements == ir->type->vector_elements);
- assert(ir->operands[0]->type->is_integer());
- assert(ir->type->base_type == GLSL_TYPE_INT);
+ assert(ir->operands[0]->type->is_integer_16_32());
+ assert(ir->type->is_int_16_32());
break;
- case ir_unop_noise:
- /* XXX what can we assert here? */
+ case ir_unop_clz:
+ assert(ir->operands[0]->type == ir->type);
+ assert(ir->type->is_uint_16_32());
break;
case ir_unop_interpolate_at_centroid:
assert(ir->operands[0]->type == ir->type);
- assert(ir->operands[0]->type->is_float());
+ assert(ir->operands[0]->type->is_float_16_32());
break;
case ir_unop_get_buffer_size:
assert(ir->operands[0]->type->is_float());
assert(ir->type->is_double());
break;
+ case ir_unop_f162f:
+ assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT16);
+ assert(ir->type->is_float());
+ break;
+ case ir_unop_f2f16:
+ case ir_unop_f2fmp:
+ assert(ir->operands[0]->type->is_float());
+ assert(ir->type->base_type == GLSL_TYPE_FLOAT16);
+ break;
+ case ir_unop_i2i:
+ assert(ir->operands[0]->type->is_int_16_32());
+ assert(ir->type->is_int_16_32());
+ assert(ir->type->base_type != ir->operands[0]->type->base_type);
+ break;
+ case ir_unop_u2u:
+ assert(ir->operands[0]->type->is_uint_16_32());
+ assert(ir->type->is_uint_16_32());
+ assert(ir->type->base_type != ir->operands[0]->type->base_type);
+ break;
+ case ir_unop_i2imp:
+ assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
+ assert(ir->type->base_type == GLSL_TYPE_INT16);
+ break;
+ case ir_unop_u2ump:
+ assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT);
+ assert(ir->type->base_type == GLSL_TYPE_UINT16);
+ break;
case ir_unop_d2i:
assert(ir->operands[0]->type->is_double());
- assert(ir->type->base_type == GLSL_TYPE_INT);
+ assert(ir->type->is_int_16_32());
break;
case ir_unop_i2d:
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
+ assert(ir->operands[0]->type->is_int_16_32());
assert(ir->type->is_double());
break;
case ir_unop_d2u:
assert(ir->operands[0]->type->is_double());
- assert(ir->type->base_type == GLSL_TYPE_UINT);
+ assert(ir->type->is_uint_16_32());
break;
case ir_unop_u2d:
- assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT);
+ assert(ir->operands[0]->type->is_uint_16_32());
assert(ir->type->is_double());
break;
case ir_unop_d2b:
break;
case ir_unop_frexp_sig:
- assert(ir->operands[0]->type->is_float() ||
- ir->operands[0]->type->is_double());
+ assert(ir->operands[0]->type->is_float_16_32_64());
assert(ir->type->is_double());
break;
case ir_unop_frexp_exp:
- assert(ir->operands[0]->type->is_float() ||
- ir->operands[0]->type->is_double());
- assert(ir->type->base_type == GLSL_TYPE_INT);
+ assert(ir->operands[0]->type->is_float_16_32_64());
+ assert(ir->type->is_int_16_32());
break;
case ir_unop_subroutine_to_int:
assert(ir->operands[0]->type->base_type == GLSL_TYPE_SUBROUTINE);
assert(ir->type->base_type == GLSL_TYPE_INT);
break;
+ case ir_unop_atan:
+ assert(ir->operands[0]->type->is_float_16_32_64());
+ assert(ir->type == ir->operands[0]->type);
+ break;
+
case ir_binop_add:
case ir_binop_sub:
case ir_binop_mul:
assert(ir->operands[0]->type->base_type ==
ir->operands[1]->type->base_type);
+ if (ir->operation == ir_binop_mul &&
+ (ir->type->base_type == GLSL_TYPE_UINT64 ||
+ ir->type->base_type == GLSL_TYPE_INT64) &&
+ (ir->operands[0]->type->is_int_16_32()||
+ ir->operands[1]->type->is_int_16_32()||
+ ir->operands[0]->type->is_uint_16_32() ||
+ ir->operands[1]->type->is_uint_16_32())) {
+ assert(ir->operands[0]->type == ir->operands[1]->type);
+ break;
+ }
+
if (ir->operands[0]->type->is_scalar())
assert(ir->operands[1]->type == ir->type);
else if (ir->operands[1]->type->is_scalar())
}
break;
+ case ir_binop_abs_sub:
+ assert(ir->operands[0]->type == ir->operands[1]->type);
+ assert(ir->operands[0]->type->is_integer_16_32_64());
+ assert(ir->operands[0]->type->vector_elements ==
+ ir->type->vector_elements);
+ assert(ir->type->is_uint_16_32_64());
+ break;
+
+ case ir_binop_add_sat:
+ case ir_binop_sub_sat:
+ case ir_binop_avg:
+ case ir_binop_avg_round:
+ assert(ir->type == ir->operands[0]->type);
+ assert(ir->type == ir->operands[1]->type);
+ assert(ir->type->is_integer_16_32_64());
+ break;
+
+ case ir_binop_mul_32x16:
case ir_binop_imul_high:
assert(ir->type == ir->operands[0]->type);
assert(ir->type == ir->operands[1]->type);
- assert(ir->type->is_integer());
+ assert(ir->type->is_integer_32());
break;
case ir_binop_carry:
break;
case ir_binop_less:
- case ir_binop_greater:
- case ir_binop_lequal:
case ir_binop_gequal:
case ir_binop_equal:
case ir_binop_nequal:
case ir_binop_lshift:
case ir_binop_rshift:
- assert(ir->operands[0]->type->is_integer_32_64() &&
- ir->operands[1]->type->is_integer());
+ assert(ir->operands[0]->type->is_integer_16_32_64() &&
+ ir->operands[1]->type->is_integer_16_32());
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_32_64());
+ assert(ir->type->is_integer_16_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_dot:
assert(ir->type == glsl_type::float_type ||
- ir->type == glsl_type::double_type);
- assert(ir->operands[0]->type->is_float() ||
- ir->operands[0]->type->is_double());
+ ir->type == glsl_type::double_type ||
+ ir->type == glsl_type::float16_t_type);
+ assert(ir->operands[0]->type->is_float_16_32_64());
assert(ir->operands[0]->type->is_vector());
assert(ir->operands[0]->type == ir->operands[1]->type);
break;
case ir_binop_ldexp:
assert(ir->operands[0]->type == ir->type);
- assert(ir->operands[0]->type->is_float() ||
- ir->operands[0]->type->is_double());
- assert(ir->operands[1]->type->base_type == GLSL_TYPE_INT);
+ assert(ir->operands[0]->type->is_float_16_32_64());
+ assert(ir->operands[1]->type->is_int_16_32());
assert(ir->operands[0]->type->components() ==
ir->operands[1]->type->components());
break;
case ir_binop_vector_extract:
assert(ir->operands[0]->type->is_vector());
assert(ir->operands[1]->type->is_scalar()
- && ir->operands[1]->type->is_integer());
+ && ir->operands[1]->type->is_integer_16_32());
break;
case ir_binop_interpolate_at_offset:
assert(ir->operands[0]->type == ir->type);
- assert(ir->operands[0]->type->is_float());
+ assert(ir->operands[0]->type->is_float_16_32());
assert(ir->operands[1]->type->components() == 2);
- assert(ir->operands[1]->type->is_float());
+ assert(ir->operands[1]->type->is_float_16_32());
break;
case ir_binop_interpolate_at_sample:
assert(ir->operands[0]->type == ir->type);
- assert(ir->operands[0]->type->is_float());
- assert(ir->operands[1]->type == glsl_type::int_type);
+ assert(ir->operands[0]->type->is_float_16_32());
+ assert(ir->operands[1]->type == glsl_type::int_type ||
+ ir->operands[1]->type == glsl_type::int16_t_type);
+ break;
+
+ case ir_binop_atan2:
+ assert(ir->operands[0]->type->is_float_16_32_64());
+ assert(ir->operands[1]->type == ir->operands[0]->type);
+ assert(ir->type == ir->operands[0]->type);
break;
case ir_triop_fma:
- assert(ir->type->is_float() ||
- ir->type->is_double());
+ assert(ir->type->is_float_16_32_64());
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->is_float() ||
- ir->operands[0]->type->is_double());
+ assert(ir->operands[0]->type->is_float_16_32_64());
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 ||
- ir->operands[2]->type == glsl_type::double_type);
+ ir->operands[2]->type == glsl_type::double_type ||
+ ir->operands[2]->type == glsl_type::float16_t_type);
break;
case ir_triop_csel:
break;
case ir_triop_bitfield_extract:
- assert(ir->type->is_integer());
+ assert(ir->type->is_integer_16_32());
assert(ir->operands[0]->type == ir->type);
assert(ir->operands[1]->type == ir->type);
assert(ir->operands[2]->type == ir->type);
assert(ir->operands[1]->type->is_scalar());
assert(ir->operands[0]->type->base_type == ir->operands[1]->type->base_type);
assert(ir->operands[2]->type->is_scalar()
- && ir->operands[2]->type->is_integer());
+ && ir->operands[2]->type->is_integer_16_32());
assert(ir->type == ir->operands[0]->type);
break;
case ir_quadop_bitfield_insert:
- assert(ir->type->is_integer());
+ assert(ir->type->is_integer_16_32());
assert(ir->operands[0]->type == ir->type);
assert(ir->operands[1]->type == ir->type);
assert(ir->operands[2]->type == ir->type);
_mesa_set_add(ir_set, ir);
}
+#ifdef DEBUG
static void
check_node_type(ir_instruction *ir, void *data)
{
if (value != NULL)
assert(value->type != glsl_type::error_type);
}
+#endif
void
validate_ir_tree(exec_list *instructions)