diff --git a/src/intrinsic_table_test.cc b/src/intrinsic_table_test.cc index 8065f030e7..b84f1abe44 100644 --- a/src/intrinsic_table_test.cc +++ b/src/intrinsic_table_test.cc @@ -53,13 +53,14 @@ TEST_F(IntrinsicTableTest, MismatchF32) { } TEST_F(IntrinsicTableTest, MatchU32) { - auto result = table->Lookup(*this, IntrinsicType::kUnpack2x16Float, - {ty.u32()}, Source{}); + auto* u32 = create(); + auto result = + table->Lookup(*this, IntrinsicType::kUnpack2x16Float, {u32}, Source{}); ASSERT_NE(result.intrinsic, nullptr); ASSERT_EQ(result.diagnostics.str(), ""); EXPECT_THAT(result.intrinsic->Type(), IntrinsicType::kUnpack2x16Float); EXPECT_THAT(result.intrinsic->ReturnType(), ty.vec2()); - EXPECT_THAT(result.intrinsic->Parameters(), ElementsAre(Parameter{ty.u32()})); + EXPECT_THAT(result.intrinsic->Parameters(), ElementsAre(Parameter{u32})); } TEST_F(IntrinsicTableTest, MismatchU32) { @@ -102,13 +103,14 @@ TEST_F(IntrinsicTableTest, MatchIU32AsI32) { } TEST_F(IntrinsicTableTest, MatchIU32AsU32) { + auto* u32 = create(); auto result = - table->Lookup(*this, IntrinsicType::kCountOneBits, {ty.u32()}, Source{}); + table->Lookup(*this, IntrinsicType::kCountOneBits, {u32}, Source{}); ASSERT_NE(result.intrinsic, nullptr); ASSERT_EQ(result.diagnostics.str(), ""); EXPECT_THAT(result.intrinsic->Type(), IntrinsicType::kCountOneBits); - EXPECT_THAT(result.intrinsic->ReturnType(), ty.u32()); - EXPECT_THAT(result.intrinsic->Parameters(), ElementsAre(Parameter{ty.u32()})); + EXPECT_THAT(result.intrinsic->ReturnType(), u32); + EXPECT_THAT(result.intrinsic->Parameters(), ElementsAre(Parameter{u32})); } TEST_F(IntrinsicTableTest, MismatchIU32) { @@ -131,15 +133,15 @@ TEST_F(IntrinsicTableTest, MatchFIU32AsI32) { } TEST_F(IntrinsicTableTest, MatchFIU32AsU32) { - auto result = table->Lookup(*this, IntrinsicType::kClamp, - {ty.u32(), ty.u32(), ty.u32()}, Source{}); + auto* u32 = create(); + auto result = + table->Lookup(*this, IntrinsicType::kClamp, {u32, u32, u32}, Source{}); ASSERT_NE(result.intrinsic, nullptr); ASSERT_EQ(result.diagnostics.str(), ""); EXPECT_THAT(result.intrinsic->Type(), IntrinsicType::kClamp); - EXPECT_THAT(result.intrinsic->ReturnType(), ty.u32()); + EXPECT_THAT(result.intrinsic->ReturnType(), u32); EXPECT_THAT(result.intrinsic->Parameters(), - ElementsAre(Parameter{ty.u32()}, Parameter{ty.u32()}, - Parameter{ty.u32()})); + ElementsAre(Parameter{u32}, Parameter{u32}, Parameter{u32})); } TEST_F(IntrinsicTableTest, MatchFIU32AsF32) { @@ -208,7 +210,7 @@ TEST_F(IntrinsicTableTest, MatchArray) { ASSERT_NE(result.intrinsic, nullptr); ASSERT_EQ(result.diagnostics.str(), ""); EXPECT_THAT(result.intrinsic->Type(), IntrinsicType::kArrayLength); - EXPECT_THAT(result.intrinsic->ReturnType(), ty.u32()); + EXPECT_TRUE(result.intrinsic->ReturnType()->Is()); ASSERT_EQ(result.intrinsic->Parameters().size(), 1u); EXPECT_TRUE(result.intrinsic->Parameters()[0].type->Is()); } @@ -371,8 +373,9 @@ TEST_F(IntrinsicTableTest, MatchOpenType) { } TEST_F(IntrinsicTableTest, MismatchOpenType) { + auto* u32 = create(); auto result = table->Lookup(*this, IntrinsicType::kClamp, - {ty.f32(), ty.u32(), ty.f32()}, Source{}); + {ty.f32(), u32, ty.f32()}, Source{}); ASSERT_EQ(result.intrinsic, nullptr); ASSERT_THAT(result.diagnostics.str(), HasSubstr("no matching call")); } @@ -391,9 +394,9 @@ TEST_F(IntrinsicTableTest, MatchOpenSizeVector) { } TEST_F(IntrinsicTableTest, MismatchOpenSizeVector) { - auto result = - table->Lookup(*this, IntrinsicType::kClamp, - {ty.vec2(), ty.vec2(), ty.vec2()}, Source{}); + auto* u32 = create(); + auto result = table->Lookup(*this, IntrinsicType::kClamp, + {ty.vec2(), u32, ty.vec2()}, Source{}); ASSERT_EQ(result.intrinsic, nullptr); ASSERT_THAT(result.diagnostics.str(), HasSubstr("no matching call")); } diff --git a/src/program_builder.h b/src/program_builder.h index 05acee4359..dddf340f89 100644 --- a/src/program_builder.h +++ b/src/program_builder.h @@ -388,14 +388,12 @@ class ProgramBuilder { } /// @returns a u32 type - typ::U32 u32() const { - return {builder->create(), builder->create()}; - } + typ::U32 u32() const { return builder->create(); } /// @param source the Source of the node /// @returns a u32 type typ::U32 u32(const Source& source) const { - return {builder->create(source), builder->create()}; + return builder->create(source); } /// @returns a void type diff --git a/src/resolver/is_host_shareable_test.cc b/src/resolver/is_host_shareable_test.cc index fef601b9fc..9a434efeb5 100644 --- a/src/resolver/is_host_shareable_test.cc +++ b/src/resolver/is_host_shareable_test.cc @@ -33,7 +33,7 @@ TEST_F(ResolverIsHostShareable, Bool) { TEST_F(ResolverIsHostShareable, NumericScalar) { EXPECT_TRUE(r()->IsHostShareable(ty.i32())); - EXPECT_TRUE(r()->IsHostShareable(ty.u32())); + EXPECT_TRUE(r()->IsHostShareable(create())); EXPECT_TRUE(r()->IsHostShareable(ty.f32())); } @@ -41,9 +41,9 @@ TEST_F(ResolverIsHostShareable, NumericVector) { EXPECT_TRUE(r()->IsHostShareable(ty.vec2())); EXPECT_TRUE(r()->IsHostShareable(ty.vec3())); EXPECT_TRUE(r()->IsHostShareable(ty.vec4())); - EXPECT_TRUE(r()->IsHostShareable(ty.vec2())); - EXPECT_TRUE(r()->IsHostShareable(ty.vec3())); - EXPECT_TRUE(r()->IsHostShareable(ty.vec4())); + EXPECT_TRUE(r()->IsHostShareable(create(create(), 2))); + EXPECT_TRUE(r()->IsHostShareable(create(create(), 3))); + EXPECT_TRUE(r()->IsHostShareable(create(create(), 4))); EXPECT_TRUE(r()->IsHostShareable(ty.vec2())); EXPECT_TRUE(r()->IsHostShareable(ty.vec3())); EXPECT_TRUE(r()->IsHostShareable(ty.vec4())); diff --git a/src/resolver/is_storeable_test.cc b/src/resolver/is_storeable_test.cc index 2b79ce49be..9b25f82f34 100644 --- a/src/resolver/is_storeable_test.cc +++ b/src/resolver/is_storeable_test.cc @@ -30,7 +30,7 @@ TEST_F(ResolverIsStorableTest, Void) { TEST_F(ResolverIsStorableTest, Scalar) { EXPECT_TRUE(r()->IsStorable(ty.bool_())); EXPECT_TRUE(r()->IsStorable(ty.i32())); - EXPECT_TRUE(r()->IsStorable(ty.u32())); + EXPECT_TRUE(r()->IsStorable(create())); EXPECT_TRUE(r()->IsStorable(ty.f32())); } @@ -38,9 +38,9 @@ TEST_F(ResolverIsStorableTest, Vector) { EXPECT_TRUE(r()->IsStorable(ty.vec2())); EXPECT_TRUE(r()->IsStorable(ty.vec3())); EXPECT_TRUE(r()->IsStorable(ty.vec4())); - EXPECT_TRUE(r()->IsStorable(ty.vec2())); - EXPECT_TRUE(r()->IsStorable(ty.vec3())); - EXPECT_TRUE(r()->IsStorable(ty.vec4())); + EXPECT_TRUE(r()->IsStorable(create(create(), 2))); + EXPECT_TRUE(r()->IsStorable(create(create(), 3))); + EXPECT_TRUE(r()->IsStorable(create(create(), 4))); EXPECT_TRUE(r()->IsStorable(ty.vec2())); EXPECT_TRUE(r()->IsStorable(ty.vec3())); EXPECT_TRUE(r()->IsStorable(ty.vec4())); diff --git a/src/resolver/resolver_test.cc b/src/resolver/resolver_test.cc index 41e15e29f5..8d7a6105b7 100644 --- a/src/resolver/resolver_test.cc +++ b/src/resolver/resolver_test.cc @@ -761,7 +761,7 @@ TEST_F(ResolverTest, Function_Parameters) { EXPECT_EQ(func_sem->Parameters().size(), 3u); EXPECT_EQ(func_sem->Parameters()[0]->Type(), ty.f32()); EXPECT_EQ(func_sem->Parameters()[1]->Type(), ty.i32()); - EXPECT_EQ(func_sem->Parameters()[2]->Type(), ty.u32()); + 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); diff --git a/src/typepair.h b/src/typepair.h index bcbf4c6d57..efe8acdac7 100644 --- a/src/typepair.h +++ b/src/typepair.h @@ -252,10 +252,11 @@ using SampledTexture = TypePair; using StorageTexture = TypePair; using Struct = TypePair; using Texture = TypePair; -using U32 = TypePair; using Vector = TypePair; using Void = TypePair; +using U32 = Ptr; + // Helpers /// Makes a type pair, deducing the return type from input args diff --git a/src/writer/hlsl/generator_impl_type_test.cc b/src/writer/hlsl/generator_impl_type_test.cc index 288b6049c1..4994859e2a 100644 --- a/src/writer/hlsl/generator_impl_type_test.cc +++ b/src/writer/hlsl/generator_impl_type_test.cc @@ -282,7 +282,7 @@ TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_Struct_WithDecoration) { } TEST_F(HlslGeneratorImplTest_Type, EmitType_U32) { - auto u32 = ty.u32(); + auto* u32 = create(); GeneratorImpl& gen = Build(); diff --git a/src/writer/wgsl/generator_impl_type_test.cc b/src/writer/wgsl/generator_impl_type_test.cc index f0005c1706..cdd291e370 100644 --- a/src/writer/wgsl/generator_impl_type_test.cc +++ b/src/writer/wgsl/generator_impl_type_test.cc @@ -276,7 +276,6 @@ struct S { TEST_F(WgslGeneratorImplTest, EmitType_U32) { auto u32 = ty.u32(); - AST().AddConstructedType(ty.alias("make_type_reachable", u32)); GeneratorImpl& gen = Build();