diff --git a/src/inspector/inspector.cc b/src/inspector/inspector.cc index 0e64db75c4..dd2bdb2d6c 100644 --- a/src/inspector/inspector.cc +++ b/src/inspector/inspector.cc @@ -66,33 +66,33 @@ std::tuple CalculateComponentAndComposition( return {ComponentType::kFloat, CompositionType::kScalar}; } else if (type->is_float_vector()) { auto* vec = type->As(); - if (vec->size() == 2) { + if (vec->Width() == 2) { return {ComponentType::kFloat, CompositionType::kVec2}; - } else if (vec->size() == 3) { + } else if (vec->Width() == 3) { return {ComponentType::kFloat, CompositionType::kVec3}; - } else if (vec->size() == 4) { + } else if (vec->Width() == 4) { return {ComponentType::kFloat, CompositionType::kVec4}; } } else if (type->is_unsigned_integer_scalar()) { return {ComponentType::kUInt, CompositionType::kScalar}; } else if (type->is_unsigned_integer_vector()) { auto* vec = type->As(); - if (vec->size() == 2) { + if (vec->Width() == 2) { return {ComponentType::kUInt, CompositionType::kVec2}; - } else if (vec->size() == 3) { + } else if (vec->Width() == 3) { return {ComponentType::kUInt, CompositionType::kVec3}; - } else if (vec->size() == 4) { + } else if (vec->Width() == 4) { return {ComponentType::kUInt, CompositionType::kVec4}; } } else if (type->is_signed_integer_scalar()) { return {ComponentType::kSInt, CompositionType::kScalar}; } else if (type->is_signed_integer_vector()) { auto* vec = type->As(); - if (vec->size() == 2) { + if (vec->Width() == 2) { return {ComponentType::kSInt, CompositionType::kVec2}; - } else if (vec->size() == 3) { + } else if (vec->Width() == 3) { return {ComponentType::kSInt, CompositionType::kVec3}; - } else if (vec->size() == 4) { + } else if (vec->Width() == 4) { return {ComponentType::kSInt, CompositionType::kVec4}; } } diff --git a/src/intrinsic_table.cc b/src/intrinsic_table.cc index c134f43e88..82c1debc2c 100644 --- a/src/intrinsic_table.cc +++ b/src/intrinsic_table.cc @@ -335,7 +335,7 @@ bool match_vec(const sem::Type* ty, Number& N, const sem::Type*& T) { } if (auto* v = ty->As()) { - N = v->size(); + N = v->Width(); T = v->type(); return true; } @@ -354,7 +354,7 @@ bool match_vec(const sem::Type* ty, const sem::Type*& T) { } if (auto* v = ty->As()) { - if (v->size() == N) { + if (v->Width() == N) { T = v->type(); return true; } @@ -395,7 +395,7 @@ bool match_mat(const sem::Type* ty, Number& M, Number& N, const sem::Type*& T) { } if (auto* m = ty->As()) { M = m->columns(); - N = m->ColumnType()->size(); + N = m->ColumnType()->Width(); T = m->type(); return true; } diff --git a/src/resolver/intrinsic_test.cc b/src/resolver/intrinsic_test.cc index d94ed2d830..95c0813dc7 100644 --- a/src/resolver/intrinsic_test.cc +++ b/src/resolver/intrinsic_test.cc @@ -77,7 +77,7 @@ TEST_P(ResolverIntrinsicDerivativeTest, Vector) { ASSERT_NE(TypeOf(expr), nullptr); ASSERT_TRUE(TypeOf(expr)->Is()); EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); - EXPECT_EQ(TypeOf(expr)->As()->size(), 4u); + EXPECT_EQ(TypeOf(expr)->As()->Width(), 4u); } TEST_P(ResolverIntrinsicDerivativeTest, MissingParam) { @@ -139,7 +139,7 @@ TEST_P(ResolverIntrinsicTest_FloatMethod, Vector) { ASSERT_NE(TypeOf(expr), nullptr); ASSERT_TRUE(TypeOf(expr)->Is()); EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); - EXPECT_EQ(TypeOf(expr)->As()->size(), 3u); + EXPECT_EQ(TypeOf(expr)->As()->Width(), 3u); } TEST_P(ResolverIntrinsicTest_FloatMethod, Scalar) { @@ -301,7 +301,7 @@ TEST_P(ResolverIntrinsicTest_StorageTextureOperation, TextureLoadRo) { } else { EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); } - EXPECT_EQ(TypeOf(expr)->As()->size(), 4u); + EXPECT_EQ(TypeOf(expr)->As()->Width(), 4u); } INSTANTIATE_TEST_SUITE_P( @@ -366,7 +366,7 @@ TEST_P(ResolverIntrinsicTest_SampledTextureOperation, TextureLoadSampled) { } else { EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); } - EXPECT_EQ(TypeOf(expr)->As()->size(), 4u); + EXPECT_EQ(TypeOf(expr)->As()->Width(), 4u); } INSTANTIATE_TEST_SUITE_P( @@ -455,7 +455,7 @@ TEST_F(ResolverIntrinsicTest, Select) { ASSERT_NE(TypeOf(expr), nullptr); EXPECT_TRUE(TypeOf(expr)->Is()); - EXPECT_EQ(TypeOf(expr)->As()->size(), 3u); + EXPECT_EQ(TypeOf(expr)->As()->Width(), 3u); EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); } @@ -668,9 +668,9 @@ TEST_P(ResolverIntrinsicTest_DataUnpacking, InferType) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_float_vector()); if (pack4) { - EXPECT_EQ(TypeOf(call)->As()->size(), 4u); + EXPECT_EQ(TypeOf(call)->As()->Width(), 4u); } else { - EXPECT_EQ(TypeOf(call)->As()->size(), 2u); + EXPECT_EQ(TypeOf(call)->As()->Width(), 2u); } } @@ -707,7 +707,7 @@ TEST_P(ResolverIntrinsicTest_SingleParam, Vector) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_float_vector()); - EXPECT_EQ(TypeOf(call)->As()->size(), 3u); + EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); } TEST_P(ResolverIntrinsicTest_SingleParam, Error_NoParams) { @@ -812,7 +812,7 @@ TEST_F(ResolverIntrinsicDataTest, Normalize_Vector) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_float_vector()); - EXPECT_EQ(TypeOf(call)->As()->size(), 3u); + EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); } TEST_F(ResolverIntrinsicDataTest, Normalize_Error_NoParams) { @@ -1028,7 +1028,7 @@ TEST_P(ResolverIntrinsicTest_SingleParam_FloatOrInt, Float_Vector) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_float_vector()); - EXPECT_EQ(TypeOf(call)->As()->size(), 3u); + EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); } TEST_P(ResolverIntrinsicTest_SingleParam_FloatOrInt, Sint_Scalar) { @@ -1053,7 +1053,7 @@ TEST_P(ResolverIntrinsicTest_SingleParam_FloatOrInt, Sint_Vector) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_signed_integer_vector()); - EXPECT_EQ(TypeOf(call)->As()->size(), 3u); + EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); } TEST_P(ResolverIntrinsicTest_SingleParam_FloatOrInt, Uint_Scalar) { @@ -1078,7 +1078,7 @@ TEST_P(ResolverIntrinsicTest_SingleParam_FloatOrInt, Uint_Vector) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_unsigned_integer_vector()); - EXPECT_EQ(TypeOf(call)->As()->size(), 3u); + EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); } TEST_P(ResolverIntrinsicTest_SingleParam_FloatOrInt, Error_NoParams) { @@ -1148,7 +1148,7 @@ TEST_P(ResolverIntrinsicTest_TwoParam, Vector) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_float_vector()); - EXPECT_EQ(TypeOf(call)->As()->size(), 3u); + EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); } TEST_P(ResolverIntrinsicTest_TwoParam, Error_NoTooManyParams) { @@ -1222,7 +1222,7 @@ TEST_F(ResolverIntrinsicTest, Cross) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_float_vector()); - EXPECT_EQ(TypeOf(call)->As()->size(), 3u); + EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); } TEST_F(ResolverIntrinsicTest, Cross_Error_NoArgs) { @@ -1304,7 +1304,7 @@ TEST_F(ResolverIntrinsicTest, Normalize) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_float_vector()); - EXPECT_EQ(TypeOf(call)->As()->size(), 3u); + EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); } TEST_F(ResolverIntrinsicTest, Normalize_NoArgs) { @@ -1344,7 +1344,7 @@ TEST_P(ResolverIntrinsicTest_ThreeParam, Vector) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_float_vector()); - EXPECT_EQ(TypeOf(call)->As()->size(), 3u); + EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); } TEST_P(ResolverIntrinsicTest_ThreeParam, Error_NoParams) { auto param = GetParam(); @@ -1395,7 +1395,7 @@ TEST_P(ResolverIntrinsicTest_ThreeParam_FloatOrInt, Float_Vector) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_float_vector()); - EXPECT_EQ(TypeOf(call)->As()->size(), 3u); + EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); } TEST_P(ResolverIntrinsicTest_ThreeParam_FloatOrInt, Sint_Scalar) { @@ -1421,7 +1421,7 @@ TEST_P(ResolverIntrinsicTest_ThreeParam_FloatOrInt, Sint_Vector) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_signed_integer_vector()); - EXPECT_EQ(TypeOf(call)->As()->size(), 3u); + EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); } TEST_P(ResolverIntrinsicTest_ThreeParam_FloatOrInt, Uint_Scalar) { @@ -1447,7 +1447,7 @@ TEST_P(ResolverIntrinsicTest_ThreeParam_FloatOrInt, Uint_Vector) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_unsigned_integer_vector()); - EXPECT_EQ(TypeOf(call)->As()->size(), 3u); + EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); } TEST_P(ResolverIntrinsicTest_ThreeParam_FloatOrInt, Error_NoParams) { @@ -1498,7 +1498,7 @@ TEST_P(ResolverIntrinsicTest_Int_SingleParam, Vector) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_signed_integer_vector()); - EXPECT_EQ(TypeOf(call)->As()->size(), 3u); + EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); } TEST_P(ResolverIntrinsicTest_Int_SingleParam, Error_NoParams) { @@ -1573,7 +1573,7 @@ TEST_P(ResolverIntrinsicTest_FloatOrInt_TwoParam, Vector_Signed) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_signed_integer_vector()); - EXPECT_EQ(TypeOf(call)->As()->size(), 3u); + EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); } TEST_P(ResolverIntrinsicTest_FloatOrInt_TwoParam, Vector_Unsigned) { @@ -1586,7 +1586,7 @@ TEST_P(ResolverIntrinsicTest_FloatOrInt_TwoParam, Vector_Unsigned) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_unsigned_integer_vector()); - EXPECT_EQ(TypeOf(call)->As()->size(), 3u); + EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); } TEST_P(ResolverIntrinsicTest_FloatOrInt_TwoParam, Vector_Float) { @@ -1600,7 +1600,7 @@ TEST_P(ResolverIntrinsicTest_FloatOrInt_TwoParam, Vector_Float) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_float_vector()); - EXPECT_EQ(TypeOf(call)->As()->size(), 3u); + EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); } TEST_P(ResolverIntrinsicTest_FloatOrInt_TwoParam, Error_NoParams) { @@ -1977,14 +1977,14 @@ TEST_P(ResolverIntrinsicTest_Texture, Call) { case ast::TextureDimension::kCubeArray: { auto* vec = As(TypeOf(call)); ASSERT_NE(vec, nullptr); - EXPECT_EQ(vec->size(), 2u); + EXPECT_EQ(vec->Width(), 2u); EXPECT_TRUE(vec->type()->Is()); break; } case ast::TextureDimension::k3d: { auto* vec = As(TypeOf(call)); ASSERT_NE(vec, nullptr); - EXPECT_EQ(vec->size(), 3u); + EXPECT_EQ(vec->Width(), 3u); EXPECT_TRUE(vec->type()->Is()); break; } diff --git a/src/resolver/resolver.cc b/src/resolver/resolver.cc index 2904df81e3..93012fdba2 100644 --- a/src/resolver/resolver.cc +++ b/src/resolver/resolver.cc @@ -1218,7 +1218,7 @@ bool Resolver::ValidateBuiltinDecoration(const ast::BuiltinDecoration* deco, stage_name.str() + " pipeline stage", deco->source()); } - if (!(type->is_float_vector() && type->As()->size() == 4)) { + if (!(type->is_float_vector() && type->As()->Width() == 4)) { AddError("store type of " + deco_to_str(deco) + " must be 'vec4'", deco->source()); return false; @@ -1232,7 +1232,7 @@ bool Resolver::ValidateBuiltinDecoration(const ast::BuiltinDecoration* deco, is_stage_mismatch = true; } if (!(type->is_unsigned_integer_vector() && - type->As()->size() == 3)) { + type->As()->Width() == 3)) { AddError("store type of " + deco_to_str(deco) + " must be 'vec3'", deco->source()); return false; @@ -2794,7 +2794,7 @@ bool Resolver::ValidateVectorConstructor( return false; } - value_cardinality_sum += value_vec->size(); + value_cardinality_sum += value_vec->Width(); } else { // A vector constructor can only accept vectors and scalars. AddError("expected vector or scalar type in vector constructor; found: " + @@ -2807,7 +2807,7 @@ bool Resolver::ValidateVectorConstructor( // A correct vector constructor must either be a zero-value expression, // a single-value initializer (splat) expression, or the number of components // of all constructor arguments must add up to the vector cardinality. - if (value_cardinality_sum > 1 && value_cardinality_sum != vec_type->size()) { + if (value_cardinality_sum > 1 && value_cardinality_sum != vec_type->Width()) { if (values.empty()) { TINT_ICE(Resolver, diagnostics_) << "constructor arguments expected to be non-empty!"; @@ -2869,7 +2869,7 @@ bool Resolver::ValidateMatrixConstructor( auto* value_type = TypeOf(value)->UnwrapRef(); auto* value_vec = value_type->As(); - if (!value_vec || value_vec->size() != matrix_type->rows() || + if (!value_vec || value_vec->Width() != matrix_type->rows() || elem_type != value_vec->type()) { AddError("expected argument type '" + VectorPretty(matrix_type->rows(), elem_type) + "' in '" + @@ -3050,7 +3050,7 @@ bool Resolver::MemberAccessor(ast::MemberAccessorExpression* expr) { return false; } - if (swizzle.back() >= vec->size()) { + if (swizzle.back() >= vec->Width()) { AddError("invalid vector swizzle member", expr->member()->source()); return false; } @@ -3130,7 +3130,7 @@ bool Resolver::Binary(ast::BinaryExpression* expr) { const bool matching_vec_elem_types = lhs_vec_elem_type && rhs_vec_elem_type && (lhs_vec_elem_type == rhs_vec_elem_type) && - (lhs_vec->size() == rhs_vec->size()); + (lhs_vec->Width() == rhs_vec->Width()); const bool matching_types = matching_vec_elem_types || (lhs_type == rhs_type); @@ -3222,7 +3222,7 @@ bool Resolver::Binary(ast::BinaryExpression* expr) { // Vector times matrix if (lhs_vec_elem_type && lhs_vec_elem_type->Is() && rhs_mat_elem_type && rhs_mat_elem_type->Is() && - (lhs_vec->size() == rhs_mat->rows())) { + (lhs_vec->Width() == rhs_mat->rows())) { SetExprInfo(expr, builder_->create(lhs_vec->type(), rhs_mat->columns())); return true; @@ -3231,7 +3231,7 @@ bool Resolver::Binary(ast::BinaryExpression* expr) { // Matrix times vector if (lhs_mat_elem_type && lhs_mat_elem_type->Is() && rhs_vec_elem_type && rhs_vec_elem_type->Is() && - (lhs_mat->columns() == rhs_vec->size())) { + (lhs_mat->columns() == rhs_vec->Width())) { SetExprInfo(expr, builder_->create(rhs_vec->type(), lhs_mat->rows())); return true; @@ -3270,13 +3270,13 @@ bool Resolver::Binary(ast::BinaryExpression* expr) { if (lhs_vec_elem_type->Is() && (expr->IsEqual() || expr->IsNotEqual())) { SetExprInfo(expr, builder_->create( - builder_->create(), lhs_vec->size())); + builder_->create(), lhs_vec->Width())); return true; } if (lhs_vec_elem_type->is_numeric_scalar()) { SetExprInfo(expr, builder_->create( - builder_->create(), lhs_vec->size())); + builder_->create(), lhs_vec->Width())); return true; } } diff --git a/src/resolver/resolver_constants.cc b/src/resolver/resolver_constants.cc index 45de987900..dc453cc1b5 100644 --- a/src/resolver/resolver_constants.cc +++ b/src/resolver/resolver_constants.cc @@ -109,7 +109,7 @@ sem::Constant Resolver::EvaluateConstantValue( } auto* elem_type = vec ? vec->type() : type; - int result_size = vec ? static_cast(vec->size()) : 1; + int result_size = vec ? static_cast(vec->Width()) : 1; // For zero value init, return 0s if (ctor_values.empty()) { diff --git a/src/resolver/resolver_constants_test.cc b/src/resolver/resolver_constants_test.cc index 198cd3b3b5..512459d3fd 100644 --- a/src/resolver/resolver_constants_test.cc +++ b/src/resolver/resolver_constants_test.cc @@ -96,7 +96,7 @@ TEST_F(ResolverConstantsTest, Vec3_ZeroInit_i32) { EXPECT_NE(sem, nullptr); ASSERT_TRUE(sem->Type()->Is()); EXPECT_TRUE(sem->Type()->As()->type()->Is()); - EXPECT_EQ(sem->Type()->As()->size(), 3u); + EXPECT_EQ(sem->Type()->As()->Width(), 3u); EXPECT_EQ(sem->ConstantValue().Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue().ElementType()->Is()); ASSERT_EQ(sem->ConstantValue().Elements().size(), 3u); @@ -115,7 +115,7 @@ TEST_F(ResolverConstantsTest, Vec3_ZeroInit_u32) { EXPECT_NE(sem, nullptr); ASSERT_TRUE(sem->Type()->Is()); EXPECT_TRUE(sem->Type()->As()->type()->Is()); - EXPECT_EQ(sem->Type()->As()->size(), 3u); + EXPECT_EQ(sem->Type()->As()->Width(), 3u); EXPECT_EQ(sem->ConstantValue().Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue().ElementType()->Is()); ASSERT_EQ(sem->ConstantValue().Elements().size(), 3u); @@ -134,7 +134,7 @@ TEST_F(ResolverConstantsTest, Vec3_ZeroInit_f32) { EXPECT_NE(sem, nullptr); ASSERT_TRUE(sem->Type()->Is()); EXPECT_TRUE(sem->Type()->As()->type()->Is()); - EXPECT_EQ(sem->Type()->As()->size(), 3u); + EXPECT_EQ(sem->Type()->As()->Width(), 3u); EXPECT_EQ(sem->ConstantValue().Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue().ElementType()->Is()); ASSERT_EQ(sem->ConstantValue().Elements().size(), 3u); @@ -153,7 +153,7 @@ TEST_F(ResolverConstantsTest, Vec3_ZeroInit_bool) { EXPECT_NE(sem, nullptr); ASSERT_TRUE(sem->Type()->Is()); EXPECT_TRUE(sem->Type()->As()->type()->Is()); - EXPECT_EQ(sem->Type()->As()->size(), 3u); + EXPECT_EQ(sem->Type()->As()->Width(), 3u); EXPECT_EQ(sem->ConstantValue().Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue().ElementType()->Is()); ASSERT_EQ(sem->ConstantValue().Elements().size(), 3u); @@ -172,7 +172,7 @@ TEST_F(ResolverConstantsTest, Vec3_Splat_i32) { EXPECT_NE(sem, nullptr); ASSERT_TRUE(sem->Type()->Is()); EXPECT_TRUE(sem->Type()->As()->type()->Is()); - EXPECT_EQ(sem->Type()->As()->size(), 3u); + EXPECT_EQ(sem->Type()->As()->Width(), 3u); EXPECT_EQ(sem->ConstantValue().Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue().ElementType()->Is()); ASSERT_EQ(sem->ConstantValue().Elements().size(), 3u); @@ -191,7 +191,7 @@ TEST_F(ResolverConstantsTest, Vec3_Splat_u32) { EXPECT_NE(sem, nullptr); ASSERT_TRUE(sem->Type()->Is()); EXPECT_TRUE(sem->Type()->As()->type()->Is()); - EXPECT_EQ(sem->Type()->As()->size(), 3u); + EXPECT_EQ(sem->Type()->As()->Width(), 3u); EXPECT_EQ(sem->ConstantValue().Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue().ElementType()->Is()); ASSERT_EQ(sem->ConstantValue().Elements().size(), 3u); @@ -210,7 +210,7 @@ TEST_F(ResolverConstantsTest, Vec3_Splat_f32) { EXPECT_NE(sem, nullptr); ASSERT_TRUE(sem->Type()->Is()); EXPECT_TRUE(sem->Type()->As()->type()->Is()); - EXPECT_EQ(sem->Type()->As()->size(), 3u); + EXPECT_EQ(sem->Type()->As()->Width(), 3u); EXPECT_EQ(sem->ConstantValue().Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue().ElementType()->Is()); ASSERT_EQ(sem->ConstantValue().Elements().size(), 3u); @@ -229,7 +229,7 @@ TEST_F(ResolverConstantsTest, Vec3_Splat_bool) { EXPECT_NE(sem, nullptr); ASSERT_TRUE(sem->Type()->Is()); EXPECT_TRUE(sem->Type()->As()->type()->Is()); - EXPECT_EQ(sem->Type()->As()->size(), 3u); + EXPECT_EQ(sem->Type()->As()->Width(), 3u); EXPECT_EQ(sem->ConstantValue().Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue().ElementType()->Is()); ASSERT_EQ(sem->ConstantValue().Elements().size(), 3u); @@ -248,7 +248,7 @@ TEST_F(ResolverConstantsTest, Vec3_FullConstruct_i32) { EXPECT_NE(sem, nullptr); ASSERT_TRUE(sem->Type()->Is()); EXPECT_TRUE(sem->Type()->As()->type()->Is()); - EXPECT_EQ(sem->Type()->As()->size(), 3u); + EXPECT_EQ(sem->Type()->As()->Width(), 3u); EXPECT_EQ(sem->ConstantValue().Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue().ElementType()->Is()); ASSERT_EQ(sem->ConstantValue().Elements().size(), 3u); @@ -267,7 +267,7 @@ TEST_F(ResolverConstantsTest, Vec3_FullConstruct_u32) { EXPECT_NE(sem, nullptr); ASSERT_TRUE(sem->Type()->Is()); EXPECT_TRUE(sem->Type()->As()->type()->Is()); - EXPECT_EQ(sem->Type()->As()->size(), 3u); + EXPECT_EQ(sem->Type()->As()->Width(), 3u); EXPECT_EQ(sem->ConstantValue().Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue().ElementType()->Is()); ASSERT_EQ(sem->ConstantValue().Elements().size(), 3u); @@ -286,7 +286,7 @@ TEST_F(ResolverConstantsTest, Vec3_FullConstruct_f32) { EXPECT_NE(sem, nullptr); ASSERT_TRUE(sem->Type()->Is()); EXPECT_TRUE(sem->Type()->As()->type()->Is()); - EXPECT_EQ(sem->Type()->As()->size(), 3u); + EXPECT_EQ(sem->Type()->As()->Width(), 3u); EXPECT_EQ(sem->ConstantValue().Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue().ElementType()->Is()); ASSERT_EQ(sem->ConstantValue().Elements().size(), 3u); @@ -305,7 +305,7 @@ TEST_F(ResolverConstantsTest, Vec3_FullConstruct_bool) { EXPECT_NE(sem, nullptr); ASSERT_TRUE(sem->Type()->Is()); EXPECT_TRUE(sem->Type()->As()->type()->Is()); - EXPECT_EQ(sem->Type()->As()->size(), 3u); + EXPECT_EQ(sem->Type()->As()->Width(), 3u); EXPECT_EQ(sem->ConstantValue().Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue().ElementType()->Is()); ASSERT_EQ(sem->ConstantValue().Elements().size(), 3u); @@ -324,7 +324,7 @@ TEST_F(ResolverConstantsTest, Vec3_MixConstruct_i32) { EXPECT_NE(sem, nullptr); ASSERT_TRUE(sem->Type()->Is()); EXPECT_TRUE(sem->Type()->As()->type()->Is()); - EXPECT_EQ(sem->Type()->As()->size(), 3u); + EXPECT_EQ(sem->Type()->As()->Width(), 3u); EXPECT_EQ(sem->ConstantValue().Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue().ElementType()->Is()); ASSERT_EQ(sem->ConstantValue().Elements().size(), 3u); @@ -343,7 +343,7 @@ TEST_F(ResolverConstantsTest, Vec3_MixConstruct_u32) { EXPECT_NE(sem, nullptr); ASSERT_TRUE(sem->Type()->Is()); EXPECT_TRUE(sem->Type()->As()->type()->Is()); - EXPECT_EQ(sem->Type()->As()->size(), 3u); + EXPECT_EQ(sem->Type()->As()->Width(), 3u); EXPECT_EQ(sem->ConstantValue().Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue().ElementType()->Is()); ASSERT_EQ(sem->ConstantValue().Elements().size(), 3u); @@ -362,7 +362,7 @@ TEST_F(ResolverConstantsTest, Vec3_MixConstruct_f32) { EXPECT_NE(sem, nullptr); ASSERT_TRUE(sem->Type()->Is()); EXPECT_TRUE(sem->Type()->As()->type()->Is()); - EXPECT_EQ(sem->Type()->As()->size(), 3u); + EXPECT_EQ(sem->Type()->As()->Width(), 3u); EXPECT_EQ(sem->ConstantValue().Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue().ElementType()->Is()); ASSERT_EQ(sem->ConstantValue().Elements().size(), 3u); @@ -381,7 +381,7 @@ TEST_F(ResolverConstantsTest, Vec3_MixConstruct_bool) { EXPECT_NE(sem, nullptr); ASSERT_TRUE(sem->Type()->Is()); EXPECT_TRUE(sem->Type()->As()->type()->Is()); - EXPECT_EQ(sem->Type()->As()->size(), 3u); + EXPECT_EQ(sem->Type()->As()->Width(), 3u); EXPECT_EQ(sem->ConstantValue().Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue().ElementType()->Is()); ASSERT_EQ(sem->ConstantValue().Elements().size(), 3u); @@ -400,7 +400,7 @@ TEST_F(ResolverConstantsTest, Vec3_Cast_f32_to_32) { EXPECT_NE(sem, nullptr); ASSERT_TRUE(sem->Type()->Is()); EXPECT_TRUE(sem->Type()->As()->type()->Is()); - EXPECT_EQ(sem->Type()->As()->size(), 3u); + EXPECT_EQ(sem->Type()->As()->Width(), 3u); EXPECT_EQ(sem->ConstantValue().Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue().ElementType()->Is()); ASSERT_EQ(sem->ConstantValue().Elements().size(), 3u); @@ -419,7 +419,7 @@ TEST_F(ResolverConstantsTest, Vec3_Cast_u32_to_f32) { EXPECT_NE(sem, nullptr); ASSERT_TRUE(sem->Type()->Is()); EXPECT_TRUE(sem->Type()->As()->type()->Is()); - EXPECT_EQ(sem->Type()->As()->size(), 3u); + EXPECT_EQ(sem->Type()->As()->Width(), 3u); EXPECT_EQ(sem->ConstantValue().Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue().ElementType()->Is()); ASSERT_EQ(sem->ConstantValue().Elements().size(), 3u); diff --git a/src/resolver/resolver_test.cc b/src/resolver/resolver_test.cc index f176dc190d..ad14dd3d33 100644 --- a/src/resolver/resolver_test.cc +++ b/src/resolver/resolver_test.cc @@ -552,7 +552,7 @@ TEST_F(ResolverTest, Expr_ArrayAccessor_Matrix) { auto* ref = TypeOf(acc)->As(); ASSERT_TRUE(ref->StoreType()->Is()); - EXPECT_EQ(ref->StoreType()->As()->size(), 3u); + EXPECT_EQ(ref->StoreType()->As()->Width(), 3u); } TEST_F(ResolverTest, Expr_ArrayAccessor_Matrix_BothDimensions) { @@ -709,7 +709,7 @@ TEST_F(ResolverTest, Expr_Constructor_Type_Vec2) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 2u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 2u); } TEST_F(ResolverTest, Expr_Constructor_Type_Vec3) { @@ -721,7 +721,7 @@ TEST_F(ResolverTest, Expr_Constructor_Type_Vec3) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 3u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 3u); } TEST_F(ResolverTest, Expr_Constructor_Type_Vec4) { @@ -733,7 +733,7 @@ TEST_F(ResolverTest, Expr_Constructor_Type_Vec4) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } TEST_F(ResolverTest, Expr_Identifier_GlobalVariable) { @@ -1328,7 +1328,7 @@ TEST_F(ResolverTest, Expr_MemberAccessor_VectorSwizzle) { ASSERT_NE(TypeOf(mem), nullptr); ASSERT_TRUE(TypeOf(mem)->Is()); EXPECT_TRUE(TypeOf(mem)->As()->type()->Is()); - EXPECT_EQ(TypeOf(mem)->As()->size(), 4u); + EXPECT_EQ(TypeOf(mem)->As()->Width(), 4u); ASSERT_TRUE(Sem().Get(mem)->Is()); EXPECT_THAT(Sem().Get(mem)->As()->Indices(), ElementsAre(0, 2, 1, 3)); @@ -1381,7 +1381,7 @@ TEST_F(ResolverTest, Expr_Accessor_MultiLevel) { ASSERT_NE(TypeOf(mem), nullptr); ASSERT_TRUE(TypeOf(mem)->Is()); EXPECT_TRUE(TypeOf(mem)->As()->type()->Is()); - EXPECT_EQ(TypeOf(mem)->As()->size(), 2u); + EXPECT_EQ(TypeOf(mem)->As()->Width(), 2u); ASSERT_TRUE(Sem().Get(mem)->Is()); } @@ -1928,7 +1928,7 @@ TEST_P(UnaryOpExpressionTest, Expr_UnaryOp) { } else { EXPECT_TRUE(TypeOf(der)->As()->type()->Is()); } - EXPECT_EQ(TypeOf(der)->As()->size(), 4u); + EXPECT_EQ(TypeOf(der)->As()->Width(), 4u); } INSTANTIATE_TEST_SUITE_P(ResolverTest, UnaryOpExpressionTest, diff --git a/src/resolver/type_constructor_validation_test.cc b/src/resolver/type_constructor_validation_test.cc index 0c275b88fb..a7556fba95 100644 --- a/src/resolver/type_constructor_validation_test.cc +++ b/src/resolver/type_constructor_validation_test.cc @@ -746,7 +746,7 @@ TEST_F(ResolverTypeConstructorValidationTest, ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 2u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 2u); } TEST_F(ResolverTypeConstructorValidationTest, @@ -759,7 +759,7 @@ TEST_F(ResolverTypeConstructorValidationTest, ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 2u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 2u); } TEST_F(ResolverTypeConstructorValidationTest, @@ -772,7 +772,7 @@ TEST_F(ResolverTypeConstructorValidationTest, ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 2u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 2u); } TEST_F(ResolverTypeConstructorValidationTest, @@ -785,7 +785,7 @@ TEST_F(ResolverTypeConstructorValidationTest, ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 2u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 2u); } TEST_F(ResolverTypeConstructorValidationTest, @@ -798,7 +798,7 @@ TEST_F(ResolverTypeConstructorValidationTest, ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 2u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 2u); } TEST_F(ResolverTypeConstructorValidationTest, @@ -811,7 +811,7 @@ TEST_F(ResolverTypeConstructorValidationTest, ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 2u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 2u); } TEST_F(ResolverTypeConstructorValidationTest, @@ -824,7 +824,7 @@ TEST_F(ResolverTypeConstructorValidationTest, ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 2u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 2u); } TEST_F(ResolverTypeConstructorValidationTest, @@ -1002,7 +1002,7 @@ TEST_F(ResolverTypeConstructorValidationTest, ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 3u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 3u); } TEST_F(ResolverTypeConstructorValidationTest, @@ -1015,7 +1015,7 @@ TEST_F(ResolverTypeConstructorValidationTest, ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 3u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 3u); } TEST_F(ResolverTypeConstructorValidationTest, @@ -1028,7 +1028,7 @@ TEST_F(ResolverTypeConstructorValidationTest, ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 3u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 3u); } TEST_F(ResolverTypeConstructorValidationTest, @@ -1041,7 +1041,7 @@ TEST_F(ResolverTypeConstructorValidationTest, ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 3u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 3u); } TEST_F(ResolverTypeConstructorValidationTest, @@ -1054,7 +1054,7 @@ TEST_F(ResolverTypeConstructorValidationTest, ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 3u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 3u); } TEST_F(ResolverTypeConstructorValidationTest, @@ -1067,7 +1067,7 @@ TEST_F(ResolverTypeConstructorValidationTest, ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 3u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 3u); } TEST_F(ResolverTypeConstructorValidationTest, @@ -1080,7 +1080,7 @@ TEST_F(ResolverTypeConstructorValidationTest, ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 3u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 3u); } TEST_F(ResolverTypeConstructorValidationTest, @@ -1093,7 +1093,7 @@ TEST_F(ResolverTypeConstructorValidationTest, ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 3u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 3u); } TEST_F(ResolverTypeConstructorValidationTest, @@ -1106,7 +1106,7 @@ TEST_F(ResolverTypeConstructorValidationTest, ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 3u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 3u); } TEST_F(ResolverTypeConstructorValidationTest, @@ -1352,7 +1352,7 @@ TEST_F(ResolverTypeConstructorValidationTest, ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } TEST_F(ResolverTypeConstructorValidationTest, @@ -1365,7 +1365,7 @@ TEST_F(ResolverTypeConstructorValidationTest, ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } TEST_F(ResolverTypeConstructorValidationTest, @@ -1378,7 +1378,7 @@ TEST_F(ResolverTypeConstructorValidationTest, ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } TEST_F(ResolverTypeConstructorValidationTest, @@ -1391,7 +1391,7 @@ TEST_F(ResolverTypeConstructorValidationTest, ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } TEST_F(ResolverTypeConstructorValidationTest, @@ -1404,7 +1404,7 @@ TEST_F(ResolverTypeConstructorValidationTest, ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } TEST_F(ResolverTypeConstructorValidationTest, @@ -1417,7 +1417,7 @@ TEST_F(ResolverTypeConstructorValidationTest, ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } TEST_F(ResolverTypeConstructorValidationTest, @@ -1430,7 +1430,7 @@ TEST_F(ResolverTypeConstructorValidationTest, ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } TEST_F(ResolverTypeConstructorValidationTest, @@ -1443,7 +1443,7 @@ TEST_F(ResolverTypeConstructorValidationTest, ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } TEST_F(ResolverTypeConstructorValidationTest, @@ -1456,7 +1456,7 @@ TEST_F(ResolverTypeConstructorValidationTest, ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } TEST_F(ResolverTypeConstructorValidationTest, @@ -1469,7 +1469,7 @@ TEST_F(ResolverTypeConstructorValidationTest, ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } TEST_F(ResolverTypeConstructorValidationTest, @@ -1482,7 +1482,7 @@ TEST_F(ResolverTypeConstructorValidationTest, ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } TEST_F(ResolverTypeConstructorValidationTest, @@ -1495,7 +1495,7 @@ TEST_F(ResolverTypeConstructorValidationTest, ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } TEST_F(ResolverTypeConstructorValidationTest, @@ -1508,7 +1508,7 @@ TEST_F(ResolverTypeConstructorValidationTest, ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } TEST_F(ResolverTypeConstructorValidationTest, @@ -1535,7 +1535,7 @@ TEST_F(ResolverTypeConstructorValidationTest, ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); - EXPECT_EQ(TypeOf(tc)->As()->size(), 4u); + EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } TEST_F(ResolverTypeConstructorValidationTest, diff --git a/src/sem/constant.cc b/src/sem/constant.cc index 8c5553b2a7..3b9711bd19 100644 --- a/src/sem/constant.cc +++ b/src/sem/constant.cc @@ -36,7 +36,7 @@ const Type* ElemType(const Type* ty, size_t num_elements) { return ty; } if (auto* vec = ty->As()) { - if (num_elements != vec->size()) { + if (num_elements != vec->Width()) { TINT_ICE(Semantic, diag) << "sem::Constant() type <-> num_element mismatch. type: '" << ty->type_name() << "' num_elements: " << num_elements; diff --git a/src/sem/matrix_type.cc b/src/sem/matrix_type.cc index c095f7ce84..f9fed56dc8 100644 --- a/src/sem/matrix_type.cc +++ b/src/sem/matrix_type.cc @@ -25,7 +25,7 @@ namespace sem { Matrix::Matrix(Vector* column_type, uint32_t columns) : subtype_(column_type->type()), column_type_(column_type), - rows_(column_type->size()), + rows_(column_type->Width()), columns_(columns) { TINT_ASSERT(AST, rows_ > 1); TINT_ASSERT(AST, rows_ < 5); diff --git a/src/sem/type.cc b/src/sem/type.cc index 338d8fde6a..16555f9b0f 100644 --- a/src/sem/type.cc +++ b/src/sem/type.cc @@ -82,9 +82,9 @@ void Type::GetDefaultAlignAndSize(uint32_t& align, uint32_t& size) const { return; } if (auto* vec = As()) { - TINT_ASSERT(Semantic, vec->size() >= 2 && vec->size() <= 4); - align = vector_align[vec->size()]; - size = vector_size[vec->size()]; + TINT_ASSERT(Semantic, vec->Width() >= 2 && vec->Width() <= 4); + align = vector_align[vec->Width()]; + size = vector_size[vec->Width()]; return; } if (auto* mat = As()) { diff --git a/src/sem/vector_type.cc b/src/sem/vector_type.cc index 74cea14526..1a44a524c3 100644 --- a/src/sem/vector_type.cc +++ b/src/sem/vector_type.cc @@ -21,10 +21,10 @@ TINT_INSTANTIATE_TYPEINFO(tint::sem::Vector); namespace tint { namespace sem { -Vector::Vector(Type const* subtype, uint32_t size) - : subtype_(subtype), size_(size) { - TINT_ASSERT(Semantic, size_ > 1); - TINT_ASSERT(Semantic, size_ < 5); +Vector::Vector(Type const* subtype, uint32_t width) + : subtype_(subtype), width_(width) { + TINT_ASSERT(Semantic, width_ > 1); + TINT_ASSERT(Semantic, width_ < 5); } Vector::Vector(Vector&&) = default; @@ -32,12 +32,12 @@ Vector::Vector(Vector&&) = default; Vector::~Vector() = default; std::string Vector::type_name() const { - return "__vec_" + std::to_string(size_) + subtype_->type_name(); + return "__vec_" + std::to_string(width_) + subtype_->type_name(); } std::string Vector::FriendlyName(const SymbolTable& symbols) const { std::ostringstream out; - out << "vec" << size_ << "<" << subtype_->FriendlyName(symbols) << ">"; + out << "vec" << width_ << "<" << subtype_->FriendlyName(symbols) << ">"; return out.str(); } diff --git a/src/sem/vector_type.h b/src/sem/vector_type.h index 79d8835879..5697386ffe 100644 --- a/src/sem/vector_type.h +++ b/src/sem/vector_type.h @@ -35,12 +35,13 @@ class Vector : public Castable { /// @returns the type of the vector elements Type* type() const { return const_cast(subtype_); } - /// @returns the size of the vector - uint32_t size() const { return size_; } /// @returns the name for th type std::string type_name() const override; + /// @returns the width of the vector + uint32_t Width() const { return width_; } + /// @param symbols the program's symbol table /// @returns the name for this type that closely resembles how it would be /// declared in WGSL. @@ -52,7 +53,7 @@ class Vector : public Castable { private: Type const* const subtype_; - uint32_t const size_; + uint32_t const width_; }; } // namespace sem diff --git a/src/sem/vector_type_test.cc b/src/sem/vector_type_test.cc index 2b2c48710c..6059972d8f 100644 --- a/src/sem/vector_type_test.cc +++ b/src/sem/vector_type_test.cc @@ -25,7 +25,7 @@ TEST_F(VectorTest, Creation) { I32 i32; Vector v{&i32, 2}; EXPECT_EQ(v.type(), &i32); - EXPECT_EQ(v.size(), 2u); + EXPECT_EQ(v.Width(), 2u); } TEST_F(VectorTest, TypeName) { diff --git a/src/transform/decompose_memory_access.cc b/src/transform/decompose_memory_access.cc index 0e2b245ea6..65bfec1eaf 100644 --- a/src/transform/decompose_memory_access.cc +++ b/src/transform/decompose_memory_access.cc @@ -153,7 +153,7 @@ bool IntrinsicDataTypeFor(const sem::Type* ty, return true; } if (auto* vec = ty->As()) { - switch (vec->size()) { + switch (vec->Width()) { case 2: if (vec->type()->Is()) { out = DecomposeMemoryAccess::Intrinsic::DataType::kVec2I32; diff --git a/src/transform/fold_constants.cc b/src/transform/fold_constants.cc index 3c72d18925..4868b3c51f 100644 --- a/src/transform/fold_constants.cc +++ b/src/transform/fold_constants.cc @@ -56,7 +56,7 @@ void FoldConstants::Run(CloneContext& ctx, const DataMap&, DataMap&) { } if (auto* vec = ty->As()) { - uint32_t vec_size = static_cast(vec->size()); + uint32_t vec_size = static_cast(vec->Width()); // We'd like to construct the new vector with the same number of // constructor args that the original node had, but after folding diff --git a/src/transform/robustness.cc b/src/transform/robustness.cc index 1e8b94e8c9..185ff96c7c 100644 --- a/src/transform/robustness.cc +++ b/src/transform/robustness.cc @@ -63,7 +63,7 @@ struct Robustness::State { Value size; // size of the array, vector or matrix size.is_signed = false; // size is always unsigned if (auto* vec = ret_type->As()) { - size.u32 = vec->size(); + size.u32 = vec->Width(); } else if (auto* arr = ret_type->As()) { size.u32 = arr->Count(); diff --git a/src/transform/transform.cc b/src/transform/transform.cc index f67c046ede..3b6f33578e 100644 --- a/src/transform/transform.cc +++ b/src/transform/transform.cc @@ -124,7 +124,7 @@ ast::Type* Transform::CreateASTTypeFor(CloneContext& ctx, const sem::Type* ty) { } if (auto* v = ty->As()) { auto* el = CreateASTTypeFor(ctx, v->type()); - return ctx.dst->create(el, v->size()); + return ctx.dst->create(el, v->Width()); } if (auto* a = ty->As()) { auto* el = CreateASTTypeFor(ctx, a->ElemType()); diff --git a/src/transform/vertex_pulling.cc b/src/transform/vertex_pulling.cc index 900b6a36cb..11e5fb803a 100644 --- a/src/transform/vertex_pulling.cc +++ b/src/transform/vertex_pulling.cc @@ -148,7 +148,7 @@ DataType DataTypeOf(sem::Type* ty) { return {BaseType::kF32, 1}; } if (auto* vec = ty->As()) { - return {DataTypeOf(vec->type()).base_type, vec->size()}; + return {DataTypeOf(vec->type()).base_type, vec->Width()}; } return {BaseType::kInvalid, 0}; } diff --git a/src/writer/append_vector.cc b/src/writer/append_vector.cc index f8e135696c..429d9b87d4 100644 --- a/src/writer/append_vector.cc +++ b/src/writer/append_vector.cc @@ -43,7 +43,7 @@ ast::TypeConstructorExpression* AppendVector(ProgramBuilder* b, auto* vector_sem = b->Sem().Get(vector); auto* vector_ty = vector_sem->Type()->UnwrapRef(); if (auto* vec = vector_ty->As()) { - packed_size = vec->size() + 1; + packed_size = vec->Width() + 1; packed_el_sem_ty = vec->type(); } else { packed_size = 2; diff --git a/src/writer/hlsl/generator_impl.cc b/src/writer/hlsl/generator_impl.cc index 1a0bc9a4cc..e853aeedc0 100644 --- a/src/writer/hlsl/generator_impl.cc +++ b/src/writer/hlsl/generator_impl.cc @@ -205,7 +205,7 @@ bool GeneratorImpl::EmitDynamicVectorAssignment( { ScopedIndent si(&helpers_); auto out = line(&helpers_); - switch (vec->size()) { + switch (vec->Width()) { case 2: out << "vec = (idx.xx == int2(0, 1)) ? val.xx : vec;"; break; @@ -217,7 +217,7 @@ bool GeneratorImpl::EmitDynamicVectorAssignment( break; default: TINT_UNREACHABLE(Writer, builder_.Diagnostics()) - << "invalid vector size " << vec->size(); + << "invalid vector size " << vec->Width(); break; } } @@ -1285,7 +1285,7 @@ bool GeneratorImpl::EmitFrexpCall(std::ostream& out, std::string width; if (auto* vec = significand_ty->As()) { - width = std::to_string(vec->size()); + width = std::to_string(vec->Width()); } // Exponent is an integer, which HLSL does not have an overload for. @@ -1318,7 +1318,7 @@ bool GeneratorImpl::EmitIsNormalCall(std::ostream& out, std::string width; if (auto* vec = input_ty->As()) { - width = std::to_string(vec->size()); + width = std::to_string(vec->Width()); } constexpr auto* kExponentMask = "0x7f80000"; @@ -1816,7 +1816,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out, // number of components. uint32_t wgsl_ret_width = 1; if (auto* vec = intrinsic->ReturnType()->As()) { - wgsl_ret_width = vec->size(); + wgsl_ret_width = vec->Width(); } if (wgsl_ret_width < hlsl_ret_width) { out << "."; @@ -2022,7 +2022,7 @@ bool GeneratorImpl::EmitTypeConstructor(std::ostream& out, } if (is_single_value_vector_init) { - out << ")." << std::string(type->As()->size(), 'x'); + out << ")." << std::string(type->As()->Width(), 'x'); } out << (brackets ? "}" : ")"); @@ -2537,7 +2537,7 @@ bool GeneratorImpl::EmitZeroValue(std::ostream& out, const sem::Type* type) { return false; } ScopedParen sp(out); - for (uint32_t i = 0; i < vec->size(); i++) { + for (uint32_t i = 0; i < vec->Width(); i++) { if (i != 0) { out << ", "; } @@ -2970,7 +2970,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, } else if (type->Is()) { out << "uint"; } else if (auto* vec = type->As()) { - auto size = vec->size(); + auto size = vec->Width(); if (vec->type()->Is() && size >= 1 && size <= 4) { out << "float" << size; } else if (vec->type()->Is() && size >= 1 && size <= 4) { diff --git a/src/writer/msl/generator_impl.cc b/src/writer/msl/generator_impl.cc index c22b146a33..eee283bf93 100644 --- a/src/writer/msl/generator_impl.cc +++ b/src/writer/msl/generator_impl.cc @@ -2017,7 +2017,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, if (!EmitType(out, vec->type(), "")) { return false; } - out << vec->size(); + out << vec->Width(); return true; } @@ -2062,7 +2062,7 @@ bool GeneratorImpl::EmitPackedType(std::ostream& out, if (!EmitType(out, vec->type(), "")) { return false; } - out << vec->size(); + out << vec->Width(); return true; } @@ -2349,7 +2349,7 @@ GeneratorImpl::SizeAndAlign GeneratorImpl::MslPackedTypeSizeAndAlign( if (auto* vec = ty->As()) { // https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf // 2.2.3 Packed Vector Types - auto num_els = vec->size(); + auto num_els = vec->Width(); auto* el_ty = vec->type(); if (el_ty->IsAnyOf()) { return SizeAndAlign{num_els * 4, 4}; diff --git a/src/writer/spirv/builder.cc b/src/writer/spirv/builder.cc index f8e8ead53d..d228564883 100644 --- a/src/writer/spirv/builder.cc +++ b/src/writer/spirv/builder.cc @@ -1337,7 +1337,7 @@ uint32_t Builder::GenerateTypeConstructorExpression( auto* value_type = TypeOf(values[0])->UnwrapRef(); if (auto* val_vec = value_type->As()) { if (val_vec->type()->is_scalar()) { - can_cast_or_copy = res_vec->size() == val_vec->size(); + can_cast_or_copy = res_vec->Width() == val_vec->Width(); } } } @@ -1413,7 +1413,7 @@ uint32_t Builder::GenerateTypeConstructorExpression( return 0; } - for (uint32_t i = 0; i < vec->size(); ++i) { + for (uint32_t i = 0; i < vec->Width(); ++i) { auto extract = result_op(); auto extract_id = extract.to_i(); @@ -1455,7 +1455,7 @@ uint32_t Builder::GenerateTypeConstructorExpression( auto* const init_result_type = TypeOf(init)->UnwrapRef(); if (values.size() == 1 && init_result_type->is_scalar_vector() && TypeOf(values[0])->UnwrapRef()->is_scalar()) { - size_t vec_size = init_result_type->As()->size(); + size_t vec_size = init_result_type->As()->Width(); for (size_t i = 0; i < (vec_size - 1); ++i) { ops.push_back(ops[0]); } @@ -1772,7 +1772,7 @@ uint32_t Builder::GenerateConstantVectorSplatIfNeeded(const sem::Vector* type, return 0; } - uint64_t key = (static_cast(type->size()) << 32) + value_id; + uint64_t key = (static_cast(type->Width()) << 32) + value_id; return utils::GetOrCreate(const_splat_to_id_, key, [&] { auto result = result_op(); auto result_id = result.to_i(); @@ -1780,7 +1780,7 @@ uint32_t Builder::GenerateConstantVectorSplatIfNeeded(const sem::Vector* type, OperandList ops; ops.push_back(Operand::Int(type_id)); ops.push_back(result); - for (uint32_t i = 0; i < type->size(); i++) { + for (uint32_t i = 0; i < type->Width(); i++) { ops.push_back(Operand::Int(value_id)); } push_type(spv::Op::OpConstantComposite, ops); @@ -1882,7 +1882,7 @@ uint32_t Builder::GenerateSplat(uint32_t scalar_id, const sem::Type* vec_type) { OperandList ops; ops.push_back(Operand::Int(GenerateTypeIfNeeded(vec_type))); ops.push_back(splat_result); - for (size_t i = 0; i < vec_type->As()->size(); ++i) { + for (size_t i = 0; i < vec_type->As()->Width(); ++i) { ops.push_back(Operand::Int(scalar_id)); } if (!push_function_inst(spv::Op::OpCompositeConstruct, ops)) { @@ -2467,12 +2467,12 @@ uint32_t Builder::GenerateIntrinsic(ast::CallExpression* call, // same size, and create vector constants by replicating the scalars. // I expect backend compilers to fold these into unique constants, so // there is no loss of efficiency. - sem::Vector uvec_ty(&u32, fvec_ty->size()); + sem::Vector uvec_ty(&u32, fvec_ty->Width()); unsigned_id = GenerateTypeIfNeeded(&uvec_ty); auto splat = [&](uint32_t scalar_id) -> uint32_t { auto splat_result = result_op(); OperandList splat_params{Operand::Int(unsigned_id), splat_result}; - for (size_t i = 0; i < fvec_ty->size(); i++) { + for (size_t i = 0; i < fvec_ty->Width(); i++) { splat_params.emplace_back(Operand::Int(scalar_id)); } if (!push_function_inst(spv::Op::OpCompositeConstruct, @@ -2531,7 +2531,7 @@ uint32_t Builder::GenerateIntrinsic(ast::CallExpression* call, if (result_vector_type && intrinsic->Parameters()[2]->Type()->is_scalar()) { sem::Bool bool_type; - sem::Vector bool_vec_type(&bool_type, result_vector_type->size()); + sem::Vector bool_vec_type(&bool_type, result_vector_type->Width()); if (!GenerateTypeIfNeeded(&bool_vec_type)) { return 0; } @@ -4015,7 +4015,7 @@ bool Builder::GenerateVectorType(const sem::Vector* vec, } push_type(spv::Op::OpTypeVector, - {result, Operand::Int(type_id), Operand::Int(vec->size())}); + {result, Operand::Int(type_id), Operand::Int(vec->Width())}); return true; }