glsl/types: Rename is_integer to is_integer_32

It only accepts 32-bit integers so it should have a more descriptive
name.  This patch should not be a functional change.

Reviewed-by: Karol Herbst <kherbst@redhat.com>
This commit is contained in:
Jason Ekstrand 2019-06-06 11:37:32 -05:00
parent 21a7e6d569
commit f0920e266c
14 changed files with 33 additions and 32 deletions

View File

@ -155,7 +155,7 @@ _mesa_ast_array_index_to_hir(void *mem_ctx,
}
if (!idx->type->is_error()) {
if (!idx->type->is_integer()) {
if (!idx->type->is_integer_32()) {
_mesa_glsl_error(& idx_loc, state, "array index must be integer type");
} else if (!idx->type->is_scalar()) {
_mesa_glsl_error(& idx_loc, state, "array index must be scalar");
@ -168,7 +168,7 @@ _mesa_ast_array_index_to_hir(void *mem_ctx,
* declared size.
*/
ir_constant *const const_index = idx->constant_expression_value(mem_ctx);
if (const_index != NULL && idx->type->is_integer()) {
if (const_index != NULL && idx->type->is_integer_32()) {
const int idx = const_index->value.i[0];
const char *type_name = "error";
unsigned bound = 0;

View File

@ -747,7 +747,7 @@ shift_result_type(const struct glsl_type *type_a,
return glsl_type::error_type;
}
if (!type_b->is_integer()) {
if (!type_b->is_integer_32()) {
_mesa_glsl_error(loc, state, "RHS of operator %s must be an integer or "
"integer vector", ast_expression::operator_string(op));
return glsl_type::error_type;
@ -2289,7 +2289,7 @@ process_array_size(exec_node *node,
return 0;
}
if (!ir->type->is_integer()) {
if (!ir->type->is_integer_32()) {
_mesa_glsl_error(& loc, state,
"array size must be integer type");
return 0;
@ -2389,7 +2389,7 @@ precision_qualifier_allowed(const glsl_type *type)
*/
const glsl_type *const t = type->without_array();
return (t->is_float() || t->is_integer() || t->contains_opaque()) &&
return (t->is_float() || t->is_integer_32() || t->contains_opaque()) &&
!t->is_struct();
}
@ -6502,7 +6502,7 @@ ast_switch_statement::hir(exec_list *instructions,
* scalar integer."
*/
if (!test_expression->type->is_scalar() ||
!test_expression->type->is_integer()) {
!test_expression->type->is_integer_32()) {
YYLTYPE loc = this->test_expression->get_location();
_mesa_glsl_error(& loc,
@ -6821,7 +6821,7 @@ ast_case_label::hir(exec_list *instructions,
glsl_type::int_type->can_implicitly_convert_to(glsl_type::uint_type,
state);
if ((!type_a->is_integer() || !type_b->is_integer()) ||
if ((!type_a->is_integer_32() || !type_b->is_integer_32()) ||
!integer_conversion_supported) {
_mesa_glsl_error(&loc, state, "type mismatch with switch "
"init-expression and case label (%s != %s)",

View File

@ -931,7 +931,7 @@ ast_layout_expression::process_qualifier_constant(struct _mesa_glsl_parse_state
ir_constant *const const_int =
ir->constant_expression_value(ralloc_parent(ir));
if (const_int == NULL || !const_int->type->is_integer()) {
if (const_int == NULL || !const_int->type->is_integer_32()) {
YYLTYPE loc = const_expression->get_location();
_mesa_glsl_error(&loc, state, "%s must be an integral constant "
"expression", qual_indentifier);
@ -987,7 +987,7 @@ process_qualifier_constant(struct _mesa_glsl_parse_state *state,
ir_constant *const const_int =
ir->constant_expression_value(ralloc_parent(ir));
if (const_int == NULL || !const_int->type->is_integer()) {
if (const_int == NULL || !const_int->type->is_integer_32()) {
_mesa_glsl_error(loc, state, "%s must be an integral constant "
"expression", qual_indentifier);
return false;

View File

@ -1358,7 +1358,7 @@ ir_constant::is_negative_one() const
bool
ir_constant::is_uint16_constant() const
{
if (!type->is_integer())
if (!type->is_integer_32())
return false;
return value.u[0] < (1 << 16);

View File

@ -435,7 +435,8 @@ constant_referenced(const ir_dereference *deref,
ir_constant *const index_c =
da->array_index->constant_expression_value(variable_context);
if (!index_c || !index_c->type->is_scalar() || !index_c->type->is_integer())
if (!index_c || !index_c->type->is_scalar() ||
!index_c->type->is_integer_32())
break;
const int index = index_c->type->base_type == GLSL_TYPE_INT ?

View File

@ -126,7 +126,7 @@ ir_validate::visit_enter(class ir_dereference_array *ir)
abort();
}
if (!ir->array_index->type->is_integer()) {
if (!ir->array_index->type->is_integer_32()) {
printf("ir_dereference_array @ %p does not have integer index: %s\n",
(void *) ir, ir->array_index->type->name);
abort();
@ -535,14 +535,14 @@ ir_validate::visit_leave(ir_expression *ir)
case ir_unop_bitfield_reverse:
assert(ir->operands[0]->type == ir->type);
assert(ir->type->is_integer());
assert(ir->type->is_integer_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->operands[0]->type->is_integer_32());
assert(ir->type->base_type == GLSL_TYPE_INT);
break;
@ -646,7 +646,7 @@ ir_validate::visit_leave(ir_expression *ir)
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:
@ -685,7 +685,7 @@ ir_validate::visit_leave(ir_expression *ir)
case ir_binop_lshift:
case ir_binop_rshift:
assert(ir->operands[0]->type->is_integer_32_64() &&
ir->operands[1]->type->is_integer());
ir->operands[1]->type->is_integer_32());
if (ir->operands[0]->type->is_scalar()) {
assert(ir->operands[1]->type->is_scalar());
}
@ -745,7 +745,7 @@ ir_validate::visit_leave(ir_expression *ir)
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_32());
break;
case ir_binop_interpolate_at_offset:
@ -786,7 +786,7 @@ ir_validate::visit_leave(ir_expression *ir)
break;
case ir_triop_bitfield_extract:
assert(ir->type->is_integer());
assert(ir->type->is_integer_32());
assert(ir->operands[0]->type == ir->type);
assert(ir->operands[1]->type == ir->type);
assert(ir->operands[2]->type == ir->type);
@ -797,12 +797,12 @@ ir_validate::visit_leave(ir_expression *ir)
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_32());
assert(ir->type == ir->operands[0]->type);
break;
case ir_quadop_bitfield_insert:
assert(ir->type->is_integer());
assert(ir->type->is_integer_32());
assert(ir->operands[0]->type == ir->type);
assert(ir->operands[1]->type == ir->type);
assert(ir->operands[2]->type == ir->type);

View File

@ -107,7 +107,7 @@ calculate_iterations(ir_rvalue *from, ir_rvalue *to, ir_rvalue *increment,
return -1;
}
if (!iter->type->is_integer()) {
if (!iter->type->is_integer_32()) {
const ir_expression_operation op = iter->type->is_double()
? ir_unop_d2i : ir_unop_f2i;
ir_rvalue *cast =

View File

@ -222,7 +222,7 @@ lower_instructions_visitor::div_to_mul_rcp(ir_expression *ir)
void
lower_instructions_visitor::int_div_to_mul_rcp(ir_expression *ir)
{
assert(ir->operands[1]->type->is_integer());
assert(ir->operands[1]->type->is_integer_32());
/* Be careful with integer division -- we need to do it as a
* float and re-truncate, since rcp(n > 1) of an integer would
@ -1745,7 +1745,7 @@ lower_instructions_visitor::visit_leave(ir_expression *ir)
break;
case ir_binop_div:
if (ir->operands[1]->type->is_integer() && lowering(INT_DIV_TO_MUL_RCP))
if (ir->operands[1]->type->is_integer_32() && lowering(INT_DIV_TO_MUL_RCP))
int_div_to_mul_rcp(ir);
else if ((ir->operands[1]->type->is_float() && lowering(FDIV_TO_MUL_RCP)) ||
(ir->operands[1]->type->is_double() && lowering(DDIV_TO_MUL_RCP)))

View File

@ -354,7 +354,7 @@ lower_shared_reference_visitor::lower_shared_atomic_intrinsic(ir_call *ir)
ir_rvalue *deref = (ir_rvalue *) inst;
assert(deref->type->is_scalar() &&
(deref->type->is_integer() || deref->type->is_float()));
(deref->type->is_integer_32() || deref->type->is_float()));
ir_variable *var = deref->variable_referenced();
assert(var);

View File

@ -971,7 +971,7 @@ lower_ubo_reference_visitor::lower_ssbo_atomic_intrinsic(ir_call *ir)
ir_rvalue *deref = (ir_rvalue *) inst;
assert(deref->type->is_scalar() &&
(deref->type->is_integer() || deref->type->is_float()));
(deref->type->is_integer_32() || deref->type->is_float()));
ir_variable *var = deref->variable_referenced();
assert(var);

View File

@ -280,7 +280,7 @@ struct switch_generator
{
unsigned middle = (begin + end) >> 1;
assert(index->type->is_integer());
assert(index->type->is_integer_32());
ir_constant *const middle_c = (index->type->base_type == GLSL_TYPE_UINT)
? new(body.mem_ctx) ir_constant((unsigned)middle)

View File

@ -1633,7 +1633,7 @@ glsl_type::can_implicitly_convert_to(const glsl_type *desired,
return false;
/* int and uint can be converted to float. */
if (desired->is_float() && this->is_integer())
if (desired->is_float() && this->is_integer_32())
return true;
/* With GLSL 4.0, ARB_gpu_shader5, or MESA_shader_integer_functions, int
@ -1654,7 +1654,7 @@ glsl_type::can_implicitly_convert_to(const glsl_type *desired,
if ((!state || state->has_double()) && desired->is_double()) {
if (this->is_float())
return true;
if (this->is_integer())
if (this->is_integer_32())
return true;
}

View File

@ -586,9 +586,9 @@ public:
}
/**
* Query whether or not a type is an integral type
* Query whether or not a type is an 32-bit integer.
*/
bool is_integer() const
bool is_integer_32() const
{
return (base_type == GLSL_TYPE_UINT) || (base_type == GLSL_TYPE_INT);
}
@ -606,7 +606,7 @@ public:
*/
bool is_integer_32_64() const
{
return is_integer() || is_integer_64();
return is_integer_32() || is_integer_64();
}
/**

View File

@ -1128,7 +1128,7 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
break;
case ir_binop_mod:
/* Floating point should be lowered by MOD_TO_FLOOR in the compiler. */
assert(ir->type->is_integer());
assert(ir->type->is_integer_32());
emit(ir, OPCODE_MUL, result_dst, op[0], op[1]);
break;