diff --git a/src/tint/BUILD.gn b/src/tint/BUILD.gn index 98d0c846f7..77e65d191e 100644 --- a/src/tint/BUILD.gn +++ b/src/tint/BUILD.gn @@ -420,7 +420,6 @@ libtint_source_set("libtint_core_all_src") { "sem/atomic.h", "sem/behavior.h", "sem/binding_point.h", - "sem/bool.h", "sem/break_if_statement.h", "sem/builtin.h", "sem/builtin_type.h", @@ -429,10 +428,7 @@ libtint_source_set("libtint_core_all_src") { "sem/constant.h", "sem/evaluation_stage.h", "sem/expression.h", - "sem/f16.h", - "sem/f32.h", "sem/for_loop_statement.h", - "sem/i32.h", "sem/if_statement.h", "sem/index_accessor_expression.h", "sem/info.h", @@ -451,9 +447,7 @@ libtint_source_set("libtint_core_all_src") { "sem/type_conversion.h", "sem/type_initializer.h", "sem/type_mappings.h", - "sem/u32.h", "sem/vector.h", - "sem/void.h", "sem/while_statement.h", "source.cc", "source.h", @@ -569,9 +563,13 @@ libtint_source_set("libtint_core_all_src") { "type/abstract_int.h", "type/abstract_numeric.h", "type/array_count.h", + "type/bool.h", "type/depth_multisampled_texture.h", "type/depth_texture.h", "type/external_texture.h", + "type/f16.h", + "type/f32.h", + "type/i32.h", "type/multisampled_texture.h", "type/node.h", "type/sampled_texture.h", @@ -580,6 +578,8 @@ libtint_source_set("libtint_core_all_src") { "type/texture.h", "type/type.h", "type/type_manager.h", + "type/u32.h", + "type/void.h", "utils/bitcast.h", "utils/bitset.h", "utils/block_allocator.h", @@ -643,8 +643,6 @@ libtint_source_set("libtint_sem_src") { "sem/behavior.h", "sem/binding_point.h", "sem/block_statement.cc", - "sem/bool.cc", - "sem/bool.h", "sem/break_if_statement.cc", "sem/break_if_statement.h", "sem/builtin.cc", @@ -660,15 +658,9 @@ libtint_source_set("libtint_sem_src") { "sem/evaluation_stage.h", "sem/expression.cc", "sem/expression.h", - "sem/f16.cc", - "sem/f16.h", - "sem/f32.cc", - "sem/f32.h", "sem/for_loop_statement.cc", "sem/for_loop_statement.h", "sem/function.cc", - "sem/i32.cc", - "sem/i32.h", "sem/if_statement.cc", "sem/if_statement.h", "sem/index_accessor_expression.cc", @@ -703,13 +695,9 @@ libtint_source_set("libtint_sem_src") { "sem/type_initializer.cc", "sem/type_initializer.h", "sem/type_mappings.h", - "sem/u32.cc", - "sem/u32.h", "sem/variable.cc", "sem/vector.cc", "sem/vector.h", - "sem/void.cc", - "sem/void.h", "sem/while_statement.cc", "sem/while_statement.h", ] @@ -727,12 +715,20 @@ libtint_source_set("libtint_type_src") { "type/abstract_numeric.h", "type/array_count.cc", "type/array_count.h", + "type/bool.cc", + "type/bool.h", "type/depth_multisampled_texture.cc", "type/depth_multisampled_texture.h", "type/depth_texture.cc", "type/depth_texture.h", "type/external_texture.cc", "type/external_texture.h", + "type/f16.cc", + "type/f16.h", + "type/f32.cc", + "type/f32.h", + "type/i32.cc", + "type/i32.h", "type/multisampled_texture.cc", "type/multisampled_texture.h", "type/node.cc", @@ -749,6 +745,10 @@ libtint_source_set("libtint_type_src") { "type/type.h", "type/type_manager.cc", "type/type_manager.h", + "type/u32.cc", + "type/u32.h", + "type/void.cc", + "type/void.h", ] public_deps = [ ":libtint_core_all_src" ] @@ -1204,26 +1204,25 @@ if (tint_build_unittests) { sources = [ "sem/array_test.cc", "sem/atomic_test.cc", - "sem/bool_test.cc", "sem/builtin_test.cc", "sem/expression_test.cc", - "sem/f16_test.cc", - "sem/f32_test.cc", - "sem/i32_test.cc", "sem/matrix_test.cc", "sem/pointer_test.cc", "sem/reference_test.cc", "sem/struct_test.cc", - "sem/u32_test.cc", "sem/vector_test.cc", ] } tint_unittests_source_set("tint_unittests_type_src") { sources = [ + "type/bool_test.cc", "type/depth_multisampled_texture_test.cc", "type/depth_texture_test.cc", "type/external_texture_test.cc", + "type/f16_test.cc", + "type/f32_test.cc", + "type/i32_test.cc", "type/multisampled_texture_test.cc", "type/sampled_texture_test.cc", "type/sampler_test.cc", @@ -1231,6 +1230,7 @@ if (tint_build_unittests) { "type/texture_test.cc", "type/type_manager_test.cc", "type/type_test.cc", + "type/u32_test.cc", ] } diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt index 9decb9924b..bb6ff5fe51 100644 --- a/src/tint/CMakeLists.txt +++ b/src/tint/CMakeLists.txt @@ -302,8 +302,6 @@ list(APPEND TINT_LIB_SRCS sem/binding_point.h sem/block_statement.cc sem/block_statement.h - sem/bool.cc - sem/bool.h sem/break_if_statement.cc sem/break_if_statement.h sem/builtin.cc @@ -317,15 +315,9 @@ list(APPEND TINT_LIB_SRCS sem/evaluation_stage.h sem/expression.cc sem/expression.h - sem/f16.cc - sem/f16.h - sem/f32.cc - sem/f32.h sem/for_loop_statement.cc sem/for_loop_statement.h sem/function.cc - sem/i32.cc - sem/i32.h sem/if_statement.cc sem/if_statement.h sem/index_accessor_expression.cc @@ -358,13 +350,9 @@ list(APPEND TINT_LIB_SRCS sem/type_conversion.cc sem/type_conversion.h sem/type_mappings.h - sem/u32.cc - sem/u32.h sem/variable.cc sem/vector.cc sem/vector.h - sem/void.cc - sem/void.h sem/while_statement.cc sem/while_statement.h symbol_table.cc @@ -483,12 +471,20 @@ list(APPEND TINT_LIB_SRCS type/abstract_numeric.h type/array_count.cc type/array_count.h + type/bool.cc + type/bool.h type/depth_multisampled_texture.cc type/depth_multisampled_texture.h type/depth_texture.cc type/depth_texture.h type/external_texture.cc type/external_texture.h + type/f16.cc + type/f16.h + type/f32.cc + type/f32.h + type/i32.cc + type/i32.h type/multisampled_texture.cc type/multisampled_texture.h type/node.cc @@ -505,6 +501,10 @@ list(APPEND TINT_LIB_SRCS type/type.h type/type_manager.cc type/type_manager.h + type/u32.cc + type/u32.h + type/void.cc + type/void.h utils/bitcast.h utils/bitset.h utils/block_allocator.h @@ -922,17 +922,12 @@ if(TINT_BUILD_TESTS) scope_stack_test.cc sem/array_test.cc sem/atomic.cc - sem/bool_test.cc sem/builtin_test.cc sem/expression_test.cc - sem/f16_test.cc - sem/f32_test.cc - sem/i32_test.cc sem/matrix_test.cc sem/pointer_test.cc sem/reference_test.cc sem/struct_test.cc - sem/u32_test.cc sem/vector_test.cc source_test.cc symbol_table_test.cc @@ -941,9 +936,13 @@ if(TINT_BUILD_TESTS) text/unicode_test.cc traits_test.cc transform/transform_test.cc + type/bool_test.cc type/depth_multisampled_texture_test.cc type/depth_texture_test.cc type/external_texture_test.cc + type/f16_test.cc + type/f32_test.cc + type/i32_test.cc type/multisampled_texture_test.cc type/sampled_texture_test.cc type/sampler_test.cc @@ -951,6 +950,7 @@ if(TINT_BUILD_TESTS) type/texture_test.cc type/type_test.cc type/type_manager_test.cc + type/u32_test.cc utils/bitcast_test.cc utils/bitset_test.cc utils/block_allocator_test.cc diff --git a/src/tint/fuzzers/tint_ast_fuzzer/mutations/change_binary_operator.cc b/src/tint/fuzzers/tint_ast_fuzzer/mutations/change_binary_operator.cc index 15af58de67..aa46ec3e61 100644 --- a/src/tint/fuzzers/tint_ast_fuzzer/mutations/change_binary_operator.cc +++ b/src/tint/fuzzers/tint_ast_fuzzer/mutations/change_binary_operator.cc @@ -17,8 +17,8 @@ #include #include "src/tint/program_builder.h" -#include "src/tint/sem/bool.h" #include "src/tint/sem/reference.h" +#include "src/tint/type/bool.h" namespace tint::fuzzers::ast_fuzzer { @@ -173,7 +173,7 @@ bool CanReplaceAndOrWith(const type::Type* lhs_type, case ast::BinaryOp::kLogicalOr: // '&' and '|' can be applied to booleans, and for boolean scalar // scalar contexts, their logical counterparts work. - return lhs_type->Is(); + return lhs_type->Is(); case ast::BinaryOp::kEqual: case ast::BinaryOp::kNotEqual: // '&' and '|' can be applied to booleans, and in these contexts equality @@ -249,7 +249,7 @@ bool CanReplaceEqualNotEqualWith(const type::Type* lhs_type, ast::BinaryOp new_o case ast::BinaryOp::kLogicalOr: // An equality comparison between boolean scalars can be turned into a // logical operation. - return lhs_type->Is(); + return lhs_type->Is(); case ast::BinaryOp::kAnd: case ast::BinaryOp::kOr: // An equality comparison between boolean scalars or vectors can be turned diff --git a/src/tint/inspector/inspector.cc b/src/tint/inspector/inspector.cc index cbf5c03309..8236a8303d 100644 --- a/src/tint/inspector/inspector.cc +++ b/src/tint/inspector/inspector.cc @@ -29,26 +29,26 @@ #include "src/tint/ast/override.h" #include "src/tint/ast/var.h" #include "src/tint/sem/array.h" -#include "src/tint/sem/bool.h" #include "src/tint/sem/call.h" -#include "src/tint/sem/f16.h" -#include "src/tint/sem/f32.h" #include "src/tint/sem/function.h" -#include "src/tint/sem/i32.h" #include "src/tint/sem/matrix.h" #include "src/tint/sem/module.h" #include "src/tint/sem/statement.h" #include "src/tint/sem/struct.h" -#include "src/tint/sem/u32.h" #include "src/tint/sem/variable.h" #include "src/tint/sem/vector.h" -#include "src/tint/sem/void.h" +#include "src/tint/type/bool.h" #include "src/tint/type/depth_multisampled_texture.h" #include "src/tint/type/depth_texture.h" #include "src/tint/type/external_texture.h" +#include "src/tint/type/f16.h" +#include "src/tint/type/f32.h" +#include "src/tint/type/i32.h" #include "src/tint/type/multisampled_texture.h" #include "src/tint/type/sampled_texture.h" #include "src/tint/type/storage_texture.h" +#include "src/tint/type/u32.h" +#include "src/tint/type/void.h" #include "src/tint/utils/math.h" #include "src/tint/utils/string.h" #include "src/tint/utils/unique_vector.h" @@ -75,10 +75,10 @@ std::tuple CalculateComponentAndComposition( ComponentType componentType = Switch( type::Type::DeepestElementOf(type), // - [&](const sem::F32*) { return ComponentType::kF32; }, - [&](const sem::F16*) { return ComponentType::kF16; }, - [&](const sem::I32*) { return ComponentType::kI32; }, - [&](const sem::U32*) { return ComponentType::kU32; }, + [&](const type::F32*) { return ComponentType::kF32; }, + [&](const type::F16*) { return ComponentType::kF16; }, + [&](const type::I32*) { return ComponentType::kI32; }, + [&](const type::U32*) { return ComponentType::kU32; }, [&](Default) { tint::diag::List diagnostics; TINT_UNREACHABLE(Inspector, diagnostics) << "unhandled component type"; @@ -226,7 +226,7 @@ EntryPoint Inspector::GetEntryPoint(const tint::ast::Function* func) { ast::BuiltinValue::kNumWorkgroups, param->Type(), param->Declaration()->attributes); } - if (!sem->ReturnType()->Is()) { + if (!sem->ReturnType()->Is()) { AddEntryPointInOutVariables("", sem->ReturnType(), func->return_type_attributes, sem->ReturnLocation(), entry_point.output_variables); @@ -314,10 +314,10 @@ std::map Inspector::GetOverrideDefaultValues() { if (auto* value = global->Initializer()->ConstantValue()) { result[override_id] = Switch( value->Type(), // - [&](const sem::I32*) { return Scalar(value->As()); }, - [&](const sem::U32*) { return Scalar(value->As()); }, - [&](const sem::F32*) { return Scalar(value->As()); }, - [&](const sem::Bool*) { return Scalar(value->As()); }); + [&](const type::I32*) { return Scalar(value->As()); }, + [&](const type::U32*) { return Scalar(value->As()); }, + [&](const type::F32*) { return Scalar(value->As()); }, + [&](const type::Bool*) { return Scalar(value->As()); }); continue; } } diff --git a/src/tint/inspector/resource_binding.cc b/src/tint/inspector/resource_binding.cc index 225e739b17..6cbb4f19db 100644 --- a/src/tint/inspector/resource_binding.cc +++ b/src/tint/inspector/resource_binding.cc @@ -15,12 +15,12 @@ #include "src/tint/inspector/resource_binding.h" #include "src/tint/sem/array.h" -#include "src/tint/sem/f32.h" -#include "src/tint/sem/i32.h" #include "src/tint/sem/matrix.h" -#include "src/tint/sem/u32.h" #include "src/tint/sem/vector.h" +#include "src/tint/type/f32.h" +#include "src/tint/type/i32.h" #include "src/tint/type/type.h" +#include "src/tint/type/u32.h" namespace tint::inspector { @@ -58,11 +58,11 @@ ResourceBinding::SampledKind BaseTypeToSampledKind(const type::Type* base_type) base_type = vt->type(); } - if (base_type->Is()) { + if (base_type->Is()) { return ResourceBinding::SampledKind::kFloat; - } else if (base_type->Is()) { + } else if (base_type->Is()) { return ResourceBinding::SampledKind::kUInt; - } else if (base_type->Is()) { + } else if (base_type->Is()) { return ResourceBinding::SampledKind::kSInt; } else { return ResourceBinding::SampledKind::kUnknown; diff --git a/src/tint/program_builder.h b/src/tint/program_builder.h index 5f45e2cf47..4312528aa6 100644 --- a/src/tint/program_builder.h +++ b/src/tint/program_builder.h @@ -92,22 +92,22 @@ #include "src/tint/program_id.h" #include "src/tint/sem/array.h" #include "src/tint/sem/array_count.h" -#include "src/tint/sem/bool.h" #include "src/tint/sem/constant.h" -#include "src/tint/sem/f16.h" -#include "src/tint/sem/f32.h" -#include "src/tint/sem/i32.h" #include "src/tint/sem/matrix.h" #include "src/tint/sem/pointer.h" #include "src/tint/sem/struct.h" -#include "src/tint/sem/u32.h" #include "src/tint/sem/vector.h" -#include "src/tint/sem/void.h" +#include "src/tint/type/bool.h" #include "src/tint/type/depth_texture.h" #include "src/tint/type/external_texture.h" +#include "src/tint/type/f16.h" +#include "src/tint/type/f32.h" +#include "src/tint/type/i32.h" #include "src/tint/type/multisampled_texture.h" #include "src/tint/type/sampled_texture.h" #include "src/tint/type/storage_texture.h" +#include "src/tint/type/u32.h" +#include "src/tint/type/void.h" #ifdef CURRENTLY_IN_TINT_PUBLIC_HEADER #error "internal tint header being #included from tint.h" diff --git a/src/tint/resolver/array_accessor_test.cc b/src/tint/resolver/array_accessor_test.cc index d7327de045..2a95c3952a 100644 --- a/src/tint/resolver/array_accessor_test.cc +++ b/src/tint/resolver/array_accessor_test.cc @@ -132,7 +132,7 @@ TEST_F(ResolverIndexAccessorTest, Matrix_BothDimensions) { ASSERT_TRUE(TypeOf(acc)->Is()); auto* ref = TypeOf(acc)->As(); - EXPECT_TRUE(ref->StoreType()->Is()); + EXPECT_TRUE(ref->StoreType()->Is()); auto idx_sem = Sem().Get(acc); ASSERT_NE(idx_sem, nullptr); @@ -184,7 +184,7 @@ TEST_F(ResolverIndexAccessorTest, Vector) { ASSERT_TRUE(TypeOf(acc)->Is()); auto* ref = TypeOf(acc)->As(); - EXPECT_TRUE(ref->StoreType()->Is()); + EXPECT_TRUE(ref->StoreType()->Is()); auto idx_sem = Sem().Get(acc); ASSERT_NE(idx_sem, nullptr); @@ -200,7 +200,7 @@ TEST_F(ResolverIndexAccessorTest, Array_Literal_i32) { ASSERT_NE(TypeOf(acc), nullptr); auto* ref = TypeOf(acc)->As(); ASSERT_NE(ref, nullptr); - EXPECT_TRUE(ref->StoreType()->Is()); + EXPECT_TRUE(ref->StoreType()->Is()); auto idx_sem = Sem().Get(acc); ASSERT_NE(idx_sem, nullptr); @@ -216,7 +216,7 @@ TEST_F(ResolverIndexAccessorTest, Array_Literal_u32) { ASSERT_NE(TypeOf(acc), nullptr); auto* ref = TypeOf(acc)->As(); ASSERT_NE(ref, nullptr); - EXPECT_TRUE(ref->StoreType()->Is()); + EXPECT_TRUE(ref->StoreType()->Is()); auto idx_sem = Sem().Get(acc); ASSERT_NE(idx_sem, nullptr); @@ -232,7 +232,7 @@ TEST_F(ResolverIndexAccessorTest, Array_Literal_AInt) { ASSERT_NE(TypeOf(acc), nullptr); auto* ref = TypeOf(acc)->As(); ASSERT_NE(ref, nullptr); - EXPECT_TRUE(ref->StoreType()->Is()); + EXPECT_TRUE(ref->StoreType()->Is()); auto idx_sem = Sem().Get(acc); ASSERT_NE(idx_sem, nullptr); @@ -254,7 +254,7 @@ TEST_F(ResolverIndexAccessorTest, Alias_Array) { ASSERT_TRUE(TypeOf(acc)->Is()); auto* ref = TypeOf(acc)->As(); - EXPECT_TRUE(ref->StoreType()->Is()); + EXPECT_TRUE(ref->StoreType()->Is()); auto idx_sem = Sem().Get(acc); ASSERT_NE(idx_sem, nullptr); @@ -271,7 +271,7 @@ TEST_F(ResolverIndexAccessorTest, Array_Constant) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(acc), nullptr); - EXPECT_TRUE(TypeOf(acc)->Is()); + EXPECT_TRUE(TypeOf(acc)->Is()); } TEST_F(ResolverIndexAccessorTest, Array_Dynamic_I32) { diff --git a/src/tint/resolver/atomics_test.cc b/src/tint/resolver/atomics_test.cc index e3d0ca9afd..e4851bbced 100644 --- a/src/tint/resolver/atomics_test.cc +++ b/src/tint/resolver/atomics_test.cc @@ -33,7 +33,7 @@ TEST_F(ResolverAtomicTest, GlobalWorkgroupI32) { ASSERT_TRUE(TypeOf(g)->Is()); auto* atomic = TypeOf(g)->UnwrapRef()->As(); ASSERT_NE(atomic, nullptr); - EXPECT_TRUE(atomic->Type()->Is()); + EXPECT_TRUE(atomic->Type()->Is()); } TEST_F(ResolverAtomicTest, GlobalWorkgroupU32) { @@ -43,7 +43,7 @@ TEST_F(ResolverAtomicTest, GlobalWorkgroupU32) { ASSERT_TRUE(TypeOf(g)->Is()); auto* atomic = TypeOf(g)->UnwrapRef()->As(); ASSERT_NE(atomic, nullptr); - EXPECT_TRUE(atomic->Type()->Is()); + EXPECT_TRUE(atomic->Type()->Is()); } TEST_F(ResolverAtomicTest, GlobalStorageStruct) { @@ -58,7 +58,7 @@ TEST_F(ResolverAtomicTest, GlobalStorageStruct) { ASSERT_EQ(str->Members().Length(), 1u); auto* atomic = str->Members()[0]->Type()->As(); ASSERT_NE(atomic, nullptr); - ASSERT_TRUE(atomic->Type()->Is()); + ASSERT_TRUE(atomic->Type()->Is()); } } // namespace diff --git a/src/tint/resolver/builtin_test.cc b/src/tint/resolver/builtin_test.cc index 72b428ce09..f8f2a68af3 100644 --- a/src/tint/resolver/builtin_test.cc +++ b/src/tint/resolver/builtin_test.cc @@ -87,7 +87,7 @@ TEST_P(ResolverBuiltinTest_BoolMethod, Scalar) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(expr), nullptr); - EXPECT_TRUE(TypeOf(expr)->Is()); + EXPECT_TRUE(TypeOf(expr)->Is()); } TEST_P(ResolverBuiltinTest_BoolMethod, Vector) { auto name = GetParam(); @@ -100,7 +100,7 @@ TEST_P(ResolverBuiltinTest_BoolMethod, Vector) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(expr), nullptr); - EXPECT_TRUE(TypeOf(expr)->Is()); + EXPECT_TRUE(TypeOf(expr)->Is()); } INSTANTIATE_TEST_SUITE_P(ResolverTest, ResolverBuiltinTest_BoolMethod, @@ -119,7 +119,7 @@ TEST_F(ResolverBuiltinTest, Select) { ASSERT_NE(TypeOf(expr), nullptr); EXPECT_TRUE(TypeOf(expr)->Is()); EXPECT_EQ(TypeOf(expr)->As()->Width(), 3u); - EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); } TEST_F(ResolverBuiltinTest, Select_Error_NoParams) { @@ -222,7 +222,7 @@ TEST_F(ResolverBuiltinArrayTest, ArrayLength_Vector) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_F(ResolverBuiltinArrayTest, ArrayLength_Error_ArraySized) { @@ -290,7 +290,7 @@ TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, OneParam_Scalar_f32) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } else { // Invalid parameter count. EXPECT_FALSE(r()->Resolve()); @@ -317,7 +317,7 @@ TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, OneParam_Vector_f32) { EXPECT_TRUE(TypeOf(call)->is_float_vector()); EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); ASSERT_NE(TypeOf(call)->As()->type(), nullptr); - EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); } else { // Invalid parameter count. EXPECT_FALSE(r()->Resolve()); @@ -338,7 +338,7 @@ TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, TwoParams_Scalar_f32) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } else { // Invalid parameter count. EXPECT_FALSE(r()->Resolve()); @@ -362,7 +362,7 @@ TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, TwoParams_Vector_f32) { EXPECT_TRUE(TypeOf(call)->is_float_vector()); EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); ASSERT_NE(TypeOf(call)->As()->type(), nullptr); - EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); } else { // Invalid parameter count. EXPECT_FALSE(r()->Resolve()); @@ -383,7 +383,7 @@ TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, ThreeParams_Scalar_f32) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } else { // Invalid parameter count. EXPECT_FALSE(r()->Resolve()); @@ -408,7 +408,7 @@ TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, ThreeParams_Vector_f32) { EXPECT_TRUE(TypeOf(call)->is_float_vector()); EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); ASSERT_NE(TypeOf(call)->As()->type(), nullptr); - EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); } else { // Invalid parameter count. EXPECT_FALSE(r()->Resolve()); @@ -430,7 +430,7 @@ TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, FourParams_Scalar_f32) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } else { // Invalid parameter count. EXPECT_FALSE(r()->Resolve()); @@ -455,7 +455,7 @@ TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, FourParams_Vector_f32) { EXPECT_TRUE(TypeOf(call)->is_float_vector()); EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); ASSERT_NE(TypeOf(call)->As()->type(), nullptr); - EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); } else { // Invalid parameter count. EXPECT_FALSE(r()->Resolve()); @@ -484,7 +484,7 @@ TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, OneParam_Scalar_f16) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } else { // Invalid parameter count. EXPECT_FALSE(r()->Resolve()); @@ -513,7 +513,7 @@ TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, OneParam_Vector_f16) { EXPECT_TRUE(TypeOf(call)->is_float_vector()); EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); ASSERT_NE(TypeOf(call)->As()->type(), nullptr); - EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); } else { // Invalid parameter count. EXPECT_FALSE(r()->Resolve()); @@ -536,7 +536,7 @@ TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, TwoParams_Scalar_f16) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } else { // Invalid parameter count. EXPECT_FALSE(r()->Resolve()); @@ -562,7 +562,7 @@ TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, TwoParams_Vector_f16) { EXPECT_TRUE(TypeOf(call)->is_float_vector()); EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); ASSERT_NE(TypeOf(call)->As()->type(), nullptr); - EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); } else { // Invalid parameter count. EXPECT_FALSE(r()->Resolve()); @@ -585,7 +585,7 @@ TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, ThreeParams_Scalar_f16) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } else { // Invalid parameter count. EXPECT_FALSE(r()->Resolve()); @@ -612,7 +612,7 @@ TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, ThreeParams_Vector_f16) { EXPECT_TRUE(TypeOf(call)->is_float_vector()); EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); ASSERT_NE(TypeOf(call)->As()->type(), nullptr); - EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); } else { // Invalid parameter count. EXPECT_FALSE(r()->Resolve()); @@ -636,7 +636,7 @@ TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, FourParams_Scalar_f16) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } else { // Invalid parameter count. EXPECT_FALSE(r()->Resolve()); @@ -663,7 +663,7 @@ TEST_P(ResolverBuiltinTest_FloatBuiltin_IdenticalType, FourParams_Vector_f16) { EXPECT_TRUE(TypeOf(call)->is_float_vector()); EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); ASSERT_NE(TypeOf(call)->As()->type(), nullptr); - EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); } else { // Invalid parameter count. EXPECT_FALSE(r()->Resolve()); @@ -739,7 +739,7 @@ TEST_F(ResolverBuiltinFloatTest, Cross_f32) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_float_vector()); EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); - EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); } TEST_F(ResolverBuiltinFloatTest, Cross_f16) { @@ -753,7 +753,7 @@ TEST_F(ResolverBuiltinFloatTest, Cross_f16) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_float_vector()); EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); - EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); } TEST_F(ResolverBuiltinFloatTest, Cross_Error_NoArgs) { @@ -835,7 +835,7 @@ TEST_F(ResolverBuiltinFloatTest, Distance_Scalar_f32) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_F(ResolverBuiltinFloatTest, Distance_Scalar_f16) { @@ -847,7 +847,7 @@ TEST_F(ResolverBuiltinFloatTest, Distance_Scalar_f16) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_F(ResolverBuiltinFloatTest, Distance_Vector_f32) { @@ -857,7 +857,7 @@ TEST_F(ResolverBuiltinFloatTest, Distance_Vector_f32) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_F(ResolverBuiltinFloatTest, Distance_Vector_f16) { @@ -869,7 +869,7 @@ TEST_F(ResolverBuiltinFloatTest, Distance_Vector_f16) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_F(ResolverBuiltinFloatTest, Distance_TooManyParams) { @@ -929,14 +929,14 @@ TEST_F(ResolverBuiltinFloatTest, FrexpScalar_f32) { ASSERT_EQ(ty->Members().Length(), 2u); auto* fract = ty->Members()[0]; - EXPECT_TRUE(fract->Type()->Is()); + EXPECT_TRUE(fract->Type()->Is()); EXPECT_EQ(fract->Offset(), 0u); EXPECT_EQ(fract->Size(), 4u); EXPECT_EQ(fract->Align(), 4u); EXPECT_EQ(fract->Name(), Sym("fract")); auto* exp = ty->Members()[1]; - EXPECT_TRUE(exp->Type()->Is()); + EXPECT_TRUE(exp->Type()->Is()); EXPECT_EQ(exp->Offset(), 4u); EXPECT_EQ(exp->Size(), 4u); EXPECT_EQ(exp->Align(), 4u); @@ -960,14 +960,14 @@ TEST_F(ResolverBuiltinFloatTest, FrexpScalar_f16) { ASSERT_EQ(ty->Members().Length(), 2u); auto* fract = ty->Members()[0]; - EXPECT_TRUE(fract->Type()->Is()); + EXPECT_TRUE(fract->Type()->Is()); EXPECT_EQ(fract->Offset(), 0u); EXPECT_EQ(fract->Size(), 2u); EXPECT_EQ(fract->Align(), 2u); EXPECT_EQ(fract->Name(), Sym("fract")); auto* exp = ty->Members()[1]; - EXPECT_TRUE(exp->Type()->Is()); + EXPECT_TRUE(exp->Type()->Is()); EXPECT_EQ(exp->Offset(), 4u); EXPECT_EQ(exp->Size(), 4u); EXPECT_EQ(exp->Align(), 4u); @@ -991,7 +991,7 @@ TEST_F(ResolverBuiltinFloatTest, FrexpVector_f32) { auto* fract = ty->Members()[0]; ASSERT_TRUE(fract->Type()->Is()); EXPECT_EQ(fract->Type()->As()->Width(), 3u); - EXPECT_TRUE(fract->Type()->As()->type()->Is()); + EXPECT_TRUE(fract->Type()->As()->type()->Is()); EXPECT_EQ(fract->Offset(), 0u); EXPECT_EQ(fract->Size(), 12u); EXPECT_EQ(fract->Align(), 16u); @@ -1000,7 +1000,7 @@ TEST_F(ResolverBuiltinFloatTest, FrexpVector_f32) { auto* exp = ty->Members()[1]; ASSERT_TRUE(exp->Type()->Is()); EXPECT_EQ(exp->Type()->As()->Width(), 3u); - EXPECT_TRUE(exp->Type()->As()->type()->Is()); + EXPECT_TRUE(exp->Type()->As()->type()->Is()); EXPECT_EQ(exp->Offset(), 16u); EXPECT_EQ(exp->Size(), 12u); EXPECT_EQ(exp->Align(), 16u); @@ -1026,7 +1026,7 @@ TEST_F(ResolverBuiltinFloatTest, FrexpVector_f16) { auto* fract = ty->Members()[0]; ASSERT_TRUE(fract->Type()->Is()); EXPECT_EQ(fract->Type()->As()->Width(), 3u); - EXPECT_TRUE(fract->Type()->As()->type()->Is()); + EXPECT_TRUE(fract->Type()->As()->type()->Is()); EXPECT_EQ(fract->Offset(), 0u); EXPECT_EQ(fract->Size(), 6u); EXPECT_EQ(fract->Align(), 8u); @@ -1035,7 +1035,7 @@ TEST_F(ResolverBuiltinFloatTest, FrexpVector_f16) { auto* exp = ty->Members()[1]; ASSERT_TRUE(exp->Type()->Is()); EXPECT_EQ(exp->Type()->As()->Width(), 3u); - EXPECT_TRUE(exp->Type()->As()->type()->Is()); + EXPECT_TRUE(exp->Type()->As()->type()->Is()); EXPECT_EQ(exp->Offset(), 16u); EXPECT_EQ(exp->Size(), 12u); EXPECT_EQ(exp->Align(), 16u); @@ -1092,7 +1092,7 @@ TEST_F(ResolverBuiltinFloatTest, Length_Scalar_f32) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_F(ResolverBuiltinFloatTest, Length_Scalar_f16) { @@ -1104,7 +1104,7 @@ TEST_F(ResolverBuiltinFloatTest, Length_Scalar_f16) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_F(ResolverBuiltinFloatTest, Length_FloatVector_f32) { @@ -1114,7 +1114,7 @@ TEST_F(ResolverBuiltinFloatTest, Length_FloatVector_f32) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_F(ResolverBuiltinFloatTest, Length_FloatVector_f16) { @@ -1126,7 +1126,7 @@ TEST_F(ResolverBuiltinFloatTest, Length_FloatVector_f16) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_F(ResolverBuiltinFloatTest, Length_NoParams) { @@ -1169,7 +1169,7 @@ TEST_F(ResolverBuiltinFloatTest, Mix_VectorScalar_f32) { EXPECT_TRUE(TypeOf(call)->is_float_vector()); EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); ASSERT_NE(TypeOf(call)->As()->type(), nullptr); - EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); } TEST_F(ResolverBuiltinFloatTest, Mix_VectorScalar_f16) { @@ -1184,7 +1184,7 @@ TEST_F(ResolverBuiltinFloatTest, Mix_VectorScalar_f16) { EXPECT_TRUE(TypeOf(call)->is_float_vector()); EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); ASSERT_NE(TypeOf(call)->As()->type(), nullptr); - EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); } // modf: (f32) -> __modf_result, (vecN) -> __modf_result_vecN, (f16) -> __modf_result_f16, @@ -1201,14 +1201,14 @@ TEST_F(ResolverBuiltinFloatTest, ModfScalar_f32) { ASSERT_EQ(ty->Members().Length(), 2u); auto* fract = ty->Members()[0]; - EXPECT_TRUE(fract->Type()->Is()); + EXPECT_TRUE(fract->Type()->Is()); EXPECT_EQ(fract->Offset(), 0u); EXPECT_EQ(fract->Size(), 4u); EXPECT_EQ(fract->Align(), 4u); EXPECT_EQ(fract->Name(), Sym("fract")); auto* whole = ty->Members()[1]; - EXPECT_TRUE(whole->Type()->Is()); + EXPECT_TRUE(whole->Type()->Is()); EXPECT_EQ(whole->Offset(), 4u); EXPECT_EQ(whole->Size(), 4u); EXPECT_EQ(whole->Align(), 4u); @@ -1232,14 +1232,14 @@ TEST_F(ResolverBuiltinFloatTest, ModfScalar_f16) { ASSERT_EQ(ty->Members().Length(), 2u); auto* fract = ty->Members()[0]; - EXPECT_TRUE(fract->Type()->Is()); + EXPECT_TRUE(fract->Type()->Is()); EXPECT_EQ(fract->Offset(), 0u); EXPECT_EQ(fract->Size(), 2u); EXPECT_EQ(fract->Align(), 2u); EXPECT_EQ(fract->Name(), Sym("fract")); auto* whole = ty->Members()[1]; - EXPECT_TRUE(whole->Type()->Is()); + EXPECT_TRUE(whole->Type()->Is()); EXPECT_EQ(whole->Offset(), 2u); EXPECT_EQ(whole->Size(), 2u); EXPECT_EQ(whole->Align(), 2u); @@ -1263,7 +1263,7 @@ TEST_F(ResolverBuiltinFloatTest, ModfVector_f32) { auto* fract = ty->Members()[0]; ASSERT_TRUE(fract->Type()->Is()); EXPECT_EQ(fract->Type()->As()->Width(), 3u); - EXPECT_TRUE(fract->Type()->As()->type()->Is()); + EXPECT_TRUE(fract->Type()->As()->type()->Is()); EXPECT_EQ(fract->Offset(), 0u); EXPECT_EQ(fract->Size(), 12u); EXPECT_EQ(fract->Align(), 16u); @@ -1272,7 +1272,7 @@ TEST_F(ResolverBuiltinFloatTest, ModfVector_f32) { auto* whole = ty->Members()[1]; ASSERT_TRUE(whole->Type()->Is()); EXPECT_EQ(whole->Type()->As()->Width(), 3u); - EXPECT_TRUE(whole->Type()->As()->type()->Is()); + EXPECT_TRUE(whole->Type()->As()->type()->Is()); EXPECT_EQ(whole->Offset(), 16u); EXPECT_EQ(whole->Size(), 12u); EXPECT_EQ(whole->Align(), 16u); @@ -1298,7 +1298,7 @@ TEST_F(ResolverBuiltinFloatTest, ModfVector_f16) { auto* fract = ty->Members()[0]; ASSERT_TRUE(fract->Type()->Is()); EXPECT_EQ(fract->Type()->As()->Width(), 3u); - EXPECT_TRUE(fract->Type()->As()->type()->Is()); + EXPECT_TRUE(fract->Type()->As()->type()->Is()); EXPECT_EQ(fract->Offset(), 0u); EXPECT_EQ(fract->Size(), 6u); EXPECT_EQ(fract->Align(), 8u); @@ -1307,7 +1307,7 @@ TEST_F(ResolverBuiltinFloatTest, ModfVector_f16) { auto* whole = ty->Members()[1]; ASSERT_TRUE(whole->Type()->Is()); EXPECT_EQ(whole->Type()->As()->Width(), 3u); - EXPECT_TRUE(whole->Type()->As()->type()->Is()); + EXPECT_TRUE(whole->Type()->As()->type()->Is()); EXPECT_EQ(whole->Offset(), 8u); EXPECT_EQ(whole->Size(), 6u); EXPECT_EQ(whole->Align(), 8u); @@ -1389,7 +1389,7 @@ TEST_F(ResolverBuiltinFloatTest, Normalize_Vector_f32) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_float_vector()); EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); - EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); } TEST_F(ResolverBuiltinFloatTest, Normalize_Vector_f16) { @@ -1403,7 +1403,7 @@ TEST_F(ResolverBuiltinFloatTest, Normalize_Vector_f16) { ASSERT_NE(TypeOf(call), nullptr); EXPECT_TRUE(TypeOf(call)->is_float_vector()); EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); - EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); } TEST_F(ResolverBuiltinFloatTest, Normalize_Error_NoParams) { @@ -1464,7 +1464,7 @@ TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, OneParams_Scalar_i32) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } else { // Invalid parameter count. EXPECT_FALSE(r()->Resolve()); @@ -1488,7 +1488,7 @@ TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, OneParams_Vector_i32) { EXPECT_TRUE(TypeOf(call)->is_signed_integer_vector()); EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); ASSERT_NE(TypeOf(call)->As()->type(), nullptr); - EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); } else { // Invalid parameter count. EXPECT_FALSE(r()->Resolve()); @@ -1509,7 +1509,7 @@ TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, OneParams_Scalar_u32) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } else { // Invalid parameter count. EXPECT_FALSE(r()->Resolve()); @@ -1533,7 +1533,7 @@ TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, OneParams_Vector_u32) { EXPECT_TRUE(TypeOf(call)->is_unsigned_integer_vector()); EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); ASSERT_NE(TypeOf(call)->As()->type(), nullptr); - EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); } else { // Invalid parameter count. EXPECT_FALSE(r()->Resolve()); @@ -1554,7 +1554,7 @@ TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, TwoParams_Scalar_i32) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } else { // Invalid parameter count. EXPECT_FALSE(r()->Resolve()); @@ -1578,7 +1578,7 @@ TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, TwoParams_Vector_i32) { EXPECT_TRUE(TypeOf(call)->is_signed_integer_vector()); EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); ASSERT_NE(TypeOf(call)->As()->type(), nullptr); - EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); } else { // Invalid parameter count. EXPECT_FALSE(r()->Resolve()); @@ -1599,7 +1599,7 @@ TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, TwoParams_Scalar_u32) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } else { // Invalid parameter count. EXPECT_FALSE(r()->Resolve()); @@ -1623,7 +1623,7 @@ TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, TwoParams_Vector_u32) { EXPECT_TRUE(TypeOf(call)->is_unsigned_integer_vector()); EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); ASSERT_NE(TypeOf(call)->As()->type(), nullptr); - EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); } else { // Invalid parameter count. EXPECT_FALSE(r()->Resolve()); @@ -1644,7 +1644,7 @@ TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, ThreeParams_Scalar_i32) EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } else { // Invalid parameter count. EXPECT_FALSE(r()->Resolve()); @@ -1669,7 +1669,7 @@ TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, ThreeParams_Vector_i32) EXPECT_TRUE(TypeOf(call)->is_signed_integer_vector()); EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); ASSERT_NE(TypeOf(call)->As()->type(), nullptr); - EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); } else { // Invalid parameter count. EXPECT_FALSE(r()->Resolve()); @@ -1691,7 +1691,7 @@ TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, ThreeParams_Scalar_u32) EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } else { // Invalid parameter count. EXPECT_FALSE(r()->Resolve()); @@ -1716,7 +1716,7 @@ TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, ThreeParams_Vector_u32) EXPECT_TRUE(TypeOf(call)->is_unsigned_integer_vector()); EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); ASSERT_NE(TypeOf(call)->As()->type(), nullptr); - EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); } else { // Invalid parameter count. EXPECT_FALSE(r()->Resolve()); @@ -1738,7 +1738,7 @@ TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, FourParams_Scalar_i32) EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } else { // Invalid parameter count. EXPECT_FALSE(r()->Resolve()); @@ -1763,7 +1763,7 @@ TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, FourParams_Vector_i32) EXPECT_TRUE(TypeOf(call)->is_signed_integer_vector()); EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); ASSERT_NE(TypeOf(call)->As()->type(), nullptr); - EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); } else { // Invalid parameter count. EXPECT_FALSE(r()->Resolve()); @@ -1785,7 +1785,7 @@ TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, FourParams_Scalar_u32) EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } else { // Invalid parameter count. EXPECT_FALSE(r()->Resolve()); @@ -1810,7 +1810,7 @@ TEST_P(ResolverBuiltinTest_IntegerBuiltin_IdenticalType, FourParams_Vector_u32) EXPECT_TRUE(TypeOf(call)->is_unsigned_integer_vector()); EXPECT_EQ(TypeOf(call)->As()->Width(), 3u); ASSERT_NE(TypeOf(call)->As()->type(), nullptr); - EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(call)->As()->type()->Is()); } else { // Invalid parameter count. EXPECT_FALSE(r()->Resolve()); @@ -1852,7 +1852,7 @@ TEST_F(ResolverBuiltinTest, Determinant_2x2_f32) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_F(ResolverBuiltinTest, Determinant_2x2_f16) { @@ -1866,7 +1866,7 @@ TEST_F(ResolverBuiltinTest, Determinant_2x2_f16) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_F(ResolverBuiltinTest, Determinant_3x3_f32) { @@ -1878,7 +1878,7 @@ TEST_F(ResolverBuiltinTest, Determinant_3x3_f32) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_F(ResolverBuiltinTest, Determinant_3x3_f16) { @@ -1892,7 +1892,7 @@ TEST_F(ResolverBuiltinTest, Determinant_3x3_f16) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_F(ResolverBuiltinTest, Determinant_4x4_f32) { @@ -1904,7 +1904,7 @@ TEST_F(ResolverBuiltinTest, Determinant_4x4_f32) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_F(ResolverBuiltinTest, Determinant_4x4_f16) { @@ -1918,7 +1918,7 @@ TEST_F(ResolverBuiltinTest, Determinant_4x4_f16) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_F(ResolverBuiltinTest, Determinant_NotSquare) { @@ -1965,7 +1965,7 @@ TEST_F(ResolverBuiltinTest, Dot_Vec2_f32) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(expr), nullptr); - EXPECT_TRUE(TypeOf(expr)->Is()); + EXPECT_TRUE(TypeOf(expr)->Is()); } TEST_F(ResolverBuiltinTest, Dot_Vec2_f16) { @@ -1979,7 +1979,7 @@ TEST_F(ResolverBuiltinTest, Dot_Vec2_f16) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(expr), nullptr); - EXPECT_TRUE(TypeOf(expr)->Is()); + EXPECT_TRUE(TypeOf(expr)->Is()); } TEST_F(ResolverBuiltinTest, Dot_Vec3_i32) { @@ -1991,7 +1991,7 @@ TEST_F(ResolverBuiltinTest, Dot_Vec3_i32) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(expr), nullptr); - EXPECT_TRUE(TypeOf(expr)->Is()); + EXPECT_TRUE(TypeOf(expr)->Is()); } TEST_F(ResolverBuiltinTest, Dot_Vec4_u32) { @@ -2003,7 +2003,7 @@ TEST_F(ResolverBuiltinTest, Dot_Vec4_u32) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(expr), nullptr); - EXPECT_TRUE(TypeOf(expr)->Is()); + EXPECT_TRUE(TypeOf(expr)->Is()); } TEST_F(ResolverBuiltinTest, Dot_Error_Scalar) { @@ -2039,7 +2039,7 @@ TEST_P(ResolverBuiltinDerivativeTest, Scalar) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(expr), nullptr); - ASSERT_TRUE(TypeOf(expr)->Is()); + ASSERT_TRUE(TypeOf(expr)->Is()); } TEST_P(ResolverBuiltinDerivativeTest, Vector) { @@ -2054,7 +2054,7 @@ TEST_P(ResolverBuiltinDerivativeTest, Vector) { ASSERT_NE(TypeOf(expr), nullptr); ASSERT_TRUE(TypeOf(expr)->Is()); - EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); EXPECT_EQ(TypeOf(expr)->As()->Width(), 4u); } @@ -2182,11 +2182,11 @@ TEST_P(ResolverBuiltinTest_SampledTextureOperation, TextureLoadSampled) { ASSERT_NE(TypeOf(expr), nullptr); ASSERT_TRUE(TypeOf(expr)->Is()); if (type == Texture::kF32) { - EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); } else if (type == Texture::kI32) { - EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); } else { - EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(expr)->As()->type()->Is()); } EXPECT_EQ(TypeOf(expr)->As()->Width(), 4u); } @@ -2470,7 +2470,7 @@ TEST_P(ResolverBuiltinTest_Texture, Call) { default: FAIL() << "invalid texture dimensions: " << param.texture_dimension; case ast::TextureDimension::k1d: - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); break; case ast::TextureDimension::k2d: case ast::TextureDimension::k2dArray: @@ -2479,45 +2479,45 @@ TEST_P(ResolverBuiltinTest_Texture, Call) { auto* vec = As(TypeOf(call)); ASSERT_NE(vec, nullptr); EXPECT_EQ(vec->Width(), 2u); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); break; } case ast::TextureDimension::k3d: { auto* vec = As(TypeOf(call)); ASSERT_NE(vec, nullptr); EXPECT_EQ(vec->Width(), 3u); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); break; } } } else if (std::string(param.function) == "textureNumLayers") { - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } else if (std::string(param.function) == "textureNumLevels") { - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } else if (std::string(param.function) == "textureNumSamples") { - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } else if (std::string(param.function) == "textureStore") { - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } else if (std::string(param.function) == "textureGather") { auto* vec = As(TypeOf(call)); ASSERT_NE(vec, nullptr); EXPECT_EQ(vec->Width(), 4u); switch (param.texture_data_type) { case ast::builtin::test::TextureDataType::kF32: - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); break; case ast::builtin::test::TextureDataType::kU32: - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); break; case ast::builtin::test::TextureDataType::kI32: - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); break; } } else if (std::string(param.function) == "textureGatherCompare") { auto* vec = As(TypeOf(call)); ASSERT_NE(vec, nullptr); EXPECT_EQ(vec->Width(), 4u); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); } else { switch (param.texture_kind) { case ast::builtin::test::TextureKind::kRegular: @@ -2527,20 +2527,20 @@ TEST_P(ResolverBuiltinTest_Texture, Call) { ASSERT_NE(vec, nullptr); switch (param.texture_data_type) { case ast::builtin::test::TextureDataType::kF32: - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); break; case ast::builtin::test::TextureDataType::kU32: - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); break; case ast::builtin::test::TextureDataType::kI32: - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); break; } break; } case ast::builtin::test::TextureKind::kDepth: case ast::builtin::test::TextureKind::kDepthMultisampled: { - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); break; } } @@ -2574,7 +2574,7 @@ TEST_P(ResolverBuiltinTest_DataPacking, InferType) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_P(ResolverBuiltinTest_DataPacking, Error_IncorrectParamType) { @@ -2675,7 +2675,7 @@ TEST_P(ResolverBuiltinTest_Barrier, InferType) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_P(ResolverBuiltinTest_Barrier, Error_TooManyParams) { diff --git a/src/tint/resolver/builtins_validation_test.cc b/src/tint/resolver/builtins_validation_test.cc index d60b5b1afa..9616627b29 100644 --- a/src/tint/resolver/builtins_validation_test.cc +++ b/src/tint/resolver/builtins_validation_test.cc @@ -894,8 +894,8 @@ TEST_F(ResolverBuiltinsValidationTest, Frexp_Scalar) { ASSERT_TRUE(res_ty != nullptr); auto members = res_ty->Members(); ASSERT_EQ(members.Length(), 2u); - EXPECT_TRUE(members[0]->Type()->Is()); - EXPECT_TRUE(members[1]->Type()->Is()); + EXPECT_TRUE(members[0]->Type()->Is()); + EXPECT_TRUE(members[1]->Type()->Is()); } TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec2) { @@ -910,9 +910,9 @@ TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec2) { ASSERT_TRUE(members[0]->Type()->Is()); ASSERT_TRUE(members[1]->Type()->Is()); EXPECT_EQ(members[0]->Type()->As()->Width(), 2u); - EXPECT_TRUE(members[0]->Type()->As()->type()->Is()); + EXPECT_TRUE(members[0]->Type()->As()->type()->Is()); EXPECT_EQ(members[1]->Type()->As()->Width(), 2u); - EXPECT_TRUE(members[1]->Type()->As()->type()->Is()); + EXPECT_TRUE(members[1]->Type()->As()->type()->Is()); } TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec3) { @@ -927,9 +927,9 @@ TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec3) { ASSERT_TRUE(members[0]->Type()->Is()); ASSERT_TRUE(members[1]->Type()->Is()); EXPECT_EQ(members[0]->Type()->As()->Width(), 3u); - EXPECT_TRUE(members[0]->Type()->As()->type()->Is()); + EXPECT_TRUE(members[0]->Type()->As()->type()->Is()); EXPECT_EQ(members[1]->Type()->As()->Width(), 3u); - EXPECT_TRUE(members[1]->Type()->As()->type()->Is()); + EXPECT_TRUE(members[1]->Type()->As()->type()->Is()); } TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec4) { @@ -944,9 +944,9 @@ TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec4) { ASSERT_TRUE(members[0]->Type()->Is()); ASSERT_TRUE(members[1]->Type()->Is()); EXPECT_EQ(members[0]->Type()->As()->Width(), 4u); - EXPECT_TRUE(members[0]->Type()->As()->type()->Is()); + EXPECT_TRUE(members[0]->Type()->As()->type()->Is()); EXPECT_EQ(members[1]->Type()->As()->Width(), 4u); - EXPECT_TRUE(members[1]->Type()->As()->type()->Is()); + EXPECT_TRUE(members[1]->Type()->As()->type()->Is()); } TEST_F(ResolverBuiltinsValidationTest, Modf_Scalar) { @@ -958,8 +958,8 @@ TEST_F(ResolverBuiltinsValidationTest, Modf_Scalar) { ASSERT_TRUE(res_ty != nullptr); auto members = res_ty->Members(); ASSERT_EQ(members.Length(), 2u); - EXPECT_TRUE(members[0]->Type()->Is()); - EXPECT_TRUE(members[1]->Type()->Is()); + EXPECT_TRUE(members[0]->Type()->Is()); + EXPECT_TRUE(members[1]->Type()->Is()); } TEST_F(ResolverBuiltinsValidationTest, Modf_Vec2) { @@ -974,9 +974,9 @@ TEST_F(ResolverBuiltinsValidationTest, Modf_Vec2) { ASSERT_TRUE(members[0]->Type()->Is()); ASSERT_TRUE(members[1]->Type()->Is()); EXPECT_EQ(members[0]->Type()->As()->Width(), 2u); - EXPECT_TRUE(members[0]->Type()->As()->type()->Is()); + EXPECT_TRUE(members[0]->Type()->As()->type()->Is()); EXPECT_EQ(members[1]->Type()->As()->Width(), 2u); - EXPECT_TRUE(members[1]->Type()->As()->type()->Is()); + EXPECT_TRUE(members[1]->Type()->As()->type()->Is()); } TEST_F(ResolverBuiltinsValidationTest, Modf_Vec3) { @@ -991,9 +991,9 @@ TEST_F(ResolverBuiltinsValidationTest, Modf_Vec3) { ASSERT_TRUE(members[0]->Type()->Is()); ASSERT_TRUE(members[1]->Type()->Is()); EXPECT_EQ(members[0]->Type()->As()->Width(), 3u); - EXPECT_TRUE(members[0]->Type()->As()->type()->Is()); + EXPECT_TRUE(members[0]->Type()->As()->type()->Is()); EXPECT_EQ(members[1]->Type()->As()->Width(), 3u); - EXPECT_TRUE(members[1]->Type()->As()->type()->Is()); + EXPECT_TRUE(members[1]->Type()->As()->type()->Is()); } TEST_F(ResolverBuiltinsValidationTest, Modf_Vec4) { @@ -1008,9 +1008,9 @@ TEST_F(ResolverBuiltinsValidationTest, Modf_Vec4) { ASSERT_TRUE(members[0]->Type()->Is()); ASSERT_TRUE(members[1]->Type()->Is()); EXPECT_EQ(members[0]->Type()->As()->Width(), 4u); - EXPECT_TRUE(members[0]->Type()->As()->type()->Is()); + EXPECT_TRUE(members[0]->Type()->As()->type()->Is()); EXPECT_EQ(members[1]->Type()->As()->Width(), 4u); - EXPECT_TRUE(members[1]->Type()->As()->type()->Is()); + EXPECT_TRUE(members[1]->Type()->As()->type()->Is()); } TEST_F(ResolverBuiltinsValidationTest, Cross_Float_Vec3) { @@ -1111,7 +1111,7 @@ TEST_P(FloatAllMatching, Scalar) { }); EXPECT_TRUE(r()->Resolve()) << r()->error(); - EXPECT_TRUE(TypeOf(builtin)->Is()); + EXPECT_TRUE(TypeOf(builtin)->Is()); } TEST_P(FloatAllMatching, Vec2) { @@ -1235,7 +1235,7 @@ TEST_P(IntegerAllMatching, ScalarUnsigned) { WrapInFunction(builtin); EXPECT_TRUE(r()->Resolve()) << r()->error(); - EXPECT_TRUE(TypeOf(builtin)->Is()); + EXPECT_TRUE(TypeOf(builtin)->Is()); } TEST_P(IntegerAllMatching, Vec2Unsigned) { @@ -1295,7 +1295,7 @@ TEST_P(IntegerAllMatching, ScalarSigned) { WrapInFunction(builtin); EXPECT_TRUE(r()->Resolve()) << r()->error(); - EXPECT_TRUE(TypeOf(builtin)->Is()); + EXPECT_TRUE(TypeOf(builtin)->Is()); } TEST_P(IntegerAllMatching, Vec2Signed) { diff --git a/src/tint/resolver/const_eval.cc b/src/tint/resolver/const_eval.cc index c94e8983ea..682e0a341c 100644 --- a/src/tint/resolver/const_eval.cc +++ b/src/tint/resolver/const_eval.cc @@ -24,18 +24,18 @@ #include "src/tint/program_builder.h" #include "src/tint/sem/array.h" -#include "src/tint/sem/bool.h" #include "src/tint/sem/constant.h" -#include "src/tint/sem/f16.h" -#include "src/tint/sem/f32.h" -#include "src/tint/sem/i32.h" #include "src/tint/sem/matrix.h" #include "src/tint/sem/member_accessor_expression.h" #include "src/tint/sem/type_initializer.h" -#include "src/tint/sem/u32.h" #include "src/tint/sem/vector.h" #include "src/tint/type/abstract_float.h" #include "src/tint/type/abstract_int.h" +#include "src/tint/type/bool.h" +#include "src/tint/type/f16.h" +#include "src/tint/type/f32.h" +#include "src/tint/type/i32.h" +#include "src/tint/type/u32.h" #include "src/tint/utils/bitcast.h" #include "src/tint/utils/compiler_macros.h" #include "src/tint/utils/map.h" @@ -59,8 +59,8 @@ template auto Dispatch_iu32(F&& f, CONSTANTS&&... cs) { return Switch( First(cs...)->Type(), // - [&](const sem::I32*) { return f(cs->template As()...); }, - [&](const sem::U32*) { return f(cs->template As()...); }); + [&](const type::I32*) { return f(cs->template As()...); }, + [&](const type::U32*) { return f(cs->template As()...); }); } /// Helper that calls `f` passing in the value of all `cs`. @@ -70,8 +70,8 @@ auto Dispatch_ia_iu32(F&& f, CONSTANTS&&... cs) { return Switch( First(cs...)->Type(), // [&](const type::AbstractInt*) { return f(cs->template As()...); }, - [&](const sem::I32*) { return f(cs->template As()...); }, - [&](const sem::U32*) { return f(cs->template As()...); }); + [&](const type::I32*) { return f(cs->template As()...); }, + [&](const type::U32*) { return f(cs->template As()...); }); } /// Helper that calls `f` passing in the value of all `cs`. @@ -81,9 +81,9 @@ auto Dispatch_ia_iu32_bool(F&& f, CONSTANTS&&... cs) { return Switch( First(cs...)->Type(), // [&](const type::AbstractInt*) { return f(cs->template As()...); }, - [&](const sem::I32*) { return f(cs->template As()...); }, - [&](const sem::U32*) { return f(cs->template As()...); }, - [&](const sem::Bool*) { return f(cs->template As()...); }); + [&](const type::I32*) { return f(cs->template As()...); }, + [&](const type::U32*) { return f(cs->template As()...); }, + [&](const type::Bool*) { return f(cs->template As()...); }); } /// Helper that calls `f` passing in the value of all `cs`. @@ -94,9 +94,9 @@ auto Dispatch_fia_fi32_f16(F&& f, CONSTANTS&&... cs) { First(cs...)->Type(), // [&](const type::AbstractInt*) { return f(cs->template As()...); }, [&](const type::AbstractFloat*) { return f(cs->template As()...); }, - [&](const sem::F32*) { return f(cs->template As()...); }, - [&](const sem::I32*) { return f(cs->template As()...); }, - [&](const sem::F16*) { return f(cs->template As()...); }); + [&](const type::F32*) { return f(cs->template As()...); }, + [&](const type::I32*) { return f(cs->template As()...); }, + [&](const type::F16*) { return f(cs->template As()...); }); } /// Helper that calls `f` passing in the value of all `cs`. @@ -107,10 +107,10 @@ auto Dispatch_fia_fiu32_f16(F&& f, CONSTANTS&&... cs) { First(cs...)->Type(), // [&](const type::AbstractInt*) { return f(cs->template As()...); }, [&](const type::AbstractFloat*) { return f(cs->template As()...); }, - [&](const sem::F32*) { return f(cs->template As()...); }, - [&](const sem::I32*) { return f(cs->template As()...); }, - [&](const sem::U32*) { return f(cs->template As()...); }, - [&](const sem::F16*) { return f(cs->template As()...); }); + [&](const type::F32*) { return f(cs->template As()...); }, + [&](const type::I32*) { return f(cs->template As()...); }, + [&](const type::U32*) { return f(cs->template As()...); }, + [&](const type::F16*) { return f(cs->template As()...); }); } /// Helper that calls `f` passing in the value of all `cs`. @@ -121,11 +121,11 @@ auto Dispatch_fia_fiu32_f16_bool(F&& f, CONSTANTS&&... cs) { First(cs...)->Type(), // [&](const type::AbstractInt*) { return f(cs->template As()...); }, [&](const type::AbstractFloat*) { return f(cs->template As()...); }, - [&](const sem::F32*) { return f(cs->template As()...); }, - [&](const sem::I32*) { return f(cs->template As()...); }, - [&](const sem::U32*) { return f(cs->template As()...); }, - [&](const sem::F16*) { return f(cs->template As()...); }, - [&](const sem::Bool*) { return f(cs->template As()...); }); + [&](const type::F32*) { return f(cs->template As()...); }, + [&](const type::I32*) { return f(cs->template As()...); }, + [&](const type::U32*) { return f(cs->template As()...); }, + [&](const type::F16*) { return f(cs->template As()...); }, + [&](const type::Bool*) { return f(cs->template As()...); }); } /// Helper that calls `f` passing in the value of all `cs`. @@ -135,8 +135,8 @@ auto Dispatch_fa_f32_f16(F&& f, CONSTANTS&&... cs) { return Switch( First(cs...)->Type(), // [&](const type::AbstractFloat*) { return f(cs->template As()...); }, - [&](const sem::F32*) { return f(cs->template As()...); }, - [&](const sem::F16*) { return f(cs->template As()...); }); + [&](const type::F32*) { return f(cs->template As()...); }, + [&](const type::F16*) { return f(cs->template As()...); }); } /// Helper that calls `f` passing in the value of all `cs`. @@ -148,7 +148,7 @@ auto Dispatch_bool(F&& f, CONSTANTS&&... cs) { /// ZeroTypeDispatch is a helper for calling the function `f`, passing a single zero-value argument /// of the C++ type that corresponds to the type::Type `type`. For example, calling -/// `ZeroTypeDispatch()` with a type of `sem::I32*` will call the function f with a single argument +/// `ZeroTypeDispatch()` with a type of `type::I32*` will call the function f with a single argument /// of `i32(0)`. /// @returns the value returned by calling `f`. /// @note `type` must be a scalar or abstract numeric type. Other types will not call `f`, and will @@ -159,11 +159,11 @@ auto ZeroTypeDispatch(const type::Type* type, F&& f) { type, // [&](const type::AbstractInt*) { return f(AInt(0)); }, // [&](const type::AbstractFloat*) { return f(AFloat(0)); }, // - [&](const sem::I32*) { return f(i32(0)); }, // - [&](const sem::U32*) { return f(u32(0)); }, // - [&](const sem::F32*) { return f(f32(0)); }, // - [&](const sem::F16*) { return f(f16(0)); }, // - [&](const sem::Bool*) { return f(static_cast(0)); }); + [&](const type::I32*) { return f(i32(0)); }, // + [&](const type::U32*) { return f(u32(0)); }, // + [&](const type::F32*) { return f(f32(0)); }, // + [&](const type::F16*) { return f(f16(0)); }, // + [&](const type::Bool*) { return f(static_cast(0)); }); } /// @returns `value` if `T` is not a Number, otherwise ValueOf returns the inner value of the @@ -1954,7 +1954,7 @@ ConstEval::Result ConstEval::OpShiftLeft(const type::Type* ty, return Dispatch_ia_iu32(create, c0, c1); }; - if (!type::Type::DeepestElementOf(args[1]->Type())->Is()) { + if (!type::Type::DeepestElementOf(args[1]->Type())->Is()) { TINT_ICE(Resolver, builder.Diagnostics()) << "Element type of rhs of ShiftLeft must be a u32"; return utils::Failure; @@ -2019,7 +2019,7 @@ ConstEval::Result ConstEval::OpShiftRight(const type::Type* ty, return Dispatch_ia_iu32(create, c0, c1); }; - if (!type::Type::DeepestElementOf(args[1]->Type())->Is()) { + if (!type::Type::DeepestElementOf(args[1]->Type())->Is()) { TINT_ICE(Resolver, builder.Diagnostics()) << "Element type of rhs of ShiftLeft must be a u32"; return utils::Failure; @@ -2647,16 +2647,16 @@ ConstEval::Result ConstEval::frexp(const type::Type* ty, double fract = std::frexp(s->As(), &exp); return Switch( s->Type(), - [&](const sem::F32*) { + [&](const type::F32*) { return FractExp{ - CreateElement(builder, source, builder.create(), f32(fract)), - CreateElement(builder, source, builder.create(), i32(exp)), + CreateElement(builder, source, builder.create(), f32(fract)), + CreateElement(builder, source, builder.create(), i32(exp)), }; }, - [&](const sem::F16*) { + [&](const type::F16*) { return FractExp{ - CreateElement(builder, source, builder.create(), f16(fract)), - CreateElement(builder, source, builder.create(), i32(exp)), + CreateElement(builder, source, builder.create(), f16(fract)), + CreateElement(builder, source, builder.create(), i32(exp)), }; }, [&](const type::AbstractFloat*) { diff --git a/src/tint/resolver/const_eval_construction_test.cc b/src/tint/resolver/const_eval_construction_test.cc index fe323c2b2b..bf9cb62205 100644 --- a/src/tint/resolver/const_eval_construction_test.cc +++ b/src/tint/resolver/const_eval_construction_test.cc @@ -27,7 +27,7 @@ TEST_F(ResolverConstEvalTest, Scalar_i32) { auto* sem = Sem().Get(expr); ASSERT_NE(sem, nullptr); - EXPECT_TRUE(sem->Type()->Is()); + EXPECT_TRUE(sem->Type()->Is()); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue()->AllEqual()); EXPECT_FALSE(sem->ConstantValue()->AnyZero()); @@ -43,7 +43,7 @@ TEST_F(ResolverConstEvalTest, Scalar_u32) { auto* sem = Sem().Get(expr); ASSERT_NE(sem, nullptr); - EXPECT_TRUE(sem->Type()->Is()); + EXPECT_TRUE(sem->Type()->Is()); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue()->AllEqual()); EXPECT_FALSE(sem->ConstantValue()->AnyZero()); @@ -59,7 +59,7 @@ TEST_F(ResolverConstEvalTest, Scalar_f32) { auto* sem = Sem().Get(expr); ASSERT_NE(sem, nullptr); - EXPECT_TRUE(sem->Type()->Is()); + EXPECT_TRUE(sem->Type()->Is()); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue()->AllEqual()); EXPECT_FALSE(sem->ConstantValue()->AnyZero()); @@ -77,7 +77,7 @@ TEST_F(ResolverConstEvalTest, Scalar_f16) { auto* sem = Sem().Get(expr); EXPECT_NE(sem, nullptr); - EXPECT_TRUE(sem->Type()->Is()); + EXPECT_TRUE(sem->Type()->Is()); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue()->AllEqual()); EXPECT_FALSE(sem->ConstantValue()->AnyZero()); @@ -94,7 +94,7 @@ TEST_F(ResolverConstEvalTest, Scalar_bool) { auto* sem = Sem().Get(expr); ASSERT_NE(sem, nullptr); - EXPECT_TRUE(sem->Type()->Is()); + EXPECT_TRUE(sem->Type()->Is()); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue()->AllEqual()); EXPECT_FALSE(sem->ConstantValue()->AnyZero()); @@ -112,7 +112,7 @@ TEST_F(ResolverConstEvalTest, Vec3_ZeroInit_i32) { ASSERT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue()->AllEqual()); @@ -145,7 +145,7 @@ TEST_F(ResolverConstEvalTest, Vec3_ZeroInit_u32) { ASSERT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue()->AllEqual()); @@ -178,7 +178,7 @@ TEST_F(ResolverConstEvalTest, Vec3_ZeroInit_f32) { ASSERT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue()->AllEqual()); @@ -213,7 +213,7 @@ TEST_F(ResolverConstEvalTest, Vec3_ZeroInit_f16) { EXPECT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue()->AllEqual()); @@ -246,7 +246,7 @@ TEST_F(ResolverConstEvalTest, Vec3_ZeroInit_bool) { ASSERT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue()->AllEqual()); @@ -279,7 +279,7 @@ TEST_F(ResolverConstEvalTest, Vec3_Splat_i32) { ASSERT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue()->AllEqual()); @@ -312,7 +312,7 @@ TEST_F(ResolverConstEvalTest, Vec3_Splat_u32) { ASSERT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue()->AllEqual()); @@ -345,7 +345,7 @@ TEST_F(ResolverConstEvalTest, Vec3_Splat_f32) { ASSERT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue()->AllEqual()); @@ -380,7 +380,7 @@ TEST_F(ResolverConstEvalTest, Vec3_Splat_f16) { EXPECT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue()->AllEqual()); @@ -414,7 +414,7 @@ TEST_F(ResolverConstEvalTest, Vec3_Splat_bool) { ASSERT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue()->AllEqual()); @@ -447,7 +447,7 @@ TEST_F(ResolverConstEvalTest, Vec3_FullConstruct_i32) { ASSERT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_FALSE(sem->ConstantValue()->AllEqual()); @@ -480,7 +480,7 @@ TEST_F(ResolverConstEvalTest, Vec3_FullConstruct_u32) { ASSERT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_FALSE(sem->ConstantValue()->AllEqual()); @@ -513,7 +513,7 @@ TEST_F(ResolverConstEvalTest, Vec3_FullConstruct_f32) { ASSERT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_FALSE(sem->ConstantValue()->AllEqual()); @@ -548,7 +548,7 @@ TEST_F(ResolverConstEvalTest, Vec3_FullConstruct_f16) { EXPECT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_FALSE(sem->ConstantValue()->AllEqual()); @@ -581,7 +581,7 @@ TEST_F(ResolverConstEvalTest, Vec3_FullConstruct_bool) { ASSERT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_FALSE(sem->ConstantValue()->AllEqual()); @@ -614,7 +614,7 @@ TEST_F(ResolverConstEvalTest, Vec3_MixConstruct_i32) { ASSERT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_FALSE(sem->ConstantValue()->AllEqual()); @@ -647,7 +647,7 @@ TEST_F(ResolverConstEvalTest, Vec3_MixConstruct_u32) { ASSERT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_FALSE(sem->ConstantValue()->AllEqual()); @@ -680,7 +680,7 @@ TEST_F(ResolverConstEvalTest, Vec3_MixConstruct_f32) { ASSERT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_FALSE(sem->ConstantValue()->AllEqual()); @@ -713,7 +713,7 @@ TEST_F(ResolverConstEvalTest, Vec3_MixConstruct_f32_all_10) { EXPECT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue()->AllEqual()); @@ -746,7 +746,7 @@ TEST_F(ResolverConstEvalTest, Vec3_MixConstruct_f32_all_positive_0) { EXPECT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue()->AllEqual()); @@ -779,7 +779,7 @@ TEST_F(ResolverConstEvalTest, Vec3_MixConstruct_f32_all_negative_0) { EXPECT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue()->AllEqual()); @@ -812,7 +812,7 @@ TEST_F(ResolverConstEvalTest, Vec3_MixConstruct_f32_mixed_sign_0) { EXPECT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_FALSE(sem->ConstantValue()->AllEqual()); @@ -847,7 +847,7 @@ TEST_F(ResolverConstEvalTest, Vec3_MixConstruct_f16) { EXPECT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_FALSE(sem->ConstantValue()->AllEqual()); @@ -882,7 +882,7 @@ TEST_F(ResolverConstEvalTest, Vec3_MixConstruct_f16_all_10) { EXPECT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue()->AllEqual()); @@ -917,7 +917,7 @@ TEST_F(ResolverConstEvalTest, Vec3_MixConstruct_f16_all_positive_0) { EXPECT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue()->AllEqual()); @@ -952,7 +952,7 @@ TEST_F(ResolverConstEvalTest, Vec3_MixConstruct_f16_all_negative_0) { EXPECT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue()->AllEqual()); @@ -987,7 +987,7 @@ TEST_F(ResolverConstEvalTest, Vec3_MixConstruct_f16_mixed_sign_0) { EXPECT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_FALSE(sem->ConstantValue()->AllEqual()); @@ -1020,7 +1020,7 @@ TEST_F(ResolverConstEvalTest, Vec3_MixConstruct_bool) { ASSERT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_FALSE(sem->ConstantValue()->AllEqual()); @@ -1053,7 +1053,7 @@ TEST_F(ResolverConstEvalTest, Vec3_MixConstruct_all_true) { ASSERT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue()->AllEqual()); @@ -1086,7 +1086,7 @@ TEST_F(ResolverConstEvalTest, Vec3_MixConstruct_all_false) { ASSERT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue()->AllEqual()); @@ -1119,7 +1119,7 @@ TEST_F(ResolverConstEvalTest, Mat2x3_ZeroInit_f32) { ASSERT_NE(sem, nullptr); auto* mat = sem->Type()->As(); ASSERT_NE(mat, nullptr); - EXPECT_TRUE(mat->type()->Is()); + EXPECT_TRUE(mat->type()->Is()); EXPECT_EQ(mat->columns(), 2u); EXPECT_EQ(mat->rows(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); @@ -1170,7 +1170,7 @@ TEST_F(ResolverConstEvalTest, Mat2x3_ZeroInit_f16) { EXPECT_NE(sem, nullptr); auto* mat = sem->Type()->As(); ASSERT_NE(mat, nullptr); - EXPECT_TRUE(mat->type()->Is()); + EXPECT_TRUE(mat->type()->Is()); EXPECT_EQ(mat->columns(), 2u); EXPECT_EQ(mat->rows(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); @@ -1219,7 +1219,7 @@ TEST_F(ResolverConstEvalTest, Mat3x2_Construct_Scalars_af) { ASSERT_NE(sem, nullptr); auto* mat = sem->Type()->As(); ASSERT_NE(mat, nullptr); - EXPECT_TRUE(mat->type()->Is()); + EXPECT_TRUE(mat->type()->Is()); EXPECT_EQ(mat->columns(), 3u); EXPECT_EQ(mat->rows(), 2u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); @@ -1271,7 +1271,7 @@ TEST_F(ResolverConstEvalTest, Mat3x2_Construct_Columns_af) { ASSERT_NE(sem, nullptr); auto* mat = sem->Type()->As(); ASSERT_NE(mat, nullptr); - EXPECT_TRUE(mat->type()->Is()); + EXPECT_TRUE(mat->type()->Is()); EXPECT_EQ(mat->columns(), 3u); EXPECT_EQ(mat->rows(), 2u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); @@ -1320,7 +1320,7 @@ TEST_F(ResolverConstEvalTest, Array_i32_Zero) { ASSERT_NE(sem, nullptr); auto* arr = sem->Type()->As(); ASSERT_NE(arr, nullptr); - EXPECT_TRUE(arr->ElemType()->Is()); + EXPECT_TRUE(arr->ElemType()->Is()); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue()->AllEqual()); EXPECT_TRUE(sem->ConstantValue()->AnyZero()); @@ -1357,7 +1357,7 @@ TEST_F(ResolverConstEvalTest, Array_f32_Zero) { ASSERT_NE(sem, nullptr); auto* arr = sem->Type()->As(); ASSERT_NE(arr, nullptr); - EXPECT_TRUE(arr->ElemType()->Is()); + EXPECT_TRUE(arr->ElemType()->Is()); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue()->AllEqual()); EXPECT_TRUE(sem->ConstantValue()->AnyZero()); @@ -1482,7 +1482,7 @@ TEST_F(ResolverConstEvalTest, Array_i32_Elements) { ASSERT_NE(sem, nullptr); auto* arr = sem->Type()->As(); ASSERT_NE(arr, nullptr); - EXPECT_TRUE(arr->ElemType()->Is()); + EXPECT_TRUE(arr->ElemType()->Is()); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_FALSE(sem->ConstantValue()->AllEqual()); EXPECT_FALSE(sem->ConstantValue()->AnyZero()); @@ -1519,7 +1519,7 @@ TEST_F(ResolverConstEvalTest, Array_f32_Elements) { ASSERT_NE(sem, nullptr); auto* arr = sem->Type()->As(); ASSERT_NE(arr, nullptr); - EXPECT_TRUE(arr->ElemType()->Is()); + EXPECT_TRUE(arr->ElemType()->Is()); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_FALSE(sem->ConstantValue()->AllEqual()); EXPECT_FALSE(sem->ConstantValue()->AnyZero()); @@ -1635,19 +1635,19 @@ TEST_F(ResolverConstEvalTest, Struct_I32s_ZeroInit) { EXPECT_TRUE(sem->ConstantValue()->Index(0)->AllEqual()); EXPECT_TRUE(sem->ConstantValue()->Index(0)->AnyZero()); EXPECT_TRUE(sem->ConstantValue()->Index(0)->AllZero()); - EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->Is()); + EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->Is()); EXPECT_EQ(sem->ConstantValue()->Index(0)->As(), 0_i); EXPECT_TRUE(sem->ConstantValue()->Index(1)->AllEqual()); EXPECT_TRUE(sem->ConstantValue()->Index(1)->AnyZero()); EXPECT_TRUE(sem->ConstantValue()->Index(1)->AllZero()); - EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->Is()); + EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->Is()); EXPECT_EQ(sem->ConstantValue()->Index(1)->As(), 0_i); EXPECT_TRUE(sem->ConstantValue()->Index(2)->AllEqual()); EXPECT_TRUE(sem->ConstantValue()->Index(2)->AnyZero()); EXPECT_TRUE(sem->ConstantValue()->Index(2)->AllZero()); - EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->Is()); + EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->Is()); EXPECT_EQ(sem->ConstantValue()->Index(2)->As(), 0_i); } @@ -1680,31 +1680,31 @@ TEST_F(ResolverConstEvalTest, Struct_MixedScalars_ZeroInit) { EXPECT_TRUE(sem->ConstantValue()->Index(0)->AllEqual()); EXPECT_TRUE(sem->ConstantValue()->Index(0)->AnyZero()); EXPECT_TRUE(sem->ConstantValue()->Index(0)->AllZero()); - EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->Is()); + EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->Is()); EXPECT_EQ(sem->ConstantValue()->Index(0)->As(), 0_i); EXPECT_TRUE(sem->ConstantValue()->Index(1)->AllEqual()); EXPECT_TRUE(sem->ConstantValue()->Index(1)->AnyZero()); EXPECT_TRUE(sem->ConstantValue()->Index(1)->AllZero()); - EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->Is()); + EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->Is()); EXPECT_EQ(sem->ConstantValue()->Index(1)->As(), 0_u); EXPECT_TRUE(sem->ConstantValue()->Index(2)->AllEqual()); EXPECT_TRUE(sem->ConstantValue()->Index(2)->AnyZero()); EXPECT_TRUE(sem->ConstantValue()->Index(2)->AllZero()); - EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->Is()); + EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->Is()); EXPECT_EQ(sem->ConstantValue()->Index(2)->As(), 0._f); EXPECT_TRUE(sem->ConstantValue()->Index(3)->AllEqual()); EXPECT_TRUE(sem->ConstantValue()->Index(3)->AnyZero()); EXPECT_TRUE(sem->ConstantValue()->Index(3)->AllZero()); - EXPECT_TRUE(sem->ConstantValue()->Index(3)->Type()->Is()); + EXPECT_TRUE(sem->ConstantValue()->Index(3)->Type()->Is()); EXPECT_EQ(sem->ConstantValue()->Index(3)->As(), 0._h); EXPECT_TRUE(sem->ConstantValue()->Index(4)->AllEqual()); EXPECT_TRUE(sem->ConstantValue()->Index(4)->AnyZero()); EXPECT_TRUE(sem->ConstantValue()->Index(4)->AllZero()); - EXPECT_TRUE(sem->ConstantValue()->Index(4)->Type()->Is()); + EXPECT_TRUE(sem->ConstantValue()->Index(4)->Type()->Is()); EXPECT_EQ(sem->ConstantValue()->Index(4)->As(), false); } @@ -1734,7 +1734,7 @@ TEST_F(ResolverConstEvalTest, Struct_VectorF32s_ZeroInit) { EXPECT_TRUE(sem->ConstantValue()->Index(0)->AnyZero()); EXPECT_TRUE(sem->ConstantValue()->Index(0)->AllZero()); EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->Is()); - EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->As()->type()->Is()); + EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->As()->type()->Is()); EXPECT_EQ(sem->ConstantValue()->Index(0)->Index(0)->As(), 0._f); EXPECT_EQ(sem->ConstantValue()->Index(0)->Index(1)->As(), 0._f); EXPECT_EQ(sem->ConstantValue()->Index(0)->Index(2)->As(), 0._f); @@ -1743,7 +1743,7 @@ TEST_F(ResolverConstEvalTest, Struct_VectorF32s_ZeroInit) { EXPECT_TRUE(sem->ConstantValue()->Index(1)->AnyZero()); EXPECT_TRUE(sem->ConstantValue()->Index(1)->AllZero()); EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->Is()); - EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->As()->type()->Is()); + EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->As()->type()->Is()); EXPECT_EQ(sem->ConstantValue()->Index(1)->Index(0)->As(), 0._f); EXPECT_EQ(sem->ConstantValue()->Index(1)->Index(1)->As(), 0._f); EXPECT_EQ(sem->ConstantValue()->Index(1)->Index(2)->As(), 0._f); @@ -1752,7 +1752,7 @@ TEST_F(ResolverConstEvalTest, Struct_VectorF32s_ZeroInit) { EXPECT_TRUE(sem->ConstantValue()->Index(2)->AnyZero()); EXPECT_TRUE(sem->ConstantValue()->Index(2)->AllZero()); EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->Is()); - EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->As()->type()->Is()); + EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->As()->type()->Is()); EXPECT_EQ(sem->ConstantValue()->Index(2)->Index(0)->As(), 0._f); EXPECT_EQ(sem->ConstantValue()->Index(2)->Index(1)->As(), 0._f); EXPECT_EQ(sem->ConstantValue()->Index(2)->Index(2)->As(), 0._f); @@ -1788,7 +1788,7 @@ TEST_F(ResolverConstEvalTest, Struct_MixedVectors_ZeroInit) { EXPECT_TRUE(sem->ConstantValue()->Index(0)->AnyZero()); EXPECT_TRUE(sem->ConstantValue()->Index(0)->AllZero()); EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->Is()); - EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->As()->type()->Is()); + EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->As()->type()->Is()); EXPECT_EQ(sem->ConstantValue()->Index(0)->Index(0)->As(), 0_i); EXPECT_EQ(sem->ConstantValue()->Index(0)->Index(1)->As(), 0_i); @@ -1796,7 +1796,7 @@ TEST_F(ResolverConstEvalTest, Struct_MixedVectors_ZeroInit) { EXPECT_TRUE(sem->ConstantValue()->Index(1)->AnyZero()); EXPECT_TRUE(sem->ConstantValue()->Index(1)->AllZero()); EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->Is()); - EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->As()->type()->Is()); + EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->As()->type()->Is()); EXPECT_EQ(sem->ConstantValue()->Index(1)->Index(0)->As(), 0_u); EXPECT_EQ(sem->ConstantValue()->Index(1)->Index(1)->As(), 0_u); EXPECT_EQ(sem->ConstantValue()->Index(1)->Index(2)->As(), 0_u); @@ -1805,7 +1805,7 @@ TEST_F(ResolverConstEvalTest, Struct_MixedVectors_ZeroInit) { EXPECT_TRUE(sem->ConstantValue()->Index(2)->AnyZero()); EXPECT_TRUE(sem->ConstantValue()->Index(2)->AllZero()); EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->Is()); - EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->As()->type()->Is()); + EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->As()->type()->Is()); EXPECT_EQ(sem->ConstantValue()->Index(2)->Index(0)->As(), 0._f); EXPECT_EQ(sem->ConstantValue()->Index(2)->Index(1)->As(), 0._f); EXPECT_EQ(sem->ConstantValue()->Index(2)->Index(2)->As(), 0._f); @@ -1815,7 +1815,7 @@ TEST_F(ResolverConstEvalTest, Struct_MixedVectors_ZeroInit) { EXPECT_TRUE(sem->ConstantValue()->Index(3)->AnyZero()); EXPECT_TRUE(sem->ConstantValue()->Index(3)->AllZero()); EXPECT_TRUE(sem->ConstantValue()->Index(3)->Type()->Is()); - EXPECT_TRUE(sem->ConstantValue()->Index(3)->Type()->As()->type()->Is()); + EXPECT_TRUE(sem->ConstantValue()->Index(3)->Type()->As()->type()->Is()); EXPECT_EQ(sem->ConstantValue()->Index(3)->Index(0)->As(), 0._h); EXPECT_EQ(sem->ConstantValue()->Index(3)->Index(1)->As(), 0._h); EXPECT_EQ(sem->ConstantValue()->Index(3)->Index(2)->As(), 0._h); @@ -1824,7 +1824,8 @@ TEST_F(ResolverConstEvalTest, Struct_MixedVectors_ZeroInit) { EXPECT_TRUE(sem->ConstantValue()->Index(4)->AnyZero()); EXPECT_TRUE(sem->ConstantValue()->Index(4)->AllZero()); EXPECT_TRUE(sem->ConstantValue()->Index(4)->Type()->Is()); - EXPECT_TRUE(sem->ConstantValue()->Index(4)->Type()->As()->type()->Is()); + EXPECT_TRUE( + sem->ConstantValue()->Index(4)->Type()->As()->type()->Is()); EXPECT_EQ(sem->ConstantValue()->Index(4)->Index(0)->As(), false); EXPECT_EQ(sem->ConstantValue()->Index(4)->Index(1)->As(), false); } @@ -1902,31 +1903,31 @@ TEST_F(ResolverConstEvalTest, Struct_MixedScalars_Construct) { EXPECT_TRUE(sem->ConstantValue()->Index(0)->AllEqual()); EXPECT_FALSE(sem->ConstantValue()->Index(0)->AnyZero()); EXPECT_FALSE(sem->ConstantValue()->Index(0)->AllZero()); - EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->Is()); + EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->Is()); EXPECT_EQ(sem->ConstantValue()->Index(0)->As(), 1_i); EXPECT_TRUE(sem->ConstantValue()->Index(1)->AllEqual()); EXPECT_FALSE(sem->ConstantValue()->Index(1)->AnyZero()); EXPECT_FALSE(sem->ConstantValue()->Index(1)->AllZero()); - EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->Is()); + EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->Is()); EXPECT_EQ(sem->ConstantValue()->Index(1)->As(), 2_u); EXPECT_TRUE(sem->ConstantValue()->Index(2)->AllEqual()); EXPECT_FALSE(sem->ConstantValue()->Index(2)->AnyZero()); EXPECT_FALSE(sem->ConstantValue()->Index(2)->AllZero()); - EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->Is()); + EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->Is()); EXPECT_EQ(sem->ConstantValue()->Index(2)->As(), 3._f); EXPECT_TRUE(sem->ConstantValue()->Index(3)->AllEqual()); EXPECT_FALSE(sem->ConstantValue()->Index(3)->AnyZero()); EXPECT_FALSE(sem->ConstantValue()->Index(3)->AllZero()); - EXPECT_TRUE(sem->ConstantValue()->Index(3)->Type()->Is()); + EXPECT_TRUE(sem->ConstantValue()->Index(3)->Type()->Is()); EXPECT_EQ(sem->ConstantValue()->Index(3)->As(), 4._h); EXPECT_TRUE(sem->ConstantValue()->Index(4)->AllEqual()); EXPECT_TRUE(sem->ConstantValue()->Index(4)->AnyZero()); EXPECT_TRUE(sem->ConstantValue()->Index(4)->AllZero()); - EXPECT_TRUE(sem->ConstantValue()->Index(4)->Type()->Is()); + EXPECT_TRUE(sem->ConstantValue()->Index(4)->Type()->Is()); EXPECT_EQ(sem->ConstantValue()->Index(4)->As(), false); } @@ -1961,7 +1962,7 @@ TEST_F(ResolverConstEvalTest, Struct_MixedVectors_Construct) { EXPECT_FALSE(sem->ConstantValue()->Index(0)->AnyZero()); EXPECT_FALSE(sem->ConstantValue()->Index(0)->AllZero()); EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->Is()); - EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->As()->type()->Is()); + EXPECT_TRUE(sem->ConstantValue()->Index(0)->Type()->As()->type()->Is()); EXPECT_EQ(sem->ConstantValue()->Index(0)->Index(0)->As(), 1_i); EXPECT_EQ(sem->ConstantValue()->Index(0)->Index(1)->As(), 1_i); @@ -1969,7 +1970,7 @@ TEST_F(ResolverConstEvalTest, Struct_MixedVectors_Construct) { EXPECT_FALSE(sem->ConstantValue()->Index(1)->AnyZero()); EXPECT_FALSE(sem->ConstantValue()->Index(1)->AllZero()); EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->Is()); - EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->As()->type()->Is()); + EXPECT_TRUE(sem->ConstantValue()->Index(1)->Type()->As()->type()->Is()); EXPECT_EQ(sem->ConstantValue()->Index(1)->Index(0)->As(), 2_u); EXPECT_EQ(sem->ConstantValue()->Index(1)->Index(1)->As(), 2_u); EXPECT_EQ(sem->ConstantValue()->Index(1)->Index(2)->As(), 2_u); @@ -1978,7 +1979,7 @@ TEST_F(ResolverConstEvalTest, Struct_MixedVectors_Construct) { EXPECT_FALSE(sem->ConstantValue()->Index(2)->AnyZero()); EXPECT_FALSE(sem->ConstantValue()->Index(2)->AllZero()); EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->Is()); - EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->As()->type()->Is()); + EXPECT_TRUE(sem->ConstantValue()->Index(2)->Type()->As()->type()->Is()); EXPECT_EQ(sem->ConstantValue()->Index(2)->Index(0)->As(), 3._f); EXPECT_EQ(sem->ConstantValue()->Index(2)->Index(1)->As(), 3._f); EXPECT_EQ(sem->ConstantValue()->Index(2)->Index(2)->As(), 3._f); @@ -1988,7 +1989,7 @@ TEST_F(ResolverConstEvalTest, Struct_MixedVectors_Construct) { EXPECT_FALSE(sem->ConstantValue()->Index(3)->AnyZero()); EXPECT_FALSE(sem->ConstantValue()->Index(3)->AllZero()); EXPECT_TRUE(sem->ConstantValue()->Index(3)->Type()->Is()); - EXPECT_TRUE(sem->ConstantValue()->Index(3)->Type()->As()->type()->Is()); + EXPECT_TRUE(sem->ConstantValue()->Index(3)->Type()->As()->type()->Is()); EXPECT_EQ(sem->ConstantValue()->Index(3)->Index(0)->As(), 4._h); EXPECT_EQ(sem->ConstantValue()->Index(3)->Index(1)->As(), 4._h); EXPECT_EQ(sem->ConstantValue()->Index(3)->Index(2)->As(), 4._h); @@ -1997,7 +1998,8 @@ TEST_F(ResolverConstEvalTest, Struct_MixedVectors_Construct) { EXPECT_TRUE(sem->ConstantValue()->Index(4)->AnyZero()); EXPECT_TRUE(sem->ConstantValue()->Index(4)->AllZero()); EXPECT_TRUE(sem->ConstantValue()->Index(4)->Type()->Is()); - EXPECT_TRUE(sem->ConstantValue()->Index(4)->Type()->As()->type()->Is()); + EXPECT_TRUE( + sem->ConstantValue()->Index(4)->Type()->As()->type()->Is()); EXPECT_EQ(sem->ConstantValue()->Index(4)->Index(0)->As(), false); EXPECT_EQ(sem->ConstantValue()->Index(4)->Index(1)->As(), false); } diff --git a/src/tint/resolver/const_eval_conversion_test.cc b/src/tint/resolver/const_eval_conversion_test.cc index 8640a1d2e6..7b277b6725 100644 --- a/src/tint/resolver/const_eval_conversion_test.cc +++ b/src/tint/resolver/const_eval_conversion_test.cc @@ -232,7 +232,7 @@ TEST_F(ResolverConstEvalTest, Vec3_Convert_f32_to_i32) { ASSERT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_FALSE(sem->ConstantValue()->AllEqual()); @@ -265,7 +265,7 @@ TEST_F(ResolverConstEvalTest, Vec3_Convert_u32_to_f32) { ASSERT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_FALSE(sem->ConstantValue()->AllEqual()); @@ -300,7 +300,7 @@ TEST_F(ResolverConstEvalTest, Vec3_Convert_f16_to_i32) { EXPECT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_FALSE(sem->ConstantValue()->AllEqual()); @@ -335,7 +335,7 @@ TEST_F(ResolverConstEvalTest, Vec3_Convert_u32_to_f16) { EXPECT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_FALSE(sem->ConstantValue()->AllEqual()); @@ -368,7 +368,7 @@ TEST_F(ResolverConstEvalTest, Vec3_Convert_Large_f32_to_i32) { ASSERT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_FALSE(sem->ConstantValue()->AllEqual()); @@ -401,7 +401,7 @@ TEST_F(ResolverConstEvalTest, Vec3_Convert_Large_f32_to_u32) { ASSERT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_FALSE(sem->ConstantValue()->AllEqual()); @@ -446,7 +446,7 @@ TEST_F(ResolverConstEvalTest, Vec3_Convert_Small_f32_to_f16) { ASSERT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_FALSE(sem->ConstantValue()->AllEqual()); diff --git a/src/tint/resolver/const_eval_indexing_test.cc b/src/tint/resolver/const_eval_indexing_test.cc index 09447d501c..723e758591 100644 --- a/src/tint/resolver/const_eval_indexing_test.cc +++ b/src/tint/resolver/const_eval_indexing_test.cc @@ -27,7 +27,7 @@ TEST_F(ResolverConstEvalTest, Vec3_Index) { auto* sem = Sem().Get(expr); ASSERT_NE(sem, nullptr); - ASSERT_TRUE(sem->Type()->Is()); + ASSERT_TRUE(sem->Type()->Is()); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue()->AllEqual()); EXPECT_FALSE(sem->ConstantValue()->AnyZero()); @@ -59,7 +59,7 @@ TEST_F(ResolverConstEvalTest, Vec3_Swizzle_Scalar) { auto* sem = Sem().Get(expr); ASSERT_NE(sem, nullptr); - ASSERT_TRUE(sem->Type()->Is()); + ASSERT_TRUE(sem->Type()->Is()); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue()->AllEqual()); EXPECT_FALSE(sem->ConstantValue()->AnyZero()); @@ -100,7 +100,7 @@ TEST_F(ResolverConstEvalTest, Vec3_Swizzle_Chain) { auto* sem = Sem().Get(expr); ASSERT_NE(sem, nullptr); - ASSERT_TRUE(sem->Type()->Is()); + ASSERT_TRUE(sem->Type()->Is()); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); EXPECT_TRUE(sem->ConstantValue()->AllEqual()); EXPECT_FALSE(sem->ConstantValue()->AnyZero()); @@ -165,7 +165,7 @@ TEST_F(ResolverConstEvalTest, Array_vec3_f32_Index) { ASSERT_NE(sem, nullptr); auto* vec = sem->Type()->As(); ASSERT_NE(vec, nullptr); - EXPECT_TRUE(vec->type()->Is()); + EXPECT_TRUE(vec->type()->Is()); EXPECT_EQ(vec->Width(), 3u); EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type()); @@ -277,7 +277,7 @@ TEST_F(ResolverConstEvalTest, ChainedIndex) { EXPECT_NE(vec, nullptr); auto* ty = vec->Type()->As(); ASSERT_NE(vec->Type(), nullptr); - EXPECT_TRUE(ty->type()->Is()); + EXPECT_TRUE(ty->type()->Is()); EXPECT_EQ(ty->Width(), 3u); EXPECT_EQ(vec->ConstantValue()->Type(), vec->Type()); EXPECT_FALSE(vec->ConstantValue()->AllEqual()); @@ -302,7 +302,7 @@ TEST_F(ResolverConstEvalTest, ChainedIndex) { { auto* f = Sem().Get(f32_expr); EXPECT_NE(f, nullptr); - EXPECT_TRUE(f->Type()->Is()); + EXPECT_TRUE(f->Type()->Is()); EXPECT_EQ(f->ConstantValue()->Type(), f->Type()); EXPECT_TRUE(f->ConstantValue()->AllEqual()); EXPECT_FALSE(f->ConstantValue()->AnyZero()); diff --git a/src/tint/resolver/const_eval_member_access_test.cc b/src/tint/resolver/const_eval_member_access_test.cc index 4f3245e9ae..3fb8fc3d1a 100644 --- a/src/tint/resolver/const_eval_member_access_test.cc +++ b/src/tint/resolver/const_eval_member_access_test.cc @@ -65,7 +65,7 @@ TEST_F(ResolverConstEvalTest, MemberAccess) { EXPECT_TRUE(i2->ConstantValue()->AllEqual()); EXPECT_FALSE(i2->ConstantValue()->AnyZero()); EXPECT_FALSE(i2->ConstantValue()->AllZero()); - EXPECT_TRUE(i2->ConstantValue()->Type()->Is()); + EXPECT_TRUE(i2->ConstantValue()->Type()->Is()); EXPECT_EQ(i2->ConstantValue()->As(), 2_u); } diff --git a/src/tint/resolver/const_eval_test.h b/src/tint/resolver/const_eval_test.h index 2b365883dd..120a0776ce 100644 --- a/src/tint/resolver/const_eval_test.h +++ b/src/tint/resolver/const_eval_test.h @@ -43,11 +43,11 @@ inline void CollectScalars(const sem::Constant* c, utils::VectorType(), // [&](const type::AbstractInt*) { scalars.Push(c->As()); }, [&](const type::AbstractFloat*) { scalars.Push(c->As()); }, - [&](const sem::Bool*) { scalars.Push(c->As()); }, - [&](const sem::I32*) { scalars.Push(c->As()); }, - [&](const sem::U32*) { scalars.Push(c->As()); }, - [&](const sem::F32*) { scalars.Push(c->As()); }, - [&](const sem::F16*) { scalars.Push(c->As()); }, + [&](const type::Bool*) { scalars.Push(c->As()); }, + [&](const type::I32*) { scalars.Push(c->As()); }, + [&](const type::U32*) { scalars.Push(c->As()); }, + [&](const type::F32*) { scalars.Push(c->As()); }, + [&](const type::F16*) { scalars.Push(c->As()); }, [&](Default) { size_t i = 0; while (auto* child = c->Index(i++)) { diff --git a/src/tint/resolver/inferred_type_test.cc b/src/tint/resolver/inferred_type_test.cc index 4b3100bbdd..d7f5548075 100644 --- a/src/tint/resolver/inferred_type_test.cc +++ b/src/tint/resolver/inferred_type_test.cc @@ -136,7 +136,7 @@ INSTANTIATE_TEST_SUITE_P(ResolverTest, ResolverInferredTypeParamTest, testing::V TEST_F(ResolverInferredTypeTest, InferArray_Pass) { auto* type = ty.array(ty.u32(), 10_u); auto* expected_type = create( - create(), create(10u), 4u, 4u * 10u, 4u, 4u); + create(), create(10u), 4u, 4u * 10u, 4u, 4u); auto* ctor_expr = Construct(type); auto* var = Var("a", ast::AddressSpace::kFunction, ctor_expr); @@ -153,7 +153,7 @@ TEST_F(ResolverInferredTypeTest, InferStruct_Pass) { auto* expected_type = create( str, str->source, str->name, utils::Vector{create(member, member->source, member->symbol, - create(), 0u, 0u, 0u, 4u, std::nullopt)}, + create(), 0u, 0u, 0u, 4u, std::nullopt)}, 0u, 4u, 4u); auto* ctor_expr = Construct(ty.Of(str)); diff --git a/src/tint/resolver/intrinsic_table.cc b/src/tint/resolver/intrinsic_table.cc index 6c70f66436..05465610c5 100644 --- a/src/tint/resolver/intrinsic_table.cc +++ b/src/tint/resolver/intrinsic_table.cc @@ -349,7 +349,7 @@ enum class OverloadFlag { using OverloadFlags = utils::EnumSet; bool match_bool(MatchState&, const type::Type* ty) { - return ty->IsAnyOf(); + return ty->IsAnyOf(); } const type::AbstractFloat* build_fa(MatchState& state) { @@ -370,40 +370,40 @@ bool match_ia(MatchState& state, const type::Type* ty) { ty->IsAnyOf(); } -const sem::Bool* build_bool(MatchState& state) { - return state.builder.create(); +const type::Bool* build_bool(MatchState& state) { + return state.builder.create(); } -const sem::F16* build_f16(MatchState& state) { - return state.builder.create(); +const type::F16* build_f16(MatchState& state) { + return state.builder.create(); } bool match_f16(MatchState&, const type::Type* ty) { - return ty->IsAnyOf(); + return ty->IsAnyOf(); } -const sem::F32* build_f32(MatchState& state) { - return state.builder.create(); +const type::F32* build_f32(MatchState& state) { + return state.builder.create(); } bool match_f32(MatchState&, const type::Type* ty) { - return ty->IsAnyOf(); + return ty->IsAnyOf(); } -const sem::I32* build_i32(MatchState& state) { - return state.builder.create(); +const type::I32* build_i32(MatchState& state) { + return state.builder.create(); } bool match_i32(MatchState&, const type::Type* ty) { - return ty->IsAnyOf(); + return ty->IsAnyOf(); } -const sem::U32* build_u32(MatchState& state) { - return state.builder.create(); +const type::U32* build_u32(MatchState& state) { + return state.builder.create(); } bool match_u32(MatchState&, const type::Type* ty) { - return ty->IsAnyOf(); + return ty->IsAnyOf(); } bool match_vec(MatchState&, const type::Type* ty, Number& N, const type::Type*& T) { @@ -834,18 +834,18 @@ sem::Struct* build_struct(ProgramBuilder& b, const sem::Struct* build_modf_result(MatchState& state, const type::Type* el) { auto build_f32 = [&] { - auto* ty = state.builder.create(); + auto* ty = state.builder.create(); return build_struct(state.builder, "__modf_result_f32", {{"fract", ty}, {"whole", ty}}); }; auto build_f16 = [&] { - auto* ty = state.builder.create(); + auto* ty = state.builder.create(); return build_struct(state.builder, "__modf_result_f16", {{"fract", ty}, {"whole", ty}}); }; return Switch( - el, // - [&](const sem::F32*) { return build_f32(); }, // - [&](const sem::F16*) { return build_f16(); }, // + el, // + [&](const type::F32*) { return build_f32(); }, // + [&](const type::F16*) { return build_f16(); }, // [&](const type::AbstractFloat*) { auto* abstract = build_struct(state.builder, "__modf_result_abstract", {{"fract", el}, {"whole", el}}); @@ -862,18 +862,18 @@ const sem::Struct* build_modf_result(MatchState& state, const type::Type* el) { const sem::Struct* build_modf_result_vec(MatchState& state, Number& n, const type::Type* el) { auto prefix = "__modf_result_vec" + std::to_string(n.Value()); auto build_f32 = [&] { - auto* vec = state.builder.create(state.builder.create(), n.Value()); + auto* vec = state.builder.create(state.builder.create(), n.Value()); return build_struct(state.builder, prefix + "_f32", {{"fract", vec}, {"whole", vec}}); }; auto build_f16 = [&] { - auto* vec = state.builder.create(state.builder.create(), n.Value()); + auto* vec = state.builder.create(state.builder.create(), n.Value()); return build_struct(state.builder, prefix + "_f16", {{"fract", vec}, {"whole", vec}}); }; return Switch( - el, // - [&](const sem::F32*) { return build_f32(); }, // - [&](const sem::F16*) { return build_f16(); }, // + el, // + [&](const type::F32*) { return build_f32(); }, // + [&](const type::F16*) { return build_f16(); }, // [&](const type::AbstractFloat*) { auto* vec = state.builder.create(el, n.Value()); auto* abstract = @@ -890,20 +890,20 @@ const sem::Struct* build_modf_result_vec(MatchState& state, Number& n, const typ const sem::Struct* build_frexp_result(MatchState& state, const type::Type* el) { auto build_f32 = [&] { - auto* f = state.builder.create(); - auto* i = state.builder.create(); + auto* f = state.builder.create(); + auto* i = state.builder.create(); return build_struct(state.builder, "__frexp_result_f32", {{"fract", f}, {"exp", i}}); }; auto build_f16 = [&] { - auto* f = state.builder.create(); - auto* i = state.builder.create(); + auto* f = state.builder.create(); + auto* i = state.builder.create(); return build_struct(state.builder, "__frexp_result_f16", {{"fract", f}, {"exp", i}}); }; return Switch( - el, // - [&](const sem::F32*) { return build_f32(); }, // - [&](const sem::F16*) { return build_f16(); }, // + el, // + [&](const type::F32*) { return build_f32(); }, // + [&](const type::F16*) { return build_f16(); }, // [&](const type::AbstractFloat*) { auto* i = state.builder.create(); auto* abstract = @@ -921,20 +921,20 @@ const sem::Struct* build_frexp_result(MatchState& state, const type::Type* el) { const sem::Struct* build_frexp_result_vec(MatchState& state, Number& n, const type::Type* el) { auto prefix = "__frexp_result_vec" + std::to_string(n.Value()); auto build_f32 = [&] { - auto* f = state.builder.create(state.builder.create(), n.Value()); - auto* e = state.builder.create(state.builder.create(), n.Value()); + auto* f = state.builder.create(state.builder.create(), n.Value()); + auto* e = state.builder.create(state.builder.create(), n.Value()); return build_struct(state.builder, prefix + "_f32", {{"fract", f}, {"exp", e}}); }; auto build_f16 = [&] { - auto* f = state.builder.create(state.builder.create(), n.Value()); - auto* e = state.builder.create(state.builder.create(), n.Value()); + auto* f = state.builder.create(state.builder.create(), n.Value()); + auto* e = state.builder.create(state.builder.create(), n.Value()); return build_struct(state.builder, prefix + "_f16", {{"fract", f}, {"exp", e}}); }; return Switch( - el, // - [&](const sem::F32*) { return build_f32(); }, // - [&](const sem::F16*) { return build_f16(); }, // + el, // + [&](const type::F32*) { return build_f32(); }, // + [&](const type::F16*) { return build_f16(); }, // [&](const type::AbstractFloat*) { auto* f = state.builder.create(el, n.Value()); auto* e = state.builder.create(state.builder.create(), @@ -956,7 +956,7 @@ const sem::Struct* build_atomic_compare_exchange_result(MatchState& state, const state.builder, "__atomic_compare_exchange_result" + ty->FriendlyName(state.builder.Symbols()), {{"old_value", const_cast(ty)}, - {"exchanged", state.builder.create()}}); + {"exchanged", state.builder.create()}}); } /// ParameterInfo describes a parameter @@ -1549,7 +1549,7 @@ IntrinsicPrototype Impl::MatchIntrinsic(const IntrinsicInfo& intrinsic, return {}; } } else { - return_type = builder.create(); + return_type = builder.create(); } return IntrinsicPrototype{match.overload, return_type, std::move(match.parameters)}; diff --git a/src/tint/resolver/intrinsic_table_test.cc b/src/tint/resolver/intrinsic_table_test.cc index 3cdf65f035..6f984a12bf 100644 --- a/src/tint/resolver/intrinsic_table_test.cc +++ b/src/tint/resolver/intrinsic_table_test.cc @@ -52,7 +52,7 @@ class IntrinsicTableTest : public testing::Test, public ProgramBuilder { }; TEST_F(IntrinsicTableTest, MatchF32) { - auto* f32 = create(); + auto* f32 = create(); auto result = table->Lookup(BuiltinType::kCos, utils::Vector{f32}, sem::EvaluationStage::kConstant, Source{}); ASSERT_NE(result.sem, nullptr) << Diagnostics().str(); @@ -64,7 +64,7 @@ TEST_F(IntrinsicTableTest, MatchF32) { } TEST_F(IntrinsicTableTest, MismatchF32) { - auto* i32 = create(); + auto* i32 = create(); auto result = table->Lookup(BuiltinType::kCos, utils::Vector{i32}, sem::EvaluationStage::kConstant, Source{}); ASSERT_EQ(result.sem, nullptr); @@ -72,8 +72,8 @@ TEST_F(IntrinsicTableTest, MismatchF32) { } TEST_F(IntrinsicTableTest, MatchU32) { - auto* f32 = create(); - auto* u32 = create(); + auto* f32 = create(); + auto* u32 = create(); auto* vec2_f32 = create(f32, 2u); auto result = table->Lookup(BuiltinType::kUnpack2X16Float, utils::Vector{u32}, sem::EvaluationStage::kConstant, Source{}); @@ -86,7 +86,7 @@ TEST_F(IntrinsicTableTest, MatchU32) { } TEST_F(IntrinsicTableTest, MismatchU32) { - auto* f32 = create(); + auto* f32 = create(); auto result = table->Lookup(BuiltinType::kUnpack2X16Float, utils::Vector{f32}, sem::EvaluationStage::kConstant, Source{}); ASSERT_EQ(result.sem, nullptr); @@ -94,8 +94,8 @@ TEST_F(IntrinsicTableTest, MismatchU32) { } TEST_F(IntrinsicTableTest, MatchI32) { - auto* f32 = create(); - auto* i32 = create(); + auto* f32 = create(); + auto* i32 = create(); auto* vec4_f32 = create(f32, 4u); auto* tex = create(ast::TextureDimension::k1d, f32); auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, i32, i32}, @@ -114,7 +114,7 @@ TEST_F(IntrinsicTableTest, MatchI32) { } TEST_F(IntrinsicTableTest, MismatchI32) { - auto* f32 = create(); + auto* f32 = create(); auto* tex = create(ast::TextureDimension::k1d, f32); auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, f32}, sem::EvaluationStage::kConstant, Source{}); @@ -123,7 +123,7 @@ TEST_F(IntrinsicTableTest, MismatchI32) { } TEST_F(IntrinsicTableTest, MatchIU32AsI32) { - auto* i32 = create(); + auto* i32 = create(); auto result = table->Lookup(BuiltinType::kCountOneBits, utils::Vector{i32}, sem::EvaluationStage::kConstant, Source{}); ASSERT_NE(result.sem, nullptr) << Diagnostics().str(); @@ -135,7 +135,7 @@ TEST_F(IntrinsicTableTest, MatchIU32AsI32) { } TEST_F(IntrinsicTableTest, MatchIU32AsU32) { - auto* u32 = create(); + auto* u32 = create(); auto result = table->Lookup(BuiltinType::kCountOneBits, utils::Vector{u32}, sem::EvaluationStage::kConstant, Source{}); ASSERT_NE(result.sem, nullptr) << Diagnostics().str(); @@ -147,7 +147,7 @@ TEST_F(IntrinsicTableTest, MatchIU32AsU32) { } TEST_F(IntrinsicTableTest, MismatchIU32) { - auto* f32 = create(); + auto* f32 = create(); auto result = table->Lookup(BuiltinType::kCountOneBits, utils::Vector{f32}, sem::EvaluationStage::kConstant, Source{}); ASSERT_EQ(result.sem, nullptr); @@ -155,7 +155,7 @@ TEST_F(IntrinsicTableTest, MismatchIU32) { } TEST_F(IntrinsicTableTest, MatchFIU32AsI32) { - auto* i32 = create(); + auto* i32 = create(); auto result = table->Lookup(BuiltinType::kClamp, utils::Vector{i32, i32, i32}, sem::EvaluationStage::kConstant, Source{}); ASSERT_NE(result.sem, nullptr) << Diagnostics().str(); @@ -169,7 +169,7 @@ TEST_F(IntrinsicTableTest, MatchFIU32AsI32) { } TEST_F(IntrinsicTableTest, MatchFIU32AsU32) { - auto* u32 = create(); + auto* u32 = create(); auto result = table->Lookup(BuiltinType::kClamp, utils::Vector{u32, u32, u32}, sem::EvaluationStage::kConstant, Source{}); ASSERT_NE(result.sem, nullptr) << Diagnostics().str(); @@ -183,7 +183,7 @@ TEST_F(IntrinsicTableTest, MatchFIU32AsU32) { } TEST_F(IntrinsicTableTest, MatchFIU32AsF32) { - auto* f32 = create(); + auto* f32 = create(); auto result = table->Lookup(BuiltinType::kClamp, utils::Vector{f32, f32, f32}, sem::EvaluationStage::kConstant, Source{}); ASSERT_NE(result.sem, nullptr) << Diagnostics().str(); @@ -197,7 +197,7 @@ TEST_F(IntrinsicTableTest, MatchFIU32AsF32) { } TEST_F(IntrinsicTableTest, MismatchFIU32) { - auto* bool_ = create(); + auto* bool_ = create(); auto result = table->Lookup(BuiltinType::kClamp, utils::Vector{bool_, bool_, bool_}, sem::EvaluationStage::kConstant, Source{}); ASSERT_EQ(result.sem, nullptr); @@ -205,8 +205,8 @@ TEST_F(IntrinsicTableTest, MismatchFIU32) { } TEST_F(IntrinsicTableTest, MatchBool) { - auto* f32 = create(); - auto* bool_ = create(); + auto* f32 = create(); + auto* bool_ = create(); auto result = table->Lookup(BuiltinType::kSelect, utils::Vector{f32, f32, bool_}, sem::EvaluationStage::kConstant, Source{}); ASSERT_NE(result.sem, nullptr) << Diagnostics().str(); @@ -220,7 +220,7 @@ TEST_F(IntrinsicTableTest, MatchBool) { } TEST_F(IntrinsicTableTest, MismatchBool) { - auto* f32 = create(); + auto* f32 = create(); auto result = table->Lookup(BuiltinType::kSelect, utils::Vector{f32, f32, f32}, sem::EvaluationStage::kConstant, Source{}); ASSERT_EQ(result.sem, nullptr); @@ -228,7 +228,7 @@ TEST_F(IntrinsicTableTest, MismatchBool) { } TEST_F(IntrinsicTableTest, MatchPointer) { - auto* i32 = create(); + auto* i32 = create(); auto* atomicI32 = create(i32); auto* ptr = create(atomicI32, ast::AddressSpace::kWorkgroup, ast::Access::kReadWrite); @@ -243,7 +243,7 @@ TEST_F(IntrinsicTableTest, MatchPointer) { } TEST_F(IntrinsicTableTest, MismatchPointer) { - auto* i32 = create(); + auto* i32 = create(); auto* atomicI32 = create(i32); auto result = table->Lookup(BuiltinType::kAtomicLoad, utils::Vector{atomicI32}, sem::EvaluationStage::kConstant, Source{}); @@ -253,14 +253,14 @@ TEST_F(IntrinsicTableTest, MismatchPointer) { TEST_F(IntrinsicTableTest, MatchArray) { auto* arr = - create(create(), create(), 4u, 4u, 4u, 4u); + create(create(), create(), 4u, 4u, 4u, 4u); auto* arr_ptr = create(arr, ast::AddressSpace::kStorage, ast::Access::kReadWrite); auto result = table->Lookup(BuiltinType::kArrayLength, utils::Vector{arr_ptr}, sem::EvaluationStage::kConstant, Source{}); ASSERT_NE(result.sem, nullptr) << Diagnostics().str(); ASSERT_EQ(Diagnostics().str(), ""); EXPECT_EQ(result.sem->Type(), BuiltinType::kArrayLength); - EXPECT_TRUE(result.sem->ReturnType()->Is()); + EXPECT_TRUE(result.sem->ReturnType()->Is()); ASSERT_EQ(result.sem->Parameters().Length(), 1u); auto* param_type = result.sem->Parameters()[0]->Type(); ASSERT_TRUE(param_type->Is()); @@ -268,7 +268,7 @@ TEST_F(IntrinsicTableTest, MatchArray) { } TEST_F(IntrinsicTableTest, MismatchArray) { - auto* f32 = create(); + auto* f32 = create(); auto result = table->Lookup(BuiltinType::kArrayLength, utils::Vector{f32}, sem::EvaluationStage::kConstant, Source{}); ASSERT_EQ(result.sem, nullptr); @@ -276,7 +276,7 @@ TEST_F(IntrinsicTableTest, MismatchArray) { } TEST_F(IntrinsicTableTest, MatchSampler) { - auto* f32 = create(); + auto* f32 = create(); auto* vec2_f32 = create(f32, 2u); auto* vec4_f32 = create(f32, 4u); auto* tex = create(ast::TextureDimension::k2d, f32); @@ -297,7 +297,7 @@ TEST_F(IntrinsicTableTest, MatchSampler) { } TEST_F(IntrinsicTableTest, MismatchSampler) { - auto* f32 = create(); + auto* f32 = create(); auto* vec2_f32 = create(f32, 2u); auto* tex = create(ast::TextureDimension::k2d, f32); auto result = table->Lookup(BuiltinType::kTextureSample, utils::Vector{tex, f32, vec2_f32}, @@ -307,8 +307,8 @@ TEST_F(IntrinsicTableTest, MismatchSampler) { } TEST_F(IntrinsicTableTest, MatchSampledTexture) { - auto* i32 = create(); - auto* f32 = create(); + auto* i32 = create(); + auto* f32 = create(); auto* vec2_i32 = create(i32, 2u); auto* vec4_f32 = create(f32, 4u); auto* tex = create(ast::TextureDimension::k2d, f32); @@ -328,8 +328,8 @@ TEST_F(IntrinsicTableTest, MatchSampledTexture) { } TEST_F(IntrinsicTableTest, MatchMultisampledTexture) { - auto* i32 = create(); - auto* f32 = create(); + auto* i32 = create(); + auto* f32 = create(); auto* vec2_i32 = create(i32, 2u); auto* vec4_f32 = create(f32, 4u); auto* tex = create(ast::TextureDimension::k2d, f32); @@ -349,8 +349,8 @@ TEST_F(IntrinsicTableTest, MatchMultisampledTexture) { } TEST_F(IntrinsicTableTest, MatchDepthTexture) { - auto* f32 = create(); - auto* i32 = create(); + auto* f32 = create(); + auto* i32 = create(); auto* vec2_i32 = create(i32, 2u); auto* tex = create(ast::TextureDimension::k2d); auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, vec2_i32, i32}, @@ -369,8 +369,8 @@ TEST_F(IntrinsicTableTest, MatchDepthTexture) { } TEST_F(IntrinsicTableTest, MatchDepthMultisampledTexture) { - auto* f32 = create(); - auto* i32 = create(); + auto* f32 = create(); + auto* i32 = create(); auto* vec2_i32 = create(i32, 2u); auto* tex = create(ast::TextureDimension::k2d); auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{tex, vec2_i32, i32}, @@ -389,8 +389,8 @@ TEST_F(IntrinsicTableTest, MatchDepthMultisampledTexture) { } TEST_F(IntrinsicTableTest, MatchExternalTexture) { - auto* f32 = create(); - auto* i32 = create(); + auto* f32 = create(); + auto* i32 = create(); auto* vec2_i32 = create(i32, 2u); auto* vec4_f32 = create(f32, 4u); auto* tex = create(); @@ -408,8 +408,8 @@ TEST_F(IntrinsicTableTest, MatchExternalTexture) { } TEST_F(IntrinsicTableTest, MatchWOStorageTexture) { - auto* f32 = create(); - auto* i32 = create(); + auto* f32 = create(); + auto* i32 = create(); auto* vec2_i32 = create(i32, 2u); auto* vec4_f32 = create(f32, 4u); auto* subtype = type::StorageTexture::SubtypeFor(ast::TexelFormat::kR32Float, Types()); @@ -421,7 +421,7 @@ TEST_F(IntrinsicTableTest, MatchWOStorageTexture) { ASSERT_NE(result.sem, nullptr) << Diagnostics().str(); ASSERT_EQ(Diagnostics().str(), ""); EXPECT_EQ(result.sem->Type(), BuiltinType::kTextureStore); - EXPECT_TRUE(result.sem->ReturnType()->Is()); + EXPECT_TRUE(result.sem->ReturnType()->Is()); ASSERT_EQ(result.sem->Parameters().Length(), 3u); EXPECT_EQ(result.sem->Parameters()[0]->Type(), tex); EXPECT_EQ(result.sem->Parameters()[0]->Usage(), ParameterUsage::kTexture); @@ -432,8 +432,8 @@ TEST_F(IntrinsicTableTest, MatchWOStorageTexture) { } TEST_F(IntrinsicTableTest, MismatchTexture) { - auto* f32 = create(); - auto* i32 = create(); + auto* f32 = create(); + auto* i32 = create(); auto* vec2_i32 = create(i32, 2u); auto result = table->Lookup(BuiltinType::kTextureLoad, utils::Vector{f32, vec2_i32}, sem::EvaluationStage::kConstant, Source{}); @@ -442,7 +442,7 @@ TEST_F(IntrinsicTableTest, MismatchTexture) { } TEST_F(IntrinsicTableTest, ImplicitLoadOnReference) { - auto* f32 = create(); + auto* f32 = create(); auto result = table->Lookup( BuiltinType::kCos, utils::Vector{ @@ -458,7 +458,7 @@ TEST_F(IntrinsicTableTest, ImplicitLoadOnReference) { } TEST_F(IntrinsicTableTest, MatchTemplateType) { - auto* f32 = create(); + auto* f32 = create(); auto result = table->Lookup(BuiltinType::kClamp, utils::Vector{f32, f32, f32}, sem::EvaluationStage::kConstant, Source{}); ASSERT_NE(result.sem, nullptr) << Diagnostics().str(); @@ -471,8 +471,8 @@ TEST_F(IntrinsicTableTest, MatchTemplateType) { } TEST_F(IntrinsicTableTest, MismatchTemplateType) { - auto* f32 = create(); - auto* u32 = create(); + auto* f32 = create(); + auto* u32 = create(); auto result = table->Lookup(BuiltinType::kClamp, utils::Vector{f32, u32, f32}, sem::EvaluationStage::kConstant, Source{}); ASSERT_EQ(result.sem, nullptr); @@ -480,7 +480,7 @@ TEST_F(IntrinsicTableTest, MismatchTemplateType) { } TEST_F(IntrinsicTableTest, MatchOpenSizeVector) { - auto* f32 = create(); + auto* f32 = create(); auto* vec2_f32 = create(f32, 2u); auto result = table->Lookup(BuiltinType::kClamp, utils::Vector{vec2_f32, vec2_f32, vec2_f32}, sem::EvaluationStage::kConstant, Source{}); @@ -495,8 +495,8 @@ TEST_F(IntrinsicTableTest, MatchOpenSizeVector) { } TEST_F(IntrinsicTableTest, MismatchOpenSizeVector) { - auto* f32 = create(); - auto* u32 = create(); + auto* f32 = create(); + auto* u32 = create(); auto* vec2_f32 = create(f32, 2u); auto result = table->Lookup(BuiltinType::kClamp, utils::Vector{vec2_f32, u32, vec2_f32}, sem::EvaluationStage::kConstant, Source{}); @@ -505,7 +505,7 @@ TEST_F(IntrinsicTableTest, MismatchOpenSizeVector) { } TEST_F(IntrinsicTableTest, MatchOpenSizeMatrix) { - auto* f32 = create(); + auto* f32 = create(); auto* vec3_f32 = create(f32, 3u); auto* mat3_f32 = create(vec3_f32, 3u); auto result = table->Lookup(BuiltinType::kDeterminant, utils::Vector{mat3_f32}, @@ -519,7 +519,7 @@ TEST_F(IntrinsicTableTest, MatchOpenSizeMatrix) { } TEST_F(IntrinsicTableTest, MismatchOpenSizeMatrix) { - auto* f32 = create(); + auto* f32 = create(); auto* vec2_f32 = create(f32, 2u); auto* mat3x2_f32 = create(vec2_f32, 3u); auto result = table->Lookup(BuiltinType::kDeterminant, utils::Vector{mat3x2_f32}, @@ -530,7 +530,7 @@ TEST_F(IntrinsicTableTest, MismatchOpenSizeMatrix) { TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_ConstantEval) { auto* af = create(); - auto* bool_ = create(); + auto* bool_ = create(); auto result = table->Lookup(BuiltinType::kSelect, utils::Vector{af, af, bool_}, sem::EvaluationStage::kConstant, Source{}); ASSERT_NE(result.sem, nullptr) << Diagnostics().str(); @@ -546,7 +546,7 @@ TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_ConstantEval) { TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_RuntimeEval) { auto* af = create(); - auto* bool_ref = create(create(), ast::AddressSpace::kFunction, + auto* bool_ref = create(create(), ast::AddressSpace::kFunction, ast::Access::kReadWrite); auto result = table->Lookup(BuiltinType::kSelect, utils::Vector{af, af, bool_ref}, sem::EvaluationStage::kRuntime, Source{}); @@ -554,16 +554,16 @@ TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Builtin_RuntimeEval) { ASSERT_EQ(Diagnostics().str(), ""); EXPECT_EQ(result.sem->Stage(), sem::EvaluationStage::kConstant); EXPECT_EQ(result.sem->Type(), BuiltinType::kSelect); - EXPECT_TRUE(result.sem->ReturnType()->Is()); + EXPECT_TRUE(result.sem->ReturnType()->Is()); ASSERT_EQ(result.sem->Parameters().Length(), 3u); - EXPECT_TRUE(result.sem->Parameters()[0]->Type()->Is()); - EXPECT_TRUE(result.sem->Parameters()[1]->Type()->Is()); - EXPECT_TRUE(result.sem->Parameters()[2]->Type()->Is()); + EXPECT_TRUE(result.sem->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(result.sem->Parameters()[1]->Type()->Is()); + EXPECT_TRUE(result.sem->Parameters()[2]->Type()->Is()); } TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Binary_ConstantEval) { auto* ai = create(); - auto* u32 = create(); + auto* u32 = create(); auto result = table->Lookup(ast::BinaryOp::kShiftLeft, ai, u32, sem::EvaluationStage::kConstant, Source{}, false); ASSERT_NE(result.result, nullptr) << Diagnostics().str(); @@ -576,21 +576,21 @@ TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Binary_ConstantEval) { TEST_F(IntrinsicTableTest, MatchDifferentArgsElementType_Binary_RuntimeEval) { auto* ai = create(); - auto* u32 = create(); + auto* u32 = create(); auto result = table->Lookup(ast::BinaryOp::kShiftLeft, ai, u32, sem::EvaluationStage::kRuntime, Source{}, false); ASSERT_NE(result.result, nullptr) << Diagnostics().str(); ASSERT_NE(result.const_eval_fn, nullptr) << Diagnostics().str(); ASSERT_EQ(Diagnostics().str(), ""); - EXPECT_TRUE(result.result->Is()); - EXPECT_TRUE(result.lhs->Is()); - EXPECT_TRUE(result.rhs->Is()); + EXPECT_TRUE(result.result->Is()); + EXPECT_TRUE(result.lhs->Is()); + EXPECT_TRUE(result.rhs->Is()); } TEST_F(IntrinsicTableTest, OverloadOrderByNumberOfParameters) { // None of the arguments match, so expect the overloads with 2 parameters to // come first - auto* bool_ = create(); + auto* bool_ = create(); table->Lookup(BuiltinType::kTextureDimensions, utils::Vector{bool_, bool_}, sem::EvaluationStage::kConstant, Source{}); ASSERT_EQ(Diagnostics().str(), @@ -629,7 +629,7 @@ TEST_F(IntrinsicTableTest, OverloadOrderByNumberOfParameters) { TEST_F(IntrinsicTableTest, OverloadOrderByMatchingParameter) { auto* tex = create(ast::TextureDimension::k2d); - auto* bool_ = create(); + auto* bool_ = create(); table->Lookup(BuiltinType::kTextureDimensions, utils::Vector{tex, bool_}, sem::EvaluationStage::kConstant, Source{}); ASSERT_EQ(Diagnostics().str(), @@ -667,9 +667,9 @@ TEST_F(IntrinsicTableTest, OverloadOrderByMatchingParameter) { } TEST_F(IntrinsicTableTest, SameOverloadReturnsSameBuiltinPointer) { - auto* f32 = create(); - auto* vec2_f32 = create(create(), 2u); - auto* bool_ = create(); + auto* f32 = create(); + auto* vec2_f32 = create(create(), 2u); + auto* bool_ = create(); auto a = table->Lookup(BuiltinType::kSelect, utils::Vector{f32, f32, bool_}, sem::EvaluationStage::kConstant, Source{}); ASSERT_NE(a.sem, nullptr) << Diagnostics().str(); @@ -690,7 +690,7 @@ TEST_F(IntrinsicTableTest, SameOverloadReturnsSameBuiltinPointer) { } TEST_F(IntrinsicTableTest, MatchUnaryOp) { - auto* i32 = create(); + auto* i32 = create(); auto* vec3_i32 = create(i32, 3u); auto result = table->Lookup(ast::UnaryOp::kNegation, vec3_i32, sem::EvaluationStage::kConstant, Source{{12, 34}}); @@ -699,7 +699,7 @@ TEST_F(IntrinsicTableTest, MatchUnaryOp) { } TEST_F(IntrinsicTableTest, MismatchUnaryOp) { - auto* bool_ = create(); + auto* bool_ = create(); auto result = table->Lookup(ast::UnaryOp::kNegation, bool_, sem::EvaluationStage::kConstant, Source{{12, 34}}); ASSERT_EQ(result.result, nullptr); @@ -724,12 +724,12 @@ TEST_F(IntrinsicTableTest, MatchUnaryOp_Runtime) { auto result = table->Lookup(ast::UnaryOp::kNegation, ai, sem::EvaluationStage::kRuntime, Source{{12, 34}}); EXPECT_NE(result.result, ai); - EXPECT_TRUE(result.result->Is()); + EXPECT_TRUE(result.result->Is()); EXPECT_EQ(Diagnostics().str(), ""); } TEST_F(IntrinsicTableTest, MatchBinaryOp) { - auto* i32 = create(); + auto* i32 = create(); auto* vec3_i32 = create(i32, 3u); auto result = table->Lookup(ast::BinaryOp::kMultiply, i32, vec3_i32, sem::EvaluationStage::kConstant, Source{{12, 34}}, @@ -741,8 +741,8 @@ TEST_F(IntrinsicTableTest, MatchBinaryOp) { } TEST_F(IntrinsicTableTest, MismatchBinaryOp) { - auto* f32 = create(); - auto* bool_ = create(); + auto* f32 = create(); + auto* bool_ = create(); auto result = table->Lookup(ast::BinaryOp::kMultiply, f32, bool_, sem::EvaluationStage::kConstant, Source{{12, 34}}, /* is_compound */ false); @@ -763,7 +763,7 @@ TEST_F(IntrinsicTableTest, MismatchBinaryOp) { } TEST_F(IntrinsicTableTest, MatchCompoundOp) { - auto* i32 = create(); + auto* i32 = create(); auto* vec3_i32 = create(i32, 3u); auto result = table->Lookup(ast::BinaryOp::kMultiply, i32, vec3_i32, sem::EvaluationStage::kConstant, Source{{12, 34}}, @@ -775,8 +775,8 @@ TEST_F(IntrinsicTableTest, MatchCompoundOp) { } TEST_F(IntrinsicTableTest, MismatchCompoundOp) { - auto* f32 = create(); - auto* bool_ = create(); + auto* f32 = create(); + auto* bool_ = create(); auto result = table->Lookup(ast::BinaryOp::kMultiply, f32, bool_, sem::EvaluationStage::kConstant, Source{{12, 34}}, /* is_compound */ true); @@ -797,7 +797,7 @@ TEST_F(IntrinsicTableTest, MismatchCompoundOp) { } TEST_F(IntrinsicTableTest, MatchTypeInitializerImplicit) { - auto* i32 = create(); + auto* i32 = create(); auto* vec3_i32 = create(i32, 3u); auto result = table->Lookup(InitConvIntrinsic::kVec3, nullptr, utils::Vector{i32, i32, i32}, sem::EvaluationStage::kConstant, Source{{12, 34}}); @@ -812,7 +812,7 @@ TEST_F(IntrinsicTableTest, MatchTypeInitializerImplicit) { } TEST_F(IntrinsicTableTest, MatchTypeInitializerExplicit) { - auto* i32 = create(); + auto* i32 = create(); auto* vec3_i32 = create(i32, 3u); auto result = table->Lookup(InitConvIntrinsic::kVec3, i32, utils::Vector{i32, i32, i32}, sem::EvaluationStage::kConstant, Source{{12, 34}}); @@ -827,8 +827,8 @@ TEST_F(IntrinsicTableTest, MatchTypeInitializerExplicit) { } TEST_F(IntrinsicTableTest, MismatchTypeInitializerImplicit) { - auto* i32 = create(); - auto* f32 = create(); + auto* i32 = create(); + auto* f32 = create(); auto result = table->Lookup(InitConvIntrinsic::kVec3, nullptr, utils::Vector{i32, f32, i32}, sem::EvaluationStage::kConstant, Source{{12, 34}}); ASSERT_EQ(result.target, nullptr); @@ -853,8 +853,8 @@ TEST_F(IntrinsicTableTest, MismatchTypeInitializerImplicit) { } TEST_F(IntrinsicTableTest, MismatchTypeInitializerExplicit) { - auto* i32 = create(); - auto* f32 = create(); + auto* i32 = create(); + auto* f32 = create(); auto result = table->Lookup(InitConvIntrinsic::kVec3, i32, utils::Vector{i32, f32, i32}, sem::EvaluationStage::kConstant, Source{{12, 34}}); ASSERT_EQ(result.target, nullptr); @@ -928,7 +928,7 @@ TEST_F(IntrinsicTableTest, MatchTypeInitializer_RuntimeEval) { auto* ai = create(); auto result = table->Lookup(InitConvIntrinsic::kVec3, nullptr, utils::Vector{ai, ai, ai}, sem::EvaluationStage::kRuntime, Source{{12, 34}}); - auto* i32 = create(); + auto* i32 = create(); auto* vec3_i32 = create(i32, 3u); ASSERT_NE(result.target, nullptr); EXPECT_EQ(result.target->Stage(), sem::EvaluationStage::kConstant); @@ -942,9 +942,9 @@ TEST_F(IntrinsicTableTest, MatchTypeInitializer_RuntimeEval) { } TEST_F(IntrinsicTableTest, MatchTypeConversion) { - auto* i32 = create(); + auto* i32 = create(); auto* vec3_i32 = create(i32, 3u); - auto* f32 = create(); + auto* f32 = create(); auto* vec3_f32 = create(f32, 3u); auto result = table->Lookup(InitConvIntrinsic::kVec3, i32, utils::Vector{vec3_f32}, sem::EvaluationStage::kConstant, Source{{12, 34}}); @@ -957,8 +957,8 @@ TEST_F(IntrinsicTableTest, MatchTypeConversion) { TEST_F(IntrinsicTableTest, MismatchTypeConversion) { auto* arr = - create(create(), create(), 4u, 4u, 4u, 4u); - auto* f32 = create(); + create(create(), create(), 4u, 4u, 4u, 4u); + auto* f32 = create(); auto result = table->Lookup(InitConvIntrinsic::kVec3, f32, utils::Vector{arr}, sem::EvaluationStage::kConstant, Source{{12, 34}}); ASSERT_EQ(result.target, nullptr); @@ -986,7 +986,7 @@ TEST_F(IntrinsicTableTest, MatchTypeConversion_ConstantEval) { auto* ai = create(); auto* af = create(); auto* vec3_ai = create(ai, 3u); - auto* f32 = create(); + auto* f32 = create(); auto* vec3_f32 = create(f32, 3u); auto result = table->Lookup(InitConvIntrinsic::kVec3, af, utils::Vector{vec3_ai}, sem::EvaluationStage::kConstant, Source{{12, 34}}); @@ -1003,8 +1003,8 @@ TEST_F(IntrinsicTableTest, MatchTypeConversion_RuntimeEval) { auto* ai = create(); auto* af = create(); auto* vec3_ai = create(ai, 3u); - auto* vec3_f32 = create(create(), 3u); - auto* vec3_i32 = create(create(), 3u); + auto* vec3_f32 = create(create(), 3u); + auto* vec3_i32 = create(create(), 3u); auto result = table->Lookup(InitConvIntrinsic::kVec3, af, utils::Vector{vec3_ai}, sem::EvaluationStage::kRuntime, Source{{12, 34}}); ASSERT_NE(result.target, nullptr); @@ -1016,7 +1016,7 @@ TEST_F(IntrinsicTableTest, MatchTypeConversion_RuntimeEval) { } TEST_F(IntrinsicTableTest, Err257Arguments) { // crbug.com/1323605 - auto* f32 = create(); + auto* f32 = create(); utils::Vector arg_tys; arg_tys.Resize(257, f32); auto result = table->Lookup(BuiltinType::kAbs, std::move(arg_tys), @@ -1031,7 +1031,7 @@ TEST_F(IntrinsicTableTest, OverloadResolution) { // conv i32(T) -> i32 // The first should win overload resolution. auto* ai = create(); - auto* i32 = create(); + auto* i32 = create(); auto result = table->Lookup(InitConvIntrinsic::kI32, nullptr, utils::Vector{ai}, sem::EvaluationStage::kConstant, Source{}); ASSERT_NE(result.target, nullptr); diff --git a/src/tint/resolver/is_host_shareable_test.cc b/src/tint/resolver/is_host_shareable_test.cc index c1060204b3..51bc52b501 100644 --- a/src/tint/resolver/is_host_shareable_test.cc +++ b/src/tint/resolver/is_host_shareable_test.cc @@ -24,54 +24,54 @@ namespace { using ResolverIsHostShareable = ResolverTest; TEST_F(ResolverIsHostShareable, Void) { - EXPECT_FALSE(r()->IsHostShareable(create())); + EXPECT_FALSE(r()->IsHostShareable(create())); } TEST_F(ResolverIsHostShareable, Bool) { - EXPECT_FALSE(r()->IsHostShareable(create())); + EXPECT_FALSE(r()->IsHostShareable(create())); } TEST_F(ResolverIsHostShareable, NumericScalar) { - EXPECT_TRUE(r()->IsHostShareable(create())); - EXPECT_TRUE(r()->IsHostShareable(create())); - EXPECT_TRUE(r()->IsHostShareable(create())); - EXPECT_TRUE(r()->IsHostShareable(create())); + EXPECT_TRUE(r()->IsHostShareable(create())); + EXPECT_TRUE(r()->IsHostShareable(create())); + EXPECT_TRUE(r()->IsHostShareable(create())); + EXPECT_TRUE(r()->IsHostShareable(create())); } TEST_F(ResolverIsHostShareable, NumericVector) { - EXPECT_TRUE(r()->IsHostShareable(create(create(), 2u))); - EXPECT_TRUE(r()->IsHostShareable(create(create(), 3u))); - EXPECT_TRUE(r()->IsHostShareable(create(create(), 4u))); - EXPECT_TRUE(r()->IsHostShareable(create(create(), 2u))); - EXPECT_TRUE(r()->IsHostShareable(create(create(), 3u))); - EXPECT_TRUE(r()->IsHostShareable(create(create(), 4u))); - EXPECT_TRUE(r()->IsHostShareable(create(create(), 2u))); - EXPECT_TRUE(r()->IsHostShareable(create(create(), 3u))); - EXPECT_TRUE(r()->IsHostShareable(create(create(), 4u))); - EXPECT_TRUE(r()->IsHostShareable(create(create(), 2u))); - EXPECT_TRUE(r()->IsHostShareable(create(create(), 3u))); - EXPECT_TRUE(r()->IsHostShareable(create(create(), 4u))); + EXPECT_TRUE(r()->IsHostShareable(create(create(), 2u))); + EXPECT_TRUE(r()->IsHostShareable(create(create(), 3u))); + EXPECT_TRUE(r()->IsHostShareable(create(create(), 4u))); + EXPECT_TRUE(r()->IsHostShareable(create(create(), 2u))); + EXPECT_TRUE(r()->IsHostShareable(create(create(), 3u))); + EXPECT_TRUE(r()->IsHostShareable(create(create(), 4u))); + EXPECT_TRUE(r()->IsHostShareable(create(create(), 2u))); + EXPECT_TRUE(r()->IsHostShareable(create(create(), 3u))); + EXPECT_TRUE(r()->IsHostShareable(create(create(), 4u))); + EXPECT_TRUE(r()->IsHostShareable(create(create(), 2u))); + EXPECT_TRUE(r()->IsHostShareable(create(create(), 3u))); + EXPECT_TRUE(r()->IsHostShareable(create(create(), 4u))); } TEST_F(ResolverIsHostShareable, BoolVector) { - EXPECT_FALSE(r()->IsHostShareable(create(create(), 2u))); - EXPECT_FALSE(r()->IsHostShareable(create(create(), 3u))); - EXPECT_FALSE(r()->IsHostShareable(create(create(), 4u))); - EXPECT_FALSE(r()->IsHostShareable(create(create(), 2u))); - EXPECT_FALSE(r()->IsHostShareable(create(create(), 3u))); - EXPECT_FALSE(r()->IsHostShareable(create(create(), 4u))); - EXPECT_FALSE(r()->IsHostShareable(create(create(), 2u))); - EXPECT_FALSE(r()->IsHostShareable(create(create(), 3u))); - EXPECT_FALSE(r()->IsHostShareable(create(create(), 4u))); + EXPECT_FALSE(r()->IsHostShareable(create(create(), 2u))); + EXPECT_FALSE(r()->IsHostShareable(create(create(), 3u))); + EXPECT_FALSE(r()->IsHostShareable(create(create(), 4u))); + EXPECT_FALSE(r()->IsHostShareable(create(create(), 2u))); + EXPECT_FALSE(r()->IsHostShareable(create(create(), 3u))); + EXPECT_FALSE(r()->IsHostShareable(create(create(), 4u))); + EXPECT_FALSE(r()->IsHostShareable(create(create(), 2u))); + EXPECT_FALSE(r()->IsHostShareable(create(create(), 3u))); + EXPECT_FALSE(r()->IsHostShareable(create(create(), 4u))); } TEST_F(ResolverIsHostShareable, Matrix) { - auto* vec2_f32 = create(create(), 2u); - auto* vec3_f32 = create(create(), 3u); - auto* vec4_f32 = create(create(), 4u); - auto* vec2_f16 = create(create(), 2u); - auto* vec3_f16 = create(create(), 3u); - auto* vec4_f16 = create(create(), 4u); + auto* vec2_f32 = create(create(), 2u); + auto* vec3_f32 = create(create(), 3u); + auto* vec4_f32 = create(create(), 4u); + auto* vec2_f16 = create(create(), 2u); + auto* vec3_f16 = create(create(), 3u); + auto* vec4_f16 = create(create(), 4u); EXPECT_TRUE(r()->IsHostShareable(create(vec2_f32, 2u))); EXPECT_TRUE(r()->IsHostShareable(create(vec2_f32, 3u))); @@ -95,25 +95,25 @@ TEST_F(ResolverIsHostShareable, Matrix) { } TEST_F(ResolverIsHostShareable, Pointer) { - auto* ptr = create(create(), ast::AddressSpace::kPrivate, + auto* ptr = create(create(), ast::AddressSpace::kPrivate, ast::Access::kReadWrite); EXPECT_FALSE(r()->IsHostShareable(ptr)); } TEST_F(ResolverIsHostShareable, Atomic) { - EXPECT_TRUE(r()->IsHostShareable(create(create()))); - EXPECT_TRUE(r()->IsHostShareable(create(create()))); + EXPECT_TRUE(r()->IsHostShareable(create(create()))); + EXPECT_TRUE(r()->IsHostShareable(create(create()))); } TEST_F(ResolverIsHostShareable, ArraySizedOfHostShareable) { - auto* arr = create(create(), create(5u), 4u, + auto* arr = create(create(), create(5u), 4u, 20u, 4u, 4u); EXPECT_TRUE(r()->IsHostShareable(arr)); } TEST_F(ResolverIsHostShareable, ArrayUnsizedOfHostShareable) { auto* arr = - create(create(), create(), 4u, 4u, 4u, 4u); + create(create(), create(), 4u, 4u, 4u, 4u); EXPECT_TRUE(r()->IsHostShareable(arr)); } diff --git a/src/tint/resolver/is_storeable_test.cc b/src/tint/resolver/is_storeable_test.cc index 9c80e0aa26..4f7edc405d 100644 --- a/src/tint/resolver/is_storeable_test.cc +++ b/src/tint/resolver/is_storeable_test.cc @@ -24,39 +24,39 @@ namespace { using ResolverIsStorableTest = ResolverTest; TEST_F(ResolverIsStorableTest, Void) { - EXPECT_FALSE(r()->IsStorable(create())); + EXPECT_FALSE(r()->IsStorable(create())); } TEST_F(ResolverIsStorableTest, Scalar) { - EXPECT_TRUE(r()->IsStorable(create())); - EXPECT_TRUE(r()->IsStorable(create())); - EXPECT_TRUE(r()->IsStorable(create())); - EXPECT_TRUE(r()->IsStorable(create())); - EXPECT_TRUE(r()->IsStorable(create())); + EXPECT_TRUE(r()->IsStorable(create())); + EXPECT_TRUE(r()->IsStorable(create())); + EXPECT_TRUE(r()->IsStorable(create())); + EXPECT_TRUE(r()->IsStorable(create())); + EXPECT_TRUE(r()->IsStorable(create())); } TEST_F(ResolverIsStorableTest, Vector) { - EXPECT_TRUE(r()->IsStorable(create(create(), 2u))); - EXPECT_TRUE(r()->IsStorable(create(create(), 3u))); - EXPECT_TRUE(r()->IsStorable(create(create(), 4u))); - EXPECT_TRUE(r()->IsStorable(create(create(), 2u))); - EXPECT_TRUE(r()->IsStorable(create(create(), 3u))); - EXPECT_TRUE(r()->IsStorable(create(create(), 4u))); - EXPECT_TRUE(r()->IsStorable(create(create(), 2u))); - EXPECT_TRUE(r()->IsStorable(create(create(), 3u))); - EXPECT_TRUE(r()->IsStorable(create(create(), 4u))); - EXPECT_TRUE(r()->IsStorable(create(create(), 2u))); - EXPECT_TRUE(r()->IsStorable(create(create(), 3u))); - EXPECT_TRUE(r()->IsStorable(create(create(), 4u))); + EXPECT_TRUE(r()->IsStorable(create(create(), 2u))); + EXPECT_TRUE(r()->IsStorable(create(create(), 3u))); + EXPECT_TRUE(r()->IsStorable(create(create(), 4u))); + EXPECT_TRUE(r()->IsStorable(create(create(), 2u))); + EXPECT_TRUE(r()->IsStorable(create(create(), 3u))); + EXPECT_TRUE(r()->IsStorable(create(create(), 4u))); + EXPECT_TRUE(r()->IsStorable(create(create(), 2u))); + EXPECT_TRUE(r()->IsStorable(create(create(), 3u))); + EXPECT_TRUE(r()->IsStorable(create(create(), 4u))); + EXPECT_TRUE(r()->IsStorable(create(create(), 2u))); + EXPECT_TRUE(r()->IsStorable(create(create(), 3u))); + EXPECT_TRUE(r()->IsStorable(create(create(), 4u))); } TEST_F(ResolverIsStorableTest, Matrix) { - auto* vec2_f32 = create(create(), 2u); - auto* vec3_f32 = create(create(), 3u); - auto* vec4_f32 = create(create(), 4u); - auto* vec2_f16 = create(create(), 2u); - auto* vec3_f16 = create(create(), 3u); - auto* vec4_f16 = create(create(), 4u); + auto* vec2_f32 = create(create(), 2u); + auto* vec3_f32 = create(create(), 3u); + auto* vec4_f32 = create(create(), 4u); + auto* vec2_f16 = create(create(), 2u); + auto* vec3_f16 = create(create(), 3u); + auto* vec4_f16 = create(create(), 4u); EXPECT_TRUE(r()->IsStorable(create(vec2_f32, 2u))); EXPECT_TRUE(r()->IsStorable(create(vec2_f32, 3u))); EXPECT_TRUE(r()->IsStorable(create(vec2_f32, 4u))); @@ -78,25 +78,25 @@ TEST_F(ResolverIsStorableTest, Matrix) { } TEST_F(ResolverIsStorableTest, Pointer) { - auto* ptr = create(create(), ast::AddressSpace::kPrivate, + auto* ptr = create(create(), ast::AddressSpace::kPrivate, ast::Access::kReadWrite); EXPECT_FALSE(r()->IsStorable(ptr)); } TEST_F(ResolverIsStorableTest, Atomic) { - EXPECT_TRUE(r()->IsStorable(create(create()))); - EXPECT_TRUE(r()->IsStorable(create(create()))); + EXPECT_TRUE(r()->IsStorable(create(create()))); + EXPECT_TRUE(r()->IsStorable(create(create()))); } TEST_F(ResolverIsStorableTest, ArraySizedOfStorable) { - auto* arr = create(create(), create(5u), 4u, + auto* arr = create(create(), create(5u), 4u, 20u, 4u, 4u); EXPECT_TRUE(r()->IsStorable(arr)); } TEST_F(ResolverIsStorableTest, ArrayUnsizedOfStorable) { auto* arr = - create(create(), create(), 4u, 4u, 4u, 4u); + create(create(), create(), 4u, 4u, 4u, 4u); EXPECT_TRUE(r()->IsStorable(arr)); } diff --git a/src/tint/resolver/materialize_test.cc b/src/tint/resolver/materialize_test.cc index d94256097a..4451f9d53e 100644 --- a/src/tint/resolver/materialize_test.cc +++ b/src/tint/resolver/materialize_test.cc @@ -1254,7 +1254,7 @@ TEST_F(MaterializeAbstractStructure, Modf_Scalar_DefaultType) { auto* materialize = sem->As(); ASSERT_TRUE(materialize->Type()->Is()); auto* concrete_str = materialize->Type()->As(); - ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is()); + ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is()); ASSERT_TRUE(materialize->Expr()->Type()->Is()); auto* abstract_str = materialize->Expr()->Type()->As(); ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is()); @@ -1271,7 +1271,7 @@ TEST_F(MaterializeAbstractStructure, Modf_Vector_DefaultType) { ASSERT_TRUE(materialize->Type()->Is()); auto* concrete_str = materialize->Type()->As(); ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is()); - ASSERT_TRUE(concrete_str->Members()[0]->Type()->As()->type()->Is()); + ASSERT_TRUE(concrete_str->Members()[0]->Type()->As()->type()->Is()); ASSERT_TRUE(materialize->Expr()->Type()->Is()); auto* abstract_str = materialize->Expr()->Type()->As(); ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is()); @@ -1292,7 +1292,7 @@ TEST_F(MaterializeAbstractStructure, Modf_Scalar_ExplicitType) { auto* materialize = sem->As(); ASSERT_TRUE(materialize->Type()->Is()); auto* concrete_str = materialize->Type()->As(); - ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is()); + ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is()); ASSERT_TRUE(materialize->Expr()->Type()->Is()); auto* abstract_str = materialize->Expr()->Type()->As(); ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is()); @@ -1312,7 +1312,7 @@ TEST_F(MaterializeAbstractStructure, Modf_Vector_ExplicitType) { ASSERT_TRUE(materialize->Type()->Is()); auto* concrete_str = materialize->Type()->As(); ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is()); - ASSERT_TRUE(concrete_str->Members()[0]->Type()->As()->type()->Is()); + ASSERT_TRUE(concrete_str->Members()[0]->Type()->As()->type()->Is()); ASSERT_TRUE(materialize->Expr()->Type()->Is()); auto* abstract_str = materialize->Expr()->Type()->As(); ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is()); @@ -1330,8 +1330,8 @@ TEST_F(MaterializeAbstractStructure, Frexp_Scalar_DefaultType) { auto* materialize = sem->As(); ASSERT_TRUE(materialize->Type()->Is()); auto* concrete_str = materialize->Type()->As(); - ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is()); - ASSERT_TRUE(concrete_str->Members()[1]->Type()->Is()); + ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is()); + ASSERT_TRUE(concrete_str->Members()[1]->Type()->Is()); ASSERT_TRUE(materialize->Expr()->Type()->Is()); auto* abstract_str = materialize->Expr()->Type()->As(); ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is()); @@ -1350,8 +1350,8 @@ TEST_F(MaterializeAbstractStructure, Frexp_Vector_DefaultType) { auto* concrete_str = materialize->Type()->As(); ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is()); ASSERT_TRUE(concrete_str->Members()[1]->Type()->Is()); - ASSERT_TRUE(concrete_str->Members()[0]->Type()->As()->type()->Is()); - ASSERT_TRUE(concrete_str->Members()[1]->Type()->As()->type()->Is()); + ASSERT_TRUE(concrete_str->Members()[0]->Type()->As()->type()->Is()); + ASSERT_TRUE(concrete_str->Members()[1]->Type()->As()->type()->Is()); ASSERT_TRUE(materialize->Expr()->Type()->Is()); auto* abstract_str = materialize->Expr()->Type()->As(); ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is()); @@ -1374,8 +1374,8 @@ TEST_F(MaterializeAbstractStructure, Frexp_Scalar_ExplicitType) { auto* materialize = sem->As(); ASSERT_TRUE(materialize->Type()->Is()); auto* concrete_str = materialize->Type()->As(); - ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is()); - ASSERT_TRUE(concrete_str->Members()[1]->Type()->Is()); + ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is()); + ASSERT_TRUE(concrete_str->Members()[1]->Type()->Is()); ASSERT_TRUE(materialize->Expr()->Type()->Is()); auto* abstract_str = materialize->Expr()->Type()->As(); ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is()); @@ -1397,8 +1397,8 @@ TEST_F(MaterializeAbstractStructure, Frexp_Vector_ExplicitType) { auto* concrete_str = materialize->Type()->As(); ASSERT_TRUE(concrete_str->Members()[0]->Type()->Is()); ASSERT_TRUE(concrete_str->Members()[1]->Type()->Is()); - ASSERT_TRUE(concrete_str->Members()[0]->Type()->As()->type()->Is()); - ASSERT_TRUE(concrete_str->Members()[1]->Type()->As()->type()->Is()); + ASSERT_TRUE(concrete_str->Members()[0]->Type()->As()->type()->Is()); + ASSERT_TRUE(concrete_str->Members()[1]->Type()->As()->type()->Is()); ASSERT_TRUE(materialize->Expr()->Type()->Is()); auto* abstract_str = materialize->Expr()->Type()->As(); ASSERT_TRUE(abstract_str->Members()[0]->Type()->Is()); diff --git a/src/tint/resolver/ptr_ref_test.cc b/src/tint/resolver/ptr_ref_test.cc index a42d554111..872bcdc4dc 100644 --- a/src/tint/resolver/ptr_ref_test.cc +++ b/src/tint/resolver/ptr_ref_test.cc @@ -37,7 +37,7 @@ TEST_F(ResolverPtrRefTest, AddressOf) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_TRUE(TypeOf(expr)->Is()); - EXPECT_TRUE(TypeOf(expr)->As()->StoreType()->Is()); + EXPECT_TRUE(TypeOf(expr)->As()->StoreType()->Is()); EXPECT_EQ(TypeOf(expr)->As()->AddressSpace(), ast::AddressSpace::kFunction); } @@ -53,7 +53,7 @@ TEST_F(ResolverPtrRefTest, AddressOfThenDeref) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_TRUE(TypeOf(expr)->Is()); - EXPECT_TRUE(TypeOf(expr)->As()->StoreType()->Is()); + EXPECT_TRUE(TypeOf(expr)->As()->StoreType()->Is()); } TEST_F(ResolverPtrRefTest, DefaultPtrAddressSpace) { diff --git a/src/tint/resolver/resolver.cc b/src/tint/resolver/resolver.cc index 18a6f59b26..bf12325c0f 100644 --- a/src/tint/resolver/resolver.cc +++ b/src/tint/resolver/resolver.cc @@ -203,19 +203,19 @@ type::Type* Resolver::Type(const ast::Type* ty) { Mark(ty); auto* s = Switch( ty, // - [&](const ast::Void*) { return builder_->create(); }, - [&](const ast::Bool*) { return builder_->create(); }, - [&](const ast::I32*) { return builder_->create(); }, - [&](const ast::U32*) { return builder_->create(); }, - [&](const ast::F16* t) -> sem::F16* { + [&](const ast::Void*) { return builder_->create(); }, + [&](const ast::Bool*) { return builder_->create(); }, + [&](const ast::I32*) { return builder_->create(); }, + [&](const ast::U32*) { return builder_->create(); }, + [&](const ast::F16* t) -> type::F16* { // Validate if f16 type is allowed. if (!enabled_extensions_.Contains(ast::Extension::kF16)) { AddError("f16 used without 'f16' extension enabled", t->source); return nullptr; } - return builder_->create(); + return builder_->create(); }, - [&](const ast::F32*) { return builder_->create(); }, + [&](const ast::F32*) { return builder_->create(); }, [&](const ast::Vector* t) -> sem::Vector* { if (!t->type) { AddError("missing vector element type", t->source.End()); @@ -481,7 +481,7 @@ sem::Variable* Resolver::Override(const ast::Override* v) { if (!materialized) { return nullptr; } - if (!materialized->Type()->IsAnyOf()) { + if (!materialized->Type()->IsAnyOf()) { AddError("@id must be an i32 or u32 value", id_attr->source); return nullptr; } @@ -661,7 +661,7 @@ sem::Variable* Resolver::Var(const ast::Var* var, bool is_global) { if (!materialized) { return nullptr; } - if (!materialized->Type()->IsAnyOf()) { + if (!materialized->Type()->IsAnyOf()) { AddError("@binding must be an i32 or u32 value", attr->source); return nullptr; } @@ -685,7 +685,7 @@ sem::Variable* Resolver::Var(const ast::Var* var, bool is_global) { if (!materialized) { return nullptr; } - if (!materialized->Type()->IsAnyOf()) { + if (!materialized->Type()->IsAnyOf()) { AddError("@group must be an i32 or u32 value", attr->source); return nullptr; } @@ -809,7 +809,7 @@ utils::Result Resolver::LocationAttribute(const ast::LocationAttribute return utils::Failure; } - if (!materialized->Type()->IsAnyOf()) { + if (!materialized->Type()->IsAnyOf()) { AddError("@location must be an i32 or u32 value", attr->source); return utils::Failure; } @@ -947,7 +947,7 @@ sem::Statement* Resolver::StaticAssert(const ast::StaticAssert* assertion) { return nullptr; } auto* cond = expr->ConstantValue(); - if (auto* ty = cond->Type(); !ty->Is()) { + if (auto* ty = cond->Type(); !ty->Is()) { AddError( "static assertion condition must be a bool, got '" + builder_->FriendlyName(ty) + "'", assertion->condition->source); @@ -1018,7 +1018,7 @@ sem::Function* Resolver::Function(const ast::Function* decl) { return nullptr; } } else { - return_type = builder_->create(); + return_type = builder_->create(); } // Determine if the return type has a location @@ -1155,7 +1155,7 @@ bool Resolver::WorkgroupSize(const ast::Function* func) { return false; } auto* ty = expr->Type(); - if (!ty->IsAnyOf()) { + if (!ty->IsAnyOf()) { AddError(kErrBadExpr, value->source); return false; } @@ -1179,7 +1179,7 @@ bool Resolver::WorkgroupSize(const ast::Function* func) { // If all arguments are abstract-integers, then materialize to i32. if (common_ty->Is()) { - common_ty = builder_->create(); + common_ty = builder_->create(); } for (size_t i = 0; i < args.Length(); i++) { @@ -1293,7 +1293,7 @@ sem::CaseStatement* Resolver::CaseStatement(const ast::CaseStatement* stmt, cons if (!materialized) { return false; } - if (!materialized->Type()->IsAnyOf()) { + if (!materialized->Type()->IsAnyOf()) { AddError("case selector must be an i32 or u32 value", sel->source); return false; } @@ -1542,7 +1542,7 @@ sem::Expression* Resolver::Expression(const ast::Expression* root) { }, [&](const ast::UnaryOpExpression* unary) -> sem::Expression* { return UnaryOp(unary); }, [&](const ast::PhonyExpression*) -> sem::Expression* { - return builder_->create(expr, builder_->create(), + return builder_->create(expr, builder_->create(), sem::EvaluationStage::kRuntime, current_statement_, /* constant_value */ nullptr, @@ -1716,8 +1716,8 @@ bool Resolver::AliasAnalysis(const sem::Call* call) { const type::Type* Resolver::ConcreteType(const type::Type* ty, const type::Type* target_ty, const Source& source) { - auto i32 = [&] { return builder_->create(); }; - auto f32 = [&] { return builder_->create(); }; + auto i32 = [&] { return builder_->create(); }; + auto f32 = [&] { return builder_->create(); }; auto i32v = [&](uint32_t width) { return builder_->create(i32(), width); }; auto f32v = [&](uint32_t width) { return builder_->create(f32(), width); }; auto f32m = [&](uint32_t columns, uint32_t rows) { @@ -1883,7 +1883,7 @@ sem::Expression* Resolver::IndexAccessor(const ast::IndexAccessorExpression* exp } auto* idx_ty = idx->Type()->UnwrapRef(); - if (!idx_ty->IsAnyOf()) { + if (!idx_ty->IsAnyOf()) { AddError("index must be of type 'i32' or 'u32', found: '" + sem_.TypeNameOf(idx_ty) + "'", idx->Declaration()->source); return nullptr; @@ -2040,11 +2040,11 @@ sem::Call* Resolver::Call(const ast::CallExpression* expr) { [&](const sem::Matrix* m) { return ct_init_or_conv(MatrixInitConvIntrinsic(m->columns(), m->rows()), m->type()); }, - [&](const sem::I32*) { return ct_init_or_conv(InitConvIntrinsic::kI32, nullptr); }, - [&](const sem::U32*) { return ct_init_or_conv(InitConvIntrinsic::kU32, nullptr); }, - [&](const sem::F16*) { return ct_init_or_conv(InitConvIntrinsic::kF16, nullptr); }, - [&](const sem::F32*) { return ct_init_or_conv(InitConvIntrinsic::kF32, nullptr); }, - [&](const sem::Bool*) { return ct_init_or_conv(InitConvIntrinsic::kBool, nullptr); }, + [&](const type::I32*) { return ct_init_or_conv(InitConvIntrinsic::kI32, nullptr); }, + [&](const type::U32*) { return ct_init_or_conv(InitConvIntrinsic::kU32, nullptr); }, + [&](const type::F16*) { return ct_init_or_conv(InitConvIntrinsic::kF16, nullptr); }, + [&](const type::F32*) { return ct_init_or_conv(InitConvIntrinsic::kF32, nullptr); }, + [&](const type::Bool*) { return ct_init_or_conv(InitConvIntrinsic::kBool, nullptr); }, [&](const sem::Array* arr) -> sem::Call* { auto* call_target = array_inits_.GetOrCreate( ArrayInitializerSig{{arr, args.Length(), args_stage}}, @@ -2351,29 +2351,29 @@ type::Type* Resolver::BuiltinTypeAlias(Symbol sym) const { auto& b = *builder_; switch (ParseTypeAlias(name)) { case TypeAlias::kVec2F: - return b.create(b.create(), 2u); + return b.create(b.create(), 2u); case TypeAlias::kVec3F: - return b.create(b.create(), 3u); + return b.create(b.create(), 3u); case TypeAlias::kVec4F: - return b.create(b.create(), 4u); + return b.create(b.create(), 4u); case TypeAlias::kVec2H: - return b.create(b.create(), 2u); + return b.create(b.create(), 2u); case TypeAlias::kVec3H: - return b.create(b.create(), 3u); + return b.create(b.create(), 3u); case TypeAlias::kVec4H: - return b.create(b.create(), 4u); + return b.create(b.create(), 4u); case TypeAlias::kVec2I: - return b.create(b.create(), 2u); + return b.create(b.create(), 2u); case TypeAlias::kVec3I: - return b.create(b.create(), 3u); + return b.create(b.create(), 3u); case TypeAlias::kVec4I: - return b.create(b.create(), 4u); + return b.create(b.create(), 4u); case TypeAlias::kVec2U: - return b.create(b.create(), 2u); + return b.create(b.create(), 2u); case TypeAlias::kVec3U: - return b.create(b.create(), 3u); + return b.create(b.create(), 3u); case TypeAlias::kVec4U: - return b.create(b.create(), 4u); + return b.create(b.create(), 4u); case TypeAlias::kUndefined: break; } @@ -2485,9 +2485,9 @@ sem::Expression* Resolver::Literal(const ast::LiteralExpression* literal) { case ast::IntLiteralExpression::Suffix::kNone: return builder_->create(); case ast::IntLiteralExpression::Suffix::kI: - return builder_->create(); + return builder_->create(); case ast::IntLiteralExpression::Suffix::kU: - return builder_->create(); + return builder_->create(); } return nullptr; }, @@ -2496,13 +2496,13 @@ sem::Expression* Resolver::Literal(const ast::LiteralExpression* literal) { case ast::FloatLiteralExpression::Suffix::kNone: return builder_->create(); case ast::FloatLiteralExpression::Suffix::kF: - return builder_->create(); + return builder_->create(); case ast::FloatLiteralExpression::Suffix::kH: - return builder_->create(); + return builder_->create(); } return nullptr; }, - [&](const ast::BoolLiteralExpression*) { return builder_->create(); }, + [&](const ast::BoolLiteralExpression*) { return builder_->create(); }, [&](Default) { return nullptr; }); if (ty == nullptr) { @@ -2511,7 +2511,7 @@ sem::Expression* Resolver::Literal(const ast::LiteralExpression* literal) { return nullptr; } - if ((ty->Is()) && (!enabled_extensions_.Contains(tint::ast::Extension::kF16))) { + if ((ty->Is()) && (!enabled_extensions_.Contains(tint::ast::Extension::kF16))) { AddError("f16 literal used without 'f16' extension enabled", literal->source); return nullptr; } @@ -3190,7 +3190,7 @@ sem::Struct* Resolver::Structure(const ast::Struct* str) { if (!materialized) { return false; } - if (!materialized->Type()->IsAnyOf()) { + if (!materialized->Type()->IsAnyOf()) { AddError("@align must be an i32 or u32 value", a->source); return false; } @@ -3219,7 +3219,7 @@ sem::Struct* Resolver::Structure(const ast::Struct* str) { if (!materialized) { return false; } - if (!materialized->Type()->IsAnyOf()) { + if (!materialized->Type()->IsAnyOf()) { AddError("@size must be an i32 or u32 value", s->source); return false; } @@ -3344,7 +3344,7 @@ sem::Statement* Resolver::ReturnStatement(const ast::ReturnStatement* stmt) { if (!expr) { return false; } - if (auto* ret_ty = current_function_->ReturnType(); !ret_ty->Is()) { + if (auto* ret_ty = current_function_->ReturnType(); !ret_ty->Is()) { expr = Materialize(expr, ret_ty); if (!expr) { return false; @@ -3355,7 +3355,7 @@ sem::Statement* Resolver::ReturnStatement(const ast::ReturnStatement* stmt) { RegisterLoadIfNeeded(expr); } else { - value_ty = builder_->create(); + value_ty = builder_->create(); } // Validate after processing the return value expression so that its type @@ -3401,7 +3401,7 @@ sem::SwitchStatement* Resolver::SwitchStatement(const ast::SwitchStatement* stmt if (!common_ty || !common_ty->is_integer_scalar()) { // No common type found or the common type was abstract. // Pick i32 and let validation deal with any mismatches. - common_ty = builder_->create(); + common_ty = builder_->create(); } cond = Materialize(cond, common_ty); if (!cond) { diff --git a/src/tint/resolver/resolver_test.cc b/src/tint/resolver/resolver_test.cc index 73a61a7655..7f3ea6af2d 100644 --- a/src/tint/resolver/resolver_test.cc +++ b/src/tint/resolver/resolver_test.cc @@ -99,8 +99,8 @@ TEST_F(ResolverTest, Stmt_Assign) { ASSERT_NE(TypeOf(lhs), nullptr); ASSERT_NE(TypeOf(rhs), nullptr); - EXPECT_TRUE(TypeOf(lhs)->UnwrapRef()->Is()); - EXPECT_TRUE(TypeOf(rhs)->Is()); + EXPECT_TRUE(TypeOf(lhs)->UnwrapRef()->Is()); + EXPECT_TRUE(TypeOf(rhs)->Is()); EXPECT_EQ(StmtOf(lhs), assign); EXPECT_EQ(StmtOf(rhs), assign); } @@ -123,8 +123,8 @@ TEST_F(ResolverTest, Stmt_Case) { ASSERT_NE(TypeOf(lhs), nullptr); ASSERT_NE(TypeOf(rhs), nullptr); - EXPECT_TRUE(TypeOf(lhs)->UnwrapRef()->Is()); - EXPECT_TRUE(TypeOf(rhs)->Is()); + EXPECT_TRUE(TypeOf(lhs)->UnwrapRef()->Is()); + EXPECT_TRUE(TypeOf(rhs)->Is()); EXPECT_EQ(StmtOf(lhs), assign); EXPECT_EQ(StmtOf(rhs), assign); EXPECT_EQ(BlockOf(assign), block); @@ -156,8 +156,8 @@ TEST_F(ResolverTest, Stmt_Block) { ASSERT_NE(TypeOf(lhs), nullptr); ASSERT_NE(TypeOf(rhs), nullptr); - EXPECT_TRUE(TypeOf(lhs)->UnwrapRef()->Is()); - EXPECT_TRUE(TypeOf(rhs)->Is()); + EXPECT_TRUE(TypeOf(lhs)->UnwrapRef()->Is()); + EXPECT_TRUE(TypeOf(rhs)->Is()); EXPECT_EQ(StmtOf(lhs), assign); EXPECT_EQ(StmtOf(rhs), assign); EXPECT_EQ(BlockOf(lhs), block); @@ -191,11 +191,11 @@ TEST_F(ResolverTest, Stmt_If) { ASSERT_NE(TypeOf(else_rhs), nullptr); ASSERT_NE(TypeOf(lhs), nullptr); ASSERT_NE(TypeOf(rhs), nullptr); - EXPECT_TRUE(TypeOf(stmt->condition)->Is()); - EXPECT_TRUE(TypeOf(else_lhs)->UnwrapRef()->Is()); - EXPECT_TRUE(TypeOf(else_rhs)->Is()); - EXPECT_TRUE(TypeOf(lhs)->UnwrapRef()->Is()); - EXPECT_TRUE(TypeOf(rhs)->Is()); + EXPECT_TRUE(TypeOf(stmt->condition)->Is()); + EXPECT_TRUE(TypeOf(else_lhs)->UnwrapRef()->Is()); + EXPECT_TRUE(TypeOf(else_rhs)->Is()); + EXPECT_TRUE(TypeOf(lhs)->UnwrapRef()->Is()); + EXPECT_TRUE(TypeOf(rhs)->Is()); EXPECT_EQ(StmtOf(lhs), assign); EXPECT_EQ(StmtOf(rhs), assign); EXPECT_EQ(StmtOf(cond), stmt); @@ -226,10 +226,10 @@ TEST_F(ResolverTest, Stmt_Loop) { ASSERT_NE(TypeOf(body_rhs), nullptr); ASSERT_NE(TypeOf(continuing_lhs), nullptr); ASSERT_NE(TypeOf(continuing_rhs), nullptr); - EXPECT_TRUE(TypeOf(body_lhs)->UnwrapRef()->Is()); - EXPECT_TRUE(TypeOf(body_rhs)->Is()); - EXPECT_TRUE(TypeOf(continuing_lhs)->UnwrapRef()->Is()); - EXPECT_TRUE(TypeOf(continuing_rhs)->Is()); + EXPECT_TRUE(TypeOf(body_lhs)->UnwrapRef()->Is()); + EXPECT_TRUE(TypeOf(body_rhs)->Is()); + EXPECT_TRUE(TypeOf(continuing_lhs)->UnwrapRef()->Is()); + EXPECT_TRUE(TypeOf(continuing_rhs)->Is()); EXPECT_EQ(BlockOf(body_lhs), body); EXPECT_EQ(BlockOf(body_rhs), body); EXPECT_EQ(BlockOf(continuing_lhs), continuing); @@ -246,7 +246,7 @@ TEST_F(ResolverTest, Stmt_Return) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(cond), nullptr); - EXPECT_TRUE(TypeOf(cond)->Is()); + EXPECT_TRUE(TypeOf(cond)->Is()); } TEST_F(ResolverTest, Stmt_Return_WithoutValue) { @@ -270,9 +270,9 @@ TEST_F(ResolverTest, Stmt_Switch) { ASSERT_NE(TypeOf(lhs), nullptr); ASSERT_NE(TypeOf(rhs), nullptr); - EXPECT_TRUE(TypeOf(stmt->condition)->Is()); - EXPECT_TRUE(TypeOf(lhs)->UnwrapRef()->Is()); - EXPECT_TRUE(TypeOf(rhs)->Is()); + EXPECT_TRUE(TypeOf(stmt->condition)->Is()); + EXPECT_TRUE(TypeOf(lhs)->UnwrapRef()->Is()); + EXPECT_TRUE(TypeOf(rhs)->Is()); EXPECT_EQ(BlockOf(lhs), case_block); EXPECT_EQ(BlockOf(rhs), case_block); } @@ -291,7 +291,7 @@ TEST_F(ResolverTest, Stmt_Call) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(expr), nullptr); - EXPECT_TRUE(TypeOf(expr)->Is()); + EXPECT_TRUE(TypeOf(expr)->Is()); EXPECT_EQ(StmtOf(expr), call); } @@ -305,7 +305,7 @@ TEST_F(ResolverTest, Stmt_VariableDecl) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(init), nullptr); - EXPECT_TRUE(TypeOf(init)->Is()); + EXPECT_TRUE(TypeOf(init)->Is()); } TEST_F(ResolverTest, Stmt_VariableDecl_Alias) { @@ -319,7 +319,7 @@ TEST_F(ResolverTest, Stmt_VariableDecl_Alias) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(init), nullptr); - EXPECT_TRUE(TypeOf(init)->Is()); + EXPECT_TRUE(TypeOf(init)->Is()); } TEST_F(ResolverTest, Stmt_VariableDecl_ModuleScope) { @@ -329,7 +329,7 @@ TEST_F(ResolverTest, Stmt_VariableDecl_ModuleScope) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(init), nullptr); - EXPECT_TRUE(TypeOf(init)->Is()); + EXPECT_TRUE(TypeOf(init)->Is()); EXPECT_EQ(StmtOf(init), nullptr); } @@ -369,13 +369,13 @@ TEST_F(ResolverTest, Stmt_VariableDecl_OuterScopeAfterInnerScope) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(foo_i32_init), nullptr); - EXPECT_TRUE(TypeOf(foo_i32_init)->Is()); + EXPECT_TRUE(TypeOf(foo_i32_init)->Is()); ASSERT_NE(TypeOf(foo_f32_init), nullptr); - EXPECT_TRUE(TypeOf(foo_f32_init)->Is()); + EXPECT_TRUE(TypeOf(foo_f32_init)->Is()); ASSERT_NE(TypeOf(bar_i32_init), nullptr); - EXPECT_TRUE(TypeOf(bar_i32_init)->UnwrapRef()->Is()); + EXPECT_TRUE(TypeOf(bar_i32_init)->UnwrapRef()->Is()); ASSERT_NE(TypeOf(bar_f32_init), nullptr); - EXPECT_TRUE(TypeOf(bar_f32_init)->UnwrapRef()->Is()); + EXPECT_TRUE(TypeOf(bar_f32_init)->UnwrapRef()->Is()); EXPECT_EQ(StmtOf(foo_i32_init), foo_i32_decl); EXPECT_EQ(StmtOf(bar_i32_init), bar_i32_decl); EXPECT_EQ(StmtOf(foo_f32_init), foo_f32_decl); @@ -416,11 +416,11 @@ TEST_F(ResolverTest, Stmt_VariableDecl_ModuleScopeAfterFunctionScope) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(mod_init), nullptr); - EXPECT_TRUE(TypeOf(mod_init)->Is()); + EXPECT_TRUE(TypeOf(mod_init)->Is()); ASSERT_NE(TypeOf(fn_i32_init), nullptr); - EXPECT_TRUE(TypeOf(fn_i32_init)->Is()); + EXPECT_TRUE(TypeOf(fn_i32_init)->Is()); ASSERT_NE(TypeOf(fn_f32_init), nullptr); - EXPECT_TRUE(TypeOf(fn_f32_init)->UnwrapRef()->Is()); + EXPECT_TRUE(TypeOf(fn_f32_init)->UnwrapRef()->Is()); EXPECT_EQ(StmtOf(fn_i32_init), fn_i32_decl); EXPECT_EQ(StmtOf(mod_init), nullptr); EXPECT_EQ(StmtOf(fn_f32_init), fn_f32_decl); @@ -586,7 +586,7 @@ TEST_F(ResolverTest, Expr_Bitcast) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(bitcast), nullptr); - EXPECT_TRUE(TypeOf(bitcast)->Is()); + EXPECT_TRUE(TypeOf(bitcast)->Is()); } TEST_F(ResolverTest, Expr_Call) { @@ -598,7 +598,7 @@ TEST_F(ResolverTest, Expr_Call) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_F(ResolverTest, Expr_Call_InBinaryOp) { @@ -610,7 +610,7 @@ TEST_F(ResolverTest, Expr_Call_InBinaryOp) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(expr), nullptr); - EXPECT_TRUE(TypeOf(expr)->Is()); + EXPECT_TRUE(TypeOf(expr)->Is()); } TEST_F(ResolverTest, Expr_Call_WithParams) { @@ -627,7 +627,7 @@ TEST_F(ResolverTest, Expr_Call_WithParams) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(param), nullptr); - EXPECT_TRUE(TypeOf(param)->Is()); + EXPECT_TRUE(TypeOf(param)->Is()); } TEST_F(ResolverTest, Expr_Call_Builtin) { @@ -637,7 +637,7 @@ TEST_F(ResolverTest, Expr_Call_Builtin) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_F(ResolverTest, Expr_Cast) { @@ -649,7 +649,7 @@ TEST_F(ResolverTest, Expr_Cast) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(cast), nullptr); - EXPECT_TRUE(TypeOf(cast)->Is()); + EXPECT_TRUE(TypeOf(cast)->Is()); } TEST_F(ResolverTest, Expr_Initializer_Scalar) { @@ -659,7 +659,7 @@ TEST_F(ResolverTest, Expr_Initializer_Scalar) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(s), nullptr); - EXPECT_TRUE(TypeOf(s)->Is()); + EXPECT_TRUE(TypeOf(s)->Is()); } TEST_F(ResolverTest, Expr_Initializer_Type_Vec2) { @@ -670,7 +670,7 @@ TEST_F(ResolverTest, Expr_Initializer_Type_Vec2) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 2u); } @@ -682,7 +682,7 @@ TEST_F(ResolverTest, Expr_Initializer_Type_Vec3) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 3u); } @@ -694,7 +694,7 @@ TEST_F(ResolverTest, Expr_Initializer_Type_Vec4) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } @@ -708,7 +708,7 @@ TEST_F(ResolverTest, Expr_Identifier_GlobalVariable) { ASSERT_NE(TypeOf(ident), nullptr); ASSERT_TRUE(TypeOf(ident)->Is()); - EXPECT_TRUE(TypeOf(ident)->UnwrapRef()->Is()); + EXPECT_TRUE(TypeOf(ident)->UnwrapRef()->Is()); EXPECT_TRUE(CheckVarUsers(my_var, utils::Vector{ident})); ASSERT_NE(VarOf(ident), nullptr); EXPECT_EQ(VarOf(ident)->Declaration(), my_var); @@ -723,7 +723,7 @@ TEST_F(ResolverTest, Expr_Identifier_GlobalConst) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(ident), nullptr); - EXPECT_TRUE(TypeOf(ident)->Is()); + EXPECT_TRUE(TypeOf(ident)->Is()); EXPECT_TRUE(CheckVarUsers(my_var, utils::Vector{ident})); ASSERT_NE(VarOf(ident), nullptr); EXPECT_EQ(VarOf(ident)->Declaration(), my_var); @@ -743,7 +743,7 @@ TEST_F(ResolverTest, Expr_Identifier_FunctionVariable_Const) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(my_var_a), nullptr); - EXPECT_TRUE(TypeOf(my_var_a)->Is()); + EXPECT_TRUE(TypeOf(my_var_a)->Is()); EXPECT_EQ(StmtOf(my_var_a), decl); EXPECT_TRUE(CheckVarUsers(var, utils::Vector{my_var_a})); ASSERT_NE(VarOf(my_var_a), nullptr); @@ -785,11 +785,11 @@ TEST_F(ResolverTest, Expr_Identifier_FunctionVariable) { ASSERT_NE(TypeOf(my_var_a), nullptr); ASSERT_TRUE(TypeOf(my_var_a)->Is()); - EXPECT_TRUE(TypeOf(my_var_a)->UnwrapRef()->Is()); + EXPECT_TRUE(TypeOf(my_var_a)->UnwrapRef()->Is()); EXPECT_EQ(StmtOf(my_var_a), assign); ASSERT_NE(TypeOf(my_var_b), nullptr); ASSERT_TRUE(TypeOf(my_var_b)->Is()); - EXPECT_TRUE(TypeOf(my_var_b)->UnwrapRef()->Is()); + EXPECT_TRUE(TypeOf(my_var_b)->UnwrapRef()->Is()); EXPECT_EQ(StmtOf(my_var_b), assign); EXPECT_TRUE(CheckVarUsers(var, utils::Vector{my_var_a, my_var_b})); ASSERT_NE(VarOf(my_var_a), nullptr); @@ -815,11 +815,11 @@ TEST_F(ResolverTest, Expr_Identifier_Function_Ptr) { ASSERT_NE(TypeOf(v), nullptr); ASSERT_TRUE(TypeOf(v)->Is()); - EXPECT_TRUE(TypeOf(v)->UnwrapRef()->Is()); + EXPECT_TRUE(TypeOf(v)->UnwrapRef()->Is()); EXPECT_EQ(StmtOf(v), p_decl); ASSERT_NE(TypeOf(p), nullptr); ASSERT_TRUE(TypeOf(p)->Is()); - EXPECT_TRUE(TypeOf(p)->UnwrapPtr()->Is()); + EXPECT_TRUE(TypeOf(p)->UnwrapPtr()->Is()); EXPECT_EQ(StmtOf(p), assign); } @@ -835,7 +835,7 @@ TEST_F(ResolverTest, Expr_Call_Function) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(call), nullptr); - EXPECT_TRUE(TypeOf(call)->Is()); + EXPECT_TRUE(TypeOf(call)->Is()); } TEST_F(ResolverTest, Expr_Identifier_Unknown) { @@ -863,13 +863,13 @@ TEST_F(ResolverTest, Function_Parameters) { auto* func_sem = Sem().Get(func); ASSERT_NE(func_sem, nullptr); EXPECT_EQ(func_sem->Parameters().Length(), 3u); - EXPECT_TRUE(func_sem->Parameters()[0]->Type()->Is()); - EXPECT_TRUE(func_sem->Parameters()[1]->Type()->Is()); - EXPECT_TRUE(func_sem->Parameters()[2]->Type()->Is()); + EXPECT_TRUE(func_sem->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(func_sem->Parameters()[1]->Type()->Is()); + EXPECT_TRUE(func_sem->Parameters()[2]->Type()->Is()); EXPECT_EQ(func_sem->Parameters()[0]->Declaration(), param_a); EXPECT_EQ(func_sem->Parameters()[1]->Declaration(), param_b); EXPECT_EQ(func_sem->Parameters()[2]->Declaration(), param_c); - EXPECT_TRUE(func_sem->ReturnType()->Is()); + EXPECT_TRUE(func_sem->ReturnType()->Is()); } TEST_F(ResolverTest, Function_Parameters_Locations) { @@ -937,7 +937,7 @@ TEST_F(ResolverTest, Function_RegisterInputOutputVariables) { auto* func_sem = Sem().Get(func); ASSERT_NE(func_sem, nullptr); EXPECT_EQ(func_sem->Parameters().Length(), 0u); - EXPECT_TRUE(func_sem->ReturnType()->Is()); + EXPECT_TRUE(func_sem->ReturnType()->Is()); const auto& vars = func_sem->TransitivelyReferencedGlobals(); ASSERT_EQ(vars.Length(), 3u); @@ -1029,7 +1029,7 @@ TEST_F(ResolverTest, Function_NotRegisterFunctionVariable) { ASSERT_NE(func_sem, nullptr); EXPECT_EQ(func_sem->TransitivelyReferencedGlobals().Length(), 0u); - EXPECT_TRUE(func_sem->ReturnType()->Is()); + EXPECT_TRUE(func_sem->ReturnType()->Is()); } TEST_F(ResolverTest, Function_NotRegisterFunctionConstant) { @@ -1044,7 +1044,7 @@ TEST_F(ResolverTest, Function_NotRegisterFunctionConstant) { ASSERT_NE(func_sem, nullptr); EXPECT_EQ(func_sem->TransitivelyReferencedGlobals().Length(), 0u); - EXPECT_TRUE(func_sem->ReturnType()->Is()); + EXPECT_TRUE(func_sem->ReturnType()->Is()); } TEST_F(ResolverTest, Function_NotRegisterFunctionParams) { @@ -1055,7 +1055,7 @@ TEST_F(ResolverTest, Function_NotRegisterFunctionParams) { ASSERT_NE(func_sem, nullptr); EXPECT_EQ(func_sem->TransitivelyReferencedGlobals().Length(), 0u); - EXPECT_TRUE(func_sem->ReturnType()->Is()); + EXPECT_TRUE(func_sem->ReturnType()->Is()); } TEST_F(ResolverTest, Function_CallSites) { @@ -1253,10 +1253,10 @@ TEST_F(ResolverTest, Expr_MemberAccessor_Struct) { ASSERT_TRUE(TypeOf(mem)->Is()); auto* ref = TypeOf(mem)->As(); - EXPECT_TRUE(ref->StoreType()->Is()); + EXPECT_TRUE(ref->StoreType()->Is()); auto* sma = Sem().Get(mem)->As(); ASSERT_NE(sma, nullptr); - EXPECT_TRUE(sma->Member()->Type()->Is()); + EXPECT_TRUE(sma->Member()->Type()->Is()); EXPECT_EQ(sma->Object()->Declaration(), mem->structure); EXPECT_EQ(sma->Member()->Index(), 1u); EXPECT_EQ(sma->Member()->Declaration()->symbol, Symbols().Get("second_member")); @@ -1277,11 +1277,11 @@ TEST_F(ResolverTest, Expr_MemberAccessor_Struct_Alias) { ASSERT_TRUE(TypeOf(mem)->Is()); auto* ref = TypeOf(mem)->As(); - EXPECT_TRUE(ref->StoreType()->Is()); + EXPECT_TRUE(ref->StoreType()->Is()); auto* sma = Sem().Get(mem)->As(); ASSERT_NE(sma, nullptr); EXPECT_EQ(sma->Object()->Declaration(), mem->structure); - EXPECT_TRUE(sma->Member()->Type()->Is()); + EXPECT_TRUE(sma->Member()->Type()->Is()); EXPECT_EQ(sma->Member()->Index(), 1u); } @@ -1295,7 +1295,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_TRUE(TypeOf(mem)->As()->type()->Is()); EXPECT_EQ(TypeOf(mem)->As()->Width(), 4u); auto* sma = Sem().Get(mem)->As(); ASSERT_NE(sma, nullptr); @@ -1315,7 +1315,7 @@ TEST_F(ResolverTest, Expr_MemberAccessor_VectorSwizzle_SingleElement) { ASSERT_TRUE(TypeOf(mem)->Is()); auto* ref = TypeOf(mem)->As(); - ASSERT_TRUE(ref->StoreType()->Is()); + ASSERT_TRUE(ref->StoreType()->Is()); auto* sma = Sem().Get(mem)->As(); ASSERT_NE(sma, nullptr); EXPECT_EQ(sma->Object()->Declaration(), mem->structure); @@ -1350,7 +1350,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_TRUE(TypeOf(mem)->As()->type()->Is()); EXPECT_EQ(TypeOf(mem)->As()->Width(), 2u); ASSERT_TRUE(Sem().Get(mem)->Is()); } @@ -1367,7 +1367,7 @@ TEST_F(ResolverTest, Expr_MemberAccessor_InBinaryOp) { EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(expr), nullptr); - EXPECT_TRUE(TypeOf(expr)->Is()); + EXPECT_TRUE(TypeOf(expr)->Is()); } namespace ExprBinaryTest { @@ -1773,12 +1773,12 @@ TEST_P(Expr_Binary_Test_Invalid_VectorMatrixMultiply, All) { if (vec_by_mat) { lhs_type = ty.vec(vec_size); rhs_type = ty.mat(mat_cols, mat_rows); - result_type = create(create(), mat_cols); + result_type = create(create(), mat_cols); is_valid_expr = vec_size == mat_rows; } else { lhs_type = ty.mat(mat_cols, mat_rows); rhs_type = ty.vec(vec_size); - result_type = create(create(), mat_rows); + result_type = create(create(), mat_rows); is_valid_expr = vec_size == mat_cols; } @@ -1815,7 +1815,7 @@ TEST_P(Expr_Binary_Test_Invalid_MatrixMatrixMultiply, All) { auto* lhs_type = ty.mat(lhs_mat_cols, lhs_mat_rows); auto* rhs_type = ty.mat(rhs_mat_cols, rhs_mat_rows); - auto* f32 = create(); + auto* f32 = create(); auto* col = create(f32, lhs_mat_rows); auto* result_type = create(col, rhs_mat_cols); @@ -1862,11 +1862,11 @@ TEST_P(UnaryOpExpressionTest, Expr_UnaryOp) { ASSERT_NE(TypeOf(der), nullptr); ASSERT_TRUE(TypeOf(der)->Is()); if (op == ast::UnaryOp::kNot) { - EXPECT_TRUE(TypeOf(der)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(der)->As()->type()->Is()); } else if (op == ast::UnaryOp::kNegation || op == ast::UnaryOp::kComplement) { - EXPECT_TRUE(TypeOf(der)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(der)->As()->type()->Is()); } else { - EXPECT_TRUE(TypeOf(der)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(der)->As()->type()->Is()); } EXPECT_EQ(TypeOf(der)->As()->Width(), 4u); } diff --git a/src/tint/resolver/resolver_test_helper.h b/src/tint/resolver/resolver_test_helper.h index 1186fa1393..e4625b6c3d 100644 --- a/src/tint/resolver/resolver_test_helper.h +++ b/src/tint/resolver/resolver_test_helper.h @@ -232,7 +232,7 @@ struct DataType { static inline const ast::Type* AST(ProgramBuilder& b) { return b.ty.bool_(); } /// @param b the ProgramBuilder /// @return the semantic bool type - static inline const type::Type* Sem(ProgramBuilder& b) { return b.create(); } + static inline const type::Type* Sem(ProgramBuilder& b) { return b.create(); } /// @param b the ProgramBuilder /// @param args args of size 1 with the boolean value to init with /// @return a new AST expression of the bool type @@ -263,7 +263,7 @@ struct DataType { static inline const ast::Type* AST(ProgramBuilder& b) { return b.ty.i32(); } /// @param b the ProgramBuilder /// @return the semantic i32 type - static inline const type::Type* Sem(ProgramBuilder& b) { return b.create(); } + static inline const type::Type* Sem(ProgramBuilder& b) { return b.create(); } /// @param b the ProgramBuilder /// @param args args of size 1 with the i32 value to init with /// @return a new AST i32 literal value expression @@ -294,7 +294,7 @@ struct DataType { static inline const ast::Type* AST(ProgramBuilder& b) { return b.ty.u32(); } /// @param b the ProgramBuilder /// @return the semantic u32 type - static inline const type::Type* Sem(ProgramBuilder& b) { return b.create(); } + static inline const type::Type* Sem(ProgramBuilder& b) { return b.create(); } /// @param b the ProgramBuilder /// @param args args of size 1 with the u32 value to init with /// @return a new AST u32 literal value expression @@ -325,7 +325,7 @@ struct DataType { static inline const ast::Type* AST(ProgramBuilder& b) { return b.ty.f32(); } /// @param b the ProgramBuilder /// @return the semantic f32 type - static inline const type::Type* Sem(ProgramBuilder& b) { return b.create(); } + static inline const type::Type* Sem(ProgramBuilder& b) { return b.create(); } /// @param b the ProgramBuilder /// @param args args of size 1 with the f32 value to init with /// @return a new AST f32 literal value expression @@ -356,7 +356,7 @@ struct DataType { static inline const ast::Type* AST(ProgramBuilder& b) { return b.ty.f16(); } /// @param b the ProgramBuilder /// @return the semantic f16 type - static inline const type::Type* Sem(ProgramBuilder& b) { return b.create(); } + static inline const type::Type* Sem(ProgramBuilder& b) { return b.create(); } /// @param b the ProgramBuilder /// @param args args of size 1 with the f16 value to init with /// @return a new AST f16 literal value expression diff --git a/src/tint/resolver/type_initializer_validation_test.cc b/src/tint/resolver/type_initializer_validation_test.cc index 437f28f90f..cbb6b89326 100644 --- a/src/tint/resolver/type_initializer_validation_test.cc +++ b/src/tint/resolver/type_initializer_validation_test.cc @@ -68,10 +68,10 @@ TEST_F(ResolverTypeInitializerValidationTest, InferTypeTest_Simple) { ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_TRUE(TypeOf(a_ident)->Is()); - EXPECT_TRUE(TypeOf(a_ident)->As()->StoreType()->Is()); + EXPECT_TRUE(TypeOf(a_ident)->As()->StoreType()->Is()); EXPECT_EQ(TypeOf(a_ident)->As()->AddressSpace(), ast::AddressSpace::kFunction); ASSERT_TRUE(TypeOf(b_ident)->Is()); - EXPECT_TRUE(TypeOf(b_ident)->As()->StoreType()->Is()); + EXPECT_TRUE(TypeOf(b_ident)->As()->StoreType()->Is()); EXPECT_EQ(TypeOf(b_ident)->As()->AddressSpace(), ast::AddressSpace::kFunction); } @@ -515,9 +515,9 @@ TEST_F(ResolverTypeInitializerValidationTest, Array_U32U32U32) { ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 3u); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); } TEST_F(ResolverTypeInitializerValidationTest, InferredArray_U32U32U32) { @@ -534,9 +534,9 @@ TEST_F(ResolverTypeInitializerValidationTest, InferredArray_U32U32U32) { ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 3u); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); } TEST_F(ResolverTypeInitializerValidationTest, Array_U32AIU32) { @@ -553,9 +553,9 @@ TEST_F(ResolverTypeInitializerValidationTest, Array_U32AIU32) { ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 3u); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); } TEST_F(ResolverTypeInitializerValidationTest, InferredArray_U32AIU32) { @@ -572,9 +572,9 @@ TEST_F(ResolverTypeInitializerValidationTest, InferredArray_U32AIU32) { ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 3u); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); } TEST_F(ResolverTypeInitializerValidationTest, ArrayU32_AIAIAI) { @@ -591,9 +591,9 @@ TEST_F(ResolverTypeInitializerValidationTest, ArrayU32_AIAIAI) { ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 3u); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); } TEST_F(ResolverTypeInitializerValidationTest, InferredArray_AIAIAI) { @@ -632,9 +632,9 @@ TEST_F(ResolverTypeInitializerValidationTest, InferredArrayU32_VecI32_VecAI) { EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 2u); ASSERT_TRUE(ctor->Parameters()[0]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->As()->type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->As()->type()->Is()); ASSERT_TRUE(ctor->Parameters()[1]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[1]->Type()->As()->type()->Is()); + EXPECT_TRUE(ctor->Parameters()[1]->Type()->As()->type()->Is()); } TEST_F(ResolverTypeInitializerValidationTest, InferredArrayU32_VecAI_VecF32) { @@ -654,9 +654,9 @@ TEST_F(ResolverTypeInitializerValidationTest, InferredArrayU32_VecAI_VecF32) { EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 2u); ASSERT_TRUE(ctor->Parameters()[0]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->As()->type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->As()->type()->Is()); ASSERT_TRUE(ctor->Parameters()[1]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[1]->Type()->As()->type()->Is()); + EXPECT_TRUE(ctor->Parameters()[1]->Type()->As()->type()->Is()); } TEST_F(ResolverTypeInitializerValidationTest, ArrayArgumentTypeMismatch_U32F32) { @@ -896,7 +896,7 @@ TEST_F(ResolverTypeInitializerValidationTest, I32_Success) { ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(expr), nullptr); - ASSERT_TRUE(TypeOf(expr)->Is()); + ASSERT_TRUE(TypeOf(expr)->Is()); auto* call = Sem().Get(expr); ASSERT_NE(call, nullptr); @@ -904,7 +904,7 @@ TEST_F(ResolverTypeInitializerValidationTest, I32_Success) { ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 1u); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); } TEST_F(ResolverTypeInitializerValidationTest, U32_Success) { @@ -914,7 +914,7 @@ TEST_F(ResolverTypeInitializerValidationTest, U32_Success) { ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(expr), nullptr); - ASSERT_TRUE(TypeOf(expr)->Is()); + ASSERT_TRUE(TypeOf(expr)->Is()); auto* call = Sem().Get(expr); ASSERT_NE(call, nullptr); @@ -922,7 +922,7 @@ TEST_F(ResolverTypeInitializerValidationTest, U32_Success) { ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 1u); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); } TEST_F(ResolverTypeInitializerValidationTest, F32_Success) { @@ -932,7 +932,7 @@ TEST_F(ResolverTypeInitializerValidationTest, F32_Success) { ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(expr), nullptr); - ASSERT_TRUE(TypeOf(expr)->Is()); + ASSERT_TRUE(TypeOf(expr)->Is()); auto* call = Sem().Get(expr); ASSERT_NE(call, nullptr); @@ -940,7 +940,7 @@ TEST_F(ResolverTypeInitializerValidationTest, F32_Success) { ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 1u); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); } TEST_F(ResolverTypeInitializerValidationTest, F16_Success) { @@ -952,7 +952,7 @@ TEST_F(ResolverTypeInitializerValidationTest, F16_Success) { ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(expr), nullptr); - ASSERT_TRUE(TypeOf(expr)->Is()); + ASSERT_TRUE(TypeOf(expr)->Is()); auto* call = Sem().Get(expr); ASSERT_NE(call, nullptr); @@ -960,7 +960,7 @@ TEST_F(ResolverTypeInitializerValidationTest, F16_Success) { ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 1u); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); } TEST_F(ResolverTypeInitializerValidationTest, Convert_f32_to_i32_Success) { @@ -970,7 +970,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Convert_f32_to_i32_Success) { ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(expr), nullptr); - ASSERT_TRUE(TypeOf(expr)->Is()); + ASSERT_TRUE(TypeOf(expr)->Is()); auto* call = Sem().Get(expr); ASSERT_NE(call, nullptr); @@ -978,7 +978,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Convert_f32_to_i32_Success) { ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 1u); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); } TEST_F(ResolverTypeInitializerValidationTest, Convert_i32_to_u32_Success) { @@ -988,7 +988,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Convert_i32_to_u32_Success) { ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(expr), nullptr); - ASSERT_TRUE(TypeOf(expr)->Is()); + ASSERT_TRUE(TypeOf(expr)->Is()); auto* call = Sem().Get(expr); ASSERT_NE(call, nullptr); @@ -996,7 +996,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Convert_i32_to_u32_Success) { ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 1u); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); } TEST_F(ResolverTypeInitializerValidationTest, Convert_u32_to_f16_Success) { @@ -1008,7 +1008,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Convert_u32_to_f16_Success) { ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(expr), nullptr); - ASSERT_TRUE(TypeOf(expr)->Is()); + ASSERT_TRUE(TypeOf(expr)->Is()); auto* call = Sem().Get(expr); ASSERT_NE(call, nullptr); @@ -1016,7 +1016,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Convert_u32_to_f16_Success) { ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 1u); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); } TEST_F(ResolverTypeInitializerValidationTest, Convert_f16_to_f32_Success) { @@ -1028,7 +1028,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Convert_f16_to_f32_Success) { ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_NE(TypeOf(expr), nullptr); - ASSERT_TRUE(TypeOf(expr)->Is()); + ASSERT_TRUE(TypeOf(expr)->Is()); auto* call = Sem().Get(expr); ASSERT_NE(call, nullptr); @@ -1036,7 +1036,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Convert_f16_to_f32_Success) { ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 1u); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); } } // namespace ScalarInitializer @@ -1142,7 +1142,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2_Success_ZeroValue) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 2u); auto* call = Sem().Get(tc); @@ -1161,7 +1161,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2F32_Success_Scalar) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 2u); auto* call = Sem().Get(tc); @@ -1170,8 +1170,8 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2F32_Success_Scalar) { ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 2u); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); } TEST_F(ResolverTypeInitializerValidationTest, Vec2F16_Success_Scalar) { @@ -1184,7 +1184,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2F16_Success_Scalar) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 2u); auto* call = Sem().Get(tc); @@ -1193,8 +1193,8 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2F16_Success_Scalar) { ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 2u); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); } TEST_F(ResolverTypeInitializerValidationTest, Vec2U32_Success_Scalar) { @@ -1205,7 +1205,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2U32_Success_Scalar) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 2u); auto* call = Sem().Get(tc); @@ -1214,8 +1214,8 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2U32_Success_Scalar) { ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 2u); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); } TEST_F(ResolverTypeInitializerValidationTest, Vec2I32_Success_Scalar) { @@ -1226,7 +1226,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2I32_Success_Scalar) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 2u); auto* call = Sem().Get(tc); @@ -1235,8 +1235,8 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2I32_Success_Scalar) { ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 2u); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); } TEST_F(ResolverTypeInitializerValidationTest, Vec2Bool_Success_Scalar) { @@ -1247,7 +1247,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2Bool_Success_Scalar) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 2u); auto* call = Sem().Get(tc); @@ -1256,8 +1256,8 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2Bool_Success_Scalar) { ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 2u); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); } TEST_F(ResolverTypeInitializerValidationTest, Vec2_Success_Identity) { @@ -1268,7 +1268,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2_Success_Identity) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 2u); auto* call = Sem().Get(tc); @@ -1288,7 +1288,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec2_Success_Vec2TypeConversion) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 2u); auto* call = Sem().Get(tc); @@ -1417,7 +1417,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3_Success_ZeroValue) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 3u); auto* call = Sem().Get(tc); @@ -1436,7 +1436,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3F32_Success_Scalar) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 3u); auto* call = Sem().Get(tc); @@ -1445,9 +1445,9 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3F32_Success_Scalar) { ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 3u); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); } TEST_F(ResolverTypeInitializerValidationTest, Vec3F16_Success_Scalar) { @@ -1460,7 +1460,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3F16_Success_Scalar) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 3u); auto* call = Sem().Get(tc); @@ -1469,9 +1469,9 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3F16_Success_Scalar) { ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 3u); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); } TEST_F(ResolverTypeInitializerValidationTest, Vec3U32_Success_Scalar) { @@ -1482,7 +1482,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3U32_Success_Scalar) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 3u); auto* call = Sem().Get(tc); @@ -1491,9 +1491,9 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3U32_Success_Scalar) { ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 3u); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); } TEST_F(ResolverTypeInitializerValidationTest, Vec3I32_Success_Scalar) { @@ -1504,7 +1504,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3I32_Success_Scalar) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 3u); auto* call = Sem().Get(tc); @@ -1513,9 +1513,9 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3I32_Success_Scalar) { ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 3u); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); } TEST_F(ResolverTypeInitializerValidationTest, Vec3Bool_Success_Scalar) { @@ -1526,7 +1526,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3Bool_Success_Scalar) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 3u); auto* call = Sem().Get(tc); @@ -1535,9 +1535,9 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3Bool_Success_Scalar) { ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 3u); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); } TEST_F(ResolverTypeInitializerValidationTest, Vec3_Success_Vec2AndScalar) { @@ -1548,7 +1548,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3_Success_Vec2AndScalar) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 3u); auto* call = Sem().Get(tc); @@ -1558,7 +1558,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3_Success_Vec2AndScalar) { EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 2u); EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); } TEST_F(ResolverTypeInitializerValidationTest, Vec3_Success_ScalarAndVec2) { @@ -1569,7 +1569,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3_Success_ScalarAndVec2) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 3u); auto* call = Sem().Get(tc); @@ -1578,7 +1578,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3_Success_ScalarAndVec2) { ASSERT_NE(ctor, nullptr); EXPECT_EQ(call->Type(), ctor->ReturnType()); ASSERT_EQ(ctor->Parameters().Length(), 2u); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); } @@ -1590,7 +1590,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3_Success_Identity) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 3u); auto* call = Sem().Get(tc); @@ -1610,7 +1610,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec3_Success_Vec3TypeConversion) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 3u); auto* call = Sem().Get(tc); @@ -1782,7 +1782,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_ZeroValue) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } @@ -1794,7 +1794,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4F32_Success_Scalar) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } @@ -1808,7 +1808,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4F16_Success_Scalar) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } @@ -1820,7 +1820,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4U32_Success_Scalar) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } @@ -1832,7 +1832,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4I32_Success_Scalar) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } @@ -1844,7 +1844,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4Bool_Success_Scalar) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } @@ -1856,7 +1856,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_Vec2ScalarScalar) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } @@ -1868,7 +1868,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_ScalarVec2Scalar) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } @@ -1880,7 +1880,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_ScalarScalarVec2) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } @@ -1892,7 +1892,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_Vec2AndVec2) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } @@ -1904,7 +1904,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_Vec3AndScalar) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } @@ -1916,7 +1916,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_ScalarAndVec3) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } @@ -1928,7 +1928,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_Identity) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } @@ -1940,7 +1940,7 @@ TEST_F(ResolverTypeInitializerValidationTest, Vec4_Success_Vec4TypeConversion) { ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } @@ -1962,7 +1962,7 @@ TEST_F(ResolverTypeInitializerValidationTest, NestedVectorInitializers_Success) ASSERT_NE(TypeOf(tc), nullptr); ASSERT_TRUE(TypeOf(tc)->Is()); - EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(tc)->As()->type()->Is()); EXPECT_EQ(TypeOf(tc)->As()->Width(), 4u); } @@ -2051,11 +2051,11 @@ TEST_F(ResolverTypeInitializerValidationTest, InferVec2ElementTypeFromScalars) { ASSERT_TRUE(TypeOf(vec2_u32)->Is()); ASSERT_TRUE(TypeOf(vec2_f32)->Is()); ASSERT_TRUE(TypeOf(vec2_f16)->Is()); - EXPECT_TRUE(TypeOf(vec2_bool)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec2_i32)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec2_u32)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec2_f32)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec2_f16)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec2_bool)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec2_i32)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec2_u32)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec2_f32)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec2_f16)->As()->type()->Is()); EXPECT_EQ(TypeOf(vec2_bool)->As()->Width(), 2u); EXPECT_EQ(TypeOf(vec2_i32)->As()->Width(), 2u); EXPECT_EQ(TypeOf(vec2_u32)->As()->Width(), 2u); @@ -2085,11 +2085,11 @@ TEST_F(ResolverTypeInitializerValidationTest, InferVec2ElementTypeFromVec2) { ASSERT_TRUE(TypeOf(vec2_u32)->Is()); ASSERT_TRUE(TypeOf(vec2_f32)->Is()); ASSERT_TRUE(TypeOf(vec2_f16)->Is()); - EXPECT_TRUE(TypeOf(vec2_bool)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec2_i32)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec2_u32)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec2_f32)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec2_f16)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec2_bool)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec2_i32)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec2_u32)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec2_f32)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec2_f16)->As()->type()->Is()); EXPECT_EQ(TypeOf(vec2_bool)->As()->Width(), 2u); EXPECT_EQ(TypeOf(vec2_i32)->As()->Width(), 2u); EXPECT_EQ(TypeOf(vec2_u32)->As()->Width(), 2u); @@ -2120,11 +2120,11 @@ TEST_F(ResolverTypeInitializerValidationTest, InferVec3ElementTypeFromScalars) { ASSERT_TRUE(TypeOf(vec3_u32)->Is()); ASSERT_TRUE(TypeOf(vec3_f32)->Is()); ASSERT_TRUE(TypeOf(vec3_f16)->Is()); - EXPECT_TRUE(TypeOf(vec3_bool)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec3_i32)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec3_u32)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec3_f32)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec3_f16)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec3_bool)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec3_i32)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec3_u32)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec3_f32)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec3_f16)->As()->type()->Is()); EXPECT_EQ(TypeOf(vec3_bool)->As()->Width(), 3u); EXPECT_EQ(TypeOf(vec3_i32)->As()->Width(), 3u); EXPECT_EQ(TypeOf(vec3_u32)->As()->Width(), 3u); @@ -2154,11 +2154,11 @@ TEST_F(ResolverTypeInitializerValidationTest, InferVec3ElementTypeFromVec3) { ASSERT_TRUE(TypeOf(vec3_u32)->Is()); ASSERT_TRUE(TypeOf(vec3_f32)->Is()); ASSERT_TRUE(TypeOf(vec3_f16)->Is()); - EXPECT_TRUE(TypeOf(vec3_bool)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec3_i32)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec3_u32)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec3_f32)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec3_f16)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec3_bool)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec3_i32)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec3_u32)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec3_f32)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec3_f16)->As()->type()->Is()); EXPECT_EQ(TypeOf(vec3_bool)->As()->Width(), 3u); EXPECT_EQ(TypeOf(vec3_i32)->As()->Width(), 3u); EXPECT_EQ(TypeOf(vec3_u32)->As()->Width(), 3u); @@ -2189,11 +2189,11 @@ TEST_F(ResolverTypeInitializerValidationTest, InferVec3ElementTypeFromScalarAndV ASSERT_TRUE(TypeOf(vec3_u32)->Is()); ASSERT_TRUE(TypeOf(vec3_f32)->Is()); ASSERT_TRUE(TypeOf(vec3_f16)->Is()); - EXPECT_TRUE(TypeOf(vec3_bool)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec3_i32)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec3_u32)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec3_f32)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec3_f16)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec3_bool)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec3_i32)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec3_u32)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec3_f32)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec3_f16)->As()->type()->Is()); EXPECT_EQ(TypeOf(vec3_bool)->As()->Width(), 3u); EXPECT_EQ(TypeOf(vec3_i32)->As()->Width(), 3u); EXPECT_EQ(TypeOf(vec3_u32)->As()->Width(), 3u); @@ -2228,11 +2228,11 @@ TEST_F(ResolverTypeInitializerValidationTest, InferVec4ElementTypeFromScalars) { ASSERT_TRUE(TypeOf(vec4_u32)->Is()); ASSERT_TRUE(TypeOf(vec4_f32)->Is()); ASSERT_TRUE(TypeOf(vec4_f16)->Is()); - EXPECT_TRUE(TypeOf(vec4_bool)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec4_i32)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec4_u32)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec4_f32)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec4_f16)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec4_bool)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec4_i32)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec4_u32)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec4_f32)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec4_f16)->As()->type()->Is()); EXPECT_EQ(TypeOf(vec4_bool)->As()->Width(), 4u); EXPECT_EQ(TypeOf(vec4_i32)->As()->Width(), 4u); EXPECT_EQ(TypeOf(vec4_u32)->As()->Width(), 4u); @@ -2263,11 +2263,11 @@ TEST_F(ResolverTypeInitializerValidationTest, InferVec4ElementTypeFromVec4) { ASSERT_TRUE(TypeOf(vec4_u32)->Is()); ASSERT_TRUE(TypeOf(vec4_f32)->Is()); ASSERT_TRUE(TypeOf(vec4_f16)->Is()); - EXPECT_TRUE(TypeOf(vec4_bool)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec4_i32)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec4_u32)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec4_f32)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec4_f16)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec4_bool)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec4_i32)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec4_u32)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec4_f32)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec4_f16)->As()->type()->Is()); EXPECT_EQ(TypeOf(vec4_bool)->As()->Width(), 4u); EXPECT_EQ(TypeOf(vec4_i32)->As()->Width(), 4u); EXPECT_EQ(TypeOf(vec4_u32)->As()->Width(), 4u); @@ -2302,11 +2302,11 @@ TEST_F(ResolverTypeInitializerValidationTest, InferVec4ElementTypeFromScalarAndV ASSERT_TRUE(TypeOf(vec4_u32)->Is()); ASSERT_TRUE(TypeOf(vec4_f32)->Is()); ASSERT_TRUE(TypeOf(vec4_f16)->Is()); - EXPECT_TRUE(TypeOf(vec4_bool)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec4_i32)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec4_u32)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec4_f32)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec4_f16)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec4_bool)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec4_i32)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec4_u32)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec4_f32)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec4_f16)->As()->type()->Is()); EXPECT_EQ(TypeOf(vec4_bool)->As()->Width(), 4u); EXPECT_EQ(TypeOf(vec4_i32)->As()->Width(), 4u); EXPECT_EQ(TypeOf(vec4_u32)->As()->Width(), 4u); @@ -2341,11 +2341,11 @@ TEST_F(ResolverTypeInitializerValidationTest, InferVec4ElementTypeFromVec2AndVec ASSERT_TRUE(TypeOf(vec4_u32)->Is()); ASSERT_TRUE(TypeOf(vec4_f32)->Is()); ASSERT_TRUE(TypeOf(vec4_f16)->Is()); - EXPECT_TRUE(TypeOf(vec4_bool)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec4_i32)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec4_u32)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec4_f32)->As()->type()->Is()); - EXPECT_TRUE(TypeOf(vec4_f16)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec4_bool)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec4_i32)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec4_u32)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec4_f32)->As()->type()->Is()); + EXPECT_TRUE(TypeOf(vec4_f16)->As()->type()->Is()); EXPECT_EQ(TypeOf(vec4_bool)->As()->Width(), 4u); EXPECT_EQ(TypeOf(vec4_i32)->As()->Width(), 4u); EXPECT_EQ(TypeOf(vec4_u32)->As()->Width(), 4u); diff --git a/src/tint/resolver/validator.cc b/src/tint/resolver/validator.cc index 1740a069f3..18cb1521d0 100644 --- a/src/tint/resolver/validator.cc +++ b/src/tint/resolver/validator.cc @@ -210,7 +210,7 @@ bool Validator::IsFixedFootprint(const type::Type* type) const { // https://gpuweb.github.io/gpuweb/wgsl.html#host-shareable-types bool Validator::IsHostShareable(const type::Type* type) const { - if (type->IsAnyOf()) { + if (type->IsAnyOf()) { return true; } return Switch( @@ -263,7 +263,7 @@ const ast::Statement* Validator::ClosestContinuing(bool stop_at_loop, bool Validator::Atomic(const ast::Atomic* a, const sem::Atomic* s) const { // https://gpuweb.github.io/gpuweb/wgsl/#atomic-types // T must be either u32 or i32. - if (!s->Type()->IsAnyOf()) { + if (!s->Type()->IsAnyOf()) { AddError("atomic only supports i32 or u32 types", a->type ? a->type->source : a->source); return false; } @@ -320,7 +320,7 @@ bool Validator::StorageTexture(const ast::StorageTexture* t) const { } bool Validator::SampledTexture(const type::SampledTexture* t, const Source& source) const { - if (!t->type()->UnwrapRef()->IsAnyOf()) { + if (!t->type()->UnwrapRef()->IsAnyOf()) { AddError("texture_2d: type must be f32, i32 or u32", source); return false; } @@ -335,7 +335,7 @@ bool Validator::MultisampledTexture(const type::MultisampledTexture* t, return false; } - if (!t->type()->UnwrapRef()->IsAnyOf()) { + if (!t->type()->UnwrapRef()->IsAnyOf()) { AddError("texture_multisampled_2d: type must be f32, i32 or u32", source); return false; } @@ -435,7 +435,7 @@ bool Validator::AddressSpaceLayout(const type::Type* store_ty, // Among three host-shareable address spaces, f16 is supported in "uniform" and // "storage" address space, but not "push_constant" address space yet. - if (Is(type::Type::DeepestElementOf(store_ty)) && + if (Is(type::Type::DeepestElementOf(store_ty)) && address_space == ast::AddressSpace::kPushConstant) { AddError("using f16 types in 'push_constant' address space is not implemented yet", source); return false; @@ -764,7 +764,7 @@ bool Validator::Override( return false; } - if (storage_ty->Is()) { + if (storage_ty->Is()) { AddError("'override' of type f16 is not implemented yet", decl->source); return false; } @@ -882,7 +882,7 @@ bool Validator::BuiltinAttribute(const ast::BuiltinAttribute* attr, !(stage == ast::PipelineStage::kFragment && !is_input)) { is_stage_mismatch = true; } - if (!type->Is()) { + if (!type->Is()) { AddError("store type of " + attr_to_str(attr) + " must be 'f32'", attr->source); return false; } @@ -892,7 +892,7 @@ bool Validator::BuiltinAttribute(const ast::BuiltinAttribute* attr, !(stage == ast::PipelineStage::kFragment && is_input)) { is_stage_mismatch = true; } - if (!type->Is()) { + if (!type->Is()) { AddError("store type of " + attr_to_str(attr) + " must be 'bool'", attr->source); return false; } @@ -902,7 +902,7 @@ bool Validator::BuiltinAttribute(const ast::BuiltinAttribute* attr, !(stage == ast::PipelineStage::kCompute && is_input)) { is_stage_mismatch = true; } - if (!type->Is()) { + if (!type->Is()) { AddError("store type of " + attr_to_str(attr) + " must be 'u32'", attr->source); return false; } @@ -913,7 +913,7 @@ bool Validator::BuiltinAttribute(const ast::BuiltinAttribute* attr, !(stage == ast::PipelineStage::kVertex && is_input)) { is_stage_mismatch = true; } - if (!type->Is()) { + if (!type->Is()) { AddError("store type of " + attr_to_str(attr) + " must be 'u32'", attr->source); return false; } @@ -922,7 +922,7 @@ bool Validator::BuiltinAttribute(const ast::BuiltinAttribute* attr, if (stage != ast::PipelineStage::kNone && !(stage == ast::PipelineStage::kFragment)) { is_stage_mismatch = true; } - if (!type->Is()) { + if (!type->Is()) { AddError("store type of " + attr_to_str(attr) + " must be 'u32'", attr->source); return false; } @@ -932,7 +932,7 @@ bool Validator::BuiltinAttribute(const ast::BuiltinAttribute* attr, !(stage == ast::PipelineStage::kFragment && is_input)) { is_stage_mismatch = true; } - if (!type->Is()) { + if (!type->Is()) { AddError("store type of " + attr_to_str(attr) + " must be 'u32'", attr->source); return false; } @@ -991,7 +991,7 @@ bool Validator::Function(const sem::Function* func, ast::PipelineStage stage) co return false; } - if (!func->ReturnType()->Is()) { + if (!func->ReturnType()->Is()) { if (!func->ReturnType()->IsConstructible()) { AddError("function return type must be a constructible type", decl->return_type->source); @@ -1247,7 +1247,7 @@ bool Validator::EntryPoint(const sem::Function* func, ast::PipelineStage stage) builtins.Clear(); locations.Clear(); - if (!func->ReturnType()->Is()) { + if (!func->ReturnType()->Is()) { if (!validate_entry_point_attributes(decl->return_type_attributes, func->ReturnType(), decl->source, ParamOrRetType::kReturnType, func->ReturnLocation())) { @@ -1458,7 +1458,7 @@ bool Validator::ForLoopStatement(const sem::ForLoopStatement* stmt) const { } if (auto* cond = stmt->Condition()) { auto* cond_ty = cond->Type()->UnwrapRef(); - if (!cond_ty->Is()) { + if (!cond_ty->Is()) { AddError("for-loop condition must be bool, got " + sem_.TypeNameOf(cond_ty), stmt->Condition()->Declaration()->source); return false; @@ -1474,7 +1474,7 @@ bool Validator::WhileStatement(const sem::WhileStatement* stmt) const { } if (auto* cond = stmt->Condition()) { auto* cond_ty = cond->Type()->UnwrapRef(); - if (!cond_ty->Is()) { + if (!cond_ty->Is()) { AddError("while condition must be bool, got " + sem_.TypeNameOf(cond_ty), stmt->Condition()->Declaration()->source); return false; @@ -1486,7 +1486,7 @@ bool Validator::WhileStatement(const sem::WhileStatement* stmt) const { bool Validator::BreakIfStatement(const sem::BreakIfStatement* stmt, sem::Statement* current_statement) const { auto* cond_ty = stmt->Condition()->Type()->UnwrapRef(); - if (!cond_ty->Is()) { + if (!cond_ty->Is()) { AddError("break-if statement condition must be bool, got " + sem_.TypeNameOf(cond_ty), stmt->Condition()->Declaration()->source); return false; @@ -1513,7 +1513,7 @@ bool Validator::BreakIfStatement(const sem::BreakIfStatement* stmt, bool Validator::IfStatement(const sem::IfStatement* stmt) const { auto* cond_ty = stmt->Condition()->Type()->UnwrapRef(); - if (!cond_ty->Is()) { + if (!cond_ty->Is()) { AddError("if statement condition must be bool, got " + sem_.TypeNameOf(cond_ty), stmt->Condition()->Declaration()->source); return false; @@ -1522,7 +1522,7 @@ bool Validator::IfStatement(const sem::IfStatement* stmt) const { } bool Validator::BuiltinCall(const sem::Call* call) const { - if (call->Type()->Is()) { + if (call->Type()->Is()) { bool is_call_statement = false; // Some built-in call are not owned by a statement, e.g. a built-in called in global // variable declaration. Calling no-return-value built-in in these context is invalid as @@ -1692,7 +1692,7 @@ bool Validator::FunctionCall(const sem::Call* call, sem::Statement* current_stat } } - if (call->Type()->Is()) { + if (call->Type()->Is()) { bool is_call_statement = false; if (auto* call_stmt = As(call->Stmt()->Declaration())) { if (call_stmt->expr == call->Declaration()) { @@ -2228,7 +2228,7 @@ bool Validator::SwitchStatement(const ast::SwitchStatement* s) { auto value = selector->Value()->As(); if (auto added = selectors.Add(value, selector->Declaration()->source); !added) { AddError("duplicate switch case '" + - (decl_ty->IsAnyOf() + (decl_ty->IsAnyOf() ? std::to_string(i32(value)) : std::to_string(value)) + "'", diff --git a/src/tint/resolver/validator_is_storeable_test.cc b/src/tint/resolver/validator_is_storeable_test.cc index 3dd144caca..6e464bcc17 100644 --- a/src/tint/resolver/validator_is_storeable_test.cc +++ b/src/tint/resolver/validator_is_storeable_test.cc @@ -24,39 +24,39 @@ namespace { using ValidatorIsStorableTest = ResolverTest; TEST_F(ValidatorIsStorableTest, Void) { - EXPECT_FALSE(v()->IsStorable(create())); + EXPECT_FALSE(v()->IsStorable(create())); } TEST_F(ValidatorIsStorableTest, Scalar) { - EXPECT_TRUE(v()->IsStorable(create())); - EXPECT_TRUE(v()->IsStorable(create())); - EXPECT_TRUE(v()->IsStorable(create())); - EXPECT_TRUE(v()->IsStorable(create())); - EXPECT_TRUE(v()->IsStorable(create())); + EXPECT_TRUE(v()->IsStorable(create())); + EXPECT_TRUE(v()->IsStorable(create())); + EXPECT_TRUE(v()->IsStorable(create())); + EXPECT_TRUE(v()->IsStorable(create())); + EXPECT_TRUE(v()->IsStorable(create())); } TEST_F(ValidatorIsStorableTest, Vector) { - EXPECT_TRUE(v()->IsStorable(create(create(), 2u))); - EXPECT_TRUE(v()->IsStorable(create(create(), 3u))); - EXPECT_TRUE(v()->IsStorable(create(create(), 4u))); - EXPECT_TRUE(v()->IsStorable(create(create(), 2u))); - EXPECT_TRUE(v()->IsStorable(create(create(), 3u))); - EXPECT_TRUE(v()->IsStorable(create(create(), 4u))); - EXPECT_TRUE(v()->IsStorable(create(create(), 2u))); - EXPECT_TRUE(v()->IsStorable(create(create(), 3u))); - EXPECT_TRUE(v()->IsStorable(create(create(), 4u))); - EXPECT_TRUE(v()->IsStorable(create(create(), 2u))); - EXPECT_TRUE(v()->IsStorable(create(create(), 3u))); - EXPECT_TRUE(v()->IsStorable(create(create(), 4u))); + EXPECT_TRUE(v()->IsStorable(create(create(), 2u))); + EXPECT_TRUE(v()->IsStorable(create(create(), 3u))); + EXPECT_TRUE(v()->IsStorable(create(create(), 4u))); + EXPECT_TRUE(v()->IsStorable(create(create(), 2u))); + EXPECT_TRUE(v()->IsStorable(create(create(), 3u))); + EXPECT_TRUE(v()->IsStorable(create(create(), 4u))); + EXPECT_TRUE(v()->IsStorable(create(create(), 2u))); + EXPECT_TRUE(v()->IsStorable(create(create(), 3u))); + EXPECT_TRUE(v()->IsStorable(create(create(), 4u))); + EXPECT_TRUE(v()->IsStorable(create(create(), 2u))); + EXPECT_TRUE(v()->IsStorable(create(create(), 3u))); + EXPECT_TRUE(v()->IsStorable(create(create(), 4u))); } TEST_F(ValidatorIsStorableTest, Matrix) { - auto* vec2_f32 = create(create(), 2u); - auto* vec3_f32 = create(create(), 3u); - auto* vec4_f32 = create(create(), 4u); - auto* vec2_f16 = create(create(), 2u); - auto* vec3_f16 = create(create(), 3u); - auto* vec4_f16 = create(create(), 4u); + auto* vec2_f32 = create(create(), 2u); + auto* vec3_f32 = create(create(), 3u); + auto* vec4_f32 = create(create(), 4u); + auto* vec2_f16 = create(create(), 2u); + auto* vec3_f16 = create(create(), 3u); + auto* vec4_f16 = create(create(), 4u); EXPECT_TRUE(v()->IsStorable(create(vec2_f32, 2u))); EXPECT_TRUE(v()->IsStorable(create(vec2_f32, 3u))); EXPECT_TRUE(v()->IsStorable(create(vec2_f32, 4u))); @@ -78,25 +78,25 @@ TEST_F(ValidatorIsStorableTest, Matrix) { } TEST_F(ValidatorIsStorableTest, Pointer) { - auto* ptr = create(create(), ast::AddressSpace::kPrivate, + auto* ptr = create(create(), ast::AddressSpace::kPrivate, ast::Access::kReadWrite); EXPECT_FALSE(v()->IsStorable(ptr)); } TEST_F(ValidatorIsStorableTest, Atomic) { - EXPECT_TRUE(v()->IsStorable(create(create()))); - EXPECT_TRUE(v()->IsStorable(create(create()))); + EXPECT_TRUE(v()->IsStorable(create(create()))); + EXPECT_TRUE(v()->IsStorable(create(create()))); } TEST_F(ValidatorIsStorableTest, ArraySizedOfStorable) { - auto* arr = create(create(), create(5u), 4u, + auto* arr = create(create(), create(5u), 4u, 20u, 4u, 4u); EXPECT_TRUE(v()->IsStorable(arr)); } TEST_F(ValidatorIsStorableTest, ArrayUnsizedOfStorable) { auto* arr = - create(create(), create(), 4u, 4u, 4u, 4u); + create(create(), create(), 4u, 4u, 4u, 4u); EXPECT_TRUE(v()->IsStorable(arr)); } diff --git a/src/tint/resolver/variable_test.cc b/src/tint/resolver/variable_test.cc index 68f4bc2cfb..a0a5ae7547 100644 --- a/src/tint/resolver/variable_test.cc +++ b/src/tint/resolver/variable_test.cc @@ -76,11 +76,11 @@ TEST_F(ResolverVariableTest, LocalVar_NoInitializer) { ASSERT_TRUE(TypeOf(s)->Is()); ASSERT_TRUE(TypeOf(a)->Is()); - EXPECT_TRUE(TypeOf(i)->As()->StoreType()->Is()); - EXPECT_TRUE(TypeOf(u)->As()->StoreType()->Is()); - EXPECT_TRUE(TypeOf(f)->As()->StoreType()->Is()); - EXPECT_TRUE(TypeOf(h)->As()->StoreType()->Is()); - EXPECT_TRUE(TypeOf(b)->As()->StoreType()->Is()); + EXPECT_TRUE(TypeOf(i)->As()->StoreType()->Is()); + EXPECT_TRUE(TypeOf(u)->As()->StoreType()->Is()); + EXPECT_TRUE(TypeOf(f)->As()->StoreType()->Is()); + EXPECT_TRUE(TypeOf(h)->As()->StoreType()->Is()); + EXPECT_TRUE(TypeOf(b)->As()->StoreType()->Is()); EXPECT_TRUE(TypeOf(s)->As()->StoreType()->Is()); EXPECT_TRUE(TypeOf(a)->As()->StoreType()->Is()); @@ -156,11 +156,11 @@ TEST_F(ResolverVariableTest, LocalVar_WithInitializer) { EXPECT_EQ(TypeOf(s)->As()->Access(), ast::Access::kReadWrite); EXPECT_EQ(TypeOf(a)->As()->Access(), ast::Access::kReadWrite); - EXPECT_TRUE(TypeOf(i)->As()->StoreType()->Is()); - EXPECT_TRUE(TypeOf(u)->As()->StoreType()->Is()); - EXPECT_TRUE(TypeOf(f)->As()->StoreType()->Is()); - EXPECT_TRUE(TypeOf(h)->As()->StoreType()->Is()); - EXPECT_TRUE(TypeOf(b)->As()->StoreType()->Is()); + EXPECT_TRUE(TypeOf(i)->As()->StoreType()->Is()); + EXPECT_TRUE(TypeOf(u)->As()->StoreType()->Is()); + EXPECT_TRUE(TypeOf(f)->As()->StoreType()->Is()); + EXPECT_TRUE(TypeOf(h)->As()->StoreType()->Is()); + EXPECT_TRUE(TypeOf(b)->As()->StoreType()->Is()); EXPECT_TRUE(TypeOf(s)->As()->StoreType()->Is()); EXPECT_TRUE(TypeOf(a)->As()->StoreType()->Is()); @@ -437,15 +437,15 @@ TEST_F(ResolverVariableTest, LocalLet) { ASSERT_TRUE(r()->Resolve()) << r()->error(); // `let` declarations are always of the storage type - ASSERT_TRUE(TypeOf(i)->Is()); - ASSERT_TRUE(TypeOf(u)->Is()); - ASSERT_TRUE(TypeOf(f)->Is()); - ASSERT_TRUE(TypeOf(h)->Is()); - ASSERT_TRUE(TypeOf(b)->Is()); + ASSERT_TRUE(TypeOf(i)->Is()); + ASSERT_TRUE(TypeOf(u)->Is()); + ASSERT_TRUE(TypeOf(f)->Is()); + ASSERT_TRUE(TypeOf(h)->Is()); + ASSERT_TRUE(TypeOf(b)->Is()); ASSERT_TRUE(TypeOf(s)->Is()); ASSERT_TRUE(TypeOf(a)->Is()); ASSERT_TRUE(TypeOf(p)->Is()); - ASSERT_TRUE(TypeOf(p)->As()->StoreType()->Is()); + ASSERT_TRUE(TypeOf(p)->As()->StoreType()->Is()); EXPECT_EQ(Sem().Get(i)->Initializer()->Declaration(), i_c); EXPECT_EQ(Sem().Get(u)->Initializer()->Declaration(), u_c); @@ -913,9 +913,9 @@ TEST_F(ResolverVariableTest, LocalConst_ExplicitType_Decls) { EXPECT_EQ(Sem().Get(c_mf32)->Declaration(), c_mf32); EXPECT_EQ(Sem().Get(c_s)->Declaration(), c_s); - ASSERT_TRUE(TypeOf(c_i32)->Is()); - ASSERT_TRUE(TypeOf(c_u32)->Is()); - ASSERT_TRUE(TypeOf(c_f32)->Is()); + ASSERT_TRUE(TypeOf(c_i32)->Is()); + ASSERT_TRUE(TypeOf(c_u32)->Is()); + ASSERT_TRUE(TypeOf(c_f32)->Is()); ASSERT_TRUE(TypeOf(c_vi32)->Is()); ASSERT_TRUE(TypeOf(c_vu32)->Is()); ASSERT_TRUE(TypeOf(c_vf32)->Is()); @@ -971,9 +971,9 @@ TEST_F(ResolverVariableTest, LocalConst_ImplicitType_Decls) { EXPECT_EQ(Sem().Get(c_maf32)->Declaration(), c_maf32); EXPECT_EQ(Sem().Get(c_s)->Declaration(), c_s); - ASSERT_TRUE(TypeOf(c_i32)->Is()); - ASSERT_TRUE(TypeOf(c_u32)->Is()); - ASSERT_TRUE(TypeOf(c_f32)->Is()); + ASSERT_TRUE(TypeOf(c_i32)->Is()); + ASSERT_TRUE(TypeOf(c_u32)->Is()); + ASSERT_TRUE(TypeOf(c_f32)->Is()); ASSERT_TRUE(TypeOf(c_ai)->Is()); ASSERT_TRUE(TypeOf(c_af)->Is()); ASSERT_TRUE(TypeOf(c_vi32)->Is()); @@ -1009,7 +1009,7 @@ TEST_F(ResolverVariableTest, LocalConst_PropagateConstValue) { ASSERT_TRUE(r()->Resolve()) << r()->error(); - ASSERT_TRUE(TypeOf(c)->Is()); + ASSERT_TRUE(TypeOf(c)->Is()); EXPECT_EQ(Sem().Get(c)->ConstantValue()->As(), 42_i); } @@ -1021,7 +1021,7 @@ TEST_F(ResolverVariableTest, LocalConst_ConstEval) { ASSERT_TRUE(r()->Resolve()) << r()->error(); - ASSERT_TRUE(TypeOf(c)->Is()); + ASSERT_TRUE(TypeOf(c)->Is()); EXPECT_EQ(Sem().Get(c)->ConstantValue()->As(), 3_i); } @@ -1093,9 +1093,9 @@ TEST_F(ResolverVariableTest, GlobalConst_ExplicitType_Decls) { EXPECT_EQ(Sem().Get(c_vf32)->Declaration(), c_vf32); EXPECT_EQ(Sem().Get(c_mf32)->Declaration(), c_mf32); - ASSERT_TRUE(TypeOf(c_i32)->Is()); - ASSERT_TRUE(TypeOf(c_u32)->Is()); - ASSERT_TRUE(TypeOf(c_f32)->Is()); + ASSERT_TRUE(TypeOf(c_i32)->Is()); + ASSERT_TRUE(TypeOf(c_u32)->Is()); + ASSERT_TRUE(TypeOf(c_f32)->Is()); ASSERT_TRUE(TypeOf(c_vi32)->Is()); ASSERT_TRUE(TypeOf(c_vu32)->Is()); ASSERT_TRUE(TypeOf(c_vf32)->Is()); @@ -1142,9 +1142,9 @@ TEST_F(ResolverVariableTest, GlobalConst_ImplicitType_Decls) { EXPECT_EQ(Sem().Get(c_mf32)->Declaration(), c_mf32); EXPECT_EQ(Sem().Get(c_maf32)->Declaration(), c_maf32); - ASSERT_TRUE(TypeOf(c_i32)->Is()); - ASSERT_TRUE(TypeOf(c_u32)->Is()); - ASSERT_TRUE(TypeOf(c_f32)->Is()); + ASSERT_TRUE(TypeOf(c_i32)->Is()); + ASSERT_TRUE(TypeOf(c_u32)->Is()); + ASSERT_TRUE(TypeOf(c_f32)->Is()); ASSERT_TRUE(TypeOf(c_ai)->Is()); ASSERT_TRUE(TypeOf(c_af)->Is()); ASSERT_TRUE(TypeOf(c_vi32)->Is()); @@ -1176,7 +1176,7 @@ TEST_F(ResolverVariableTest, GlobalConst_PropagateConstValue) { ASSERT_TRUE(r()->Resolve()) << r()->error(); - ASSERT_TRUE(TypeOf(c)->Is()); + ASSERT_TRUE(TypeOf(c)->Is()); EXPECT_EQ(Sem().Get(c)->ConstantValue()->As(), 42_i); } @@ -1186,7 +1186,7 @@ TEST_F(ResolverVariableTest, GlobalConst_ConstEval) { ASSERT_TRUE(r()->Resolve()) << r()->error(); - ASSERT_TRUE(TypeOf(c)->Is()); + ASSERT_TRUE(TypeOf(c)->Is()); EXPECT_EQ(Sem().Get(c)->ConstantValue()->As(), 3_i); } diff --git a/src/tint/sem/array_test.cc b/src/tint/sem/array_test.cc index e4ecd077b3..ab244b9204 100644 --- a/src/tint/sem/array_test.cc +++ b/src/tint/sem/array_test.cc @@ -21,15 +21,22 @@ namespace { using ArrayTest = TestHelper; TEST_F(ArrayTest, CreateSizedArray) { - auto* a = create(create(), create(2u), 4u, 8u, 32u, 16u); - auto* b = create(create(), create(2u), 4u, 8u, 32u, 16u); - auto* c = create(create(), create(3u), 4u, 8u, 32u, 16u); - auto* d = create(create(), create(2u), 5u, 8u, 32u, 16u); - auto* e = create(create(), create(2u), 4u, 9u, 32u, 16u); - auto* f = create(create(), create(2u), 4u, 8u, 33u, 16u); - auto* g = create(create(), create(2u), 4u, 8u, 33u, 17u); + auto* a = + create(create(), create(2u), 4u, 8u, 32u, 16u); + auto* b = + create(create(), create(2u), 4u, 8u, 32u, 16u); + auto* c = + create(create(), create(3u), 4u, 8u, 32u, 16u); + auto* d = + create(create(), create(2u), 5u, 8u, 32u, 16u); + auto* e = + create(create(), create(2u), 4u, 9u, 32u, 16u); + auto* f = + create(create(), create(2u), 4u, 8u, 33u, 16u); + auto* g = + create(create(), create(2u), 4u, 8u, 33u, 17u); - EXPECT_EQ(a->ElemType(), create()); + EXPECT_EQ(a->ElemType(), create()); EXPECT_EQ(a->Count(), create(2u)); EXPECT_EQ(a->Align(), 4u); EXPECT_EQ(a->Size(), 8u); @@ -47,14 +54,20 @@ TEST_F(ArrayTest, CreateSizedArray) { } TEST_F(ArrayTest, CreateRuntimeArray) { - auto* a = create(create(), create(), 4u, 8u, 32u, 32u); - auto* b = create(create(), create(), 4u, 8u, 32u, 32u); - auto* c = create(create(), create(), 5u, 8u, 32u, 32u); - auto* d = create(create(), create(), 4u, 9u, 32u, 32u); - auto* e = create(create(), create(), 4u, 8u, 33u, 32u); - auto* f = create(create(), create(), 4u, 8u, 33u, 17u); + auto* a = + create(create(), create(), 4u, 8u, 32u, 32u); + auto* b = + create(create(), create(), 4u, 8u, 32u, 32u); + auto* c = + create(create(), create(), 5u, 8u, 32u, 32u); + auto* d = + create(create(), create(), 4u, 9u, 32u, 32u); + auto* e = + create(create(), create(), 4u, 8u, 33u, 32u); + auto* f = + create(create(), create(), 4u, 8u, 33u, 17u); - EXPECT_EQ(a->ElemType(), create()); + EXPECT_EQ(a->ElemType(), create()); EXPECT_EQ(a->Count(), create()); EXPECT_EQ(a->Align(), 4u); EXPECT_EQ(a->Size(), 8u); @@ -71,13 +84,20 @@ TEST_F(ArrayTest, CreateRuntimeArray) { } TEST_F(ArrayTest, Hash) { - auto* a = create(create(), create(2u), 4u, 8u, 32u, 16u); - auto* b = create(create(), create(2u), 4u, 8u, 32u, 16u); - auto* c = create(create(), create(3u), 4u, 8u, 32u, 16u); - auto* d = create(create(), create(2u), 5u, 8u, 32u, 16u); - auto* e = create(create(), create(2u), 4u, 9u, 32u, 16u); - auto* f = create(create(), create(2u), 4u, 8u, 33u, 16u); - auto* g = create(create(), create(2u), 4u, 8u, 33u, 17u); + auto* a = + create(create(), create(2u), 4u, 8u, 32u, 16u); + auto* b = + create(create(), create(2u), 4u, 8u, 32u, 16u); + auto* c = + create(create(), create(3u), 4u, 8u, 32u, 16u); + auto* d = + create(create(), create(2u), 5u, 8u, 32u, 16u); + auto* e = + create(create(), create(2u), 4u, 9u, 32u, 16u); + auto* f = + create(create(), create(2u), 4u, 8u, 33u, 16u); + auto* g = + create(create(), create(2u), 4u, 8u, 33u, 17u); EXPECT_EQ(a->Hash(), b->Hash()); EXPECT_NE(a->Hash(), c->Hash()); @@ -88,13 +108,20 @@ TEST_F(ArrayTest, Hash) { } TEST_F(ArrayTest, Equals) { - auto* a = create(create(), create(2u), 4u, 8u, 32u, 16u); - auto* b = create(create(), create(2u), 4u, 8u, 32u, 16u); - auto* c = create(create(), create(3u), 4u, 8u, 32u, 16u); - auto* d = create(create(), create(2u), 5u, 8u, 32u, 16u); - auto* e = create(create(), create(2u), 4u, 9u, 32u, 16u); - auto* f = create(create(), create(2u), 4u, 8u, 33u, 16u); - auto* g = create(create(), create(2u), 4u, 8u, 33u, 17u); + auto* a = + create(create(), create(2u), 4u, 8u, 32u, 16u); + auto* b = + create(create(), create(2u), 4u, 8u, 32u, 16u); + auto* c = + create(create(), create(3u), 4u, 8u, 32u, 16u); + auto* d = + create(create(), create(2u), 5u, 8u, 32u, 16u); + auto* e = + create(create(), create(2u), 4u, 9u, 32u, 16u); + auto* f = + create(create(), create(2u), 4u, 8u, 33u, 16u); + auto* g = + create(create(), create(2u), 4u, 8u, 33u, 17u); EXPECT_TRUE(a->Equals(*b)); EXPECT_FALSE(a->Equals(*c)); @@ -102,38 +129,42 @@ TEST_F(ArrayTest, Equals) { EXPECT_FALSE(a->Equals(*e)); EXPECT_FALSE(a->Equals(*f)); EXPECT_FALSE(a->Equals(*g)); - EXPECT_FALSE(a->Equals(Void{})); + EXPECT_FALSE(a->Equals(type::Void{})); } TEST_F(ArrayTest, FriendlyNameRuntimeSized) { - auto* arr = create(create(), create(), 0u, 4u, 4u, 4u); + auto* arr = + create(create(), create(), 0u, 4u, 4u, 4u); EXPECT_EQ(arr->FriendlyName(Symbols()), "array"); } TEST_F(ArrayTest, FriendlyNameStaticSized) { - auto* arr = create(create(), create(5u), 4u, 20u, 4u, 4u); + auto* arr = + create(create(), create(5u), 4u, 20u, 4u, 4u); EXPECT_EQ(arr->FriendlyName(Symbols()), "array"); } TEST_F(ArrayTest, FriendlyNameRuntimeSizedNonImplicitStride) { - auto* arr = create(create(), create(), 0u, 4u, 8u, 4u); + auto* arr = + create(create(), create(), 0u, 4u, 8u, 4u); EXPECT_EQ(arr->FriendlyName(Symbols()), "@stride(8) array"); } TEST_F(ArrayTest, FriendlyNameStaticSizedNonImplicitStride) { - auto* arr = create(create(), create(5u), 4u, 20u, 8u, 4u); + auto* arr = + create(create(), create(5u), 4u, 20u, 8u, 4u); EXPECT_EQ(arr->FriendlyName(Symbols()), "@stride(8) array"); } TEST_F(ArrayTest, IsConstructable) { auto* fixed_sized = - create(create(), create(2u), 4u, 8u, 32u, 16u); + create(create(), create(2u), 4u, 8u, 32u, 16u); auto* named_override_sized = create( - create(), create(nullptr), 4u, 8u, 32u, 16u); + create(), create(nullptr), 4u, 8u, 32u, 16u); auto* unnamed_override_sized = create( - create(), create(nullptr), 4u, 8u, 32u, 16u); + create(), create(nullptr), 4u, 8u, 32u, 16u); auto* runtime_sized = - create(create(), create(), 4u, 8u, 32u, 16u); + create(create(), create(), 4u, 8u, 32u, 16u); EXPECT_TRUE(fixed_sized->IsConstructible()); EXPECT_FALSE(named_override_sized->IsConstructible()); @@ -143,13 +174,13 @@ TEST_F(ArrayTest, IsConstructable) { TEST_F(ArrayTest, HasCreationFixedFootprint) { auto* fixed_sized = - create(create(), create(2u), 4u, 8u, 32u, 16u); + create(create(), create(2u), 4u, 8u, 32u, 16u); auto* named_override_sized = create( - create(), create(nullptr), 4u, 8u, 32u, 16u); + create(), create(nullptr), 4u, 8u, 32u, 16u); auto* unnamed_override_sized = create( - create(), create(nullptr), 4u, 8u, 32u, 16u); + create(), create(nullptr), 4u, 8u, 32u, 16u); auto* runtime_sized = - create(create(), create(), 4u, 8u, 32u, 16u); + create(create(), create(), 4u, 8u, 32u, 16u); EXPECT_TRUE(fixed_sized->HasCreationFixedFootprint()); EXPECT_FALSE(named_override_sized->HasCreationFixedFootprint()); @@ -159,13 +190,13 @@ TEST_F(ArrayTest, HasCreationFixedFootprint) { TEST_F(ArrayTest, HasFixedFootprint) { auto* fixed_sized = - create(create(), create(2u), 4u, 8u, 32u, 16u); + create(create(), create(2u), 4u, 8u, 32u, 16u); auto* named_override_sized = create( - create(), create(nullptr), 4u, 8u, 32u, 16u); + create(), create(nullptr), 4u, 8u, 32u, 16u); auto* unnamed_override_sized = create( - create(), create(nullptr), 4u, 8u, 32u, 16u); + create(), create(nullptr), 4u, 8u, 32u, 16u); auto* runtime_sized = - create(create(), create(), 4u, 8u, 32u, 16u); + create(create(), create(), 4u, 8u, 32u, 16u); EXPECT_TRUE(fixed_sized->HasFixedFootprint()); EXPECT_TRUE(named_override_sized->HasFixedFootprint()); diff --git a/src/tint/sem/atomic_test.cc b/src/tint/sem/atomic_test.cc index fbf9bc3b55..436f185d9b 100644 --- a/src/tint/sem/atomic_test.cc +++ b/src/tint/sem/atomic_test.cc @@ -22,33 +22,33 @@ namespace { using AtomicTest = TestHelper; TEST_F(AtomicTest, Creation) { - auto* a = create(create()); - auto* b = create(create()); - auto* c = create(create()); - EXPECT_TRUE(a->Type()->Is()); + auto* a = create(create()); + auto* b = create(create()); + auto* c = create(create()); + EXPECT_TRUE(a->Type()->Is()); EXPECT_EQ(a, b); EXPECT_NE(a, c); } TEST_F(AtomicTest, Hash) { - auto* a = create(create()); - auto* b = create(create()); - auto* c = create(create()); + auto* a = create(create()); + auto* b = create(create()); + auto* c = create(create()); EXPECT_EQ(a->Hash(), b->Hash()); EXPECT_NE(a->Hash(), c->Hash()); } TEST_F(AtomicTest, Equals) { - auto* a = create(create()); - auto* b = create(create()); - auto* c = create(create()); + auto* a = create(create()); + auto* b = create(create()); + auto* c = create(create()); EXPECT_TRUE(a->Equals(*b)); EXPECT_FALSE(a->Equals(*c)); - EXPECT_FALSE(a->Equals(Void{})); + EXPECT_FALSE(a->Equals(type::Void{})); } TEST_F(AtomicTest, FriendlyName) { - auto* a = create(create()); + auto* a = create(create()); EXPECT_EQ(a->FriendlyName(Symbols()), "atomic"); } diff --git a/src/tint/sem/expression_test.cc b/src/tint/sem/expression_test.cc index aae9f46f60..f12f0ed335 100644 --- a/src/tint/sem/expression_test.cc +++ b/src/tint/sem/expression_test.cc @@ -42,8 +42,8 @@ class MockConstant : public sem::Constant { using ExpressionTest = TestHelper; TEST_F(ExpressionTest, UnwrapMaterialize) { - MockConstant c(create()); - auto* a = create(/* declaration */ nullptr, create(), + MockConstant c(create()); + auto* a = create(/* declaration */ nullptr, create(), sem::EvaluationStage::kRuntime, /* statement */ nullptr, /* constant_value */ nullptr, /* has_side_effects */ false, /* root_ident */ nullptr); diff --git a/src/tint/sem/matrix_test.cc b/src/tint/sem/matrix_test.cc index fb8c850bb9..5ff13dcf70 100644 --- a/src/tint/sem/matrix_test.cc +++ b/src/tint/sem/matrix_test.cc @@ -21,13 +21,13 @@ namespace { using MatrixTest = TestHelper; TEST_F(MatrixTest, Creation) { - auto* a = create(create(create(), 3u), 4u); - auto* b = create(create(create(), 3u), 4u); - auto* c = create(create(create(), 3u), 4u); - auto* d = create(create(create(), 2u), 4u); - auto* e = create(create(create(), 3u), 2u); + auto* a = create(create(create(), 3u), 4u); + auto* b = create(create(create(), 3u), 4u); + auto* c = create(create(create(), 3u), 4u); + auto* d = create(create(create(), 2u), 4u); + auto* e = create(create(create(), 3u), 2u); - EXPECT_EQ(a->type(), create()); + EXPECT_EQ(a->type(), create()); EXPECT_EQ(a->rows(), 3u); EXPECT_EQ(a->columns(), 4u); @@ -38,11 +38,11 @@ TEST_F(MatrixTest, Creation) { } TEST_F(MatrixTest, Hash) { - auto* a = create(create(create(), 3u), 4u); - auto* b = create(create(create(), 3u), 4u); - auto* c = create(create(create(), 3u), 4u); - auto* d = create(create(create(), 2u), 4u); - auto* e = create(create(create(), 3u), 2u); + auto* a = create(create(create(), 3u), 4u); + auto* b = create(create(create(), 3u), 4u); + auto* c = create(create(create(), 3u), 4u); + auto* d = create(create(create(), 2u), 4u); + auto* e = create(create(create(), 3u), 2u); EXPECT_EQ(a->Hash(), b->Hash()); EXPECT_NE(a->Hash(), c->Hash()); @@ -51,21 +51,21 @@ TEST_F(MatrixTest, Hash) { } TEST_F(MatrixTest, Equals) { - auto* a = create(create(create(), 3u), 4u); - auto* b = create(create(create(), 3u), 4u); - auto* c = create(create(create(), 3u), 4u); - auto* d = create(create(create(), 2u), 4u); - auto* e = create(create(create(), 3u), 2u); + auto* a = create(create(create(), 3u), 4u); + auto* b = create(create(create(), 3u), 4u); + auto* c = create(create(create(), 3u), 4u); + auto* d = create(create(create(), 2u), 4u); + auto* e = create(create(create(), 3u), 2u); EXPECT_TRUE(a->Equals(*b)); EXPECT_FALSE(a->Equals(*c)); EXPECT_FALSE(a->Equals(*d)); EXPECT_FALSE(a->Equals(*e)); - EXPECT_FALSE(a->Equals(Void{})); + EXPECT_FALSE(a->Equals(type::Void{})); } TEST_F(MatrixTest, FriendlyName) { - I32 i32; + type::I32 i32; Vector c{&i32, 3}; Matrix m{&c, 2}; EXPECT_EQ(m.FriendlyName(Symbols()), "mat2x3"); diff --git a/src/tint/sem/pointer_test.cc b/src/tint/sem/pointer_test.cc index fb3d6c0f7a..c5201ff4be 100644 --- a/src/tint/sem/pointer_test.cc +++ b/src/tint/sem/pointer_test.cc @@ -21,13 +21,17 @@ namespace { using PointerTest = TestHelper; TEST_F(PointerTest, Creation) { - auto* a = create(create(), ast::AddressSpace::kStorage, ast::Access::kReadWrite); - auto* b = create(create(), ast::AddressSpace::kStorage, ast::Access::kReadWrite); - auto* c = create(create(), ast::AddressSpace::kStorage, ast::Access::kReadWrite); - auto* d = create(create(), ast::AddressSpace::kPrivate, ast::Access::kReadWrite); - auto* e = create(create(), ast::AddressSpace::kStorage, ast::Access::kRead); + auto* a = + create(create(), ast::AddressSpace::kStorage, ast::Access::kReadWrite); + auto* b = + create(create(), ast::AddressSpace::kStorage, ast::Access::kReadWrite); + auto* c = + create(create(), ast::AddressSpace::kStorage, ast::Access::kReadWrite); + auto* d = + create(create(), ast::AddressSpace::kPrivate, ast::Access::kReadWrite); + auto* e = create(create(), ast::AddressSpace::kStorage, ast::Access::kRead); - EXPECT_TRUE(a->StoreType()->Is()); + EXPECT_TRUE(a->StoreType()->Is()); EXPECT_EQ(a->AddressSpace(), ast::AddressSpace::kStorage); EXPECT_EQ(a->Access(), ast::Access::kReadWrite); @@ -38,11 +42,15 @@ TEST_F(PointerTest, Creation) { } TEST_F(PointerTest, Hash) { - auto* a = create(create(), ast::AddressSpace::kStorage, ast::Access::kReadWrite); - auto* b = create(create(), ast::AddressSpace::kStorage, ast::Access::kReadWrite); - auto* c = create(create(), ast::AddressSpace::kStorage, ast::Access::kReadWrite); - auto* d = create(create(), ast::AddressSpace::kPrivate, ast::Access::kReadWrite); - auto* e = create(create(), ast::AddressSpace::kStorage, ast::Access::kRead); + auto* a = + create(create(), ast::AddressSpace::kStorage, ast::Access::kReadWrite); + auto* b = + create(create(), ast::AddressSpace::kStorage, ast::Access::kReadWrite); + auto* c = + create(create(), ast::AddressSpace::kStorage, ast::Access::kReadWrite); + auto* d = + create(create(), ast::AddressSpace::kPrivate, ast::Access::kReadWrite); + auto* e = create(create(), ast::AddressSpace::kStorage, ast::Access::kRead); EXPECT_EQ(a->Hash(), b->Hash()); EXPECT_NE(a->Hash(), c->Hash()); @@ -51,26 +59,31 @@ TEST_F(PointerTest, Hash) { } TEST_F(PointerTest, Equals) { - auto* a = create(create(), ast::AddressSpace::kStorage, ast::Access::kReadWrite); - auto* b = create(create(), ast::AddressSpace::kStorage, ast::Access::kReadWrite); - auto* c = create(create(), ast::AddressSpace::kStorage, ast::Access::kReadWrite); - auto* d = create(create(), ast::AddressSpace::kPrivate, ast::Access::kReadWrite); - auto* e = create(create(), ast::AddressSpace::kStorage, ast::Access::kRead); + auto* a = + create(create(), ast::AddressSpace::kStorage, ast::Access::kReadWrite); + auto* b = + create(create(), ast::AddressSpace::kStorage, ast::Access::kReadWrite); + auto* c = + create(create(), ast::AddressSpace::kStorage, ast::Access::kReadWrite); + auto* d = + create(create(), ast::AddressSpace::kPrivate, ast::Access::kReadWrite); + auto* e = create(create(), ast::AddressSpace::kStorage, ast::Access::kRead); EXPECT_TRUE(a->Equals(*b)); EXPECT_FALSE(a->Equals(*c)); EXPECT_FALSE(a->Equals(*d)); EXPECT_FALSE(a->Equals(*e)); - EXPECT_FALSE(a->Equals(Void{})); + EXPECT_FALSE(a->Equals(type::Void{})); } TEST_F(PointerTest, FriendlyName) { - auto* r = create(create(), ast::AddressSpace::kNone, ast::Access::kRead); + auto* r = create(create(), ast::AddressSpace::kNone, ast::Access::kRead); EXPECT_EQ(r->FriendlyName(Symbols()), "ptr"); } TEST_F(PointerTest, FriendlyNameWithAddressSpace) { - auto* r = create(create(), ast::AddressSpace::kWorkgroup, ast::Access::kRead); + auto* r = + create(create(), ast::AddressSpace::kWorkgroup, ast::Access::kRead); EXPECT_EQ(r->FriendlyName(Symbols()), "ptr"); } diff --git a/src/tint/sem/reference_test.cc b/src/tint/sem/reference_test.cc index 53ba21b25e..3ead2336a4 100644 --- a/src/tint/sem/reference_test.cc +++ b/src/tint/sem/reference_test.cc @@ -21,17 +21,18 @@ namespace { using ReferenceTest = TestHelper; TEST_F(ReferenceTest, Creation) { - auto* a = - create(create(), ast::AddressSpace::kStorage, ast::Access::kReadWrite); - auto* b = - create(create(), ast::AddressSpace::kStorage, ast::Access::kReadWrite); - auto* c = - create(create(), ast::AddressSpace::kStorage, ast::Access::kReadWrite); - auto* d = - create(create(), ast::AddressSpace::kPrivate, ast::Access::kReadWrite); - auto* e = create(create(), ast::AddressSpace::kStorage, ast::Access::kRead); + auto* a = create(create(), ast::AddressSpace::kStorage, + ast::Access::kReadWrite); + auto* b = create(create(), ast::AddressSpace::kStorage, + ast::Access::kReadWrite); + auto* c = create(create(), ast::AddressSpace::kStorage, + ast::Access::kReadWrite); + auto* d = create(create(), ast::AddressSpace::kPrivate, + ast::Access::kReadWrite); + auto* e = + create(create(), ast::AddressSpace::kStorage, ast::Access::kRead); - EXPECT_TRUE(a->StoreType()->Is()); + EXPECT_TRUE(a->StoreType()->Is()); EXPECT_EQ(a->AddressSpace(), ast::AddressSpace::kStorage); EXPECT_EQ(a->Access(), ast::Access::kReadWrite); @@ -42,15 +43,16 @@ TEST_F(ReferenceTest, Creation) { } TEST_F(ReferenceTest, Hash) { - auto* a = - create(create(), ast::AddressSpace::kStorage, ast::Access::kReadWrite); - auto* b = - create(create(), ast::AddressSpace::kStorage, ast::Access::kReadWrite); - auto* c = - create(create(), ast::AddressSpace::kStorage, ast::Access::kReadWrite); - auto* d = - create(create(), ast::AddressSpace::kPrivate, ast::Access::kReadWrite); - auto* e = create(create(), ast::AddressSpace::kStorage, ast::Access::kRead); + auto* a = create(create(), ast::AddressSpace::kStorage, + ast::Access::kReadWrite); + auto* b = create(create(), ast::AddressSpace::kStorage, + ast::Access::kReadWrite); + auto* c = create(create(), ast::AddressSpace::kStorage, + ast::Access::kReadWrite); + auto* d = create(create(), ast::AddressSpace::kPrivate, + ast::Access::kReadWrite); + auto* e = + create(create(), ast::AddressSpace::kStorage, ast::Access::kRead); EXPECT_EQ(a->Hash(), b->Hash()); EXPECT_NE(a->Hash(), c->Hash()); @@ -59,30 +61,32 @@ TEST_F(ReferenceTest, Hash) { } TEST_F(ReferenceTest, Equals) { - auto* a = - create(create(), ast::AddressSpace::kStorage, ast::Access::kReadWrite); - auto* b = - create(create(), ast::AddressSpace::kStorage, ast::Access::kReadWrite); - auto* c = - create(create(), ast::AddressSpace::kStorage, ast::Access::kReadWrite); - auto* d = - create(create(), ast::AddressSpace::kPrivate, ast::Access::kReadWrite); - auto* e = create(create(), ast::AddressSpace::kStorage, ast::Access::kRead); + auto* a = create(create(), ast::AddressSpace::kStorage, + ast::Access::kReadWrite); + auto* b = create(create(), ast::AddressSpace::kStorage, + ast::Access::kReadWrite); + auto* c = create(create(), ast::AddressSpace::kStorage, + ast::Access::kReadWrite); + auto* d = create(create(), ast::AddressSpace::kPrivate, + ast::Access::kReadWrite); + auto* e = + create(create(), ast::AddressSpace::kStorage, ast::Access::kRead); EXPECT_TRUE(a->Equals(*b)); EXPECT_FALSE(a->Equals(*c)); EXPECT_FALSE(a->Equals(*d)); EXPECT_FALSE(a->Equals(*e)); - EXPECT_FALSE(a->Equals(Void{})); + EXPECT_FALSE(a->Equals(type::Void{})); } TEST_F(ReferenceTest, FriendlyName) { - auto* r = create(create(), ast::AddressSpace::kNone, ast::Access::kRead); + auto* r = create(create(), ast::AddressSpace::kNone, ast::Access::kRead); EXPECT_EQ(r->FriendlyName(Symbols()), "ref"); } TEST_F(ReferenceTest, FriendlyNameWithAddressSpace) { - auto* r = create(create(), ast::AddressSpace::kWorkgroup, ast::Access::kRead); + auto* r = + create(create(), ast::AddressSpace::kWorkgroup, ast::Access::kRead); EXPECT_EQ(r->FriendlyName(Symbols()), "ref"); } diff --git a/src/tint/sem/struct_test.cc b/src/tint/sem/struct_test.cc index 2d07f537b7..b2f16cf651 100644 --- a/src/tint/sem/struct_test.cc +++ b/src/tint/sem/struct_test.cc @@ -55,7 +55,7 @@ TEST_F(StructTest, Equals) { EXPECT_TRUE(a->Equals(*a)); EXPECT_FALSE(a->Equals(*b)); - EXPECT_FALSE(a->Equals(Void{})); + EXPECT_FALSE(a->Equals(type::Void{})); } TEST_F(StructTest, FriendlyName) { diff --git a/src/tint/sem/vector_test.cc b/src/tint/sem/vector_test.cc index e5c3201b2d..a20f0d7bce 100644 --- a/src/tint/sem/vector_test.cc +++ b/src/tint/sem/vector_test.cc @@ -21,12 +21,12 @@ namespace { using VectorTest = TestHelper; TEST_F(VectorTest, Creation) { - auto* a = create(create(), 2u); - auto* b = create(create(), 2u); - auto* c = create(create(), 2u); - auto* d = create(create(), 3u); + auto* a = create(create(), 2u); + auto* b = create(create(), 2u); + auto* c = create(create(), 2u); + auto* d = create(create(), 3u); - EXPECT_EQ(a->type(), create()); + EXPECT_EQ(a->type(), create()); EXPECT_EQ(a->Width(), 2u); EXPECT_EQ(a, b); @@ -35,10 +35,10 @@ TEST_F(VectorTest, Creation) { } TEST_F(VectorTest, Hash) { - auto* a = create(create(), 2u); - auto* b = create(create(), 2u); - auto* c = create(create(), 2u); - auto* d = create(create(), 3u); + auto* a = create(create(), 2u); + auto* b = create(create(), 2u); + auto* c = create(create(), 2u); + auto* d = create(create(), 3u); EXPECT_EQ(a->Hash(), b->Hash()); EXPECT_NE(a->Hash(), c->Hash()); @@ -46,19 +46,19 @@ TEST_F(VectorTest, Hash) { } TEST_F(VectorTest, Equals) { - auto* a = create(create(), 2u); - auto* b = create(create(), 2u); - auto* c = create(create(), 2u); - auto* d = create(create(), 3u); + auto* a = create(create(), 2u); + auto* b = create(create(), 2u); + auto* c = create(create(), 2u); + auto* d = create(create(), 3u); EXPECT_TRUE(a->Equals(*b)); EXPECT_FALSE(a->Equals(*c)); EXPECT_FALSE(a->Equals(*d)); - EXPECT_FALSE(a->Equals(Void{})); + EXPECT_FALSE(a->Equals(type::Void{})); } TEST_F(VectorTest, FriendlyName) { - auto* f32 = create(); + auto* f32 = create(); auto* v = create(f32, 3u); EXPECT_EQ(v->FriendlyName(Symbols()), "vec3"); } diff --git a/src/tint/tint.natvis b/src/tint/tint.natvis index 4e957ffd29..4d2c3a34b5 100644 --- a/src/tint/tint.natvis +++ b/src/tint/tint.natvis @@ -244,11 +244,11 @@ AbstractFloat - + bool - + f32 diff --git a/src/tint/transform/builtin_polyfill.cc b/src/tint/transform/builtin_polyfill.cc index 757f8585f7..3a3c0704fc 100644 --- a/src/tint/transform/builtin_polyfill.cc +++ b/src/tint/transform/builtin_polyfill.cc @@ -473,7 +473,7 @@ struct BuiltinPolyfill::State { uint32_t width = WidthOf(ty); // Currently in WGSL parameters of insertBits must be i32, u32, vecN or vecN - if (!type::Type::DeepestElementOf(ty)->IsAnyOf()) { + if (!type::Type::DeepestElementOf(ty)->IsAnyOf()) { TINT_ICE(Transform, b.Diagnostics()) << "insertBits polyfill only support i32, u32, and vector of i32 or u32, got " << b.FriendlyName(ty); @@ -895,7 +895,7 @@ Transform::ApplyResult BuiltinPolyfill::Apply(const Program* src, auto& sig = builtin->Signature(); auto* tex = sig.Parameter(sem::ParameterUsage::kTexture); if (auto* stex = tex->Type()->As()) { - if (stex->type()->Is()) { + if (stex->type()->Is()) { fn = builtin_polyfills.GetOrCreate(builtin, [&] { return s.textureSampleBaseClampToEdge_2d_f32(); }); diff --git a/src/tint/transform/canonicalize_entry_point_io.cc b/src/tint/transform/canonicalize_entry_point_io.cc index 8899ac72d8..48e2948a1a 100644 --- a/src/tint/transform/canonicalize_entry_point_io.cc +++ b/src/tint/transform/canonicalize_entry_point_io.cc @@ -396,7 +396,7 @@ struct CanonicalizeEntryPointIO::State { AddOutput(name, member->Type(), member->Location(), std::move(attributes), ctx.dst->MemberAccessor(original_result, name)); } - } else if (!inner_ret_type->Is()) { + } else if (!inner_ret_type->Is()) { auto attributes = CloneShaderIOAttributes(func_ast->return_type_attributes, do_interpolate); @@ -421,7 +421,7 @@ struct CanonicalizeEntryPointIO::State { // No existing sample mask builtin was found, so create a new output value // using the fixed sample mask. - AddOutput("fixed_sample_mask", ctx.dst->create(), std::nullopt, + AddOutput("fixed_sample_mask", ctx.dst->create(), std::nullopt, {ctx.dst->Builtin(ast::BuiltinValue::kSampleMask)}, ctx.dst->Expr(u32(cfg.fixed_sample_mask))); } @@ -429,7 +429,7 @@ struct CanonicalizeEntryPointIO::State { /// Add a point size builtin to the wrapper function output. void AddVertexPointSize() { // Create a new output value and assign it a literal 1.0 value. - AddOutput("vertex_point_size", ctx.dst->create(), std::nullopt, + AddOutput("vertex_point_size", ctx.dst->create(), std::nullopt, {ctx.dst->Builtin(ast::BuiltinValue::kPointSize)}, ctx.dst->Expr(1_f)); } @@ -576,7 +576,7 @@ struct CanonicalizeEntryPointIO::State { } // Exit early if there is no shader IO to handle. - if (func_sem->Parameters().Length() == 0 && func_sem->ReturnType()->Is() && + if (func_sem->Parameters().Length() == 0 && func_sem->ReturnType()->Is() && !needs_fixed_sample_mask && !needs_vertex_point_size && cfg.shader_style != ShaderStyle::kGlsl) { return; @@ -604,7 +604,7 @@ struct CanonicalizeEntryPointIO::State { // Process the return type, and start building the wrapper function body. std::function wrapper_ret_type = [&] { return ctx.dst->ty.void_(); }; - if (func_sem->ReturnType()->Is()) { + if (func_sem->ReturnType()->Is()) { // The function call is just a statement with no result. wrapper_body.Push(ctx.dst->CallStmt(call_inner)); } else { @@ -760,7 +760,7 @@ struct CanonicalizeEntryPointIO::State { case ast::BuiltinValue::kInstanceIndex: case ast::BuiltinValue::kSampleIndex: case ast::BuiltinValue::kSampleMask: - type = ctx.dst->create(); + type = ctx.dst->create(); value = ctx.dst->Bitcast(CreateASTTypeFor(ctx, type), value); break; default: diff --git a/src/tint/transform/decompose_memory_access.cc b/src/tint/transform/decompose_memory_access.cc index 7875a4e6cc..70cf8300c9 100644 --- a/src/tint/transform/decompose_memory_access.cc +++ b/src/tint/transform/decompose_memory_access.cc @@ -76,7 +76,7 @@ struct OffsetExpr : Offset { const ast::Expression* Build(CloneContext& ctx) const override { auto* type = ctx.src->Sem().Get(expr)->Type()->UnwrapRef(); auto* res = ctx.Clone(expr); - if (!type->Is()) { + if (!type->Is()) { res = ctx.dst->Construct(res); } return res; @@ -141,74 +141,74 @@ struct AtomicKey { }; bool IntrinsicDataTypeFor(const type::Type* ty, DecomposeMemoryAccess::Intrinsic::DataType& out) { - if (ty->Is()) { + if (ty->Is()) { out = DecomposeMemoryAccess::Intrinsic::DataType::kI32; return true; } - if (ty->Is()) { + if (ty->Is()) { out = DecomposeMemoryAccess::Intrinsic::DataType::kU32; return true; } - if (ty->Is()) { + if (ty->Is()) { out = DecomposeMemoryAccess::Intrinsic::DataType::kF32; return true; } - if (ty->Is()) { + if (ty->Is()) { out = DecomposeMemoryAccess::Intrinsic::DataType::kF16; return true; } if (auto* vec = ty->As()) { switch (vec->Width()) { case 2: - if (vec->type()->Is()) { + if (vec->type()->Is()) { out = DecomposeMemoryAccess::Intrinsic::DataType::kVec2I32; return true; } - if (vec->type()->Is()) { + if (vec->type()->Is()) { out = DecomposeMemoryAccess::Intrinsic::DataType::kVec2U32; return true; } - if (vec->type()->Is()) { + if (vec->type()->Is()) { out = DecomposeMemoryAccess::Intrinsic::DataType::kVec2F32; return true; } - if (vec->type()->Is()) { + if (vec->type()->Is()) { out = DecomposeMemoryAccess::Intrinsic::DataType::kVec2F16; return true; } break; case 3: - if (vec->type()->Is()) { + if (vec->type()->Is()) { out = DecomposeMemoryAccess::Intrinsic::DataType::kVec3I32; return true; } - if (vec->type()->Is()) { + if (vec->type()->Is()) { out = DecomposeMemoryAccess::Intrinsic::DataType::kVec3U32; return true; } - if (vec->type()->Is()) { + if (vec->type()->Is()) { out = DecomposeMemoryAccess::Intrinsic::DataType::kVec3F32; return true; } - if (vec->type()->Is()) { + if (vec->type()->Is()) { out = DecomposeMemoryAccess::Intrinsic::DataType::kVec3F16; return true; } break; case 4: - if (vec->type()->Is()) { + if (vec->type()->Is()) { out = DecomposeMemoryAccess::Intrinsic::DataType::kVec4I32; return true; } - if (vec->type()->Is()) { + if (vec->type()->Is()) { out = DecomposeMemoryAccess::Intrinsic::DataType::kVec4U32; return true; } - if (vec->type()->Is()) { + if (vec->type()->Is()) { out = DecomposeMemoryAccess::Intrinsic::DataType::kVec4F32; return true; } - if (vec->type()->Is()) { + if (vec->type()->Is()) { out = DecomposeMemoryAccess::Intrinsic::DataType::kVec4F16; return true; } diff --git a/src/tint/transform/direct_variable_access.cc b/src/tint/transform/direct_variable_access.cc index f187ac8e9e..78169d894e 100644 --- a/src/tint/transform/direct_variable_access.cc +++ b/src/tint/transform/direct_variable_access.cc @@ -573,7 +573,7 @@ struct DirectVariableAccess::State { if (!idx->UnwrapMaterialize() ->Type() ->UnwrapRef() - ->IsAnyOf()) { + ->IsAnyOf()) { expr = b.Construct(b.ty.u32(), expr); } } diff --git a/src/tint/transform/spirv_atomic.cc b/src/tint/transform/spirv_atomic.cc index 57fc420e4d..8bf1836880 100644 --- a/src/tint/transform/spirv_atomic.cc +++ b/src/tint/transform/spirv_atomic.cc @@ -201,8 +201,8 @@ struct SpirvAtomic::State { const ast::Type* AtomicTypeFor(const type::Type* ty) { return Switch( ty, // - [&](const sem::I32*) { return b.ty.atomic(CreateASTTypeFor(ctx, ty)); }, - [&](const sem::U32*) { return b.ty.atomic(CreateASTTypeFor(ctx, ty)); }, + [&](const type::I32*) { return b.ty.atomic(CreateASTTypeFor(ctx, ty)); }, + [&](const type::U32*) { return b.ty.atomic(CreateASTTypeFor(ctx, ty)); }, [&](const sem::Struct* str) { return b.ty.type_name(Fork(str->Declaration()).name); }, [&](const sem::Array* arr) -> const ast::Type* { if (arr->Count()->Is()) { diff --git a/src/tint/transform/std140.cc b/src/tint/transform/std140.cc index e1cc7c58f8..dab3eb1f98 100644 --- a/src/tint/transform/std140.cc +++ b/src/tint/transform/std140.cc @@ -645,8 +645,8 @@ struct Std140::State { return "mat" + std::to_string(mat->columns()) + "x" + std::to_string(mat->rows()) + "_" + ConvertSuffix(mat->type()); }, - [&](const sem::F32*) { return "f32"; }, // - [&](const sem::F16*) { return "f16"; }, + [&](const type::F32*) { return "f32"; }, // + [&](const type::F16*) { return "f16"; }, [&](Default) { TINT_ICE(Transform, b.Diagnostics()) << "unhandled type for conversion name: " << src->FriendlyName(ty); diff --git a/src/tint/transform/substitute_override.cc b/src/tint/transform/substitute_override.cc index 7c2d0a2770..9031f44b61 100644 --- a/src/tint/transform/substitute_override.cc +++ b/src/tint/transform/substitute_override.cc @@ -81,11 +81,11 @@ Transform::ApplyResult SubstituteOverride::Apply(const Program* src, auto value = iter->second; auto* ctor = Switch( sem->Type(), - [&](const sem::Bool*) { return b.Expr(!std::equal_to()(value, 0.0)); }, - [&](const sem::I32*) { return b.Expr(i32(value)); }, - [&](const sem::U32*) { return b.Expr(u32(value)); }, - [&](const sem::F32*) { return b.Expr(f32(value)); }, - [&](const sem::F16*) { return b.Expr(f16(value)); }); + [&](const type::Bool*) { return b.Expr(!std::equal_to()(value, 0.0)); }, + [&](const type::I32*) { return b.Expr(i32(value)); }, + [&](const type::U32*) { return b.Expr(u32(value)); }, + [&](const type::F32*) { return b.Expr(f32(value)); }, + [&](const type::F16*) { return b.Expr(f16(value)); }); if (!ctor) { b.Diagnostics().add_error(diag::System::Transform, diff --git a/src/tint/transform/transform.cc b/src/tint/transform/transform.cc index e2a537a343..85448f7542 100644 --- a/src/tint/transform/transform.cc +++ b/src/tint/transform/transform.cc @@ -74,22 +74,22 @@ void Transform::RemoveStatement(CloneContext& ctx, const ast::Statement* stmt) { } const ast::Type* Transform::CreateASTTypeFor(CloneContext& ctx, const type::Type* ty) { - if (ty->Is()) { + if (ty->Is()) { return ctx.dst->create(); } - if (ty->Is()) { + if (ty->Is()) { return ctx.dst->create(); } - if (ty->Is()) { + if (ty->Is()) { return ctx.dst->create(); } - if (ty->Is()) { + if (ty->Is()) { return ctx.dst->create(); } - if (ty->Is()) { + if (ty->Is()) { return ctx.dst->create(); } - if (ty->Is()) { + if (ty->Is()) { return ctx.dst->create(); } if (auto* m = ty->As()) { diff --git a/src/tint/transform/transform_test.cc b/src/tint/transform/transform_test.cc index cb26b9f5e9..70e0c3a578 100644 --- a/src/tint/transform/transform_test.cc +++ b/src/tint/transform/transform_test.cc @@ -41,16 +41,16 @@ struct CreateASTTypeForTest : public testing::Test, public Transform { }; TEST_F(CreateASTTypeForTest, Basic) { - EXPECT_TRUE(create([](ProgramBuilder& b) { return b.create(); })->Is()); - EXPECT_TRUE(create([](ProgramBuilder& b) { return b.create(); })->Is()); - EXPECT_TRUE(create([](ProgramBuilder& b) { return b.create(); })->Is()); - EXPECT_TRUE(create([](ProgramBuilder& b) { return b.create(); })->Is()); - EXPECT_TRUE(create([](ProgramBuilder& b) { return b.create(); })->Is()); + EXPECT_TRUE(create([](ProgramBuilder& b) { return b.create(); })->Is()); + EXPECT_TRUE(create([](ProgramBuilder& b) { return b.create(); })->Is()); + EXPECT_TRUE(create([](ProgramBuilder& b) { return b.create(); })->Is()); + EXPECT_TRUE(create([](ProgramBuilder& b) { return b.create(); })->Is()); + EXPECT_TRUE(create([](ProgramBuilder& b) { return b.create(); })->Is()); } TEST_F(CreateASTTypeForTest, Matrix) { auto* mat = create([](ProgramBuilder& b) { - auto* column_type = b.create(b.create(), 2u); + auto* column_type = b.create(b.create(), 2u); return b.create(column_type, 3u); }); ASSERT_TRUE(mat->Is()); @@ -61,7 +61,7 @@ TEST_F(CreateASTTypeForTest, Matrix) { TEST_F(CreateASTTypeForTest, Vector) { auto* vec = - create([](ProgramBuilder& b) { return b.create(b.create(), 2u); }); + create([](ProgramBuilder& b) { return b.create(b.create(), 2u); }); ASSERT_TRUE(vec->Is()); ASSERT_TRUE(vec->As()->type->Is()); ASSERT_EQ(vec->As()->width, 2u); @@ -69,7 +69,7 @@ TEST_F(CreateASTTypeForTest, Vector) { TEST_F(CreateASTTypeForTest, ArrayImplicitStride) { auto* arr = create([](ProgramBuilder& b) { - return b.create(b.create(), b.create(2u), + return b.create(b.create(), b.create(2u), 4u, 4u, 32u, 32u); }); ASSERT_TRUE(arr->Is()); @@ -83,7 +83,7 @@ TEST_F(CreateASTTypeForTest, ArrayImplicitStride) { TEST_F(CreateASTTypeForTest, ArrayNonImplicitStride) { auto* arr = create([](ProgramBuilder& b) { - return b.create(b.create(), b.create(2u), + return b.create(b.create(), b.create(2u), 4u, 4u, 64u, 32u); }); ASSERT_TRUE(arr->Is()); diff --git a/src/tint/transform/vertex_pulling.cc b/src/tint/transform/vertex_pulling.cc index a9b442113f..d014c610c8 100644 --- a/src/tint/transform/vertex_pulling.cc +++ b/src/tint/transform/vertex_pulling.cc @@ -153,16 +153,16 @@ bool IsTypeCompatible(AttributeWGSLType wgslType, VertexFormatType vertexFormatT AttributeWGSLType WGSLTypeOf(const type::Type* ty) { return Switch( ty, - [](const sem::I32*) -> AttributeWGSLType { + [](const type::I32*) -> AttributeWGSLType { return {BaseWGSLType::kI32, 1}; }, - [](const sem::U32*) -> AttributeWGSLType { + [](const type::U32*) -> AttributeWGSLType { return {BaseWGSLType::kU32, 1}; }, - [](const sem::F32*) -> AttributeWGSLType { + [](const type::F32*) -> AttributeWGSLType { return {BaseWGSLType::kF32, 1}; }, - [](const sem::F16*) -> AttributeWGSLType { + [](const type::F16*) -> AttributeWGSLType { return {BaseWGSLType::kF16, 1}; }, [](const sem::Vector* vec) -> AttributeWGSLType { diff --git a/src/tint/transform/zero_init_workgroup_memory.cc b/src/tint/transform/zero_init_workgroup_memory.cc index e6a335905a..0ae63d6c41 100644 --- a/src/tint/transform/zero_init_workgroup_memory.cc +++ b/src/tint/transform/zero_init_workgroup_memory.cc @@ -411,7 +411,7 @@ struct ZeroInitWorkgroupMemory::State { // Constant value could not be found. Build expression instead. workgroup_size_expr = [this, expr, size = workgroup_size_expr] { auto* e = ctx.Clone(expr); - if (ctx.src->TypeOf(expr)->UnwrapRef()->Is()) { + if (ctx.src->TypeOf(expr)->UnwrapRef()->Is()) { e = b.Construct(e); } return size ? b.Mul(size(), e) : e; diff --git a/src/tint/sem/bool.cc b/src/tint/type/bool.cc similarity index 87% rename from src/tint/sem/bool.cc rename to src/tint/type/bool.cc index 4c3833506e..4c3ab15f5a 100644 --- a/src/tint/sem/bool.cc +++ b/src/tint/type/bool.cc @@ -1,4 +1,4 @@ -// Copyright 2020 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,13 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/sem/bool.h" +#include "src/tint/type/bool.h" #include "src/tint/program_builder.h" -TINT_INSTANTIATE_TYPEINFO(tint::sem::Bool); +TINT_INSTANTIATE_TYPEINFO(tint::type::Bool); -namespace tint::sem { +namespace tint::type { Bool::Bool() : Base(type::TypeFlags{ @@ -51,4 +51,4 @@ uint32_t Bool::Align() const { return 4; } -} // namespace tint::sem +} // namespace tint::type diff --git a/src/tint/sem/bool.h b/src/tint/type/bool.h similarity index 90% rename from src/tint/sem/bool.h rename to src/tint/type/bool.h index f70f6f6a9b..900630d8aa 100644 --- a/src/tint/sem/bool.h +++ b/src/tint/type/bool.h @@ -1,4 +1,4 @@ -// Copyright 2020 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SRC_TINT_SEM_BOOL_H_ -#define SRC_TINT_SEM_BOOL_H_ +#ifndef SRC_TINT_TYPE_BOOL_H_ +#define SRC_TINT_TYPE_BOOL_H_ #include @@ -25,7 +25,7 @@ #undef Bool #endif -namespace tint::sem { +namespace tint::type { /// A boolean type class Bool final : public Castable { @@ -59,6 +59,6 @@ class Bool final : public Castable { uint32_t Align() const override; }; -} // namespace tint::sem +} // namespace tint::type -#endif // SRC_TINT_SEM_BOOL_H_ +#endif // SRC_TINT_TYPE_BOOL_H_ diff --git a/src/tint/sem/bool_test.cc b/src/tint/type/bool_test.cc similarity index 90% rename from src/tint/sem/bool_test.cc rename to src/tint/type/bool_test.cc index 00c862eecd..24b30140f4 100644 --- a/src/tint/sem/bool_test.cc +++ b/src/tint/type/bool_test.cc @@ -1,4 +1,4 @@ -// Copyright 2020 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/sem/test_helper.h" +#include "src/tint/type/test_helper.h" #include "src/tint/type/texture.h" -namespace tint::sem { +namespace tint::type { namespace { using BoolTest = TestHelper; @@ -45,4 +45,4 @@ TEST_F(BoolTest, FriendlyName) { } } // namespace -} // namespace tint::sem +} // namespace tint::type diff --git a/src/tint/type/depth_multisampled_texture_test.cc b/src/tint/type/depth_multisampled_texture_test.cc index 77f356f2c5..d0257b98b7 100644 --- a/src/tint/type/depth_multisampled_texture_test.cc +++ b/src/tint/type/depth_multisampled_texture_test.cc @@ -44,7 +44,7 @@ TEST_F(DepthMultisampledTextureTest, Equals) { EXPECT_TRUE(a->Equals(*a)); EXPECT_TRUE(a->Equals(*b)); - EXPECT_FALSE(a->Equals(sem::Void{})); + EXPECT_FALSE(a->Equals(type::Void{})); } TEST_F(DepthMultisampledTextureTest, Dim) { diff --git a/src/tint/type/depth_texture_test.cc b/src/tint/type/depth_texture_test.cc index f817af8b48..e885fa63b6 100644 --- a/src/tint/type/depth_texture_test.cc +++ b/src/tint/type/depth_texture_test.cc @@ -49,7 +49,7 @@ TEST_F(DepthTextureTest, Equals) { EXPECT_TRUE(a->Equals(*b)); EXPECT_FALSE(a->Equals(*c)); - EXPECT_FALSE(a->Equals(sem::Void{})); + EXPECT_FALSE(a->Equals(type::Void{})); } TEST_F(DepthTextureTest, IsTexture) { diff --git a/src/tint/type/external_texture_test.cc b/src/tint/type/external_texture_test.cc index 678b0137ce..bbafebc93c 100644 --- a/src/tint/type/external_texture_test.cc +++ b/src/tint/type/external_texture_test.cc @@ -41,11 +41,11 @@ TEST_F(ExternalTextureTest, Equals) { auto* a = create(); auto* b = create(); EXPECT_TRUE(a->Equals(*b)); - EXPECT_FALSE(a->Equals(sem::Void{})); + EXPECT_FALSE(a->Equals(type::Void{})); } TEST_F(ExternalTextureTest, IsTexture) { - sem::F32 f32; + type::F32 f32; ExternalTexture s; Texture* ty = &s; EXPECT_FALSE(ty->Is()); @@ -56,7 +56,7 @@ TEST_F(ExternalTextureTest, IsTexture) { } TEST_F(ExternalTextureTest, Dim) { - sem::F32 f32; + type::F32 f32; ExternalTexture s; EXPECT_EQ(s.dim(), ast::TextureDimension::k2d); } diff --git a/src/tint/sem/f16.cc b/src/tint/type/f16.cc similarity index 89% rename from src/tint/sem/f16.cc rename to src/tint/type/f16.cc index f8ab347a52..5cb3cfdca8 100644 --- a/src/tint/sem/f16.cc +++ b/src/tint/type/f16.cc @@ -12,14 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/sem/f16.h" +#include "src/tint/type/f16.h" #include "src/tint/program_builder.h" -TINT_INSTANTIATE_TYPEINFO(tint::sem::F16); +TINT_INSTANTIATE_TYPEINFO(tint::type::F16); -namespace tint { -namespace sem { +namespace tint::type { F16::F16() : Base(type::TypeFlags{ @@ -52,5 +51,4 @@ uint32_t F16::Align() const { return 2; } -} // namespace sem -} // namespace tint +} // namespace tint::type diff --git a/src/tint/sem/f16.h b/src/tint/type/f16.h similarity index 91% rename from src/tint/sem/f16.h rename to src/tint/type/f16.h index e19615524b..a10597bed5 100644 --- a/src/tint/sem/f16.h +++ b/src/tint/type/f16.h @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SRC_TINT_SEM_F16_H_ -#define SRC_TINT_SEM_F16_H_ +#ifndef SRC_TINT_TYPE_F16_H_ +#define SRC_TINT_TYPE_F16_H_ #include #include "src/tint/type/type.h" -namespace tint::sem { +namespace tint::type { /// A float 16 type class F16 final : public Castable { @@ -49,6 +49,6 @@ class F16 final : public Castable { uint32_t Align() const override; }; -} // namespace tint::sem +} // namespace tint::type -#endif // SRC_TINT_SEM_F16_H_ +#endif // SRC_TINT_TYPE_F16_H_ diff --git a/src/tint/sem/f16_test.cc b/src/tint/type/f16_test.cc similarity index 92% rename from src/tint/sem/f16_test.cc rename to src/tint/type/f16_test.cc index 6c774f832b..4bd0529635 100644 --- a/src/tint/sem/f16_test.cc +++ b/src/tint/type/f16_test.cc @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/sem/test_helper.h" +#include "src/tint/type/test_helper.h" #include "src/tint/type/texture.h" -namespace tint::sem { +namespace tint::type { namespace { using F16Test = TestHelper; @@ -45,4 +45,4 @@ TEST_F(F16Test, FriendlyName) { } } // namespace -} // namespace tint::sem +} // namespace tint::type diff --git a/src/tint/sem/f32.cc b/src/tint/type/f32.cc similarity index 87% rename from src/tint/sem/f32.cc rename to src/tint/type/f32.cc index 86c0d05307..92bc4d459e 100644 --- a/src/tint/sem/f32.cc +++ b/src/tint/type/f32.cc @@ -1,4 +1,4 @@ -// Copyright 2020 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,13 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/sem/f32.h" +#include "src/tint/type/f32.h" #include "src/tint/program_builder.h" -TINT_INSTANTIATE_TYPEINFO(tint::sem::F32); +TINT_INSTANTIATE_TYPEINFO(tint::type::F32); -namespace tint::sem { +namespace tint::type { F32::F32() : Base(type::TypeFlags{ @@ -51,4 +51,4 @@ uint32_t F32::Align() const { return 4; } -} // namespace tint::sem +} // namespace tint::type diff --git a/src/tint/sem/f32.h b/src/tint/type/f32.h similarity index 89% rename from src/tint/sem/f32.h rename to src/tint/type/f32.h index 67979bc529..0991c3d357 100644 --- a/src/tint/sem/f32.h +++ b/src/tint/type/f32.h @@ -1,4 +1,4 @@ -// Copyright 2020 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SRC_TINT_SEM_F32_H_ -#define SRC_TINT_SEM_F32_H_ +#ifndef SRC_TINT_TYPE_F32_H_ +#define SRC_TINT_TYPE_F32_H_ #include #include "src/tint/type/type.h" -namespace tint::sem { +namespace tint::type { /// A float 32 type class F32 final : public Castable { @@ -49,6 +49,6 @@ class F32 final : public Castable { uint32_t Align() const override; }; -} // namespace tint::sem +} // namespace tint::type -#endif // SRC_TINT_SEM_F32_H_ +#endif // SRC_TINT_TYPE_F32_H_ diff --git a/src/tint/sem/f32_test.cc b/src/tint/type/f32_test.cc similarity index 90% rename from src/tint/sem/f32_test.cc rename to src/tint/type/f32_test.cc index 1d5a7d13bd..127a34bb40 100644 --- a/src/tint/sem/f32_test.cc +++ b/src/tint/type/f32_test.cc @@ -1,4 +1,4 @@ -// Copyright 2020 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/sem/test_helper.h" +#include "src/tint/type/test_helper.h" #include "src/tint/type/texture.h" -namespace tint::sem { +namespace tint::type { namespace { using F32Test = TestHelper; @@ -45,4 +45,4 @@ TEST_F(F32Test, FriendlyName) { } } // namespace -} // namespace tint::sem +} // namespace tint::type diff --git a/src/tint/sem/i32.cc b/src/tint/type/i32.cc similarity index 87% rename from src/tint/sem/i32.cc rename to src/tint/type/i32.cc index 0f4ccae7d6..f657e244da 100644 --- a/src/tint/sem/i32.cc +++ b/src/tint/type/i32.cc @@ -1,4 +1,4 @@ -// Copyright 2020 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,13 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/sem/i32.h" +#include "src/tint/type/i32.h" #include "src/tint/program_builder.h" -TINT_INSTANTIATE_TYPEINFO(tint::sem::I32); +TINT_INSTANTIATE_TYPEINFO(tint::type::I32); -namespace tint::sem { +namespace tint::type { I32::I32() : Base(type::TypeFlags{ @@ -51,4 +51,4 @@ uint32_t I32::Align() const { return 4; } -} // namespace tint::sem +} // namespace tint::type diff --git a/src/tint/sem/i32.h b/src/tint/type/i32.h similarity index 89% rename from src/tint/sem/i32.h rename to src/tint/type/i32.h index 9893f2f57f..3057cdabc7 100644 --- a/src/tint/sem/i32.h +++ b/src/tint/type/i32.h @@ -1,4 +1,4 @@ -// Copyright 2020 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SRC_TINT_SEM_I32_H_ -#define SRC_TINT_SEM_I32_H_ +#ifndef SRC_TINT_TYPE_I32_H_ +#define SRC_TINT_TYPE_I32_H_ #include #include "src/tint/type/type.h" -namespace tint::sem { +namespace tint::type { /// A signed int 32 type. class I32 final : public Castable { @@ -49,6 +49,6 @@ class I32 final : public Castable { uint32_t Align() const override; }; -} // namespace tint::sem +} // namespace tint::type -#endif // SRC_TINT_SEM_I32_H_ +#endif // SRC_TINT_TYPE_I32_H_ diff --git a/src/tint/sem/i32_test.cc b/src/tint/type/i32_test.cc similarity index 90% rename from src/tint/sem/i32_test.cc rename to src/tint/type/i32_test.cc index 632251790c..7b45a03ec9 100644 --- a/src/tint/sem/i32_test.cc +++ b/src/tint/type/i32_test.cc @@ -1,4 +1,4 @@ -// Copyright 2020 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/sem/test_helper.h" +#include "src/tint/type/test_helper.h" #include "src/tint/type/texture.h" -namespace tint::sem { +namespace tint::type { namespace { using I32Test = TestHelper; @@ -45,4 +45,4 @@ TEST_F(I32Test, FriendlyName) { } } // namespace -} // namespace tint::sem +} // namespace tint::type diff --git a/src/tint/type/multisampled_texture_test.cc b/src/tint/type/multisampled_texture_test.cc index 6753136603..72cf496e48 100644 --- a/src/tint/type/multisampled_texture_test.cc +++ b/src/tint/type/multisampled_texture_test.cc @@ -26,38 +26,38 @@ namespace { using MultisampledTextureTest = TestHelper; TEST_F(MultisampledTextureTest, Creation) { - auto* a = create(ast::TextureDimension::k2d, create()); - auto* b = create(ast::TextureDimension::k2d, create()); - auto* c = create(ast::TextureDimension::k3d, create()); - auto* d = create(ast::TextureDimension::k2d, create()); + auto* a = create(ast::TextureDimension::k2d, create()); + auto* b = create(ast::TextureDimension::k2d, create()); + auto* c = create(ast::TextureDimension::k3d, create()); + auto* d = create(ast::TextureDimension::k2d, create()); EXPECT_EQ(a, b); EXPECT_NE(a, c); EXPECT_NE(a, d); } TEST_F(MultisampledTextureTest, Hash) { - auto* a = create(ast::TextureDimension::k2d, create()); - auto* b = create(ast::TextureDimension::k2d, create()); - auto* c = create(ast::TextureDimension::k3d, create()); - auto* d = create(ast::TextureDimension::k2d, create()); + auto* a = create(ast::TextureDimension::k2d, create()); + auto* b = create(ast::TextureDimension::k2d, create()); + auto* c = create(ast::TextureDimension::k3d, create()); + auto* d = create(ast::TextureDimension::k2d, create()); EXPECT_EQ(a->Hash(), b->Hash()); EXPECT_NE(a->Hash(), c->Hash()); EXPECT_NE(a->Hash(), d->Hash()); } TEST_F(MultisampledTextureTest, Equals) { - auto* a = create(ast::TextureDimension::k2d, create()); - auto* b = create(ast::TextureDimension::k2d, create()); - auto* c = create(ast::TextureDimension::k3d, create()); - auto* d = create(ast::TextureDimension::k2d, create()); + auto* a = create(ast::TextureDimension::k2d, create()); + auto* b = create(ast::TextureDimension::k2d, create()); + auto* c = create(ast::TextureDimension::k3d, create()); + auto* d = create(ast::TextureDimension::k2d, create()); EXPECT_TRUE(a->Equals(*b)); EXPECT_FALSE(a->Equals(*c)); EXPECT_FALSE(a->Equals(*d)); - EXPECT_FALSE(a->Equals(sem::Void{})); + EXPECT_FALSE(a->Equals(type::Void{})); } TEST_F(MultisampledTextureTest, IsTexture) { - sem::F32 f32; + type::F32 f32; MultisampledTexture s(ast::TextureDimension::kCube, &f32); Texture* ty = &s; EXPECT_FALSE(ty->Is()); @@ -68,19 +68,19 @@ TEST_F(MultisampledTextureTest, IsTexture) { } TEST_F(MultisampledTextureTest, Dim) { - sem::F32 f32; + type::F32 f32; MultisampledTexture s(ast::TextureDimension::k3d, &f32); EXPECT_EQ(s.dim(), ast::TextureDimension::k3d); } TEST_F(MultisampledTextureTest, Type) { - sem::F32 f32; + type::F32 f32; MultisampledTexture s(ast::TextureDimension::k3d, &f32); EXPECT_EQ(s.type(), &f32); } TEST_F(MultisampledTextureTest, FriendlyName) { - sem::F32 f32; + type::F32 f32; MultisampledTexture s(ast::TextureDimension::k3d, &f32); EXPECT_EQ(s.FriendlyName(Symbols()), "texture_multisampled_3d"); } diff --git a/src/tint/type/sampled_texture_test.cc b/src/tint/type/sampled_texture_test.cc index e45fb7c2de..4f327ea50e 100644 --- a/src/tint/type/sampled_texture_test.cc +++ b/src/tint/type/sampled_texture_test.cc @@ -25,12 +25,12 @@ namespace { using SampledTextureTest = TestHelper; TEST_F(SampledTextureTest, Creation) { - auto* a = create(ast::TextureDimension::kCube, create()); - auto* b = create(ast::TextureDimension::kCube, create()); - auto* c = create(ast::TextureDimension::k2d, create()); - auto* d = create(ast::TextureDimension::kCube, create()); + auto* a = create(ast::TextureDimension::kCube, create()); + auto* b = create(ast::TextureDimension::kCube, create()); + auto* c = create(ast::TextureDimension::k2d, create()); + auto* d = create(ast::TextureDimension::kCube, create()); - EXPECT_TRUE(a->type()->Is()); + EXPECT_TRUE(a->type()->Is()); EXPECT_EQ(a->dim(), ast::TextureDimension::kCube); EXPECT_EQ(a, b); @@ -39,10 +39,10 @@ TEST_F(SampledTextureTest, Creation) { } TEST_F(SampledTextureTest, Hash) { - auto* a = create(ast::TextureDimension::kCube, create()); - auto* b = create(ast::TextureDimension::kCube, create()); - auto* c = create(ast::TextureDimension::k2d, create()); - auto* d = create(ast::TextureDimension::kCube, create()); + auto* a = create(ast::TextureDimension::kCube, create()); + auto* b = create(ast::TextureDimension::kCube, create()); + auto* c = create(ast::TextureDimension::k2d, create()); + auto* d = create(ast::TextureDimension::kCube, create()); EXPECT_EQ(a->Hash(), b->Hash()); EXPECT_NE(a->Hash(), c->Hash()); @@ -50,19 +50,19 @@ TEST_F(SampledTextureTest, Hash) { } TEST_F(SampledTextureTest, Equals) { - auto* a = create(ast::TextureDimension::kCube, create()); - auto* b = create(ast::TextureDimension::kCube, create()); - auto* c = create(ast::TextureDimension::k2d, create()); - auto* d = create(ast::TextureDimension::kCube, create()); + auto* a = create(ast::TextureDimension::kCube, create()); + auto* b = create(ast::TextureDimension::kCube, create()); + auto* c = create(ast::TextureDimension::k2d, create()); + auto* d = create(ast::TextureDimension::kCube, create()); EXPECT_TRUE(a->Equals(*b)); EXPECT_FALSE(a->Equals(*c)); EXPECT_FALSE(a->Equals(*d)); - EXPECT_FALSE(a->Equals(sem::Void{})); + EXPECT_FALSE(a->Equals(type::Void{})); } TEST_F(SampledTextureTest, IsTexture) { - sem::F32 f32; + type::F32 f32; SampledTexture s(ast::TextureDimension::kCube, &f32); Texture* ty = &s; EXPECT_FALSE(ty->Is()); @@ -72,19 +72,19 @@ TEST_F(SampledTextureTest, IsTexture) { } TEST_F(SampledTextureTest, Dim) { - sem::F32 f32; + type::F32 f32; SampledTexture s(ast::TextureDimension::k3d, &f32); EXPECT_EQ(s.dim(), ast::TextureDimension::k3d); } TEST_F(SampledTextureTest, Type) { - sem::F32 f32; + type::F32 f32; SampledTexture s(ast::TextureDimension::k3d, &f32); EXPECT_EQ(s.type(), &f32); } TEST_F(SampledTextureTest, FriendlyName) { - sem::F32 f32; + type::F32 f32; SampledTexture s(ast::TextureDimension::k3d, &f32); EXPECT_EQ(s.FriendlyName(Symbols()), "texture_3d"); } diff --git a/src/tint/type/sampler_test.cc b/src/tint/type/sampler_test.cc index 6d0e1888df..038efb59ac 100644 --- a/src/tint/type/sampler_test.cc +++ b/src/tint/type/sampler_test.cc @@ -52,7 +52,7 @@ TEST_F(SamplerTest, Equals) { EXPECT_TRUE(a->Equals(*b)); EXPECT_FALSE(a->Equals(*c)); - EXPECT_FALSE(a->Equals(sem::Void{})); + EXPECT_FALSE(a->Equals(type::Void{})); } TEST_F(SamplerTest, FriendlyNameSampler) { diff --git a/src/tint/type/storage_texture.cc b/src/tint/type/storage_texture.cc index b922284ed2..03d340e4e3 100644 --- a/src/tint/type/storage_texture.cc +++ b/src/tint/type/storage_texture.cc @@ -55,7 +55,7 @@ type::Type* StorageTexture::SubtypeFor(ast::TexelFormat format, type::TypeManage case ast::TexelFormat::kRg32Uint: case ast::TexelFormat::kRgba16Uint: case ast::TexelFormat::kRgba32Uint: { - return type_mgr.Get(); + return type_mgr.Get(); } case ast::TexelFormat::kR32Sint: @@ -63,7 +63,7 @@ type::Type* StorageTexture::SubtypeFor(ast::TexelFormat format, type::TypeManage case ast::TexelFormat::kRg32Sint: case ast::TexelFormat::kRgba16Sint: case ast::TexelFormat::kRgba32Sint: { - return type_mgr.Get(); + return type_mgr.Get(); } case ast::TexelFormat::kRgba8Unorm: @@ -72,7 +72,7 @@ type::Type* StorageTexture::SubtypeFor(ast::TexelFormat format, type::TypeManage case ast::TexelFormat::kRg32Float: case ast::TexelFormat::kRgba16Float: case ast::TexelFormat::kRgba32Float: { - return type_mgr.Get(); + return type_mgr.Get(); } case ast::TexelFormat::kUndefined: diff --git a/src/tint/type/storage_texture_test.cc b/src/tint/type/storage_texture_test.cc index 55becae22c..a237d716f2 100644 --- a/src/tint/type/storage_texture_test.cc +++ b/src/tint/type/storage_texture_test.cc @@ -41,7 +41,7 @@ TEST_F(StorageTextureTest, Creation) { auto* e = Create(ast::TextureDimension::kCube, ast::TexelFormat::kRgba32Float, ast::Access::kRead); - EXPECT_TRUE(a->type()->Is()); + EXPECT_TRUE(a->type()->Is()); EXPECT_EQ(a->dim(), ast::TextureDimension::kCube); EXPECT_EQ(a, b); @@ -84,7 +84,7 @@ TEST_F(StorageTextureTest, Equals) { EXPECT_FALSE(a->Equals(*c)); EXPECT_FALSE(a->Equals(*d)); EXPECT_FALSE(a->Equals(*e)); - EXPECT_FALSE(a->Equals(sem::Void{})); + EXPECT_FALSE(a->Equals(type::Void{})); } TEST_F(StorageTextureTest, Dim) { @@ -114,7 +114,7 @@ TEST_F(StorageTextureTest, F32) { ASSERT_TRUE(program.IsValid()) << program.Diagnostics().str(); ASSERT_TRUE(s->Is()); ASSERT_TRUE(s->Is()); - EXPECT_TRUE(s->As()->type()->Is()); + EXPECT_TRUE(s->As()->type()->Is()); } TEST_F(StorageTextureTest, U32) { @@ -128,7 +128,7 @@ TEST_F(StorageTextureTest, U32) { ASSERT_TRUE(program.IsValid()) << program.Diagnostics().str(); ASSERT_TRUE(s->Is()); ASSERT_TRUE(s->Is()); - EXPECT_TRUE(s->As()->type()->Is()); + EXPECT_TRUE(s->As()->type()->Is()); } TEST_F(StorageTextureTest, I32) { @@ -142,7 +142,7 @@ TEST_F(StorageTextureTest, I32) { ASSERT_TRUE(program.IsValid()) << program.Diagnostics().str(); ASSERT_TRUE(s->Is()); ASSERT_TRUE(s->Is()); - EXPECT_TRUE(s->As()->type()->Is()); + EXPECT_TRUE(s->As()->type()->Is()); } } // namespace diff --git a/src/tint/type/texture_test.cc b/src/tint/type/texture_test.cc index 1c3abd7128..c7da4f5212 100644 --- a/src/tint/type/texture_test.cc +++ b/src/tint/type/texture_test.cc @@ -24,7 +24,7 @@ using TextureTypeDimTest = TestParamHelper; TEST_P(TextureTypeDimTest, DimMustMatch) { // Check that the dim() query returns the right dimensionality. - sem::F32 f32; + type::F32 f32; // TextureType is an abstract class, so use concrete class // SampledTexture in its stead. SampledTexture st(GetParam(), &f32); diff --git a/src/tint/type/type.cc b/src/tint/type/type.cc index a416947986..61bb3dd267 100644 --- a/src/tint/type/type.cc +++ b/src/tint/type/type.cc @@ -15,20 +15,20 @@ #include "src/tint/type/type.h" #include "src/tint/sem/array.h" -#include "src/tint/sem/bool.h" -#include "src/tint/sem/f16.h" -#include "src/tint/sem/f32.h" -#include "src/tint/sem/i32.h" #include "src/tint/sem/matrix.h" #include "src/tint/sem/pointer.h" #include "src/tint/sem/reference.h" #include "src/tint/sem/struct.h" -#include "src/tint/sem/u32.h" #include "src/tint/sem/vector.h" #include "src/tint/type/abstract_float.h" #include "src/tint/type/abstract_int.h" +#include "src/tint/type/bool.h" +#include "src/tint/type/f16.h" +#include "src/tint/type/f32.h" +#include "src/tint/type/i32.h" #include "src/tint/type/sampler.h" #include "src/tint/type/texture.h" +#include "src/tint/type/u32.h" TINT_INSTANTIATE_TYPEINFO(tint::type::Type); @@ -69,15 +69,15 @@ uint32_t Type::Align() const { } bool Type::is_scalar() const { - return IsAnyOf(); + return IsAnyOf(); } bool Type::is_numeric_scalar() const { - return IsAnyOf(); + return IsAnyOf(); } bool Type::is_float_scalar() const { - return IsAnyOf(); + return IsAnyOf(); } bool Type::is_float_matrix() const { @@ -103,32 +103,32 @@ bool Type::is_float_scalar_or_vector_or_matrix() const { } bool Type::is_integer_scalar() const { - return IsAnyOf(); + return IsAnyOf(); } bool Type::is_signed_integer_scalar() const { - return IsAnyOf(); + return IsAnyOf(); } bool Type::is_unsigned_integer_scalar() const { - return Is(); + return Is(); } bool Type::is_signed_integer_vector() const { return Is( - [](const sem::Vector* v) { return v->type()->IsAnyOf(); }); + [](const sem::Vector* v) { return v->type()->IsAnyOf(); }); } bool Type::is_unsigned_integer_vector() const { - return Is([](const sem::Vector* v) { return v->type()->Is(); }); + return Is([](const sem::Vector* v) { return v->type()->Is(); }); } bool Type::is_unsigned_integer_scalar_or_vector() const { - return Is() || is_unsigned_integer_vector(); + return Is() || is_unsigned_integer_vector(); } bool Type::is_signed_integer_scalar_or_vector() const { - return IsAnyOf() || is_signed_integer_vector(); + return IsAnyOf() || is_signed_integer_vector(); } bool Type::is_integer_scalar_or_vector() const { @@ -152,11 +152,11 @@ bool Type::is_abstract_float_scalar_or_vector() const { } bool Type::is_bool_vector() const { - return Is([](const sem::Vector* v) { return v->type()->Is(); }); + return Is([](const sem::Vector* v) { return v->type()->Is(); }); } bool Type::is_bool_scalar_or_vector() const { - return Is() || is_bool_vector(); + return Is() || is_bool_vector(); } bool Type::is_numeric_vector() const { @@ -200,19 +200,19 @@ uint32_t Type::ConversionRank(const Type* from, const Type* to) { from, [&](const type::AbstractFloat*) { return Switch( - to, // - [&](const sem::F32*) { return 1; }, // - [&](const sem::F16*) { return 2; }, // + to, // + [&](const type::F32*) { return 1; }, // + [&](const type::F16*) { return 2; }, // [&](Default) { return kNoConversion; }); }, [&](const type::AbstractInt*) { return Switch( to, // - [&](const sem::I32*) { return 3; }, // - [&](const sem::U32*) { return 4; }, // + [&](const type::I32*) { return 3; }, // + [&](const type::U32*) { return 4; }, // [&](const type::AbstractFloat*) { return 5; }, // - [&](const sem::F32*) { return 6; }, // - [&](const sem::F16*) { return 7; }, // + [&](const type::F32*) { return 6; }, // + [&](const type::F16*) { return 7; }, // [&](Default) { return kNoConversion; }); }, [&](const sem::Vector* from_vec) { diff --git a/src/tint/type/type_manager_test.cc b/src/tint/type/type_manager_test.cc index 76312bd17e..11c3645f71 100644 --- a/src/tint/type/type_manager_test.cc +++ b/src/tint/type/type_manager_test.cc @@ -15,8 +15,8 @@ #include "src/tint/type/type_manager.h" #include "gtest/gtest.h" -#include "src/tint/sem/i32.h" -#include "src/tint/sem/u32.h" +#include "src/tint/type/i32.h" +#include "src/tint/type/u32.h" namespace tint::type { namespace { @@ -35,51 +35,51 @@ using TypeManagerTest = testing::Test; TEST_F(TypeManagerTest, GetUnregistered) { TypeManager tm; - auto* t = tm.Get(); + auto* t = tm.Get(); ASSERT_NE(t, nullptr); - EXPECT_TRUE(t->Is()); + EXPECT_TRUE(t->Is()); } TEST_F(TypeManagerTest, GetSameTypeReturnsSamePtr) { TypeManager tm; - auto* t = tm.Get(); + auto* t = tm.Get(); ASSERT_NE(t, nullptr); - EXPECT_TRUE(t->Is()); + EXPECT_TRUE(t->Is()); - auto* t2 = tm.Get(); + auto* t2 = tm.Get(); EXPECT_EQ(t, t2); } TEST_F(TypeManagerTest, GetDifferentTypeReturnsDifferentPtr) { TypeManager tm; - type::Type* t = tm.Get(); + type::Type* t = tm.Get(); ASSERT_NE(t, nullptr); - EXPECT_TRUE(t->Is()); + EXPECT_TRUE(t->Is()); - type::Type* t2 = tm.Get(); + type::Type* t2 = tm.Get(); ASSERT_NE(t2, nullptr); EXPECT_NE(t, t2); - EXPECT_TRUE(t2->Is()); + EXPECT_TRUE(t2->Is()); } TEST_F(TypeManagerTest, Find) { TypeManager tm; - auto* created = tm.Get(); + auto* created = tm.Get(); - EXPECT_EQ(tm.Find(), nullptr); - EXPECT_EQ(tm.Find(), created); + EXPECT_EQ(tm.Find(), nullptr); + EXPECT_EQ(tm.Find(), created); } TEST_F(TypeManagerTest, WrapDoesntAffectInner) { TypeManager inner; TypeManager outer = TypeManager::Wrap(inner); - inner.Get(); + inner.Get(); EXPECT_EQ(count(inner), 1u); EXPECT_EQ(count(outer), 0u); - outer.Get(); + outer.Get(); EXPECT_EQ(count(inner), 1u); EXPECT_EQ(count(outer), 1u); diff --git a/src/tint/type/type_test.cc b/src/tint/type/type_test.cc index 9036f8912a..4b083004ce 100644 --- a/src/tint/type/type_test.cc +++ b/src/tint/type/type_test.cc @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/sem/f16.h" #include "src/tint/sem/reference.h" #include "src/tint/type/abstract_float.h" #include "src/tint/type/abstract_int.h" #include "src/tint/type/array_count.h" +#include "src/tint/type/f16.h" #include "src/tint/type/test_helper.h" namespace tint::type { @@ -25,10 +25,10 @@ namespace { struct TypeTest : public TestHelper { const type::AbstractFloat* af = create(); const type::AbstractInt* ai = create(); - const sem::F32* f32 = create(); - const sem::F16* f16 = create(); - const sem::I32* i32 = create(); - const sem::U32* u32 = create(); + const type::F32* f32 = create(); + const type::F16* f16 = create(); + const type::I32* i32 = create(); + const type::U32* u32 = create(); const sem::Vector* vec2_f32 = create(f32, 2u); const sem::Vector* vec3_f32 = create(f32, 3u); const sem::Vector* vec3_f16 = create(f16, 3u); diff --git a/src/tint/sem/u32.cc b/src/tint/type/u32.cc similarity index 87% rename from src/tint/sem/u32.cc rename to src/tint/type/u32.cc index 6b15150b27..54b487e10c 100644 --- a/src/tint/sem/u32.cc +++ b/src/tint/type/u32.cc @@ -1,4 +1,4 @@ -// Copyright 2020 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,13 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/sem/u32.h" +#include "src/tint/type/u32.h" #include "src/tint/program_builder.h" -TINT_INSTANTIATE_TYPEINFO(tint::sem::U32); +TINT_INSTANTIATE_TYPEINFO(tint::type::U32); -namespace tint::sem { +namespace tint::type { U32::U32() : Base(type::TypeFlags{ @@ -51,4 +51,4 @@ uint32_t U32::Align() const { return 4; } -} // namespace tint::sem +} // namespace tint::type diff --git a/src/tint/sem/u32.h b/src/tint/type/u32.h similarity index 89% rename from src/tint/sem/u32.h rename to src/tint/type/u32.h index 5f6ca0a837..bbbc33fb09 100644 --- a/src/tint/sem/u32.h +++ b/src/tint/type/u32.h @@ -1,4 +1,4 @@ -// Copyright 2020 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SRC_TINT_SEM_U32_H_ -#define SRC_TINT_SEM_U32_H_ +#ifndef SRC_TINT_TYPE_U32_H_ +#define SRC_TINT_TYPE_U32_H_ #include #include "src/tint/type/type.h" -namespace tint::sem { +namespace tint::type { /// A unsigned int 32 type. class U32 final : public Castable { @@ -49,6 +49,6 @@ class U32 final : public Castable { uint32_t Align() const override; }; -} // namespace tint::sem +} // namespace tint::type -#endif // SRC_TINT_SEM_U32_H_ +#endif // SRC_TINT_TYPE_U32_H_ diff --git a/src/tint/sem/u32_test.cc b/src/tint/type/u32_test.cc similarity index 90% rename from src/tint/sem/u32_test.cc rename to src/tint/type/u32_test.cc index c3ca0e5119..784b6d6c61 100644 --- a/src/tint/sem/u32_test.cc +++ b/src/tint/type/u32_test.cc @@ -1,4 +1,4 @@ -// Copyright 2020 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/sem/test_helper.h" +#include "src/tint/type/test_helper.h" #include "src/tint/type/texture.h" -namespace tint::sem { +namespace tint::type { namespace { using U32Test = TestHelper; @@ -45,4 +45,4 @@ TEST_F(U32Test, FriendlyName) { } } // namespace -} // namespace tint::sem +} // namespace tint::type diff --git a/src/tint/sem/void.cc b/src/tint/type/void.cc similarity index 85% rename from src/tint/sem/void.cc rename to src/tint/type/void.cc index bc8dbfbc49..2b8bb17312 100644 --- a/src/tint/sem/void.cc +++ b/src/tint/type/void.cc @@ -1,4 +1,4 @@ -// Copyright 2020 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,13 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/tint/sem/void.h" +#include "src/tint/type/void.h" #include "src/tint/program_builder.h" -TINT_INSTANTIATE_TYPEINFO(tint::sem::Void); +TINT_INSTANTIATE_TYPEINFO(tint::type::Void); -namespace tint::sem { +namespace tint::type { Void::Void() : Base(type::TypeFlags{}) {} @@ -38,4 +38,4 @@ std::string Void::FriendlyName(const SymbolTable&) const { return "void"; } -} // namespace tint::sem +} // namespace tint::type diff --git a/src/tint/sem/void.h b/src/tint/type/void.h similarity index 87% rename from src/tint/sem/void.h rename to src/tint/type/void.h index d5d04086e9..e533c86970 100644 --- a/src/tint/sem/void.h +++ b/src/tint/type/void.h @@ -1,4 +1,4 @@ -// Copyright 2020 The Tint Authors. +// Copyright 2022 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SRC_TINT_SEM_VOID_H_ -#define SRC_TINT_SEM_VOID_H_ +#ifndef SRC_TINT_TYPE_VOID_H_ +#define SRC_TINT_TYPE_VOID_H_ #include #include "src/tint/type/type.h" -namespace tint::sem { +namespace tint::type { /// A void type class Void final : public Castable { @@ -43,6 +43,6 @@ class Void final : public Castable { std::string FriendlyName(const SymbolTable& symbols) const override; }; -} // namespace tint::sem +} // namespace tint::type -#endif // SRC_TINT_SEM_VOID_H_ +#endif // SRC_TINT_TYPE_VOID_H_ diff --git a/src/tint/writer/append_vector.cc b/src/tint/writer/append_vector.cc index c3a094aae4..97bae38f76 100644 --- a/src/tint/writer/append_vector.cc +++ b/src/tint/writer/append_vector.cc @@ -46,13 +46,13 @@ VectorInitializerInfo AsVectorInitializer(const sem::Expression* expr) { const sem::Expression* Zero(ProgramBuilder& b, const type::Type* ty, const sem::Statement* stmt) { const ast::Expression* expr = nullptr; - if (ty->Is()) { + if (ty->Is()) { expr = b.Expr(0_i); - } else if (ty->Is()) { + } else if (ty->Is()) { expr = b.Expr(0_u); - } else if (ty->Is()) { + } else if (ty->Is()) { expr = b.Expr(0_f); - } else if (ty->Is()) { + } else if (ty->Is()) { expr = b.Expr(false); } else { TINT_UNREACHABLE(Writer, b.Diagnostics()) @@ -85,13 +85,13 @@ const sem::Call* AppendVector(ProgramBuilder* b, } const ast::Type* packed_el_ast_ty = nullptr; - if (packed_el_sem_ty->Is()) { + if (packed_el_sem_ty->Is()) { packed_el_ast_ty = b->create(); - } else if (packed_el_sem_ty->Is()) { + } else if (packed_el_sem_ty->Is()) { packed_el_ast_ty = b->create(); - } else if (packed_el_sem_ty->Is()) { + } else if (packed_el_sem_ty->Is()) { packed_el_ast_ty = b->create(); - } else if (packed_el_sem_ty->Is()) { + } else if (packed_el_sem_ty->Is()) { packed_el_ast_ty = b->create(); } else { TINT_UNREACHABLE(Writer, b->Diagnostics()) diff --git a/src/tint/writer/append_vector_test.cc b/src/tint/writer/append_vector_test.cc index 08c1d1c87d..1164f544f0 100644 --- a/src/tint/writer/append_vector_test.cc +++ b/src/tint/writer/append_vector_test.cc @@ -57,13 +57,13 @@ TEST_F(AppendVectorTest, Vec2i32_i32) { ASSERT_NE(ctor, nullptr); ASSERT_TRUE(ctor->ReturnType()->Is()); EXPECT_EQ(ctor->ReturnType()->As()->Width(), 3u); - EXPECT_TRUE(ctor->ReturnType()->As()->type()->Is()); + EXPECT_TRUE(ctor->ReturnType()->As()->type()->Is()); EXPECT_EQ(ctor->ReturnType(), call->Type()); ASSERT_EQ(ctor->Parameters().Length(), 3u); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); } // AppendVector(vec2(1, 2), 3u) -> vec3(1, 2, i32(3u)) @@ -101,13 +101,13 @@ TEST_F(AppendVectorTest, Vec2i32_u32) { ASSERT_NE(ctor, nullptr); ASSERT_TRUE(ctor->ReturnType()->Is()); EXPECT_EQ(ctor->ReturnType()->As()->Width(), 3u); - EXPECT_TRUE(ctor->ReturnType()->As()->type()->Is()); + EXPECT_TRUE(ctor->ReturnType()->As()->type()->Is()); EXPECT_EQ(ctor->ReturnType(), call->Type()); ASSERT_EQ(ctor->Parameters().Length(), 3u); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); } // AppendVector(vec2(vec2(1u, 2u)), 3u) -> @@ -152,12 +152,12 @@ TEST_F(AppendVectorTest, Vec2i32FromVec2u32_u32) { ASSERT_NE(ctor, nullptr); ASSERT_TRUE(ctor->ReturnType()->Is()); EXPECT_EQ(ctor->ReturnType()->As()->Width(), 3u); - EXPECT_TRUE(ctor->ReturnType()->As()->type()->Is()); + EXPECT_TRUE(ctor->ReturnType()->As()->type()->Is()); EXPECT_EQ(ctor->ReturnType(), call->Type()); ASSERT_EQ(ctor->Parameters().Length(), 2u); EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); } // AppendVector(vec2(1, 2), 3.0f) -> vec3(1, 2, i32(3.0f)) @@ -195,13 +195,13 @@ TEST_F(AppendVectorTest, Vec2i32_f32) { ASSERT_NE(ctor, nullptr); ASSERT_TRUE(ctor->ReturnType()->Is()); EXPECT_EQ(ctor->ReturnType()->As()->Width(), 3u); - EXPECT_TRUE(ctor->ReturnType()->As()->type()->Is()); + EXPECT_TRUE(ctor->ReturnType()->As()->type()->Is()); EXPECT_EQ(ctor->ReturnType(), call->Type()); ASSERT_EQ(ctor->Parameters().Length(), 3u); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); } // AppendVector(vec3(1, 2, 3), 4) -> vec4(1, 2, 3, 4) @@ -238,14 +238,14 @@ TEST_F(AppendVectorTest, Vec3i32_i32) { ASSERT_NE(ctor, nullptr); ASSERT_TRUE(ctor->ReturnType()->Is()); EXPECT_EQ(ctor->ReturnType()->As()->Width(), 4u); - EXPECT_TRUE(ctor->ReturnType()->As()->type()->Is()); + EXPECT_TRUE(ctor->ReturnType()->As()->type()->Is()); EXPECT_EQ(ctor->ReturnType(), call->Type()); ASSERT_EQ(ctor->Parameters().Length(), 4u); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[3]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[3]->Type()->Is()); } // AppendVector(vec_12, 3) -> vec3(vec_12, 3) @@ -276,12 +276,12 @@ TEST_F(AppendVectorTest, Vec2i32Var_i32) { ASSERT_NE(ctor, nullptr); ASSERT_TRUE(ctor->ReturnType()->Is()); EXPECT_EQ(ctor->ReturnType()->As()->Width(), 3u); - EXPECT_TRUE(ctor->ReturnType()->As()->type()->Is()); + EXPECT_TRUE(ctor->ReturnType()->As()->type()->Is()); EXPECT_EQ(ctor->ReturnType(), call->Type()); ASSERT_EQ(ctor->Parameters().Length(), 2u); EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); } // AppendVector(1, 2, scalar_3) -> vec3(1, 2, scalar_3) @@ -316,13 +316,13 @@ TEST_F(AppendVectorTest, Vec2i32_i32Var) { ASSERT_NE(ctor, nullptr); ASSERT_TRUE(ctor->ReturnType()->Is()); EXPECT_EQ(ctor->ReturnType()->As()->Width(), 3u); - EXPECT_TRUE(ctor->ReturnType()->As()->type()->Is()); + EXPECT_TRUE(ctor->ReturnType()->As()->type()->Is()); EXPECT_EQ(ctor->ReturnType(), call->Type()); ASSERT_EQ(ctor->Parameters().Length(), 3u); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); } // AppendVector(vec_12, scalar_3) -> vec3(vec_12, scalar_3) @@ -354,12 +354,12 @@ TEST_F(AppendVectorTest, Vec2i32Var_i32Var) { ASSERT_NE(ctor, nullptr); ASSERT_TRUE(ctor->ReturnType()->Is()); EXPECT_EQ(ctor->ReturnType()->As()->Width(), 3u); - EXPECT_TRUE(ctor->ReturnType()->As()->type()->Is()); + EXPECT_TRUE(ctor->ReturnType()->As()->type()->Is()); EXPECT_EQ(ctor->ReturnType(), call->Type()); ASSERT_EQ(ctor->Parameters().Length(), 2u); EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); } // AppendVector(vec_12, scalar_3) -> vec3(vec_12, i32(scalar_3)) @@ -395,12 +395,12 @@ TEST_F(AppendVectorTest, Vec2i32Var_f32Var) { ASSERT_NE(ctor, nullptr); ASSERT_TRUE(ctor->ReturnType()->Is()); EXPECT_EQ(ctor->ReturnType()->As()->Width(), 3u); - EXPECT_TRUE(ctor->ReturnType()->As()->type()->Is()); + EXPECT_TRUE(ctor->ReturnType()->As()->type()->Is()); EXPECT_EQ(ctor->ReturnType(), call->Type()); ASSERT_EQ(ctor->Parameters().Length(), 2u); EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); } // AppendVector(vec_12, scalar_3) -> vec3(vec_12, scalar_3) @@ -432,12 +432,12 @@ TEST_F(AppendVectorTest, Vec2boolVar_boolVar) { ASSERT_NE(ctor, nullptr); ASSERT_TRUE(ctor->ReturnType()->Is()); EXPECT_EQ(ctor->ReturnType()->As()->Width(), 3u); - EXPECT_TRUE(ctor->ReturnType()->As()->type()->Is()); + EXPECT_TRUE(ctor->ReturnType()->As()->type()->Is()); EXPECT_EQ(ctor->ReturnType(), call->Type()); ASSERT_EQ(ctor->Parameters().Length(), 2u); EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); } // AppendVector(vec3(), 4) -> vec3(0, 0, 0, 4) @@ -473,14 +473,14 @@ TEST_F(AppendVectorTest, ZeroVec3i32_i32) { ASSERT_NE(ctor, nullptr); ASSERT_TRUE(ctor->ReturnType()->Is()); EXPECT_EQ(ctor->ReturnType()->As()->Width(), 4u); - EXPECT_TRUE(ctor->ReturnType()->As()->type()->Is()); + EXPECT_TRUE(ctor->ReturnType()->As()->type()->Is()); EXPECT_EQ(ctor->ReturnType(), call->Type()); ASSERT_EQ(ctor->Parameters().Length(), 4u); - EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); - EXPECT_TRUE(ctor->Parameters()[3]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[0]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[1]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[2]->Type()->Is()); + EXPECT_TRUE(ctor->Parameters()[3]->Type()->Is()); } } // namespace diff --git a/src/tint/writer/glsl/generator_impl.cc b/src/tint/writer/glsl/generator_impl.cc index 00f6490db2..ea439438f1 100644 --- a/src/tint/writer/glsl/generator_impl.cc +++ b/src/tint/writer/glsl/generator_impl.cc @@ -941,7 +941,7 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out, return false; } out << ", 0"; - if (builtin->ReturnType()->Is()) { + if (builtin->ReturnType()->Is()) { out << "u"; } } @@ -1280,7 +1280,7 @@ bool GeneratorImpl::EmitDegreesCall(std::ostream& out, const ast::CallExpression* expr, const sem::Builtin* builtin) { auto* return_elem_type = type::Type::DeepestElementOf(builtin->ReturnType()); - const std::string suffix = Is(return_elem_type) ? "hf" : "f"; + const std::string suffix = Is(return_elem_type) ? "hf" : "f"; return CallBuiltinHelper(out, expr, builtin, [&](TextBuffer* b, const std::vector& params) { line(b) << "return " << params[0] << " * " << std::setprecision(20) @@ -1293,7 +1293,7 @@ bool GeneratorImpl::EmitRadiansCall(std::ostream& out, const ast::CallExpression* expr, const sem::Builtin* builtin) { auto* return_elem_type = type::Type::DeepestElementOf(builtin->ReturnType()); - const std::string suffix = Is(return_elem_type) ? "hf" : "f"; + const std::string suffix = Is(return_elem_type) ? "hf" : "f"; return CallBuiltinHelper(out, expr, builtin, [&](TextBuffer* b, const std::vector& params) { line(b) << "return " << params[0] << " * " << std::setprecision(20) @@ -1351,7 +1351,7 @@ bool GeneratorImpl::EmitBarrierCall(std::ostream& out, const sem::Builtin* built const ast::Expression* GeneratorImpl::CreateF32Zero(const sem::Statement* stmt) { auto* zero = builder_.Expr(0_f); - auto* f32 = builder_.create(); + auto* f32 = builder_.create(); auto* sem_zero = builder_.create(zero, f32, sem::EvaluationStage::kRuntime, stmt, /* constant_value */ nullptr, /* has_side_effects */ false); @@ -1658,7 +1658,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out, out << ")"; - if (builtin->ReturnType()->Is()) { + if (builtin->ReturnType()->Is()) { return true; } // If the builtin return type does not match the number of elements of the @@ -2297,23 +2297,23 @@ bool GeneratorImpl::EmitEntryPointFunction(const ast::Function* func) { bool GeneratorImpl::EmitConstant(std::ostream& out, const sem::Constant* constant) { return Switch( constant->Type(), // - [&](const sem::Bool*) { + [&](const type::Bool*) { out << (constant->As() ? "true" : "false"); return true; }, - [&](const sem::F32*) { + [&](const type::F32*) { PrintF32(out, constant->As()); return true; }, - [&](const sem::F16*) { + [&](const type::F16*) { PrintF16(out, constant->As()); return true; }, - [&](const sem::I32*) { + [&](const type::I32*) { out << constant->As(); return true; }, - [&](const sem::U32*) { + [&](const type::U32*) { out << constant->As() << "u"; return true; }, @@ -2436,15 +2436,15 @@ bool GeneratorImpl::EmitLiteral(std::ostream& out, const ast::LiteralExpression* } bool GeneratorImpl::EmitZeroValue(std::ostream& out, const type::Type* type) { - if (type->Is()) { + if (type->Is()) { out << "false"; - } else if (type->Is()) { + } else if (type->Is()) { out << "0.0f"; - } else if (type->Is()) { + } else if (type->Is()) { out << "0.0hf"; - } else if (type->Is()) { + } else if (type->Is()) { out << "0"; - } else if (type->Is()) { + } else if (type->Is()) { out << "0u"; } else if (auto* vec = type->As()) { if (!EmitType(out, type, ast::AddressSpace::kNone, ast::Access::kReadWrite, "")) { @@ -2871,17 +2871,17 @@ bool GeneratorImpl::EmitType(std::ostream& out, out << "[]"; } } - } else if (type->Is()) { + } else if (type->Is()) { out << "bool"; - } else if (type->Is()) { + } else if (type->Is()) { out << "float"; - } else if (type->Is()) { + } else if (type->Is()) { out << "float16_t"; - } else if (type->Is()) { + } else if (type->Is()) { out << "int"; } else if (auto* mat = type->As()) { - TINT_ASSERT(Writer, (mat->type()->IsAnyOf())); - if (mat->type()->Is()) { + TINT_ASSERT(Writer, (mat->type()->IsAnyOf())); + if (mat->type()->Is()) { out << "f16"; } out << "mat" << mat->columns(); @@ -2917,10 +2917,10 @@ bool GeneratorImpl::EmitType(std::ostream& out, : storage ? storage->type() : ms ? ms->type() : nullptr; - if (!subtype || subtype->Is()) { - } else if (subtype->Is()) { + if (!subtype || subtype->Is()) { + } else if (subtype->Is()) { out << "i"; - } else if (subtype->Is()) { + } else if (subtype->Is()) { out << "u"; } else { TINT_ICE(Writer, diagnostics_) << "Unsupported texture type"; @@ -2956,19 +2956,19 @@ bool GeneratorImpl::EmitType(std::ostream& out, if (tex->Is()) { out << "Shadow"; } - } else if (type->Is()) { + } else if (type->Is()) { out << "uint"; } else if (auto* vec = type->As()) { auto width = vec->Width(); - if (vec->type()->Is() && width >= 1 && width <= 4) { + if (vec->type()->Is() && width >= 1 && width <= 4) { out << "vec" << width; - } else if (vec->type()->Is() && width >= 1 && width <= 4) { + } else if (vec->type()->Is() && width >= 1 && width <= 4) { out << "f16vec" << width; - } else if (vec->type()->Is() && width >= 1 && width <= 4) { + } else if (vec->type()->Is() && width >= 1 && width <= 4) { out << "ivec" << width; - } else if (vec->type()->Is() && width >= 1 && width <= 4) { + } else if (vec->type()->Is() && width >= 1 && width <= 4) { out << "uvec" << width; - } else if (vec->type()->Is() && width >= 1 && width <= 4) { + } else if (vec->type()->Is() && width >= 1 && width <= 4) { out << "bvec" << width; } else { out << "vector<"; @@ -2981,7 +2981,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, if (!EmitType(out, atomic->Type(), address_space, access, name)) { return false; } - } else if (type->Is()) { + } else if (type->Is()) { out << "void"; } else { diagnostics_.add_error(diag::System::Writer, "unknown type in EmitType"); @@ -3206,8 +3206,8 @@ bool GeneratorImpl::CallBuiltinHelper(std::ostream& out, } type::Type* GeneratorImpl::BoolTypeToUint(const type::Type* type) { - auto* u32 = builder_.create(); - if (type->Is()) { + auto* u32 = builder_.create(); + if (type->Is()) { return u32; } else if (auto* vec = type->As()) { return builder_.create(u32, vec->Width()); diff --git a/src/tint/writer/glsl/generator_impl_type_test.cc b/src/tint/writer/glsl/generator_impl_type_test.cc index 726b834ceb..7adf2746d7 100644 --- a/src/tint/writer/glsl/generator_impl_type_test.cc +++ b/src/tint/writer/glsl/generator_impl_type_test.cc @@ -84,7 +84,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Array_WithoutName) { } TEST_F(GlslGeneratorImplTest_Type, EmitType_Bool) { - auto* bool_ = create(); + auto* bool_ = create(); GeneratorImpl& gen = Build(); @@ -95,7 +95,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Bool) { } TEST_F(GlslGeneratorImplTest_Type, EmitType_F32) { - auto* f32 = create(); + auto* f32 = create(); GeneratorImpl& gen = Build(); @@ -108,7 +108,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_F32) { TEST_F(GlslGeneratorImplTest_Type, EmitType_F16) { Enable(ast::Extension::kF16); - auto* f16 = create(); + auto* f16 = create(); GeneratorImpl& gen = Build(); @@ -119,7 +119,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_F16) { } TEST_F(GlslGeneratorImplTest_Type, EmitType_I32) { - auto* i32 = create(); + auto* i32 = create(); GeneratorImpl& gen = Build(); @@ -130,7 +130,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_I32) { } TEST_F(GlslGeneratorImplTest_Type, EmitType_Matrix_F32) { - auto* f32 = create(); + auto* f32 = create(); auto* vec3 = create(f32, 3u); auto* mat2x3 = create(vec3, 2u); @@ -145,7 +145,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Matrix_F32) { TEST_F(GlslGeneratorImplTest_Type, EmitType_Matrix_F16) { Enable(ast::Extension::kF16); - auto* f16 = create(); + auto* f16 = create(); auto* vec3 = create(f16, 3u); auto* mat2x3 = create(vec3, 2u); @@ -231,7 +231,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Struct_WithOffsetAttributes) { } TEST_F(GlslGeneratorImplTest_Type, EmitType_U32) { - auto* u32 = create(); + auto* u32 = create(); GeneratorImpl& gen = Build(); @@ -242,7 +242,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_U32) { } TEST_F(GlslGeneratorImplTest_Type, EmitType_Vector_F32) { - auto* f32 = create(); + auto* f32 = create(); auto* vec3 = create(f32, 3u); GeneratorImpl& gen = Build(); @@ -256,7 +256,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Vector_F32) { TEST_F(GlslGeneratorImplTest_Type, EmitType_Vector_F16) { Enable(ast::Extension::kF16); - auto* f16 = create(); + auto* f16 = create(); auto* vec3 = create(f16, 3u); GeneratorImpl& gen = Build(); @@ -268,7 +268,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Vector_F16) { } TEST_F(GlslGeneratorImplTest_Type, EmitType_Void) { - auto* void_ = create(); + auto* void_ = create(); GeneratorImpl& gen = Build(); @@ -494,7 +494,7 @@ INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Type, })); TEST_F(GlslGeneratorImplTest_Type, EmitMultisampledTexture) { - auto* f32 = create(); + auto* f32 = create(); auto* s = create(ast::TextureDimension::k2d, f32); GeneratorImpl& gen = Build(); diff --git a/src/tint/writer/hlsl/generator_impl.cc b/src/tint/writer/hlsl/generator_impl.cc index e989bfcbc3..565f97a7df 100644 --- a/src/tint/writer/hlsl/generator_impl.cc +++ b/src/tint/writer/hlsl/generator_impl.cc @@ -1116,7 +1116,7 @@ bool GeneratorImpl::EmitUniformBufferAccess( bool scalar_offset_constant = false; if (auto* val = offset_arg->ConstantValue()) { - TINT_ASSERT(Writer, val->Type()->Is()); + TINT_ASSERT(Writer, val->Type()->Is()); scalar_offset_bytes = static_cast(std::get(val->Value())); scalar_offset_index = scalar_offset_bytes / 4; // bytes -> scalar index scalar_offset_constant = true; @@ -1775,7 +1775,7 @@ bool GeneratorImpl::EmitWorkgroupAtomicCall(std::ostream& out, const sem::Builtin* builtin) { std::string result = UniqueIdentifier("atomic_result"); - if (!builtin->ReturnType()->Is()) { + if (!builtin->ReturnType()->Is()) { auto pre = line(); if (!EmitTypeAndName(pre, builtin->ReturnType(), ast::AddressSpace::kNone, ast::Access::kUndefined, result)) { @@ -2021,7 +2021,7 @@ bool GeneratorImpl::EmitFrexpCall(std::ostream& out, } std::string member_type; - if (Is(type::Type::DeepestElementOf(ty))) { + if (Is(type::Type::DeepestElementOf(ty))) { member_type = width.empty() ? "float16_t" : ("vector"); } else { member_type = "float" + width; @@ -2539,7 +2539,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out, } auto emit_vector_appended_with_i32_zero = [&](const ast::Expression* vector) { - auto* i32 = builder_.create(); + auto* i32 = builder_.create(); auto* zero = builder_.Expr(0_i); auto* stmt = builder_.Sem().Get(vector)->Stmt(); builder_.Sem().Add( @@ -2915,7 +2915,7 @@ bool GeneratorImpl::EmitFunction(const ast::Function* func) { out << ") {"; } - if (sem->DiscardStatement() && !sem->ReturnType()->Is()) { + if (sem->DiscardStatement() && !sem->ReturnType()->Is()) { // BUG(crbug.com/tint/1081): work around non-void functions with discard // failing compilation sometimes if (!EmitFunctionBodyWithDiscard(func)) { @@ -2939,7 +2939,7 @@ bool GeneratorImpl::EmitFunctionBodyWithDiscard(const ast::Function* func) { // there is always an (unused) return statement. auto* sem = builder_.Sem().Get(func); - TINT_ASSERT(Writer, sem->DiscardStatement() && !sem->ReturnType()->Is()); + TINT_ASSERT(Writer, sem->DiscardStatement() && !sem->ReturnType()->Is()); ScopedIndent si(this); line() << "if (true) {"; @@ -3267,26 +3267,26 @@ bool GeneratorImpl::EmitConstant(std::ostream& out, bool is_variable_initializer) { return Switch( constant->Type(), // - [&](const sem::Bool*) { + [&](const type::Bool*) { out << (constant->As() ? "true" : "false"); return true; }, - [&](const sem::F32*) { + [&](const type::F32*) { PrintF32(out, constant->As()); return true; }, - [&](const sem::F16*) { + [&](const type::F16*) { // emit a f16 scalar with explicit float16_t type declaration. out << "float16_t("; PrintF16(out, constant->As()); out << ")"; return true; }, - [&](const sem::I32*) { + [&](const type::I32*) { out << constant->As(); return true; }, - [&](const sem::U32*) { + [&](const type::U32*) { out << constant->As() << "u"; return true; }, @@ -3459,23 +3459,23 @@ bool GeneratorImpl::EmitLiteral(std::ostream& out, const ast::LiteralExpression* bool GeneratorImpl::EmitValue(std::ostream& out, const type::Type* type, int value) { return Switch( type, - [&](const sem::Bool*) { + [&](const type::Bool*) { out << (value == 0 ? "false" : "true"); return true; }, - [&](const sem::F32*) { + [&](const type::F32*) { out << value << ".0f"; return true; }, - [&](const sem::F16*) { + [&](const type::F16*) { out << "float16_t(" << value << ".0h)"; return true; }, - [&](const sem::I32*) { + [&](const type::I32*) { out << value; return true; }, - [&](const sem::U32*) { + [&](const type::U32*) { out << value << "u"; return true; }, @@ -3954,24 +3954,24 @@ bool GeneratorImpl::EmitType(std::ostream& out, } return true; }, - [&](const sem::Bool*) { + [&](const type::Bool*) { out << "bool"; return true; }, - [&](const sem::F32*) { + [&](const type::F32*) { out << "float"; return true; }, - [&](const sem::F16*) { + [&](const type::F16*) { out << "float16_t"; return true; }, - [&](const sem::I32*) { + [&](const type::I32*) { out << "int"; return true; }, [&](const sem::Matrix* mat) { - if (mat->type()->Is()) { + if (mat->type()->Is()) { // Use matrix for f16 matrix out << "matrix<"; if (!EmitType(out, mat->type(), address_space, access, "")) { @@ -4066,11 +4066,11 @@ bool GeneratorImpl::EmitType(std::ostream& out, } else if (sampled || ms) { auto* subtype = sampled ? sampled->type() : ms->type(); out << "<"; - if (subtype->Is()) { + if (subtype->Is()) { out << "float4"; - } else if (subtype->Is()) { + } else if (subtype->Is()) { out << "int4"; - } else if (subtype->Is()) { + } else if (subtype->Is()) { out << "uint4"; } else { TINT_ICE(Writer, diagnostics_) << "Unsupported multisampled texture type"; @@ -4080,19 +4080,19 @@ bool GeneratorImpl::EmitType(std::ostream& out, } return true; }, - [&](const sem::U32*) { + [&](const type::U32*) { out << "uint"; return true; }, [&](const sem::Vector* vec) { auto width = vec->Width(); - if (vec->type()->Is() && width >= 1 && width <= 4) { + if (vec->type()->Is() && width >= 1 && width <= 4) { out << "float" << width; - } else if (vec->type()->Is() && width >= 1 && width <= 4) { + } else if (vec->type()->Is() && width >= 1 && width <= 4) { out << "int" << width; - } else if (vec->type()->Is() && width >= 1 && width <= 4) { + } else if (vec->type()->Is() && width >= 1 && width <= 4) { out << "uint" << width; - } else if (vec->type()->Is() && width >= 1 && width <= 4) { + } else if (vec->type()->Is() && width >= 1 && width <= 4) { out << "bool" << width; } else { // For example, use "vector" for f16 vector. @@ -4107,7 +4107,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, [&](const sem::Atomic* atomic) { return EmitType(out, atomic->Type(), address_space, access, name); }, - [&](const sem::Void*) { + [&](const type::Void*) { out << "void"; return true; }, diff --git a/src/tint/writer/hlsl/generator_impl_type_test.cc b/src/tint/writer/hlsl/generator_impl_type_test.cc index b11320576e..ed85b4801b 100644 --- a/src/tint/writer/hlsl/generator_impl_type_test.cc +++ b/src/tint/writer/hlsl/generator_impl_type_test.cc @@ -84,7 +84,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Array_WithoutName) { } TEST_F(HlslGeneratorImplTest_Type, EmitType_Bool) { - auto* bool_ = create(); + auto* bool_ = create(); GeneratorImpl& gen = Build(); @@ -95,7 +95,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Bool) { } TEST_F(HlslGeneratorImplTest_Type, EmitType_F16) { - auto* f16 = create(); + auto* f16 = create(); GeneratorImpl& gen = Build(); @@ -106,7 +106,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_F16) { } TEST_F(HlslGeneratorImplTest_Type, EmitType_F32) { - auto* f32 = create(); + auto* f32 = create(); GeneratorImpl& gen = Build(); @@ -117,7 +117,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_F32) { } TEST_F(HlslGeneratorImplTest_Type, EmitType_I32) { - auto* i32 = create(); + auto* i32 = create(); GeneratorImpl& gen = Build(); @@ -128,7 +128,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_I32) { } TEST_F(HlslGeneratorImplTest_Type, EmitType_Matrix_F16) { - auto* f16 = create(); + auto* f16 = create(); auto* vec3 = create(f16, 3u); auto* mat2x3 = create(vec3, 2u); @@ -141,7 +141,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Matrix_F16) { } TEST_F(HlslGeneratorImplTest_Type, EmitType_Matrix_F32) { - auto* f32 = create(); + auto* f32 = create(); auto* vec3 = create(f32, 3u); auto* mat2x3 = create(vec3, 2u); @@ -239,7 +239,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct_WithOffsetAttributes) { } TEST_F(HlslGeneratorImplTest_Type, EmitType_U32) { - auto* u32 = create(); + auto* u32 = create(); GeneratorImpl& gen = Build(); @@ -250,7 +250,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_U32) { } TEST_F(HlslGeneratorImplTest_Type, EmitType_Vector) { - auto* f32 = create(); + auto* f32 = create(); auto* vec3 = create(f32, 3u); GeneratorImpl& gen = Build(); @@ -262,7 +262,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Vector) { } TEST_F(HlslGeneratorImplTest_Type, EmitType_Void) { - auto* void_ = create(); + auto* void_ = create(); GeneratorImpl& gen = Build(); @@ -493,7 +493,7 @@ INSTANTIATE_TEST_SUITE_P(HlslGeneratorImplTest_Type, })); TEST_F(HlslGeneratorImplTest_Type, EmitMultisampledTexture) { - auto* f32 = create(); + auto* f32 = create(); auto* s = create(ast::TextureDimension::k2d, f32); GeneratorImpl& gen = Build(); diff --git a/src/tint/writer/msl/generator_impl.cc b/src/tint/writer/msl/generator_impl.cc index 4126fe01a4..7b19a26ae9 100644 --- a/src/tint/writer/msl/generator_impl.cc +++ b/src/tint/writer/msl/generator_impl.cc @@ -33,13 +33,9 @@ #include "src/tint/ast/void.h" #include "src/tint/sem/array.h" #include "src/tint/sem/atomic.h" -#include "src/tint/sem/bool.h" #include "src/tint/sem/call.h" #include "src/tint/sem/constant.h" -#include "src/tint/sem/f16.h" -#include "src/tint/sem/f32.h" #include "src/tint/sem/function.h" -#include "src/tint/sem/i32.h" #include "src/tint/sem/matrix.h" #include "src/tint/sem/member_accessor_expression.h" #include "src/tint/sem/module.h" @@ -49,10 +45,8 @@ #include "src/tint/sem/switch_statement.h" #include "src/tint/sem/type_conversion.h" #include "src/tint/sem/type_initializer.h" -#include "src/tint/sem/u32.h" #include "src/tint/sem/variable.h" #include "src/tint/sem/vector.h" -#include "src/tint/sem/void.h" #include "src/tint/transform/array_length_from_uniform.h" #include "src/tint/transform/builtin_polyfill.h" #include "src/tint/transform/canonicalize_entry_point_io.h" @@ -70,11 +64,17 @@ #include "src/tint/transform/unshadow.h" #include "src/tint/transform/vectorize_scalar_matrix_initializers.h" #include "src/tint/transform/zero_init_workgroup_memory.h" +#include "src/tint/type/bool.h" #include "src/tint/type/depth_multisampled_texture.h" #include "src/tint/type/depth_texture.h" +#include "src/tint/type/f16.h" +#include "src/tint/type/f32.h" +#include "src/tint/type/i32.h" #include "src/tint/type/multisampled_texture.h" #include "src/tint/type/sampled_texture.h" #include "src/tint/type/storage_texture.h" +#include "src/tint/type/u32.h" +#include "src/tint/type/void.h" #include "src/tint/utils/defer.h" #include "src/tint/utils/map.h" #include "src/tint/utils/scoped_assignment.h" @@ -494,18 +494,18 @@ bool GeneratorImpl::EmitBinary(std::ostream& out, const ast::BinaryExpression* e auto signed_type_of = [&](const type::Type* ty) -> const type::Type* { if (ty->is_integer_scalar()) { - return builder_.create(); + return builder_.create(); } else if (auto* v = ty->As()) { - return builder_.create(builder_.create(), v->Width()); + return builder_.create(builder_.create(), v->Width()); } return {}; }; auto unsigned_type_of = [&](const type::Type* ty) -> const type::Type* { if (ty->is_integer_scalar()) { - return builder_.create(); + return builder_.create(); } else if (auto* v = ty->As()) { - return builder_.create(builder_.create(), v->Width()); + return builder_.create(builder_.create(), v->Width()); } return {}; }; @@ -584,7 +584,7 @@ bool GeneratorImpl::EmitBinary(std::ostream& out, const ast::BinaryExpression* e } // Handle '&' and '|' of booleans. - if ((expr->IsAnd() || expr->IsOr()) && lhs_type->Is()) { + if ((expr->IsAnd() || expr->IsOr()) && lhs_type->Is()) { out << "bool"; ScopedParen sp(out); if (!EmitExpression(out, expr->lhs)) { @@ -1612,23 +1612,23 @@ bool GeneratorImpl::EmitContinue(const ast::ContinueStatement*) { bool GeneratorImpl::EmitZeroValue(std::ostream& out, const type::Type* type) { return Switch( type, - [&](const sem::Bool*) { + [&](const type::Bool*) { out << "false"; return true; }, - [&](const sem::F16*) { + [&](const type::F16*) { out << "0.0h"; return true; }, - [&](const sem::F32*) { + [&](const type::F32*) { out << "0.0f"; return true; }, - [&](const sem::I32*) { + [&](const type::I32*) { out << "0"; return true; }, - [&](const sem::U32*) { + [&](const type::U32*) { out << "0u"; return true; }, @@ -1661,23 +1661,23 @@ bool GeneratorImpl::EmitZeroValue(std::ostream& out, const type::Type* type) { bool GeneratorImpl::EmitConstant(std::ostream& out, const sem::Constant* constant) { return Switch( constant->Type(), // - [&](const sem::Bool*) { + [&](const type::Bool*) { out << (constant->As() ? "true" : "false"); return true; }, - [&](const sem::F32*) { + [&](const type::F32*) { PrintF32(out, constant->As()); return true; }, - [&](const sem::F16*) { + [&](const type::F16*) { PrintF16(out, constant->As()); return true; }, - [&](const sem::I32*) { + [&](const type::I32*) { PrintI32(out, constant->As()); return true; }, - [&](const sem::U32*) { + [&](const type::U32*) { out << constant->As() << "u"; return true; }, @@ -2524,11 +2524,11 @@ bool GeneratorImpl::EmitType(std::ostream& out, return Switch( type, [&](const sem::Atomic* atomic) { - if (atomic->Type()->Is()) { + if (atomic->Type()->Is()) { out << "atomic_int"; return true; } - if (atomic->Type()->Is()) { + if (atomic->Type()->Is()) { out << "atomic_uint"; return true; } @@ -2557,19 +2557,19 @@ bool GeneratorImpl::EmitType(std::ostream& out, out << ">"; return true; }, - [&](const sem::Bool*) { + [&](const type::Bool*) { out << "bool"; return true; }, - [&](const sem::F16*) { + [&](const type::F16*) { out << "half"; return true; }, - [&](const sem::F32*) { + [&](const type::F32*) { out << "float"; return true; }, - [&](const sem::I32*) { + [&](const type::I32*) { out << "int"; return true; }, @@ -2695,7 +2695,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, return false; }); }, - [&](const sem::U32*) { + [&](const type::U32*) { out << "uint"; return true; }, @@ -2706,7 +2706,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, out << vec->Width(); return true; }, - [&](const sem::Void*) { + [&](const type::Void*) { out << "void"; return true; }, @@ -3085,16 +3085,16 @@ GeneratorImpl::SizeAndAlign GeneratorImpl::MslPackedTypeSizeAndAlign(const type: // https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf // 2.1 Scalar Data Types - [&](const sem::U32*) { + [&](const type::U32*) { return SizeAndAlign{4, 4}; }, - [&](const sem::I32*) { + [&](const type::I32*) { return SizeAndAlign{4, 4}; }, - [&](const sem::F32*) { + [&](const type::F32*) { return SizeAndAlign{4, 4}; }, - [&](const sem::F16*) { + [&](const type::F16*) { return SizeAndAlign{2, 2}; }, @@ -3102,7 +3102,7 @@ GeneratorImpl::SizeAndAlign GeneratorImpl::MslPackedTypeSizeAndAlign(const type: auto num_els = vec->Width(); auto* el_ty = vec->type(); SizeAndAlign el_size_align = MslPackedTypeSizeAndAlign(el_ty); - if (el_ty->IsAnyOf()) { + if (el_ty->IsAnyOf()) { // Use a packed_vec type for 3-element vectors only. if (num_els == 3) { // https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf @@ -3127,7 +3127,7 @@ GeneratorImpl::SizeAndAlign GeneratorImpl::MslPackedTypeSizeAndAlign(const type: auto rows = mat->rows(); auto* el_ty = mat->type(); // Metal only support half and float matrix. - if (el_ty->IsAnyOf()) { + if (el_ty->IsAnyOf()) { static constexpr SizeAndAlign table_f32[] = { /* float2x2 */ {16, 8}, /* float2x3 */ {32, 16}, @@ -3151,7 +3151,7 @@ GeneratorImpl::SizeAndAlign GeneratorImpl::MslPackedTypeSizeAndAlign(const type: /* half4x4 */ {32, 8}, }; if (cols >= 2 && cols <= 4 && rows >= 2 && rows <= 4) { - if (el_ty->Is()) { + if (el_ty->Is()) { return table_f32[(3 * (cols - 2)) + (rows - 2)]; } else { return table_f16[(3 * (cols - 2)) + (rows - 2)]; diff --git a/src/tint/writer/msl/generator_impl_type_test.cc b/src/tint/writer/msl/generator_impl_type_test.cc index 0ea3bbae6a..c7d62e0e86 100644 --- a/src/tint/writer/msl/generator_impl_type_test.cc +++ b/src/tint/writer/msl/generator_impl_type_test.cc @@ -146,7 +146,7 @@ TEST_F(MslGeneratorImplTest, EmitType_RuntimeArray) { } TEST_F(MslGeneratorImplTest, EmitType_Bool) { - auto* bool_ = create(); + auto* bool_ = create(); GeneratorImpl& gen = Build(); @@ -156,7 +156,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Bool) { } TEST_F(MslGeneratorImplTest, EmitType_F32) { - auto* f32 = create(); + auto* f32 = create(); GeneratorImpl& gen = Build(); @@ -166,7 +166,7 @@ TEST_F(MslGeneratorImplTest, EmitType_F32) { } TEST_F(MslGeneratorImplTest, EmitType_F16) { - auto* f16 = create(); + auto* f16 = create(); GeneratorImpl& gen = Build(); @@ -176,7 +176,7 @@ TEST_F(MslGeneratorImplTest, EmitType_F16) { } TEST_F(MslGeneratorImplTest, EmitType_I32) { - auto* i32 = create(); + auto* i32 = create(); GeneratorImpl& gen = Build(); @@ -186,7 +186,7 @@ TEST_F(MslGeneratorImplTest, EmitType_I32) { } TEST_F(MslGeneratorImplTest, EmitType_Matrix_F32) { - auto* f32 = create(); + auto* f32 = create(); auto* vec3 = create(f32, 3u); auto* mat2x3 = create(vec3, 2u); @@ -198,7 +198,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Matrix_F32) { } TEST_F(MslGeneratorImplTest, EmitType_Matrix_F16) { - auto* f16 = create(); + auto* f16 = create(); auto* vec3 = create(f16, 3u); auto* mat2x3 = create(vec3, 2u); @@ -210,7 +210,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Matrix_F16) { } TEST_F(MslGeneratorImplTest, EmitType_Pointer) { - auto* f32 = create(); + auto* f32 = create(); auto* p = create(f32, ast::AddressSpace::kWorkgroup, ast::Access::kReadWrite); GeneratorImpl& gen = Build(); @@ -699,7 +699,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_WithAttribute) { } TEST_F(MslGeneratorImplTest, EmitType_U32) { - auto* u32 = create(); + auto* u32 = create(); GeneratorImpl& gen = Build(); @@ -709,7 +709,7 @@ TEST_F(MslGeneratorImplTest, EmitType_U32) { } TEST_F(MslGeneratorImplTest, EmitType_Vector) { - auto* f32 = create(); + auto* f32 = create(); auto* vec3 = create(f32, 3u); GeneratorImpl& gen = Build(); @@ -720,7 +720,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Vector) { } TEST_F(MslGeneratorImplTest, EmitType_Void) { - auto* void_ = create(); + auto* void_ = create(); GeneratorImpl& gen = Build(); @@ -803,7 +803,7 @@ using MslSampledtexturesTest = TestParamHelper; TEST_P(MslSampledtexturesTest, Emit) { auto params = GetParam(); - auto* f32 = create(); + auto* f32 = create(); auto* s = create(params.dim, f32); GeneratorImpl& gen = Build(); @@ -825,7 +825,7 @@ INSTANTIATE_TEST_SUITE_P( "texturecube_array"})); TEST_F(MslGeneratorImplTest, Emit_TypeMultisampledTexture) { - auto* u32 = create(); + auto* u32 = create(); auto* ms = create(ast::TextureDimension::k2d, u32); GeneratorImpl& gen = Build(); diff --git a/src/tint/writer/spirv/builder.cc b/src/tint/writer/spirv/builder.cc index caa575ffeb..3b9b1770e5 100644 --- a/src/tint/writer/spirv/builder.cc +++ b/src/tint/writer/spirv/builder.cc @@ -631,7 +631,7 @@ bool Builder::GenerateFunction(const ast::Function* func_ast) { } if (InsideBasicBlock()) { - if (func->ReturnType()->Is()) { + if (func->ReturnType()->Is()) { push_function_inst(spv::Op::OpReturn, {}); } else { auto zero = GenerateConstantNullIfNeeded(func->ReturnType()); @@ -1484,20 +1484,20 @@ uint32_t Builder::GenerateCastOrCopyOrPassthrough(const type::Type* to_type, auto* from_type = TypeOf(from_expr)->UnwrapRef(); spv::Op op = spv::Op::OpNop; - if ((from_type->Is() && to_type->is_float_scalar()) || + if ((from_type->Is() && to_type->is_float_scalar()) || (from_type->is_signed_integer_vector() && to_type->is_float_vector())) { op = spv::Op::OpConvertSToF; - } else if ((from_type->Is() && to_type->is_float_scalar()) || + } else if ((from_type->Is() && to_type->is_float_scalar()) || (from_type->is_unsigned_integer_vector() && to_type->is_float_vector())) { op = spv::Op::OpConvertUToF; - } else if ((from_type->is_float_scalar() && to_type->Is()) || + } else if ((from_type->is_float_scalar() && to_type->Is()) || (from_type->is_float_vector() && to_type->is_signed_integer_vector())) { op = spv::Op::OpConvertFToS; - } else if ((from_type->is_float_scalar() && to_type->Is()) || + } else if ((from_type->is_float_scalar() && to_type->Is()) || (from_type->is_float_vector() && to_type->is_unsigned_integer_vector())) { op = spv::Op::OpConvertFToU; - } else if (from_type - ->IsAnyOf() && + } else if (from_type->IsAnyOf() && from_type == to_type) { // Identity initializer for scalar and vector types return val_id; @@ -1509,13 +1509,13 @@ uint32_t Builder::GenerateCastOrCopyOrPassthrough(const type::Type* to_type, // and to_type being the same floating point scalar or vector type, i.e. identity // initializer, is already handled in the previous else-if clause. op = spv::Op::OpFConvert; - } else if ((from_type->Is() && to_type->Is()) || - (from_type->Is() && to_type->Is()) || + } else if ((from_type->Is() && to_type->Is()) || + (from_type->Is() && to_type->Is()) || (from_type->is_signed_integer_vector() && to_type->is_unsigned_integer_vector()) || (from_type->is_unsigned_integer_vector() && to_type->is_integer_scalar_or_vector())) { op = spv::Op::OpBitcast; - } else if ((from_type->is_numeric_scalar() && to_type->Is()) || + } else if ((from_type->is_numeric_scalar() && to_type->Is()) || (from_type->is_numeric_vector() && to_type->is_bool_vector())) { // Convert scalar (vector) to bool (vector) @@ -1536,16 +1536,16 @@ uint32_t Builder::GenerateCastOrCopyOrPassthrough(const type::Type* to_type, const auto* to_elem_type = elem_type_of(to_type); uint32_t one_id; uint32_t zero_id; - if (to_elem_type->Is()) { + if (to_elem_type->Is()) { zero_id = GenerateConstantIfNeeded(ScalarConstant::F32(0)); one_id = GenerateConstantIfNeeded(ScalarConstant::F32(1)); - } else if (to_elem_type->Is()) { + } else if (to_elem_type->Is()) { zero_id = GenerateConstantIfNeeded(ScalarConstant::F16(0)); one_id = GenerateConstantIfNeeded(ScalarConstant::F16(1)); - } else if (to_elem_type->Is()) { + } else if (to_elem_type->Is()) { zero_id = GenerateConstantIfNeeded(ScalarConstant::U32(0)); one_id = GenerateConstantIfNeeded(ScalarConstant::U32(1)); - } else if (to_elem_type->Is()) { + } else if (to_elem_type->Is()) { zero_id = GenerateConstantIfNeeded(ScalarConstant::I32(0)); one_id = GenerateConstantIfNeeded(ScalarConstant::I32(1)); } else { @@ -1680,23 +1680,23 @@ uint32_t Builder::GenerateConstantIfNeeded(const sem::Constant* constant) { return Switch( ty, // - [&](const sem::Bool*) { + [&](const type::Bool*) { bool val = constant->As(); return GenerateConstantIfNeeded(ScalarConstant::Bool(val)); }, - [&](const sem::F32*) { + [&](const type::F32*) { auto val = constant->As(); return GenerateConstantIfNeeded(ScalarConstant::F32(val.value)); }, - [&](const sem::F16*) { + [&](const type::F16*) { auto val = constant->As(); return GenerateConstantIfNeeded(ScalarConstant::F16(val.value)); }, - [&](const sem::I32*) { + [&](const type::I32*) { auto val = constant->As(); return GenerateConstantIfNeeded(ScalarConstant::I32(val.value)); }, - [&](const sem::U32*) { + [&](const type::U32*) { auto val = constant->As(); return GenerateConstantIfNeeded(ScalarConstant::U32(val.value)); }, @@ -1727,23 +1727,23 @@ uint32_t Builder::GenerateConstantIfNeeded(const ScalarConstant& constant) { switch (constant.kind) { case ScalarConstant::Kind::kU32: { - type_id = GenerateTypeIfNeeded(builder_.create()); + type_id = GenerateTypeIfNeeded(builder_.create()); break; } case ScalarConstant::Kind::kI32: { - type_id = GenerateTypeIfNeeded(builder_.create()); + type_id = GenerateTypeIfNeeded(builder_.create()); break; } case ScalarConstant::Kind::kF32: { - type_id = GenerateTypeIfNeeded(builder_.create()); + type_id = GenerateTypeIfNeeded(builder_.create()); break; } case ScalarConstant::Kind::kF16: { - type_id = GenerateTypeIfNeeded(builder_.create()); + type_id = GenerateTypeIfNeeded(builder_.create()); break; } case ScalarConstant::Kind::kBool: { - type_id = GenerateTypeIfNeeded(builder_.create()); + type_id = GenerateTypeIfNeeded(builder_.create()); break; } } @@ -2349,14 +2349,14 @@ uint32_t Builder::GenerateBuiltinCall(const sem::Call* call, const sem::Builtin* switch (builtin->Type()) { case BuiltinType::kAny: - if (builtin->Parameters()[0]->Type()->Is()) { + if (builtin->Parameters()[0]->Type()->Is()) { // any(v: bool) just resolves to v. return get_arg_as_value_id(0); } op = spv::Op::OpAny; break; case BuiltinType::kAll: - if (builtin->Parameters()[0]->Type()->Is()) { + if (builtin->Parameters()[0]->Type()->Is()) { // all(v: bool) just resolves to v. return get_arg_as_value_id(0); } @@ -2525,7 +2525,7 @@ uint32_t Builder::GenerateBuiltinCall(const sem::Call* call, const sem::Builtin* // TODO(jrprice): If we're targeting SPIR-V 1.4, we don't need to do this. auto* result_vector_type = builtin->ReturnType()->As(); if (result_vector_type && builtin->Parameters()[2]->Type()->is_scalar()) { - auto* bool_vec_ty = builder_.create(builder_.create(), + auto* bool_vec_ty = builder_.create(builder_.create(), result_vector_type->Width()); if (!GenerateTypeIfNeeded(bool_vec_ty)) { return 0; @@ -2686,7 +2686,7 @@ bool Builder::GenerateTextureBuiltin(const sem::Call* call, // to calling append_result_type_and_id_to_spirv_params(). auto append_result_type_and_id_to_spirv_params_for_read = [&]() { if (texture_type->IsAnyOf()) { - auto* f32 = builder_.create(); + auto* f32 = builder_.create(); auto* spirv_result_type = builder_.create(f32, 4u); auto spirv_result = result_op(); post_emission = [=] { @@ -2940,10 +2940,10 @@ bool Builder::GenerateTextureBuiltin(const sem::Call* call, return false; } auto level = Operand(0u); - if (arg(Usage::kLevel)->Type()->UnwrapRef()->IsAnyOf()) { + if (arg(Usage::kLevel)->Type()->UnwrapRef()->IsAnyOf()) { // Depth textures have i32 or u32 parameters for the level, but SPIR-V expects f32. // Cast. - auto f32_type_id = GenerateTypeIfNeeded(builder_.create()); + auto f32_type_id = GenerateTypeIfNeeded(builder_.create()); if (f32_type_id == 0) { return 0; } @@ -3068,7 +3068,7 @@ bool Builder::GenerateAtomicBuiltin(const sem::Call* call, const sem::Builtin* builtin, Operand result_type, Operand result_id) { - auto is_value_signed = [&] { return builtin->Parameters()[1]->Type()->Is(); }; + auto is_value_signed = [&] { return builtin->Parameters()[1]->Type()->Is(); }; auto address_space = builtin->Parameters()[0]->Type()->As()->AddressSpace(); @@ -3219,7 +3219,7 @@ bool Builder::GenerateAtomicBuiltin(const sem::Call* call, return false; } - auto* bool_sem_ty = builder_.create(); + auto* bool_sem_ty = builder_.create(); auto bool_type = GenerateTypeIfNeeded(bool_sem_ty); if (bool_type == 0) { return false; @@ -3282,7 +3282,7 @@ uint32_t Builder::GenerateSampledImage(const type::Type* texture_type, // Using anything other than 0 is problematic on various Vulkan drivers. if (auto* depthTextureType = texture_type->As()) { texture_type = builder_.create(depthTextureType->dim(), - builder_.create()); + builder_.create()); } uint32_t sampled_image_type_id = @@ -3647,10 +3647,10 @@ uint32_t Builder::GenerateTypeIfNeeded(const type::Type* type) { // Using anything other than 0 is problematic on various Vulkan drivers. if (auto* depthTextureType = type->As()) { type = builder_.create(depthTextureType->dim(), - builder_.create()); + builder_.create()); } else if (auto* multisampledDepthTextureType = type->As()) { type = builder_.create(multisampledDepthTextureType->dim(), - builder_.create()); + builder_.create()); } // Pointers and references with differing accesses should not result in a @@ -3676,19 +3676,19 @@ uint32_t Builder::GenerateTypeIfNeeded(const type::Type* type) { [&](const sem::Array* arr) { // return GenerateArrayType(arr, result); }, - [&](const sem::Bool*) { + [&](const type::Bool*) { push_type(spv::Op::OpTypeBool, {result}); return true; }, - [&](const sem::F32*) { + [&](const type::F32*) { push_type(spv::Op::OpTypeFloat, {result, Operand(32u)}); return true; }, - [&](const sem::F16*) { + [&](const type::F16*) { push_type(spv::Op::OpTypeFloat, {result, Operand(16u)}); return true; }, - [&](const sem::I32*) { + [&](const type::I32*) { push_type(spv::Op::OpTypeInt, {result, Operand(32u), Operand(1u)}); return true; }, @@ -3704,14 +3704,14 @@ uint32_t Builder::GenerateTypeIfNeeded(const type::Type* type) { [&](const sem::Struct* str) { // return GenerateStructType(str, result); }, - [&](const sem::U32*) { + [&](const type::U32*) { push_type(spv::Op::OpTypeInt, {result, Operand(32u), Operand(0u)}); return true; }, [&](const sem::Vector* vec) { // return GenerateVectorType(vec, result); }, - [&](const sem::Void*) { + [&](const type::Void*) { push_type(spv::Op::OpTypeVoid, {result}); return true; }, @@ -3812,10 +3812,10 @@ bool Builder::GenerateTextureType(const type::Texture* texture, const Operand& r uint32_t type_id = Switch( texture, [&](const type::DepthTexture*) { - return GenerateTypeIfNeeded(builder_.create()); + return GenerateTypeIfNeeded(builder_.create()); }, [&](const type::DepthMultisampledTexture*) { - return GenerateTypeIfNeeded(builder_.create()); + return GenerateTypeIfNeeded(builder_.create()); }, [&](const type::SampledTexture* t) { return GenerateTypeIfNeeded(t->type()); }, [&](const type::MultisampledTexture* t) { return GenerateTypeIfNeeded(t->type()); }, diff --git a/src/tint/writer/spirv/builder_entry_point_test.cc b/src/tint/writer/spirv/builder_entry_point_test.cc index 4cdebf2ba8..3527ea97e0 100644 --- a/src/tint/writer/spirv/builder_entry_point_test.cc +++ b/src/tint/writer/spirv/builder_entry_point_test.cc @@ -23,8 +23,8 @@ #include "src/tint/ast/stage_attribute.h" #include "src/tint/ast/variable.h" #include "src/tint/program.h" -#include "src/tint/sem/f32.h" #include "src/tint/sem/vector.h" +#include "src/tint/type/f32.h" #include "src/tint/writer/spirv/builder.h" #include "src/tint/writer/spirv/spv_dump.h" #include "src/tint/writer/spirv/test_helper.h" diff --git a/src/tint/writer/spirv/builder_type_test.cc b/src/tint/writer/spirv/builder_type_test.cc index 74d6cbc216..ca0aa474cf 100644 --- a/src/tint/writer/spirv/builder_type_test.cc +++ b/src/tint/writer/spirv/builder_type_test.cc @@ -114,7 +114,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedArray) { } TEST_F(BuilderTest_Type, GenerateBool) { - auto* bool_ = create(); + auto* bool_ = create(); spirv::Builder& b = Build(); @@ -128,8 +128,8 @@ TEST_F(BuilderTest_Type, GenerateBool) { } TEST_F(BuilderTest_Type, ReturnsGeneratedBool) { - auto* bool_ = create(); - auto* i32 = create(); + auto* bool_ = create(); + auto* i32 = create(); spirv::Builder& b = Build(); @@ -142,7 +142,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedBool) { } TEST_F(BuilderTest_Type, GenerateF32) { - auto* f32 = create(); + auto* f32 = create(); spirv::Builder& b = Build(); @@ -156,8 +156,8 @@ TEST_F(BuilderTest_Type, GenerateF32) { } TEST_F(BuilderTest_Type, ReturnsGeneratedF32) { - auto* f32 = create(); - auto* i32 = create(); + auto* f32 = create(); + auto* i32 = create(); spirv::Builder& b = Build(); @@ -170,7 +170,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedF32) { } TEST_F(BuilderTest_Type, GenerateF16) { - auto* f16 = create(); + auto* f16 = create(); spirv::Builder& b = Build(); @@ -184,8 +184,8 @@ TEST_F(BuilderTest_Type, GenerateF16) { } TEST_F(BuilderTest_Type, ReturnsGeneratedF16) { - auto* f16 = create(); - auto* i32 = create(); + auto* f16 = create(); + auto* i32 = create(); spirv::Builder& b = Build(); @@ -198,7 +198,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedF16) { } TEST_F(BuilderTest_Type, GenerateI32) { - auto* i32 = create(); + auto* i32 = create(); spirv::Builder& b = Build(); @@ -212,8 +212,8 @@ TEST_F(BuilderTest_Type, GenerateI32) { } TEST_F(BuilderTest_Type, ReturnsGeneratedI32) { - auto* f32 = create(); - auto* i32 = create(); + auto* f32 = create(); + auto* i32 = create(); spirv::Builder& b = Build(); @@ -226,7 +226,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedI32) { } TEST_F(BuilderTest_Type, GenerateMatrix) { - auto* f32 = create(); + auto* f32 = create(); auto* vec3 = create(f32, 3u); auto* mat2x3 = create(vec3, 2u); @@ -244,7 +244,7 @@ TEST_F(BuilderTest_Type, GenerateMatrix) { } TEST_F(BuilderTest_Type, ReturnsGeneratedMatrix) { - auto* i32 = create(); + auto* i32 = create(); auto* col = create(i32, 4u); auto* mat = create(col, 3u); @@ -259,7 +259,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedMatrix) { } TEST_F(BuilderTest_Type, GenerateF16Matrix) { - auto* f16 = create(); + auto* f16 = create(); auto* vec3 = create(f16, 3u); auto* mat2x3 = create(vec3, 2u); @@ -277,7 +277,7 @@ TEST_F(BuilderTest_Type, GenerateF16Matrix) { } TEST_F(BuilderTest_Type, ReturnsGeneratedF16Matrix) { - auto* f16 = create(); + auto* f16 = create(); auto* col = create(f16, 4u); auto* mat = create(col, 3u); @@ -292,7 +292,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedF16Matrix) { } TEST_F(BuilderTest_Type, GeneratePtr) { - auto* i32 = create(); + auto* i32 = create(); auto* ptr = create(i32, ast::AddressSpace::kOut, ast::Access::kReadWrite); spirv::Builder& b = Build(); @@ -307,7 +307,7 @@ TEST_F(BuilderTest_Type, GeneratePtr) { } TEST_F(BuilderTest_Type, ReturnsGeneratedPtr) { - auto* i32 = create(); + auto* i32 = create(); auto* ptr = create(i32, ast::AddressSpace::kOut, ast::Access::kReadWrite); spirv::Builder& b = Build(); @@ -517,7 +517,7 @@ OpDecorate %21 ArrayStride 64 } TEST_F(BuilderTest_Type, GenerateU32) { - auto* u32 = create(); + auto* u32 = create(); spirv::Builder& b = Build(); @@ -531,8 +531,8 @@ TEST_F(BuilderTest_Type, GenerateU32) { } TEST_F(BuilderTest_Type, ReturnsGeneratedU32) { - auto* u32 = create(); - auto* f32 = create(); + auto* u32 = create(); + auto* f32 = create(); spirv::Builder& b = Build(); @@ -545,7 +545,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedU32) { } TEST_F(BuilderTest_Type, GenerateVector) { - auto* vec = create(create(), 3u); + auto* vec = create(create(), 3u); spirv::Builder& b = Build(); @@ -560,7 +560,7 @@ TEST_F(BuilderTest_Type, GenerateVector) { } TEST_F(BuilderTest_Type, ReturnsGeneratedVector) { - auto* i32 = create(); + auto* i32 = create(); auto* vec = create(i32, 3u); spirv::Builder& b = Build(); @@ -574,7 +574,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedVector) { } TEST_F(BuilderTest_Type, GenerateVoid) { - auto* void_ = create(); + auto* void_ = create(); spirv::Builder& b = Build(); @@ -588,8 +588,8 @@ TEST_F(BuilderTest_Type, GenerateVoid) { } TEST_F(BuilderTest_Type, ReturnsGeneratedVoid) { - auto* void_ = create(); - auto* i32 = create(); + auto* void_ = create(); + auto* i32 = create(); spirv::Builder& b = Build(); @@ -691,7 +691,7 @@ TEST_F(BuilderTest_Type, DepthTexture_Generate_CubeArray) { } TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_i32) { - auto* i32 = create(); + auto* i32 = create(); auto* ms = create(ast::TextureDimension::k2d, i32); spirv::Builder& b = Build(); @@ -704,7 +704,7 @@ TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_i32) { } TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_u32) { - auto* u32 = create(); + auto* u32 = create(); auto* ms = create(ast::TextureDimension::k2d, u32); spirv::Builder& b = Build(); @@ -718,7 +718,7 @@ TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_u32) { } TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_f32) { - auto* f32 = create(); + auto* f32 = create(); auto* ms = create(ast::TextureDimension::k2d, f32); spirv::Builder& b = Build(); @@ -732,7 +732,7 @@ TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_f32) { } TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_i32) { - auto* s = create(ast::TextureDimension::k1d, create()); + auto* s = create(ast::TextureDimension::k1d, create()); spirv::Builder& b = Build(); @@ -749,7 +749,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_i32) { } TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_u32) { - auto* u32 = create(); + auto* u32 = create(); auto* s = create(ast::TextureDimension::k1d, u32); spirv::Builder& b = Build(); @@ -767,7 +767,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_u32) { } TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_f32) { - auto* f32 = create(); + auto* f32 = create(); auto* s = create(ast::TextureDimension::k1d, f32); spirv::Builder& b = Build(); @@ -785,7 +785,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_f32) { } TEST_F(BuilderTest_Type, SampledTexture_Generate_2d) { - auto* f32 = create(); + auto* f32 = create(); auto* s = create(ast::TextureDimension::k2d, f32); spirv::Builder& b = Build(); @@ -799,7 +799,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_2d) { } TEST_F(BuilderTest_Type, SampledTexture_Generate_2d_array) { - auto* f32 = create(); + auto* f32 = create(); auto* s = create(ast::TextureDimension::k2dArray, f32); spirv::Builder& b = Build(); @@ -813,7 +813,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_2d_array) { } TEST_F(BuilderTest_Type, SampledTexture_Generate_3d) { - auto* f32 = create(); + auto* f32 = create(); auto* s = create(ast::TextureDimension::k3d, f32); spirv::Builder& b = Build(); @@ -827,7 +827,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_3d) { } TEST_F(BuilderTest_Type, SampledTexture_Generate_Cube) { - auto* f32 = create(); + auto* f32 = create(); auto* s = create(ast::TextureDimension::kCube, f32); spirv::Builder& b = Build(); @@ -842,7 +842,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_Cube) { } TEST_F(BuilderTest_Type, SampledTexture_Generate_CubeArray) { - auto* f32 = create(); + auto* f32 = create(); auto* s = create(ast::TextureDimension::kCubeArray, f32); spirv::Builder& b = Build();