From f0920e266c152044cb05892f3aea5a17a163cc02 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Thu, 6 Jun 2019 11:37:32 -0500 Subject: [PATCH] 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 --- src/compiler/glsl/ast_array_index.cpp | 4 ++-- src/compiler/glsl/ast_to_hir.cpp | 10 +++++----- src/compiler/glsl/ast_type.cpp | 4 ++-- src/compiler/glsl/ir.cpp | 2 +- src/compiler/glsl/ir_constant_expression.cpp | 3 ++- src/compiler/glsl/ir_validate.cpp | 18 +++++++++--------- src/compiler/glsl/loop_analysis.cpp | 2 +- src/compiler/glsl/lower_instructions.cpp | 4 ++-- src/compiler/glsl/lower_shared_reference.cpp | 2 +- src/compiler/glsl/lower_ubo_reference.cpp | 2 +- .../lower_variable_index_to_cond_assign.cpp | 2 +- src/compiler/glsl_types.cpp | 4 ++-- src/compiler/glsl_types.h | 6 +++--- src/mesa/program/ir_to_mesa.cpp | 2 +- 14 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/compiler/glsl/ast_array_index.cpp b/src/compiler/glsl/ast_array_index.cpp index 3b30f6858e0..ea305b54701 100644 --- a/src/compiler/glsl/ast_array_index.cpp +++ b/src/compiler/glsl/ast_array_index.cpp @@ -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; diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp index 26f72fc0925..9cd67ab7885 100644 --- a/src/compiler/glsl/ast_to_hir.cpp +++ b/src/compiler/glsl/ast_to_hir.cpp @@ -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)", diff --git a/src/compiler/glsl/ast_type.cpp b/src/compiler/glsl/ast_type.cpp index c7f74e7aa08..ebb224e121f 100644 --- a/src/compiler/glsl/ast_type.cpp +++ b/src/compiler/glsl/ast_type.cpp @@ -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; diff --git a/src/compiler/glsl/ir.cpp b/src/compiler/glsl/ir.cpp index 6b455cdf510..4263f1fa911 100644 --- a/src/compiler/glsl/ir.cpp +++ b/src/compiler/glsl/ir.cpp @@ -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); diff --git a/src/compiler/glsl/ir_constant_expression.cpp b/src/compiler/glsl/ir_constant_expression.cpp index cb8558eb00d..e5893103ed2 100644 --- a/src/compiler/glsl/ir_constant_expression.cpp +++ b/src/compiler/glsl/ir_constant_expression.cpp @@ -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 ? diff --git a/src/compiler/glsl/ir_validate.cpp b/src/compiler/glsl/ir_validate.cpp index 18d27cbf6b1..33c262c8948 100644 --- a/src/compiler/glsl/ir_validate.cpp +++ b/src/compiler/glsl/ir_validate.cpp @@ -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); diff --git a/src/compiler/glsl/loop_analysis.cpp b/src/compiler/glsl/loop_analysis.cpp index 4041a0f66ec..aae8fc62cd0 100644 --- a/src/compiler/glsl/loop_analysis.cpp +++ b/src/compiler/glsl/loop_analysis.cpp @@ -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 = diff --git a/src/compiler/glsl/lower_instructions.cpp b/src/compiler/glsl/lower_instructions.cpp index 8e0c8744048..f5cf24b86e2 100644 --- a/src/compiler/glsl/lower_instructions.cpp +++ b/src/compiler/glsl/lower_instructions.cpp @@ -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))) diff --git a/src/compiler/glsl/lower_shared_reference.cpp b/src/compiler/glsl/lower_shared_reference.cpp index 5954ccce445..fb6af0c088f 100644 --- a/src/compiler/glsl/lower_shared_reference.cpp +++ b/src/compiler/glsl/lower_shared_reference.cpp @@ -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); diff --git a/src/compiler/glsl/lower_ubo_reference.cpp b/src/compiler/glsl/lower_ubo_reference.cpp index 5fc936007e8..08d4f72efa0 100644 --- a/src/compiler/glsl/lower_ubo_reference.cpp +++ b/src/compiler/glsl/lower_ubo_reference.cpp @@ -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); diff --git a/src/compiler/glsl/lower_variable_index_to_cond_assign.cpp b/src/compiler/glsl/lower_variable_index_to_cond_assign.cpp index 6fe4fe62b59..c22789c39e3 100644 --- a/src/compiler/glsl/lower_variable_index_to_cond_assign.cpp +++ b/src/compiler/glsl/lower_variable_index_to_cond_assign.cpp @@ -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) diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp index b47e126e950..2e84d6ea72c 100644 --- a/src/compiler/glsl_types.cpp +++ b/src/compiler/glsl_types.cpp @@ -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; } diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h index 23d2ee00fdf..693b0371151 100644 --- a/src/compiler/glsl_types.h +++ b/src/compiler/glsl_types.h @@ -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(); } /** diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 005b855230b..053912a8410 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -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; -- 2.30.2