diff --git a/src/ast/access_control.cc b/src/ast/access_control.cc index ce0d619277..9a70a6435d 100644 --- a/src/ast/access_control.cc +++ b/src/ast/access_control.cc @@ -19,15 +19,15 @@ namespace ast { std::ostream& operator<<(std::ostream& out, AccessControl access) { switch (access) { - case AccessControl::kReadOnly: { + case ast::AccessControl::kReadOnly: { out << "read_only"; break; } - case AccessControl::kReadWrite: { + case ast::AccessControl::kReadWrite: { out << "read_write"; break; } - case AccessControl::kWriteOnly: { + case ast::AccessControl::kWriteOnly: { out << "write_only"; break; } diff --git a/src/ast/access_decoration.h b/src/ast/access_decoration.h index 37a400eb06..8e45062412 100644 --- a/src/ast/access_decoration.h +++ b/src/ast/access_decoration.h @@ -41,7 +41,7 @@ class AccessDecoration : public Castable { void to_str(std::ostream& out, size_t indent) const override; private: - AccessControl value_ = AccessControl::kReadWrite; + AccessControl value_ = ast::AccessControl::kReadWrite; }; } // namespace ast diff --git a/src/ast/access_decoration_test.cc b/src/ast/access_decoration_test.cc index 4a15fa469e..36c030dfaf 100644 --- a/src/ast/access_decoration_test.cc +++ b/src/ast/access_decoration_test.cc @@ -25,17 +25,17 @@ namespace { using AccessDecorationTest = TestHelper; TEST_F(AccessDecorationTest, Creation) { - AccessDecoration d{AccessControl::kWriteOnly, Source{}}; - EXPECT_EQ(AccessControl::kWriteOnly, d.value()); + AccessDecoration d{ast::AccessControl::kWriteOnly, Source{}}; + EXPECT_EQ(ast::AccessControl::kWriteOnly, d.value()); } TEST_F(AccessDecorationTest, Is) { - AccessDecoration d{AccessControl::kReadWrite, Source{}}; + AccessDecoration d{ast::AccessControl::kReadWrite, Source{}}; EXPECT_FALSE(d.IsAccess()); } TEST_F(AccessDecorationTest, ToStr) { - AccessDecoration d{AccessControl::kReadOnly, Source{}}; + AccessDecoration d{ast::AccessControl::kReadOnly, Source{}}; std::ostringstream out; d.to_str(out, 0); EXPECT_EQ(out.str(), R"(AccessDecoration{read} diff --git a/src/ast/bitcast_expression_test.cc b/src/ast/bitcast_expression_test.cc index a07eee71d5..51d48c9a31 100644 --- a/src/ast/bitcast_expression_test.cc +++ b/src/ast/bitcast_expression_test.cc @@ -25,7 +25,7 @@ namespace { using BitcastExpressionTest = TestHelper; TEST_F(BitcastExpressionTest, Create) { - type::F32Type f32; + type::F32 f32; auto* expr = create("expr"); BitcastExpression exp(&f32, expr); @@ -34,7 +34,7 @@ TEST_F(BitcastExpressionTest, Create) { } TEST_F(BitcastExpressionTest, CreateWithSource) { - type::F32Type f32; + type::F32 f32; auto* expr = create("expr"); BitcastExpression exp(Source{Source::Location{20, 2}}, &f32, expr); @@ -49,7 +49,7 @@ TEST_F(BitcastExpressionTest, IsBitcast) { } TEST_F(BitcastExpressionTest, IsValid) { - type::F32Type f32; + type::F32 f32; auto* expr = create("expr"); BitcastExpression exp(&f32, expr); @@ -65,7 +65,7 @@ TEST_F(BitcastExpressionTest, IsValid_MissingType) { } TEST_F(BitcastExpressionTest, IsValid_MissingExpr) { - type::F32Type f32; + type::F32 f32; BitcastExpression exp; exp.set_type(&f32); @@ -73,14 +73,14 @@ TEST_F(BitcastExpressionTest, IsValid_MissingExpr) { } TEST_F(BitcastExpressionTest, IsValid_InvalidExpr) { - type::F32Type f32; + type::F32 f32; auto* expr = create(""); BitcastExpression e(&f32, expr); EXPECT_FALSE(e.IsValid()); } TEST_F(BitcastExpressionTest, ToStr) { - type::F32Type f32; + type::F32 f32; auto* expr = create("expr"); BitcastExpression exp(&f32, expr); diff --git a/src/ast/bool_literal_test.cc b/src/ast/bool_literal_test.cc index ca2ff785bf..186d71e7a2 100644 --- a/src/ast/bool_literal_test.cc +++ b/src/ast/bool_literal_test.cc @@ -28,7 +28,7 @@ namespace { using BoolLiteralTest = TestHelper; TEST_F(BoolLiteralTest, True) { - type::BoolType bool_type; + type::Bool bool_type; BoolLiteral b{&bool_type, true}; ASSERT_TRUE(b.Is()); ASSERT_TRUE(b.IsTrue()); @@ -36,7 +36,7 @@ TEST_F(BoolLiteralTest, True) { } TEST_F(BoolLiteralTest, False) { - type::BoolType bool_type; + type::Bool bool_type; BoolLiteral b{&bool_type, false}; ASSERT_TRUE(b.Is()); ASSERT_FALSE(b.IsTrue()); @@ -44,7 +44,7 @@ TEST_F(BoolLiteralTest, False) { } TEST_F(BoolLiteralTest, Is) { - type::BoolType bool_type; + type::Bool bool_type; BoolLiteral b{&bool_type, false}; Literal* l = &b; EXPECT_TRUE(l->Is()); @@ -56,7 +56,7 @@ TEST_F(BoolLiteralTest, Is) { } TEST_F(BoolLiteralTest, ToStr) { - type::BoolType bool_type; + type::Bool bool_type; BoolLiteral t{&bool_type, true}; BoolLiteral f{&bool_type, false}; diff --git a/src/ast/builder.cc b/src/ast/builder.cc index eca0c04d0a..cdc683530c 100644 --- a/src/ast/builder.cc +++ b/src/ast/builder.cc @@ -18,11 +18,11 @@ namespace tint { namespace ast { TypesBuilder::TypesBuilder(Module* mod) - : bool_(mod->create()), - f32(mod->create()), - i32(mod->create()), - u32(mod->create()), - void_(mod->create()), + : bool_(mod->create()), + f32(mod->create()), + i32(mod->create()), + u32(mod->create()), + void_(mod->create()), mod_(mod) {} Builder::Builder(Context* c, Module* m) : ctx(c), mod(m), ty(m) {} diff --git a/src/ast/builder.h b/src/ast/builder.h index 7ea60781c3..7551f92741 100644 --- a/src/ast/builder.h +++ b/src/ast/builder.h @@ -52,15 +52,15 @@ class TypesBuilder { explicit TypesBuilder(Module* mod); /// A boolean type - type::BoolType* const bool_; + type::Bool* const bool_; /// A f32 type - type::F32Type* const f32; + type::F32* const f32; /// A i32 type - type::I32Type* const i32; + type::I32* const i32; /// A u32 type - type::U32Type* const u32; + type::U32* const u32; /// A void type - type::VoidType* const void_; + type::Void* const void_; /// @return the tint AST type for the C type `T`. template @@ -70,86 +70,86 @@ class TypesBuilder { /// @return the tint AST type for a 2-element vector of the C type `T`. template - type::VectorType* vec2() const { - return mod_->create(Of(), 2); + type::Vector* vec2() const { + return mod_->create(Of(), 2); } /// @return the tint AST type for a 3-element vector of the C type `T`. template - type::VectorType* vec3() const { - return mod_->create(Of(), 3); + type::Vector* vec3() const { + return mod_->create(Of(), 3); } /// @return the tint AST type for a 4-element vector of the C type `T`. template type::Type* vec4() const { - return mod_->create(Of(), 4); + return mod_->create(Of(), 4); } /// @return the tint AST type for a 2x3 matrix of the C type `T`. template - type::MatrixType* mat2x2() const { - return mod_->create(Of(), 2, 2); + type::Matrix* mat2x2() const { + return mod_->create(Of(), 2, 2); } /// @return the tint AST type for a 2x3 matrix of the C type `T`. template - type::MatrixType* mat2x3() const { - return mod_->create(Of(), 3, 2); + type::Matrix* mat2x3() const { + return mod_->create(Of(), 3, 2); } /// @return the tint AST type for a 2x4 matrix of the C type `T`. template - type::MatrixType* mat2x4() const { - return mod_->create(Of(), 4, 2); + type::Matrix* mat2x4() const { + return mod_->create(Of(), 4, 2); } /// @return the tint AST type for a 3x2 matrix of the C type `T`. template - type::MatrixType* mat3x2() const { - return mod_->create(Of(), 2, 3); + type::Matrix* mat3x2() const { + return mod_->create(Of(), 2, 3); } /// @return the tint AST type for a 3x3 matrix of the C type `T`. template - type::MatrixType* mat3x3() const { - return mod_->create(Of(), 3, 3); + type::Matrix* mat3x3() const { + return mod_->create(Of(), 3, 3); } /// @return the tint AST type for a 3x4 matrix of the C type `T`. template - type::MatrixType* mat3x4() const { - return mod_->create(Of(), 4, 3); + type::Matrix* mat3x4() const { + return mod_->create(Of(), 4, 3); } /// @return the tint AST type for a 4x2 matrix of the C type `T`. template - type::MatrixType* mat4x2() const { - return mod_->create(Of(), 2, 4); + type::Matrix* mat4x2() const { + return mod_->create(Of(), 2, 4); } /// @return the tint AST type for a 4x3 matrix of the C type `T`. template - type::MatrixType* mat4x3() const { - return mod_->create(Of(), 3, 4); + type::Matrix* mat4x3() const { + return mod_->create(Of(), 3, 4); } /// @return the tint AST type for a 4x4 matrix of the C type `T`. template - type::MatrixType* mat4x4() const { - return mod_->create(Of(), 4, 4); + type::Matrix* mat4x4() const { + return mod_->create(Of(), 4, 4); } /// @param subtype the array element type /// @param n the array size. 0 represents unbounded /// @return the tint AST type for a array of size `n` of type `T` - type::ArrayType* array(type::Type* subtype, uint32_t n) const { - return mod_->create(subtype, n); + type::Array* array(type::Type* subtype, uint32_t n) const { + return mod_->create(subtype, n); } /// @return the tint AST type for an array of size `N` of type `T` template - type::ArrayType* array() const { + type::Array* array() const { return array(Of(), N); } diff --git a/src/ast/case_statement_test.cc b/src/ast/case_statement_test.cc index 8b6e6d945b..5600173f07 100644 --- a/src/ast/case_statement_test.cc +++ b/src/ast/case_statement_test.cc @@ -29,7 +29,7 @@ namespace { using CaseStatementTest = TestHelper; TEST_F(CaseStatementTest, Creation_i32) { - type::I32Type i32; + type::I32 i32; CaseSelectorList b; auto* selector = create(&i32, 2); @@ -47,7 +47,7 @@ TEST_F(CaseStatementTest, Creation_i32) { } TEST_F(CaseStatementTest, Creation_u32) { - type::U32Type u32; + type::U32 u32; CaseSelectorList b; auto* selector = create(&u32, 2); @@ -65,7 +65,7 @@ TEST_F(CaseStatementTest, Creation_u32) { } TEST_F(CaseStatementTest, Creation_WithSource) { - type::I32Type i32; + type::I32 i32; CaseSelectorList b; b.push_back(create(&i32, 2)); @@ -88,7 +88,7 @@ TEST_F(CaseStatementTest, IsDefault_WithoutSelectors) { } TEST_F(CaseStatementTest, IsDefault_WithSelectors) { - type::I32Type i32; + type::I32 i32; CaseSelectorList b; b.push_back(create(&i32, 2)); @@ -108,7 +108,7 @@ TEST_F(CaseStatementTest, IsValid) { } TEST_F(CaseStatementTest, IsValid_NullBodyStatement) { - type::I32Type i32; + type::I32 i32; CaseSelectorList b; b.push_back(create(&i32, 2)); @@ -121,7 +121,7 @@ TEST_F(CaseStatementTest, IsValid_NullBodyStatement) { } TEST_F(CaseStatementTest, IsValid_InvalidBodyStatement) { - type::I32Type i32; + type::I32 i32; CaseSelectorList b; b.push_back(create(&i32, 2)); @@ -133,7 +133,7 @@ TEST_F(CaseStatementTest, IsValid_InvalidBodyStatement) { } TEST_F(CaseStatementTest, ToStr_WithSelectors_i32) { - type::I32Type i32; + type::I32 i32; CaseSelectorList b; b.push_back(create(&i32, -2)); @@ -150,7 +150,7 @@ TEST_F(CaseStatementTest, ToStr_WithSelectors_i32) { } TEST_F(CaseStatementTest, ToStr_WithSelectors_u32) { - type::U32Type u32; + type::U32 u32; CaseSelectorList b; b.push_back(create(&u32, 2)); @@ -167,7 +167,7 @@ TEST_F(CaseStatementTest, ToStr_WithSelectors_u32) { } TEST_F(CaseStatementTest, ToStr_WithMultipleSelectors) { - type::I32Type i32; + type::I32 i32; CaseSelectorList b; b.push_back(create(&i32, 1)); diff --git a/src/ast/decorated_variable_test.cc b/src/ast/decorated_variable_test.cc index e9c2a523ff..63a4340006 100644 --- a/src/ast/decorated_variable_test.cc +++ b/src/ast/decorated_variable_test.cc @@ -33,7 +33,7 @@ namespace { using DecoratedVariableTest = TestHelper; TEST_F(DecoratedVariableTest, Creation) { - type::I32Type t; + type::I32 t; auto* var = create("my_var", StorageClass::kFunction, &t); DecoratedVariable dv(var); @@ -48,7 +48,7 @@ TEST_F(DecoratedVariableTest, Creation) { TEST_F(DecoratedVariableTest, CreationWithSource) { Source s{Source::Range{Source::Location{27, 4}, Source::Location{27, 5}}}; - type::F32Type t; + type::F32 t; auto* var = create(s, "i", StorageClass::kPrivate, &t); DecoratedVariable dv(var); @@ -62,7 +62,7 @@ TEST_F(DecoratedVariableTest, CreationWithSource) { } TEST_F(DecoratedVariableTest, NoDecorations) { - type::I32Type t; + type::I32 t; auto* var = create("my_var", StorageClass::kFunction, &t); DecoratedVariable dv(var); EXPECT_FALSE(dv.HasLocationDecoration()); @@ -71,7 +71,7 @@ TEST_F(DecoratedVariableTest, NoDecorations) { } TEST_F(DecoratedVariableTest, WithDecorations) { - type::F32Type t; + type::F32 t; auto* var = create("my_var", StorageClass::kFunction, &t); DecoratedVariable dv(var); @@ -88,7 +88,7 @@ TEST_F(DecoratedVariableTest, WithDecorations) { } TEST_F(DecoratedVariableTest, ConstantId) { - type::F32Type t; + type::F32 t; auto* var = create("my_var", StorageClass::kFunction, &t); DecoratedVariable dv(var); @@ -100,7 +100,7 @@ TEST_F(DecoratedVariableTest, ConstantId) { } TEST_F(DecoratedVariableTest, IsValid) { - type::I32Type t; + type::I32 t; auto* var = create("my_var", StorageClass::kNone, &t); DecoratedVariable dv(var); EXPECT_TRUE(dv.IsValid()); @@ -112,7 +112,7 @@ TEST_F(DecoratedVariableTest, IsDecorated) { } TEST_F(DecoratedVariableTest, to_str) { - type::F32Type t; + type::F32 t; auto* var = create("my_var", StorageClass::kFunction, &t); DecoratedVariable dv(var); dv.set_constructor(create("expr")); diff --git a/src/ast/else_statement_test.cc b/src/ast/else_statement_test.cc index 2e60b3952b..40ac0e0978 100644 --- a/src/ast/else_statement_test.cc +++ b/src/ast/else_statement_test.cc @@ -28,7 +28,7 @@ namespace { using ElseStatementTest = TestHelper; TEST_F(ElseStatementTest, Creation) { - type::BoolType bool_type; + type::Bool bool_type; auto* cond = create( create(&bool_type, true)); auto* body = create(); @@ -55,7 +55,7 @@ TEST_F(ElseStatementTest, IsElse) { } TEST_F(ElseStatementTest, HasCondition) { - type::BoolType bool_type; + type::Bool bool_type; auto* cond = create( create(&bool_type, true)); ElseStatement e(cond, create()); @@ -104,7 +104,7 @@ TEST_F(ElseStatementTest, IsValid_InvalidBodyStatement) { } TEST_F(ElseStatementTest, ToStr) { - type::BoolType bool_type; + type::Bool bool_type; auto* cond = create( create(&bool_type, true)); auto* body = create(); diff --git a/src/ast/expression_test.cc b/src/ast/expression_test.cc index c6337a4904..62538e8e83 100644 --- a/src/ast/expression_test.cc +++ b/src/ast/expression_test.cc @@ -33,23 +33,23 @@ class Expr : public Expression { using ExpressionTest = TestHelper; TEST_F(ExpressionTest, set_result_type) { - type::I32Type i32; + type::I32 i32; Expr e; e.set_result_type(&i32); ASSERT_NE(e.result_type(), nullptr); - EXPECT_TRUE(e.result_type()->Is()); + EXPECT_TRUE(e.result_type()->Is()); } TEST_F(ExpressionTest, set_result_type_alias) { - type::I32Type i32; - type::AliasType a("a", &i32); - type::AliasType b("b", &a); + type::I32 i32; + type::Alias a("a", &i32); + type::Alias b("b", &a); Expr e; e.set_result_type(&b); ASSERT_NE(e.result_type(), nullptr); - EXPECT_TRUE(e.result_type()->Is()); + EXPECT_TRUE(e.result_type()->Is()); } } // namespace diff --git a/src/ast/float_literal_test.cc b/src/ast/float_literal_test.cc index ffc93613f1..77b03f6cbf 100644 --- a/src/ast/float_literal_test.cc +++ b/src/ast/float_literal_test.cc @@ -28,14 +28,14 @@ namespace { using FloatLiteralTest = TestHelper; TEST_F(FloatLiteralTest, Value) { - type::F32Type f32; + type::F32 f32; FloatLiteral f{&f32, 47.2f}; ASSERT_TRUE(f.Is()); EXPECT_EQ(f.value(), 47.2f); } TEST_F(FloatLiteralTest, Is) { - type::F32Type f32; + type::F32 f32; FloatLiteral f{&f32, 42.f}; Literal* l = &f; EXPECT_FALSE(l->Is()); @@ -47,14 +47,14 @@ TEST_F(FloatLiteralTest, Is) { } TEST_F(FloatLiteralTest, ToStr) { - type::F32Type f32; + type::F32 f32; FloatLiteral f{&f32, 42.1f}; EXPECT_EQ(f.to_str(), "42.099998"); } TEST_F(FloatLiteralTest, ToName) { - type::F32Type f32; + type::F32 f32; FloatLiteral f{&f32, 42.1f}; EXPECT_EQ(f.name(), "__float42.0999985"); } diff --git a/src/ast/function.cc b/src/ast/function.cc index b251a7d55c..6c9f5d425d 100644 --- a/src/ast/function.cc +++ b/src/ast/function.cc @@ -282,9 +282,8 @@ Function::ReferencedSamplerVariablesImpl(type::SamplerKind kind) const { for (auto* var : referenced_module_variables()) { auto* unwrapped_type = var->type()->UnwrapIfNeeded(); - if (!var->Is() || - !unwrapped_type->Is() || - unwrapped_type->As()->kind() != kind) { + if (!var->Is() || !unwrapped_type->Is() || + unwrapped_type->As()->kind() != kind) { continue; } @@ -312,14 +311,12 @@ Function::ReferencedSampledTextureVariablesImpl(bool multisampled) const { for (auto* var : referenced_module_variables()) { auto* unwrapped_type = var->type()->UnwrapIfNeeded(); - if (!var->Is() || - !unwrapped_type->Is()) { + if (!var->Is() || !unwrapped_type->Is()) { continue; } - if ((multisampled && - !unwrapped_type->Is()) || - (!multisampled && !unwrapped_type->Is())) { + if ((multisampled && !unwrapped_type->Is()) || + (!multisampled && !unwrapped_type->Is())) { continue; } diff --git a/src/ast/function_test.cc b/src/ast/function_test.cc index d94f9284f9..c307284bd3 100644 --- a/src/ast/function_test.cc +++ b/src/ast/function_test.cc @@ -33,8 +33,8 @@ namespace { using FunctionTest = TestHelper; TEST_F(FunctionTest, Creation) { - type::VoidType void_type; - type::I32Type i32; + type::Void void_type; + type::I32 i32; VariableList params; params.push_back(create("var", StorageClass::kNone, &i32)); @@ -48,8 +48,8 @@ TEST_F(FunctionTest, Creation) { } TEST_F(FunctionTest, Creation_WithSource) { - type::VoidType void_type; - type::I32Type i32; + type::Void void_type; + type::I32 i32; VariableList params; params.push_back(create("var", StorageClass::kNone, &i32)); @@ -62,8 +62,8 @@ TEST_F(FunctionTest, Creation_WithSource) { } TEST_F(FunctionTest, AddDuplicateReferencedVariables) { - type::VoidType void_type; - type::I32Type i32; + type::Void void_type; + type::I32 i32; Variable v("var", StorageClass::kInput, &i32); Function f("func", VariableList{}, &void_type, create()); @@ -82,8 +82,8 @@ TEST_F(FunctionTest, AddDuplicateReferencedVariables) { } TEST_F(FunctionTest, GetReferenceLocations) { - type::VoidType void_type; - type::I32Type i32; + type::Void void_type; + type::I32 i32; DecoratedVariable loc1(create("loc1", StorageClass::kInput, &i32)); loc1.set_decorations({create(0, Source{})}); @@ -118,8 +118,8 @@ TEST_F(FunctionTest, GetReferenceLocations) { } TEST_F(FunctionTest, GetReferenceBuiltins) { - type::VoidType void_type; - type::I32Type i32; + type::Void void_type; + type::I32 i32; DecoratedVariable loc1(create("loc1", StorageClass::kInput, &i32)); loc1.set_decorations({create(0, Source{})}); @@ -154,7 +154,7 @@ TEST_F(FunctionTest, GetReferenceBuiltins) { } TEST_F(FunctionTest, AddDuplicateEntryPoints) { - type::VoidType void_type; + type::Void void_type; Function f("func", VariableList{}, &void_type, create()); f.add_ancestor_entry_point("main"); @@ -167,8 +167,8 @@ TEST_F(FunctionTest, AddDuplicateEntryPoints) { } TEST_F(FunctionTest, IsValid) { - type::VoidType void_type; - type::I32Type i32; + type::Void void_type; + type::I32 i32; VariableList params; params.push_back(create("var", StorageClass::kNone, &i32)); @@ -182,8 +182,8 @@ TEST_F(FunctionTest, IsValid) { } TEST_F(FunctionTest, IsValid_EmptyName) { - type::VoidType void_type; - type::I32Type i32; + type::Void void_type; + type::I32 i32; VariableList params; params.push_back(create("var", StorageClass::kNone, &i32)); @@ -193,7 +193,7 @@ TEST_F(FunctionTest, IsValid_EmptyName) { } TEST_F(FunctionTest, IsValid_MissingReturnType) { - type::I32Type i32; + type::I32 i32; VariableList params; params.push_back(create("var", StorageClass::kNone, &i32)); @@ -203,8 +203,8 @@ TEST_F(FunctionTest, IsValid_MissingReturnType) { } TEST_F(FunctionTest, IsValid_NullParam) { - type::VoidType void_type; - type::I32Type i32; + type::Void void_type; + type::I32 i32; VariableList params; params.push_back(create("var", StorageClass::kNone, &i32)); @@ -215,7 +215,7 @@ TEST_F(FunctionTest, IsValid_NullParam) { } TEST_F(FunctionTest, IsValid_InvalidParam) { - type::VoidType void_type; + type::Void void_type; VariableList params; params.push_back(create("var", StorageClass::kNone, nullptr)); @@ -225,8 +225,8 @@ TEST_F(FunctionTest, IsValid_InvalidParam) { } TEST_F(FunctionTest, IsValid_NullBodyStatement) { - type::VoidType void_type; - type::I32Type i32; + type::Void void_type; + type::I32 i32; VariableList params; params.push_back(create("var", StorageClass::kNone, &i32)); @@ -241,8 +241,8 @@ TEST_F(FunctionTest, IsValid_NullBodyStatement) { } TEST_F(FunctionTest, IsValid_InvalidBodyStatement) { - type::VoidType void_type; - type::I32Type i32; + type::Void void_type; + type::I32 i32; VariableList params; params.push_back(create("var", StorageClass::kNone, &i32)); @@ -257,8 +257,8 @@ TEST_F(FunctionTest, IsValid_InvalidBodyStatement) { } TEST_F(FunctionTest, ToStr) { - type::VoidType void_type; - type::I32Type i32; + type::Void void_type; + type::I32 i32; auto* block = create(); block->append(create()); @@ -277,8 +277,8 @@ TEST_F(FunctionTest, ToStr) { } TEST_F(FunctionTest, ToStr_WithDecoration) { - type::VoidType void_type; - type::I32Type i32; + type::Void void_type; + type::I32 i32; auto* block = create(); block->append(create()); @@ -299,8 +299,8 @@ TEST_F(FunctionTest, ToStr_WithDecoration) { } TEST_F(FunctionTest, ToStr_WithParams) { - type::VoidType void_type; - type::I32Type i32; + type::Void void_type; + type::I32 i32; VariableList params; params.push_back(create("var", StorageClass::kNone, &i32)); @@ -328,16 +328,16 @@ TEST_F(FunctionTest, ToStr_WithParams) { } TEST_F(FunctionTest, TypeName) { - type::VoidType void_type; + type::Void void_type; Function f("func", {}, &void_type, create()); EXPECT_EQ(f.type_name(), "__func__void"); } TEST_F(FunctionTest, TypeName_WithParams) { - type::VoidType void_type; - type::I32Type i32; - type::F32Type f32; + type::Void void_type; + type::I32 i32; + type::F32 f32; VariableList params; params.push_back(create("var1", StorageClass::kNone, &i32)); @@ -348,7 +348,7 @@ TEST_F(FunctionTest, TypeName_WithParams) { } TEST_F(FunctionTest, GetLastStatement) { - type::VoidType void_type; + type::Void void_type; VariableList params; auto* body = create(); @@ -361,7 +361,7 @@ TEST_F(FunctionTest, GetLastStatement) { } TEST_F(FunctionTest, GetLastStatement_nullptr) { - type::VoidType void_type; + type::Void void_type; VariableList params; auto* body = create(); @@ -372,7 +372,7 @@ TEST_F(FunctionTest, GetLastStatement_nullptr) { } TEST_F(FunctionTest, WorkgroupSize_NoneSet) { - type::VoidType void_type; + type::Void void_type; Function f("f", {}, &void_type, create()); uint32_t x = 0; uint32_t y = 0; @@ -384,7 +384,7 @@ TEST_F(FunctionTest, WorkgroupSize_NoneSet) { } TEST_F(FunctionTest, WorkgroupSize) { - type::VoidType void_type; + type::Void void_type; Function f("f", {}, &void_type, create()); f.add_decoration(create(2u, 4u, 6u, Source{})); diff --git a/src/ast/int_literal_test.cc b/src/ast/int_literal_test.cc index 70d399a97b..3a1eb7599c 100644 --- a/src/ast/int_literal_test.cc +++ b/src/ast/int_literal_test.cc @@ -30,13 +30,13 @@ namespace { using IntLiteralTest = TestHelper; TEST_F(IntLiteralTest, Sint_IsInt) { - type::I32Type i32; + type::I32 i32; SintLiteral i{&i32, 47}; ASSERT_TRUE(i.Is()); } TEST_F(IntLiteralTest, Uint_IsInt) { - type::I32Type i32; + type::I32 i32; UintLiteral i{&i32, 42}; EXPECT_TRUE(i.Is()); } diff --git a/src/ast/module.cc b/src/ast/module.cc index c11bbd7c1d..748a984cf3 100644 --- a/src/ast/module.cc +++ b/src/ast/module.cc @@ -56,17 +56,17 @@ bool Module::IsValid() const { if (ty == nullptr) { return false; } - if (ty->Is()) { - auto* alias = ty->As(); + if (ty->Is()) { + auto* alias = ty->As(); if (alias->type() == nullptr) { return false; } - if (alias->type()->Is() && - alias->type()->As()->name().empty()) { + if (alias->type()->Is() && + alias->type()->As()->name().empty()) { return false; } - } else if (ty->Is()) { - auto* str = ty->As(); + } else if (ty->Is()) { + auto* str = ty->As(); if (str->name().empty()) { return false; } @@ -91,14 +91,14 @@ std::string Module::to_str() const { for (size_t i = 0; i < indent; ++i) { out << " "; } - if (ty->Is()) { - auto* alias = ty->As(); + if (ty->Is()) { + auto* alias = ty->As(); out << alias->name() << " -> " << alias->type()->type_name() << std::endl; - if (alias->type()->Is()) { - alias->type()->As()->impl()->to_str(out, indent); + if (alias->type()->Is()) { + alias->type()->As()->impl()->to_str(out, indent); } - } else if (ty->Is()) { - auto* str = ty->As(); + } else if (ty->Is()) { + auto* str = ty->As(); out << str->name() << " "; str->impl()->to_str(out, indent); } diff --git a/src/ast/module_test.cc b/src/ast/module_test.cc index cf05d4efcd..0bdbf49c4d 100644 --- a/src/ast/module_test.cc +++ b/src/ast/module_test.cc @@ -45,7 +45,7 @@ TEST_F(ModuleTest, ToStrEmitsPreambleAndPostamble) { } TEST_F(ModuleTest, LookupFunction) { - type::F32Type f32; + type::F32 f32; Module m; auto* func = @@ -65,7 +65,7 @@ TEST_F(ModuleTest, IsValid_Empty) { } TEST_F(ModuleTest, IsValid_GlobalVariable) { - type::F32Type f32; + type::F32 f32; auto* var = create("var", StorageClass::kInput, &f32); Module m; @@ -88,8 +88,8 @@ TEST_F(ModuleTest, IsValid_Invalid_GlobalVariable) { } TEST_F(ModuleTest, IsValid_Alias) { - type::F32Type f32; - type::AliasType alias("alias", &f32); + type::F32 f32; + type::Alias alias("alias", &f32); Module m; m.AddConstructedType(&alias); @@ -103,9 +103,9 @@ TEST_F(ModuleTest, IsValid_Null_Alias) { } TEST_F(ModuleTest, IsValid_Struct) { - type::F32Type f32; - type::StructType st("name", {}); - type::AliasType alias("name", &st); + type::F32 f32; + type::Struct st("name", {}); + type::Alias alias("name", &st); Module m; m.AddConstructedType(&alias); @@ -113,9 +113,9 @@ TEST_F(ModuleTest, IsValid_Struct) { } TEST_F(ModuleTest, IsValid_Struct_EmptyName) { - type::F32Type f32; - type::StructType st("", {}); - type::AliasType alias("name", &st); + type::F32 f32; + type::Struct st("", {}); + type::Alias alias("name", &st); Module m; m.AddConstructedType(&alias); @@ -123,7 +123,7 @@ TEST_F(ModuleTest, IsValid_Struct_EmptyName) { } TEST_F(ModuleTest, IsValid_Function) { - type::F32Type f32; + type::F32 f32; auto* func = create("main", VariableList(), &f32, create()); diff --git a/src/ast/null_literal_test.cc b/src/ast/null_literal_test.cc index 8c151ee8b2..1ae8c83177 100644 --- a/src/ast/null_literal_test.cc +++ b/src/ast/null_literal_test.cc @@ -28,7 +28,7 @@ namespace { using NullLiteralTest = TestHelper; TEST_F(NullLiteralTest, Is) { - type::I32Type i32; + type::I32 i32; NullLiteral i{&i32}; Literal* l = &i; EXPECT_FALSE(l->Is()); @@ -40,14 +40,14 @@ TEST_F(NullLiteralTest, Is) { } TEST_F(NullLiteralTest, ToStr) { - type::I32Type i32; + type::I32 i32; NullLiteral i{&i32}; EXPECT_EQ(i.to_str(), "null __i32"); } TEST_F(NullLiteralTest, Name_I32) { - type::I32Type i32; + type::I32 i32; NullLiteral i{&i32}; EXPECT_EQ("__null__i32", i.name()); } diff --git a/src/ast/scalar_constructor_expression_test.cc b/src/ast/scalar_constructor_expression_test.cc index d7184c6de3..60e4185fa2 100644 --- a/src/ast/scalar_constructor_expression_test.cc +++ b/src/ast/scalar_constructor_expression_test.cc @@ -25,14 +25,14 @@ namespace { using ScalarConstructorExpressionTest = TestHelper; TEST_F(ScalarConstructorExpressionTest, Creation) { - type::BoolType bool_type; + type::Bool bool_type; auto* b = create(&bool_type, true); ScalarConstructorExpression c(b); EXPECT_EQ(c.literal(), b); } TEST_F(ScalarConstructorExpressionTest, Creation_WithSource) { - type::BoolType bool_type; + type::Bool bool_type; auto* b = create(&bool_type, true); ScalarConstructorExpression c(Source{Source::Location{20, 2}}, b); auto src = c.source(); @@ -41,7 +41,7 @@ TEST_F(ScalarConstructorExpressionTest, Creation_WithSource) { } TEST_F(ScalarConstructorExpressionTest, IsValid) { - type::BoolType bool_type; + type::Bool bool_type; auto* b = create(&bool_type, true); ScalarConstructorExpression c(b); EXPECT_TRUE(c.IsValid()); @@ -53,7 +53,7 @@ TEST_F(ScalarConstructorExpressionTest, IsValid_MissingLiteral) { } TEST_F(ScalarConstructorExpressionTest, ToStr) { - type::BoolType bool_type; + type::Bool bool_type; auto* b = create(&bool_type, true); ScalarConstructorExpression c(b); std::ostringstream out; diff --git a/src/ast/sint_literal_test.cc b/src/ast/sint_literal_test.cc index 7a8972fadd..09b4a34b2b 100644 --- a/src/ast/sint_literal_test.cc +++ b/src/ast/sint_literal_test.cc @@ -29,14 +29,14 @@ namespace { using SintLiteralTest = TestHelper; TEST_F(SintLiteralTest, Value) { - type::I32Type i32; + type::I32 i32; SintLiteral i{&i32, 47}; ASSERT_TRUE(i.Is()); EXPECT_EQ(i.value(), 47); } TEST_F(SintLiteralTest, Is) { - type::I32Type i32; + type::I32 i32; SintLiteral i{&i32, 42}; Literal* l = &i; EXPECT_FALSE(l->Is()); @@ -47,20 +47,20 @@ TEST_F(SintLiteralTest, Is) { } TEST_F(SintLiteralTest, ToStr) { - type::I32Type i32; + type::I32 i32; SintLiteral i{&i32, -42}; EXPECT_EQ(i.to_str(), "-42"); } TEST_F(SintLiteralTest, Name_I32) { - type::I32Type i32; + type::I32 i32; SintLiteral i{&i32, 2}; EXPECT_EQ("__sint__i32_2", i.name()); } TEST_F(SintLiteralTest, Name_U32) { - type::U32Type u32; + type::U32 u32; SintLiteral i{&u32, 2}; EXPECT_EQ("__sint__u32_2", i.name()); } diff --git a/src/ast/struct_member_test.cc b/src/ast/struct_member_test.cc index 18a71eb5c3..88b2eae0ae 100644 --- a/src/ast/struct_member_test.cc +++ b/src/ast/struct_member_test.cc @@ -28,7 +28,7 @@ namespace { using StructMemberTest = TestHelper; TEST_F(StructMemberTest, Creation) { - type::I32Type i32; + type::I32 i32; StructMemberDecorationList decorations; decorations.emplace_back(create(4, Source{})); @@ -44,7 +44,7 @@ TEST_F(StructMemberTest, Creation) { } TEST_F(StructMemberTest, CreationWithSource) { - type::I32Type i32; + type::I32 i32; Source s{Source::Range{Source::Location{27, 4}, Source::Location{27, 8}}}; StructMember st{s, "a", &i32, {}}; @@ -58,13 +58,13 @@ TEST_F(StructMemberTest, CreationWithSource) { } TEST_F(StructMemberTest, IsValid) { - type::I32Type i32; + type::I32 i32; StructMember st{"a", &i32, {}}; EXPECT_TRUE(st.IsValid()); } TEST_F(StructMemberTest, IsValid_EmptyName) { - type::I32Type i32; + type::I32 i32; StructMember st{"", &i32, {}}; EXPECT_FALSE(st.IsValid()); } @@ -75,7 +75,7 @@ TEST_F(StructMemberTest, IsValid_NullType) { } TEST_F(StructMemberTest, IsValid_Null_Decoration) { - type::I32Type i32; + type::I32 i32; StructMemberDecorationList decorations; decorations.emplace_back(create(4, Source{})); decorations.push_back(nullptr); @@ -85,7 +85,7 @@ TEST_F(StructMemberTest, IsValid_Null_Decoration) { } TEST_F(StructMemberTest, ToStr) { - type::I32Type i32; + type::I32 i32; StructMemberDecorationList decorations; decorations.emplace_back(create(4, Source{})); @@ -96,7 +96,7 @@ TEST_F(StructMemberTest, ToStr) { } TEST_F(StructMemberTest, ToStrNoDecorations) { - type::I32Type i32; + type::I32 i32; StructMember st{"a", &i32, {}}; std::ostringstream out; st.to_str(out, 2); diff --git a/src/ast/struct_test.cc b/src/ast/struct_test.cc index 33f0697083..11e9bb89f9 100644 --- a/src/ast/struct_test.cc +++ b/src/ast/struct_test.cc @@ -30,7 +30,7 @@ namespace { using StructTest = TestHelper; TEST_F(StructTest, Creation) { - type::I32Type i32; + type::I32 i32; StructMemberList members; members.push_back( create("a", &i32, StructMemberDecorationList())); @@ -45,7 +45,7 @@ TEST_F(StructTest, Creation) { } TEST_F(StructTest, Creation_WithDecorations) { - type::I32Type i32; + type::I32 i32; StructMemberList members; members.push_back( @@ -65,7 +65,7 @@ TEST_F(StructTest, Creation_WithDecorations) { } TEST_F(StructTest, CreationWithSourceAndDecorations) { - type::I32Type i32; + type::I32 i32; StructMemberList members; members.emplace_back( @@ -92,7 +92,7 @@ TEST_F(StructTest, IsValid) { } TEST_F(StructTest, IsValid_Null_StructMember) { - type::I32Type i32; + type::I32 i32; StructMemberList members; members.push_back( @@ -104,7 +104,7 @@ TEST_F(StructTest, IsValid_Null_StructMember) { } TEST_F(StructTest, IsValid_Invalid_StructMember) { - type::I32Type i32; + type::I32 i32; StructMemberList members; members.push_back( @@ -115,7 +115,7 @@ TEST_F(StructTest, IsValid_Invalid_StructMember) { } TEST_F(StructTest, ToStr) { - type::I32Type i32; + type::I32 i32; StructMemberList members; members.emplace_back( diff --git a/src/ast/switch_statement_test.cc b/src/ast/switch_statement_test.cc index 7627a0bbfd..14d90e6d26 100644 --- a/src/ast/switch_statement_test.cc +++ b/src/ast/switch_statement_test.cc @@ -29,7 +29,7 @@ namespace { using SwitchStatementTest = TestHelper; TEST_F(SwitchStatementTest, Creation) { - type::I32Type i32; + type::I32 i32; CaseSelectorList lit; lit.push_back(create(&i32, 1)); @@ -61,7 +61,7 @@ TEST_F(SwitchStatementTest, IsSwitch) { } TEST_F(SwitchStatementTest, IsValid) { - type::I32Type i32; + type::I32 i32; CaseSelectorList lit; lit.push_back(create(&i32, 2)); @@ -75,7 +75,7 @@ TEST_F(SwitchStatementTest, IsValid) { } TEST_F(SwitchStatementTest, IsValid_Null_Condition) { - type::I32Type i32; + type::I32 i32; CaseSelectorList lit; lit.push_back(create(&i32, 2)); @@ -89,7 +89,7 @@ TEST_F(SwitchStatementTest, IsValid_Null_Condition) { } TEST_F(SwitchStatementTest, IsValid_Invalid_Condition) { - type::I32Type i32; + type::I32 i32; CaseSelectorList lit; lit.push_back(create(&i32, 2)); @@ -103,7 +103,7 @@ TEST_F(SwitchStatementTest, IsValid_Invalid_Condition) { } TEST_F(SwitchStatementTest, IsValid_Null_BodyStatement) { - type::I32Type i32; + type::I32 i32; CaseSelectorList lit; lit.push_back(create(&i32, 2)); @@ -145,7 +145,7 @@ TEST_F(SwitchStatementTest, ToStr_Empty) { } TEST_F(SwitchStatementTest, ToStr) { - type::I32Type i32; + type::I32 i32; CaseSelectorList lit; lit.push_back(create(&i32, 2)); diff --git a/src/ast/type/access_control_type.cc b/src/ast/type/access_control_type.cc index 4e59370287..a419efbdc4 100644 --- a/src/ast/type/access_control_type.cc +++ b/src/ast/type/access_control_type.cc @@ -20,38 +20,37 @@ namespace tint { namespace ast { namespace type { -AccessControlType::AccessControlType(AccessControl access, Type* subtype) +AccessControl::AccessControl(ast::AccessControl access, Type* subtype) : access_(access), subtype_(subtype) { assert(subtype_); - assert(!subtype_->Is()); + assert(!subtype_->Is()); } -AccessControlType::AccessControlType(AccessControlType&&) = default; +AccessControl::AccessControl(AccessControl&&) = default; -AccessControlType::~AccessControlType() = default; +AccessControl::~AccessControl() = default; -std::string AccessControlType::type_name() const { +std::string AccessControl::type_name() const { std::string name = "__access_control_"; switch (access_) { - case AccessControl::kReadOnly: + case ast::AccessControl::kReadOnly: name += "read_only"; break; - case AccessControl::kWriteOnly: + case ast::AccessControl::kWriteOnly: name += "write_only"; break; - case AccessControl::kReadWrite: + case ast::AccessControl::kReadWrite: name += "read_write"; break; } return name + subtype_->type_name(); } -uint64_t AccessControlType::MinBufferBindingSize( - MemoryLayout mem_layout) const { +uint64_t AccessControl::MinBufferBindingSize(MemoryLayout mem_layout) const { return subtype_->MinBufferBindingSize(mem_layout); } -uint64_t AccessControlType::BaseAlignment(MemoryLayout mem_layout) const { +uint64_t AccessControl::BaseAlignment(MemoryLayout mem_layout) const { return subtype_->BaseAlignment(mem_layout); } diff --git a/src/ast/type/access_control_type.h b/src/ast/type/access_control_type.h index 9e31d67a35..c5828a6899 100644 --- a/src/ast/type/access_control_type.h +++ b/src/ast/type/access_control_type.h @@ -25,25 +25,25 @@ namespace ast { namespace type { /// An access control type. Holds an access setting and pointer to another type. -class AccessControlType : public Castable { +class AccessControl : public Castable { public: /// Constructor /// @param access the access control setting /// @param subtype the access controlled type - AccessControlType(AccessControl access, Type* subtype); + AccessControl(ast::AccessControl access, Type* subtype); /// Move constructor - AccessControlType(AccessControlType&&); - ~AccessControlType() override; + AccessControl(AccessControl&&); + ~AccessControl() override; /// @returns true if the access control is read only - bool IsReadOnly() const { return access_ == AccessControl::kReadOnly; } + bool IsReadOnly() const { return access_ == ast::AccessControl::kReadOnly; } /// @returns true if the access control is write only - bool IsWriteOnly() const { return access_ == AccessControl::kWriteOnly; } + bool IsWriteOnly() const { return access_ == ast::AccessControl::kWriteOnly; } /// @returns true if the access control is read/write - bool IsReadWrite() const { return access_ == AccessControl::kReadWrite; } + bool IsReadWrite() const { return access_ == ast::AccessControl::kReadWrite; } /// @returns the access control value - AccessControl access_control() const { return access_; } + ast::AccessControl access_control() const { return access_; } /// @returns the subtype type Type* type() const { return subtype_; } @@ -61,7 +61,7 @@ class AccessControlType : public Castable { uint64_t BaseAlignment(MemoryLayout mem_layout) const override; private: - AccessControl access_ = AccessControl::kReadOnly; + ast::AccessControl access_ = ast::AccessControl::kReadOnly; Type* subtype_ = nullptr; }; diff --git a/src/ast/type/access_control_type_test.cc b/src/ast/type/access_control_type_test.cc index ded04fbb70..b49f64c8c6 100644 --- a/src/ast/type/access_control_type_test.cc +++ b/src/ast/type/access_control_type_test.cc @@ -39,38 +39,38 @@ namespace ast { namespace type { namespace { -using AccessControlTypeTest = TestHelper; +using AccessControlTest = TestHelper; -TEST_F(AccessControlTypeTest, Create) { - U32Type u32; - AccessControlType a{AccessControl::kReadWrite, &u32}; +TEST_F(AccessControlTest, Create) { + U32 u32; + AccessControl a{ast::AccessControl::kReadWrite, &u32}; EXPECT_TRUE(a.IsReadWrite()); EXPECT_EQ(a.type(), &u32); } -TEST_F(AccessControlTypeTest, Is) { - I32Type i32; +TEST_F(AccessControlTest, Is) { + I32 i32; - AccessControlType at{AccessControl::kReadOnly, &i32}; + AccessControl at{ast::AccessControl::kReadOnly, &i32}; Type* ty = &at; - EXPECT_TRUE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_TRUE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); } -TEST_F(AccessControlTypeTest, AccessRead) { - I32Type i32; - AccessControlType at{AccessControl::kReadOnly, &i32}; +TEST_F(AccessControlTest, AccessRead) { + I32 i32; + AccessControl at{ast::AccessControl::kReadOnly, &i32}; EXPECT_TRUE(at.IsReadOnly()); EXPECT_FALSE(at.IsWriteOnly()); EXPECT_FALSE(at.IsReadWrite()); @@ -78,9 +78,9 @@ TEST_F(AccessControlTypeTest, AccessRead) { EXPECT_EQ(at.type_name(), "__access_control_read_only__i32"); } -TEST_F(AccessControlTypeTest, AccessWrite) { - I32Type i32; - AccessControlType at{AccessControl::kWriteOnly, &i32}; +TEST_F(AccessControlTest, AccessWrite) { + I32 i32; + AccessControl at{ast::AccessControl::kWriteOnly, &i32}; EXPECT_FALSE(at.IsReadOnly()); EXPECT_TRUE(at.IsWriteOnly()); EXPECT_FALSE(at.IsReadWrite()); @@ -88,9 +88,9 @@ TEST_F(AccessControlTypeTest, AccessWrite) { EXPECT_EQ(at.type_name(), "__access_control_write_only__i32"); } -TEST_F(AccessControlTypeTest, AccessReadWrite) { - I32Type i32; - AccessControlType at{AccessControl::kReadWrite, &i32}; +TEST_F(AccessControlTest, AccessReadWrite) { + I32 i32; + AccessControl at{ast::AccessControl::kReadWrite, &i32}; EXPECT_FALSE(at.IsReadOnly()); EXPECT_FALSE(at.IsWriteOnly()); EXPECT_TRUE(at.IsReadWrite()); @@ -98,34 +98,34 @@ TEST_F(AccessControlTypeTest, AccessReadWrite) { EXPECT_EQ(at.type_name(), "__access_control_read_write__i32"); } -TEST_F(AccessControlTypeTest, MinBufferBindingSizeU32) { - U32Type u32; - AccessControlType at{AccessControl::kReadOnly, &u32}; +TEST_F(AccessControlTest, MinBufferBindingSizeU32) { + U32 u32; + AccessControl at{ast::AccessControl::kReadOnly, &u32}; EXPECT_EQ(4u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); } -TEST_F(AccessControlTypeTest, MinBufferBindingSizeArray) { - U32Type u32; - ArrayType array(&u32, 4); +TEST_F(AccessControlTest, MinBufferBindingSizeArray) { + U32 u32; + Array array(&u32, 4); ArrayDecorationList decos; decos.push_back(create(4, Source{})); array.set_decorations(decos); - AccessControlType at{AccessControl::kReadOnly, &array}; + AccessControl at{ast::AccessControl::kReadOnly, &array}; EXPECT_EQ(16u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); } -TEST_F(AccessControlTypeTest, MinBufferBindingSizeRuntimeArray) { - U32Type u32; - ArrayType array(&u32); +TEST_F(AccessControlTest, MinBufferBindingSizeRuntimeArray) { + U32 u32; + Array array(&u32); ArrayDecorationList decos; decos.push_back(create(4, Source{})); array.set_decorations(decos); - AccessControlType at{AccessControl::kReadOnly, &array}; + AccessControl at{ast::AccessControl::kReadOnly, &array}; EXPECT_EQ(4u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); } -TEST_F(AccessControlTypeTest, MinBufferBindingSizeStruct) { - U32Type u32; +TEST_F(AccessControlTest, MinBufferBindingSizeStruct) { + U32 u32; StructMemberList members; StructMemberDecorationList deco; @@ -138,41 +138,41 @@ TEST_F(AccessControlTypeTest, MinBufferBindingSizeStruct) { StructDecorationList decos; - auto* str = create(decos, members); - StructType struct_type("struct_type", str); - AccessControlType at{AccessControl::kReadOnly, &struct_type}; + auto* str = create(decos, members); + Struct struct_type("struct_type", str); + AccessControl at{ast::AccessControl::kReadOnly, &struct_type}; EXPECT_EQ(16u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); EXPECT_EQ(8u, at.MinBufferBindingSize(MemoryLayout::kStorageBuffer)); } -TEST_F(AccessControlTypeTest, BaseAlignmentU32) { - U32Type u32; - AccessControlType at{AccessControl::kReadOnly, &u32}; +TEST_F(AccessControlTest, BaseAlignmentU32) { + U32 u32; + AccessControl at{ast::AccessControl::kReadOnly, &u32}; EXPECT_EQ(4u, at.BaseAlignment(MemoryLayout::kUniformBuffer)); } -TEST_F(AccessControlTypeTest, BaseAlignmentArray) { - U32Type u32; - ArrayType array(&u32, 4); +TEST_F(AccessControlTest, BaseAlignmentArray) { + U32 u32; + Array array(&u32, 4); ArrayDecorationList decos; decos.push_back(create(4, Source{})); array.set_decorations(decos); - AccessControlType at{AccessControl::kReadOnly, &array}; + AccessControl at{ast::AccessControl::kReadOnly, &array}; EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer)); } -TEST_F(AccessControlTypeTest, BaseAlignmentRuntimeArray) { - U32Type u32; - ArrayType array(&u32); +TEST_F(AccessControlTest, BaseAlignmentRuntimeArray) { + U32 u32; + Array array(&u32); ArrayDecorationList decos; decos.push_back(create(4, Source{})); array.set_decorations(decos); - AccessControlType at{AccessControl::kReadOnly, &array}; + AccessControl at{ast::AccessControl::kReadOnly, &array}; EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer)); } -TEST_F(AccessControlTypeTest, BaseAlignmentStruct) { - U32Type u32; +TEST_F(AccessControlTest, BaseAlignmentStruct) { + U32 u32; StructMemberList members; { @@ -187,9 +187,9 @@ TEST_F(AccessControlTypeTest, BaseAlignmentStruct) { } StructDecorationList decos; - auto* str = create(decos, members); - StructType struct_type("struct_type", str); - AccessControlType at{AccessControl::kReadOnly, &struct_type}; + auto* str = create(decos, members); + Struct struct_type("struct_type", str); + AccessControl at{ast::AccessControl::kReadOnly, &struct_type}; EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(4u, at.BaseAlignment(MemoryLayout::kStorageBuffer)); } diff --git a/src/ast/type/alias_type.cc b/src/ast/type/alias_type.cc index f2fece845f..955f12f4ac 100644 --- a/src/ast/type/alias_type.cc +++ b/src/ast/type/alias_type.cc @@ -20,24 +20,24 @@ namespace tint { namespace ast { namespace type { -AliasType::AliasType(const std::string& name, Type* subtype) +Alias::Alias(const std::string& name, Type* subtype) : name_(name), subtype_(subtype) { assert(subtype_); } -AliasType::AliasType(AliasType&&) = default; +Alias::Alias(Alias&&) = default; -AliasType::~AliasType() = default; +Alias::~Alias() = default; -std::string AliasType::type_name() const { +std::string Alias::type_name() const { return "__alias_" + name_ + subtype_->type_name(); } -uint64_t AliasType::MinBufferBindingSize(MemoryLayout mem_layout) const { +uint64_t Alias::MinBufferBindingSize(MemoryLayout mem_layout) const { return subtype_->MinBufferBindingSize(mem_layout); } -uint64_t AliasType::BaseAlignment(MemoryLayout mem_layout) const { +uint64_t Alias::BaseAlignment(MemoryLayout mem_layout) const { return subtype_->BaseAlignment(mem_layout); } diff --git a/src/ast/type/alias_type.h b/src/ast/type/alias_type.h index 1476b59e9b..7d4840a8b9 100644 --- a/src/ast/type/alias_type.h +++ b/src/ast/type/alias_type.h @@ -24,15 +24,15 @@ namespace ast { namespace type { /// A type alias type. Holds a name and pointer to another type. -class AliasType : public Castable { +class Alias : public Castable { public: /// Constructor /// @param name the alias name /// @param subtype the alias'd type - AliasType(const std::string& name, Type* subtype); + Alias(const std::string& name, Type* subtype); /// Move constructor - AliasType(AliasType&&); - ~AliasType() override; + Alias(Alias&&); + ~Alias() override; /// @returns the alias name const std::string& name() const { return name_; } diff --git a/src/ast/type/alias_type_test.cc b/src/ast/type/alias_type_test.cc index e2e5c6a342..7979efa68f 100644 --- a/src/ast/type/alias_type_test.cc +++ b/src/ast/type/alias_type_test.cc @@ -40,155 +40,155 @@ namespace ast { namespace type { namespace { -using AliasTypeTest = TestHelper; +using AliasTest = TestHelper; -TEST_F(AliasTypeTest, Create) { - U32Type u32; - AliasType a{"a_type", &u32}; +TEST_F(AliasTest, Create) { + U32 u32; + Alias a{"a_type", &u32}; EXPECT_EQ(a.name(), "a_type"); EXPECT_EQ(a.type(), &u32); } -TEST_F(AliasTypeTest, Is) { - I32Type i32; +TEST_F(AliasTest, Is) { + I32 i32; - AliasType at{"a", &i32}; + Alias at{"a", &i32}; Type* ty = &at; - EXPECT_FALSE(ty->Is()); - EXPECT_TRUE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_TRUE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); } -TEST_F(AliasTypeTest, TypeName) { - I32Type i32; - AliasType at{"Particle", &i32}; +TEST_F(AliasTest, TypeName) { + I32 i32; + Alias at{"Particle", &i32}; EXPECT_EQ(at.type_name(), "__alias_Particle__i32"); } -TEST_F(AliasTypeTest, UnwrapIfNeeded_Alias) { - U32Type u32; - AliasType a{"a_type", &u32}; +TEST_F(AliasTest, UnwrapIfNeeded_Alias) { + U32 u32; + Alias a{"a_type", &u32}; EXPECT_EQ(a.name(), "a_type"); EXPECT_EQ(a.type(), &u32); EXPECT_EQ(a.UnwrapIfNeeded(), &u32); EXPECT_EQ(u32.UnwrapIfNeeded(), &u32); } -TEST_F(AliasTypeTest, UnwrapIfNeeded_AccessControl) { - U32Type u32; - AccessControlType a{AccessControl::kReadOnly, &u32}; +TEST_F(AliasTest, UnwrapIfNeeded_AccessControl) { + U32 u32; + AccessControl a{ast::AccessControl::kReadOnly, &u32}; EXPECT_EQ(a.type(), &u32); EXPECT_EQ(a.UnwrapIfNeeded(), &u32); } -TEST_F(AliasTypeTest, UnwrapIfNeeded_MultiLevel) { - U32Type u32; - AliasType a{"a_type", &u32}; - AliasType aa{"aa_type", &a}; +TEST_F(AliasTest, UnwrapIfNeeded_MultiLevel) { + U32 u32; + Alias a{"a_type", &u32}; + Alias aa{"aa_type", &a}; EXPECT_EQ(aa.name(), "aa_type"); EXPECT_EQ(aa.type(), &a); EXPECT_EQ(aa.UnwrapIfNeeded(), &u32); } -TEST_F(AliasTypeTest, UnwrapIfNeeded_MultiLevel_AliasAccessControl) { - U32Type u32; - AliasType a{"a_type", &u32}; - AccessControlType aa{AccessControl::kReadWrite, &a}; +TEST_F(AliasTest, UnwrapIfNeeded_MultiLevel_AliasAccessControl) { + U32 u32; + Alias a{"a_type", &u32}; + AccessControl aa{ast::AccessControl::kReadWrite, &a}; EXPECT_EQ(aa.type(), &a); EXPECT_EQ(aa.UnwrapIfNeeded(), &u32); } -TEST_F(AliasTypeTest, UnwrapAll_TwiceAliasPointerTwiceAlias) { - U32Type u32; - AliasType a{"a_type", &u32}; - AliasType aa{"aa_type", &a}; - PointerType paa{&aa, StorageClass::kUniform}; - AliasType apaa{"paa_type", &paa}; - AliasType aapaa{"aapaa_type", &apaa}; +TEST_F(AliasTest, UnwrapAll_TwiceAliasPointerTwiceAlias) { + U32 u32; + Alias a{"a_type", &u32}; + Alias aa{"aa_type", &a}; + Pointer paa{&aa, StorageClass::kUniform}; + Alias apaa{"paa_type", &paa}; + Alias aapaa{"aapaa_type", &apaa}; EXPECT_EQ(aapaa.name(), "aapaa_type"); EXPECT_EQ(aapaa.type(), &apaa); EXPECT_EQ(aapaa.UnwrapAll(), &u32); EXPECT_EQ(u32.UnwrapAll(), &u32); } -TEST_F(AliasTypeTest, UnwrapAll_SecondConsecutivePointerBlocksUnrapping) { - U32Type u32; - AliasType a{"a_type", &u32}; - AliasType aa{"aa_type", &a}; - PointerType paa{&aa, StorageClass::kUniform}; - PointerType ppaa{&paa, StorageClass::kUniform}; - AliasType appaa{"appaa_type", &ppaa}; +TEST_F(AliasTest, UnwrapAll_SecondConsecutivePointerBlocksUnrapping) { + U32 u32; + Alias a{"a_type", &u32}; + Alias aa{"aa_type", &a}; + Pointer paa{&aa, StorageClass::kUniform}; + Pointer ppaa{&paa, StorageClass::kUniform}; + Alias appaa{"appaa_type", &ppaa}; EXPECT_EQ(appaa.UnwrapAll(), &paa); } -TEST_F(AliasTypeTest, UnwrapAll_SecondNonConsecutivePointerBlocksUnrapping) { - U32Type u32; - AliasType a{"a_type", &u32}; - AliasType aa{"aa_type", &a}; - PointerType paa{&aa, StorageClass::kUniform}; - AliasType apaa{"apaa_type", &paa}; - AliasType aapaa{"aapaa_type", &apaa}; - PointerType paapaa{&aapaa, StorageClass::kUniform}; - AliasType apaapaa{"apaapaa_type", &paapaa}; +TEST_F(AliasTest, UnwrapAll_SecondNonConsecutivePointerBlocksUnrapping) { + U32 u32; + Alias a{"a_type", &u32}; + Alias aa{"aa_type", &a}; + Pointer paa{&aa, StorageClass::kUniform}; + Alias apaa{"apaa_type", &paa}; + Alias aapaa{"aapaa_type", &apaa}; + Pointer paapaa{&aapaa, StorageClass::kUniform}; + Alias apaapaa{"apaapaa_type", &paapaa}; EXPECT_EQ(apaapaa.UnwrapAll(), &paa); } -TEST_F(AliasTypeTest, UnwrapAll_AccessControlPointer) { - U32Type u32; - AccessControlType a{AccessControl::kReadOnly, &u32}; - PointerType pa{&a, StorageClass::kUniform}; +TEST_F(AliasTest, UnwrapAll_AccessControlPointer) { + U32 u32; + AccessControl a{ast::AccessControl::kReadOnly, &u32}; + Pointer pa{&a, StorageClass::kUniform}; EXPECT_EQ(pa.type(), &a); EXPECT_EQ(pa.UnwrapAll(), &u32); EXPECT_EQ(u32.UnwrapAll(), &u32); } -TEST_F(AliasTypeTest, UnwrapAll_PointerAccessControl) { - U32Type u32; - PointerType p{&u32, StorageClass::kUniform}; - AccessControlType a{AccessControl::kReadOnly, &p}; +TEST_F(AliasTest, UnwrapAll_PointerAccessControl) { + U32 u32; + Pointer p{&u32, StorageClass::kUniform}; + AccessControl a{ast::AccessControl::kReadOnly, &p}; EXPECT_EQ(a.type(), &p); EXPECT_EQ(a.UnwrapAll(), &u32); EXPECT_EQ(u32.UnwrapAll(), &u32); } -TEST_F(AliasTypeTest, MinBufferBindingSizeU32) { - U32Type u32; - AliasType alias{"alias", &u32}; +TEST_F(AliasTest, MinBufferBindingSizeU32) { + U32 u32; + Alias alias{"alias", &u32}; EXPECT_EQ(4u, alias.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); } -TEST_F(AliasTypeTest, MinBufferBindingSizeArray) { - U32Type u32; - ArrayType array(&u32, 4); +TEST_F(AliasTest, MinBufferBindingSizeArray) { + U32 u32; + Array array(&u32, 4); ArrayDecorationList decos; decos.push_back(create(4, Source{})); array.set_decorations(decos); - AliasType alias{"alias", &array}; + Alias alias{"alias", &array}; EXPECT_EQ(16u, alias.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); } -TEST_F(AliasTypeTest, MinBufferBindingSizeRuntimeArray) { - U32Type u32; - ArrayType array(&u32); +TEST_F(AliasTest, MinBufferBindingSizeRuntimeArray) { + U32 u32; + Array array(&u32); ArrayDecorationList decos; decos.push_back(create(4, Source{})); array.set_decorations(decos); - AliasType alias{"alias", &array}; + Alias alias{"alias", &array}; EXPECT_EQ(4u, alias.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); } -TEST_F(AliasTypeTest, MinBufferBindingSizeStruct) { - U32Type u32; +TEST_F(AliasTest, MinBufferBindingSizeStruct) { + U32 u32; StructMemberList members; { @@ -203,41 +203,41 @@ TEST_F(AliasTypeTest, MinBufferBindingSizeStruct) { } StructDecorationList decos; - auto* str = create(decos, members); - StructType struct_type("struct_type", str); - AliasType alias{"alias", &struct_type}; + auto* str = create(decos, members); + Struct struct_type("struct_type", str); + Alias alias{"alias", &struct_type}; EXPECT_EQ(16u, alias.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); EXPECT_EQ(8u, alias.MinBufferBindingSize(MemoryLayout::kStorageBuffer)); } -TEST_F(AliasTypeTest, BaseAlignmentU32) { - U32Type u32; - AliasType alias{"alias", &u32}; +TEST_F(AliasTest, BaseAlignmentU32) { + U32 u32; + Alias alias{"alias", &u32}; EXPECT_EQ(4u, alias.BaseAlignment(MemoryLayout::kUniformBuffer)); } -TEST_F(AliasTypeTest, BaseAlignmentArray) { - U32Type u32; - ArrayType array(&u32, 4); +TEST_F(AliasTest, BaseAlignmentArray) { + U32 u32; + Array array(&u32, 4); ArrayDecorationList decos; decos.push_back(create(4, Source{})); array.set_decorations(decos); - AliasType alias{"alias", &array}; + Alias alias{"alias", &array}; EXPECT_EQ(16u, alias.BaseAlignment(MemoryLayout::kUniformBuffer)); } -TEST_F(AliasTypeTest, BaseAlignmentRuntimeArray) { - U32Type u32; - ArrayType array(&u32); +TEST_F(AliasTest, BaseAlignmentRuntimeArray) { + U32 u32; + Array array(&u32); ArrayDecorationList decos; decos.push_back(create(4, Source{})); array.set_decorations(decos); - AliasType alias{"alias", &array}; + Alias alias{"alias", &array}; EXPECT_EQ(16u, alias.BaseAlignment(MemoryLayout::kUniformBuffer)); } -TEST_F(AliasTypeTest, BaseAlignmentStruct) { - U32Type u32; +TEST_F(AliasTest, BaseAlignmentStruct) { + U32 u32; StructMemberList members; { @@ -252,9 +252,9 @@ TEST_F(AliasTypeTest, BaseAlignmentStruct) { } StructDecorationList decos; - auto* str = create(decos, members); - StructType struct_type("struct_type", str); - AliasType alias{"alias", &struct_type}; + auto* str = create(decos, members); + Struct struct_type("struct_type", str); + Alias alias{"alias", &struct_type}; EXPECT_EQ(16u, alias.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(4u, alias.BaseAlignment(MemoryLayout::kStorageBuffer)); } diff --git a/src/ast/type/array_type.cc b/src/ast/type/array_type.cc index 2b4bb8006c..3883e0e7da 100644 --- a/src/ast/type/array_type.cc +++ b/src/ast/type/array_type.cc @@ -23,16 +23,15 @@ namespace tint { namespace ast { namespace type { -ArrayType::ArrayType(Type* subtype) : subtype_(subtype) {} +Array::Array(Type* subtype) : subtype_(subtype) {} -ArrayType::ArrayType(Type* subtype, uint32_t size) - : subtype_(subtype), size_(size) {} +Array::Array(Type* subtype, uint32_t size) : subtype_(subtype), size_(size) {} -ArrayType::ArrayType(ArrayType&&) = default; +Array::Array(Array&&) = default; -ArrayType::~ArrayType() = default; +Array::~Array() = default; -uint64_t ArrayType::MinBufferBindingSize(MemoryLayout mem_layout) const { +uint64_t Array::MinBufferBindingSize(MemoryLayout mem_layout) const { if (!has_array_stride()) { // Arrays in buffers are required to have a stride. return 0; @@ -52,7 +51,7 @@ uint64_t ArrayType::MinBufferBindingSize(MemoryLayout mem_layout) const { } } -uint64_t ArrayType::BaseAlignment(MemoryLayout mem_layout) const { +uint64_t Array::BaseAlignment(MemoryLayout mem_layout) const { if (mem_layout == MemoryLayout::kUniformBuffer) { float aligment = 16; // for a vec4 float unaligned = static_cast(subtype_->BaseAlignment(mem_layout)); @@ -63,7 +62,7 @@ uint64_t ArrayType::BaseAlignment(MemoryLayout mem_layout) const { return 0; } -uint32_t ArrayType::array_stride() const { +uint32_t Array::array_stride() const { for (auto* deco : decos_) { if (auto* stride = deco->As()) { return stride->stride(); @@ -72,7 +71,7 @@ uint32_t ArrayType::array_stride() const { return 0; } -bool ArrayType::has_array_stride() const { +bool Array::has_array_stride() const { for (auto* deco : decos_) { if (deco->Is()) { return true; @@ -81,7 +80,7 @@ bool ArrayType::has_array_stride() const { return false; } -std::string ArrayType::type_name() const { +std::string Array::type_name() const { assert(subtype_); std::string type_name = "__array" + subtype_->type_name(); diff --git a/src/ast/type/array_type.h b/src/ast/type/array_type.h index c44393b341..ef6f6c2fca 100644 --- a/src/ast/type/array_type.h +++ b/src/ast/type/array_type.h @@ -28,18 +28,18 @@ namespace ast { namespace type { /// An array type. If size is zero then it is a runtime array. -class ArrayType : public Castable { +class Array : public Castable { public: /// Constructor for runtime array /// @param subtype the type of the array elements - explicit ArrayType(Type* subtype); + explicit Array(Type* subtype); /// Constructor /// @param subtype the type of the array elements /// @param size the number of elements in the array - ArrayType(Type* subtype, uint32_t size); + Array(Type* subtype, uint32_t size); /// Move constructor - ArrayType(ArrayType&&); - ~ArrayType() override; + Array(Array&&); + ~Array() override; /// @returns true if this is a runtime array. /// i.e. the size is determined at runtime diff --git a/src/ast/type/array_type_test.cc b/src/ast/type/array_type_test.cc index 7a3d3514de..3dbcdda411 100644 --- a/src/ast/type/array_type_test.cc +++ b/src/ast/type/array_type_test.cc @@ -35,111 +35,111 @@ namespace ast { namespace type { namespace { -using ArrayTypeTest = TestHelper; +using ArrayTest = TestHelper; -TEST_F(ArrayTypeTest, CreateSizedArray) { - U32Type u32; - ArrayType arr{&u32, 3}; +TEST_F(ArrayTest, CreateSizedArray) { + U32 u32; + Array arr{&u32, 3}; EXPECT_EQ(arr.type(), &u32); EXPECT_EQ(arr.size(), 3u); - EXPECT_TRUE(arr.Is()); + EXPECT_TRUE(arr.Is()); EXPECT_FALSE(arr.IsRuntimeArray()); } -TEST_F(ArrayTypeTest, CreateRuntimeArray) { - U32Type u32; - ArrayType arr{&u32}; +TEST_F(ArrayTest, CreateRuntimeArray) { + U32 u32; + Array arr{&u32}; EXPECT_EQ(arr.type(), &u32); EXPECT_EQ(arr.size(), 0u); - EXPECT_TRUE(arr.Is()); + EXPECT_TRUE(arr.Is()); EXPECT_TRUE(arr.IsRuntimeArray()); } -TEST_F(ArrayTypeTest, Is) { - I32Type i32; +TEST_F(ArrayTest, Is) { + I32 i32; - ArrayType arr{&i32, 3}; + Array arr{&i32, 3}; Type* ty = &arr; - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_TRUE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_TRUE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); } -TEST_F(ArrayTypeTest, TypeName) { - I32Type i32; - ArrayType arr{&i32}; +TEST_F(ArrayTest, TypeName) { + I32 i32; + Array arr{&i32}; EXPECT_EQ(arr.type_name(), "__array__i32"); } -TEST_F(ArrayTypeTest, TypeName_RuntimeArray) { - I32Type i32; - ArrayType arr{&i32, 3}; +TEST_F(ArrayTest, TypeName_RuntimeArray) { + I32 i32; + Array arr{&i32, 3}; EXPECT_EQ(arr.type_name(), "__array__i32_3"); } -TEST_F(ArrayTypeTest, TypeName_WithStride) { - I32Type i32; +TEST_F(ArrayTest, TypeName_WithStride) { + I32 i32; ArrayDecorationList decos; decos.push_back(create(16, Source{})); - ArrayType arr{&i32, 3}; + Array arr{&i32, 3}; arr.set_decorations(decos); EXPECT_EQ(arr.type_name(), "__array__i32_3_stride_16"); } -TEST_F(ArrayTypeTest, MinBufferBindingSizeNoStride) { - U32Type u32; - ArrayType arr(&u32, 4); +TEST_F(ArrayTest, MinBufferBindingSizeNoStride) { + U32 u32; + Array arr(&u32, 4); EXPECT_EQ(0u, arr.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); } -TEST_F(ArrayTypeTest, MinBufferBindingSizeArray) { - U32Type u32; +TEST_F(ArrayTest, MinBufferBindingSizeArray) { + U32 u32; ArrayDecorationList decos; decos.push_back(create(4, Source{})); - ArrayType arr(&u32, 4); + Array arr(&u32, 4); arr.set_decorations(decos); EXPECT_EQ(16u, arr.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); } -TEST_F(ArrayTypeTest, MinBufferBindingSizeRuntimeArray) { - U32Type u32; +TEST_F(ArrayTest, MinBufferBindingSizeRuntimeArray) { + U32 u32; ArrayDecorationList decos; decos.push_back(create(4, Source{})); - ArrayType arr(&u32); + Array arr(&u32); arr.set_decorations(decos); EXPECT_EQ(4u, arr.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); } -TEST_F(ArrayTypeTest, BaseAlignmentArray) { - U32Type u32; +TEST_F(ArrayTest, BaseAlignmentArray) { + U32 u32; ArrayDecorationList decos; decos.push_back(create(4, Source{})); - ArrayType arr(&u32, 4); + Array arr(&u32, 4); arr.set_decorations(decos); EXPECT_EQ(16u, arr.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(4u, arr.BaseAlignment(MemoryLayout::kStorageBuffer)); } -TEST_F(ArrayTypeTest, BaseAlignmentRuntimeArray) { - U32Type u32; +TEST_F(ArrayTest, BaseAlignmentRuntimeArray) { + U32 u32; ArrayDecorationList decos; decos.push_back(create(4, Source{})); - ArrayType arr(&u32); + Array arr(&u32); arr.set_decorations(decos); EXPECT_EQ(16u, arr.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(4u, arr.BaseAlignment(MemoryLayout::kStorageBuffer)); diff --git a/src/ast/type/bool_type.cc b/src/ast/type/bool_type.cc index 7accedfac1..55bbc3567b 100644 --- a/src/ast/type/bool_type.cc +++ b/src/ast/type/bool_type.cc @@ -18,13 +18,13 @@ namespace tint { namespace ast { namespace type { -BoolType::BoolType() = default; +Bool::Bool() = default; -BoolType::BoolType(BoolType&&) = default; +Bool::Bool(Bool&&) = default; -BoolType::~BoolType() = default; +Bool::~Bool() = default; -std::string BoolType::type_name() const { +std::string Bool::type_name() const { return "__bool"; } diff --git a/src/ast/type/bool_type.h b/src/ast/type/bool_type.h index 5e7ccf6f14..92b08ed184 100644 --- a/src/ast/type/bool_type.h +++ b/src/ast/type/bool_type.h @@ -24,13 +24,13 @@ namespace ast { namespace type { /// A boolean type -class BoolType : public Castable { +class Bool : public Castable { public: /// Constructor - BoolType(); + Bool(); /// Move constructor - BoolType(BoolType&&); - ~BoolType() override; + Bool(Bool&&); + ~Bool() override; /// @returns the name for this type std::string type_name() const override; diff --git a/src/ast/type/bool_type_test.cc b/src/ast/type/bool_type_test.cc index 52e64a7b3c..d6c6f253a1 100644 --- a/src/ast/type/bool_type_test.cc +++ b/src/ast/type/bool_type_test.cc @@ -31,33 +31,33 @@ namespace ast { namespace type { namespace { -using BoolTypeTest = TestHelper; +using BoolTest = TestHelper; -TEST_F(BoolTypeTest, Is) { - BoolType b; +TEST_F(BoolTest, Is) { + Bool b; Type* ty = &b; - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_TRUE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_TRUE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); } -TEST_F(BoolTypeTest, TypeName) { - BoolType b; +TEST_F(BoolTest, TypeName) { + Bool b; EXPECT_EQ(b.type_name(), "__bool"); } -TEST_F(BoolTypeTest, MinBufferBindingSize) { - BoolType b; +TEST_F(BoolTest, MinBufferBindingSize) { + Bool b; EXPECT_EQ(0u, b.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); } diff --git a/src/ast/type/depth_texture_type.cc b/src/ast/type/depth_texture_type.cc index 95a954f3c8..c6153ee397 100644 --- a/src/ast/type/depth_texture_type.cc +++ b/src/ast/type/depth_texture_type.cc @@ -33,15 +33,15 @@ bool IsValidDepthDimension(TextureDimension dim) { } // namespace -DepthTextureType::DepthTextureType(TextureDimension dim) : Base(dim) { +DepthTexture::DepthTexture(TextureDimension dim) : Base(dim) { assert(IsValidDepthDimension(dim)); } -DepthTextureType::DepthTextureType(DepthTextureType&&) = default; +DepthTexture::DepthTexture(DepthTexture&&) = default; -DepthTextureType::~DepthTextureType() = default; +DepthTexture::~DepthTexture() = default; -std::string DepthTextureType::type_name() const { +std::string DepthTexture::type_name() const { std::ostringstream out; out << "__depth_texture_" << dim(); return out.str(); diff --git a/src/ast/type/depth_texture_type.h b/src/ast/type/depth_texture_type.h index 4f58fb045c..49a0a1c67f 100644 --- a/src/ast/type/depth_texture_type.h +++ b/src/ast/type/depth_texture_type.h @@ -24,14 +24,14 @@ namespace ast { namespace type { /// A depth texture type. -class DepthTextureType : public Castable { +class DepthTexture : public Castable { public: /// Constructor /// @param dim the dimensionality of the texture - explicit DepthTextureType(TextureDimension dim); + explicit DepthTexture(TextureDimension dim); /// Move constructor - DepthTextureType(DepthTextureType&&); - ~DepthTextureType() override; + DepthTexture(DepthTexture&&); + ~DepthTexture() override; /// @returns the name for this type std::string type_name() const override; diff --git a/src/ast/type/depth_texture_type_test.cc b/src/ast/type/depth_texture_type_test.cc index 4b39585455..b956f8905b 100644 --- a/src/ast/type/depth_texture_type_test.cc +++ b/src/ast/type/depth_texture_type_test.cc @@ -34,46 +34,46 @@ namespace ast { namespace type { namespace { -using DepthTextureTypeTest = TestHelper; +using DepthTextureTest = TestHelper; -TEST_F(DepthTextureTypeTest, Is) { - DepthTextureType d(TextureDimension::kCube); +TEST_F(DepthTextureTest, Is) { + DepthTexture d(TextureDimension::kCube); Type* ty = &d; - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_TRUE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_TRUE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); } -TEST_F(DepthTextureTypeTest, IsTextureType) { - DepthTextureType d(TextureDimension::kCube); - TextureType* ty = &d; - EXPECT_TRUE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); +TEST_F(DepthTextureTest, IsTexture) { + DepthTexture d(TextureDimension::kCube); + Texture* ty = &d; + EXPECT_TRUE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); } -TEST_F(DepthTextureTypeTest, Dim) { - DepthTextureType d(TextureDimension::kCube); +TEST_F(DepthTextureTest, Dim) { + DepthTexture d(TextureDimension::kCube); EXPECT_EQ(d.dim(), TextureDimension::kCube); } -TEST_F(DepthTextureTypeTest, TypeName) { - DepthTextureType d(TextureDimension::kCube); +TEST_F(DepthTextureTest, TypeName) { + DepthTexture d(TextureDimension::kCube); EXPECT_EQ(d.type_name(), "__depth_texture_cube"); } -TEST_F(DepthTextureTypeTest, MinBufferBindingSize) { - DepthTextureType d(TextureDimension::kCube); +TEST_F(DepthTextureTest, MinBufferBindingSize) { + DepthTexture d(TextureDimension::kCube); EXPECT_EQ(0u, d.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); } diff --git a/src/ast/type/f32_type.cc b/src/ast/type/f32_type.cc index 08e37c233e..7712aec7c5 100644 --- a/src/ast/type/f32_type.cc +++ b/src/ast/type/f32_type.cc @@ -18,21 +18,21 @@ namespace tint { namespace ast { namespace type { -F32Type::F32Type() = default; +F32::F32() = default; -F32Type::F32Type(F32Type&&) = default; +F32::F32(F32&&) = default; -F32Type::~F32Type() = default; +F32::~F32() = default; -std::string F32Type::type_name() const { +std::string F32::type_name() const { return "__f32"; } -uint64_t F32Type::MinBufferBindingSize(MemoryLayout) const { +uint64_t F32::MinBufferBindingSize(MemoryLayout) const { return 4; } -uint64_t F32Type::BaseAlignment(MemoryLayout) const { +uint64_t F32::BaseAlignment(MemoryLayout) const { return 4; } diff --git a/src/ast/type/f32_type.h b/src/ast/type/f32_type.h index e5ceb7fc21..92f25f058d 100644 --- a/src/ast/type/f32_type.h +++ b/src/ast/type/f32_type.h @@ -24,13 +24,13 @@ namespace ast { namespace type { /// A float 32 type -class F32Type : public Castable { +class F32 : public Castable { public: /// Constructor - F32Type(); + F32(); /// Move constructor - F32Type(F32Type&&); - ~F32Type() override; + F32(F32&&); + ~F32() override; /// @returns the name for this type std::string type_name() const override; diff --git a/src/ast/type/f32_type_test.cc b/src/ast/type/f32_type_test.cc index 8d356eeebc..0570b7e239 100644 --- a/src/ast/type/f32_type_test.cc +++ b/src/ast/type/f32_type_test.cc @@ -31,38 +31,38 @@ namespace ast { namespace type { namespace { -using F32TypeTest = TestHelper; +using F32Test = TestHelper; -TEST_F(F32TypeTest, Is) { - F32Type f; +TEST_F(F32Test, Is) { + F32 f; Type* ty = &f; - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_TRUE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_TRUE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); } -TEST_F(F32TypeTest, TypeName) { - F32Type f; +TEST_F(F32Test, TypeName) { + F32 f; EXPECT_EQ(f.type_name(), "__f32"); } -TEST_F(F32TypeTest, MinBufferBindingSize) { - F32Type f; +TEST_F(F32Test, MinBufferBindingSize) { + F32 f; EXPECT_EQ(4u, f.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); } -TEST_F(F32TypeTest, BaseAlignment) { - F32Type f; +TEST_F(F32Test, BaseAlignment) { + F32 f; EXPECT_EQ(4u, f.BaseAlignment(MemoryLayout::kUniformBuffer)); } diff --git a/src/ast/type/i32_type.cc b/src/ast/type/i32_type.cc index c3c2838ac9..eced6b691c 100644 --- a/src/ast/type/i32_type.cc +++ b/src/ast/type/i32_type.cc @@ -18,21 +18,21 @@ namespace tint { namespace ast { namespace type { -I32Type::I32Type() = default; +I32::I32() = default; -I32Type::I32Type(I32Type&&) = default; +I32::I32(I32&&) = default; -I32Type::~I32Type() = default; +I32::~I32() = default; -std::string I32Type::type_name() const { +std::string I32::type_name() const { return "__i32"; } -uint64_t I32Type::MinBufferBindingSize(MemoryLayout) const { +uint64_t I32::MinBufferBindingSize(MemoryLayout) const { return 4; } -uint64_t I32Type::BaseAlignment(MemoryLayout) const { +uint64_t I32::BaseAlignment(MemoryLayout) const { return 4; } diff --git a/src/ast/type/i32_type.h b/src/ast/type/i32_type.h index e1b9d9f34e..4ad01158c6 100644 --- a/src/ast/type/i32_type.h +++ b/src/ast/type/i32_type.h @@ -24,13 +24,13 @@ namespace ast { namespace type { /// A signed int 32 type. -class I32Type : public Castable { +class I32 : public Castable { public: /// Constructor - I32Type(); + I32(); /// Move constructor - I32Type(I32Type&&); - ~I32Type() override; + I32(I32&&); + ~I32() override; /// @returns the name for this type std::string type_name() const override; diff --git a/src/ast/type/i32_type_test.cc b/src/ast/type/i32_type_test.cc index fc9c75a320..0333d01d34 100644 --- a/src/ast/type/i32_type_test.cc +++ b/src/ast/type/i32_type_test.cc @@ -31,38 +31,38 @@ namespace ast { namespace type { namespace { -using I32TypeTest = TestHelper; +using I32Test = TestHelper; -TEST_F(I32TypeTest, Is) { - I32Type i; +TEST_F(I32Test, Is) { + I32 i; Type* ty = &i; - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_TRUE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_TRUE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); } -TEST_F(I32TypeTest, TypeName) { - I32Type i; +TEST_F(I32Test, TypeName) { + I32 i; EXPECT_EQ(i.type_name(), "__i32"); } -TEST_F(I32TypeTest, MinBufferBindingSize) { - I32Type i; +TEST_F(I32Test, MinBufferBindingSize) { + I32 i; EXPECT_EQ(4u, i.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); } -TEST_F(I32TypeTest, BaseAlignment) { - I32Type i; +TEST_F(I32Test, BaseAlignment) { + I32 i; EXPECT_EQ(4u, i.BaseAlignment(MemoryLayout::kUniformBuffer)); } diff --git a/src/ast/type/matrix_type.cc b/src/ast/type/matrix_type.cc index da2ef681dc..7065b7fcba 100644 --- a/src/ast/type/matrix_type.cc +++ b/src/ast/type/matrix_type.cc @@ -23,7 +23,7 @@ namespace tint { namespace ast { namespace type { -MatrixType::MatrixType(Type* subtype, uint32_t rows, uint32_t columns) +Matrix::Matrix(Type* subtype, uint32_t rows, uint32_t columns) : subtype_(subtype), rows_(rows), columns_(columns) { assert(rows > 1); assert(rows < 5); @@ -31,24 +31,24 @@ MatrixType::MatrixType(Type* subtype, uint32_t rows, uint32_t columns) assert(columns < 5); } -MatrixType::MatrixType(MatrixType&&) = default; +Matrix::Matrix(Matrix&&) = default; -MatrixType::~MatrixType() = default; +Matrix::~Matrix() = default; -std::string MatrixType::type_name() const { +std::string Matrix::type_name() const { return "__mat_" + std::to_string(rows_) + "_" + std::to_string(columns_) + subtype_->type_name(); } -uint64_t MatrixType::MinBufferBindingSize(MemoryLayout mem_layout) const { - VectorType vec(subtype_, rows_); +uint64_t Matrix::MinBufferBindingSize(MemoryLayout mem_layout) const { + Vector vec(subtype_, rows_); return (columns_ - 1) * vec.BaseAlignment(mem_layout) + vec.MinBufferBindingSize(mem_layout); } -uint64_t MatrixType::BaseAlignment(MemoryLayout mem_layout) const { - VectorType vec(subtype_, rows_); - ArrayType arr(&vec, columns_); +uint64_t Matrix::BaseAlignment(MemoryLayout mem_layout) const { + Vector vec(subtype_, rows_); + Array arr(&vec, columns_); return arr.BaseAlignment(mem_layout); } diff --git a/src/ast/type/matrix_type.h b/src/ast/type/matrix_type.h index d08d09e4a2..2943a03ac9 100644 --- a/src/ast/type/matrix_type.h +++ b/src/ast/type/matrix_type.h @@ -24,16 +24,16 @@ namespace ast { namespace type { /// A matrix type -class MatrixType : public Castable { +class Matrix : public Castable { public: /// Constructor /// @param subtype type matrix type /// @param rows the number of rows in the matrix /// @param columns the number of columns in the matrix - MatrixType(Type* subtype, uint32_t rows, uint32_t columns); + Matrix(Type* subtype, uint32_t rows, uint32_t columns); /// Move constructor - MatrixType(MatrixType&&); - ~MatrixType() override; + Matrix(Matrix&&); + ~Matrix() override; /// @returns the type of the matrix Type* type() const { return subtype_; } diff --git a/src/ast/type/matrix_type_test.cc b/src/ast/type/matrix_type_test.cc index 514d61d9c1..fb4c1a7613 100644 --- a/src/ast/type/matrix_type_test.cc +++ b/src/ast/type/matrix_type_test.cc @@ -31,93 +31,93 @@ namespace ast { namespace type { namespace { -using MatrixTypeTest = TestHelper; +using MatrixTest = TestHelper; -TEST_F(MatrixTypeTest, Creation) { - I32Type i32; - MatrixType m{&i32, 2, 4}; +TEST_F(MatrixTest, Creation) { + I32 i32; + Matrix m{&i32, 2, 4}; EXPECT_EQ(m.type(), &i32); EXPECT_EQ(m.rows(), 2u); EXPECT_EQ(m.columns(), 4u); } -TEST_F(MatrixTypeTest, Is) { - I32Type i32; - MatrixType m{&i32, 2, 3}; +TEST_F(MatrixTest, Is) { + I32 i32; + Matrix m{&i32, 2, 3}; Type* ty = &m; - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_TRUE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_TRUE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); } -TEST_F(MatrixTypeTest, TypeName) { - I32Type i32; - MatrixType m{&i32, 2, 3}; +TEST_F(MatrixTest, TypeName) { + I32 i32; + Matrix m{&i32, 2, 3}; EXPECT_EQ(m.type_name(), "__mat_2_3__i32"); } -TEST_F(MatrixTypeTest, MinBufferBindingSize4x2) { - I32Type i32; - MatrixType m{&i32, 4, 2}; +TEST_F(MatrixTest, MinBufferBindingSize4x2) { + I32 i32; + Matrix m{&i32, 4, 2}; EXPECT_EQ(32u, m.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); EXPECT_EQ(32u, m.MinBufferBindingSize(MemoryLayout::kStorageBuffer)); } -TEST_F(MatrixTypeTest, MinBufferBindingSize3x2) { - I32Type i32; - MatrixType m{&i32, 3, 2}; +TEST_F(MatrixTest, MinBufferBindingSize3x2) { + I32 i32; + Matrix m{&i32, 3, 2}; EXPECT_EQ(28u, m.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); EXPECT_EQ(28u, m.MinBufferBindingSize(MemoryLayout::kStorageBuffer)); } -TEST_F(MatrixTypeTest, MinBufferBindingSize2x3) { - I32Type i32; - MatrixType m{&i32, 2, 3}; +TEST_F(MatrixTest, MinBufferBindingSize2x3) { + I32 i32; + Matrix m{&i32, 2, 3}; EXPECT_EQ(24u, m.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); EXPECT_EQ(24u, m.MinBufferBindingSize(MemoryLayout::kStorageBuffer)); } -TEST_F(MatrixTypeTest, MinBufferBindingSize2x2) { - I32Type i32; - MatrixType m{&i32, 2, 2}; +TEST_F(MatrixTest, MinBufferBindingSize2x2) { + I32 i32; + Matrix m{&i32, 2, 2}; EXPECT_EQ(16u, m.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); EXPECT_EQ(16u, m.MinBufferBindingSize(MemoryLayout::kStorageBuffer)); } -TEST_F(MatrixTypeTest, BaseAlignment4x2) { - I32Type i32; - MatrixType m{&i32, 4, 2}; +TEST_F(MatrixTest, BaseAlignment4x2) { + I32 i32; + Matrix m{&i32, 4, 2}; EXPECT_EQ(16u, m.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(16u, m.BaseAlignment(MemoryLayout::kStorageBuffer)); } -TEST_F(MatrixTypeTest, BaseAlignment3x2) { - I32Type i32; - MatrixType m{&i32, 3, 2}; +TEST_F(MatrixTest, BaseAlignment3x2) { + I32 i32; + Matrix m{&i32, 3, 2}; EXPECT_EQ(16u, m.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(16u, m.BaseAlignment(MemoryLayout::kStorageBuffer)); } -TEST_F(MatrixTypeTest, BaseAlignment2x3) { - I32Type i32; - MatrixType m{&i32, 2, 3}; +TEST_F(MatrixTest, BaseAlignment2x3) { + I32 i32; + Matrix m{&i32, 2, 3}; EXPECT_EQ(16u, m.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(8u, m.BaseAlignment(MemoryLayout::kStorageBuffer)); } -TEST_F(MatrixTypeTest, BaseAlignment2x2) { - I32Type i32; - MatrixType m{&i32, 2, 2}; +TEST_F(MatrixTest, BaseAlignment2x2) { + I32 i32; + Matrix m{&i32, 2, 2}; EXPECT_EQ(16u, m.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(8u, m.BaseAlignment(MemoryLayout::kStorageBuffer)); } diff --git a/src/ast/type/multisampled_texture_type.cc b/src/ast/type/multisampled_texture_type.cc index bcca076497..d73ad18649 100644 --- a/src/ast/type/multisampled_texture_type.cc +++ b/src/ast/type/multisampled_texture_type.cc @@ -21,19 +21,16 @@ namespace tint { namespace ast { namespace type { -MultisampledTextureType::MultisampledTextureType(TextureDimension dim, - Type* type) +MultisampledTexture::MultisampledTexture(TextureDimension dim, Type* type) : Base(dim), type_(type) { assert(type_); } -MultisampledTextureType::MultisampledTextureType(MultisampledTextureType&&) = - default; +MultisampledTexture::MultisampledTexture(MultisampledTexture&&) = default; -MultisampledTextureType::~MultisampledTextureType() = default; +MultisampledTexture::~MultisampledTexture() = default; - -std::string MultisampledTextureType::type_name() const { +std::string MultisampledTexture::type_name() const { std::ostringstream out; out << "__multisampled_texture_" << dim() << type_->type_name(); return out.str(); diff --git a/src/ast/type/multisampled_texture_type.h b/src/ast/type/multisampled_texture_type.h index 2cebe1fa79..351e9f83e7 100644 --- a/src/ast/type/multisampled_texture_type.h +++ b/src/ast/type/multisampled_texture_type.h @@ -24,16 +24,15 @@ namespace ast { namespace type { /// A multisampled texture type. -class MultisampledTextureType - : public Castable { +class MultisampledTexture : public Castable { public: /// Constructor /// @param dim the dimensionality of the texture /// @param type the data type of the multisampled texture - MultisampledTextureType(TextureDimension dim, Type* type); + MultisampledTexture(TextureDimension dim, Type* type); /// Move constructor - MultisampledTextureType(MultisampledTextureType&&); - ~MultisampledTextureType() override; + MultisampledTexture(MultisampledTexture&&); + ~MultisampledTexture() override; /// @returns the subtype of the sampled texture Type* type() const { return type_; } diff --git a/src/ast/type/multisampled_texture_type_test.cc b/src/ast/type/multisampled_texture_type_test.cc index 8b1aa211ec..99bb0e5971 100644 --- a/src/ast/type/multisampled_texture_type_test.cc +++ b/src/ast/type/multisampled_texture_type_test.cc @@ -34,58 +34,58 @@ namespace ast { namespace type { namespace { -using MultisampledTextureTypeTest = TestHelper; +using MultisampledTextureTest = TestHelper; -TEST_F(MultisampledTextureTypeTest, Is) { - F32Type f32; - MultisampledTextureType s(TextureDimension::kCube, &f32); +TEST_F(MultisampledTextureTest, Is) { + F32 f32; + MultisampledTexture s(TextureDimension::kCube, &f32); Type* ty = &s; - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_TRUE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_TRUE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); } -TEST_F(MultisampledTextureTypeTest, IsTextureType) { - F32Type f32; - MultisampledTextureType s(TextureDimension::kCube, &f32); - TextureType* ty = &s; - EXPECT_FALSE(ty->Is()); - EXPECT_TRUE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); +TEST_F(MultisampledTextureTest, IsTexture) { + F32 f32; + MultisampledTexture s(TextureDimension::kCube, &f32); + Texture* ty = &s; + EXPECT_FALSE(ty->Is()); + EXPECT_TRUE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); } -TEST_F(MultisampledTextureTypeTest, Dim) { - F32Type f32; - MultisampledTextureType s(TextureDimension::k3d, &f32); +TEST_F(MultisampledTextureTest, Dim) { + F32 f32; + MultisampledTexture s(TextureDimension::k3d, &f32); EXPECT_EQ(s.dim(), TextureDimension::k3d); } -TEST_F(MultisampledTextureTypeTest, Type) { - F32Type f32; - MultisampledTextureType s(TextureDimension::k3d, &f32); +TEST_F(MultisampledTextureTest, Type) { + F32 f32; + MultisampledTexture s(TextureDimension::k3d, &f32); EXPECT_EQ(s.type(), &f32); } -TEST_F(MultisampledTextureTypeTest, TypeName) { - F32Type f32; - MultisampledTextureType s(TextureDimension::k3d, &f32); +TEST_F(MultisampledTextureTest, TypeName) { + F32 f32; + MultisampledTexture s(TextureDimension::k3d, &f32); EXPECT_EQ(s.type_name(), "__multisampled_texture_3d__f32"); } -TEST_F(MultisampledTextureTypeTest, MinBufferBindingSize) { - F32Type f32; - MultisampledTextureType s(TextureDimension::k3d, &f32); +TEST_F(MultisampledTextureTest, MinBufferBindingSize) { + F32 f32; + MultisampledTexture s(TextureDimension::k3d, &f32); EXPECT_EQ(0u, s.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); } diff --git a/src/ast/type/pointer_type.cc b/src/ast/type/pointer_type.cc index a577e78dc6..745349145d 100644 --- a/src/ast/type/pointer_type.cc +++ b/src/ast/type/pointer_type.cc @@ -18,18 +18,18 @@ namespace tint { namespace ast { namespace type { -PointerType::PointerType(Type* subtype, StorageClass storage_class) +Pointer::Pointer(Type* subtype, StorageClass storage_class) : subtype_(subtype), storage_class_(storage_class) {} -std::string PointerType::type_name() const { +std::string Pointer::type_name() const { std::ostringstream out; out << "__ptr_" << storage_class_ << subtype_->type_name(); return out.str(); } -PointerType::PointerType(PointerType&&) = default; +Pointer::Pointer(Pointer&&) = default; -PointerType::~PointerType() = default; +Pointer::~Pointer() = default; } // namespace type } // namespace ast diff --git a/src/ast/type/pointer_type.h b/src/ast/type/pointer_type.h index 9dbf71b8f6..07a3c6beab 100644 --- a/src/ast/type/pointer_type.h +++ b/src/ast/type/pointer_type.h @@ -26,15 +26,15 @@ namespace ast { namespace type { /// A pointer type. -class PointerType : public Castable { +class Pointer : public Castable { public: /// Construtor /// @param subtype the pointee type /// @param storage_class the storage class of the pointer - explicit PointerType(Type* subtype, StorageClass storage_class); + explicit Pointer(Type* subtype, StorageClass storage_class); /// Move constructor - PointerType(PointerType&&); - ~PointerType() override; + Pointer(Pointer&&); + ~Pointer() override; /// @returns the pointee type Type* type() const { return subtype_; } diff --git a/src/ast/type/pointer_type_test.cc b/src/ast/type/pointer_type_test.cc index f50a6a715d..0089c4388e 100644 --- a/src/ast/type/pointer_type_test.cc +++ b/src/ast/type/pointer_type_test.cc @@ -31,37 +31,37 @@ namespace ast { namespace type { namespace { -using PointerTypeTest = TestHelper; +using PointerTest = TestHelper; -TEST_F(PointerTypeTest, Creation) { - I32Type i32; - PointerType p{&i32, StorageClass::kStorageBuffer}; +TEST_F(PointerTest, Creation) { + I32 i32; + Pointer p{&i32, StorageClass::kStorageBuffer}; EXPECT_EQ(p.type(), &i32); EXPECT_EQ(p.storage_class(), StorageClass::kStorageBuffer); } -TEST_F(PointerTypeTest, Is) { - I32Type i32; - PointerType p{&i32, StorageClass::kFunction}; +TEST_F(PointerTest, Is) { + I32 i32; + Pointer p{&i32, StorageClass::kFunction}; Type* ty = &p; - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_TRUE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_TRUE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); } -TEST_F(PointerTypeTest, TypeName) { - I32Type i32; - PointerType p{&i32, StorageClass::kWorkgroup}; +TEST_F(PointerTest, TypeName) { + I32 i32; + Pointer p{&i32, StorageClass::kWorkgroup}; EXPECT_EQ(p.type_name(), "__ptr_workgroup__i32"); } diff --git a/src/ast/type/sampled_texture_type.cc b/src/ast/type/sampled_texture_type.cc index dc03bebce8..490a5863a2 100644 --- a/src/ast/type/sampled_texture_type.cc +++ b/src/ast/type/sampled_texture_type.cc @@ -21,16 +21,16 @@ namespace tint { namespace ast { namespace type { -SampledTextureType::SampledTextureType(TextureDimension dim, Type* type) +SampledTexture::SampledTexture(TextureDimension dim, Type* type) : Base(dim), type_(type) { assert(type_); } -SampledTextureType::SampledTextureType(SampledTextureType&&) = default; +SampledTexture::SampledTexture(SampledTexture&&) = default; -SampledTextureType::~SampledTextureType() = default; +SampledTexture::~SampledTexture() = default; -std::string SampledTextureType::type_name() const { +std::string SampledTexture::type_name() const { std::ostringstream out; out << "__sampled_texture_" << dim() << type_->type_name(); return out.str(); diff --git a/src/ast/type/sampled_texture_type.h b/src/ast/type/sampled_texture_type.h index a270a95272..3c6abafda3 100644 --- a/src/ast/type/sampled_texture_type.h +++ b/src/ast/type/sampled_texture_type.h @@ -24,15 +24,15 @@ namespace ast { namespace type { /// A sampled texture type. -class SampledTextureType : public Castable { +class SampledTexture : public Castable { public: /// Constructor /// @param dim the dimensionality of the texture /// @param type the data type of the sampled texture - SampledTextureType(TextureDimension dim, Type* type); + SampledTexture(TextureDimension dim, Type* type); /// Move constructor - SampledTextureType(SampledTextureType&&); - ~SampledTextureType() override; + SampledTexture(SampledTexture&&); + ~SampledTexture() override; /// @returns the subtype of the sampled texture Type* type() const { return type_; } diff --git a/src/ast/type/sampled_texture_type_test.cc b/src/ast/type/sampled_texture_type_test.cc index f0049a4909..5c6bcb4493 100644 --- a/src/ast/type/sampled_texture_type_test.cc +++ b/src/ast/type/sampled_texture_type_test.cc @@ -33,57 +33,57 @@ namespace ast { namespace type { namespace { -using SampledTextureTypeTest = TestHelper; +using SampledTextureTest = TestHelper; -TEST_F(SampledTextureTypeTest, Is) { - F32Type f32; - SampledTextureType s(TextureDimension::kCube, &f32); +TEST_F(SampledTextureTest, Is) { + F32 f32; + SampledTexture s(TextureDimension::kCube, &f32); Type* ty = &s; - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_TRUE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_TRUE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); } -TEST_F(SampledTextureTypeTest, IsTextureType) { - F32Type f32; - SampledTextureType s(TextureDimension::kCube, &f32); - TextureType* ty = &s; - EXPECT_FALSE(ty->Is()); - EXPECT_TRUE(ty->Is()); - EXPECT_FALSE(ty->Is()); +TEST_F(SampledTextureTest, IsTexture) { + F32 f32; + SampledTexture s(TextureDimension::kCube, &f32); + Texture* ty = &s; + EXPECT_FALSE(ty->Is()); + EXPECT_TRUE(ty->Is()); + EXPECT_FALSE(ty->Is()); } -TEST_F(SampledTextureTypeTest, Dim) { - F32Type f32; - SampledTextureType s(TextureDimension::k3d, &f32); +TEST_F(SampledTextureTest, Dim) { + F32 f32; + SampledTexture s(TextureDimension::k3d, &f32); EXPECT_EQ(s.dim(), TextureDimension::k3d); } -TEST_F(SampledTextureTypeTest, Type) { - F32Type f32; - SampledTextureType s(TextureDimension::k3d, &f32); +TEST_F(SampledTextureTest, Type) { + F32 f32; + SampledTexture s(TextureDimension::k3d, &f32); EXPECT_EQ(s.type(), &f32); } -TEST_F(SampledTextureTypeTest, TypeName) { - F32Type f32; - SampledTextureType s(TextureDimension::k3d, &f32); +TEST_F(SampledTextureTest, TypeName) { + F32 f32; + SampledTexture s(TextureDimension::k3d, &f32); EXPECT_EQ(s.type_name(), "__sampled_texture_3d__f32"); } -TEST_F(SampledTextureTypeTest, MinBufferBindingSize) { - F32Type f32; - SampledTextureType s(TextureDimension::kCube, &f32); +TEST_F(SampledTextureTest, MinBufferBindingSize) { + F32 f32; + SampledTexture s(TextureDimension::kCube, &f32); EXPECT_EQ(0u, s.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); } diff --git a/src/ast/type/sampler_type.cc b/src/ast/type/sampler_type.cc index c183b432d0..5d61348bb7 100644 --- a/src/ast/type/sampler_type.cc +++ b/src/ast/type/sampler_type.cc @@ -30,13 +30,13 @@ std::ostream& operator<<(std::ostream& out, SamplerKind kind) { return out; } -SamplerType::SamplerType(SamplerKind kind) : kind_(kind) {} +Sampler::Sampler(SamplerKind kind) : kind_(kind) {} -SamplerType::SamplerType(SamplerType&&) = default; +Sampler::Sampler(Sampler&&) = default; -SamplerType::~SamplerType() = default; +Sampler::~Sampler() = default; -std::string SamplerType::type_name() const { +std::string Sampler::type_name() const { return std::string("__sampler_") + (kind_ == SamplerKind::kSampler ? "sampler" : "comparison"); } diff --git a/src/ast/type/sampler_type.h b/src/ast/type/sampler_type.h index c83c44a24f..0d2b914ae1 100644 --- a/src/ast/type/sampler_type.h +++ b/src/ast/type/sampler_type.h @@ -34,14 +34,14 @@ enum class SamplerKind { std::ostream& operator<<(std::ostream& out, SamplerKind kind); /// A sampler type. -class SamplerType : public Castable { +class Sampler : public Castable { public: /// Constructor /// @param kind the kind of sampler - explicit SamplerType(SamplerKind kind); + explicit Sampler(SamplerKind kind); /// Move constructor - SamplerType(SamplerType&&); - ~SamplerType() override; + Sampler(Sampler&&); + ~Sampler() override; /// @returns the sampler type SamplerKind kind() const { return kind_; } diff --git a/src/ast/type/sampler_type_test.cc b/src/ast/type/sampler_type_test.cc index 2353c8a8cc..9641aecfff 100644 --- a/src/ast/type/sampler_type_test.cc +++ b/src/ast/type/sampler_type_test.cc @@ -32,49 +32,49 @@ namespace ast { namespace type { namespace { -using SamplerTypeTest = TestHelper; +using SamplerTest = TestHelper; -TEST_F(SamplerTypeTest, Creation) { - SamplerType s{SamplerKind::kSampler}; +TEST_F(SamplerTest, Creation) { + Sampler s{SamplerKind::kSampler}; EXPECT_EQ(s.kind(), SamplerKind::kSampler); } -TEST_F(SamplerTypeTest, Creation_ComparisonSampler) { - SamplerType s{SamplerKind::kComparisonSampler}; +TEST_F(SamplerTest, Creation_ComparisonSampler) { + Sampler s{SamplerKind::kComparisonSampler}; EXPECT_EQ(s.kind(), SamplerKind::kComparisonSampler); EXPECT_TRUE(s.IsComparison()); } -TEST_F(SamplerTypeTest, Is) { - SamplerType s{SamplerKind::kSampler}; +TEST_F(SamplerTest, Is) { + Sampler s{SamplerKind::kSampler}; Type* ty = &s; - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_TRUE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_TRUE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); } -TEST_F(SamplerTypeTest, TypeName_Sampler) { - SamplerType s{SamplerKind::kSampler}; +TEST_F(SamplerTest, TypeName_Sampler) { + Sampler s{SamplerKind::kSampler}; EXPECT_EQ(s.type_name(), "__sampler_sampler"); } -TEST_F(SamplerTypeTest, TypeName_Comparison) { - SamplerType s{SamplerKind::kComparisonSampler}; +TEST_F(SamplerTest, TypeName_Comparison) { + Sampler s{SamplerKind::kComparisonSampler}; EXPECT_EQ(s.type_name(), "__sampler_comparison"); } -TEST_F(SamplerTypeTest, MinBufferBindingSize) { - SamplerType s{SamplerKind::kSampler}; +TEST_F(SamplerTest, MinBufferBindingSize) { + Sampler s{SamplerKind::kSampler}; EXPECT_EQ(0u, s.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); } diff --git a/src/ast/type/storage_texture_type.cc b/src/ast/type/storage_texture_type.cc index 963e4911ae..72fd648e0d 100644 --- a/src/ast/type/storage_texture_type.cc +++ b/src/ast/type/storage_texture_type.cc @@ -150,26 +150,26 @@ std::ostream& operator<<(std::ostream& out, ImageFormat format) { return out; } -StorageTextureType::StorageTextureType(TextureDimension dim, - AccessControl access, - ImageFormat format) +StorageTexture::StorageTexture(TextureDimension dim, + ast::AccessControl access, + ImageFormat format) : Base(dim), access_(access), image_format_(format) { assert(IsValidStorageDimension(dim)); } -void StorageTextureType::set_type(Type* const type) { +void StorageTexture::set_type(Type* const type) { type_ = type; } -Type* StorageTextureType::type() const { +Type* StorageTexture::type() const { return type_; } -StorageTextureType::StorageTextureType(StorageTextureType&&) = default; +StorageTexture::StorageTexture(StorageTexture&&) = default; -StorageTextureType::~StorageTextureType() = default; +StorageTexture::~StorageTexture() = default; -std::string StorageTextureType::type_name() const { +std::string StorageTexture::type_name() const { std::ostringstream out; out << "__storage_texture_" << access_ << "_" << dim() << "_" << image_format_; diff --git a/src/ast/type/storage_texture_type.h b/src/ast/type/storage_texture_type.h index 84d6e6ec20..d4545399bc 100644 --- a/src/ast/type/storage_texture_type.h +++ b/src/ast/type/storage_texture_type.h @@ -66,19 +66,19 @@ enum class ImageFormat { std::ostream& operator<<(std::ostream& out, ImageFormat dim); /// A storage texture type. -class StorageTextureType : public Castable { +class StorageTexture : public Castable { public: /// Constructor /// @param dim the dimensionality of the texture /// @param access the access type for the texture /// @param format the image format of the texture - StorageTextureType(TextureDimension dim, - AccessControl access, - ImageFormat format); + StorageTexture(TextureDimension dim, + ast::AccessControl access, + ImageFormat format); /// Move constructor - StorageTextureType(StorageTextureType&&); - ~StorageTextureType() override; + StorageTexture(StorageTexture&&); + ~StorageTexture() override; /// @param type the subtype of the storage texture void set_type(Type* const type); @@ -87,7 +87,7 @@ class StorageTextureType : public Castable { Type* type() const; /// @returns the storage access - AccessControl access() const { return access_; } + ast::AccessControl access() const { return access_; } /// @returns the image format ImageFormat image_format() const { return image_format_; } @@ -97,7 +97,7 @@ class StorageTextureType : public Castable { private: Type* type_ = nullptr; - AccessControl access_ = AccessControl::kReadOnly; + ast::AccessControl access_ = ast::AccessControl::kReadOnly; ImageFormat image_format_ = ImageFormat::kRgba32Float; }; diff --git a/src/ast/type/storage_texture_type_test.cc b/src/ast/type/storage_texture_type_test.cc index 2664f1d830..6eb20a5ac7 100644 --- a/src/ast/type/storage_texture_type_test.cc +++ b/src/ast/type/storage_texture_type_test.cc @@ -37,107 +37,105 @@ namespace ast { namespace type { namespace { -using StorageTextureTypeTest = TestHelper; +using StorageTextureTest = TestHelper; -TEST_F(StorageTextureTypeTest, Is) { - StorageTextureType s(TextureDimension::k2dArray, AccessControl::kReadOnly, - ImageFormat::kRgba32Float); +TEST_F(StorageTextureTest, Is) { + StorageTexture s(TextureDimension::k2dArray, ast::AccessControl::kReadOnly, + ImageFormat::kRgba32Float); Type* ty = &s; - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_TRUE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_TRUE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); } -TEST_F(StorageTextureTypeTest, IsTextureType) { - StorageTextureType s(TextureDimension::k2dArray, AccessControl::kReadOnly, - ImageFormat::kRgba32Float); - TextureType* ty = &s; - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_TRUE(ty->Is()); +TEST_F(StorageTextureTest, IsTexture) { + StorageTexture s(TextureDimension::k2dArray, ast::AccessControl::kReadOnly, + ImageFormat::kRgba32Float); + Texture* ty = &s; + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_TRUE(ty->Is()); } -TEST_F(StorageTextureTypeTest, Dim) { - StorageTextureType s(TextureDimension::k2dArray, AccessControl::kReadOnly, - ImageFormat::kRgba32Float); +TEST_F(StorageTextureTest, Dim) { + StorageTexture s(TextureDimension::k2dArray, ast::AccessControl::kReadOnly, + ImageFormat::kRgba32Float); EXPECT_EQ(s.dim(), TextureDimension::k2dArray); } -TEST_F(StorageTextureTypeTest, Access) { - StorageTextureType s(TextureDimension::k2dArray, AccessControl::kReadOnly, - ImageFormat::kRgba32Float); - EXPECT_EQ(s.access(), AccessControl::kReadOnly); +TEST_F(StorageTextureTest, Access) { + StorageTexture s(TextureDimension::k2dArray, ast::AccessControl::kReadOnly, + ImageFormat::kRgba32Float); + EXPECT_EQ(s.access(), ast::AccessControl::kReadOnly); } -TEST_F(StorageTextureTypeTest, Format) { - StorageTextureType s(TextureDimension::k2dArray, AccessControl::kReadOnly, - ImageFormat::kRgba32Float); +TEST_F(StorageTextureTest, Format) { + StorageTexture s(TextureDimension::k2dArray, ast::AccessControl::kReadOnly, + ImageFormat::kRgba32Float); EXPECT_EQ(s.image_format(), ImageFormat::kRgba32Float); } -TEST_F(StorageTextureTypeTest, TypeName) { - StorageTextureType s(TextureDimension::k2dArray, AccessControl::kReadOnly, - ImageFormat::kRgba32Float); +TEST_F(StorageTextureTest, TypeName) { + StorageTexture s(TextureDimension::k2dArray, ast::AccessControl::kReadOnly, + ImageFormat::kRgba32Float); EXPECT_EQ(s.type_name(), "__storage_texture_read_only_2d_array_rgba32float"); } -TEST_F(StorageTextureTypeTest, F32Type) { +TEST_F(StorageTextureTest, F32) { Context ctx; Module mod; - Type* s = mod.create(TextureDimension::k2dArray, - AccessControl::kReadOnly, - ImageFormat::kRgba32Float); + Type* s = mod.create(TextureDimension::k2dArray, + ast::AccessControl::kReadOnly, + ImageFormat::kRgba32Float); TypeDeterminer td(&ctx, &mod); ASSERT_TRUE(td.Determine()) << td.error(); - ASSERT_TRUE(s->Is()); - ASSERT_TRUE(s->Is()); - EXPECT_TRUE( - s->As()->As()->type()->Is()); + ASSERT_TRUE(s->Is()); + ASSERT_TRUE(s->Is()); + EXPECT_TRUE(s->As()->As()->type()->Is()); } -TEST_F(StorageTextureTypeTest, U32Type) { +TEST_F(StorageTextureTest, U32) { Context ctx; Module mod; - Type* s = mod.create(TextureDimension::k2dArray, - AccessControl::kReadOnly, - ImageFormat::kRg32Uint); + Type* s = mod.create(TextureDimension::k2dArray, + ast::AccessControl::kReadOnly, + ImageFormat::kRg32Uint); TypeDeterminer td(&ctx, &mod); ASSERT_TRUE(td.Determine()) << td.error(); - ASSERT_TRUE(s->Is()); - ASSERT_TRUE(s->Is()); - EXPECT_TRUE(s->As()->type()->Is()); + ASSERT_TRUE(s->Is()); + ASSERT_TRUE(s->Is()); + EXPECT_TRUE(s->As()->type()->Is()); } -TEST_F(StorageTextureTypeTest, I32Type) { +TEST_F(StorageTextureTest, I32) { Context ctx; Module mod; - Type* s = mod.create(TextureDimension::k2dArray, - AccessControl::kReadOnly, - ImageFormat::kRgba32Sint); + Type* s = mod.create(TextureDimension::k2dArray, + ast::AccessControl::kReadOnly, + ImageFormat::kRgba32Sint); TypeDeterminer td(&ctx, &mod); ASSERT_TRUE(td.Determine()) << td.error(); - ASSERT_TRUE(s->Is()); - ASSERT_TRUE(s->Is()); - EXPECT_TRUE( - s->As()->As()->type()->Is()); + ASSERT_TRUE(s->Is()); + ASSERT_TRUE(s->Is()); + EXPECT_TRUE(s->As()->As()->type()->Is()); } -TEST_F(StorageTextureTypeTest, MinBufferBindingSize) { - StorageTextureType s(TextureDimension::k2dArray, AccessControl::kReadOnly, - ImageFormat::kRgba32Sint); +TEST_F(StorageTextureTest, MinBufferBindingSize) { + StorageTexture s(TextureDimension::k2dArray, ast::AccessControl::kReadOnly, + ImageFormat::kRgba32Sint); EXPECT_EQ(0u, s.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); } diff --git a/src/ast/type/struct_type.cc b/src/ast/type/struct_type.cc index 3b107e42f4..fc8f1102d4 100644 --- a/src/ast/type/struct_type.cc +++ b/src/ast/type/struct_type.cc @@ -26,18 +26,18 @@ namespace tint { namespace ast { namespace type { -StructType::StructType(const std::string& name, Struct* impl) +Struct::Struct(const std::string& name, ast::Struct* impl) : name_(name), struct_(impl) {} -StructType::StructType(StructType&&) = default; +Struct::Struct(Struct&&) = default; -StructType::~StructType() = default; +Struct::~Struct() = default; -std::string StructType::type_name() const { +std::string Struct::type_name() const { return "__struct_" + name_; } -uint64_t StructType::MinBufferBindingSize(MemoryLayout mem_layout) const { +uint64_t Struct::MinBufferBindingSize(MemoryLayout mem_layout) const { if (!struct_->members().size()) { return 0; } @@ -61,7 +61,7 @@ uint64_t StructType::MinBufferBindingSize(MemoryLayout mem_layout) const { return static_cast(alignment * std::ceil(unaligned / alignment)); } -uint64_t StructType::BaseAlignment(MemoryLayout mem_layout) const { +uint64_t Struct::BaseAlignment(MemoryLayout mem_layout) const { uint64_t max = 0; for (auto* member : struct_->members()) { if (member->type()->BaseAlignment(mem_layout) > max) { diff --git a/src/ast/type/struct_type.h b/src/ast/type/struct_type.h index 18ed3ba5d0..615468de63 100644 --- a/src/ast/type/struct_type.h +++ b/src/ast/type/struct_type.h @@ -26,15 +26,15 @@ namespace ast { namespace type { /// A structure type -class StructType : public Castable { +class Struct : public Castable { public: /// Constructor /// @param name the name of the struct /// @param impl the struct data - StructType(const std::string& name, Struct* impl); + Struct(const std::string& name, ast::Struct* impl); /// Move constructor - StructType(StructType&&); - ~StructType() override; + Struct(Struct&&); + ~Struct() override; /// @returns the struct name const std::string& name() const { return name_; } @@ -43,7 +43,7 @@ class StructType : public Castable { bool IsBlockDecorated() const { return struct_->IsBlockDecorated(); } /// @returns the struct name - Struct* impl() const { return struct_; } + ast::Struct* impl() const { return struct_; } /// @returns the name for the type std::string type_name() const override; @@ -60,7 +60,7 @@ class StructType : public Castable { private: std::string name_; - Struct* struct_ = nullptr; + ast::Struct* struct_ = nullptr; uint64_t LargestMemberBaseAlignment(MemoryLayout mem_layout) const; }; diff --git a/src/ast/type/struct_type_test.cc b/src/ast/type/struct_type_test.cc index 1f5587e2d2..1a915a2007 100644 --- a/src/ast/type/struct_type_test.cc +++ b/src/ast/type/struct_type_test.cc @@ -37,42 +37,42 @@ namespace ast { namespace type { namespace { -using StructTypeTest = TestHelper; +using StructTest = TestHelper; -TEST_F(StructTypeTest, Creation) { - auto* impl = create(); +TEST_F(StructTest, Creation) { + auto* impl = create(); auto* ptr = impl; - StructType s{"S", impl}; + Struct s{"S", impl}; EXPECT_EQ(s.impl(), ptr); } -TEST_F(StructTypeTest, Is) { - auto* impl = create(); - StructType s{"S", impl}; +TEST_F(StructTest, Is) { + auto* impl = create(); + Struct s{"S", impl}; Type* ty = &s; - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_TRUE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_TRUE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); } -TEST_F(StructTypeTest, TypeName) { - auto* impl = create(); - StructType s{"my_struct", impl}; +TEST_F(StructTest, TypeName) { + auto* impl = create(); + Struct s{"my_struct", impl}; EXPECT_EQ(s.type_name(), "__struct_my_struct"); } -TEST_F(StructTypeTest, MinBufferBindingSize) { - U32Type u32; +TEST_F(StructTest, MinBufferBindingSize) { + U32 u32; StructMemberList members; { @@ -87,16 +87,16 @@ TEST_F(StructTypeTest, MinBufferBindingSize) { } StructDecorationList decos; - auto* str = create(decos, members); - StructType struct_type("struct_type", str); + auto* str = create(decos, members); + Struct struct_type("struct_type", str); EXPECT_EQ(16u, struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); EXPECT_EQ(8u, struct_type.MinBufferBindingSize(MemoryLayout::kStorageBuffer)); } -TEST_F(StructTypeTest, MinBufferBindingSizeArray) { - U32Type u32; - ArrayType arr(&u32, 4); +TEST_F(StructTest, MinBufferBindingSizeArray) { + U32 u32; + Array arr(&u32, 4); { ArrayDecorationList decos; decos.push_back(create(4, Source{})); @@ -121,17 +121,17 @@ TEST_F(StructTypeTest, MinBufferBindingSizeArray) { } StructDecorationList decos; - auto* str = create(decos, members); - StructType struct_type("struct_type", str); + auto* str = create(decos, members); + Struct struct_type("struct_type", str); EXPECT_EQ(32u, struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); EXPECT_EQ(24u, struct_type.MinBufferBindingSize(MemoryLayout::kStorageBuffer)); } -TEST_F(StructTypeTest, MinBufferBindingSizeRuntimeArray) { - U32Type u32; - ArrayType arr(&u32); +TEST_F(StructTest, MinBufferBindingSizeRuntimeArray) { + U32 u32; + Array arr(&u32); { ArrayDecorationList decos; decos.push_back(create(4, Source{})); @@ -156,15 +156,15 @@ TEST_F(StructTypeTest, MinBufferBindingSizeRuntimeArray) { } StructDecorationList decos; - auto* str = create(decos, members); - StructType struct_type("struct_type", str); + auto* str = create(decos, members); + Struct struct_type("struct_type", str); EXPECT_EQ(12u, struct_type.MinBufferBindingSize(MemoryLayout::kStorageBuffer)); } -TEST_F(StructTypeTest, MinBufferBindingSizeVec2) { - U32Type u32; - VectorType vec2(&u32, 2); +TEST_F(StructTest, MinBufferBindingSizeVec2) { + U32 u32; + Vector vec2(&u32, 2); StructMemberList members; { @@ -174,16 +174,16 @@ TEST_F(StructTypeTest, MinBufferBindingSizeVec2) { } StructDecorationList decos; - auto* str = create(decos, members); - StructType struct_type("struct_type", str); + auto* str = create(decos, members); + Struct struct_type("struct_type", str); EXPECT_EQ(16u, struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); EXPECT_EQ(8u, struct_type.MinBufferBindingSize(MemoryLayout::kStorageBuffer)); } -TEST_F(StructTypeTest, MinBufferBindingSizeVec3) { - U32Type u32; - VectorType vec3(&u32, 3); +TEST_F(StructTest, MinBufferBindingSizeVec3) { + U32 u32; + Vector vec3(&u32, 3); StructMemberList members; { @@ -193,17 +193,17 @@ TEST_F(StructTypeTest, MinBufferBindingSizeVec3) { } StructDecorationList decos; - auto* str = create(decos, members); - StructType struct_type("struct_type", str); + auto* str = create(decos, members); + Struct struct_type("struct_type", str); EXPECT_EQ(16u, struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); EXPECT_EQ(16u, struct_type.MinBufferBindingSize(MemoryLayout::kStorageBuffer)); } -TEST_F(StructTypeTest, MinBufferBindingSizeVec4) { - U32Type u32; - VectorType vec4(&u32, 4); +TEST_F(StructTest, MinBufferBindingSizeVec4) { + U32 u32; + Vector vec4(&u32, 4); StructMemberList members; { @@ -213,16 +213,16 @@ TEST_F(StructTypeTest, MinBufferBindingSizeVec4) { } StructDecorationList decos; - auto* str = create(decos, members); - StructType struct_type("struct_type", str); + auto* str = create(decos, members); + Struct struct_type("struct_type", str); EXPECT_EQ(16u, struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); EXPECT_EQ(16u, struct_type.MinBufferBindingSize(MemoryLayout::kStorageBuffer)); } -TEST_F(StructTypeTest, BaseAlignment) { - U32Type u32; +TEST_F(StructTest, BaseAlignment) { + U32 u32; StructMemberList members; { @@ -237,15 +237,15 @@ TEST_F(StructTypeTest, BaseAlignment) { } StructDecorationList decos; - auto* str = create(decos, members); - StructType struct_type("struct_type", str); + auto* str = create(decos, members); + Struct struct_type("struct_type", str); EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(4u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer)); } -TEST_F(StructTypeTest, BaseAlignmentArray) { - U32Type u32; - ArrayType arr(&u32, 4); +TEST_F(StructTest, BaseAlignmentArray) { + U32 u32; + Array arr(&u32, 4); { ArrayDecorationList decos; decos.push_back(create(4, Source{})); @@ -270,15 +270,15 @@ TEST_F(StructTypeTest, BaseAlignmentArray) { } StructDecorationList decos; - auto* str = create(decos, members); - StructType struct_type("struct_type", str); + auto* str = create(decos, members); + Struct struct_type("struct_type", str); EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(4u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer)); } -TEST_F(StructTypeTest, BaseAlignmentRuntimeArray) { - U32Type u32; - ArrayType arr(&u32); +TEST_F(StructTest, BaseAlignmentRuntimeArray) { + U32 u32; + Array arr(&u32); { ArrayDecorationList decos; decos.push_back(create(4, Source{})); @@ -303,14 +303,14 @@ TEST_F(StructTypeTest, BaseAlignmentRuntimeArray) { } StructDecorationList decos; - auto* str = create(decos, members); - StructType struct_type("struct_type", str); + auto* str = create(decos, members); + Struct struct_type("struct_type", str); EXPECT_EQ(4u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer)); } -TEST_F(StructTypeTest, BaseAlignmentVec2) { - U32Type u32; - VectorType vec2(&u32, 2); +TEST_F(StructTest, BaseAlignmentVec2) { + U32 u32; + Vector vec2(&u32, 2); StructMemberList members; { @@ -320,15 +320,15 @@ TEST_F(StructTypeTest, BaseAlignmentVec2) { } StructDecorationList decos; - auto* str = create(decos, members); - StructType struct_type("struct_type", str); + auto* str = create(decos, members); + Struct struct_type("struct_type", str); EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(8u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer)); } -TEST_F(StructTypeTest, BaseAlignmentVec3) { - U32Type u32; - VectorType vec3(&u32, 3); +TEST_F(StructTest, BaseAlignmentVec3) { + U32 u32; + Vector vec3(&u32, 3); StructMemberList members; { @@ -338,15 +338,15 @@ TEST_F(StructTypeTest, BaseAlignmentVec3) { } StructDecorationList decos; - auto* str = create(decos, members); - StructType struct_type("struct_type", str); + auto* str = create(decos, members); + Struct struct_type("struct_type", str); EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer)); } -TEST_F(StructTypeTest, BaseAlignmentVec4) { - U32Type u32; - VectorType vec4(&u32, 4); +TEST_F(StructTest, BaseAlignmentVec4) { + U32 u32; + Vector vec4(&u32, 4); StructMemberList members; { @@ -356,8 +356,8 @@ TEST_F(StructTypeTest, BaseAlignmentVec4) { } StructDecorationList decos; - auto* str = create(decos, members); - StructType struct_type("struct_type", str); + auto* str = create(decos, members); + Struct struct_type("struct_type", str); EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer)); } diff --git a/src/ast/type/texture_type.cc b/src/ast/type/texture_type.cc index 453dcd092c..cd81de51ba 100644 --- a/src/ast/type/texture_type.cc +++ b/src/ast/type/texture_type.cc @@ -53,11 +53,11 @@ std::ostream& operator<<(std::ostream& out, TextureDimension dim) { return out; } -TextureType::TextureType(TextureDimension dim) : dim_(dim) {} +Texture::Texture(TextureDimension dim) : dim_(dim) {} -TextureType::TextureType(TextureType&&) = default; +Texture::Texture(Texture&&) = default; -TextureType::~TextureType() = default; +Texture::~Texture() = default; } // namespace type } // namespace ast diff --git a/src/ast/type/texture_type.h b/src/ast/type/texture_type.h index aa8db9fccc..59c1ccf247 100644 --- a/src/ast/type/texture_type.h +++ b/src/ast/type/texture_type.h @@ -46,14 +46,14 @@ enum class TextureDimension { std::ostream& operator<<(std::ostream& out, TextureDimension dim); /// A texture type. -class TextureType : public Castable { +class Texture : public Castable { public: /// Constructor /// @param dim the dimensionality of the texture - explicit TextureType(TextureDimension dim); + explicit Texture(TextureDimension dim); /// Move constructor - TextureType(TextureType&&); - ~TextureType() override; + Texture(Texture&&); + ~Texture() override; /// @returns the texture dimension TextureDimension dim() const { return dim_; } diff --git a/src/ast/type/type.cc b/src/ast/type/type.cc index 27d8a4996f..e1d7b1aaaa 100644 --- a/src/ast/type/type.cc +++ b/src/ast/type/type.cc @@ -42,8 +42,8 @@ Type::Type(Type&&) = default; Type::~Type() = default; Type* Type::UnwrapPtrIfNeeded() { - if (Is()) { - return As()->type(); + if (Is()) { + return As()->type(); } return this; } @@ -51,10 +51,10 @@ Type* Type::UnwrapPtrIfNeeded() { Type* Type::UnwrapIfNeeded() { auto* where = this; while (true) { - if (where->Is()) { - where = where->As()->type(); - } else if (where->Is()) { - where = where->As()->type(); + if (where->Is()) { + where = where->As()->type(); + } else if (where->Is()) { + where = where->As()->type(); } else { break; } @@ -75,19 +75,19 @@ uint64_t Type::BaseAlignment(MemoryLayout) const { } bool Type::is_scalar() { - return is_float_scalar() || is_integer_scalar() || Is(); + return is_float_scalar() || is_integer_scalar() || Is(); } bool Type::is_float_scalar() { - return Is(); + return Is(); } bool Type::is_float_matrix() { - return Is() && As()->type()->is_float_scalar(); + return Is() && As()->type()->is_float_scalar(); } bool Type::is_float_vector() { - return Is() && As()->type()->is_float_scalar(); + return Is() && As()->type()->is_float_scalar(); } bool Type::is_float_scalar_or_vector() { @@ -95,25 +95,23 @@ bool Type::is_float_scalar_or_vector() { } bool Type::is_integer_scalar() { - return Is() || Is(); + return Is() || Is(); } bool Type::is_unsigned_integer_vector() { - return Is() && As()->type()->Is(); + return Is() && As()->type()->Is(); } bool Type::is_signed_integer_vector() { - return Is() && As()->type()->Is(); + return Is() && As()->type()->Is(); } bool Type::is_unsigned_scalar_or_vector() { - return Is() || - (Is() && As()->type()->Is()); + return Is() || (Is() && As()->type()->Is()); } bool Type::is_signed_scalar_or_vector() { - return Is() || - (Is() && As()->type()->Is()); + return Is() || (Is() && As()->type()->Is()); } bool Type::is_integer_scalar_or_vector() { diff --git a/src/ast/type/u32_type.cc b/src/ast/type/u32_type.cc index baaffd2ddb..97cf951d49 100644 --- a/src/ast/type/u32_type.cc +++ b/src/ast/type/u32_type.cc @@ -18,21 +18,21 @@ namespace tint { namespace ast { namespace type { -U32Type::U32Type() = default; +U32::U32() = default; -U32Type::~U32Type() = default; +U32::~U32() = default; -U32Type::U32Type(U32Type&&) = default; +U32::U32(U32&&) = default; -std::string U32Type::type_name() const { +std::string U32::type_name() const { return "__u32"; } -uint64_t U32Type::MinBufferBindingSize(MemoryLayout) const { +uint64_t U32::MinBufferBindingSize(MemoryLayout) const { return 4; } -uint64_t U32Type::BaseAlignment(MemoryLayout) const { +uint64_t U32::BaseAlignment(MemoryLayout) const { return 4; } diff --git a/src/ast/type/u32_type.h b/src/ast/type/u32_type.h index 35e4b912f9..9decaa3602 100644 --- a/src/ast/type/u32_type.h +++ b/src/ast/type/u32_type.h @@ -24,13 +24,13 @@ namespace ast { namespace type { /// A unsigned int 32 type. -class U32Type : public Castable { +class U32 : public Castable { public: /// Constructor - U32Type(); + U32(); /// Move constructor - U32Type(U32Type&&); - ~U32Type() override; + U32(U32&&); + ~U32() override; /// @returns the name for th type std::string type_name() const override; diff --git a/src/ast/type/u32_type_test.cc b/src/ast/type/u32_type_test.cc index 19802b5a05..bf3a56b3d1 100644 --- a/src/ast/type/u32_type_test.cc +++ b/src/ast/type/u32_type_test.cc @@ -32,38 +32,38 @@ namespace ast { namespace type { namespace { -using U32TypeTest = TestHelper; +using U32Test = TestHelper; -TEST_F(U32TypeTest, Is) { - U32Type u; +TEST_F(U32Test, Is) { + U32 u; Type* ty = &u; - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_TRUE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_TRUE(ty->Is()); + EXPECT_FALSE(ty->Is()); } -TEST_F(U32TypeTest, TypeName) { - U32Type u; +TEST_F(U32Test, TypeName) { + U32 u; EXPECT_EQ(u.type_name(), "__u32"); } -TEST_F(U32TypeTest, MinBufferBindingSize) { - U32Type u; +TEST_F(U32Test, MinBufferBindingSize) { + U32 u; EXPECT_EQ(4u, u.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); } -TEST_F(U32TypeTest, BaseAlignment) { - U32Type u; +TEST_F(U32Test, BaseAlignment) { + U32 u; EXPECT_EQ(4u, u.BaseAlignment(MemoryLayout::kUniformBuffer)); } diff --git a/src/ast/type/vector_type.cc b/src/ast/type/vector_type.cc index 14614c3f11..c2dfaa5b1c 100644 --- a/src/ast/type/vector_type.cc +++ b/src/ast/type/vector_type.cc @@ -21,25 +21,24 @@ namespace tint { namespace ast { namespace type { -VectorType::VectorType(Type* subtype, uint32_t size) - : subtype_(subtype), size_(size) { +Vector::Vector(Type* subtype, uint32_t size) : subtype_(subtype), size_(size) { assert(size_ > 1); assert(size_ < 5); } -VectorType::VectorType(VectorType&&) = default; +Vector::Vector(Vector&&) = default; -VectorType::~VectorType() = default; +Vector::~Vector() = default; -std::string VectorType::type_name() const { +std::string Vector::type_name() const { return "__vec_" + std::to_string(size_) + subtype_->type_name(); } -uint64_t VectorType::MinBufferBindingSize(MemoryLayout mem_layout) const { +uint64_t Vector::MinBufferBindingSize(MemoryLayout mem_layout) const { return size_ * subtype_->MinBufferBindingSize(mem_layout); } -uint64_t VectorType::BaseAlignment(MemoryLayout mem_layout) const { +uint64_t Vector::BaseAlignment(MemoryLayout mem_layout) const { if (size_ == 2) { return 2 * subtype_->BaseAlignment(mem_layout); } else if (size_ == 3 || size_ == 4) { diff --git a/src/ast/type/vector_type.h b/src/ast/type/vector_type.h index c09d75e9f5..2186774274 100644 --- a/src/ast/type/vector_type.h +++ b/src/ast/type/vector_type.h @@ -24,15 +24,15 @@ namespace ast { namespace type { /// A vector type. -class VectorType : public Castable { +class Vector : public Castable { public: /// Constructor /// @param subtype the vector element type /// @param size the number of elements in the vector - VectorType(Type* subtype, uint32_t size); + Vector(Type* subtype, uint32_t size); /// Move constructor - VectorType(VectorType&&); - ~VectorType() override; + Vector(Vector&&); + ~Vector() override; /// @returns the type of the vector elements Type* type() const { return subtype_; } diff --git a/src/ast/type/vector_type_test.cc b/src/ast/type/vector_type_test.cc index 14c88cdfec..9b885ae32d 100644 --- a/src/ast/type/vector_type_test.cc +++ b/src/ast/type/vector_type_test.cc @@ -31,73 +31,73 @@ namespace ast { namespace type { namespace { -using VectorTypeTest = TestHelper; +using VectorTest = TestHelper; -TEST_F(VectorTypeTest, Creation) { - I32Type i32; - VectorType v{&i32, 2}; +TEST_F(VectorTest, Creation) { + I32 i32; + Vector v{&i32, 2}; EXPECT_EQ(v.type(), &i32); EXPECT_EQ(v.size(), 2u); } -TEST_F(VectorTypeTest, Is) { - I32Type i32; - VectorType v{&i32, 4}; +TEST_F(VectorTest, Is) { + I32 i32; + Vector v{&i32, 4}; Type* ty = &v; - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); - EXPECT_TRUE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); + EXPECT_TRUE(ty->Is()); } -TEST_F(VectorTypeTest, TypeName) { - I32Type i32; - VectorType v{&i32, 3}; +TEST_F(VectorTest, TypeName) { + I32 i32; + Vector v{&i32, 3}; EXPECT_EQ(v.type_name(), "__vec_3__i32"); } -TEST_F(VectorTypeTest, MinBufferBindingSizeVec2) { - I32Type i32; - VectorType v{&i32, 2}; +TEST_F(VectorTest, MinBufferBindingSizeVec2) { + I32 i32; + Vector v{&i32, 2}; EXPECT_EQ(8u, v.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); } -TEST_F(VectorTypeTest, MinBufferBindingSizeVec3) { - I32Type i32; - VectorType v{&i32, 3}; +TEST_F(VectorTest, MinBufferBindingSizeVec3) { + I32 i32; + Vector v{&i32, 3}; EXPECT_EQ(12u, v.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); } -TEST_F(VectorTypeTest, MinBufferBindingSizeVec4) { - I32Type i32; - VectorType v{&i32, 4}; +TEST_F(VectorTest, MinBufferBindingSizeVec4) { + I32 i32; + Vector v{&i32, 4}; EXPECT_EQ(16u, v.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); } -TEST_F(VectorTypeTest, BaseAlignmentVec2) { - I32Type i32; - VectorType v{&i32, 2}; +TEST_F(VectorTest, BaseAlignmentVec2) { + I32 i32; + Vector v{&i32, 2}; EXPECT_EQ(8u, v.BaseAlignment(MemoryLayout::kUniformBuffer)); } -TEST_F(VectorTypeTest, BaseAlignmentVec3) { - I32Type i32; - VectorType v{&i32, 3}; +TEST_F(VectorTest, BaseAlignmentVec3) { + I32 i32; + Vector v{&i32, 3}; EXPECT_EQ(16u, v.BaseAlignment(MemoryLayout::kUniformBuffer)); } -TEST_F(VectorTypeTest, BaseAlignmentVec4) { - I32Type i32; - VectorType v{&i32, 4}; +TEST_F(VectorTest, BaseAlignmentVec4) { + I32 i32; + Vector v{&i32, 4}; EXPECT_EQ(16u, v.BaseAlignment(MemoryLayout::kUniformBuffer)); } diff --git a/src/ast/type/void_type.cc b/src/ast/type/void_type.cc index ea0ccf692a..66fc7c6b4a 100644 --- a/src/ast/type/void_type.cc +++ b/src/ast/type/void_type.cc @@ -18,13 +18,13 @@ namespace tint { namespace ast { namespace type { -VoidType::VoidType() = default; +Void::Void() = default; -VoidType::VoidType(VoidType&&) = default; +Void::Void(Void&&) = default; -VoidType::~VoidType() = default; +Void::~Void() = default; -std::string VoidType::type_name() const { +std::string Void::type_name() const { return "__void"; } diff --git a/src/ast/type/void_type.h b/src/ast/type/void_type.h index 5099e8bcbb..16d9193a69 100644 --- a/src/ast/type/void_type.h +++ b/src/ast/type/void_type.h @@ -24,13 +24,13 @@ namespace ast { namespace type { /// A void type -class VoidType : public Castable { +class Void : public Castable { public: /// Constructor - VoidType(); + Void(); /// Move constructor - VoidType(VoidType&&); - ~VoidType() override; + Void(Void&&); + ~Void() override; /// @returns the name for this type std::string type_name() const override; diff --git a/src/ast/type_constructor_expression_test.cc b/src/ast/type_constructor_expression_test.cc index 517b109226..477faf5e86 100644 --- a/src/ast/type_constructor_expression_test.cc +++ b/src/ast/type_constructor_expression_test.cc @@ -30,7 +30,7 @@ namespace { using TypeConstructorExpressionTest = TestHelper; TEST_F(TypeConstructorExpressionTest, Creation) { - type::F32Type f32; + type::F32 f32; ExpressionList expr; expr.push_back(create("expr")); @@ -41,7 +41,7 @@ TEST_F(TypeConstructorExpressionTest, Creation) { } TEST_F(TypeConstructorExpressionTest, Creation_WithSource) { - type::F32Type f32; + type::F32 f32; ExpressionList expr; expr.push_back(create("expr")); @@ -57,7 +57,7 @@ TEST_F(TypeConstructorExpressionTest, IsTypeConstructor) { } TEST_F(TypeConstructorExpressionTest, IsValid) { - type::F32Type f32; + type::F32 f32; ExpressionList expr; expr.push_back(create("expr")); @@ -66,7 +66,7 @@ TEST_F(TypeConstructorExpressionTest, IsValid) { } TEST_F(TypeConstructorExpressionTest, IsValid_EmptyValue) { - type::F32Type f32; + type::F32 f32; ExpressionList expr; TypeConstructorExpression t(&f32, expr); @@ -83,7 +83,7 @@ TEST_F(TypeConstructorExpressionTest, IsValid_NullType) { } TEST_F(TypeConstructorExpressionTest, IsValid_NullValue) { - type::F32Type f32; + type::F32 f32; ExpressionList expr; expr.push_back(create("expr")); expr.push_back(nullptr); @@ -93,7 +93,7 @@ TEST_F(TypeConstructorExpressionTest, IsValid_NullValue) { } TEST_F(TypeConstructorExpressionTest, IsValid_InvalidValue) { - type::F32Type f32; + type::F32 f32; ExpressionList expr; expr.push_back(create("")); @@ -102,8 +102,8 @@ TEST_F(TypeConstructorExpressionTest, IsValid_InvalidValue) { } TEST_F(TypeConstructorExpressionTest, ToStr) { - type::F32Type f32; - type::VectorType vec(&f32, 3); + type::F32 f32; + type::Vector vec(&f32, 3); ExpressionList expr; expr.push_back(create("expr_1")); expr.push_back(create("expr_2")); diff --git a/src/ast/type_manager_test.cc b/src/ast/type_manager_test.cc index adced4bfc7..f78a61f132 100644 --- a/src/ast/type_manager_test.cc +++ b/src/ast/type_manager_test.cc @@ -27,43 +27,43 @@ using TypeManagerTest = testing::Test; TEST_F(TypeManagerTest, GetUnregistered) { TypeManager tm; - auto* t = tm.Get(std::make_unique()); + auto* t = tm.Get(std::make_unique()); ASSERT_NE(t, nullptr); - EXPECT_TRUE(t->Is()); + EXPECT_TRUE(t->Is()); } TEST_F(TypeManagerTest, GetSameTypeReturnsSamePtr) { TypeManager tm; - auto* t = tm.Get(std::make_unique()); + auto* t = tm.Get(std::make_unique()); ASSERT_NE(t, nullptr); - EXPECT_TRUE(t->Is()); + EXPECT_TRUE(t->Is()); - auto* t2 = tm.Get(std::make_unique()); + auto* t2 = tm.Get(std::make_unique()); EXPECT_EQ(t, t2); } TEST_F(TypeManagerTest, GetDifferentTypeReturnsDifferentPtr) { TypeManager tm; - auto* t = tm.Get(std::make_unique()); + auto* t = tm.Get(std::make_unique()); ASSERT_NE(t, nullptr); - EXPECT_TRUE(t->Is()); + EXPECT_TRUE(t->Is()); - auto* t2 = tm.Get(std::make_unique()); + auto* t2 = tm.Get(std::make_unique()); ASSERT_NE(t2, nullptr); EXPECT_NE(t, t2); - EXPECT_TRUE(t2->Is()); + EXPECT_TRUE(t2->Is()); } TEST_F(TypeManagerTest, ResetClearsPreviousData) { TypeManager tm; - auto* t = tm.Get(std::make_unique()); + auto* t = tm.Get(std::make_unique()); ASSERT_NE(t, nullptr); EXPECT_FALSE(tm.types().empty()); tm.Reset(); EXPECT_TRUE(tm.types().empty()); - auto* t2 = tm.Get(std::make_unique()); + auto* t2 = tm.Get(std::make_unique()); ASSERT_NE(t2, nullptr); } diff --git a/src/ast/uint_literal_test.cc b/src/ast/uint_literal_test.cc index 218c64f2fe..579fdca468 100644 --- a/src/ast/uint_literal_test.cc +++ b/src/ast/uint_literal_test.cc @@ -28,14 +28,14 @@ namespace { using UintLiteralTest = TestHelper; TEST_F(UintLiteralTest, Value) { - type::U32Type u32; + type::U32 u32; UintLiteral u{&u32, 47}; ASSERT_TRUE(u.Is()); EXPECT_EQ(u.value(), 47u); } TEST_F(UintLiteralTest, Is) { - type::U32Type u32; + type::U32 u32; UintLiteral u{&u32, 42}; Literal* l = &u; EXPECT_FALSE(l->Is()); @@ -46,7 +46,7 @@ TEST_F(UintLiteralTest, Is) { } TEST_F(UintLiteralTest, ToStr) { - type::U32Type u32; + type::U32 u32; UintLiteral i{&u32, 42}; EXPECT_EQ(i.to_str(), "42"); diff --git a/src/ast/variable_decl_statement_test.cc b/src/ast/variable_decl_statement_test.cc index 9b5f907089..afd15380d9 100644 --- a/src/ast/variable_decl_statement_test.cc +++ b/src/ast/variable_decl_statement_test.cc @@ -25,7 +25,7 @@ namespace { using VariableDeclStatementTest = TestHelper; TEST_F(VariableDeclStatementTest, Creation) { - type::F32Type f32; + type::F32 f32; auto* var = create("a", StorageClass::kNone, &f32); VariableDeclStatement stmt(var); @@ -33,7 +33,7 @@ TEST_F(VariableDeclStatementTest, Creation) { } TEST_F(VariableDeclStatementTest, Creation_WithSource) { - type::F32Type f32; + type::F32 f32; auto* var = create("a", StorageClass::kNone, &f32); VariableDeclStatement stmt(Source{Source::Location{20, 2}}, var); @@ -48,14 +48,14 @@ TEST_F(VariableDeclStatementTest, IsVariableDecl) { } TEST_F(VariableDeclStatementTest, IsValid) { - type::F32Type f32; + type::F32 f32; auto* var = create("a", StorageClass::kNone, &f32); VariableDeclStatement stmt(var); EXPECT_TRUE(stmt.IsValid()); } TEST_F(VariableDeclStatementTest, IsValid_InvalidVariable) { - type::F32Type f32; + type::F32 f32; auto* var = create("", StorageClass::kNone, &f32); VariableDeclStatement stmt(var); EXPECT_FALSE(stmt.IsValid()); @@ -67,7 +67,7 @@ TEST_F(VariableDeclStatementTest, IsValid_NullVariable) { } TEST_F(VariableDeclStatementTest, ToStr) { - type::F32Type f32; + type::F32 f32; auto* var = create("a", StorageClass::kNone, &f32); VariableDeclStatement stmt(Source{Source::Location{20, 2}}, var); diff --git a/src/ast/variable_test.cc b/src/ast/variable_test.cc index 0643b84c19..0b8bf9bc21 100644 --- a/src/ast/variable_test.cc +++ b/src/ast/variable_test.cc @@ -26,7 +26,7 @@ namespace { using VariableTest = TestHelper; TEST_F(VariableTest, Creation) { - type::I32Type t; + type::I32 t; Variable v("my_var", StorageClass::kFunction, &t); EXPECT_EQ(v.name(), "my_var"); @@ -40,7 +40,7 @@ TEST_F(VariableTest, Creation) { TEST_F(VariableTest, CreationWithSource) { Source s{Source::Range{Source::Location{27, 4}, Source::Location{27, 5}}}; - type::F32Type t; + type::F32 t; Variable v(s, "i", StorageClass::kPrivate, &t); EXPECT_EQ(v.name(), "i"); @@ -59,7 +59,7 @@ TEST_F(VariableTest, CreationEmpty) { v.set_storage_class(StorageClass::kWorkgroup); v.set_name("a_var"); - type::I32Type t; + type::I32 t; v.set_type(&t); EXPECT_EQ(v.name(), "a_var"); @@ -72,20 +72,20 @@ TEST_F(VariableTest, CreationEmpty) { } TEST_F(VariableTest, IsValid) { - type::I32Type t; + type::I32 t; Variable v{"my_var", StorageClass::kNone, &t}; EXPECT_TRUE(v.IsValid()); } TEST_F(VariableTest, IsValid_WithConstructor) { - type::I32Type t; + type::I32 t; Variable v{"my_var", StorageClass::kNone, &t}; v.set_constructor(create("ident")); EXPECT_TRUE(v.IsValid()); } TEST_F(VariableTest, IsValid_MissinName) { - type::I32Type t; + type::I32 t; Variable v{"", StorageClass::kNone, &t}; EXPECT_FALSE(v.IsValid()); } @@ -101,14 +101,14 @@ TEST_F(VariableTest, IsValid_MissingBoth) { } TEST_F(VariableTest, IsValid_InvalidConstructor) { - type::I32Type t; + type::I32 t; Variable v{"my_var", StorageClass::kNone, &t}; v.set_constructor(create("")); EXPECT_FALSE(v.IsValid()); } TEST_F(VariableTest, to_str) { - type::F32Type t; + type::F32 t; Variable v{"my_var", StorageClass::kFunction, &t}; std::ostringstream out; v.to_str(out, 2); diff --git a/src/inspector/inspector.cc b/src/inspector/inspector.cc index 596420e160..7f18ed4d08 100644 --- a/src/inspector/inspector.cc +++ b/src/inspector/inspector.cc @@ -185,16 +185,16 @@ std::vector Inspector::GetUniformBufferResourceBindings( ast::Variable* var = nullptr; ast::Function::BindingInfo binding_info; std::tie(var, binding_info) = ruv; - if (!var->type()->Is()) { + if (!var->type()->Is()) { continue; } auto* unwrapped_type = var->type()->UnwrapIfNeeded(); - if (!unwrapped_type->Is()) { + if (!unwrapped_type->Is()) { continue; } - if (!unwrapped_type->As()->IsBlockDecorated()) { + if (!unwrapped_type->As()->IsBlockDecorated()) { continue; } @@ -307,16 +307,16 @@ std::vector Inspector::GetStorageBufferResourceBindingsImpl( ast::Variable* var = nullptr; ast::Function::BindingInfo binding_info; std::tie(var, binding_info) = rsv; - if (!var->type()->Is()) { + if (!var->type()->Is()) { continue; } - auto* ac_type = var->type()->As(); + auto* ac_type = var->type()->As(); if (read_only != ac_type->IsReadOnly()) { continue; } - if (!var->type()->UnwrapIfNeeded()->Is()) { + if (!var->type()->UnwrapIfNeeded()->Is()) { continue; } @@ -353,7 +353,7 @@ std::vector Inspector::GetSampledTextureResourceBindingsImpl( entry.binding = binding_info.binding->value(); auto* texture_type = - var->type()->UnwrapIfNeeded()->As(); + var->type()->UnwrapIfNeeded()->As(); switch (texture_type->dim()) { case ast::type::TextureDimension::k1d: entry.dim = ResourceBinding::TextureDimension::k1d; @@ -383,28 +383,28 @@ std::vector Inspector::GetSampledTextureResourceBindingsImpl( ast::type::Type* base_type = nullptr; if (multisampled_only) { - base_type = texture_type->As() + base_type = texture_type->As() ->type() ->UnwrapIfNeeded(); } else { - base_type = texture_type->As() + base_type = texture_type->As() ->type() ->UnwrapIfNeeded(); } - if (base_type->Is()) { - base_type = base_type->As()->type(); - } else if (base_type->Is()) { - base_type = base_type->As()->type(); - } else if (base_type->Is()) { - base_type = base_type->As()->type(); + if (base_type->Is()) { + base_type = base_type->As()->type(); + } else if (base_type->Is()) { + base_type = base_type->As()->type(); + } else if (base_type->Is()) { + base_type = base_type->As()->type(); } - if (base_type->Is()) { + if (base_type->Is()) { entry.sampled_kind = ResourceBinding::SampledKind::kFloat; - } else if (base_type->Is()) { + } else if (base_type->Is()) { entry.sampled_kind = ResourceBinding::SampledKind::kUInt; - } else if (base_type->Is()) { + } else if (base_type->Is()) { entry.sampled_kind = ResourceBinding::SampledKind::kSInt; } else { entry.sampled_kind = ResourceBinding::SampledKind::kUnknown; diff --git a/src/inspector/inspector_test.cc b/src/inspector/inspector_test.cc index eb2a3a00f9..f463ba361f 100644 --- a/src/inspector/inspector_test.cc +++ b/src/inspector/inspector_test.cc @@ -244,7 +244,7 @@ class InspectorHelper { /// type and offset of a member of the struct /// @param is_block whether or not to decorate as a Block /// @returns a struct type - std::unique_ptr MakeStructType( + std::unique_ptr MakeStructType( const std::string& name, std::vector> members_info, bool is_block) { @@ -269,7 +269,7 @@ class InspectorHelper { auto* str = create(decos, members); - return std::make_unique(name, str); + return std::make_unique(name, str); } /// Generates types appropriate for using in an uniform buffer @@ -279,13 +279,13 @@ class InspectorHelper { /// @returns a tuple {struct type, access control type}, where the struct has /// the layout for an uniform buffer, and the control type wraps the /// struct. - std::tuple, - std::unique_ptr> + std::tuple, + std::unique_ptr> MakeUniformBufferTypes( const std::string& name, std::vector> members_info) { auto struct_type = MakeStructType(name, members_info, true); - auto access_type = std::make_unique( + auto access_type = std::make_unique( ast::AccessControl::kReadOnly, struct_type.get()); return {std::move(struct_type), std::move(access_type)}; } @@ -297,13 +297,13 @@ class InspectorHelper { /// @returns a tuple {struct type, access control type}, where the struct has /// the layout for a storage buffer, and the control type wraps the /// struct. - std::tuple, - std::unique_ptr> + std::tuple, + std::unique_ptr> MakeStorageBufferTypes( const std::string& name, std::vector> members_info) { auto struct_type = MakeStructType(name, members_info, false); - auto access_type = std::make_unique( + auto access_type = std::make_unique( ast::AccessControl::kReadWrite, struct_type.get()); return {std::move(struct_type), std::move(access_type)}; } @@ -315,13 +315,13 @@ class InspectorHelper { /// @returns a tuple {struct type, access control type}, where the struct has /// the layout for a read-only storage buffer, and the control type /// wraps the struct. - std::tuple, - std::unique_ptr> + std::tuple, + std::unique_ptr> MakeReadOnlyStorageBufferTypes( const std::string& name, std::vector> members_info) { auto struct_type = MakeStructType(name, members_info, false); - auto access_type = std::make_unique( + auto access_type = std::make_unique( ast::AccessControl::kReadOnly, struct_type.get()); return {std::move(struct_type), std::move(access_type)}; } @@ -429,32 +429,32 @@ class InspectorHelper { ast::StorageClass::kUniformConstant, set, binding); } - /// Generates a SampledTextureType appropriate for the params + /// Generates a SampledTexture appropriate for the params /// @param dim the dimensions of the texture /// @param type the data type of the sampled texture /// @returns the generated SampleTextureType - std::unique_ptr MakeSampledTextureType( + std::unique_ptr MakeSampledTextureType( ast::type::TextureDimension dim, ast::type::Type* type) { - return std::make_unique(dim, type); + return std::make_unique(dim, type); } - /// Generates a DepthTextureType appropriate for the params + /// Generates a DepthTexture appropriate for the params /// @param dim the dimensions of the texture - /// @returns the generated DepthTextureType - std::unique_ptr MakeDepthTextureType( + /// @returns the generated DepthTexture + std::unique_ptr MakeDepthTextureType( ast::type::TextureDimension dim) { - return std::make_unique(dim); + return std::make_unique(dim); } - /// Generates a MultisampledTextureType appropriate for the params + /// Generates a MultisampledTexture appropriate for the params /// @param dim the dimensions of the texture /// @param type the data type of the sampled texture /// @returns the generated SampleTextureType - std::unique_ptr - MakeMultisampledTextureType(ast::type::TextureDimension dim, - ast::type::Type* type) { - return std::make_unique(dim, type); + std::unique_ptr MakeMultisampledTextureType( + ast::type::TextureDimension dim, + ast::type::Type* type) { + return std::make_unique(dim, type); } /// Adds a sampled texture variable to the module @@ -645,31 +645,31 @@ class InspectorHelper { TypeDeterminer* td() { return td_.get(); } Inspector* inspector() { return inspector_.get(); } - ast::type::BoolType* bool_type() { return &bool_type_; } - ast::type::F32Type* f32_type() { return &f32_type_; } - ast::type::I32Type* i32_type() { return &i32_type_; } - ast::type::U32Type* u32_type() { return &u32_type_; } - ast::type::ArrayType* u32_array_type(uint32_t count) { + ast::type::Bool* bool_type() { return &bool_type_; } + ast::type::F32* f32_type() { return &f32_type_; } + ast::type::I32* i32_type() { return &i32_type_; } + ast::type::U32* u32_type() { return &u32_type_; } + ast::type::Array* u32_array_type(uint32_t count) { if (array_type_memo_.find(count) == array_type_memo_.end()) { array_type_memo_[count] = - std::make_unique(u32_type(), count); + std::make_unique(u32_type(), count); ast::ArrayDecorationList decos; decos.push_back(create(4, Source{})); array_type_memo_[count]->set_decorations(decos); } return array_type_memo_[count].get(); } - ast::type::VectorType* vec_type(ast::type::Type* type, uint32_t count) { + ast::type::Vector* vec_type(ast::type::Type* type, uint32_t count) { if (vector_type_memo_.find(std::tie(type, count)) == vector_type_memo_.end()) { vector_type_memo_[std::tie(type, count)] = - std::make_unique(u32_type(), count); + std::make_unique(u32_type(), count); } return vector_type_memo_[std::tie(type, count)].get(); } - ast::type::VoidType* void_type() { return &void_type_; } - ast::type::SamplerType* sampler_type() { return &sampler_type_; } - ast::type::SamplerType* comparison_sampler_type() { + ast::type::Void* void_type() { return &void_type_; } + ast::type::Sampler* sampler_type() { return &sampler_type_; } + ast::type::Sampler* comparison_sampler_type() { return &comparison_sampler_type_; } @@ -688,16 +688,16 @@ class InspectorHelper { std::unique_ptr td_; std::unique_ptr inspector_; - ast::type::BoolType bool_type_; - ast::type::F32Type f32_type_; - ast::type::I32Type i32_type_; - ast::type::U32Type u32_type_; - ast::type::VoidType void_type_; - ast::type::SamplerType sampler_type_; - ast::type::SamplerType comparison_sampler_type_; - std::map> array_type_memo_; + ast::type::Bool bool_type_; + ast::type::F32 f32_type_; + ast::type::I32 i32_type_; + ast::type::U32 u32_type_; + ast::type::Void void_type_; + ast::type::Sampler sampler_type_; + ast::type::Sampler comparison_sampler_type_; + std::map> array_type_memo_; std::map, - std::unique_ptr> + std::unique_ptr> vector_type_memo_; }; @@ -1234,8 +1234,8 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MissingEntryPoint) { } TEST_F(InspectorGetUniformBufferResourceBindingsTest, NonEntryPointFunc) { - std::unique_ptr foo_struct_type; - std::unique_ptr foo_control_type; + std::unique_ptr foo_struct_type; + std::unique_ptr foo_control_type; std::tie(foo_struct_type, foo_control_type) = MakeUniformBufferTypes("foo_type", {{i32_type(), 0}}); AddUniformBuffer("foo_ub", foo_control_type.get(), 0, 0); @@ -1267,7 +1267,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MissingBlockDeco) { ast::StructDecorationList decos; auto* str = create(decos, members); - auto foo_type = std::make_unique("foo_type", str); + auto foo_type = std::make_unique("foo_type", str); AddUniformBuffer("foo_ub", foo_type.get(), 0, 0); @@ -1288,8 +1288,8 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MissingBlockDeco) { } TEST_F(InspectorGetUniformBufferResourceBindingsTest, Simple) { - std::unique_ptr foo_struct_type; - std::unique_ptr foo_control_type; + std::unique_ptr foo_struct_type; + std::unique_ptr foo_control_type; std::tie(foo_struct_type, foo_control_type) = MakeUniformBufferTypes("foo_type", {{i32_type(), 0}}); AddUniformBuffer("foo_ub", foo_control_type.get(), 0, 0); @@ -1315,8 +1315,8 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, Simple) { } TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleMembers) { - std::unique_ptr foo_struct_type; - std::unique_ptr foo_control_type; + std::unique_ptr foo_struct_type; + std::unique_ptr foo_control_type; std::tie(foo_struct_type, foo_control_type) = MakeUniformBufferTypes( "foo_type", {{i32_type(), 0}, {u32_type(), 4}, {f32_type(), 8}}); AddUniformBuffer("foo_ub", foo_control_type.get(), 0, 0); @@ -1342,8 +1342,8 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleMembers) { } TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleUniformBuffers) { - std::unique_ptr ub_struct_type; - std::unique_ptr ub_control_type; + std::unique_ptr ub_struct_type; + std::unique_ptr ub_control_type; std::tie(ub_struct_type, ub_control_type) = MakeUniformBufferTypes( "ub_type", {{i32_type(), 0}, {u32_type(), 4}, {f32_type(), 8}}); AddUniformBuffer("ub_foo", ub_control_type.get(), 0, 0); @@ -1401,8 +1401,8 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleUniformBuffers) { } TEST_F(InspectorGetUniformBufferResourceBindingsTest, ContainingArray) { - std::unique_ptr foo_struct_type; - std::unique_ptr foo_control_type; + std::unique_ptr foo_struct_type; + std::unique_ptr foo_control_type; std::tie(foo_struct_type, foo_control_type) = MakeUniformBufferTypes( "foo_type", {{i32_type(), 0}, {u32_array_type(4), 4}}); AddUniformBuffer("foo_ub", foo_control_type.get(), 0, 0); @@ -1428,8 +1428,8 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, ContainingArray) { } TEST_F(InspectorGetStorageBufferResourceBindingsTest, Simple) { - std::unique_ptr foo_struct_type; - std::unique_ptr foo_control_type; + std::unique_ptr foo_struct_type; + std::unique_ptr foo_control_type; std::tie(foo_struct_type, foo_control_type) = MakeStorageBufferTypes("foo_type", {{i32_type(), 0}}); AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0); @@ -1455,8 +1455,8 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, Simple) { } TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleMembers) { - std::unique_ptr foo_struct_type; - std::unique_ptr foo_control_type; + std::unique_ptr foo_struct_type; + std::unique_ptr foo_control_type; std::tie(foo_struct_type, foo_control_type) = MakeStorageBufferTypes( "foo_type", {{i32_type(), 0}, {u32_type(), 4}, {f32_type(), 8}}); AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0); @@ -1482,8 +1482,8 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleMembers) { } TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleStorageBuffers) { - std::unique_ptr sb_struct_type; - std::unique_ptr sb_control_type; + std::unique_ptr sb_struct_type; + std::unique_ptr sb_control_type; std::tie(sb_struct_type, sb_control_type) = MakeStorageBufferTypes( "sb_type", {{i32_type(), 0}, {u32_type(), 4}, {f32_type(), 8}}); AddStorageBuffer("sb_foo", sb_control_type.get(), 0, 0); @@ -1541,8 +1541,8 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleStorageBuffers) { } TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingArray) { - std::unique_ptr foo_struct_type; - std::unique_ptr foo_control_type; + std::unique_ptr foo_struct_type; + std::unique_ptr foo_control_type; std::tie(foo_struct_type, foo_control_type) = MakeStorageBufferTypes( "foo_type", {{i32_type(), 0}, {u32_array_type(4), 4}}); AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0); @@ -1568,8 +1568,8 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingArray) { } TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingRuntimeArray) { - std::unique_ptr foo_struct_type; - std::unique_ptr foo_control_type; + std::unique_ptr foo_struct_type; + std::unique_ptr foo_control_type; std::tie(foo_struct_type, foo_control_type) = MakeStorageBufferTypes( "foo_type", {{i32_type(), 0}, {u32_array_type(0), 4}}); AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0); @@ -1595,8 +1595,8 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingRuntimeArray) { } TEST_F(InspectorGetStorageBufferResourceBindingsTest, SkipReadOnly) { - std::unique_ptr foo_struct_type; - std::unique_ptr foo_control_type; + std::unique_ptr foo_struct_type; + std::unique_ptr foo_control_type; std::tie(foo_struct_type, foo_control_type) = MakeReadOnlyStorageBufferTypes("foo_type", {{i32_type(), 0}}); AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0); @@ -1618,8 +1618,8 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, SkipReadOnly) { } TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, Simple) { - std::unique_ptr foo_struct_type; - std::unique_ptr foo_control_type; + std::unique_ptr foo_struct_type; + std::unique_ptr foo_control_type; std::tie(foo_struct_type, foo_control_type) = MakeReadOnlyStorageBufferTypes("foo_type", {{i32_type(), 0}}); AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0); @@ -1647,8 +1647,8 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, Simple) { TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, MultipleStorageBuffers) { - std::unique_ptr sb_struct_type; - std::unique_ptr sb_control_type; + std::unique_ptr sb_struct_type; + std::unique_ptr sb_control_type; std::tie(sb_struct_type, sb_control_type) = MakeReadOnlyStorageBufferTypes( "sb_type", {{i32_type(), 0}, {u32_type(), 4}, {f32_type(), 8}}); AddStorageBuffer("sb_foo", sb_control_type.get(), 0, 0); @@ -1707,8 +1707,8 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, } TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, ContainingArray) { - std::unique_ptr foo_struct_type; - std::unique_ptr foo_control_type; + std::unique_ptr foo_struct_type; + std::unique_ptr foo_control_type; std::tie(foo_struct_type, foo_control_type) = MakeReadOnlyStorageBufferTypes( "foo_type", {{i32_type(), 0}, {u32_array_type(4), 4}}); AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0); @@ -1736,8 +1736,8 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, ContainingArray) { TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, ContainingRuntimeArray) { - std::unique_ptr foo_struct_type; - std::unique_ptr foo_control_type; + std::unique_ptr foo_struct_type; + std::unique_ptr foo_control_type; std::tie(foo_struct_type, foo_control_type) = MakeReadOnlyStorageBufferTypes( "foo_type", {{i32_type(), 0}, {u32_array_type(0), 4}}); AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0); @@ -1764,8 +1764,8 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, } TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, SkipNonReadOnly) { - std::unique_ptr foo_struct_type; - std::unique_ptr foo_control_type; + std::unique_ptr foo_struct_type; + std::unique_ptr foo_control_type; std::tie(foo_struct_type, foo_control_type) = MakeStorageBufferTypes("foo_type", {{i32_type(), 0}}); AddStorageBuffer("foo_sb", foo_control_type.get(), 0, 0); diff --git a/src/reader/spirv/function.cc b/src/reader/spirv/function.cc index 133fac08ab..a550c6de57 100644 --- a/src/reader/spirv/function.cc +++ b/src/reader/spirv/function.cc @@ -2013,7 +2013,7 @@ bool FunctionEmitter::EmitIfStart(const BlockInfo& block_info) { if (!guard_name.empty()) { // Declare the guard variable just before the "if", initialized to true. auto* guard_var = create( - guard_name, ast::StorageClass::kFunction, parser_impl_.BoolType()); + guard_name, ast::StorageClass::kFunction, parser_impl_.Bool()); guard_var->set_constructor(MakeTrue()); auto* guard_decl = create(guard_var); AddStatement(guard_decl); @@ -2700,8 +2700,8 @@ bool FunctionEmitter::EmitStatement(const spvtools::opt::Instruction& inst) { // So represent a load by a new const definition. auto expr = MakeExpression(inst.GetSingleWordInOperand(0)); // The load result type is the pointee type of its operand. - assert(expr.type->Is()); - expr.type = expr.type->As()->type(); + assert(expr.type->Is()); + expr.type = expr.type->As()->type(); return EmitConstDefOrWriteToHoistedVar(inst, expr); } case SpvOpCopyObject: { @@ -3061,7 +3061,7 @@ TypedExpression FunctionEmitter::MakeAccessChain( type_mgr_->FindPointerToType(pointee_type_id, storage_class); auto* ast_pointer_type = parser_impl_.ConvertType(pointer_type_id); assert(ast_pointer_type); - assert(ast_pointer_type->Is()); + assert(ast_pointer_type->Is()); current_expr = TypedExpression{ast_pointer_type, next_expr}; } return current_expr; @@ -3080,7 +3080,7 @@ TypedExpression FunctionEmitter::MakeCompositeExtract( TypedExpression current_expr(MakeOperand(inst, 0)); auto make_index = [this](uint32_t literal) { - ast::type::U32Type u32; + ast::type::U32 u32; return create( create(&u32, literal)); }; @@ -3183,13 +3183,13 @@ TypedExpression FunctionEmitter::MakeCompositeExtract( ast::Expression* FunctionEmitter::MakeTrue() const { return create( - create(parser_impl_.BoolType(), true)); + create(parser_impl_.Bool(), true)); } ast::Expression* FunctionEmitter::MakeFalse() const { - ast::type::BoolType bool_type; + ast::type::Bool bool_type; return create( - create(parser_impl_.BoolType(), false)); + create(parser_impl_.Bool(), false)); } TypedExpression FunctionEmitter::MakeVectorShuffle( @@ -3207,8 +3207,8 @@ TypedExpression FunctionEmitter::MakeVectorShuffle( // Generate an ast::TypeConstructor expression. // Assume the literal indices are valid, and there is a valid number of them. - ast::type::VectorType* result_type = - parser_impl_.ConvertType(inst.type_id())->As(); + ast::type::Vector* result_type = + parser_impl_.ConvertType(inst.type_id())->As(); ast::ExpressionList values; for (uint32_t i = 2; i < inst.NumInOperands(); ++i) { const auto index = inst.GetSingleWordInOperand(i); @@ -3257,9 +3257,9 @@ bool FunctionEmitter::RegisterLocallyDefinedValues() { if (type) { if (type->AsPointer()) { const auto* ast_type = parser_impl_.ConvertType(inst.type_id()); - if (ast_type && ast_type->As()) { + if (ast_type && ast_type->As()) { info->storage_class = - ast_type->As()->storage_class(); + ast_type->As()->storage_class(); } switch (inst.opcode()) { case SpvOpUndef: @@ -3301,8 +3301,8 @@ ast::StorageClass FunctionEmitter::GetStorageClassForPointerValue(uint32_t id) { const auto type_id = def_use_mgr_->GetDef(id)->type_id(); if (type_id) { auto* ast_type = parser_impl_.ConvertType(type_id); - if (ast_type && ast_type->Is()) { - return ast_type->As()->storage_class(); + if (ast_type && ast_type->Is()) { + return ast_type->As()->storage_class(); } } return ast::StorageClass::kNone; @@ -3310,13 +3310,13 @@ ast::StorageClass FunctionEmitter::GetStorageClassForPointerValue(uint32_t id) { ast::type::Type* FunctionEmitter::RemapStorageClass(ast::type::Type* type, uint32_t result_id) { - if (type->Is()) { + if (type->Is()) { // Remap an old-style storage buffer pointer to a new-style storage // buffer pointer. - const auto* ast_ptr_type = type->As(); + const auto* ast_ptr_type = type->As(); const auto sc = GetStorageClassForPointerValue(result_id); if (ast_ptr_type->storage_class() != sc) { - return parser_impl_.get_module().create( + return parser_impl_.get_module().create( ast_ptr_type->type(), sc); } } @@ -3558,7 +3558,7 @@ bool FunctionEmitter::EmitFunctionCall(const spvtools::opt::Instruction& inst) { << inst.PrettyPrint(); } - if (result_type->Is()) { + if (result_type->Is()) { return nullptr != AddStatementForInstruction( create(call_expr), inst); } @@ -3600,8 +3600,8 @@ TypedExpression FunctionEmitter::MakeSimpleSelect( // - you can't select over pointers or pointer vectors, unless you also have // a VariablePointers* capability, which is not allowed in by WebGPU. auto* op_ty = operand1.type; - if (op_ty->Is() || op_ty->is_float_scalar() || - op_ty->is_integer_scalar() || op_ty->Is()) { + if (op_ty->Is() || op_ty->is_float_scalar() || + op_ty->is_integer_scalar() || op_ty->Is()) { ast::ExpressionList params; params.push_back(operand1.expr); params.push_back(operand2.expr); @@ -3711,14 +3711,13 @@ bool FunctionEmitter::EmitSampledImageAccess( auto* lod_operand = MakeOperand(inst, arg_index).expr; // When sampling from a depth texture, the Lod operand must be an unsigned // integer. - if (ast::type::PointerType* type = - parser_impl_.GetTypeForHandleVar(*image)) { - if (ast::type::TextureType* texture_type = - type->type()->As()) { - if (texture_type->Is()) { + if (ast::type::Pointer* type = parser_impl_.GetTypeForHandleVar(*image)) { + if (ast::type::Texture* texture_type = + type->type()->As()) { + if (texture_type->Is()) { // Convert it to an unsigned integer type. lod_operand = ast_module_.create( - ast_module_.create(), + ast_module_.create(), ast::ExpressionList{lod_operand}); } } @@ -3780,17 +3779,17 @@ ast::ExpressionList FunctionEmitter::MakeCoordinateOperandsForImageAccess( if (!raw_coords.type) { return {}; } - ast::type::PointerType* type = parser_impl_.GetTypeForHandleVar(*image); + ast::type::Pointer* type = parser_impl_.GetTypeForHandleVar(*image); if (!parser_impl_.success()) { Fail(); return {}; } - if (!type || !type->type()->Is()) { + if (!type || !type->type()->Is()) { Fail() << "invalid texture type for " << image->PrettyPrint(); return {}; } ast::type::TextureDimension dim = - type->type()->As()->dim(); + type->type()->As()->dim(); // Number of regular coordinates. uint32_t num_axes = 0; bool is_arrayed = false; @@ -3829,10 +3828,10 @@ ast::ExpressionList FunctionEmitter::MakeCoordinateOperandsForImageAccess( assert(num_axes <= 3); const auto num_coords_required = num_axes + (is_arrayed ? 1 : 0); uint32_t num_coords_supplied = 0; - if (raw_coords.type->Is()) { + if (raw_coords.type->Is()) { num_coords_supplied = 1; - } else if (raw_coords.type->Is()) { - num_coords_supplied = raw_coords.type->As()->size(); + } else if (raw_coords.type->Is()) { + num_coords_supplied = raw_coords.type->As()->size(); } if (num_coords_supplied == 0) { Fail() << "bad or unsupported coordinate type for image access: " @@ -3867,7 +3866,7 @@ ast::ExpressionList FunctionEmitter::MakeCoordinateOperandsForImageAccess( Swizzle(num_axes)); // Convert it to an unsigned integer type. result.push_back(ast_module_.create( - ast_module_.create(), + ast_module_.create(), ast::ExpressionList{array_index})); } else { if (num_coords_supplied == num_coords_required) { diff --git a/src/reader/spirv/function_var_test.cc b/src/reader/spirv/function_var_test.cc index b3e946daf2..b4c94615de 100644 --- a/src/reader/spirv/function_var_test.cc +++ b/src/reader/spirv/function_var_test.cc @@ -441,7 +441,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer) { )")) << ToString(fe.ast_body()); } -TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_AliasType) { +TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Alias) { auto p = parser(test::Assemble( std::string("OpDecorate %arr2uint ArrayStride 16\n") + Preamble() + R"( %ptr = OpTypePointer Function %arr2uint @@ -508,7 +508,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Null) { )")) << ToString(fe.ast_body()); } -TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_AliasType_Null) { +TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Alias_Null) { auto p = parser(test::Assemble( std::string("OpDecorate %arr2uint ArrayStride 16\n") + Preamble() + R"( %ptr = OpTypePointer Function %arr2uint diff --git a/src/reader/spirv/parser_impl.cc b/src/reader/spirv/parser_impl.cc index eb0c8fca3d..38f5589b39 100644 --- a/src/reader/spirv/parser_impl.cc +++ b/src/reader/spirv/parser_impl.cc @@ -196,7 +196,7 @@ ParserImpl::ParserImpl(Context* ctx, const std::vector& spv_binary) : Reader(ctx), spv_binary_(spv_binary), fail_stream_(&success_, &errors_), - bool_type_(ast_module_.create()), + bool_type_(ast_module_.create()), namer_(fail_stream_), enum_converter_(fail_stream_), tools_context_(kInputEnv) { @@ -285,7 +285,7 @@ ast::type::Type* ParserImpl::ConvertType(uint32_t type_id) { switch (spirv_type->kind()) { case spvtools::opt::analysis::Type::kVoid: - return save(ast_module_.create()); + return save(ast_module_.create()); case spvtools::opt::analysis::Type::kBool: return save(bool_type_); case spvtools::opt::analysis::Type::kInteger: @@ -315,7 +315,7 @@ ast::type::Type* ParserImpl::ConvertType(uint32_t type_id) { case spvtools::opt::analysis::Type::kImage: // Fake it for sampler and texture types. These are handled in an // entirely different way. - return save(ast_module_.create()); + return save(ast_module_.create()); default: break; } @@ -648,8 +648,8 @@ bool ParserImpl::RegisterEntryPoints() { ast::type::Type* ParserImpl::ConvertType( const spvtools::opt::analysis::Integer* int_ty) { if (int_ty->width() == 32) { - ast::type::Type* signed_ty = ast_module_.create(); - ast::type::Type* unsigned_ty = ast_module_.create(); + ast::type::Type* signed_ty = ast_module_.create(); + ast::type::Type* unsigned_ty = ast_module_.create(); signed_type_for_[unsigned_ty] = signed_ty; unsigned_type_for_[signed_ty] = unsigned_ty; return int_ty->IsSigned() ? signed_ty : unsigned_ty; @@ -661,7 +661,7 @@ ast::type::Type* ParserImpl::ConvertType( ast::type::Type* ParserImpl::ConvertType( const spvtools::opt::analysis::Float* float_ty) { if (float_ty->width() == 32) { - return ast_module_.create(); + return ast_module_.create(); } Fail() << "unhandled float width: " << float_ty->width(); return nullptr; @@ -674,16 +674,15 @@ ast::type::Type* ParserImpl::ConvertType( if (ast_elem_ty == nullptr) { return nullptr; } - auto* this_ty = - ast_module_.create(ast_elem_ty, num_elem); + auto* this_ty = ast_module_.create(ast_elem_ty, num_elem); // Generate the opposite-signedness vector type, if this type is integral. if (unsigned_type_for_.count(ast_elem_ty)) { - auto* other_ty = ast_module_.create( + auto* other_ty = ast_module_.create( unsigned_type_for_[ast_elem_ty], num_elem); signed_type_for_[other_ty] = this_ty; unsigned_type_for_[this_ty] = other_ty; } else if (signed_type_for_.count(ast_elem_ty)) { - auto* other_ty = ast_module_.create( + auto* other_ty = ast_module_.create( signed_type_for_[ast_elem_ty], num_elem); unsigned_type_for_[other_ty] = this_ty; signed_type_for_[this_ty] = other_ty; @@ -701,8 +700,8 @@ ast::type::Type* ParserImpl::ConvertType( if (ast_scalar_ty == nullptr) { return nullptr; } - return ast_module_.create(ast_scalar_ty, num_rows, - num_columns); + return ast_module_.create(ast_scalar_ty, num_rows, + num_columns); } ast::type::Type* ParserImpl::ConvertType( @@ -711,7 +710,7 @@ ast::type::Type* ParserImpl::ConvertType( if (ast_elem_ty == nullptr) { return nullptr; } - auto ast_type = std::make_unique(ast_elem_ty); + auto ast_type = std::make_unique(ast_elem_ty); if (!ApplyArrayDecorations(rtarr_ty, ast_type.get())) { return nullptr; } @@ -752,7 +751,7 @@ ast::type::Type* ParserImpl::ConvertType( << num_elem; return nullptr; } - auto ast_type = std::make_unique( + auto ast_type = std::make_unique( ast_elem_ty, static_cast(num_elem)); if (!ApplyArrayDecorations(arr_ty, ast_type.get())) { return nullptr; @@ -765,7 +764,7 @@ ast::type::Type* ParserImpl::ConvertType( bool ParserImpl::ApplyArrayDecorations( const spvtools::opt::analysis::Type* spv_type, - ast::type::ArrayType* ast_type) { + ast::type::Array* ast_type) { const auto type_id = type_mgr_->GetId(spv_type); for (auto& decoration : this->GetDecorationsFor(type_id)) { if (decoration.size() == 2 && decoration[0] == SpvDecorationArrayStride) { @@ -886,8 +885,8 @@ ast::type::Type* ParserImpl::ConvertType( namer_.SuggestSanitizedName(type_id, "S"); - auto* result = ast_module_.create( - namer_.GetName(type_id), ast_struct); + auto* result = ast_module_.create(namer_.GetName(type_id), + ast_struct); id_to_type_[type_id] = result; if (num_non_writable_members == members.size()) { read_only_struct_types_.insert(result); @@ -927,8 +926,7 @@ ast::type::Type* ParserImpl::ConvertType( ast_storage_class = ast::StorageClass::kStorageBuffer; remap_buffer_block_type_.insert(type_id); } - return ast_module_.create(ast_elem_ty, - ast_storage_class); + return ast_module_.create(ast_elem_ty, ast_storage_class); } bool ParserImpl::RegisterTypes() { @@ -975,15 +973,15 @@ bool ParserImpl::EmitScalarSpecConstants() { case SpvOpSpecConstant: { ast_type = ConvertType(inst.type_id()); const uint32_t literal_value = inst.GetSingleWordInOperand(0); - if (ast_type->Is()) { + if (ast_type->Is()) { ast_expr = create(create( ast_type, static_cast(literal_value))); - } else if (ast_type->Is()) { + } else if (ast_type->Is()) { ast_expr = create(create( ast_type, static_cast(literal_value))); - } else if (ast_type->Is()) { + } else if (ast_type->Is()) { float float_value; // Copy the bits so we can read them as a float. std::memcpy(&float_value, &literal_value, sizeof(float_value)); @@ -1058,7 +1056,7 @@ void ParserImpl::MaybeGenerateAlias(uint32_t type_id, } const auto name = namer_.GetName(type_id); auto* ast_alias_type = - ast_module_.create(name, ast_underlying_type); + ast_module_.create(name, ast_underlying_type); // Record this new alias as the AST type for this SPIR-V ID. id_to_type_[type_id] = ast_alias_type; ast_module_.AddConstructedType(ast_alias_type); @@ -1116,15 +1114,15 @@ bool ParserImpl::EmitModuleScopeVariables() { "SPIR-V type with ID: " << var.type_id(); } - if (!ast_type->Is()) { + if (!ast_type->Is()) { return Fail() << "variable with ID " << var.result_id() << " has non-pointer type " << var.type_id(); } } - auto* ast_store_type = ast_type->As()->type(); + auto* ast_store_type = ast_type->As()->type(); auto ast_storage_class = - ast_type->As()->storage_class(); + ast_type->As()->storage_class(); auto* ast_var = MakeVariable(var.result_id(), ast_storage_class, ast_store_type); if (var.NumInOperands() > 1) { @@ -1170,7 +1168,7 @@ ast::Variable* ParserImpl::MakeVariable(uint32_t id, auto access = read_only_struct_types_.count(type) ? ast::AccessControl::kReadOnly : ast::AccessControl::kReadWrite; - type = ast_module_.create(access, type); + type = ast_module_.create(access, type); } auto* ast_var = create(namer_.Name(id), sc, type); @@ -1263,22 +1261,22 @@ TypedExpression ParserImpl::MakeConstantExpression(uint32_t id) { // So canonicalization should map that way too. // Currently "null" is missing from the WGSL parser. // See https://bugs.chromium.org/p/tint/issues/detail?id=34 - if (ast_type->Is()) { + if (ast_type->Is()) { return {ast_type, create( create(ast_type, spirv_const->GetU32()))}; } - if (ast_type->Is()) { + if (ast_type->Is()) { return {ast_type, create( create(ast_type, spirv_const->GetS32()))}; } - if (ast_type->Is()) { + if (ast_type->Is()) { return {ast_type, create( create(ast_type, spirv_const->GetFloat()))}; } - if (ast_type->Is()) { + if (ast_type->Is()) { const bool value = spirv_const->AsNullConstant() ? false : spirv_const->AsBoolConstant()->value(); @@ -1335,24 +1333,24 @@ ast::Expression* ParserImpl::MakeNullValue(ast::type::Type* type) { auto* original_type = type; type = type->UnwrapIfNeeded(); - if (type->Is()) { + if (type->Is()) { return create( create(type, false)); } - if (type->Is()) { + if (type->Is()) { return create( create(type, 0u)); } - if (type->Is()) { + if (type->Is()) { return create( create(type, 0)); } - if (type->Is()) { + if (type->Is()) { return create( create(type, 0.0f)); } - if (type->Is()) { - const auto* vec_ty = type->As(); + if (type->Is()) { + const auto* vec_ty = type->As(); ast::ExpressionList ast_components; for (size_t i = 0; i < vec_ty->size(); ++i) { ast_components.emplace_back(MakeNullValue(vec_ty->type())); @@ -1360,11 +1358,11 @@ ast::Expression* ParserImpl::MakeNullValue(ast::type::Type* type) { return create(type, std::move(ast_components)); } - if (type->Is()) { - const auto* mat_ty = type->As(); + if (type->Is()) { + const auto* mat_ty = type->As(); // Matrix components are columns - auto* column_ty = ast_module_.create(mat_ty->type(), - mat_ty->rows()); + auto* column_ty = + ast_module_.create(mat_ty->type(), mat_ty->rows()); ast::ExpressionList ast_components; for (size_t i = 0; i < mat_ty->columns(); ++i) { ast_components.emplace_back(MakeNullValue(column_ty)); @@ -1372,8 +1370,8 @@ ast::Expression* ParserImpl::MakeNullValue(ast::type::Type* type) { return create(type, std::move(ast_components)); } - if (type->Is()) { - auto* arr_ty = type->As(); + if (type->Is()) { + auto* arr_ty = type->As(); ast::ExpressionList ast_components; for (size_t i = 0; i < arr_ty->size(); ++i) { ast_components.emplace_back(MakeNullValue(arr_ty->type())); @@ -1381,8 +1379,8 @@ ast::Expression* ParserImpl::MakeNullValue(ast::type::Type* type) { return create(original_type, std::move(ast_components)); } - if (type->Is()) { - auto* struct_ty = type->As(); + if (type->Is()) { + auto* struct_ty = type->As(); ast::ExpressionList ast_components; for (auto* member : struct_ty->impl()->members()) { ast_components.emplace_back(MakeNullValue(member->type())); @@ -1445,14 +1443,14 @@ ast::type::Type* ParserImpl::GetSignedIntMatchingShape(ast::type::Type* other) { if (other == nullptr) { Fail() << "no type provided"; } - auto* i32 = ast_module_.create(); - if (other->Is() || other->Is() || - other->Is()) { + auto* i32 = ast_module_.create(); + if (other->Is() || other->Is() || + other->Is()) { return i32; } - auto* vec_ty = other->As(); + auto* vec_ty = other->As(); if (vec_ty) { - return ast_module_.create(i32, vec_ty->size()); + return ast_module_.create(i32, vec_ty->size()); } Fail() << "required numeric scalar or vector, but got " << other->type_name(); return nullptr; @@ -1464,14 +1462,14 @@ ast::type::Type* ParserImpl::GetUnsignedIntMatchingShape( Fail() << "no type provided"; return nullptr; } - auto* u32 = ast_module_.create(); - if (other->Is() || other->Is() || - other->Is()) { + auto* u32 = ast_module_.create(); + if (other->Is() || other->Is() || + other->Is()) { return u32; } - auto* vec_ty = other->As(); + auto* vec_ty = other->As(); if (vec_ty) { - return ast_module_.create(u32, vec_ty->size()); + return ast_module_.create(u32, vec_ty->size()); } Fail() << "required numeric scalar or vector, but got " << other->type_name(); return nullptr; @@ -1603,7 +1601,7 @@ ParserImpl::GetMemoryObjectDeclarationForHandle(uint32_t id, } } -ast::type::PointerType* ParserImpl::GetTypeForHandleVar( +ast::type::Pointer* ParserImpl::GetTypeForHandleVar( const spvtools::opt::Instruction& var) { if (!success()) { return nullptr; @@ -1726,7 +1724,7 @@ ast::type::PointerType* ParserImpl::GetTypeForHandleVar( // Construct the Tint handle type. ast::type::Type* ast_store_type = nullptr; if (usage.IsSampler()) { - ast_store_type = ast_module_.create( + ast_store_type = ast_module_.create( usage.IsComparisonSampler() ? ast::type::SamplerKind::kComparisonSampler : ast::type::SamplerKind::kSampler); } else if (usage.IsTexture()) { @@ -1757,13 +1755,13 @@ ast::type::PointerType* ParserImpl::GetTypeForHandleVar( // OpImage variable with an OpImage*Dref* instruction. In WGSL we must // treat that as a depth texture. if (image_type->depth() || usage.IsDepthTexture()) { - ast_store_type = ast_module_.create(dim); + ast_store_type = ast_module_.create(dim); } else if (image_type->is_multisampled()) { // Multisampled textures are never depth textures. - ast_store_type = ast_module_.create( + ast_store_type = ast_module_.create( dim, ast_sampled_component_type); } else { - ast_store_type = ast_module_.create( + ast_store_type = ast_module_.create( dim, ast_sampled_component_type); } } else { @@ -1774,8 +1772,8 @@ ast::type::PointerType* ParserImpl::GetTypeForHandleVar( if (format == ast::type::ImageFormat::kNone) { return nullptr; } - ast_store_type = ast_module_.create( - dim, access, format); + ast_store_type = + ast_module_.create(dim, access, format); } } else { Fail() << "unsupported: UniformConstant variable is not a recognized " @@ -1785,7 +1783,7 @@ ast::type::PointerType* ParserImpl::GetTypeForHandleVar( } // Form the pointer type. - auto* result = ast_module_.create( + auto* result = ast_module_.create( ast_store_type, ast::StorageClass::kUniformConstant); // Remember it for later. handle_type_[&var] = result; diff --git a/src/reader/spirv/parser_impl.h b/src/reader/spirv/parser_impl.h index 11b0052b1a..fbb3e826a9 100644 --- a/src/reader/spirv/parser_impl.h +++ b/src/reader/spirv/parser_impl.h @@ -357,7 +357,7 @@ class ParserImpl : Reader { ast::type::Type* first_operand_type); /// @returns the registered boolean type. - ast::type::Type* BoolType() const { return bool_type_; } + ast::type::Type* Bool() const { return bool_type_; } /// Bookkeeping used for tracking the "position" builtin variable. struct BuiltInPositionInfo { @@ -433,7 +433,7 @@ class ParserImpl : Reader { /// @param var the OpVariable instruction /// @returns the Tint AST type for the poiner-to-{sampler|texture} or null on /// error - ast::type::PointerType* GetTypeForHandleVar( + ast::type::Pointer* GetTypeForHandleVar( const spvtools::opt::Instruction& var); /// Returns the SPIR-V instruction with the given ID, or nullptr. @@ -484,7 +484,7 @@ class ParserImpl : Reader { /// @param ast_type non-null; the AST type to apply decorations to /// @returns true on success. bool ApplyArrayDecorations(const spvtools::opt::analysis::Type* spv_type, - ast::type::ArrayType* ast_type); + ast::type::Array* ast_type); /// Creates a new `ast::Node` owned by the Module. When the Module is /// destructed, the `ast::Node` will also be destructed. @@ -592,7 +592,7 @@ class ParserImpl : Reader { // usages implied by usages of the memory-object-declaration. std::unordered_map handle_usage_; // The inferred pointer type for the given handle variable. - std::unordered_map + std::unordered_map handle_type_; }; diff --git a/src/reader/spirv/parser_impl_convert_type_test.cc b/src/reader/spirv/parser_impl_convert_type_test.cc index f1f2007181..6de6d87ab7 100644 --- a/src/reader/spirv/parser_impl_convert_type_test.cc +++ b/src/reader/spirv/parser_impl_convert_type_test.cc @@ -92,7 +92,7 @@ TEST_F(SpvParserTest, ConvertType_Void) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(1); - EXPECT_TRUE(type->Is()); + EXPECT_TRUE(type->Is()); EXPECT_TRUE(p->error().empty()); } @@ -101,7 +101,7 @@ TEST_F(SpvParserTest, ConvertType_Bool) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(100); - EXPECT_TRUE(type->Is()); + EXPECT_TRUE(type->Is()); EXPECT_TRUE(p->error().empty()); } @@ -110,7 +110,7 @@ TEST_F(SpvParserTest, ConvertType_I32) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(2); - EXPECT_TRUE(type->Is()); + EXPECT_TRUE(type->Is()); EXPECT_TRUE(p->error().empty()); } @@ -119,7 +119,7 @@ TEST_F(SpvParserTest, ConvertType_U32) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(3); - EXPECT_TRUE(type->Is()); + EXPECT_TRUE(type->Is()); EXPECT_TRUE(p->error().empty()); } @@ -128,7 +128,7 @@ TEST_F(SpvParserTest, ConvertType_F32) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(4); - EXPECT_TRUE(type->Is()); + EXPECT_TRUE(type->Is()); EXPECT_TRUE(p->error().empty()); } @@ -172,22 +172,19 @@ TEST_F(SpvParserTest, ConvertType_VecOverF32) { EXPECT_TRUE(p->BuildInternalModule()); auto* v2xf32 = p->ConvertType(20); - EXPECT_TRUE(v2xf32->Is()); - EXPECT_TRUE( - v2xf32->As()->type()->Is()); - EXPECT_EQ(v2xf32->As()->size(), 2u); + EXPECT_TRUE(v2xf32->Is()); + EXPECT_TRUE(v2xf32->As()->type()->Is()); + EXPECT_EQ(v2xf32->As()->size(), 2u); auto* v3xf32 = p->ConvertType(30); - EXPECT_TRUE(v3xf32->Is()); - EXPECT_TRUE( - v3xf32->As()->type()->Is()); - EXPECT_EQ(v3xf32->As()->size(), 3u); + EXPECT_TRUE(v3xf32->Is()); + EXPECT_TRUE(v3xf32->As()->type()->Is()); + EXPECT_EQ(v3xf32->As()->size(), 3u); auto* v4xf32 = p->ConvertType(40); - EXPECT_TRUE(v4xf32->Is()); - EXPECT_TRUE( - v4xf32->As()->type()->Is()); - EXPECT_EQ(v4xf32->As()->size(), 4u); + EXPECT_TRUE(v4xf32->Is()); + EXPECT_TRUE(v4xf32->As()->type()->Is()); + EXPECT_EQ(v4xf32->As()->size(), 4u); EXPECT_TRUE(p->error().empty()); } @@ -202,22 +199,19 @@ TEST_F(SpvParserTest, ConvertType_VecOverI32) { EXPECT_TRUE(p->BuildInternalModule()); auto* v2xi32 = p->ConvertType(20); - EXPECT_TRUE(v2xi32->Is()); - EXPECT_TRUE( - v2xi32->As()->type()->Is()); - EXPECT_EQ(v2xi32->As()->size(), 2u); + EXPECT_TRUE(v2xi32->Is()); + EXPECT_TRUE(v2xi32->As()->type()->Is()); + EXPECT_EQ(v2xi32->As()->size(), 2u); auto* v3xi32 = p->ConvertType(30); - EXPECT_TRUE(v3xi32->Is()); - EXPECT_TRUE( - v3xi32->As()->type()->Is()); - EXPECT_EQ(v3xi32->As()->size(), 3u); + EXPECT_TRUE(v3xi32->Is()); + EXPECT_TRUE(v3xi32->As()->type()->Is()); + EXPECT_EQ(v3xi32->As()->size(), 3u); auto* v4xi32 = p->ConvertType(40); - EXPECT_TRUE(v4xi32->Is()); - EXPECT_TRUE( - v4xi32->As()->type()->Is()); - EXPECT_EQ(v4xi32->As()->size(), 4u); + EXPECT_TRUE(v4xi32->Is()); + EXPECT_TRUE(v4xi32->As()->type()->Is()); + EXPECT_EQ(v4xi32->As()->size(), 4u); EXPECT_TRUE(p->error().empty()); } @@ -232,22 +226,19 @@ TEST_F(SpvParserTest, ConvertType_VecOverU32) { EXPECT_TRUE(p->BuildInternalModule()); auto* v2xu32 = p->ConvertType(20); - EXPECT_TRUE(v2xu32->Is()); - EXPECT_TRUE( - v2xu32->As()->type()->Is()); - EXPECT_EQ(v2xu32->As()->size(), 2u); + EXPECT_TRUE(v2xu32->Is()); + EXPECT_TRUE(v2xu32->As()->type()->Is()); + EXPECT_EQ(v2xu32->As()->size(), 2u); auto* v3xu32 = p->ConvertType(30); - EXPECT_TRUE(v3xu32->Is()); - EXPECT_TRUE( - v3xu32->As()->type()->Is()); - EXPECT_EQ(v3xu32->As()->size(), 3u); + EXPECT_TRUE(v3xu32->Is()); + EXPECT_TRUE(v3xu32->As()->type()->Is()); + EXPECT_EQ(v3xu32->As()->size(), 3u); auto* v4xu32 = p->ConvertType(40); - EXPECT_TRUE(v4xu32->Is()); - EXPECT_TRUE( - v4xu32->As()->type()->Is()); - EXPECT_EQ(v4xu32->As()->size(), 4u); + EXPECT_TRUE(v4xu32->Is()); + EXPECT_TRUE(v4xu32->As()->type()->Is()); + EXPECT_EQ(v4xu32->As()->size(), 4u); EXPECT_TRUE(p->error().empty()); } @@ -287,67 +278,58 @@ TEST_F(SpvParserTest, ConvertType_MatrixOverF32) { EXPECT_TRUE(p->BuildInternalModule()); auto* m22 = p->ConvertType(22); - EXPECT_TRUE(m22->Is()); - EXPECT_TRUE( - m22->As()->type()->Is()); - EXPECT_EQ(m22->As()->rows(), 2u); - EXPECT_EQ(m22->As()->columns(), 2u); + EXPECT_TRUE(m22->Is()); + EXPECT_TRUE(m22->As()->type()->Is()); + EXPECT_EQ(m22->As()->rows(), 2u); + EXPECT_EQ(m22->As()->columns(), 2u); auto* m23 = p->ConvertType(23); - EXPECT_TRUE(m23->Is()); - EXPECT_TRUE( - m23->As()->type()->Is()); - EXPECT_EQ(m23->As()->rows(), 2u); - EXPECT_EQ(m23->As()->columns(), 3u); + EXPECT_TRUE(m23->Is()); + EXPECT_TRUE(m23->As()->type()->Is()); + EXPECT_EQ(m23->As()->rows(), 2u); + EXPECT_EQ(m23->As()->columns(), 3u); auto* m24 = p->ConvertType(24); - EXPECT_TRUE(m24->Is()); - EXPECT_TRUE( - m24->As()->type()->Is()); - EXPECT_EQ(m24->As()->rows(), 2u); - EXPECT_EQ(m24->As()->columns(), 4u); + EXPECT_TRUE(m24->Is()); + EXPECT_TRUE(m24->As()->type()->Is()); + EXPECT_EQ(m24->As()->rows(), 2u); + EXPECT_EQ(m24->As()->columns(), 4u); auto* m32 = p->ConvertType(32); - EXPECT_TRUE(m32->Is()); - EXPECT_TRUE( - m32->As()->type()->Is()); - EXPECT_EQ(m32->As()->rows(), 3u); - EXPECT_EQ(m32->As()->columns(), 2u); + EXPECT_TRUE(m32->Is()); + EXPECT_TRUE(m32->As()->type()->Is()); + EXPECT_EQ(m32->As()->rows(), 3u); + EXPECT_EQ(m32->As()->columns(), 2u); auto* m33 = p->ConvertType(33); - EXPECT_TRUE(m33->Is()); - EXPECT_TRUE( - m33->As()->type()->Is()); - EXPECT_EQ(m33->As()->rows(), 3u); - EXPECT_EQ(m33->As()->columns(), 3u); + EXPECT_TRUE(m33->Is()); + EXPECT_TRUE(m33->As()->type()->Is()); + EXPECT_EQ(m33->As()->rows(), 3u); + EXPECT_EQ(m33->As()->columns(), 3u); auto* m34 = p->ConvertType(34); - EXPECT_TRUE(m34->Is()); - EXPECT_TRUE( - m34->As()->type()->Is()); - EXPECT_EQ(m34->As()->rows(), 3u); - EXPECT_EQ(m34->As()->columns(), 4u); + EXPECT_TRUE(m34->Is()); + EXPECT_TRUE(m34->As()->type()->Is()); + EXPECT_EQ(m34->As()->rows(), 3u); + EXPECT_EQ(m34->As()->columns(), 4u); auto* m42 = p->ConvertType(42); - EXPECT_TRUE(m42->Is()); - EXPECT_TRUE( - m42->As()->type()->Is()); - EXPECT_EQ(m42->As()->rows(), 4u); - EXPECT_EQ(m42->As()->columns(), 2u); + EXPECT_TRUE(m42->Is()); + EXPECT_TRUE(m42->As()->type()->Is()); + EXPECT_EQ(m42->As()->rows(), 4u); + EXPECT_EQ(m42->As()->columns(), 2u); auto* m43 = p->ConvertType(43); - EXPECT_TRUE(m43->Is()); - EXPECT_TRUE( - m43->As()->type()->Is()); - EXPECT_EQ(m43->As()->rows(), 4u); - EXPECT_EQ(m43->As()->columns(), 3u); + EXPECT_TRUE(m43->Is()); + EXPECT_TRUE(m43->As()->type()->Is()); + EXPECT_EQ(m43->As()->rows(), 4u); + EXPECT_EQ(m43->As()->columns(), 3u); auto* m44 = p->ConvertType(44); - EXPECT_TRUE(m44->Is()); - EXPECT_TRUE( - m44->As()->type()->Is()); - EXPECT_EQ(m44->As()->rows(), 4u); - EXPECT_EQ(m44->As()->columns(), 4u); + EXPECT_TRUE(m44->Is()); + EXPECT_TRUE(m44->As()->type()->Is()); + EXPECT_EQ(m44->As()->rows(), 4u); + EXPECT_EQ(m44->As()->columns(), 4u); EXPECT_TRUE(p->error().empty()); } @@ -361,8 +343,8 @@ TEST_F(SpvParserTest, ConvertType_RuntimeArray) { auto* type = p->ConvertType(10); ASSERT_NE(type, nullptr); - EXPECT_TRUE(type->Is()); - auto* arr_type = type->As(); + EXPECT_TRUE(type->Is()); + auto* arr_type = type->As(); EXPECT_TRUE(arr_type->IsRuntimeArray()); ASSERT_NE(arr_type, nullptr); EXPECT_EQ(arr_type->size(), 0u); @@ -370,7 +352,7 @@ TEST_F(SpvParserTest, ConvertType_RuntimeArray) { EXPECT_FALSE(arr_type->has_array_stride()); auto* elem_type = arr_type->type(); ASSERT_NE(elem_type, nullptr); - EXPECT_TRUE(elem_type->Is()); + EXPECT_TRUE(elem_type->Is()); EXPECT_TRUE(p->error().empty()); } @@ -397,7 +379,7 @@ TEST_F(SpvParserTest, ConvertType_RuntimeArray_ArrayStride_Valid) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(10); ASSERT_NE(type, nullptr); - auto* arr_type = type->As(); + auto* arr_type = type->As(); EXPECT_TRUE(arr_type->IsRuntimeArray()); ASSERT_NE(arr_type, nullptr); EXPECT_EQ(arr_type->array_stride(), 64u); @@ -443,8 +425,8 @@ TEST_F(SpvParserTest, ConvertType_Array) { auto* type = p->ConvertType(10); ASSERT_NE(type, nullptr); - EXPECT_TRUE(type->Is()); - auto* arr_type = type->As(); + EXPECT_TRUE(type->Is()); + auto* arr_type = type->As(); EXPECT_FALSE(arr_type->IsRuntimeArray()); ASSERT_NE(arr_type, nullptr); EXPECT_EQ(arr_type->size(), 42u); @@ -452,7 +434,7 @@ TEST_F(SpvParserTest, ConvertType_Array) { EXPECT_FALSE(arr_type->has_array_stride()); auto* elem_type = arr_type->type(); ASSERT_NE(elem_type, nullptr); - EXPECT_TRUE(elem_type->Is()); + EXPECT_TRUE(elem_type->Is()); EXPECT_TRUE(p->error().empty()); } @@ -531,8 +513,8 @@ TEST_F(SpvParserTest, ConvertType_ArrayStride_Valid) { auto* type = p->ConvertType(10); ASSERT_NE(type, nullptr); - EXPECT_TRUE(type->Is()); - auto* arr_type = type->As(); + EXPECT_TRUE(type->Is()); + auto* arr_type = type->As(); ASSERT_NE(arr_type, nullptr); ASSERT_EQ(arr_type->array_stride(), 8u); EXPECT_TRUE(arr_type->has_array_stride()); @@ -581,9 +563,9 @@ TEST_F(SpvParserTest, ConvertType_StructTwoMembers) { auto* type = p->ConvertType(10); ASSERT_NE(type, nullptr); - EXPECT_TRUE(type->Is()); + EXPECT_TRUE(type->Is()); std::stringstream ss; - type->As()->impl()->to_str(ss, 0); + type->As()->impl()->to_str(ss, 0); EXPECT_THAT(ss.str(), Eq(R"(Struct{ StructMember{field0: __u32} StructMember{field1: __f32} @@ -602,9 +584,9 @@ TEST_F(SpvParserTest, ConvertType_StructWithBlockDecoration) { auto* type = p->ConvertType(10); ASSERT_NE(type, nullptr); - EXPECT_TRUE(type->Is()); + EXPECT_TRUE(type->Is()); std::stringstream ss; - type->As()->impl()->to_str(ss, 0); + type->As()->impl()->to_str(ss, 0); EXPECT_THAT(ss.str(), Eq(R"(Struct{ [[block]] StructMember{field0: __u32} @@ -627,9 +609,9 @@ TEST_F(SpvParserTest, ConvertType_StructWithMemberDecorations) { auto* type = p->ConvertType(10); ASSERT_NE(type, nullptr); - EXPECT_TRUE(type->Is()); + EXPECT_TRUE(type->Is()); std::stringstream ss; - type->As()->impl()->to_str(ss, 0); + type->As()->impl()->to_str(ss, 0); EXPECT_THAT(ss.str(), Eq(R"(Struct{ StructMember{[[ offset 0 ]] field0: __f32} StructMember{[[ offset 8 ]] field1: __vec_2__f32} @@ -676,10 +658,10 @@ TEST_F(SpvParserTest, ConvertType_PointerInput) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(3); - EXPECT_TRUE(type->Is()); - auto* ptr_ty = type->As(); + EXPECT_TRUE(type->Is()); + auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); - EXPECT_TRUE(ptr_ty->type()->Is()); + EXPECT_TRUE(ptr_ty->type()->Is()); EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kInput); EXPECT_TRUE(p->error().empty()); } @@ -692,10 +674,10 @@ TEST_F(SpvParserTest, ConvertType_PointerOutput) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(3); - EXPECT_TRUE(type->Is()); - auto* ptr_ty = type->As(); + EXPECT_TRUE(type->Is()); + auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); - EXPECT_TRUE(ptr_ty->type()->Is()); + EXPECT_TRUE(ptr_ty->type()->Is()); EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kOutput); EXPECT_TRUE(p->error().empty()); } @@ -708,10 +690,10 @@ TEST_F(SpvParserTest, ConvertType_PointerUniform) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(3); - EXPECT_TRUE(type->Is()); - auto* ptr_ty = type->As(); + EXPECT_TRUE(type->Is()); + auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); - EXPECT_TRUE(ptr_ty->type()->Is()); + EXPECT_TRUE(ptr_ty->type()->Is()); EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kUniform); EXPECT_TRUE(p->error().empty()); } @@ -724,10 +706,10 @@ TEST_F(SpvParserTest, ConvertType_PointerWorkgroup) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(3); - EXPECT_TRUE(type->Is()); - auto* ptr_ty = type->As(); + EXPECT_TRUE(type->Is()); + auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); - EXPECT_TRUE(ptr_ty->type()->Is()); + EXPECT_TRUE(ptr_ty->type()->Is()); EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kWorkgroup); EXPECT_TRUE(p->error().empty()); } @@ -740,10 +722,10 @@ TEST_F(SpvParserTest, ConvertType_PointerUniformConstant) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(3); - EXPECT_TRUE(type->Is()); - auto* ptr_ty = type->As(); + EXPECT_TRUE(type->Is()); + auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); - EXPECT_TRUE(ptr_ty->type()->Is()); + EXPECT_TRUE(ptr_ty->type()->Is()); EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kUniformConstant); EXPECT_TRUE(p->error().empty()); } @@ -756,10 +738,10 @@ TEST_F(SpvParserTest, ConvertType_PointerStorageBuffer) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(3); - EXPECT_TRUE(type->Is()); - auto* ptr_ty = type->As(); + EXPECT_TRUE(type->Is()); + auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); - EXPECT_TRUE(ptr_ty->type()->Is()); + EXPECT_TRUE(ptr_ty->type()->Is()); EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kStorageBuffer); EXPECT_TRUE(p->error().empty()); } @@ -772,10 +754,10 @@ TEST_F(SpvParserTest, ConvertType_PointerImage) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(3); - EXPECT_TRUE(type->Is()); - auto* ptr_ty = type->As(); + EXPECT_TRUE(type->Is()); + auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); - EXPECT_TRUE(ptr_ty->type()->Is()); + EXPECT_TRUE(ptr_ty->type()->Is()); EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kImage); EXPECT_TRUE(p->error().empty()); } @@ -788,10 +770,10 @@ TEST_F(SpvParserTest, ConvertType_PointerPrivate) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(3); - EXPECT_TRUE(type->Is()); - auto* ptr_ty = type->As(); + EXPECT_TRUE(type->Is()); + auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); - EXPECT_TRUE(ptr_ty->type()->Is()); + EXPECT_TRUE(ptr_ty->type()->Is()); EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kPrivate); EXPECT_TRUE(p->error().empty()); } @@ -804,10 +786,10 @@ TEST_F(SpvParserTest, ConvertType_PointerFunction) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(3); - EXPECT_TRUE(type->Is()); - auto* ptr_ty = type->As(); + EXPECT_TRUE(type->Is()); + auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); - EXPECT_TRUE(ptr_ty->type()->Is()); + EXPECT_TRUE(ptr_ty->type()->Is()); EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kFunction); EXPECT_TRUE(p->error().empty()); } @@ -823,17 +805,17 @@ TEST_F(SpvParserTest, ConvertType_PointerToPointer) { auto* type = p->ConvertType(3); EXPECT_NE(type, nullptr); - EXPECT_TRUE(type->Is()); + EXPECT_TRUE(type->Is()); - auto* ptr_ty = type->As(); + auto* ptr_ty = type->As(); EXPECT_NE(ptr_ty, nullptr); EXPECT_EQ(ptr_ty->storage_class(), ast::StorageClass::kInput); - EXPECT_TRUE(ptr_ty->type()->Is()); + EXPECT_TRUE(ptr_ty->type()->Is()); - auto* ptr_ptr_ty = ptr_ty->type()->As(); + auto* ptr_ptr_ty = ptr_ty->type()->As(); EXPECT_NE(ptr_ptr_ty, nullptr); EXPECT_EQ(ptr_ptr_ty->storage_class(), ast::StorageClass::kOutput); - EXPECT_TRUE(ptr_ptr_ty->type()->Is()); + EXPECT_TRUE(ptr_ptr_ty->type()->Is()); EXPECT_TRUE(p->error().empty()); } @@ -846,7 +828,7 @@ TEST_F(SpvParserTest, ConvertType_Sampler_PretendVoid) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(1); - EXPECT_TRUE(type->Is()); + EXPECT_TRUE(type->Is()); EXPECT_TRUE(p->error().empty()); } @@ -859,7 +841,7 @@ TEST_F(SpvParserTest, ConvertType_Image_PretendVoid) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(1); - EXPECT_TRUE(type->Is()); + EXPECT_TRUE(type->Is()); EXPECT_TRUE(p->error().empty()); } @@ -872,7 +854,7 @@ TEST_F(SpvParserTest, ConvertType_SampledImage_PretendVoid) { EXPECT_TRUE(p->BuildInternalModule()); auto* type = p->ConvertType(1); - EXPECT_TRUE(type->Is()); + EXPECT_TRUE(type->Is()); EXPECT_TRUE(p->error().empty()); } diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc index 60eada7b5f..699bbd2f0e 100644 --- a/src/reader/wgsl/parser_impl.cc +++ b/src/reader/wgsl/parser_impl.cc @@ -318,7 +318,7 @@ Expect ParserImpl::expect_global_decl() { return Failure::kErrored; auto* type = module_.unique_type(std::move(str.value)); - register_constructed(type->As()->name(), type); + register_constructed(type->As()->name(), type); module_.AddConstructedType(type); return true; } @@ -471,8 +471,7 @@ Maybe ParserImpl::texture_sampler_types() { if (subtype.errored) return Failure::kErrored; - return module_.create(dim.value, - subtype.value); + return module_.create(dim.value, subtype.value); } auto ms_dim = multisampled_texture_type(); @@ -483,8 +482,8 @@ Maybe ParserImpl::texture_sampler_types() { if (subtype.errored) return Failure::kErrored; - return module_.create(ms_dim.value, - subtype.value); + return module_.create(ms_dim.value, + subtype.value); } auto storage = storage_texture_type(); @@ -497,7 +496,7 @@ Maybe ParserImpl::texture_sampler_types() { if (format.errored) return Failure::kErrored; - return module_.create( + return module_.create( storage->first, storage->second, format.value); } @@ -509,11 +508,10 @@ Maybe ParserImpl::texture_sampler_types() { // | SAMPLER_COMPARISON Maybe ParserImpl::sampler_type() { if (match(Token::Type::kSampler)) - return module_.create( - ast::type::SamplerKind::kSampler); + return module_.create(ast::type::SamplerKind::kSampler); if (match(Token::Type::kComparisonSampler)) - return module_.create( + return module_.create( ast::type::SamplerKind::kComparisonSampler); return Failure::kNoMatch; @@ -642,19 +640,19 @@ ParserImpl::storage_texture_type() { // | TEXTURE_DEPTH_CUBE_ARRAY Maybe ParserImpl::depth_texture_type() { if (match(Token::Type::kTextureDepth2d)) - return module_.create( + return module_.create( ast::type::TextureDimension::k2d); if (match(Token::Type::kTextureDepth2dArray)) - return module_.create( + return module_.create( ast::type::TextureDimension::k2dArray); if (match(Token::Type::kTextureDepthCube)) - return module_.create( + return module_.create( ast::type::TextureDimension::kCube); if (match(Token::Type::kTextureDepthCubeArray)) - return module_.create( + return module_.create( ast::type::TextureDimension::kCubeArray); return Failure::kNoMatch; @@ -840,7 +838,7 @@ Expect ParserImpl::expect_variable_ident_decl( for (auto* deco : access_decos) { // If we have an access control decoration then we take it and wrap our // type up with that decoration - ty = module_.create( + ty = module_.create( deco->As()->value(), ty); } @@ -900,7 +898,7 @@ Maybe ParserImpl::type_alias() { if (!type.matched) return add_error(peek(), "invalid type alias"); - auto* alias = module_.create(name.value, type.value); + auto* alias = module_.create(name.value, type.value); register_constructed(name.value, alias); return alias; @@ -958,16 +956,16 @@ Maybe ParserImpl::type_decl(ast::DecorationList& decos) { } if (match(Token::Type::kBool)) - return module_.create(); + return module_.create(); if (match(Token::Type::kF32)) - return module_.create(); + return module_.create(); if (match(Token::Type::kI32)) - return module_.create(); + return module_.create(); if (match(Token::Type::kU32)) - return module_.create(); + return module_.create(); if (t.IsVec2() || t.IsVec3() || t.IsVec4()) { next(); // Consume the peek @@ -1025,7 +1023,7 @@ Expect ParserImpl::expect_type_decl_pointer() { if (subtype.errored) return Failure::kErrored; - return module_.create(subtype.value, sc.value); + return module_.create(subtype.value, sc.value); }); } @@ -1042,7 +1040,7 @@ Expect ParserImpl::expect_type_decl_vector(Token t) { if (subtype.errored) return Failure::kErrored; - return module_.create(subtype.value, count); + return module_.create(subtype.value, count); } Expect ParserImpl::expect_type_decl_array( @@ -1062,7 +1060,7 @@ Expect ParserImpl::expect_type_decl_array( size = val.value; } - auto ty = std::make_unique(subtype.value, size); + auto ty = std::make_unique(subtype.value, size); ty->set_decorations(std::move(decos)); return module_.unique_type(std::move(ty)); }); @@ -1088,7 +1086,7 @@ Expect ParserImpl::expect_type_decl_matrix(Token t) { if (subtype.errored) return Failure::kErrored; - return module_.create(subtype.value, rows, columns); + return module_.create(subtype.value, rows, columns); } // storage_class @@ -1135,7 +1133,7 @@ Expect ParserImpl::expect_storage_class( // struct_decl // : struct_decoration_decl* STRUCT IDENT struct_body_decl -Maybe> ParserImpl::struct_decl( +Maybe> ParserImpl::struct_decl( ast::DecorationList& decos) { auto t = peek(); auto source = t.source(); @@ -1155,7 +1153,7 @@ Maybe> ParserImpl::struct_decl( if (struct_decos.errored) return Failure::kErrored; - return std::make_unique( + return std::make_unique( name.value, create(source, std::move(struct_decos.value), std::move(body.value))); } @@ -1256,7 +1254,7 @@ Maybe ParserImpl::function_decl(ast::DecorationList& decos) { // | VOID Maybe ParserImpl::function_type_decl() { if (match(Token::Type::kVoid)) - return module_.create(); + return module_.create(); return type_decl(); } @@ -2615,19 +2613,19 @@ Maybe ParserImpl::assignment_stmt() { Maybe ParserImpl::const_literal() { auto t = peek(); if (match(Token::Type::kTrue)) { - auto* type = module_.create(); + auto* type = module_.create(); return create(type, true); } if (match(Token::Type::kFalse)) { - auto* type = module_.create(); + auto* type = module_.create(); return create(type, false); } if (match(Token::Type::kSintLiteral)) { - auto* type = module_.create(); + auto* type = module_.create(); return create(type, t.to_i32()); } if (match(Token::Type::kUintLiteral)) { - auto* type = module_.create(); + auto* type = module_.create(); return create(type, t.to_u32()); } if (match(Token::Type::kFloatLiteral)) { @@ -2636,7 +2634,7 @@ Maybe ParserImpl::const_literal() { next(); // Consume 'f' add_error(p.source(), "float literals must not be suffixed with 'f'"); } - auto* type = module_.create(); + auto* type = module_.create(); return create(type, t.to_f32()); } return Failure::kNoMatch; diff --git a/src/reader/wgsl/parser_impl.h b/src/reader/wgsl/parser_impl.h index 883a7136a7..44f1e2a878 100644 --- a/src/reader/wgsl/parser_impl.h +++ b/src/reader/wgsl/parser_impl.h @@ -34,7 +34,6 @@ #include "src/ast/constructor_expression.h" #include "src/ast/continue_statement.h" #include "src/ast/else_statement.h" -#include "src/ast/switch_statement.h" #include "src/ast/function.h" #include "src/ast/if_statement.h" #include "src/ast/literal.h" @@ -48,6 +47,7 @@ #include "src/ast/struct_decoration.h" #include "src/ast/struct_member.h" #include "src/ast/struct_member_decoration.h" +#include "src/ast/switch_statement.h" #include "src/ast/type/storage_texture_type.h" #include "src/ast/type/struct_type.h" #include "src/ast/type/texture_type.h" @@ -353,7 +353,7 @@ class ParserImpl { /// `struct_decoration_decl*` provided as |decos|. /// @returns the struct type or nullptr on error /// @param decos the list of decorations for the struct declaration. - Maybe> struct_decl( + Maybe> struct_decl( ast::DecorationList& decos); /// Parses a `struct_body_decl` grammar element, erroring on parse failure. /// @returns the struct members diff --git a/src/reader/wgsl/parser_impl_const_expr_test.cc b/src/reader/wgsl/parser_impl_const_expr_test.cc index cb0c7ee8c7..8dd60682bb 100644 --- a/src/reader/wgsl/parser_impl_const_expr_test.cc +++ b/src/reader/wgsl/parser_impl_const_expr_test.cc @@ -35,8 +35,8 @@ TEST_F(ParserImplTest, ConstExpr_TypeDecl) { ASSERT_TRUE(e->Is()); auto* t = e->As(); - ASSERT_TRUE(t->type()->Is()); - EXPECT_EQ(t->type()->As()->size(), 2u); + ASSERT_TRUE(t->type()->Is()); + EXPECT_EQ(t->type()->As()->size(), 2u); ASSERT_EQ(t->values().size(), 2u); auto& v = t->values(); diff --git a/src/reader/wgsl/parser_impl_depth_texture_type_test.cc b/src/reader/wgsl/parser_impl_depth_texture_type_test.cc index fd1d93bdf5..5ba850e5c0 100644 --- a/src/reader/wgsl/parser_impl_depth_texture_type_test.cc +++ b/src/reader/wgsl/parser_impl_depth_texture_type_test.cc @@ -36,10 +36,9 @@ TEST_F(ParserImplTest, DepthTextureType_2d) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE( - t->As()->Is()); - EXPECT_EQ(t->As()->dim(), + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->As()->Is()); + EXPECT_EQ(t->As()->dim(), ast::type::TextureDimension::k2d); EXPECT_FALSE(p->has_error()); } @@ -50,10 +49,9 @@ TEST_F(ParserImplTest, DepthTextureType_2dArray) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE( - t->As()->Is()); - EXPECT_EQ(t->As()->dim(), + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->As()->Is()); + EXPECT_EQ(t->As()->dim(), ast::type::TextureDimension::k2dArray); EXPECT_FALSE(p->has_error()); } @@ -64,10 +62,9 @@ TEST_F(ParserImplTest, DepthTextureType_Cube) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE( - t->As()->Is()); - EXPECT_EQ(t->As()->dim(), + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->As()->Is()); + EXPECT_EQ(t->As()->dim(), ast::type::TextureDimension::kCube); EXPECT_FALSE(p->has_error()); } @@ -78,10 +75,9 @@ TEST_F(ParserImplTest, DepthTextureType_CubeArray) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE( - t->As()->Is()); - EXPECT_EQ(t->As()->dim(), + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->As()->Is()); + EXPECT_EQ(t->As()->dim(), ast::type::TextureDimension::kCubeArray); EXPECT_FALSE(p->has_error()); } diff --git a/src/reader/wgsl/parser_impl_function_decl_test.cc b/src/reader/wgsl/parser_impl_function_decl_test.cc index 7ba09b3345..e7e38ec929 100644 --- a/src/reader/wgsl/parser_impl_function_decl_test.cc +++ b/src/reader/wgsl/parser_impl_function_decl_test.cc @@ -39,14 +39,14 @@ TEST_F(ParserImplTest, FunctionDecl) { EXPECT_EQ(f->name(), "main"); ASSERT_NE(f->return_type(), nullptr); - EXPECT_TRUE(f->return_type()->Is()); + EXPECT_TRUE(f->return_type()->Is()); ASSERT_EQ(f->params().size(), 2u); EXPECT_EQ(f->params()[0]->name(), "a"); EXPECT_EQ(f->params()[1]->name(), "b"); ASSERT_NE(f->return_type(), nullptr); - EXPECT_TRUE(f->return_type()->Is()); + EXPECT_TRUE(f->return_type()->Is()); auto* body = f->body(); ASSERT_EQ(body->size(), 1u); @@ -67,10 +67,10 @@ TEST_F(ParserImplTest, FunctionDecl_DecorationList) { EXPECT_EQ(f->name(), "main"); ASSERT_NE(f->return_type(), nullptr); - EXPECT_TRUE(f->return_type()->Is()); + EXPECT_TRUE(f->return_type()->Is()); ASSERT_EQ(f->params().size(), 0u); ASSERT_NE(f->return_type(), nullptr); - EXPECT_TRUE(f->return_type()->Is()); + EXPECT_TRUE(f->return_type()->Is()); auto& decorations = f->decorations(); ASSERT_EQ(decorations.size(), 1u); @@ -105,10 +105,10 @@ fn main() -> void { return; })"); EXPECT_EQ(f->name(), "main"); ASSERT_NE(f->return_type(), nullptr); - EXPECT_TRUE(f->return_type()->Is()); + EXPECT_TRUE(f->return_type()->Is()); ASSERT_EQ(f->params().size(), 0u); ASSERT_NE(f->return_type(), nullptr); - EXPECT_TRUE(f->return_type()->Is()); + EXPECT_TRUE(f->return_type()->Is()); auto& decorations = f->decorations(); ASSERT_EQ(decorations.size(), 2u); @@ -150,10 +150,10 @@ fn main() -> void { return; })"); EXPECT_EQ(f->name(), "main"); ASSERT_NE(f->return_type(), nullptr); - EXPECT_TRUE(f->return_type()->Is()); + EXPECT_TRUE(f->return_type()->Is()); ASSERT_EQ(f->params().size(), 0u); ASSERT_NE(f->return_type(), nullptr); - EXPECT_TRUE(f->return_type()->Is()); + EXPECT_TRUE(f->return_type()->Is()); auto& decos = f->decorations(); ASSERT_EQ(decos.size(), 2u); diff --git a/src/reader/wgsl/parser_impl_function_header_test.cc b/src/reader/wgsl/parser_impl_function_header_test.cc index 77662bfa6d..e6a9e15e3f 100644 --- a/src/reader/wgsl/parser_impl_function_header_test.cc +++ b/src/reader/wgsl/parser_impl_function_header_test.cc @@ -36,7 +36,7 @@ TEST_F(ParserImplTest, FunctionHeader) { ASSERT_EQ(f->params().size(), 2u); EXPECT_EQ(f->params()[0]->name(), "a"); EXPECT_EQ(f->params()[1]->name(), "b"); - EXPECT_TRUE(f->return_type()->Is()); + EXPECT_TRUE(f->return_type()->Is()); } TEST_F(ParserImplTest, FunctionHeader_MissingIdent) { diff --git a/src/reader/wgsl/parser_impl_function_type_decl_test.cc b/src/reader/wgsl/parser_impl_function_type_decl_test.cc index 64b16240a6..b4160e5e48 100644 --- a/src/reader/wgsl/parser_impl_function_type_decl_test.cc +++ b/src/reader/wgsl/parser_impl_function_type_decl_test.cc @@ -30,7 +30,7 @@ TEST_F(ParserImplTest, FunctionTypeDecl_Void) { auto p = parser("void"); auto& mod = p->get_module(); - auto* v = mod.create(); + auto* v = mod.create(); auto e = p->function_type_decl(); EXPECT_TRUE(e.matched); @@ -43,8 +43,8 @@ TEST_F(ParserImplTest, FunctionTypeDecl_Type) { auto p = parser("vec2"); auto& mod = p->get_module(); - auto* f32 = mod.create(); - auto* vec2 = mod.create(f32, 2); + auto* f32 = mod.create(); + auto* vec2 = mod.create(f32, 2); auto e = p->function_type_decl(); EXPECT_TRUE(e.matched); diff --git a/src/reader/wgsl/parser_impl_global_constant_decl_test.cc b/src/reader/wgsl/parser_impl_global_constant_decl_test.cc index fe26ad1c00..564b13881f 100644 --- a/src/reader/wgsl/parser_impl_global_constant_decl_test.cc +++ b/src/reader/wgsl/parser_impl_global_constant_decl_test.cc @@ -35,7 +35,7 @@ TEST_F(ParserImplTest, GlobalConstantDecl) { EXPECT_TRUE(e->is_const()); EXPECT_EQ(e->name(), "a"); ASSERT_NE(e->type(), nullptr); - EXPECT_TRUE(e->type()->Is()); + EXPECT_TRUE(e->type()->Is()); EXPECT_EQ(e->source().range.begin.line, 1u); EXPECT_EQ(e->source().range.begin.column, 7u); diff --git a/src/reader/wgsl/parser_impl_global_decl_test.cc b/src/reader/wgsl/parser_impl_global_decl_test.cc index 230c755459..d654b068fc 100644 --- a/src/reader/wgsl/parser_impl_global_decl_test.cc +++ b/src/reader/wgsl/parser_impl_global_decl_test.cc @@ -88,8 +88,8 @@ TEST_F(ParserImplTest, GlobalDecl_TypeAlias) { auto& m = p->get_module(); ASSERT_EQ(m.constructed_types().size(), 1u); - ASSERT_TRUE(m.constructed_types()[0]->Is()); - EXPECT_EQ(m.constructed_types()[0]->As()->name(), "A"); + ASSERT_TRUE(m.constructed_types()[0]->Is()); + EXPECT_EQ(m.constructed_types()[0]->As()->name(), "A"); } TEST_F(ParserImplTest, GlobalDecl_TypeAlias_StructIdent) { @@ -103,12 +103,12 @@ type B = A;)"); auto& m = p->get_module(); ASSERT_EQ(m.constructed_types().size(), 2u); - ASSERT_TRUE(m.constructed_types()[0]->Is()); - auto* str = m.constructed_types()[0]->As(); + ASSERT_TRUE(m.constructed_types()[0]->Is()); + auto* str = m.constructed_types()[0]->As(); EXPECT_EQ(str->name(), "A"); - ASSERT_TRUE(m.constructed_types()[1]->Is()); - auto* alias = m.constructed_types()[1]->As(); + ASSERT_TRUE(m.constructed_types()[1]->Is()); + auto* alias = m.constructed_types()[1]->As(); EXPECT_EQ(alias->name(), "B"); EXPECT_EQ(alias->type(), str); } @@ -164,9 +164,9 @@ TEST_F(ParserImplTest, GlobalDecl_ParsesStruct) { auto* t = m.constructed_types()[0]; ASSERT_NE(t, nullptr); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* str = t->As(); + auto* str = t->As(); EXPECT_EQ(str->name(), "A"); EXPECT_EQ(str->impl()->members().size(), 2u); } @@ -183,16 +183,16 @@ TEST_F(ParserImplTest, GlobalDecl_Struct_WithStride) { auto* t = m.constructed_types()[0]; ASSERT_NE(t, nullptr); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* str = t->As(); + auto* str = t->As(); EXPECT_EQ(str->name(), "A"); EXPECT_EQ(str->impl()->members().size(), 1u); EXPECT_FALSE(str->IsBlockDecorated()); const auto* ty = str->impl()->members()[0]->type(); - ASSERT_TRUE(ty->Is()); - const auto* arr = ty->As(); + ASSERT_TRUE(ty->Is()); + const auto* arr = ty->As(); EXPECT_TRUE(arr->has_array_stride()); EXPECT_EQ(arr->array_stride(), 4u); } @@ -207,9 +207,9 @@ TEST_F(ParserImplTest, GlobalDecl_Struct_WithDecoration) { auto* t = m.constructed_types()[0]; ASSERT_NE(t, nullptr); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* str = t->As(); + auto* str = t->As(); EXPECT_EQ(str->name(), "A"); EXPECT_EQ(str->impl()->members().size(), 1u); EXPECT_TRUE(str->IsBlockDecorated()); diff --git a/src/reader/wgsl/parser_impl_global_variable_decl_test.cc b/src/reader/wgsl/parser_impl_global_variable_decl_test.cc index 76f2c29751..f0952700dc 100644 --- a/src/reader/wgsl/parser_impl_global_variable_decl_test.cc +++ b/src/reader/wgsl/parser_impl_global_variable_decl_test.cc @@ -37,7 +37,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithoutConstructor) { ASSERT_NE(e.value, nullptr); EXPECT_EQ(e->name(), "a"); - EXPECT_TRUE(e->type()->Is()); + EXPECT_TRUE(e->type()->Is()); EXPECT_EQ(e->storage_class(), ast::StorageClass::kOutput); EXPECT_EQ(e->source().range.begin.line, 1u); @@ -61,7 +61,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithConstructor) { ASSERT_NE(e.value, nullptr); EXPECT_EQ(e->name(), "a"); - EXPECT_TRUE(e->type()->Is()); + EXPECT_TRUE(e->type()->Is()); EXPECT_EQ(e->storage_class(), ast::StorageClass::kOutput); EXPECT_EQ(e->source().range.begin.line, 1u); @@ -90,7 +90,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithDecoration) { EXPECT_EQ(e->name(), "a"); ASSERT_NE(e->type(), nullptr); - EXPECT_TRUE(e->type()->Is()); + EXPECT_TRUE(e->type()->Is()); EXPECT_EQ(e->storage_class(), ast::StorageClass::kOutput); EXPECT_EQ(e->source().range.begin.line, 1u); @@ -124,7 +124,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithDecoration_MulitpleGroups) { EXPECT_EQ(e->name(), "a"); ASSERT_NE(e->type(), nullptr); - EXPECT_TRUE(e->type()->Is()); + EXPECT_TRUE(e->type()->Is()); EXPECT_EQ(e->storage_class(), ast::StorageClass::kOutput); EXPECT_EQ(e->source().range.begin.line, 1u); diff --git a/src/reader/wgsl/parser_impl_param_list_test.cc b/src/reader/wgsl/parser_impl_param_list_test.cc index de27bdacb6..622514d174 100644 --- a/src/reader/wgsl/parser_impl_param_list_test.cc +++ b/src/reader/wgsl/parser_impl_param_list_test.cc @@ -31,7 +31,7 @@ TEST_F(ParserImplTest, ParamList_Single) { auto p = parser("a : i32"); auto& mod = p->get_module(); - auto* i32 = mod.create(); + auto* i32 = mod.create(); auto e = p->expect_param_list(); ASSERT_FALSE(p->has_error()) << p->error(); @@ -52,9 +52,9 @@ TEST_F(ParserImplTest, ParamList_Multiple) { auto p = parser("a : i32, b: f32, c: vec2"); auto& mod = p->get_module(); - auto* i32 = mod.create(); - auto* f32 = mod.create(); - auto* vec2 = mod.create(f32, 2); + auto* i32 = mod.create(); + auto* f32 = mod.create(); + auto* vec2 = mod.create(f32, 2); auto e = p->expect_param_list(); ASSERT_FALSE(p->has_error()) << p->error(); diff --git a/src/reader/wgsl/parser_impl_primary_expression_test.cc b/src/reader/wgsl/parser_impl_primary_expression_test.cc index 4753c63928..8a566afb73 100644 --- a/src/reader/wgsl/parser_impl_primary_expression_test.cc +++ b/src/reader/wgsl/parser_impl_primary_expression_test.cc @@ -194,7 +194,7 @@ TEST_F(ParserImplTest, PrimaryExpression_Cast) { auto p = parser("f32(1)"); auto& mod = p->get_module(); - auto* f32 = mod.create(); + auto* f32 = mod.create(); auto e = p->primary_expression(); EXPECT_TRUE(e.matched); @@ -216,7 +216,7 @@ TEST_F(ParserImplTest, PrimaryExpression_Bitcast) { auto p = parser("bitcast(1)"); auto& mod = p->get_module(); - auto* f32 = mod.create(); + auto* f32 = mod.create(); auto e = p->primary_expression(); EXPECT_TRUE(e.matched); diff --git a/src/reader/wgsl/parser_impl_sampler_type_test.cc b/src/reader/wgsl/parser_impl_sampler_type_test.cc index 5b17627208..b4303cdc2c 100644 --- a/src/reader/wgsl/parser_impl_sampler_type_test.cc +++ b/src/reader/wgsl/parser_impl_sampler_type_test.cc @@ -37,8 +37,8 @@ TEST_F(ParserImplTest, SamplerType_Sampler) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - EXPECT_FALSE(t->As()->IsComparison()); + ASSERT_TRUE(t->Is()); + EXPECT_FALSE(t->As()->IsComparison()); EXPECT_FALSE(p->has_error()); } @@ -48,8 +48,8 @@ TEST_F(ParserImplTest, SamplerType_ComparisonSampler) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - EXPECT_TRUE(t->As()->IsComparison()); + ASSERT_TRUE(t->Is()); + EXPECT_TRUE(t->As()->IsComparison()); EXPECT_FALSE(p->has_error()); } diff --git a/src/reader/wgsl/parser_impl_struct_body_decl_test.cc b/src/reader/wgsl/parser_impl_struct_body_decl_test.cc index 74c7fdfc9e..8577ecce77 100644 --- a/src/reader/wgsl/parser_impl_struct_body_decl_test.cc +++ b/src/reader/wgsl/parser_impl_struct_body_decl_test.cc @@ -26,7 +26,7 @@ TEST_F(ParserImplTest, StructBodyDecl_Parses) { auto p = parser("{a : i32;}"); auto& mod = p->get_module(); - auto* i32 = mod.create(); + auto* i32 = mod.create(); auto m = p->expect_struct_body_decl(); ASSERT_FALSE(p->has_error()); diff --git a/src/reader/wgsl/parser_impl_struct_member_test.cc b/src/reader/wgsl/parser_impl_struct_member_test.cc index f4643d3bfd..4223ca30f4 100644 --- a/src/reader/wgsl/parser_impl_struct_member_test.cc +++ b/src/reader/wgsl/parser_impl_struct_member_test.cc @@ -27,7 +27,7 @@ TEST_F(ParserImplTest, StructMember_Parses) { auto p = parser("a : i32;"); auto& mod = p->get_module(); - auto* i32 = mod.create(); + auto* i32 = mod.create(); auto decos = p->decoration_list(); EXPECT_FALSE(decos.errored); @@ -53,7 +53,7 @@ TEST_F(ParserImplTest, StructMember_ParsesWithDecoration) { auto p = parser("[[offset(2)]] a : i32;"); auto& mod = p->get_module(); - auto* i32 = mod.create(); + auto* i32 = mod.create(); auto decos = p->decoration_list(); EXPECT_FALSE(decos.errored); @@ -84,7 +84,7 @@ TEST_F(ParserImplTest, StructMember_ParsesWithMultipleDecorations) { [[offset(4)]] a : i32;)"); auto& mod = p->get_module(); - auto* i32 = mod.create(); + auto* i32 = mod.create(); auto decos = p->decoration_list(); EXPECT_FALSE(decos.errored); diff --git a/src/reader/wgsl/parser_impl_test.cc b/src/reader/wgsl/parser_impl_test.cc index 475e3c2b4c..44afe10934 100644 --- a/src/reader/wgsl/parser_impl_test.cc +++ b/src/reader/wgsl/parser_impl_test.cc @@ -57,7 +57,7 @@ fn main() -> { # missing return type TEST_F(ParserImplTest, GetRegisteredType) { auto p = parser(""); - ast::type::I32Type i32; + ast::type::I32 i32; p->register_constructed("my_alias", &i32); auto* alias = p->get_constructed("my_alias"); diff --git a/src/reader/wgsl/parser_impl_texture_sampler_types_test.cc b/src/reader/wgsl/parser_impl_texture_sampler_types_test.cc index 182776682a..dc74f2991a 100644 --- a/src/reader/wgsl/parser_impl_texture_sampler_types_test.cc +++ b/src/reader/wgsl/parser_impl_texture_sampler_types_test.cc @@ -44,8 +44,8 @@ TEST_F(ParserImplTest, TextureSamplerTypes_Sampler) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_FALSE(t->As()->IsComparison()); + ASSERT_TRUE(t->Is()); + ASSERT_FALSE(t->As()->IsComparison()); } TEST_F(ParserImplTest, TextureSamplerTypes_SamplerComparison) { @@ -55,8 +55,8 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SamplerComparison) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->As()->IsComparison()); + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->As()->IsComparison()); } TEST_F(ParserImplTest, TextureSamplerTypes_DepthTexture) { @@ -66,9 +66,9 @@ TEST_F(ParserImplTest, TextureSamplerTypes_DepthTexture) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->Is()); - EXPECT_EQ(t->As()->dim(), + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); + EXPECT_EQ(t->As()->dim(), ast::type::TextureDimension::k2d); } @@ -79,11 +79,10 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_F32_Old) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE( - t->As()->type()->Is()); - EXPECT_EQ(t->As()->dim(), + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->As()->type()->Is()); + EXPECT_EQ(t->As()->dim(), ast::type::TextureDimension::k1d); } @@ -94,11 +93,10 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_I32_Old) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE( - t->As()->type()->Is()); - EXPECT_EQ(t->As()->dim(), + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->As()->type()->Is()); + EXPECT_EQ(t->As()->dim(), ast::type::TextureDimension::k2d); } @@ -109,11 +107,10 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_U32_Old) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE( - t->As()->type()->Is()); - EXPECT_EQ(t->As()->dim(), + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->As()->type()->Is()); + EXPECT_EQ(t->As()->dim(), ast::type::TextureDimension::k3d); } @@ -165,11 +162,10 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_F32) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE( - t->As()->type()->Is()); - EXPECT_EQ(t->As()->dim(), + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->As()->type()->Is()); + EXPECT_EQ(t->As()->dim(), ast::type::TextureDimension::k1d); } @@ -180,11 +176,10 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_I32) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE( - t->As()->type()->Is()); - EXPECT_EQ(t->As()->dim(), + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->As()->type()->Is()); + EXPECT_EQ(t->As()->dim(), ast::type::TextureDimension::k2d); } @@ -195,11 +190,10 @@ TEST_F(ParserImplTest, TextureSamplerTypes_SampledTexture_U32) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE( - t->As()->type()->Is()); - EXPECT_EQ(t->As()->dim(), + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->As()->type()->Is()); + EXPECT_EQ(t->As()->dim(), ast::type::TextureDimension::k3d); } @@ -250,12 +244,11 @@ TEST_F(ParserImplTest, TextureSamplerTypes_MultisampledTexture_I32) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->As() - ->type() - ->Is()); - EXPECT_EQ(t->As()->dim(), + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); + ASSERT_TRUE( + t->As()->type()->Is()); + EXPECT_EQ(t->As()->dim(), ast::type::TextureDimension::k2d); } @@ -307,13 +300,13 @@ TEST_F(ParserImplTest, EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->Is()); - EXPECT_EQ(t->As()->image_format(), + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); + EXPECT_EQ(t->As()->image_format(), ast::type::ImageFormat::kR8Unorm); - EXPECT_EQ(t->As()->access(), + EXPECT_EQ(t->As()->access(), ast::AccessControl::kReadOnly); - EXPECT_EQ(t->As()->dim(), + EXPECT_EQ(t->As()->dim(), ast::type::TextureDimension::k1d); } @@ -325,13 +318,13 @@ TEST_F(ParserImplTest, EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->Is()); - EXPECT_EQ(t->As()->image_format(), + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); + EXPECT_EQ(t->As()->image_format(), ast::type::ImageFormat::kR16Float); - EXPECT_EQ(t->As()->access(), + EXPECT_EQ(t->As()->access(), ast::AccessControl::kWriteOnly); - EXPECT_EQ(t->As()->dim(), + EXPECT_EQ(t->As()->dim(), ast::type::TextureDimension::k2d); } @@ -379,13 +372,13 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Readonly1dR8Unorm) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->Is()); - EXPECT_EQ(t->As()->image_format(), + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); + EXPECT_EQ(t->As()->image_format(), ast::type::ImageFormat::kR8Unorm); - EXPECT_EQ(t->As()->access(), + EXPECT_EQ(t->As()->access(), ast::AccessControl::kReadOnly); - EXPECT_EQ(t->As()->dim(), + EXPECT_EQ(t->As()->dim(), ast::type::TextureDimension::k1d); } @@ -396,13 +389,13 @@ TEST_F(ParserImplTest, TextureSamplerTypes_StorageTexture_Writeonly2dR16Float) { EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->Is()); - EXPECT_EQ(t->As()->image_format(), + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); + EXPECT_EQ(t->As()->image_format(), ast::type::ImageFormat::kR16Float); - EXPECT_EQ(t->As()->access(), + EXPECT_EQ(t->As()->access(), ast::AccessControl::kWriteOnly); - EXPECT_EQ(t->As()->dim(), + EXPECT_EQ(t->As()->dim(), ast::type::TextureDimension::k2d); } diff --git a/src/reader/wgsl/parser_impl_type_alias_test.cc b/src/reader/wgsl/parser_impl_type_alias_test.cc index eba08831de..52179e1c90 100644 --- a/src/reader/wgsl/parser_impl_type_alias_test.cc +++ b/src/reader/wgsl/parser_impl_type_alias_test.cc @@ -29,21 +29,21 @@ TEST_F(ParserImplTest, TypeDecl_ParsesType) { auto p = parser("type a = i32"); auto& mod = p->get_module(); - auto* i32 = mod.create(); + auto* i32 = mod.create(); auto t = p->type_alias(); EXPECT_FALSE(p->has_error()); EXPECT_FALSE(t.errored); EXPECT_TRUE(t.matched); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - auto* alias = t->As(); - ASSERT_TRUE(alias->type()->Is()); + ASSERT_TRUE(t->Is()); + auto* alias = t->As(); + ASSERT_TRUE(alias->type()->Is()); ASSERT_EQ(alias->type(), i32); } TEST_F(ParserImplTest, TypeDecl_ParsesStruct_Ident) { - ast::type::StructType str("B", {}); + ast::type::Struct str("B", {}); auto p = parser("type a = B"); p->register_constructed("B", &str); @@ -53,12 +53,12 @@ TEST_F(ParserImplTest, TypeDecl_ParsesStruct_Ident) { EXPECT_FALSE(t.errored); EXPECT_TRUE(t.matched); ASSERT_NE(t.value, nullptr); - ASSERT_TRUE(t->Is()); - auto* alias = t->As(); + ASSERT_TRUE(t->Is()); + auto* alias = t->As(); EXPECT_EQ(alias->name(), "a"); - ASSERT_TRUE(alias->type()->Is()); + ASSERT_TRUE(alias->type()->Is()); - auto* s = alias->type()->As(); + auto* s = alias->type()->As(); EXPECT_EQ(s->name(), "B"); } diff --git a/src/reader/wgsl/parser_impl_type_decl_test.cc b/src/reader/wgsl/parser_impl_type_decl_test.cc index e8a85f8569..a197168573 100644 --- a/src/reader/wgsl/parser_impl_type_decl_test.cc +++ b/src/reader/wgsl/parser_impl_type_decl_test.cc @@ -48,8 +48,8 @@ TEST_F(ParserImplTest, TypeDecl_Identifier) { auto& mod = p->get_module(); - auto* int_type = mod.create(); - auto* alias_type = mod.create("A", int_type); + auto* int_type = mod.create(); + auto* alias_type = mod.create("A", int_type); p->register_constructed("A", alias_type); @@ -58,9 +58,9 @@ TEST_F(ParserImplTest, TypeDecl_Identifier) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); EXPECT_EQ(t.value, alias_type); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* alias = t->As(); + auto* alias = t->As(); EXPECT_EQ(alias->name(), "A"); EXPECT_EQ(alias->type(), int_type); } @@ -80,56 +80,56 @@ TEST_F(ParserImplTest, TypeDecl_Bool) { auto p = parser("bool"); auto& mod = p->get_module(); - auto* bool_type = mod.create(); + auto* bool_type = mod.create(); auto t = p->type_decl(); EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); EXPECT_EQ(t.value, bool_type); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); } TEST_F(ParserImplTest, TypeDecl_F32) { auto p = parser("f32"); auto& mod = p->get_module(); - auto* float_type = mod.create(); + auto* float_type = mod.create(); auto t = p->type_decl(); EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); EXPECT_EQ(t.value, float_type); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); } TEST_F(ParserImplTest, TypeDecl_I32) { auto p = parser("i32"); auto& mod = p->get_module(); - auto* int_type = mod.create(); + auto* int_type = mod.create(); auto t = p->type_decl(); EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); EXPECT_EQ(t.value, int_type); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); } TEST_F(ParserImplTest, TypeDecl_U32) { auto p = parser("u32"); auto& mod = p->get_module(); - auto* uint_type = mod.create(); + auto* uint_type = mod.create(); auto t = p->type_decl(); EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); EXPECT_EQ(t.value, uint_type); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); } struct VecData { @@ -151,8 +151,8 @@ TEST_P(VecTest, Parse) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - EXPECT_TRUE(t->Is()); - EXPECT_EQ(t->As()->size(), params.count); + EXPECT_TRUE(t->Is()); + EXPECT_EQ(t->As()->size(), params.count); } INSTANTIATE_TEST_SUITE_P(ParserImplTest, VecTest, @@ -239,10 +239,10 @@ TEST_F(ParserImplTest, TypeDecl_Ptr) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* ptr = t->As(); - ASSERT_TRUE(ptr->type()->Is()); + auto* ptr = t->As(); + ASSERT_TRUE(ptr->type()->Is()); ASSERT_EQ(ptr->storage_class(), ast::StorageClass::kFunction); } @@ -253,15 +253,15 @@ TEST_F(ParserImplTest, TypeDecl_Ptr_ToVec) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* ptr = t->As(); - ASSERT_TRUE(ptr->type()->Is()); + auto* ptr = t->As(); + ASSERT_TRUE(ptr->type()->Is()); ASSERT_EQ(ptr->storage_class(), ast::StorageClass::kFunction); - auto* vec = ptr->type()->As(); + auto* vec = ptr->type()->As(); ASSERT_EQ(vec->size(), 2u); - ASSERT_TRUE(vec->type()->Is()); + ASSERT_TRUE(vec->type()->Is()); } TEST_F(ParserImplTest, TypeDecl_Ptr_MissingLessThan) { @@ -351,12 +351,12 @@ TEST_F(ParserImplTest, TypeDecl_Array) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* a = t->As(); + auto* a = t->As(); ASSERT_FALSE(a->IsRuntimeArray()); ASSERT_EQ(a->size(), 5u); - ASSERT_TRUE(a->type()->Is()); + ASSERT_TRUE(a->type()->Is()); ASSERT_FALSE(a->has_array_stride()); } @@ -367,12 +367,12 @@ TEST_F(ParserImplTest, TypeDecl_Array_Stride) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* a = t->As(); + auto* a = t->As(); ASSERT_FALSE(a->IsRuntimeArray()); ASSERT_EQ(a->size(), 5u); - ASSERT_TRUE(a->type()->Is()); + ASSERT_TRUE(a->type()->Is()); ASSERT_TRUE(a->has_array_stride()); EXPECT_EQ(a->array_stride(), 16u); } @@ -384,11 +384,11 @@ TEST_F(ParserImplTest, TypeDecl_Array_Runtime_Stride) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* a = t->As(); + auto* a = t->As(); ASSERT_TRUE(a->IsRuntimeArray()); - ASSERT_TRUE(a->type()->Is()); + ASSERT_TRUE(a->type()->Is()); ASSERT_TRUE(a->has_array_stride()); EXPECT_EQ(a->array_stride(), 16u); } @@ -400,11 +400,11 @@ TEST_F(ParserImplTest, TypeDecl_Array_MultipleDecorations_OneBlock) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* a = t->As(); + auto* a = t->As(); ASSERT_TRUE(a->IsRuntimeArray()); - ASSERT_TRUE(a->type()->Is()); + ASSERT_TRUE(a->type()->Is()); auto& decos = a->decorations(); ASSERT_EQ(decos.size(), 2u); @@ -421,11 +421,11 @@ TEST_F(ParserImplTest, TypeDecl_Array_MultipleDecorations_MultipleBlocks) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* a = t->As(); + auto* a = t->As(); ASSERT_TRUE(a->IsRuntimeArray()); - ASSERT_TRUE(a->type()->Is()); + ASSERT_TRUE(a->type()->Is()); auto& decos = a->decorations(); ASSERT_EQ(decos.size(), 2u); @@ -524,11 +524,11 @@ TEST_F(ParserImplTest, TypeDecl_Array_Runtime) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* a = t->As(); + auto* a = t->As(); ASSERT_TRUE(a->IsRuntimeArray()); - ASSERT_TRUE(a->type()->Is()); + ASSERT_TRUE(a->type()->Is()); } TEST_F(ParserImplTest, TypeDecl_Array_BadType) { @@ -621,8 +621,8 @@ TEST_P(MatrixTest, Parse) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - EXPECT_TRUE(t->Is()); - auto* mat = t->As(); + EXPECT_TRUE(t->Is()); + auto* mat = t->As(); EXPECT_EQ(mat->rows(), params.rows); EXPECT_EQ(mat->columns(), params.columns); } @@ -739,24 +739,23 @@ TEST_F(ParserImplTest, TypeDecl_Sampler) { auto p = parser("sampler"); auto& mod = p->get_module(); - auto* type = - mod.create(ast::type::SamplerKind::kSampler); + auto* type = mod.create(ast::type::SamplerKind::kSampler); auto t = p->type_decl(); EXPECT_TRUE(t.matched); EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); EXPECT_EQ(t.value, type); - ASSERT_TRUE(t->Is()); - ASSERT_FALSE(t->As()->IsComparison()); + ASSERT_TRUE(t->Is()); + ASSERT_FALSE(t->As()->IsComparison()); } TEST_F(ParserImplTest, TypeDecl_Texture_Old) { auto p = parser("texture_sampled_cube"); auto& mod = p->get_module(); - ast::type::F32Type f32; - auto* type = mod.create( + ast::type::F32 f32; + auto* type = mod.create( ast::type::TextureDimension::kCube, &f32); auto t = p->type_decl(); @@ -764,18 +763,17 @@ TEST_F(ParserImplTest, TypeDecl_Texture_Old) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr) << p->error(); EXPECT_EQ(t.value, type); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE( - t->As()->type()->Is()); + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->As()->type()->Is()); } TEST_F(ParserImplTest, TypeDecl_Texture) { auto p = parser("texture_cube"); - ast::type::F32Type f32; + ast::type::F32 f32; auto& mod = p->get_module(); - auto* type = mod.create( + auto* type = mod.create( ast::type::TextureDimension::kCube, &f32); auto t = p->type_decl(); @@ -783,10 +781,9 @@ TEST_F(ParserImplTest, TypeDecl_Texture) { EXPECT_FALSE(t.errored); ASSERT_NE(t.value, nullptr); EXPECT_EQ(t.value, type); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE(t->Is()); - ASSERT_TRUE( - t->As()->type()->Is()); + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->As()->type()->Is()); } } // namespace diff --git a/src/reader/wgsl/parser_impl_variable_decl_test.cc b/src/reader/wgsl/parser_impl_variable_decl_test.cc index fdc17c9004..f1a9ea629c 100644 --- a/src/reader/wgsl/parser_impl_variable_decl_test.cc +++ b/src/reader/wgsl/parser_impl_variable_decl_test.cc @@ -32,7 +32,7 @@ TEST_F(ParserImplTest, VariableDecl_Parses) { ASSERT_NE(var.value, nullptr); EXPECT_EQ(var->name(), "my_var"); EXPECT_NE(var->type(), nullptr); - EXPECT_TRUE(var->type()->Is()); + EXPECT_TRUE(var->type()->Is()); EXPECT_EQ(var->source().range.begin.line, 1u); EXPECT_EQ(var->source().range.begin.column, 5u); @@ -70,7 +70,7 @@ TEST_F(ParserImplTest, VariableDecl_WithStorageClass) { EXPECT_FALSE(p->has_error()); ASSERT_NE(v.value, nullptr); EXPECT_EQ(v->name(), "my_var"); - EXPECT_TRUE(v->type()->Is()); + EXPECT_TRUE(v->type()->Is()); EXPECT_EQ(v->storage_class(), ast::StorageClass::kPrivate); EXPECT_EQ(v->source().range.begin.line, 1u); diff --git a/src/reader/wgsl/parser_impl_variable_ident_decl_test.cc b/src/reader/wgsl/parser_impl_variable_ident_decl_test.cc index da48b8873f..427a93a950 100644 --- a/src/reader/wgsl/parser_impl_variable_ident_decl_test.cc +++ b/src/reader/wgsl/parser_impl_variable_ident_decl_test.cc @@ -34,7 +34,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_Parses) { ASSERT_FALSE(decl.errored); ASSERT_EQ(decl->name, "my_var"); ASSERT_NE(decl->type, nullptr); - ASSERT_TRUE(decl->type->Is()); + ASSERT_TRUE(decl->type->Is()); ASSERT_EQ(decl->source.range.begin.line, 1u); ASSERT_EQ(decl->source.range.begin.column, 1u); @@ -83,7 +83,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_InvalidType) { } TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) { - ast::type::I32Type i32; + ast::type::I32 i32; ast::StructMember mem("a", &i32, ast::StructMemberDecorationList{}); ast::StructMemberList members; @@ -94,7 +94,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) { decos.push_back(&block_deco); ast::Struct str(decos, members); - ast::type::StructType s("S", &str); + ast::type::Struct s("S", &str); auto p = parser("my_var : [[access(read)]] S"); p->register_constructed("S", &s); @@ -104,12 +104,12 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) { ASSERT_FALSE(decl.errored); ASSERT_EQ(decl->name, "my_var"); ASSERT_NE(decl->type, nullptr); - ASSERT_TRUE(decl->type->Is()); - EXPECT_TRUE(decl->type->As()->IsReadOnly()); + ASSERT_TRUE(decl->type->Is()); + EXPECT_TRUE(decl->type->As()->IsReadOnly()); } TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) { - ast::type::I32Type i32; + ast::type::I32 i32; ast::StructMember mem("a", &i32, ast::StructMemberDecorationList{}); ast::StructMemberList members; @@ -120,7 +120,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) { decos.push_back(&block_deco); ast::Struct str(decos, members); - ast::type::StructType s("S", &str); + ast::type::Struct s("S", &str); auto p = parser("my_var : [[access(read_write)]] S"); p->register_constructed("S", &s); @@ -130,12 +130,12 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) { ASSERT_FALSE(decl.errored); ASSERT_EQ(decl->name, "my_var"); ASSERT_NE(decl->type, nullptr); - ASSERT_TRUE(decl->type->Is()); - EXPECT_TRUE(decl->type->As()->IsReadWrite()); + ASSERT_TRUE(decl->type->Is()); + EXPECT_TRUE(decl->type->As()->IsReadWrite()); } TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDecoFail) { - ast::type::I32Type i32; + ast::type::I32 i32; ast::StructMember mem("a", &i32, ast::StructMemberDecorationList{}); ast::StructMemberList members; @@ -146,7 +146,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDecoFail) { decos.push_back(&block_deco); ast::Struct str(decos, members); - ast::type::StructType s("S", &str); + ast::type::Struct s("S", &str); auto p = parser("my_var : [[access(read), access(read_write)]] S"); p->register_constructed("S", &s); @@ -158,7 +158,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDecoFail) { } TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDeco_MultiBlock_Fail) { - ast::type::I32Type i32; + ast::type::I32 i32; ast::StructMember mem("a", &i32, ast::StructMemberDecorationList{}); ast::StructMemberList members; @@ -169,7 +169,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDeco_MultiBlock_Fail) { decos.push_back(&block_deco); ast::Struct str(decos, members); - ast::type::StructType s("S", &str); + ast::type::Struct s("S", &str); auto p = parser("my_var : [[access(read)]][[access(read_write)]] S"); p->register_constructed("S", &s); @@ -197,7 +197,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_AccessDecoIllegalValue) { } TEST_F(ParserImplTest, VariableIdentDecl_NonAccessDecoFail) { - ast::type::I32Type i32; + ast::type::I32 i32; ast::StructMember mem("a", &i32, ast::StructMemberDecorationList{}); ast::StructMemberList members; @@ -208,7 +208,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_NonAccessDecoFail) { decos.push_back(&block_deco); ast::Struct str(decos, members); - ast::type::StructType s("S", &str); + ast::type::Struct s("S", &str); auto p = parser("my_var : [[stride(1)]] S"); p->register_constructed("S", &s); diff --git a/src/transform/bound_array_accessors_transform.cc b/src/transform/bound_array_accessors_transform.cc index ab5c20deda..86d83ee106 100644 --- a/src/transform/bound_array_accessors_transform.cc +++ b/src/transform/bound_array_accessors_transform.cc @@ -179,17 +179,15 @@ bool BoundArrayAccessorsTransform::ProcessArrayAccessor( } auto* ret_type = expr->array()->result_type()->UnwrapAll(); - if (!ret_type->Is() && - !ret_type->Is() && - !ret_type->Is()) { + if (!ret_type->Is() && !ret_type->Is() && + !ret_type->Is()) { return true; } - if (ret_type->Is() || - ret_type->Is()) { - uint32_t size = ret_type->Is() - ? ret_type->As()->size() - : ret_type->As()->size(); + if (ret_type->Is() || ret_type->Is()) { + uint32_t size = ret_type->Is() + ? ret_type->As()->size() + : ret_type->As()->size(); if (size == 0) { error_ = "invalid 0 size for array or vector"; return false; @@ -201,7 +199,7 @@ bool BoundArrayAccessorsTransform::ProcessArrayAccessor( } else { // The row accessor would have been an embedded array accessor and already // handled, so we just need to do columns here. - uint32_t size = ret_type->As()->columns(); + uint32_t size = ret_type->As()->columns(); if (!ProcessAccessExpression(expr, size)) { return false; } @@ -234,7 +232,7 @@ bool BoundArrayAccessorsTransform::ProcessAccessExpression( return false; } } else { - auto* u32 = mod_->create(); + auto* u32 = mod_->create(); ast::ExpressionList cast_expr; cast_expr.push_back(expr->idx_expr()); diff --git a/src/transform/bound_array_accessors_transform_test.cc b/src/transform/bound_array_accessors_transform_test.cc index 7805d8c132..8df7a7cfd9 100644 --- a/src/transform/bound_array_accessors_transform_test.cc +++ b/src/transform/bound_array_accessors_transform_test.cc @@ -89,7 +89,7 @@ class BoundArrayAccessorsTest : public testing::Test { Context ctx_; ast::Module mod_; TypeDeterminer td_; - ast::type::VoidType void_type_; + ast::type::Void void_type_; std::unique_ptr manager_; BoundArrayAccessorsTransform* transform_; ast::BlockStatement* body_ = nullptr; @@ -102,10 +102,10 @@ TEST_F(BoundArrayAccessorsTest, Ptrs_Clamp) { // // -> const b : ptr = a[min(u32(c), 2)] - ast::type::F32Type f32; - ast::type::U32Type u32; - ast::type::ArrayType ary(&f32, 3); - ast::type::PointerType ptr_type(&f32, ast::StorageClass::kFunction); + ast::type::F32 f32; + ast::type::U32 u32; + ast::type::Array ary(&f32, 3); + ast::type::Pointer ptr_type(&f32, ast::StorageClass::kFunction); SetupFunctionAndBody(); DeclareVariable( @@ -141,7 +141,7 @@ TEST_F(BoundArrayAccessorsTest, Ptrs_Clamp) { ASSERT_TRUE(idx->params()[0]->Is()); ASSERT_TRUE(idx->params()[0]->Is()); auto* tc = idx->params()[0]->As(); - EXPECT_TRUE(tc->type()->Is()); + EXPECT_TRUE(tc->type()->Is()); ASSERT_EQ(tc->values().size(), 1u); ASSERT_EQ(tc->values()[0], access_idx); @@ -152,7 +152,7 @@ TEST_F(BoundArrayAccessorsTest, Ptrs_Clamp) { EXPECT_EQ(scalar->literal()->As()->value(), 2u); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); - ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); + ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); } TEST_F(BoundArrayAccessorsTest, Array_Idx_Nested_Scalar) { @@ -163,10 +163,10 @@ TEST_F(BoundArrayAccessorsTest, Array_Idx_Nested_Scalar) { // // -> var c : f32 = a[min(u32(b[min(u32(i), 4)]), 2)]; - ast::type::F32Type f32; - ast::type::U32Type u32; - ast::type::ArrayType ary3(&f32, 3); - ast::type::ArrayType ary5(&f32, 5); + ast::type::F32 f32; + ast::type::U32 u32; + ast::type::Array ary3(&f32, 3); + ast::type::Array ary5(&f32, 5); SetupFunctionAndBody(); DeclareVariable( @@ -204,7 +204,7 @@ TEST_F(BoundArrayAccessorsTest, Array_Idx_Nested_Scalar) { ASSERT_TRUE(idx->params()[0]->Is()); ASSERT_TRUE(idx->params()[0]->Is()); auto* tc = idx->params()[0]->As(); - EXPECT_TRUE(tc->type()->Is()); + EXPECT_TRUE(tc->type()->Is()); ASSERT_EQ(tc->values().size(), 1u); auto* sub = tc->values()[0]; @@ -222,7 +222,7 @@ TEST_F(BoundArrayAccessorsTest, Array_Idx_Nested_Scalar) { ASSERT_TRUE(sub_idx->params()[0]->Is()); ASSERT_TRUE(sub_idx->params()[0]->Is()); tc = sub_idx->params()[0]->As(); - EXPECT_TRUE(tc->type()->Is()); + EXPECT_TRUE(tc->type()->Is()); ASSERT_EQ(tc->values().size(), 1u); ASSERT_EQ(tc->values()[0], b_access_idx); @@ -239,7 +239,7 @@ TEST_F(BoundArrayAccessorsTest, Array_Idx_Nested_Scalar) { EXPECT_EQ(scalar->literal()->As()->value(), 2u); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); - ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); + ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); } TEST_F(BoundArrayAccessorsTest, Array_Idx_Scalar) { @@ -248,9 +248,9 @@ TEST_F(BoundArrayAccessorsTest, Array_Idx_Scalar) { // // -> var b : f32 = a[1]; - ast::type::F32Type f32; - ast::type::U32Type u32; - ast::type::ArrayType ary(&f32, 3); + ast::type::F32 f32; + ast::type::U32 u32; + ast::type::Array ary(&f32, 3); SetupFunctionAndBody(); DeclareVariable( @@ -278,7 +278,7 @@ TEST_F(BoundArrayAccessorsTest, Array_Idx_Scalar) { EXPECT_EQ(scalar->literal()->As()->value(), 1u); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); - ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); + ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); } TEST_F(BoundArrayAccessorsTest, Array_Idx_Expr) { @@ -288,9 +288,9 @@ TEST_F(BoundArrayAccessorsTest, Array_Idx_Expr) { // // -> var b : f32 = a[min(u32(c + 2 - 3), 2)] - ast::type::F32Type f32; - ast::type::U32Type u32; - ast::type::ArrayType ary(&f32, 3); + ast::type::F32 f32; + ast::type::U32 u32; + ast::type::Array ary(&f32, 3); SetupFunctionAndBody(); DeclareVariable( @@ -329,7 +329,7 @@ TEST_F(BoundArrayAccessorsTest, Array_Idx_Expr) { ASSERT_TRUE(idx->params()[0]->Is()); ASSERT_TRUE(idx->params()[0]->Is()); auto* tc = idx->params()[0]->As(); - EXPECT_TRUE(tc->type()->Is()); + EXPECT_TRUE(tc->type()->Is()); ASSERT_EQ(tc->values().size(), 1u); ASSERT_EQ(tc->values()[0], access_idx); @@ -340,7 +340,7 @@ TEST_F(BoundArrayAccessorsTest, Array_Idx_Expr) { EXPECT_EQ(scalar->literal()->As()->value(), 2u); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); - ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); + ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); } TEST_F(BoundArrayAccessorsTest, Array_Idx_Negative) { @@ -349,9 +349,9 @@ TEST_F(BoundArrayAccessorsTest, Array_Idx_Negative) { // // -> var b : f32 = a[0] - ast::type::F32Type f32; - ast::type::I32Type i32; - ast::type::ArrayType ary(&f32, 3); + ast::type::F32 f32; + ast::type::I32 i32; + ast::type::Array ary(&f32, 3); SetupFunctionAndBody(); DeclareVariable( @@ -379,7 +379,7 @@ TEST_F(BoundArrayAccessorsTest, Array_Idx_Negative) { EXPECT_EQ(scalar->literal()->As()->value(), 0); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); - ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); + ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); } TEST_F(BoundArrayAccessorsTest, Array_Idx_OutOfBounds) { @@ -388,9 +388,9 @@ TEST_F(BoundArrayAccessorsTest, Array_Idx_OutOfBounds) { // // -> var b : f32 = a[2] - ast::type::F32Type f32; - ast::type::U32Type u32; - ast::type::ArrayType ary(&f32, 3); + ast::type::F32 f32; + ast::type::U32 u32; + ast::type::Array ary(&f32, 3); SetupFunctionAndBody(); DeclareVariable( @@ -418,7 +418,7 @@ TEST_F(BoundArrayAccessorsTest, Array_Idx_OutOfBounds) { EXPECT_EQ(scalar->literal()->As()->value(), 2u); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); - ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); + ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); } TEST_F(BoundArrayAccessorsTest, Vector_Idx_Scalar) { @@ -427,9 +427,9 @@ TEST_F(BoundArrayAccessorsTest, Vector_Idx_Scalar) { // // -> var b : f32 = a[1] - ast::type::F32Type f32; - ast::type::U32Type u32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::U32 u32; + ast::type::Vector vec(&f32, 3); SetupFunctionAndBody(); DeclareVariable( @@ -457,7 +457,7 @@ TEST_F(BoundArrayAccessorsTest, Vector_Idx_Scalar) { EXPECT_EQ(scalar->literal()->As()->value(), 1u); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); - ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); + ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); } TEST_F(BoundArrayAccessorsTest, Vector_Idx_Expr) { @@ -467,9 +467,9 @@ TEST_F(BoundArrayAccessorsTest, Vector_Idx_Expr) { // // -> var b : f32 = a[min(u32(c + 2 - 3), 2)] - ast::type::F32Type f32; - ast::type::U32Type u32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::U32 u32; + ast::type::Vector vec(&f32, 3); SetupFunctionAndBody(); DeclareVariable( @@ -507,7 +507,7 @@ TEST_F(BoundArrayAccessorsTest, Vector_Idx_Expr) { ASSERT_TRUE(idx->params()[0]->Is()); ASSERT_TRUE(idx->params()[0]->Is()); auto* tc = idx->params()[0]->As(); - EXPECT_TRUE(tc->type()->Is()); + EXPECT_TRUE(tc->type()->Is()); ASSERT_EQ(tc->values().size(), 1u); ASSERT_EQ(tc->values()[0], access_idx); @@ -518,7 +518,7 @@ TEST_F(BoundArrayAccessorsTest, Vector_Idx_Expr) { EXPECT_EQ(scalar->literal()->As()->value(), 2u); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); - ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); + ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); } TEST_F(BoundArrayAccessorsTest, Vector_Idx_Negative) { @@ -527,9 +527,9 @@ TEST_F(BoundArrayAccessorsTest, Vector_Idx_Negative) { // // -> var b : f32 = a[0] - ast::type::F32Type f32; - ast::type::I32Type i32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::I32 i32; + ast::type::Vector vec(&f32, 3); SetupFunctionAndBody(); DeclareVariable( @@ -557,7 +557,7 @@ TEST_F(BoundArrayAccessorsTest, Vector_Idx_Negative) { EXPECT_EQ(scalar->literal()->As()->value(), 0); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); - ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); + ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); } TEST_F(BoundArrayAccessorsTest, Vector_Idx_OutOfBounds) { @@ -566,9 +566,9 @@ TEST_F(BoundArrayAccessorsTest, Vector_Idx_OutOfBounds) { // // -> var b : f32 = a[2] - ast::type::F32Type f32; - ast::type::U32Type u32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::U32 u32; + ast::type::Vector vec(&f32, 3); SetupFunctionAndBody(); DeclareVariable( @@ -596,7 +596,7 @@ TEST_F(BoundArrayAccessorsTest, Vector_Idx_OutOfBounds) { EXPECT_EQ(scalar->literal()->As()->value(), 2u); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); - ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); + ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); } TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Scalar) { @@ -605,9 +605,9 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Scalar) { // // -> var b : f32 = a[2][1] - ast::type::F32Type f32; - ast::type::U32Type u32; - ast::type::MatrixType mat(&f32, 2, 3); + ast::type::F32 f32; + ast::type::U32 u32; + ast::type::Matrix mat(&f32, 2, 3); SetupFunctionAndBody(); DeclareVariable( @@ -641,7 +641,7 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Scalar) { EXPECT_EQ(scalar->literal()->As()->value(), 2u); ASSERT_NE(ary->idx_expr()->result_type(), nullptr); - ASSERT_TRUE(ary->idx_expr()->result_type()->Is()); + ASSERT_TRUE(ary->idx_expr()->result_type()->Is()); ASSERT_TRUE(ptr->idx_expr()->Is()); ASSERT_TRUE(ptr->idx_expr()->Is()); @@ -651,7 +651,7 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Scalar) { EXPECT_EQ(scalar->literal()->As()->value(), 1u); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); - ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); + ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); } TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Expr_Column) { @@ -661,9 +661,9 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Expr_Column) { // // -> var b : f32 = a[min(u32(c + 2 - 3), 2)][1] - ast::type::F32Type f32; - ast::type::U32Type u32; - ast::type::MatrixType mat(&f32, 2, 3); + ast::type::F32 f32; + ast::type::U32 u32; + ast::type::Matrix mat(&f32, 2, 3); SetupFunctionAndBody(); DeclareVariable( @@ -708,7 +708,7 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Expr_Column) { ASSERT_TRUE(idx->params()[0]->Is()); ASSERT_TRUE(idx->params()[0]->Is()); auto* tc = idx->params()[0]->As(); - EXPECT_TRUE(tc->type()->Is()); + EXPECT_TRUE(tc->type()->Is()); ASSERT_EQ(tc->values().size(), 1u); ASSERT_EQ(tc->values()[0], access_idx); @@ -719,7 +719,7 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Expr_Column) { EXPECT_EQ(scalar->literal()->As()->value(), 2u); ASSERT_NE(ary->idx_expr()->result_type(), nullptr); - ASSERT_TRUE(ary->idx_expr()->result_type()->Is()); + ASSERT_TRUE(ary->idx_expr()->result_type()->Is()); ASSERT_TRUE(ptr->idx_expr()->Is()); ASSERT_TRUE(ptr->idx_expr()->Is()); @@ -729,7 +729,7 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Expr_Column) { EXPECT_EQ(scalar->literal()->As()->value(), 1u); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); - ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); + ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); } TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Expr_Row) { @@ -739,9 +739,9 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Expr_Row) { // // -> var b : f32 = a[1][min(u32(c + 2 - 3), 1)] - ast::type::F32Type f32; - ast::type::U32Type u32; - ast::type::MatrixType mat(&f32, 2, 3); + ast::type::F32 f32; + ast::type::U32 u32; + ast::type::Matrix mat(&f32, 2, 3); SetupFunctionAndBody(); DeclareVariable( @@ -794,7 +794,7 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Expr_Row) { ASSERT_TRUE(idx->params()[0]->Is()); ASSERT_TRUE(idx->params()[0]->Is()); auto* tc = idx->params()[0]->As(); - EXPECT_TRUE(tc->type()->Is()); + EXPECT_TRUE(tc->type()->Is()); ASSERT_EQ(tc->values().size(), 1u); ASSERT_EQ(tc->values()[0], access_idx); @@ -805,10 +805,10 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Expr_Row) { EXPECT_EQ(scalar->literal()->As()->value(), 1u); ASSERT_NE(ary->idx_expr()->result_type(), nullptr); - ASSERT_TRUE(ary->idx_expr()->result_type()->Is()); + ASSERT_TRUE(ary->idx_expr()->result_type()->Is()); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); - ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); + ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); } TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Negative_Column) { @@ -816,9 +816,9 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Negative_Column) { // var b : f32 = a[-1][1] // // -> var b : f32 = a[0][1] - ast::type::F32Type f32; - ast::type::I32Type i32; - ast::type::MatrixType mat(&f32, 2, 3); + ast::type::F32 f32; + ast::type::I32 i32; + ast::type::Matrix mat(&f32, 2, 3); SetupFunctionAndBody(); DeclareVariable( @@ -852,7 +852,7 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Negative_Column) { EXPECT_EQ(scalar->literal()->As()->value(), 0); ASSERT_NE(ary->idx_expr()->result_type(), nullptr); - ASSERT_TRUE(ary->idx_expr()->result_type()->Is()); + ASSERT_TRUE(ary->idx_expr()->result_type()->Is()); ASSERT_TRUE(ptr->idx_expr()->Is()); ASSERT_TRUE(ptr->idx_expr()->Is()); @@ -862,7 +862,7 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Negative_Column) { EXPECT_EQ(scalar->literal()->As()->value(), 1); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); - ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); + ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); } TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Negative_Row) { @@ -870,9 +870,9 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Negative_Row) { // var b : f32 = a[2][-1] // // -> var b : f32 = a[2][0] - ast::type::F32Type f32; - ast::type::I32Type i32; - ast::type::MatrixType mat(&f32, 2, 3); + ast::type::F32 f32; + ast::type::I32 i32; + ast::type::Matrix mat(&f32, 2, 3); SetupFunctionAndBody(); DeclareVariable( @@ -906,7 +906,7 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Negative_Row) { EXPECT_EQ(scalar->literal()->As()->value(), 2); ASSERT_NE(ary->idx_expr()->result_type(), nullptr); - ASSERT_TRUE(ary->idx_expr()->result_type()->Is()); + ASSERT_TRUE(ary->idx_expr()->result_type()->Is()); ASSERT_TRUE(ptr->idx_expr()->Is()); ASSERT_TRUE(ptr->idx_expr()->Is()); @@ -916,7 +916,7 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Negative_Row) { EXPECT_EQ(scalar->literal()->As()->value(), 0); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); - ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); + ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); } TEST_F(BoundArrayAccessorsTest, Matrix_Idx_OutOfBounds_Column) { @@ -925,9 +925,9 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_OutOfBounds_Column) { // // -> var b : f32 = a[2][1] - ast::type::F32Type f32; - ast::type::U32Type u32; - ast::type::MatrixType mat(&f32, 2, 3); + ast::type::F32 f32; + ast::type::U32 u32; + ast::type::Matrix mat(&f32, 2, 3); SetupFunctionAndBody(); DeclareVariable( @@ -961,7 +961,7 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_OutOfBounds_Column) { EXPECT_EQ(scalar->literal()->As()->value(), 2u); ASSERT_NE(ary->idx_expr()->result_type(), nullptr); - ASSERT_TRUE(ary->idx_expr()->result_type()->Is()); + ASSERT_TRUE(ary->idx_expr()->result_type()->Is()); ASSERT_TRUE(ptr->idx_expr()->Is()); ASSERT_TRUE(ptr->idx_expr()->Is()); @@ -971,7 +971,7 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_OutOfBounds_Column) { EXPECT_EQ(scalar->literal()->As()->value(), 1u); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); - ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); + ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); } TEST_F(BoundArrayAccessorsTest, Matrix_Idx_OutOfBounds_Row) { @@ -980,9 +980,9 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_OutOfBounds_Row) { // // -> var b : f32 = a[2][1] - ast::type::F32Type f32; - ast::type::U32Type u32; - ast::type::MatrixType mat(&f32, 2, 3); + ast::type::F32 f32; + ast::type::U32 u32; + ast::type::Matrix mat(&f32, 2, 3); SetupFunctionAndBody(); DeclareVariable( @@ -1016,7 +1016,7 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_OutOfBounds_Row) { EXPECT_EQ(scalar->literal()->As()->value(), 2u); ASSERT_NE(ary->idx_expr()->result_type(), nullptr); - ASSERT_TRUE(ary->idx_expr()->result_type()->Is()); + ASSERT_TRUE(ary->idx_expr()->result_type()->Is()); ASSERT_TRUE(ptr->idx_expr()->Is()); ASSERT_TRUE(ptr->idx_expr()->Is()); @@ -1026,7 +1026,7 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_OutOfBounds_Row) { EXPECT_EQ(scalar->literal()->As()->value(), 1u); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); - ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); + ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); } // TODO(dsinclair): Implement when constant_id exists diff --git a/src/transform/vertex_pulling_transform.cc b/src/transform/vertex_pulling_transform.cc index 40cfc4abd2..21aa053eb3 100644 --- a/src/transform/vertex_pulling_transform.cc +++ b/src/transform/vertex_pulling_transform.cc @@ -220,7 +220,7 @@ void VertexPullingTransform::ConvertVertexInputVariablesToPrivate() { void VertexPullingTransform::AddVertexStorageBuffers() { // TODO(idanr): Make this readonly https://github.com/gpuweb/gpuweb/issues/935 // The array inside the struct definition - auto internal_array = std::make_unique(GetU32Type()); + auto internal_array = std::make_unique(GetU32Type()); ast::ArrayDecorationList ary_decos; ary_decos.push_back(create(4u, Source{})); internal_array->set_decorations(std::move(ary_decos)); @@ -238,7 +238,7 @@ void VertexPullingTransform::AddVertexStorageBuffers() { ast::StructDecorationList decos; decos.push_back(create(Source{})); - auto* struct_type = mod_->create( + auto* struct_type = mod_->create( kStructName, create(std::move(decos), std::move(members))); for (uint32_t i = 0; i < vertex_state_->vertex_buffers.size(); ++i) { @@ -412,20 +412,19 @@ ast::Expression* VertexPullingTransform::AccessVec(uint32_t buffer, } return create( - mod_->create(base_type, count), - std::move(expr_list)); + mod_->create(base_type, count), std::move(expr_list)); } ast::type::Type* VertexPullingTransform::GetU32Type() { - return mod_->create(); + return mod_->create(); } ast::type::Type* VertexPullingTransform::GetI32Type() { - return mod_->create(); + return mod_->create(); } ast::type::Type* VertexPullingTransform::GetF32Type() { - return mod_->create(); + return mod_->create(); } VertexBufferLayoutDescriptor::VertexBufferLayoutDescriptor() = default; diff --git a/src/transform/vertex_pulling_transform_test.cc b/src/transform/vertex_pulling_transform_test.cc index 093d7fc254..e4657a4ac6 100644 --- a/src/transform/vertex_pulling_transform_test.cc +++ b/src/transform/vertex_pulling_transform_test.cc @@ -47,7 +47,7 @@ class VertexPullingTransformHelper { // Create basic module with an entry point and vertex function void InitBasicModule() { auto* func = create("main", ast::VariableList{}, - mod_->create(), + mod_->create(), create()); func->add_decoration( create(ast::PipelineStage::kVertex, Source{})); @@ -125,7 +125,7 @@ TEST_F(VertexPullingTransformTest, Error_InvalidEntryPoint) { TEST_F(VertexPullingTransformTest, Error_EntryPointWrongStage) { auto* func = create("main", ast::VariableList{}, - mod()->create(), + mod()->create(), create()); func->add_decoration( create(ast::PipelineStage::kFragment, Source{})); @@ -145,7 +145,7 @@ TEST_F(VertexPullingTransformTest, BasicModule) { TEST_F(VertexPullingTransformTest, OneAttribute) { InitBasicModule(); - ast::type::F32Type f32; + ast::type::F32 f32; AddVertexInputVariable(0, "var_a", &f32); InitTransform({{{4, InputStepMode::kVertex, {{VertexFormat::kF32, 0, 0}}}}}); @@ -229,7 +229,7 @@ TEST_F(VertexPullingTransformTest, OneAttribute) { TEST_F(VertexPullingTransformTest, OneInstancedAttribute) { InitBasicModule(); - ast::type::F32Type f32; + ast::type::F32 f32; AddVertexInputVariable(0, "var_a", &f32); InitTransform( @@ -314,7 +314,7 @@ TEST_F(VertexPullingTransformTest, OneInstancedAttribute) { TEST_F(VertexPullingTransformTest, OneAttributeDifferentOutputSet) { InitBasicModule(); - ast::type::F32Type f32; + ast::type::F32 f32; AddVertexInputVariable(0, "var_a", &f32); InitTransform({{{4, InputStepMode::kVertex, {{VertexFormat::kF32, 0, 0}}}}}); @@ -400,11 +400,11 @@ TEST_F(VertexPullingTransformTest, OneAttributeDifferentOutputSet) { TEST_F(VertexPullingTransformTest, ExistingVertexIndexAndInstanceIndex) { InitBasicModule(); - ast::type::F32Type f32; + ast::type::F32 f32; AddVertexInputVariable(0, "var_a", &f32); AddVertexInputVariable(1, "var_b", &f32); - ast::type::I32Type i32; + ast::type::I32 i32; { auto* vertex_index_var = create(create( @@ -564,10 +564,10 @@ TEST_F(VertexPullingTransformTest, ExistingVertexIndexAndInstanceIndex) { TEST_F(VertexPullingTransformTest, TwoAttributesSameBuffer) { InitBasicModule(); - ast::type::F32Type f32; + ast::type::F32 f32; AddVertexInputVariable(0, "var_a", &f32); - ast::type::ArrayType vec4_f32{&f32, 4u}; + ast::type::Array vec4_f32{&f32, 4u}; AddVertexInputVariable(1, "var_b", &vec4_f32); InitTransform( @@ -745,14 +745,14 @@ TEST_F(VertexPullingTransformTest, TwoAttributesSameBuffer) { TEST_F(VertexPullingTransformTest, FloatVectorAttributes) { InitBasicModule(); - ast::type::F32Type f32; - ast::type::ArrayType vec2_f32{&f32, 2u}; + ast::type::F32 f32; + ast::type::Array vec2_f32{&f32, 2u}; AddVertexInputVariable(0, "var_a", &vec2_f32); - ast::type::ArrayType vec3_f32{&f32, 3u}; + ast::type::Array vec3_f32{&f32, 3u}; AddVertexInputVariable(1, "var_b", &vec3_f32); - ast::type::ArrayType vec4_f32{&f32, 4u}; + ast::type::Array vec4_f32{&f32, 4u}; AddVertexInputVariable(2, "var_c", &vec4_f32); InitTransform( diff --git a/src/type_determiner.cc b/src/type_determiner.cc index b0eaa9a17f..6679e206e2 100644 --- a/src/type_determiner.cc +++ b/src/type_determiner.cc @@ -88,12 +88,12 @@ void TypeDeterminer::set_referenced_from_function_if_needed( bool TypeDeterminer::Determine() { for (auto& iter : mod_->types()) { auto& type = iter.second; - if (!type->Is() || - !type->Is()) { + if (!type->Is() || + !type->Is()) { continue; } if (!DetermineStorageTextureSubtype( - type->As())) { + type->As())) { set_error(Source{}, "unable to determine storage texture subtype for: " + type->type_name()); return false; @@ -330,13 +330,13 @@ bool TypeDeterminer::DetermineArrayAccessor( auto* res = expr->array()->result_type(); auto* parent_type = res->UnwrapAll(); ast::type::Type* ret = nullptr; - if (parent_type->Is()) { - ret = parent_type->As()->type(); - } else if (parent_type->Is()) { - ret = parent_type->As()->type(); - } else if (parent_type->Is()) { - auto* m = parent_type->As(); - ret = mod_->create(m->type(), m->rows()); + if (parent_type->Is()) { + ret = parent_type->As()->type(); + } else if (parent_type->Is()) { + ret = parent_type->As()->type(); + } else if (parent_type->Is()) { + auto* m = parent_type->As(); + ret = mod_->create(m->type(), m->rows()); } else { set_error(expr->source(), "invalid parent type (" + parent_type->type_name() + @@ -345,16 +345,15 @@ bool TypeDeterminer::DetermineArrayAccessor( } // If we're extracting from a pointer, we return a pointer. - if (res->Is()) { - ret = mod_->create( - ret, res->As()->storage_class()); - } else if (parent_type->Is() && - !parent_type->As()->type()->is_scalar()) { + if (res->Is()) { + ret = mod_->create( + ret, res->As()->storage_class()); + } else if (parent_type->Is() && + !parent_type->As()->type()->is_scalar()) { // If we extract a non-scalar from an array then we also get a pointer. We // will generate a Function storage class variable to store this // into. - ret = - mod_->create(ret, ast::StorageClass::kFunction); + ret = mod_->create(ret, ast::StorageClass::kFunction); } expr->set_result_type(ret); @@ -516,11 +515,11 @@ bool TypeDeterminer::DetermineIntrinsic(ast::IdentifierExpression* ident, } if (ident->intrinsic() == ast::Intrinsic::kAny || ident->intrinsic() == ast::Intrinsic::kAll) { - expr->func()->set_result_type(mod_->create()); + expr->func()->set_result_type(mod_->create()); return true; } if (ident->intrinsic() == ast::Intrinsic::kArrayLength) { - expr->func()->set_result_type(mod_->create()); + expr->func()->set_result_type(mod_->create()); return true; } if (ast::intrinsic::IsFloatClassificationIntrinsic(ident->intrinsic())) { @@ -530,12 +529,12 @@ bool TypeDeterminer::DetermineIntrinsic(ast::IdentifierExpression* ident, return false; } - auto* bool_type = mod_->create(); + auto* bool_type = mod_->create(); auto* param_type = expr->params()[0]->result_type()->UnwrapPtrIfNeeded(); - if (param_type->Is()) { - expr->func()->set_result_type(mod_->create( - bool_type, param_type->As()->size())); + if (param_type->Is()) { + expr->func()->set_result_type(mod_->create( + bool_type, param_type->As()->size())); } else { expr->func()->set_result_type(bool_type); } @@ -547,13 +546,13 @@ bool TypeDeterminer::DetermineIntrinsic(ast::IdentifierExpression* ident, auto* texture_param = expr->params()[0]; if (!texture_param->result_type() ->UnwrapPtrIfNeeded() - ->Is()) { + ->Is()) { set_error(expr->source(), "invalid first argument for " + ident->name()); return false; } - ast::type::TextureType* texture = texture_param->result_type() - ->UnwrapPtrIfNeeded() - ->As(); + ast::type::Texture* texture = texture_param->result_type() + ->UnwrapPtrIfNeeded() + ->As(); bool is_array = false; switch (texture->dim()) { @@ -658,34 +657,34 @@ bool TypeDeterminer::DetermineIntrinsic(ast::IdentifierExpression* ident, ident->set_intrinsic_signature( std::make_unique(param)); - if (texture->Is()) { - expr->func()->set_result_type(mod_->create()); + if (texture->Is()) { + expr->func()->set_result_type(mod_->create()); return true; } - if (!texture->Is() && - !(texture->Is() || - texture->Is())) { + if (!texture->Is() && + !(texture->Is() || + texture->Is())) { set_error(expr->source(), "invalid texture for " + ident->name()); return false; } ast::type::Type* type = nullptr; - if (texture->Is()) { - type = texture->As()->type(); - } else if (texture->Is()) { - type = texture->As()->type(); - } else if (texture->Is()) { - type = texture->As()->type(); + if (texture->Is()) { + type = texture->As()->type(); + } else if (texture->Is()) { + type = texture->As()->type(); + } else if (texture->Is()) { + type = texture->As()->type(); } else { set_error(expr->source(), "unknown texture type for texture sampling"); return false; } - expr->func()->set_result_type(mod_->create(type, 4)); + expr->func()->set_result_type(mod_->create(type, 4)); return true; } if (ident->intrinsic() == ast::Intrinsic::kDot) { - expr->func()->set_result_type(mod_->create()); + expr->func()->set_result_type(mod_->create()); return true; } if (ident->intrinsic() == ast::Intrinsic::kOuterProduct) { @@ -697,16 +696,16 @@ bool TypeDeterminer::DetermineIntrinsic(ast::IdentifierExpression* ident, auto* param0_type = expr->params()[0]->result_type()->UnwrapPtrIfNeeded(); auto* param1_type = expr->params()[1]->result_type()->UnwrapPtrIfNeeded(); - if (!param0_type->Is() || - !param1_type->Is()) { + if (!param0_type->Is() || + !param1_type->Is()) { set_error(expr->source(), "invalid parameter type for " + ident->name()); return false; } - expr->func()->set_result_type(mod_->create( - mod_->create(), - param0_type->As()->size(), - param1_type->As()->size())); + expr->func()->set_result_type(mod_->create( + mod_->create(), + param0_type->As()->size(), + param1_type->As()->size())); return true; } if (ident->intrinsic() == ast::Intrinsic::kSelect) { @@ -782,7 +781,7 @@ bool TypeDeterminer::DetermineIntrinsic(ast::IdentifierExpression* ident, return false; } if (data->vector_size > 0 && - result_types.back()->As()->size() != + result_types.back()->As()->size() != data->vector_size) { set_error(expr->source(), "incorrect vector size for " + ident->name() + ". " + "Requires " + @@ -792,7 +791,7 @@ bool TypeDeterminer::DetermineIntrinsic(ast::IdentifierExpression* ident, } break; case IntrinsicDataType::kMatrix: - if (!result_types.back()->Is()) { + if (!result_types.back()->Is()) { set_error(expr->source(), "incorrect type for " + ident->name() + ". Requires matrix value"); return false; @@ -817,13 +816,13 @@ bool TypeDeterminer::DetermineIntrinsic(ast::IdentifierExpression* ident, expr->func()->set_result_type( result_types[0]->is_float_scalar() ? result_types[0] - : result_types[0]->As()->type()); + : result_types[0]->As()->type()); return true; } // The determinant returns the component type of the columns if (ident->intrinsic() == ast::Intrinsic::kDeterminant) { expr->func()->set_result_type( - result_types[0]->As()->type()); + result_types[0]->As()->type()); return true; } expr->func()->set_result_type(result_types[0]); @@ -853,11 +852,11 @@ bool TypeDeterminer::DetermineIdentifier(ast::IdentifierExpression* expr) { // the pointer around the variable type. if (var->is_const()) { expr->set_result_type(var->type()); - } else if (var->type()->Is()) { + } else if (var->type()->Is()) { expr->set_result_type(var->type()); } else { - expr->set_result_type(mod_->create( - var->type(), var->storage_class())); + expr->set_result_type( + mod_->create(var->type(), var->storage_class())); } set_referenced_from_function_if_needed(var); @@ -1031,8 +1030,8 @@ bool TypeDeterminer::DetermineMemberAccessor( auto* data_type = res->UnwrapPtrIfNeeded()->UnwrapIfNeeded(); ast::type::Type* ret = nullptr; - if (data_type->Is()) { - auto* strct = data_type->As()->impl(); + if (data_type->Is()) { + auto* strct = data_type->As()->impl(); auto name = expr->member()->name(); for (auto* member : strct->members()) { @@ -1048,27 +1047,27 @@ bool TypeDeterminer::DetermineMemberAccessor( } // If we're extracting from a pointer, we return a pointer. - if (res->Is()) { - ret = mod_->create( - ret, res->As()->storage_class()); + if (res->Is()) { + ret = mod_->create( + ret, res->As()->storage_class()); } - } else if (data_type->Is()) { - auto* vec = data_type->As(); + } else if (data_type->Is()) { + auto* vec = data_type->As(); auto size = expr->member()->name().size(); if (size == 1) { // A single element swizzle is just the type of the vector. ret = vec->type(); // If we're extracting from a pointer, we return a pointer. - if (res->Is()) { - ret = mod_->create( - ret, res->As()->storage_class()); + if (res->Is()) { + ret = mod_->create( + ret, res->As()->storage_class()); } } else { // The vector will have a number of components equal to the length of the // swizzle. This assumes the validator will check that the swizzle // is correct. - ret = mod_->create(vec->type(), size); + ret = mod_->create(vec->type(), size); } } else { set_error( @@ -1099,11 +1098,11 @@ bool TypeDeterminer::DetermineBinary(ast::BinaryExpression* expr) { if (expr->IsLogicalAnd() || expr->IsLogicalOr() || expr->IsEqual() || expr->IsNotEqual() || expr->IsLessThan() || expr->IsGreaterThan() || expr->IsLessThanEqual() || expr->IsGreaterThanEqual()) { - auto* bool_type = mod_->create(); + auto* bool_type = mod_->create(); auto* param_type = expr->lhs()->result_type()->UnwrapPtrIfNeeded(); - if (param_type->Is()) { - expr->set_result_type(mod_->create( - bool_type, param_type->As()->size())); + if (param_type->Is()) { + expr->set_result_type(mod_->create( + bool_type, param_type->As()->size())); } else { expr->set_result_type(bool_type); } @@ -1115,36 +1114,36 @@ bool TypeDeterminer::DetermineBinary(ast::BinaryExpression* expr) { // Note, the ordering here matters. The later checks depend on the prior // checks having been done. - if (lhs_type->Is() && - rhs_type->Is()) { - expr->set_result_type(mod_->create( - lhs_type->As()->type(), - lhs_type->As()->rows(), - rhs_type->As()->columns())); + if (lhs_type->Is() && + rhs_type->Is()) { + expr->set_result_type(mod_->create( + lhs_type->As()->type(), + lhs_type->As()->rows(), + rhs_type->As()->columns())); - } else if (lhs_type->Is() && - rhs_type->Is()) { - auto* mat = lhs_type->As(); + } else if (lhs_type->Is() && + rhs_type->Is()) { + auto* mat = lhs_type->As(); expr->set_result_type( - mod_->create(mat->type(), mat->rows())); - } else if (lhs_type->Is() && - rhs_type->Is()) { - auto* mat = rhs_type->As(); + mod_->create(mat->type(), mat->rows())); + } else if (lhs_type->Is() && + rhs_type->Is()) { + auto* mat = rhs_type->As(); expr->set_result_type( - mod_->create(mat->type(), mat->columns())); - } else if (lhs_type->Is()) { + mod_->create(mat->type(), mat->columns())); + } else if (lhs_type->Is()) { // matrix * scalar expr->set_result_type(lhs_type); - } else if (rhs_type->Is()) { + } else if (rhs_type->Is()) { // scalar * matrix expr->set_result_type(rhs_type); - } else if (lhs_type->Is() && - rhs_type->Is()) { + } else if (lhs_type->Is() && + rhs_type->Is()) { expr->set_result_type(lhs_type); - } else if (lhs_type->Is()) { + } else if (lhs_type->Is()) { // Vector * scalar expr->set_result_type(lhs_type); - } else if (rhs_type->Is()) { + } else if (rhs_type->Is()) { // Scalar * vector expr->set_result_type(rhs_type); } else { @@ -1169,7 +1168,7 @@ bool TypeDeterminer::DetermineUnaryOp(ast::UnaryOpExpression* expr) { } bool TypeDeterminer::DetermineStorageTextureSubtype( - ast::type::StorageTextureType* tex) { + ast::type::StorageTexture* tex) { if (tex->type() != nullptr) { return true; } @@ -1184,7 +1183,7 @@ bool TypeDeterminer::DetermineStorageTextureSubtype( case ast::type::ImageFormat::kRg32Uint: case ast::type::ImageFormat::kRgba16Uint: case ast::type::ImageFormat::kRgba32Uint: { - tex->set_type(mod_->create()); + tex->set_type(mod_->create()); return true; } @@ -1197,7 +1196,7 @@ bool TypeDeterminer::DetermineStorageTextureSubtype( case ast::type::ImageFormat::kRg32Sint: case ast::type::ImageFormat::kRgba16Sint: case ast::type::ImageFormat::kRgba32Sint: { - tex->set_type(mod_->create()); + tex->set_type(mod_->create()); return true; } @@ -1218,7 +1217,7 @@ bool TypeDeterminer::DetermineStorageTextureSubtype( case ast::type::ImageFormat::kRg32Float: case ast::type::ImageFormat::kRgba16Float: case ast::type::ImageFormat::kRgba32Float: { - tex->set_type(mod_->create()); + tex->set_type(mod_->create()); return true; } diff --git a/src/type_determiner.h b/src/type_determiner.h index af279f54a5..9d2fec9f4c 100644 --- a/src/type_determiner.h +++ b/src/type_determiner.h @@ -86,7 +86,7 @@ class TypeDeterminer { /// Determines the result type based off a storage texture format /// @param tex the storage texture /// @returns false on error - bool DetermineStorageTextureSubtype(ast::type::StorageTextureType* tex); + bool DetermineStorageTextureSubtype(ast::type::StorageTexture* tex); /// Testing method to set a given variable into the type stack /// @param var the variable to set diff --git a/src/type_determiner_test.cc b/src/type_determiner_test.cc index 5357c823cf..e39736cd67 100644 --- a/src/type_determiner_test.cc +++ b/src/type_determiner_test.cc @@ -121,8 +121,8 @@ TEST_F(TypeDeterminerTest, Stmt_Error_Unknown) { } TEST_F(TypeDeterminerTest, Stmt_Assign) { - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::F32 f32; + ast::type::I32 i32; auto* lhs = create( create(&i32, 2)); @@ -135,13 +135,13 @@ TEST_F(TypeDeterminerTest, Stmt_Assign) { ASSERT_NE(lhs->result_type(), nullptr); ASSERT_NE(rhs->result_type(), nullptr); - EXPECT_TRUE(lhs->result_type()->Is()); - EXPECT_TRUE(rhs->result_type()->Is()); + EXPECT_TRUE(lhs->result_type()->Is()); + EXPECT_TRUE(rhs->result_type()->Is()); } TEST_F(TypeDeterminerTest, Stmt_Case) { - ast::type::I32Type i32; - ast::type::F32Type f32; + ast::type::I32 i32; + ast::type::F32 f32; auto* lhs = create( create(&i32, 2)); @@ -158,13 +158,13 @@ TEST_F(TypeDeterminerTest, Stmt_Case) { EXPECT_TRUE(td()->DetermineResultType(&cse)); ASSERT_NE(lhs->result_type(), nullptr); ASSERT_NE(rhs->result_type(), nullptr); - EXPECT_TRUE(lhs->result_type()->Is()); - EXPECT_TRUE(rhs->result_type()->Is()); + EXPECT_TRUE(lhs->result_type()->Is()); + EXPECT_TRUE(rhs->result_type()->Is()); } TEST_F(TypeDeterminerTest, Stmt_Block) { - ast::type::I32Type i32; - ast::type::F32Type f32; + ast::type::I32 i32; + ast::type::F32 f32; auto* lhs = create( create(&i32, 2)); @@ -177,13 +177,13 @@ TEST_F(TypeDeterminerTest, Stmt_Block) { EXPECT_TRUE(td()->DetermineResultType(&block)); ASSERT_NE(lhs->result_type(), nullptr); ASSERT_NE(rhs->result_type(), nullptr); - EXPECT_TRUE(lhs->result_type()->Is()); - EXPECT_TRUE(rhs->result_type()->Is()); + EXPECT_TRUE(lhs->result_type()->Is()); + EXPECT_TRUE(rhs->result_type()->Is()); } TEST_F(TypeDeterminerTest, Stmt_Else) { - ast::type::I32Type i32; - ast::type::F32Type f32; + ast::type::I32 i32; + ast::type::F32 f32; auto* lhs = create( create(&i32, 2)); @@ -201,14 +201,14 @@ TEST_F(TypeDeterminerTest, Stmt_Else) { ASSERT_NE(stmt.condition()->result_type(), nullptr); ASSERT_NE(lhs->result_type(), nullptr); ASSERT_NE(rhs->result_type(), nullptr); - EXPECT_TRUE(stmt.condition()->result_type()->Is()); - EXPECT_TRUE(lhs->result_type()->Is()); - EXPECT_TRUE(rhs->result_type()->Is()); + EXPECT_TRUE(stmt.condition()->result_type()->Is()); + EXPECT_TRUE(lhs->result_type()->Is()); + EXPECT_TRUE(rhs->result_type()->Is()); } TEST_F(TypeDeterminerTest, Stmt_If) { - ast::type::I32Type i32; - ast::type::F32Type f32; + ast::type::I32 i32; + ast::type::F32 f32; auto* else_lhs = create( create(&i32, 2)); @@ -245,16 +245,16 @@ TEST_F(TypeDeterminerTest, Stmt_If) { ASSERT_NE(else_rhs->result_type(), nullptr); ASSERT_NE(lhs->result_type(), nullptr); ASSERT_NE(rhs->result_type(), nullptr); - EXPECT_TRUE(stmt.condition()->result_type()->Is()); - EXPECT_TRUE(else_lhs->result_type()->Is()); - EXPECT_TRUE(else_rhs->result_type()->Is()); - EXPECT_TRUE(lhs->result_type()->Is()); - EXPECT_TRUE(rhs->result_type()->Is()); + EXPECT_TRUE(stmt.condition()->result_type()->Is()); + EXPECT_TRUE(else_lhs->result_type()->Is()); + EXPECT_TRUE(else_rhs->result_type()->Is()); + EXPECT_TRUE(lhs->result_type()->Is()); + EXPECT_TRUE(rhs->result_type()->Is()); } TEST_F(TypeDeterminerTest, Stmt_Loop) { - ast::type::I32Type i32; - ast::type::F32Type f32; + ast::type::I32 i32; + ast::type::F32 f32; auto* body_lhs = create( create(&i32, 2)); @@ -280,14 +280,14 @@ TEST_F(TypeDeterminerTest, Stmt_Loop) { ASSERT_NE(body_rhs->result_type(), nullptr); ASSERT_NE(continuing_lhs->result_type(), nullptr); ASSERT_NE(continuing_rhs->result_type(), nullptr); - EXPECT_TRUE(body_lhs->result_type()->Is()); - EXPECT_TRUE(body_rhs->result_type()->Is()); - EXPECT_TRUE(continuing_lhs->result_type()->Is()); - EXPECT_TRUE(continuing_rhs->result_type()->Is()); + EXPECT_TRUE(body_lhs->result_type()->Is()); + EXPECT_TRUE(body_rhs->result_type()->Is()); + EXPECT_TRUE(continuing_lhs->result_type()->Is()); + EXPECT_TRUE(continuing_rhs->result_type()->Is()); } TEST_F(TypeDeterminerTest, Stmt_Return) { - ast::type::I32Type i32; + ast::type::I32 i32; auto* cond = create( create(&i32, 2)); @@ -296,18 +296,18 @@ TEST_F(TypeDeterminerTest, Stmt_Return) { EXPECT_TRUE(td()->DetermineResultType(&ret)); ASSERT_NE(cond->result_type(), nullptr); - EXPECT_TRUE(cond->result_type()->Is()); + EXPECT_TRUE(cond->result_type()->Is()); } TEST_F(TypeDeterminerTest, Stmt_Return_WithoutValue) { - ast::type::I32Type i32; + ast::type::I32 i32; ast::ReturnStatement ret; EXPECT_TRUE(td()->DetermineResultType(&ret)); } TEST_F(TypeDeterminerTest, Stmt_Switch) { - ast::type::I32Type i32; - ast::type::F32Type f32; + ast::type::I32 i32; + ast::type::F32 f32; auto* lhs = create( create(&i32, 2)); @@ -332,13 +332,13 @@ TEST_F(TypeDeterminerTest, Stmt_Switch) { ASSERT_NE(lhs->result_type(), nullptr); ASSERT_NE(rhs->result_type(), nullptr); - EXPECT_TRUE(stmt.condition()->result_type()->Is()); - EXPECT_TRUE(lhs->result_type()->Is()); - EXPECT_TRUE(rhs->result_type()->Is()); + EXPECT_TRUE(stmt.condition()->result_type()->Is()); + EXPECT_TRUE(lhs->result_type()->Is()); + EXPECT_TRUE(rhs->result_type()->Is()); } TEST_F(TypeDeterminerTest, Stmt_Call) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::VariableList params; auto* func = create("my_func", params, &f32, @@ -355,13 +355,13 @@ TEST_F(TypeDeterminerTest, Stmt_Call) { ast::CallStatement call(expr); EXPECT_TRUE(td()->DetermineResultType(&call)); ASSERT_NE(expr->result_type(), nullptr); - EXPECT_TRUE(expr->result_type()->Is()); + EXPECT_TRUE(expr->result_type()->Is()); } TEST_F(TypeDeterminerTest, Stmt_Call_undeclared) { // fn main() -> void {func(); return; } // fn func() -> void { return; } - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList call_params; auto* call_expr = create(create( @@ -385,7 +385,7 @@ TEST_F(TypeDeterminerTest, Stmt_Call_undeclared) { } TEST_F(TypeDeterminerTest, Stmt_VariableDecl) { - ast::type::I32Type i32; + ast::type::I32 i32; auto* var = create("my_var", ast::StorageClass::kNone, &i32); var->set_constructor(create( create(&i32, 2))); @@ -395,11 +395,11 @@ TEST_F(TypeDeterminerTest, Stmt_VariableDecl) { EXPECT_TRUE(td()->DetermineResultType(&decl)); ASSERT_NE(init->result_type(), nullptr); - EXPECT_TRUE(init->result_type()->Is()); + EXPECT_TRUE(init->result_type()->Is()); } TEST_F(TypeDeterminerTest, Stmt_VariableDecl_ModuleScope) { - ast::type::I32Type i32; + ast::type::I32 i32; auto* var = create("my_var", ast::StorageClass::kNone, &i32); var->set_constructor(create( create(&i32, 2))); @@ -409,7 +409,7 @@ TEST_F(TypeDeterminerTest, Stmt_VariableDecl_ModuleScope) { EXPECT_TRUE(td()->Determine()); ASSERT_NE(init->result_type(), nullptr); - EXPECT_TRUE(init->result_type()->Is()); + EXPECT_TRUE(init->result_type()->Is()); } TEST_F(TypeDeterminerTest, Expr_Error_Unknown) { @@ -421,9 +421,9 @@ TEST_F(TypeDeterminerTest, Expr_Error_Unknown) { } TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Array) { - ast::type::I32Type i32; - ast::type::F32Type f32; - ast::type::ArrayType ary(&f32, 3); + ast::type::I32 i32; + ast::type::F32 f32; + ast::type::Array ary(&f32, 3); auto* idx = create( create(&i32, 2)); @@ -438,17 +438,17 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Array) { idx); EXPECT_TRUE(td()->DetermineResultType(&acc)); ASSERT_NE(acc.result_type(), nullptr); - ASSERT_TRUE(acc.result_type()->Is()); + ASSERT_TRUE(acc.result_type()->Is()); - auto* ptr = acc.result_type()->As(); - EXPECT_TRUE(ptr->type()->Is()); + auto* ptr = acc.result_type()->As(); + EXPECT_TRUE(ptr->type()->Is()); } TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Alias_Array) { - ast::type::I32Type i32; - ast::type::F32Type f32; - ast::type::ArrayType ary(&f32, 3); - ast::type::AliasType aary("myarrty", &ary); + ast::type::I32 i32; + ast::type::F32 f32; + ast::type::Array ary(&f32, 3); + ast::type::Alias aary("myarrty", &ary); auto* idx = create( create(&i32, 2)); @@ -463,16 +463,16 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Alias_Array) { idx); EXPECT_TRUE(td()->DetermineResultType(&acc)); ASSERT_NE(acc.result_type(), nullptr); - ASSERT_TRUE(acc.result_type()->Is()); + ASSERT_TRUE(acc.result_type()->Is()); - auto* ptr = acc.result_type()->As(); - EXPECT_TRUE(ptr->type()->Is()); + auto* ptr = acc.result_type()->As(); + EXPECT_TRUE(ptr->type()->Is()); } TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Array_Constant) { - ast::type::I32Type i32; - ast::type::F32Type f32; - ast::type::ArrayType ary(&f32, 3); + ast::type::I32 i32; + ast::type::F32 f32; + ast::type::Array ary(&f32, 3); auto* idx = create( create(&i32, 2)); @@ -488,14 +488,14 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Array_Constant) { idx); EXPECT_TRUE(td()->DetermineResultType(&acc)); ASSERT_NE(acc.result_type(), nullptr); - EXPECT_TRUE(acc.result_type()->Is()) + EXPECT_TRUE(acc.result_type()->Is()) << acc.result_type()->type_name(); } TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Matrix) { - ast::type::I32Type i32; - ast::type::F32Type f32; - ast::type::MatrixType mat(&f32, 3, 2); + ast::type::I32 i32; + ast::type::F32 f32; + ast::type::Matrix mat(&f32, 3, 2); auto* idx = create( create(&i32, 2)); @@ -509,17 +509,17 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Matrix) { idx); EXPECT_TRUE(td()->DetermineResultType(&acc)); ASSERT_NE(acc.result_type(), nullptr); - ASSERT_TRUE(acc.result_type()->Is()); + ASSERT_TRUE(acc.result_type()->Is()); - auto* ptr = acc.result_type()->As(); - ASSERT_TRUE(ptr->type()->Is()); - EXPECT_EQ(ptr->type()->As()->size(), 3u); + auto* ptr = acc.result_type()->As(); + ASSERT_TRUE(ptr->type()->Is()); + EXPECT_EQ(ptr->type()->As()->size(), 3u); } TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Matrix_BothDimensions) { - ast::type::I32Type i32; - ast::type::F32Type f32; - ast::type::MatrixType mat(&f32, 3, 2); + ast::type::I32 i32; + ast::type::F32 f32; + ast::type::Matrix mat(&f32, 3, 2); auto* idx1 = create( create(&i32, 2)); @@ -538,16 +538,16 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Matrix_BothDimensions) { EXPECT_TRUE(td()->DetermineResultType(&acc)); ASSERT_NE(acc.result_type(), nullptr); - ASSERT_TRUE(acc.result_type()->Is()); + ASSERT_TRUE(acc.result_type()->Is()); - auto* ptr = acc.result_type()->As(); - EXPECT_TRUE(ptr->type()->Is()); + auto* ptr = acc.result_type()->As(); + EXPECT_TRUE(ptr->type()->Is()); } TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Vector) { - ast::type::I32Type i32; - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::I32 i32; + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); auto* idx = create( create(&i32, 2)); @@ -561,14 +561,14 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Vector) { idx); EXPECT_TRUE(td()->DetermineResultType(&acc)); ASSERT_NE(acc.result_type(), nullptr); - ASSERT_TRUE(acc.result_type()->Is()); + ASSERT_TRUE(acc.result_type()->Is()); - auto* ptr = acc.result_type()->As(); - EXPECT_TRUE(ptr->type()->Is()); + auto* ptr = acc.result_type()->As(); + EXPECT_TRUE(ptr->type()->Is()); } TEST_F(TypeDeterminerTest, Expr_Bitcast) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::BitcastExpression bitcast(&f32, create("name")); @@ -577,11 +577,11 @@ TEST_F(TypeDeterminerTest, Expr_Bitcast) { EXPECT_TRUE(td()->DetermineResultType(&bitcast)); ASSERT_NE(bitcast.result_type(), nullptr); - EXPECT_TRUE(bitcast.result_type()->Is()); + EXPECT_TRUE(bitcast.result_type()->Is()); } TEST_F(TypeDeterminerTest, Expr_Call) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::VariableList params; auto* func = create("my_func", params, &f32, @@ -596,11 +596,11 @@ TEST_F(TypeDeterminerTest, Expr_Call) { call_params); EXPECT_TRUE(td()->DetermineResultType(&call)); ASSERT_NE(call.result_type(), nullptr); - EXPECT_TRUE(call.result_type()->Is()); + EXPECT_TRUE(call.result_type()->Is()); } TEST_F(TypeDeterminerTest, Expr_Call_WithParams) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::VariableList params; auto* func = create("my_func", params, &f32, @@ -620,11 +620,11 @@ TEST_F(TypeDeterminerTest, Expr_Call_WithParams) { call_params); EXPECT_TRUE(td()->DetermineResultType(&call)); ASSERT_NE(param->result_type(), nullptr); - EXPECT_TRUE(param->result_type()->Is()); + EXPECT_TRUE(param->result_type()->Is()); } TEST_F(TypeDeterminerTest, Expr_Call_Intrinsic) { - ast::type::F32Type f32; + ast::type::F32 f32; // Register the function EXPECT_TRUE(td()->Determine()); @@ -638,11 +638,11 @@ TEST_F(TypeDeterminerTest, Expr_Call_Intrinsic) { EXPECT_TRUE(td()->DetermineResultType(&call)); ASSERT_NE(call.result_type(), nullptr); - EXPECT_TRUE(call.result_type()->Is()); + EXPECT_TRUE(call.result_type()->Is()); } TEST_F(TypeDeterminerTest, Expr_Cast) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create("name")); @@ -653,21 +653,21 @@ TEST_F(TypeDeterminerTest, Expr_Cast) { EXPECT_TRUE(td()->DetermineResultType(&cast)); ASSERT_NE(cast.result_type(), nullptr); - EXPECT_TRUE(cast.result_type()->Is()); + EXPECT_TRUE(cast.result_type()->Is()); } TEST_F(TypeDeterminerTest, Expr_Constructor_Scalar) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::ScalarConstructorExpression s(create(&f32, 1.0f)); EXPECT_TRUE(td()->DetermineResultType(&s)); ASSERT_NE(s.result_type(), nullptr); - EXPECT_TRUE(s.result_type()->Is()); + EXPECT_TRUE(s.result_type()->Is()); } TEST_F(TypeDeterminerTest, Expr_Constructor_Type) { - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::ExpressionList vals; vals.push_back(create( @@ -681,16 +681,14 @@ TEST_F(TypeDeterminerTest, Expr_Constructor_Type) { EXPECT_TRUE(td()->DetermineResultType(&tc)); ASSERT_NE(tc.result_type(), nullptr); - ASSERT_TRUE(tc.result_type()->Is()); - EXPECT_TRUE(tc.result_type() - ->As() - ->type() - ->Is()); - EXPECT_EQ(tc.result_type()->As()->size(), 3u); + ASSERT_TRUE(tc.result_type()->Is()); + EXPECT_TRUE( + tc.result_type()->As()->type()->Is()); + EXPECT_EQ(tc.result_type()->As()->size(), 3u); } TEST_F(TypeDeterminerTest, Expr_Identifier_GlobalVariable) { - ast::type::F32Type f32; + ast::type::F32 f32; auto* var = create("my_var", ast::StorageClass::kNone, &f32); mod->AddGlobalVariable(var); @@ -700,15 +698,15 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_GlobalVariable) { ast::IdentifierExpression ident("my_var"); EXPECT_TRUE(td()->DetermineResultType(&ident)); ASSERT_NE(ident.result_type(), nullptr); - EXPECT_TRUE(ident.result_type()->Is()); + EXPECT_TRUE(ident.result_type()->Is()); EXPECT_TRUE(ident.result_type() - ->As() + ->As() ->type() - ->Is()); + ->Is()); } TEST_F(TypeDeterminerTest, Expr_Identifier_GlobalConstant) { - ast::type::F32Type f32; + ast::type::F32 f32; auto* var = create("my_var", ast::StorageClass::kNone, &f32); var->set_is_const(true); mod->AddGlobalVariable(var); @@ -719,11 +717,11 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_GlobalConstant) { ast::IdentifierExpression ident("my_var"); EXPECT_TRUE(td()->DetermineResultType(&ident)); ASSERT_NE(ident.result_type(), nullptr); - EXPECT_TRUE(ident.result_type()->Is()); + EXPECT_TRUE(ident.result_type()->Is()); } TEST_F(TypeDeterminerTest, Expr_Identifier_FunctionVariable_Const) { - ast::type::F32Type f32; + ast::type::F32 f32; auto* my_var = create("my_var"); @@ -740,11 +738,11 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_FunctionVariable_Const) { EXPECT_TRUE(td()->DetermineFunction(&f)); ASSERT_NE(my_var->result_type(), nullptr); - EXPECT_TRUE(my_var->result_type()->Is()); + EXPECT_TRUE(my_var->result_type()->Is()); } TEST_F(TypeDeterminerTest, Expr_Identifier_FunctionVariable) { - ast::type::F32Type f32; + ast::type::F32 f32; auto* my_var = create("my_var"); @@ -760,16 +758,16 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_FunctionVariable) { EXPECT_TRUE(td()->DetermineFunction(&f)); ASSERT_NE(my_var->result_type(), nullptr); - EXPECT_TRUE(my_var->result_type()->Is()); + EXPECT_TRUE(my_var->result_type()->Is()); EXPECT_TRUE(my_var->result_type() - ->As() + ->As() ->type() - ->Is()); + ->Is()); } TEST_F(TypeDeterminerTest, Expr_Identifier_Function_Ptr) { - ast::type::F32Type f32; - ast::type::PointerType ptr(&f32, ast::StorageClass::kFunction); + ast::type::F32 f32; + ast::type::Pointer ptr(&f32, ast::StorageClass::kFunction); auto* my_var = create("my_var"); @@ -785,15 +783,15 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_Function_Ptr) { EXPECT_TRUE(td()->DetermineFunction(&f)); ASSERT_NE(my_var->result_type(), nullptr); - EXPECT_TRUE(my_var->result_type()->Is()); + EXPECT_TRUE(my_var->result_type()->Is()); EXPECT_TRUE(my_var->result_type() - ->As() + ->As() ->type() - ->Is()); + ->Is()); } TEST_F(TypeDeterminerTest, Expr_Identifier_Function) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::VariableList params; auto* func = create("my_func", params, &f32, @@ -806,7 +804,7 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_Function) { ast::IdentifierExpression ident("my_func"); EXPECT_TRUE(td()->DetermineResultType(&ident)); ASSERT_NE(ident.result_type(), nullptr); - EXPECT_TRUE(ident.result_type()->Is()); + EXPECT_TRUE(ident.result_type()->Is()); } TEST_F(TypeDeterminerTest, Expr_Identifier_Unknown) { @@ -815,7 +813,7 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_Unknown) { } TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables) { - ast::type::F32Type f32; + ast::type::F32 f32; auto* in_var = create("in_var", ast::StorageClass::kInput, &f32); @@ -865,7 +863,7 @@ TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables) { } TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables_SubFunction) { - ast::type::F32Type f32; + ast::type::F32 f32; auto* in_var = create("in_var", ast::StorageClass::kInput, &f32); @@ -924,7 +922,7 @@ TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables_SubFunction) { } TEST_F(TypeDeterminerTest, Function_NotRegisterFunctionVariable) { - ast::type::F32Type f32; + ast::type::F32 f32; auto* var = create("in_var", ast::StorageClass::kFunction, &f32); @@ -951,8 +949,8 @@ TEST_F(TypeDeterminerTest, Function_NotRegisterFunctionVariable) { } TEST_F(TypeDeterminerTest, Expr_MemberAccessor_Struct) { - ast::type::I32Type i32; - ast::type::F32Type f32; + ast::type::I32 i32; + ast::type::F32 f32; ast::StructMemberDecorationList decos; ast::StructMemberList members; @@ -961,7 +959,7 @@ TEST_F(TypeDeterminerTest, Expr_MemberAccessor_Struct) { auto* strct = create(members); - ast::type::StructType st("S", strct); + ast::type::Struct st("S", strct); auto* var = create("my_struct", ast::StorageClass::kNone, &st); @@ -976,15 +974,15 @@ TEST_F(TypeDeterminerTest, Expr_MemberAccessor_Struct) { ast::MemberAccessorExpression mem(ident, mem_ident); EXPECT_TRUE(td()->DetermineResultType(&mem)); ASSERT_NE(mem.result_type(), nullptr); - ASSERT_TRUE(mem.result_type()->Is()); + ASSERT_TRUE(mem.result_type()->Is()); - auto* ptr = mem.result_type()->As(); - EXPECT_TRUE(ptr->type()->Is()); + auto* ptr = mem.result_type()->As(); + EXPECT_TRUE(ptr->type()->Is()); } TEST_F(TypeDeterminerTest, Expr_MemberAccessor_Struct_Alias) { - ast::type::I32Type i32; - ast::type::F32Type f32; + ast::type::I32 i32; + ast::type::F32 f32; ast::StructMemberDecorationList decos; ast::StructMemberList members; @@ -993,8 +991,8 @@ TEST_F(TypeDeterminerTest, Expr_MemberAccessor_Struct_Alias) { auto* strct = create(members); - auto st = std::make_unique("alias", strct); - ast::type::AliasType alias("alias", st.get()); + auto st = std::make_unique("alias", strct); + ast::type::Alias alias("alias", st.get()); auto* var = create("my_struct", ast::StorageClass::kNone, &alias); @@ -1010,15 +1008,15 @@ TEST_F(TypeDeterminerTest, Expr_MemberAccessor_Struct_Alias) { ast::MemberAccessorExpression mem(ident, mem_ident); EXPECT_TRUE(td()->DetermineResultType(&mem)); ASSERT_NE(mem.result_type(), nullptr); - ASSERT_TRUE(mem.result_type()->Is()); + ASSERT_TRUE(mem.result_type()->Is()); - auto* ptr = mem.result_type()->As(); - EXPECT_TRUE(ptr->type()->Is()); + auto* ptr = mem.result_type()->As(); + EXPECT_TRUE(ptr->type()->Is()); } TEST_F(TypeDeterminerTest, Expr_MemberAccessor_VectorSwizzle) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); auto* var = create("my_vec", ast::StorageClass::kNone, &vec3); mod->AddGlobalVariable(var); @@ -1032,17 +1030,15 @@ TEST_F(TypeDeterminerTest, Expr_MemberAccessor_VectorSwizzle) { ast::MemberAccessorExpression mem(ident, swizzle); EXPECT_TRUE(td()->DetermineResultType(&mem)) << td()->error(); ASSERT_NE(mem.result_type(), nullptr); - ASSERT_TRUE(mem.result_type()->Is()); - EXPECT_TRUE(mem.result_type() - ->As() - ->type() - ->Is()); - EXPECT_EQ(mem.result_type()->As()->size(), 2u); + ASSERT_TRUE(mem.result_type()->Is()); + EXPECT_TRUE( + mem.result_type()->As()->type()->Is()); + EXPECT_EQ(mem.result_type()->As()->size(), 2u); } TEST_F(TypeDeterminerTest, Expr_MemberAccessor_VectorSwizzle_SingleElement) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); auto* var = create("my_vec", ast::StorageClass::kNone, &vec3); mod->AddGlobalVariable(var); @@ -1056,10 +1052,10 @@ TEST_F(TypeDeterminerTest, Expr_MemberAccessor_VectorSwizzle_SingleElement) { ast::MemberAccessorExpression mem(ident, swizzle); EXPECT_TRUE(td()->DetermineResultType(&mem)) << td()->error(); ASSERT_NE(mem.result_type(), nullptr); - ASSERT_TRUE(mem.result_type()->Is()); + ASSERT_TRUE(mem.result_type()->Is()); - auto* ptr = mem.result_type()->As(); - ASSERT_TRUE(ptr->type()->Is()); + auto* ptr = mem.result_type()->As(); + ASSERT_TRUE(ptr->type()->Is()); } TEST_F(TypeDeterminerTest, Expr_Accessor_MultiLevel) { @@ -1087,26 +1083,26 @@ TEST_F(TypeDeterminerTest, Expr_Accessor_MultiLevel) { // Identifier{yx} // } // - ast::type::I32Type i32; - ast::type::F32Type f32; + ast::type::I32 i32; + ast::type::F32 f32; - ast::type::VectorType vec4(&f32, 4); + ast::type::Vector vec4(&f32, 4); ast::StructMemberDecorationList decos; ast::StructMemberList b_members; b_members.push_back(create("foo", &vec4, decos)); auto* strctB = create(b_members); - ast::type::StructType stB("B", strctB); + ast::type::Struct stB("B", strctB); - ast::type::VectorType vecB(&stB, 3); + ast::type::Vector vecB(&stB, 3); ast::StructMemberList a_members; a_members.push_back(create("mem", &vecB, decos)); auto* strctA = create(a_members); - ast::type::StructType stA("A", strctA); + ast::type::Struct stA("A", strctA); auto* var = create("c", ast::StorageClass::kNone, &stA); mod->AddGlobalVariable(var); @@ -1130,19 +1126,17 @@ TEST_F(TypeDeterminerTest, Expr_Accessor_MultiLevel) { EXPECT_TRUE(td()->DetermineResultType(&mem)) << td()->error(); ASSERT_NE(mem.result_type(), nullptr); - ASSERT_TRUE(mem.result_type()->Is()); - EXPECT_TRUE(mem.result_type() - ->As() - ->type() - ->Is()); - EXPECT_EQ(mem.result_type()->As()->size(), 2u); + ASSERT_TRUE(mem.result_type()->Is()); + EXPECT_TRUE( + mem.result_type()->As()->type()->Is()); + EXPECT_EQ(mem.result_type()->As()->size(), 2u); } using Expr_Binary_BitwiseTest = TypeDeterminerTestWithParam; TEST_P(Expr_Binary_BitwiseTest, Scalar) { auto op = GetParam(); - ast::type::I32Type i32; + ast::type::I32 i32; auto* var = create("val", ast::StorageClass::kNone, &i32); mod->AddGlobalVariable(var); @@ -1155,14 +1149,14 @@ TEST_P(Expr_Binary_BitwiseTest, Scalar) { ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error(); ASSERT_NE(expr.result_type(), nullptr); - EXPECT_TRUE(expr.result_type()->Is()); + EXPECT_TRUE(expr.result_type()->Is()); } TEST_P(Expr_Binary_BitwiseTest, Vector) { auto op = GetParam(); - ast::type::I32Type i32; - ast::type::VectorType vec3(&i32, 3); + ast::type::I32 i32; + ast::type::Vector vec3(&i32, 3); auto* var = create("val", ast::StorageClass::kNone, &vec3); mod->AddGlobalVariable(var); @@ -1175,12 +1169,12 @@ TEST_P(Expr_Binary_BitwiseTest, Vector) { ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error(); ASSERT_NE(expr.result_type(), nullptr); - ASSERT_TRUE(expr.result_type()->Is()); + ASSERT_TRUE(expr.result_type()->Is()); EXPECT_TRUE(expr.result_type() - ->As() + ->As() ->type() - ->Is()); - EXPECT_EQ(expr.result_type()->As()->size(), 3u); + ->Is()); + EXPECT_EQ(expr.result_type()->As()->size(), 3u); } INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest, Expr_Binary_BitwiseTest, @@ -1198,7 +1192,7 @@ using Expr_Binary_LogicalTest = TypeDeterminerTestWithParam; TEST_P(Expr_Binary_LogicalTest, Scalar) { auto op = GetParam(); - ast::type::BoolType bool_type; + ast::type::Bool bool_type; auto* var = create("val", ast::StorageClass::kNone, &bool_type); @@ -1212,14 +1206,14 @@ TEST_P(Expr_Binary_LogicalTest, Scalar) { ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error(); ASSERT_NE(expr.result_type(), nullptr); - EXPECT_TRUE(expr.result_type()->Is()); + EXPECT_TRUE(expr.result_type()->Is()); } TEST_P(Expr_Binary_LogicalTest, Vector) { auto op = GetParam(); - ast::type::BoolType bool_type; - ast::type::VectorType vec3(&bool_type, 3); + ast::type::Bool bool_type; + ast::type::Vector vec3(&bool_type, 3); auto* var = create("val", ast::StorageClass::kNone, &vec3); mod->AddGlobalVariable(var); @@ -1232,12 +1226,12 @@ TEST_P(Expr_Binary_LogicalTest, Vector) { ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error(); ASSERT_NE(expr.result_type(), nullptr); - ASSERT_TRUE(expr.result_type()->Is()); + ASSERT_TRUE(expr.result_type()->Is()); EXPECT_TRUE(expr.result_type() - ->As() + ->As() ->type() - ->Is()); - EXPECT_EQ(expr.result_type()->As()->size(), 3u); + ->Is()); + EXPECT_EQ(expr.result_type()->As()->size(), 3u); } INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest, Expr_Binary_LogicalTest, @@ -1248,7 +1242,7 @@ using Expr_Binary_CompareTest = TypeDeterminerTestWithParam; TEST_P(Expr_Binary_CompareTest, Scalar) { auto op = GetParam(); - ast::type::I32Type i32; + ast::type::I32 i32; auto* var = create("val", ast::StorageClass::kNone, &i32); mod->AddGlobalVariable(var); @@ -1261,14 +1255,14 @@ TEST_P(Expr_Binary_CompareTest, Scalar) { ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error(); ASSERT_NE(expr.result_type(), nullptr); - EXPECT_TRUE(expr.result_type()->Is()); + EXPECT_TRUE(expr.result_type()->Is()); } TEST_P(Expr_Binary_CompareTest, Vector) { auto op = GetParam(); - ast::type::I32Type i32; - ast::type::VectorType vec3(&i32, 3); + ast::type::I32 i32; + ast::type::Vector vec3(&i32, 3); auto* var = create("val", ast::StorageClass::kNone, &vec3); mod->AddGlobalVariable(var); @@ -1281,12 +1275,12 @@ TEST_P(Expr_Binary_CompareTest, Vector) { ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error(); ASSERT_NE(expr.result_type(), nullptr); - ASSERT_TRUE(expr.result_type()->Is()); + ASSERT_TRUE(expr.result_type()->Is()); EXPECT_TRUE(expr.result_type() - ->As() + ->As() ->type() - ->Is()); - EXPECT_EQ(expr.result_type()->As()->size(), 3u); + ->Is()); + EXPECT_EQ(expr.result_type()->As()->size(), 3u); } INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest, Expr_Binary_CompareTest, @@ -1298,7 +1292,7 @@ INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest, ast::BinaryOp::kGreaterThanEqual)); TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Scalar_Scalar) { - ast::type::I32Type i32; + ast::type::I32 i32; auto* var = create("val", ast::StorageClass::kNone, &i32); mod->AddGlobalVariable(var); @@ -1312,12 +1306,12 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Scalar_Scalar) { ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error(); ASSERT_NE(expr.result_type(), nullptr); - EXPECT_TRUE(expr.result_type()->Is()); + EXPECT_TRUE(expr.result_type()->Is()); } TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Vector_Scalar) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); auto* scalar = create("scalar", ast::StorageClass::kNone, &f32); @@ -1335,17 +1329,17 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Vector_Scalar) { ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error(); ASSERT_NE(expr.result_type(), nullptr); - ASSERT_TRUE(expr.result_type()->Is()); + ASSERT_TRUE(expr.result_type()->Is()); EXPECT_TRUE(expr.result_type() - ->As() + ->As() ->type() - ->Is()); - EXPECT_EQ(expr.result_type()->As()->size(), 3u); + ->Is()); + EXPECT_EQ(expr.result_type()->As()->size(), 3u); } TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Scalar_Vector) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); auto* scalar = create("scalar", ast::StorageClass::kNone, &f32); @@ -1363,17 +1357,17 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Scalar_Vector) { ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error(); ASSERT_NE(expr.result_type(), nullptr); - ASSERT_TRUE(expr.result_type()->Is()); + ASSERT_TRUE(expr.result_type()->Is()); EXPECT_TRUE(expr.result_type() - ->As() + ->As() ->type() - ->Is()); - EXPECT_EQ(expr.result_type()->As()->size(), 3u); + ->Is()); + EXPECT_EQ(expr.result_type()->As()->size(), 3u); } TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Vector_Vector) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); auto* vector = create("vector", ast::StorageClass::kNone, &vec3); @@ -1388,17 +1382,17 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Vector_Vector) { ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error(); ASSERT_NE(expr.result_type(), nullptr); - ASSERT_TRUE(expr.result_type()->Is()); + ASSERT_TRUE(expr.result_type()->Is()); EXPECT_TRUE(expr.result_type() - ->As() + ->As() ->type() - ->Is()); - EXPECT_EQ(expr.result_type()->As()->size(), 3u); + ->Is()); + EXPECT_EQ(expr.result_type()->As()->size(), 3u); } TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Matrix_Scalar) { - ast::type::F32Type f32; - ast::type::MatrixType mat3x2(&f32, 3, 2); + ast::type::F32 f32; + ast::type::Matrix mat3x2(&f32, 3, 2); auto* scalar = create("scalar", ast::StorageClass::kNone, &f32); @@ -1416,17 +1410,17 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Matrix_Scalar) { ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error(); ASSERT_NE(expr.result_type(), nullptr); - ASSERT_TRUE(expr.result_type()->Is()); + ASSERT_TRUE(expr.result_type()->Is()); - auto* mat = expr.result_type()->As(); - EXPECT_TRUE(mat->type()->Is()); + auto* mat = expr.result_type()->As(); + EXPECT_TRUE(mat->type()->Is()); EXPECT_EQ(mat->rows(), 3u); EXPECT_EQ(mat->columns(), 2u); } TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Scalar_Matrix) { - ast::type::F32Type f32; - ast::type::MatrixType mat3x2(&f32, 3, 2); + ast::type::F32 f32; + ast::type::Matrix mat3x2(&f32, 3, 2); auto* scalar = create("scalar", ast::StorageClass::kNone, &f32); @@ -1444,18 +1438,18 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Scalar_Matrix) { ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error(); ASSERT_NE(expr.result_type(), nullptr); - ASSERT_TRUE(expr.result_type()->Is()); + ASSERT_TRUE(expr.result_type()->Is()); - auto* mat = expr.result_type()->As(); - EXPECT_TRUE(mat->type()->Is()); + auto* mat = expr.result_type()->As(); + EXPECT_TRUE(mat->type()->Is()); EXPECT_EQ(mat->rows(), 3u); EXPECT_EQ(mat->columns(), 2u); } TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Matrix_Vector) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 2); - ast::type::MatrixType mat3x2(&f32, 3, 2); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 2); + ast::type::Matrix mat3x2(&f32, 3, 2); auto* vector = create("vector", ast::StorageClass::kNone, &vec3); @@ -1473,18 +1467,18 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Matrix_Vector) { ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error(); ASSERT_NE(expr.result_type(), nullptr); - ASSERT_TRUE(expr.result_type()->Is()); + ASSERT_TRUE(expr.result_type()->Is()); EXPECT_TRUE(expr.result_type() - ->As() + ->As() ->type() - ->Is()); - EXPECT_EQ(expr.result_type()->As()->size(), 3u); + ->Is()); + EXPECT_EQ(expr.result_type()->As()->size(), 3u); } TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Vector_Matrix) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); - ast::type::MatrixType mat3x2(&f32, 3, 2); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); + ast::type::Matrix mat3x2(&f32, 3, 2); auto* vector = create("vector", ast::StorageClass::kNone, &vec3); @@ -1502,18 +1496,18 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Vector_Matrix) { ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error(); ASSERT_NE(expr.result_type(), nullptr); - ASSERT_TRUE(expr.result_type()->Is()); + ASSERT_TRUE(expr.result_type()->Is()); EXPECT_TRUE(expr.result_type() - ->As() + ->As() ->type() - ->Is()); - EXPECT_EQ(expr.result_type()->As()->size(), 2u); + ->Is()); + EXPECT_EQ(expr.result_type()->As()->size(), 2u); } TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Matrix_Matrix) { - ast::type::F32Type f32; - ast::type::MatrixType mat4x3(&f32, 4, 3); - ast::type::MatrixType mat3x4(&f32, 3, 4); + ast::type::F32 f32; + ast::type::Matrix mat4x3(&f32, 4, 3); + ast::type::Matrix mat3x4(&f32, 3, 4); auto* matrix1 = create("mat4x3", ast::StorageClass::kNone, &mat4x3); @@ -1531,10 +1525,10 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Matrix_Matrix) { ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error(); ASSERT_NE(expr.result_type(), nullptr); - ASSERT_TRUE(expr.result_type()->Is()); + ASSERT_TRUE(expr.result_type()->Is()); - auto* mat = expr.result_type()->As(); - EXPECT_TRUE(mat->type()->Is()); + auto* mat = expr.result_type()->As(); + EXPECT_TRUE(mat->type()->Is()); EXPECT_EQ(mat->rows(), 4u); EXPECT_EQ(mat->columns(), 4u); } @@ -1543,7 +1537,7 @@ using IntrinsicDerivativeTest = TypeDeterminerTestWithParam; TEST_P(IntrinsicDerivativeTest, Scalar) { auto name = GetParam(); - ast::type::F32Type f32; + ast::type::F32 f32; auto* var = create("ident", ast::StorageClass::kNone, &f32); mod->AddGlobalVariable(var); @@ -1559,14 +1553,14 @@ TEST_P(IntrinsicDerivativeTest, Scalar) { EXPECT_TRUE(td()->DetermineResultType(&expr)); ASSERT_NE(expr.result_type(), nullptr); - ASSERT_TRUE(expr.result_type()->Is()); + ASSERT_TRUE(expr.result_type()->Is()); } TEST_P(IntrinsicDerivativeTest, Vector) { auto name = GetParam(); - ast::type::F32Type f32; - ast::type::VectorType vec4(&f32, 4); + ast::type::F32 f32; + ast::type::Vector vec4(&f32, 4); auto* var = create("ident", ast::StorageClass::kNone, &vec4); mod->AddGlobalVariable(var); @@ -1582,19 +1576,19 @@ TEST_P(IntrinsicDerivativeTest, Vector) { EXPECT_TRUE(td()->DetermineResultType(&expr)); ASSERT_NE(expr.result_type(), nullptr); - ASSERT_TRUE(expr.result_type()->Is()); + ASSERT_TRUE(expr.result_type()->Is()); EXPECT_TRUE(expr.result_type() - ->As() + ->As() ->type() - ->Is()); - EXPECT_EQ(expr.result_type()->As()->size(), 4u); + ->Is()); + EXPECT_EQ(expr.result_type()->As()->size(), 4u); } TEST_P(IntrinsicDerivativeTest, MissingParam) { auto name = GetParam(); - ast::type::F32Type f32; - ast::type::VectorType vec4(&f32, 4); + ast::type::F32 f32; + ast::type::Vector vec4(&f32, 4); // Register the global EXPECT_TRUE(td()->Determine()); @@ -1609,8 +1603,8 @@ TEST_P(IntrinsicDerivativeTest, MissingParam) { TEST_P(IntrinsicDerivativeTest, ToomManyParams) { auto name = GetParam(); - ast::type::F32Type f32; - ast::type::VectorType vec4(&f32, 4); + ast::type::F32 f32; + ast::type::Vector vec4(&f32, 4); auto* var1 = create("ident1", ast::StorageClass::kNone, &vec4); auto* var2 = create("ident2", ast::StorageClass::kNone, &vec4); @@ -1645,8 +1639,8 @@ using Intrinsic = TypeDeterminerTestWithParam; TEST_P(Intrinsic, Test) { auto name = GetParam(); - ast::type::BoolType bool_type; - ast::type::VectorType vec3(&bool_type, 3); + ast::type::Bool bool_type; + ast::type::Vector vec3(&bool_type, 3); auto* var = create("my_var", ast::StorageClass::kNone, &vec3); mod->AddGlobalVariable(var); @@ -1662,7 +1656,7 @@ TEST_P(Intrinsic, Test) { EXPECT_TRUE(td()->DetermineResultType(&expr)); ASSERT_NE(expr.result_type(), nullptr); - EXPECT_TRUE(expr.result_type()->Is()); + EXPECT_TRUE(expr.result_type()->Is()); } INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest, Intrinsic, @@ -1672,8 +1666,8 @@ using Intrinsic_FloatMethod = TypeDeterminerTestWithParam; TEST_P(Intrinsic_FloatMethod, Vector) { auto name = GetParam(); - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); auto* var = create("my_var", ast::StorageClass::kNone, &vec3); mod->AddGlobalVariable(var); @@ -1689,18 +1683,18 @@ TEST_P(Intrinsic_FloatMethod, Vector) { EXPECT_TRUE(td()->DetermineResultType(&expr)); ASSERT_NE(expr.result_type(), nullptr); - ASSERT_TRUE(expr.result_type()->Is()); + ASSERT_TRUE(expr.result_type()->Is()); EXPECT_TRUE(expr.result_type() - ->As() + ->As() ->type() - ->Is()); - EXPECT_EQ(expr.result_type()->As()->size(), 3u); + ->Is()); + EXPECT_EQ(expr.result_type()->As()->size(), 3u); } TEST_P(Intrinsic_FloatMethod, Scalar) { auto name = GetParam(); - ast::type::F32Type f32; + ast::type::F32 f32; auto* var = create("my_var", ast::StorageClass::kNone, &f32); mod->AddGlobalVariable(var); @@ -1715,13 +1709,13 @@ TEST_P(Intrinsic_FloatMethod, Scalar) { EXPECT_TRUE(td()->Determine()); EXPECT_TRUE(td()->DetermineResultType(&expr)); ASSERT_NE(expr.result_type(), nullptr); - EXPECT_TRUE(expr.result_type()->Is()); + EXPECT_TRUE(expr.result_type()->Is()); } TEST_P(Intrinsic_FloatMethod, MissingParam) { auto name = GetParam(); - ast::type::F32Type f32; + ast::type::F32 f32; auto* var = create("my_var", ast::StorageClass::kNone, &f32); mod->AddGlobalVariable(var); @@ -1739,7 +1733,7 @@ TEST_P(Intrinsic_FloatMethod, MissingParam) { TEST_P(Intrinsic_FloatMethod, TooManyParams) { auto name = GetParam(); - ast::type::F32Type f32; + ast::type::F32 f32; auto* var = create("my_var", ast::StorageClass::kNone, &f32); mod->AddGlobalVariable(var); @@ -1761,11 +1755,11 @@ INSTANTIATE_TEST_SUITE_P( Intrinsic_FloatMethod, testing::Values("isInf", "isNan", "isFinite", "isNormal")); -enum class TextureType { kF32, kI32, kU32 }; -inline std::ostream& operator<<(std::ostream& out, TextureType data) { - if (data == TextureType::kF32) { +enum class Texture { kF32, kI32, kU32 }; +inline std::ostream& operator<<(std::ostream& out, Texture data) { + if (data == Texture::kF32) { out << "f32"; - } else if (data == TextureType::kI32) { + } else if (data == Texture::kI32) { out << "i32"; } else { out << "u32"; @@ -1775,7 +1769,7 @@ inline std::ostream& operator<<(std::ostream& out, TextureType data) { struct TextureTestParams { ast::type::TextureDimension dim; - TextureType type = TextureType::kF32; + Texture type = Texture::kF32; ast::type::ImageFormat format = ast::type::ImageFormat::kR16Float; }; inline std::ostream& operator<<(std::ostream& out, TextureTestParams data) { @@ -1790,20 +1784,20 @@ class Intrinsic_TextureOperation ast::type::TextureDimension dim, ast::type::Type* type) { if (dim == ast::type::TextureDimension::k1d) { - if (type->Is()) { - return std::make_unique(); - } else if (type->Is()) { - return std::make_unique(); + if (type->Is()) { + return std::make_unique(); + } else if (type->Is()) { + return std::make_unique(); } else { - return std::make_unique(); + return std::make_unique(); } } else if (dim == ast::type::TextureDimension::k1dArray || dim == ast::type::TextureDimension::k2d) { - return std::make_unique(type, 2); + return std::make_unique(type, 2); } else if (dim == ast::type::TextureDimension::kCubeArray) { - return std::make_unique(type, 4); + return std::make_unique(type, 4); } else { - return std::make_unique(type, 3); + return std::make_unique(type, 3); } } @@ -1815,14 +1809,14 @@ class Intrinsic_TextureOperation call_params->push_back(create(name)); } - std::unique_ptr subtype(TextureType type) { - if (type == TextureType::kF32) { - return std::make_unique(); + std::unique_ptr subtype(Texture type) { + if (type == Texture::kF32) { + return std::make_unique(); } - if (type == TextureType::kI32) { - return std::make_unique(); + if (type == Texture::kI32) { + return std::make_unique(); } - return std::make_unique(); + return std::make_unique(); } }; @@ -1832,10 +1826,10 @@ TEST_P(Intrinsic_StorageTextureOperation, TextureLoadRo) { auto type = GetParam().type; auto format = GetParam().format; - ast::type::I32Type i32; + ast::type::I32 i32; auto coords_type = get_coords_type(dim, &i32); - ast::type::Type* texture_type = mod->create( + ast::type::Type* texture_type = mod->create( dim, ast::AccessControl::kReadOnly, format); ast::ExpressionList call_params; @@ -1851,59 +1845,59 @@ TEST_P(Intrinsic_StorageTextureOperation, TextureLoadRo) { EXPECT_TRUE(td()->DetermineResultType(&expr)); ASSERT_NE(expr.result_type(), nullptr); - ASSERT_TRUE(expr.result_type()->Is()); - if (type == TextureType::kF32) { + ASSERT_TRUE(expr.result_type()->Is()); + if (type == Texture::kF32) { EXPECT_TRUE(expr.result_type() - ->As() + ->As() ->type() - ->Is()); - } else if (type == TextureType::kI32) { + ->Is()); + } else if (type == Texture::kI32) { EXPECT_TRUE(expr.result_type() - ->As() + ->As() ->type() - ->Is()); + ->Is()); } else { EXPECT_TRUE(expr.result_type() - ->As() + ->As() ->type() - ->Is()); + ->Is()); } - EXPECT_EQ(expr.result_type()->As()->size(), 4u); + EXPECT_EQ(expr.result_type()->As()->size(), 4u); } INSTANTIATE_TEST_SUITE_P( TypeDeterminerTest, Intrinsic_StorageTextureOperation, testing::Values( - TextureTestParams{ast::type::TextureDimension::k1d, TextureType::kF32, + TextureTestParams{ast::type::TextureDimension::k1d, Texture::kF32, ast::type::ImageFormat::kR16Float}, - TextureTestParams{ast::type::TextureDimension::k1d, TextureType::kI32, + TextureTestParams{ast::type::TextureDimension::k1d, Texture::kI32, ast::type::ImageFormat::kR16Sint}, - TextureTestParams{ast::type::TextureDimension::k1d, TextureType::kF32, + TextureTestParams{ast::type::TextureDimension::k1d, Texture::kF32, ast::type::ImageFormat::kR8Unorm}, - TextureTestParams{ast::type::TextureDimension::k1dArray, - TextureType::kF32, ast::type::ImageFormat::kR16Float}, - TextureTestParams{ast::type::TextureDimension::k1dArray, - TextureType::kI32, ast::type::ImageFormat::kR16Sint}, - TextureTestParams{ast::type::TextureDimension::k1dArray, - TextureType::kF32, ast::type::ImageFormat::kR8Unorm}, - TextureTestParams{ast::type::TextureDimension::k2d, TextureType::kF32, + TextureTestParams{ast::type::TextureDimension::k1dArray, Texture::kF32, ast::type::ImageFormat::kR16Float}, - TextureTestParams{ast::type::TextureDimension::k2d, TextureType::kI32, + TextureTestParams{ast::type::TextureDimension::k1dArray, Texture::kI32, ast::type::ImageFormat::kR16Sint}, - TextureTestParams{ast::type::TextureDimension::k2d, TextureType::kF32, + TextureTestParams{ast::type::TextureDimension::k1dArray, Texture::kF32, ast::type::ImageFormat::kR8Unorm}, - TextureTestParams{ast::type::TextureDimension::k2dArray, - TextureType::kF32, ast::type::ImageFormat::kR16Float}, - TextureTestParams{ast::type::TextureDimension::k2dArray, - TextureType::kI32, ast::type::ImageFormat::kR16Sint}, - TextureTestParams{ast::type::TextureDimension::k2dArray, - TextureType::kF32, ast::type::ImageFormat::kR8Unorm}, - TextureTestParams{ast::type::TextureDimension::k3d, TextureType::kF32, + TextureTestParams{ast::type::TextureDimension::k2d, Texture::kF32, ast::type::ImageFormat::kR16Float}, - TextureTestParams{ast::type::TextureDimension::k3d, TextureType::kI32, + TextureTestParams{ast::type::TextureDimension::k2d, Texture::kI32, ast::type::ImageFormat::kR16Sint}, - TextureTestParams{ast::type::TextureDimension::k3d, TextureType::kF32, + TextureTestParams{ast::type::TextureDimension::k2d, Texture::kF32, + ast::type::ImageFormat::kR8Unorm}, + TextureTestParams{ast::type::TextureDimension::k2dArray, Texture::kF32, + ast::type::ImageFormat::kR16Float}, + TextureTestParams{ast::type::TextureDimension::k2dArray, Texture::kI32, + ast::type::ImageFormat::kR16Sint}, + TextureTestParams{ast::type::TextureDimension::k2dArray, Texture::kF32, + ast::type::ImageFormat::kR8Unorm}, + TextureTestParams{ast::type::TextureDimension::k3d, Texture::kF32, + ast::type::ImageFormat::kR16Float}, + TextureTestParams{ast::type::TextureDimension::k3d, Texture::kI32, + ast::type::ImageFormat::kR16Sint}, + TextureTestParams{ast::type::TextureDimension::k3d, Texture::kF32, ast::type::ImageFormat::kR8Unorm})); using Intrinsic_SampledTextureOperation = Intrinsic_TextureOperation; @@ -1911,11 +1905,10 @@ TEST_P(Intrinsic_SampledTextureOperation, TextureLoadSampled) { auto dim = GetParam().dim; auto type = GetParam().type; - ast::type::I32Type i32; + ast::type::I32 i32; std::unique_ptr s = subtype(type); auto coords_type = get_coords_type(dim, &i32); - auto texture_type = - std::make_unique(dim, s.get()); + auto texture_type = std::make_unique(dim, s.get()); ast::ExpressionList call_params; @@ -1930,24 +1923,24 @@ TEST_P(Intrinsic_SampledTextureOperation, TextureLoadSampled) { EXPECT_TRUE(td()->DetermineResultType(&expr)); ASSERT_NE(expr.result_type(), nullptr); - ASSERT_TRUE(expr.result_type()->Is()); - if (type == TextureType::kF32) { + ASSERT_TRUE(expr.result_type()->Is()); + if (type == Texture::kF32) { EXPECT_TRUE(expr.result_type() - ->As() + ->As() ->type() - ->Is()); - } else if (type == TextureType::kI32) { + ->Is()); + } else if (type == Texture::kI32) { EXPECT_TRUE(expr.result_type() - ->As() + ->As() ->type() - ->Is()); + ->Is()); } else { EXPECT_TRUE(expr.result_type() - ->As() + ->As() ->type() - ->Is()); + ->Is()); } - EXPECT_EQ(expr.result_type()->As()->size(), 4u); + EXPECT_EQ(expr.result_type()->As()->size(), 4u); } INSTANTIATE_TEST_SUITE_P( @@ -1960,8 +1953,8 @@ INSTANTIATE_TEST_SUITE_P( ast::type::TextureDimension::kCubeArray})); TEST_F(TypeDeterminerTest, Intrinsic_Dot) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); auto* var = create("my_var", ast::StorageClass::kNone, &vec3); mod->AddGlobalVariable(var); @@ -1977,14 +1970,14 @@ TEST_F(TypeDeterminerTest, Intrinsic_Dot) { EXPECT_TRUE(td()->Determine()); EXPECT_TRUE(td()->DetermineResultType(&expr)); ASSERT_NE(expr.result_type(), nullptr); - EXPECT_TRUE(expr.result_type()->Is()); + EXPECT_TRUE(expr.result_type()->Is()); } TEST_F(TypeDeterminerTest, Intrinsic_Select) { - ast::type::F32Type f32; - ast::type::BoolType bool_type; - ast::type::VectorType vec3(&f32, 3); - ast::type::VectorType bool_vec3(&bool_type, 3); + ast::type::F32 f32; + ast::type::Bool bool_type; + ast::type::Vector vec3(&f32, 3); + ast::type::Vector bool_vec3(&bool_type, 3); auto* var = create("my_var", ast::StorageClass::kNone, &vec3); auto* bool_var = @@ -2004,17 +1997,17 @@ TEST_F(TypeDeterminerTest, Intrinsic_Select) { EXPECT_TRUE(td()->Determine()); EXPECT_TRUE(td()->DetermineResultType(&expr)) << td()->error(); ASSERT_NE(expr.result_type(), nullptr); - EXPECT_TRUE(expr.result_type()->Is()); - EXPECT_EQ(expr.result_type()->As()->size(), 3u); + EXPECT_TRUE(expr.result_type()->Is()); + EXPECT_EQ(expr.result_type()->As()->size(), 3u); EXPECT_TRUE(expr.result_type() - ->As() + ->As() ->type() - ->Is()); + ->Is()); } TEST_F(TypeDeterminerTest, Intrinsic_Select_TooFewParams) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); auto* var = create("v", ast::StorageClass::kNone, &vec3); mod->AddGlobalVariable(var); @@ -2033,8 +2026,8 @@ TEST_F(TypeDeterminerTest, Intrinsic_Select_TooFewParams) { } TEST_F(TypeDeterminerTest, Intrinsic_Select_TooManyParams) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); auto* var = create("v", ast::StorageClass::kNone, &vec3); mod->AddGlobalVariable(var); @@ -2056,9 +2049,9 @@ TEST_F(TypeDeterminerTest, Intrinsic_Select_TooManyParams) { } TEST_F(TypeDeterminerTest, Intrinsic_OuterProduct) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); - ast::type::VectorType vec2(&f32, 2); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); + ast::type::Vector vec2(&f32, 2); auto* var1 = create("v3", ast::StorageClass::kNone, &vec3); auto* var2 = create("v2", ast::StorageClass::kNone, &vec2); @@ -2077,18 +2070,18 @@ TEST_F(TypeDeterminerTest, Intrinsic_OuterProduct) { EXPECT_TRUE(td()->DetermineResultType(&expr)); ASSERT_NE(expr.result_type(), nullptr); - ASSERT_TRUE(expr.result_type()->Is()); + ASSERT_TRUE(expr.result_type()->Is()); - auto* mat = expr.result_type()->As(); - EXPECT_TRUE(mat->type()->Is()); + auto* mat = expr.result_type()->As(); + EXPECT_TRUE(mat->type()->Is()); EXPECT_EQ(mat->rows(), 3u); EXPECT_EQ(mat->columns(), 2u); } TEST_F(TypeDeterminerTest, Intrinsic_OuterProduct_TooFewParams) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); - ast::type::VectorType vec2(&f32, 2); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); + ast::type::Vector vec2(&f32, 2); auto* var2 = create("v2", ast::StorageClass::kNone, &vec2); mod->AddGlobalVariable(var2); @@ -2106,9 +2099,9 @@ TEST_F(TypeDeterminerTest, Intrinsic_OuterProduct_TooFewParams) { } TEST_F(TypeDeterminerTest, Intrinsic_OuterProduct_TooManyParams) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); - ast::type::VectorType vec2(&f32, 2); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); + ast::type::Vector vec2(&f32, 2); auto* var2 = create("v2", ast::StorageClass::kNone, &vec2); mod->AddGlobalVariable(var2); @@ -2131,9 +2124,9 @@ using UnaryOpExpressionTest = TypeDeterminerTestWithParam; TEST_P(UnaryOpExpressionTest, Expr_UnaryOp) { auto op = GetParam(); - ast::type::F32Type f32; + ast::type::F32 f32; - ast::type::VectorType vec4(&f32, 4); + ast::type::Vector vec4(&f32, 4); auto* var = create("ident", ast::StorageClass::kNone, &vec4); mod->AddGlobalVariable(var); @@ -2144,12 +2137,10 @@ TEST_P(UnaryOpExpressionTest, Expr_UnaryOp) { ast::UnaryOpExpression der(op, create("ident")); EXPECT_TRUE(td()->DetermineResultType(&der)); ASSERT_NE(der.result_type(), nullptr); - ASSERT_TRUE(der.result_type()->Is()); - EXPECT_TRUE(der.result_type() - ->As() - ->type() - ->Is()); - EXPECT_EQ(der.result_type()->As()->size(), 4u); + ASSERT_TRUE(der.result_type()->Is()); + EXPECT_TRUE( + der.result_type()->As()->type()->Is()); + EXPECT_EQ(der.result_type()->As()->size(), 4u); } INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest, UnaryOpExpressionTest, @@ -2157,7 +2148,7 @@ INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest, ast::UnaryOp::kNot)); TEST_F(TypeDeterminerTest, StorageClass_SetsIfMissing) { - ast::type::I32Type i32; + ast::type::I32 i32; auto* var = create("var", ast::StorageClass::kNone, &i32); auto* stmt = create(var); @@ -2173,7 +2164,7 @@ TEST_F(TypeDeterminerTest, StorageClass_SetsIfMissing) { } TEST_F(TypeDeterminerTest, StorageClass_DoesNotSetOnConst) { - ast::type::I32Type i32; + ast::type::I32 i32; auto* var = create("var", ast::StorageClass::kNone, &i32); var->set_is_const(true); @@ -2190,7 +2181,7 @@ TEST_F(TypeDeterminerTest, StorageClass_DoesNotSetOnConst) { } TEST_F(TypeDeterminerTest, StorageClass_NonFunctionClassError) { - ast::type::I32Type i32; + ast::type::I32 i32; auto* var = create("var", ast::StorageClass::kWorkgroup, &i32); auto* stmt = create(var); @@ -2309,7 +2300,7 @@ using ImportData_SingleParamTest = TypeDeterminerTestWithParam; TEST_P(ImportData_SingleParamTest, Scalar) { auto param = GetParam(); - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( @@ -2327,8 +2318,8 @@ TEST_P(ImportData_SingleParamTest, Scalar) { TEST_P(ImportData_SingleParamTest, Vector) { auto param = GetParam(); - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::ExpressionList vals; vals.push_back(create( @@ -2348,13 +2339,13 @@ TEST_P(ImportData_SingleParamTest, Vector) { EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error(); ASSERT_NE(ident->result_type(), nullptr); EXPECT_TRUE(ident->result_type()->is_float_vector()); - EXPECT_EQ(ident->result_type()->As()->size(), 3u); + EXPECT_EQ(ident->result_type()->As()->size(), 3u); } TEST_P(ImportData_SingleParamTest, Error_Integer) { auto param = GetParam(); - ast::type::I32Type i32; + ast::type::I32 i32; ast::ExpressionList params; params.push_back(create( @@ -2385,7 +2376,7 @@ TEST_P(ImportData_SingleParamTest, Error_NoParams) { TEST_P(ImportData_SingleParamTest, Error_MultipleParams) { auto param = GetParam(); - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( create(&f32, 1.f))); @@ -2433,7 +2424,7 @@ using ImportData_SingleParam_FloatOrInt_Test = TEST_P(ImportData_SingleParam_FloatOrInt_Test, Float_Scalar) { auto param = GetParam(); - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( @@ -2451,8 +2442,8 @@ TEST_P(ImportData_SingleParam_FloatOrInt_Test, Float_Scalar) { TEST_P(ImportData_SingleParam_FloatOrInt_Test, Float_Vector) { auto param = GetParam(); - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::ExpressionList vals; vals.push_back(create( @@ -2472,13 +2463,13 @@ TEST_P(ImportData_SingleParam_FloatOrInt_Test, Float_Vector) { EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error(); ASSERT_NE(ident->result_type(), nullptr); EXPECT_TRUE(ident->result_type()->is_float_vector()); - EXPECT_EQ(ident->result_type()->As()->size(), 3u); + EXPECT_EQ(ident->result_type()->As()->size(), 3u); } TEST_P(ImportData_SingleParam_FloatOrInt_Test, Sint_Scalar) { auto param = GetParam(); - ast::type::I32Type i32; + ast::type::I32 i32; ast::ExpressionList params; params.push_back(create( @@ -2490,14 +2481,14 @@ TEST_P(ImportData_SingleParam_FloatOrInt_Test, Sint_Scalar) { EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error(); ASSERT_NE(ident->result_type(), nullptr); - EXPECT_TRUE(ident->result_type()->Is()); + EXPECT_TRUE(ident->result_type()->Is()); } TEST_P(ImportData_SingleParam_FloatOrInt_Test, Sint_Vector) { auto param = GetParam(); - ast::type::I32Type i32; - ast::type::VectorType vec(&i32, 3); + ast::type::I32 i32; + ast::type::Vector vec(&i32, 3); ast::ExpressionList vals; vals.push_back(create( @@ -2517,13 +2508,13 @@ TEST_P(ImportData_SingleParam_FloatOrInt_Test, Sint_Vector) { EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error(); ASSERT_NE(ident->result_type(), nullptr); EXPECT_TRUE(ident->result_type()->is_signed_integer_vector()); - EXPECT_EQ(ident->result_type()->As()->size(), 3u); + EXPECT_EQ(ident->result_type()->As()->size(), 3u); } TEST_P(ImportData_SingleParam_FloatOrInt_Test, Uint_Scalar) { auto param = GetParam(); - ast::type::U32Type u32; + ast::type::U32 u32; ast::ExpressionList params; params.push_back(create( @@ -2535,14 +2526,14 @@ TEST_P(ImportData_SingleParam_FloatOrInt_Test, Uint_Scalar) { EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error(); ASSERT_NE(ident->result_type(), nullptr); - EXPECT_TRUE(ident->result_type()->Is()); + EXPECT_TRUE(ident->result_type()->Is()); } TEST_P(ImportData_SingleParam_FloatOrInt_Test, Uint_Vector) { auto param = GetParam(); - ast::type::U32Type u32; - ast::type::VectorType vec(&u32, 3); + ast::type::U32 u32; + ast::type::Vector vec(&u32, 3); ast::ExpressionList vals; vals.push_back(create( @@ -2562,13 +2553,13 @@ TEST_P(ImportData_SingleParam_FloatOrInt_Test, Uint_Vector) { EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error(); ASSERT_NE(ident->result_type(), nullptr); EXPECT_TRUE(ident->result_type()->is_unsigned_integer_vector()); - EXPECT_EQ(ident->result_type()->As()->size(), 3u); + EXPECT_EQ(ident->result_type()->As()->size(), 3u); } TEST_P(ImportData_SingleParam_FloatOrInt_Test, Error_Bool) { auto param = GetParam(); - ast::type::BoolType bool_type; + ast::type::Bool bool_type; ast::ExpressionList params; params.push_back(create( @@ -2599,7 +2590,7 @@ TEST_P(ImportData_SingleParam_FloatOrInt_Test, Error_NoParams) { TEST_P(ImportData_SingleParam_FloatOrInt_Test, Error_MultipleParams) { auto param = GetParam(); - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( create(&f32, 1.f))); @@ -2622,7 +2613,7 @@ INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest, ast::Intrinsic::kAbs})); TEST_F(TypeDeterminerTest, ImportData_Length_Scalar) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( @@ -2640,8 +2631,8 @@ TEST_F(TypeDeterminerTest, ImportData_Length_Scalar) { } TEST_F(TypeDeterminerTest, ImportData_Length_FloatVector) { - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::ExpressionList vals; vals.push_back(create( @@ -2664,7 +2655,7 @@ TEST_F(TypeDeterminerTest, ImportData_Length_FloatVector) { } TEST_F(TypeDeterminerTest, ImportData_Length_Error_Integer) { - ast::type::I32Type i32; + ast::type::I32 i32; ast::ExpressionList params; params.push_back(create( @@ -2691,7 +2682,7 @@ TEST_F(TypeDeterminerTest, ImportData_Length_Error_NoParams) { } TEST_F(TypeDeterminerTest, ImportData_Length_Error_MultipleParams) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( create(&f32, 1.f))); @@ -2712,7 +2703,7 @@ using ImportData_TwoParamTest = TypeDeterminerTestWithParam; TEST_P(ImportData_TwoParamTest, Scalar) { auto param = GetParam(); - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( @@ -2732,8 +2723,8 @@ TEST_P(ImportData_TwoParamTest, Scalar) { TEST_P(ImportData_TwoParamTest, Vector) { auto param = GetParam(); - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::ExpressionList vals_1; vals_1.push_back(create( @@ -2762,13 +2753,13 @@ TEST_P(ImportData_TwoParamTest, Vector) { EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error(); ASSERT_NE(ident->result_type(), nullptr); EXPECT_TRUE(ident->result_type()->is_float_vector()); - EXPECT_EQ(ident->result_type()->As()->size(), 3u); + EXPECT_EQ(ident->result_type()->As()->size(), 3u); } TEST_P(ImportData_TwoParamTest, Error_Integer) { auto param = GetParam(); - ast::type::I32Type i32; + ast::type::I32 i32; ast::ExpressionList params; params.push_back(create( @@ -2801,7 +2792,7 @@ TEST_P(ImportData_TwoParamTest, Error_NoParams) { TEST_P(ImportData_TwoParamTest, Error_OneParam) { auto param = GetParam(); - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( create(&f32, 1.f))); @@ -2817,9 +2808,9 @@ TEST_P(ImportData_TwoParamTest, Error_OneParam) { TEST_P(ImportData_TwoParamTest, Error_MismatchedParamCount) { auto param = GetParam(); - ast::type::F32Type f32; - ast::type::VectorType vec2(&f32, 2); - ast::type::VectorType vec3(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec2(&f32, 2); + ast::type::Vector vec3(&f32, 3); ast::ExpressionList vals_1; vals_1.push_back(create( @@ -2850,8 +2841,8 @@ TEST_P(ImportData_TwoParamTest, Error_MismatchedParamCount) { TEST_P(ImportData_TwoParamTest, Error_MismatchedParamType) { auto param = GetParam(); - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::ExpressionList vals; vals.push_back(create( @@ -2877,7 +2868,7 @@ TEST_P(ImportData_TwoParamTest, Error_MismatchedParamType) { TEST_P(ImportData_TwoParamTest, Error_TooManyParams) { auto param = GetParam(); - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( create(&f32, 1.f))); @@ -2903,7 +2894,7 @@ INSTANTIATE_TEST_SUITE_P( IntrinsicData{"reflect", ast::Intrinsic::kReflect})); TEST_F(TypeDeterminerTest, ImportData_Distance_Scalar) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( @@ -2921,8 +2912,8 @@ TEST_F(TypeDeterminerTest, ImportData_Distance_Scalar) { } TEST_F(TypeDeterminerTest, ImportData_Distance_Vector) { - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::ExpressionList vals_1; vals_1.push_back(create( @@ -2950,11 +2941,11 @@ TEST_F(TypeDeterminerTest, ImportData_Distance_Vector) { EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error(); ASSERT_NE(ident->result_type(), nullptr); - EXPECT_TRUE(ident->result_type()->Is()); + EXPECT_TRUE(ident->result_type()->Is()); } TEST_F(TypeDeterminerTest, ImportData_Distance_Error_Integer) { - ast::type::I32Type i32; + ast::type::I32 i32; ast::ExpressionList params; params.push_back(create( @@ -2983,7 +2974,7 @@ TEST_F(TypeDeterminerTest, ImportData_Distance_Error_NoParams) { } TEST_F(TypeDeterminerTest, ImportData_Distance_Error_OneParam) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( create(&f32, 1.f))); @@ -2997,9 +2988,9 @@ TEST_F(TypeDeterminerTest, ImportData_Distance_Error_OneParam) { } TEST_F(TypeDeterminerTest, ImportData_Distance_Error_MismatchedParamCount) { - ast::type::F32Type f32; - ast::type::VectorType vec2(&f32, 2); - ast::type::VectorType vec3(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec2(&f32, 2); + ast::type::Vector vec3(&f32, 3); ast::ExpressionList vals_1; vals_1.push_back(create( @@ -3027,8 +3018,8 @@ TEST_F(TypeDeterminerTest, ImportData_Distance_Error_MismatchedParamCount) { } TEST_F(TypeDeterminerTest, ImportData_Distance_Error_MismatchedParamType) { - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::ExpressionList vals; vals.push_back(create( @@ -3051,7 +3042,7 @@ TEST_F(TypeDeterminerTest, ImportData_Distance_Error_MismatchedParamType) { } TEST_F(TypeDeterminerTest, ImportData_Distance_Error_TooManyParams) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( create(&f32, 1.f))); @@ -3069,8 +3060,8 @@ TEST_F(TypeDeterminerTest, ImportData_Distance_Error_TooManyParams) { } TEST_F(TypeDeterminerTest, ImportData_Cross) { - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::ExpressionList vals_1; vals_1.push_back(create( @@ -3099,11 +3090,11 @@ TEST_F(TypeDeterminerTest, ImportData_Cross) { EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error(); ASSERT_NE(ident->result_type(), nullptr); EXPECT_TRUE(ident->result_type()->is_float_vector()); - EXPECT_EQ(ident->result_type()->As()->size(), 3u); + EXPECT_EQ(ident->result_type()->As()->size(), 3u); } TEST_F(TypeDeterminerTest, ImportData_Cross_Error_Scalar) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( @@ -3120,8 +3111,8 @@ TEST_F(TypeDeterminerTest, ImportData_Cross_Error_Scalar) { } TEST_F(TypeDeterminerTest, ImportData_Cross_Error_IntType) { - ast::type::I32Type i32; - ast::type::VectorType vec(&i32, 3); + ast::type::I32 i32; + ast::type::Vector vec(&i32, 3); ast::ExpressionList vals_1; vals_1.push_back(create( @@ -3162,8 +3153,8 @@ TEST_F(TypeDeterminerTest, ImportData_Cross_Error_MissingParams) { } TEST_F(TypeDeterminerTest, ImportData_Cross_Error_TooFewParams) { - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::ExpressionList vals_1; vals_1.push_back(create( @@ -3185,8 +3176,8 @@ TEST_F(TypeDeterminerTest, ImportData_Cross_Error_TooFewParams) { } TEST_F(TypeDeterminerTest, ImportData_Cross_Error_TooManyParams) { - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::ExpressionList vals_1; vals_1.push_back(create( @@ -3229,7 +3220,7 @@ using ImportData_ThreeParamTest = TypeDeterminerTestWithParam; TEST_P(ImportData_ThreeParamTest, Scalar) { auto param = GetParam(); - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( @@ -3251,8 +3242,8 @@ TEST_P(ImportData_ThreeParamTest, Scalar) { TEST_P(ImportData_ThreeParamTest, Vector) { auto param = GetParam(); - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::ExpressionList vals_1; vals_1.push_back(create( @@ -3290,13 +3281,13 @@ TEST_P(ImportData_ThreeParamTest, Vector) { EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error(); ASSERT_NE(ident->result_type(), nullptr); EXPECT_TRUE(ident->result_type()->is_float_vector()); - EXPECT_EQ(ident->result_type()->As()->size(), 3u); + EXPECT_EQ(ident->result_type()->As()->size(), 3u); } TEST_P(ImportData_ThreeParamTest, Error_Integer) { auto param = GetParam(); - ast::type::I32Type i32; + ast::type::I32 i32; ast::ExpressionList params; params.push_back(create( @@ -3331,7 +3322,7 @@ TEST_P(ImportData_ThreeParamTest, Error_NoParams) { TEST_P(ImportData_ThreeParamTest, Error_OneParam) { auto param = GetParam(); - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( create(&f32, 1.f))); @@ -3347,7 +3338,7 @@ TEST_P(ImportData_ThreeParamTest, Error_OneParam) { TEST_P(ImportData_ThreeParamTest, Error_TwoParams) { auto param = GetParam(); - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( create(&f32, 1.f))); @@ -3365,9 +3356,9 @@ TEST_P(ImportData_ThreeParamTest, Error_TwoParams) { TEST_P(ImportData_ThreeParamTest, Error_MismatchedParamCount) { auto param = GetParam(); - ast::type::F32Type f32; - ast::type::VectorType vec2(&f32, 2); - ast::type::VectorType vec3(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec2(&f32, 2); + ast::type::Vector vec3(&f32, 3); ast::ExpressionList vals_1; vals_1.push_back(create( @@ -3407,8 +3398,8 @@ TEST_P(ImportData_ThreeParamTest, Error_MismatchedParamCount) { TEST_P(ImportData_ThreeParamTest, Error_MismatchedParamType) { auto param = GetParam(); - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::ExpressionList vals; vals.push_back(create( @@ -3436,7 +3427,7 @@ TEST_P(ImportData_ThreeParamTest, Error_MismatchedParamType) { TEST_P(ImportData_ThreeParamTest, Error_TooManyParams) { auto param = GetParam(); - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( create(&f32, 1.f))); @@ -3469,7 +3460,7 @@ using ImportData_ThreeParam_FloatOrInt_Test = TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Float_Scalar) { auto param = GetParam(); - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( @@ -3491,8 +3482,8 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Float_Scalar) { TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Float_Vector) { auto param = GetParam(); - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::ExpressionList vals_1; vals_1.push_back(create( @@ -3530,13 +3521,13 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Float_Vector) { EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error(); ASSERT_NE(ident->result_type(), nullptr); EXPECT_TRUE(ident->result_type()->is_float_vector()); - EXPECT_EQ(ident->result_type()->As()->size(), 3u); + EXPECT_EQ(ident->result_type()->As()->size(), 3u); } TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Sint_Scalar) { auto param = GetParam(); - ast::type::I32Type i32; + ast::type::I32 i32; ast::ExpressionList params; params.push_back(create( @@ -3552,14 +3543,14 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Sint_Scalar) { EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error(); ASSERT_NE(ident->result_type(), nullptr); - EXPECT_TRUE(ident->result_type()->Is()); + EXPECT_TRUE(ident->result_type()->Is()); } TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Sint_Vector) { auto param = GetParam(); - ast::type::I32Type i32; - ast::type::VectorType vec(&i32, 3); + ast::type::I32 i32; + ast::type::Vector vec(&i32, 3); ast::ExpressionList vals_1; vals_1.push_back(create( @@ -3597,13 +3588,13 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Sint_Vector) { EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error(); ASSERT_NE(ident->result_type(), nullptr); EXPECT_TRUE(ident->result_type()->is_signed_integer_vector()); - EXPECT_EQ(ident->result_type()->As()->size(), 3u); + EXPECT_EQ(ident->result_type()->As()->size(), 3u); } TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Uint_Scalar) { auto param = GetParam(); - ast::type::U32Type u32; + ast::type::U32 u32; ast::ExpressionList params; params.push_back(create( @@ -3619,14 +3610,14 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Uint_Scalar) { EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error(); ASSERT_NE(ident->result_type(), nullptr); - EXPECT_TRUE(ident->result_type()->Is()); + EXPECT_TRUE(ident->result_type()->Is()); } TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Uint_Vector) { auto param = GetParam(); - ast::type::U32Type u32; - ast::type::VectorType vec(&u32, 3); + ast::type::U32 u32; + ast::type::Vector vec(&u32, 3); ast::ExpressionList vals_1; vals_1.push_back(create( @@ -3664,13 +3655,13 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Uint_Vector) { EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error(); ASSERT_NE(ident->result_type(), nullptr); EXPECT_TRUE(ident->result_type()->is_unsigned_integer_vector()); - EXPECT_EQ(ident->result_type()->As()->size(), 3u); + EXPECT_EQ(ident->result_type()->As()->size(), 3u); } TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Error_Bool) { auto param = GetParam(); - ast::type::BoolType bool_type; + ast::type::Bool bool_type; ast::ExpressionList params; params.push_back(create( @@ -3705,7 +3696,7 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Error_NoParams) { TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Error_OneParam) { auto param = GetParam(); - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( create(&f32, 1.f))); @@ -3721,7 +3712,7 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Error_OneParam) { TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Error_TwoParams) { auto param = GetParam(); - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( create(&f32, 1.f))); @@ -3739,9 +3730,9 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Error_TwoParams) { TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Error_MismatchedParamCount) { auto param = GetParam(); - ast::type::F32Type f32; - ast::type::VectorType vec2(&f32, 2); - ast::type::VectorType vec3(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec2(&f32, 2); + ast::type::Vector vec3(&f32, 3); ast::ExpressionList vals_1; vals_1.push_back(create( @@ -3781,8 +3772,8 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Error_MismatchedParamCount) { TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Error_MismatchedParamType) { auto param = GetParam(); - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::ExpressionList vals; vals.push_back(create( @@ -3810,7 +3801,7 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Error_MismatchedParamType) { TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Error_TooManyParams) { auto param = GetParam(); - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( create(&f32, 1.f))); @@ -3839,7 +3830,7 @@ using ImportData_Int_SingleParamTest = TEST_P(ImportData_Int_SingleParamTest, Scalar) { auto param = GetParam(); - ast::type::I32Type i32; + ast::type::I32 i32; ast::ExpressionList params; params.push_back(create( @@ -3857,8 +3848,8 @@ TEST_P(ImportData_Int_SingleParamTest, Scalar) { TEST_P(ImportData_Int_SingleParamTest, Vector) { auto param = GetParam(); - ast::type::I32Type i32; - ast::type::VectorType vec(&i32, 3); + ast::type::I32 i32; + ast::type::Vector vec(&i32, 3); ast::ExpressionList vals; vals.push_back(create( @@ -3878,13 +3869,13 @@ TEST_P(ImportData_Int_SingleParamTest, Vector) { EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error(); ASSERT_NE(ident->result_type(), nullptr); EXPECT_TRUE(ident->result_type()->is_signed_integer_vector()); - EXPECT_EQ(ident->result_type()->As()->size(), 3u); + EXPECT_EQ(ident->result_type()->As()->size(), 3u); } TEST_P(ImportData_Int_SingleParamTest, Error_Float) { auto param = GetParam(); - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( @@ -3915,7 +3906,7 @@ TEST_P(ImportData_Int_SingleParamTest, Error_NoParams) { TEST_P(ImportData_Int_SingleParamTest, Error_MultipleParams) { auto param = GetParam(); - ast::type::I32Type i32; + ast::type::I32 i32; ast::ExpressionList params; params.push_back(create( create(&i32, 1))); @@ -3944,7 +3935,7 @@ using ImportData_FloatOrInt_TwoParamTest = TEST_P(ImportData_FloatOrInt_TwoParamTest, Scalar_Signed) { auto param = GetParam(); - ast::type::I32Type i32; + ast::type::I32 i32; ast::ExpressionList params; params.push_back(create( @@ -3958,13 +3949,13 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Scalar_Signed) { EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error(); ASSERT_NE(ident->result_type(), nullptr); - EXPECT_TRUE(ident->result_type()->Is()); + EXPECT_TRUE(ident->result_type()->Is()); } TEST_P(ImportData_FloatOrInt_TwoParamTest, Scalar_Unsigned) { auto param = GetParam(); - ast::type::U32Type u32; + ast::type::U32 u32; ast::ExpressionList params; params.push_back(create( @@ -3978,13 +3969,13 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Scalar_Unsigned) { EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error(); ASSERT_NE(ident->result_type(), nullptr); - EXPECT_TRUE(ident->result_type()->Is()); + EXPECT_TRUE(ident->result_type()->Is()); } TEST_P(ImportData_FloatOrInt_TwoParamTest, Scalar_Float) { auto param = GetParam(); - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( @@ -3998,14 +3989,14 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Scalar_Float) { EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error(); ASSERT_NE(ident->result_type(), nullptr); - EXPECT_TRUE(ident->result_type()->Is()); + EXPECT_TRUE(ident->result_type()->Is()); } TEST_P(ImportData_FloatOrInt_TwoParamTest, Vector_Signed) { auto param = GetParam(); - ast::type::I32Type i32; - ast::type::VectorType vec(&i32, 3); + ast::type::I32 i32; + ast::type::Vector vec(&i32, 3); ast::ExpressionList vals_1; vals_1.push_back(create( @@ -4034,14 +4025,14 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Vector_Signed) { EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error(); ASSERT_NE(ident->result_type(), nullptr); EXPECT_TRUE(ident->result_type()->is_signed_integer_vector()); - EXPECT_EQ(ident->result_type()->As()->size(), 3u); + EXPECT_EQ(ident->result_type()->As()->size(), 3u); } TEST_P(ImportData_FloatOrInt_TwoParamTest, Vector_Unsigned) { auto param = GetParam(); - ast::type::U32Type u32; - ast::type::VectorType vec(&u32, 3); + ast::type::U32 u32; + ast::type::Vector vec(&u32, 3); ast::ExpressionList vals_1; vals_1.push_back(create( @@ -4070,14 +4061,14 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Vector_Unsigned) { EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error(); ASSERT_NE(ident->result_type(), nullptr); EXPECT_TRUE(ident->result_type()->is_unsigned_integer_vector()); - EXPECT_EQ(ident->result_type()->As()->size(), 3u); + EXPECT_EQ(ident->result_type()->As()->size(), 3u); } TEST_P(ImportData_FloatOrInt_TwoParamTest, Vector_Float) { auto param = GetParam(); - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::ExpressionList vals_1; vals_1.push_back(create( @@ -4106,13 +4097,13 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Vector_Float) { EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error(); ASSERT_NE(ident->result_type(), nullptr); EXPECT_TRUE(ident->result_type()->is_float_vector()); - EXPECT_EQ(ident->result_type()->As()->size(), 3u); + EXPECT_EQ(ident->result_type()->As()->size(), 3u); } TEST_P(ImportData_FloatOrInt_TwoParamTest, Error_Bool) { auto param = GetParam(); - ast::type::BoolType bool_type; + ast::type::Bool bool_type; ast::ExpressionList params; params.push_back(create( @@ -4145,7 +4136,7 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Error_NoParams) { TEST_P(ImportData_FloatOrInt_TwoParamTest, Error_OneParam) { auto param = GetParam(); - ast::type::I32Type i32; + ast::type::I32 i32; ast::ExpressionList params; params.push_back(create( create(&i32, 1))); @@ -4161,9 +4152,9 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Error_OneParam) { TEST_P(ImportData_FloatOrInt_TwoParamTest, Error_MismatchedParamCount) { auto param = GetParam(); - ast::type::I32Type i32; - ast::type::VectorType vec2(&i32, 2); - ast::type::VectorType vec3(&i32, 3); + ast::type::I32 i32; + ast::type::Vector vec2(&i32, 2); + ast::type::Vector vec3(&i32, 3); ast::ExpressionList vals_1; vals_1.push_back(create( @@ -4194,8 +4185,8 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Error_MismatchedParamCount) { TEST_P(ImportData_FloatOrInt_TwoParamTest, Error_MismatchedParamType) { auto param = GetParam(); - ast::type::I32Type i32; - ast::type::VectorType vec(&i32, 3); + ast::type::I32 i32; + ast::type::Vector vec(&i32, 3); ast::ExpressionList vals; vals.push_back(create( @@ -4221,7 +4212,7 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Error_MismatchedParamType) { TEST_P(ImportData_FloatOrInt_TwoParamTest, Error_TooManyParams) { auto param = GetParam(); - ast::type::I32Type i32; + ast::type::I32 i32; ast::ExpressionList params; params.push_back(create( create(&i32, 1))); @@ -4245,8 +4236,8 @@ INSTANTIATE_TEST_SUITE_P( IntrinsicData{"max", ast::Intrinsic::kMax})); TEST_F(TypeDeterminerTest, ImportData_GLSL_Determinant) { - ast::type::F32Type f32; - ast::type::MatrixType mat(&f32, 3, 3); + ast::type::F32 f32; + ast::type::Matrix mat(&f32, 3, 3); auto* var = create("var", ast::StorageClass::kFunction, &mat); mod->AddGlobalVariable(var); @@ -4263,7 +4254,7 @@ TEST_F(TypeDeterminerTest, ImportData_GLSL_Determinant) { EXPECT_TRUE(td()->DetermineResultType(&call)) << td()->error(); ASSERT_NE(ident->result_type(), nullptr); - EXPECT_TRUE(ident->result_type()->Is()); + EXPECT_TRUE(ident->result_type()->Is()); } using ImportData_Matrix_OneParam_Test = @@ -4271,7 +4262,7 @@ using ImportData_Matrix_OneParam_Test = TEST_P(ImportData_Matrix_OneParam_Test, Error_Float) { auto param = GetParam(); - ast::type::F32Type f32; + ast::type::F32 f32; auto* var = create("var", ast::StorageClass::kFunction, &f32); mod->AddGlobalVariable(var); @@ -4306,8 +4297,8 @@ TEST_P(ImportData_Matrix_OneParam_Test, NoParams) { TEST_P(ImportData_Matrix_OneParam_Test, TooManyParams) { auto param = GetParam(); - ast::type::F32Type f32; - ast::type::MatrixType mat(&f32, 3, 3); + ast::type::F32 f32; + ast::type::Matrix mat(&f32, 3, 3); auto* var = create("var", ast::StorageClass::kFunction, &mat); mod->AddGlobalVariable(var); @@ -4332,7 +4323,7 @@ INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest, "determinant", ast::Intrinsic::kDeterminant})); TEST_F(TypeDeterminerTest, Function_EntryPoints_StageDecoration) { - ast::type::F32Type f32; + ast::type::F32 f32; // fn b() {} // fn c() { b(); } @@ -4617,17 +4608,17 @@ TEST_P(TypeDeterminerTextureIntrinsicTest, Call) { break; } - ast::type::SamplerType sampler_type{param.sampler_kind}; + ast::type::Sampler sampler_type{param.sampler_kind}; switch (param.texture_kind) { case ast::intrinsic::test::TextureKind::kRegular: Var("texture", ast::StorageClass::kNone, - mod->create(param.texture_dimension, - datatype)); + mod->create(param.texture_dimension, + datatype)); break; case ast::intrinsic::test::TextureKind::kDepth: Var("texture", ast::StorageClass::kNone, - mod->create(param.texture_dimension)); + mod->create(param.texture_dimension)); break; } @@ -4640,9 +4631,8 @@ TEST_P(TypeDeterminerTextureIntrinsicTest, Call) { switch (param.texture_kind) { case ast::intrinsic::test::TextureKind::kRegular: - ASSERT_TRUE(call.result_type()->Is()); - EXPECT_EQ(call.result_type()->As()->type(), - datatype); + ASSERT_TRUE(call.result_type()->Is()); + EXPECT_EQ(call.result_type()->As()->type(), datatype); break; case ast::intrinsic::test::TextureKind::kDepth: diff --git a/src/validator/validator_control_block_test.cc b/src/validator/validator_control_block_test.cc index 0a54cf9a2e..7e4fef27b8 100644 --- a/src/validator/validator_control_block_test.cc +++ b/src/validator/validator_control_block_test.cc @@ -42,7 +42,7 @@ TEST_F(ValidateControlBlockTest, SwitchSelectorExpressionNoneIntegerType_Fail) { // switch (a) { // default: {} // } - ast::type::F32Type f32; + ast::type::F32 f32; auto* var = create("a", ast::StorageClass::kNone, &f32); var->set_constructor(create( create(&f32, 3.14f))); @@ -70,7 +70,7 @@ TEST_F(ValidateControlBlockTest, SwitchWithoutDefault_Fail) { // switch (a) { // case 1: {} // } - ast::type::I32Type i32; + ast::type::I32 i32; auto* var = create("a", ast::StorageClass::kNone, &i32); var->set_constructor(create( create(&i32, 2))); @@ -101,7 +101,7 @@ TEST_F(ValidateControlBlockTest, SwitchWithTwoDefault_Fail) { // case 1: {} // default: {} // } - ast::type::I32Type i32; + ast::type::I32 i32; auto* var = create("a", ast::StorageClass::kNone, &i32); var->set_constructor(create( create(&i32, 2))); @@ -143,8 +143,8 @@ TEST_F(ValidateControlBlockTest, // case 1: {} // default: {} // } - ast::type::U32Type u32; - ast::type::I32Type i32; + ast::type::U32 u32; + ast::type::I32 i32; auto* var = create("a", ast::StorageClass::kNone, &i32); var->set_constructor(create( create(&i32, 2))); @@ -179,8 +179,8 @@ TEST_F(ValidateControlBlockTest, // case -1: {} // default: {} // } - ast::type::U32Type u32; - ast::type::I32Type i32; + ast::type::U32 u32; + ast::type::I32 i32; auto* var = create("a", ast::StorageClass::kNone, &u32); var->set_constructor(create( create(&u32, 2))); @@ -215,7 +215,7 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueUint_Fail) { // case 2, 2: {} // default: {} // } - ast::type::U32Type u32; + ast::type::U32 u32; auto* var = create("a", ast::StorageClass::kNone, &u32); var->set_constructor(create( create(&u32, 3))); @@ -256,7 +256,7 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueSint_Fail) { // case 0,1,2,10: {} // default: {} // } - ast::type::I32Type i32; + ast::type::I32 i32; auto* var = create("a", ast::StorageClass::kNone, &i32); var->set_constructor(create( create(&i32, 2))); @@ -297,7 +297,7 @@ TEST_F(ValidateControlBlockTest, LastClauseLastStatementIsFallthrough_Fail) { // switch (a) { // default: { fallthrough; } // } - ast::type::I32Type i32; + ast::type::I32 i32; auto* var = create("a", ast::StorageClass::kNone, &i32); var->set_constructor(create( create(&i32, 2))); @@ -327,7 +327,7 @@ TEST_F(ValidateControlBlockTest, SwitchCase_Pass) { // default: {} // case 5: {} // } - ast::type::I32Type i32; + ast::type::I32 i32; auto* var = create("a", ast::StorageClass::kNone, &i32); var->set_constructor(create( create(&i32, 2))); @@ -358,8 +358,8 @@ TEST_F(ValidateControlBlockTest, SwitchCaseAlias_Pass) { // default: {} // } - ast::type::U32Type u32; - ast::type::AliasType my_int{"MyInt", &u32}; + ast::type::U32 u32; + ast::type::Alias my_int{"MyInt", &u32}; auto* var = create("a", ast::StorageClass::kNone, &my_int); var->set_constructor(create( diff --git a/src/validator/validator_function_test.cc b/src/validator/validator_function_test.cc index 32f111afca..4bb5d7c9cd 100644 --- a/src/validator/validator_function_test.cc +++ b/src/validator/validator_function_test.cc @@ -38,13 +38,13 @@ class ValidateFunctionTest : public ValidatorTestHelper, TEST_F(ValidateFunctionTest, VoidFunctionEndWithoutReturnStatement_Pass) { // [[stage(vertex)]] // fn func -> void { var a:i32 = 2; } - ast::type::I32Type i32; + ast::type::I32 i32; auto* var = create("a", ast::StorageClass::kNone, &i32); var->set_constructor(create( create(&i32, 2))); ast::VariableList params; - ast::type::VoidType void_type; + ast::type::Void void_type; auto* body = create(); body->append(create(var)); auto* func = create(Source{Source::Location{12, 34}}, "func", @@ -61,7 +61,7 @@ TEST_F(ValidateFunctionTest, VoidFunctionEndWithoutReturnStatementEmptyBody_Pass) { // [[stage(vertex)]] // fn func -> void {} - ast::type::VoidType void_type; + ast::type::Void void_type; ast::VariableList params; auto* func = create(Source{Source::Location{12, 34}}, "func", params, @@ -77,13 +77,13 @@ TEST_F(ValidateFunctionTest, TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatement_Fail) { // fn func -> int { var a:i32 = 2; } - ast::type::I32Type i32; + ast::type::I32 i32; auto* var = create("a", ast::StorageClass::kNone, &i32); var->set_constructor(create( create(&i32, 2))); ast::VariableList params; - ast::type::VoidType void_type; + ast::type::Void void_type; auto* body = create(); body->append(create(var)); auto* func = create(Source{Source::Location{12, 34}}, "func", @@ -98,8 +98,8 @@ TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatement_Fail) { TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatementEmptyBody_Fail) { // fn func -> int {} - ast::type::VoidType void_type; - ast::type::I32Type i32; + ast::type::Void void_type; + ast::type::I32 i32; ast::VariableList params; auto* func = create(Source{Source::Location{12, 34}}, "func", params, @@ -115,7 +115,7 @@ TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatementEmptyBody_Fail) { TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_Pass) { // [[stage(vertex)]] // fn func -> void { return; } - ast::type::VoidType void_type; + ast::type::Void void_type; ast::VariableList params; auto* body = create(); @@ -131,8 +131,8 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_Pass) { TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_fail) { // fn func -> void { return 2; } - ast::type::VoidType void_type; - ast::type::I32Type i32; + ast::type::Void void_type; + ast::type::I32 i32; ast::VariableList params; auto* body = create(); auto* return_expr = create( @@ -153,8 +153,8 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_fail) { TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementTypeF32_fail) { // fn func -> f32 { return 2; } - ast::type::I32Type i32; - ast::type::F32Type f32; + ast::type::I32 i32; + ast::type::F32 f32; ast::VariableList params; auto* body = create(); auto* return_expr = create( @@ -176,8 +176,8 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementTypeF32_fail) { TEST_F(ValidateFunctionTest, FunctionNamesMustBeUnique_fail) { // fn func -> i32 { return 2; } // fn func -> i32 { return 2; } - ast::type::VoidType void_type; - ast::type::I32Type i32; + ast::type::Void void_type; + ast::type::I32 i32; ast::VariableList params; auto* body = create(); @@ -206,8 +206,8 @@ TEST_F(ValidateFunctionTest, FunctionNamesMustBeUnique_fail) { TEST_F(ValidateFunctionTest, RecursionIsNotAllowed_Fail) { // fn func() -> void {func(); return; } - ast::type::F32Type f32; - ast::type::VoidType void_type; + ast::type::F32 f32; + ast::type::Void void_type; ast::ExpressionList call_params; auto* call_expr = create( Source{Source::Location{12, 34}}, @@ -226,7 +226,7 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowed_Fail) { TEST_F(ValidateFunctionTest, RecursionIsNotAllowedExpr_Fail) { // fn func() -> i32 {var a: i32 = func(); return 2; } - ast::type::I32Type i32; + ast::type::I32 i32; auto* var = create("a", ast::StorageClass::kNone, &i32); ast::ExpressionList call_params; auto* call_expr = create( @@ -251,7 +251,7 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowedExpr_Fail) { TEST_F(ValidateFunctionTest, Function_WithPipelineStage_NotVoid_Fail) { // [[stage(vertex)]] // fn vtx_main() -> i32 { return 0; } - ast::type::I32Type i32; + ast::type::I32 i32; ast::VariableList params; auto* return_expr = create( create(&i32, 0)); @@ -273,8 +273,8 @@ TEST_F(ValidateFunctionTest, Function_WithPipelineStage_NotVoid_Fail) { TEST_F(ValidateFunctionTest, Function_WithPipelineStage_WithParams_Fail) { // [[stage(vertex)]] // fn vtx_func(a : i32) -> void { return; } - ast::type::I32Type i32; - ast::type::VoidType void_type; + ast::type::I32 i32; + ast::type::Void void_type; ast::VariableList params; params.push_back(create("a", ast::StorageClass::kNone, &i32)); auto* body = create(); @@ -296,7 +296,7 @@ TEST_F(ValidateFunctionTest, PipelineStage_MustBeUnique_Fail) { // [[stage(fragment)]] // [[stage(vertex)]] // fn main() -> void { return; } - ast::type::VoidType void_type; + ast::type::Void void_type; ast::VariableList params; auto* body = create(); body->append(create()); @@ -317,7 +317,7 @@ TEST_F(ValidateFunctionTest, PipelineStage_MustBeUnique_Fail) { TEST_F(ValidateFunctionTest, OnePipelineStageFunctionMustBePresent_Pass) { // [[stage(vertex)]] // fn vtx_func() -> void { return; } - ast::type::VoidType void_type; + ast::type::Void void_type; ast::VariableList params; auto* body = create(); body->append(create()); @@ -332,7 +332,7 @@ TEST_F(ValidateFunctionTest, OnePipelineStageFunctionMustBePresent_Pass) { TEST_F(ValidateFunctionTest, OnePipelineStageFunctionMustBePresent_Fail) { // fn vtx_func() -> void { return; } - ast::type::VoidType void_type; + ast::type::Void void_type; ast::VariableList params; auto* body = create(); body->append(create()); diff --git a/src/validator/validator_impl.cc b/src/validator/validator_impl.cc index 510bcd3e64..237776b753 100644 --- a/src/validator/validator_impl.cc +++ b/src/validator/validator_impl.cc @@ -85,11 +85,11 @@ bool ValidatorImpl::Validate(const ast::Module* module) { bool ValidatorImpl::ValidateConstructedTypes( const std::vector& constructed_types) { for (auto* const ct : constructed_types) { - if (ct->Is()) { - auto* st = ct->As(); + if (ct->Is()) { + auto* st = ct->As(); for (auto* member : st->impl()->members()) { - if (member->type()->UnwrapAll()->Is()) { - auto* r = member->type()->UnwrapAll()->As(); + if (member->type()->UnwrapAll()->Is()) { + auto* r = member->type()->UnwrapAll()->As(); if (r->IsRuntimeArray()) { if (member != st->impl()->members().back()) { add_error(member->source(), "v-0015", @@ -168,7 +168,7 @@ bool ValidatorImpl::ValidateEntryPoint(const ast::FunctionList& funcs) { return false; } - if (!func->return_type()->Is()) { + if (!func->return_type()->Is()) { add_error( func->source(), "v-0024", "Entry point function must return void: '" + func->name() + "'"); @@ -207,7 +207,7 @@ bool ValidatorImpl::ValidateFunction(const ast::Function* func) { } variable_stack_.pop_scope(); - if (!current_function_->return_type()->Is()) { + if (!current_function_->return_type()->Is()) { if (!func->get_last_statement() || !func->get_last_statement()->Is()) { add_error(func->source(), "v-0002", @@ -223,7 +223,7 @@ bool ValidatorImpl::ValidateReturnStatement(const ast::ReturnStatement* ret) { // https://github.com/gpuweb/gpuweb/issues/996 ast::type::Type* func_type = current_function_->return_type(); - ast::type::VoidType void_type; + ast::type::Void void_type; auto* ret_type = ret->has_value() ? ret->value()->result_type()->UnwrapAll() : &void_type; @@ -265,11 +265,11 @@ bool ValidatorImpl::ValidateDeclStatement( return false; } variable_stack_.set(name, decl->variable()); - if (decl->variable()->type()->UnwrapAll()->Is()) { + if (decl->variable()->type()->UnwrapAll()->Is()) { if (decl->variable() ->type() ->UnwrapAll() - ->As() + ->As() ->IsRuntimeArray()) { add_error(decl->source(), "v-0015", "runtime arrays may only appear as the last " @@ -317,8 +317,7 @@ bool ValidatorImpl::ValidateSwitch(const ast::SwitchStatement* s) { } auto* cond_type = s->condition()->result_type()->UnwrapAll(); - if (!(cond_type->Is() || - cond_type->Is())) { + if (!(cond_type->Is() || cond_type->Is())) { add_error(s->condition()->source(), "v-0025", "switch statement selector expression must be of a " "scalar integer type"); @@ -345,11 +344,11 @@ bool ValidatorImpl::ValidateSwitch(const ast::SwitchStatement* s) { } auto v = - static_cast(selector->type()->Is() + static_cast(selector->type()->Is() ? selector->As()->value() : selector->As()->value()); if (selector_set.count(v)) { - auto v_str = selector->type()->Is() + auto v_str = selector->type()->Is() ? selector->As()->to_str() : selector->As()->to_str(); add_error(case_stmt->source(), "v-0027", diff --git a/src/validator/validator_test.cc b/src/validator/validator_test.cc index 9f0f726292..e15a5e0dfc 100644 --- a/src/validator/validator_test.cc +++ b/src/validator/validator_test.cc @@ -62,7 +62,7 @@ class ValidatorTest : public ValidatorTestHelper, public testing::Test {}; TEST_F(ValidatorTest, DISABLED_AssignToScalar_Fail) { // 1 = my_var; - ast::type::I32Type i32; + ast::type::I32 i32; auto* lhs = create( create(&i32, 1)); @@ -77,7 +77,7 @@ TEST_F(ValidatorTest, DISABLED_AssignToScalar_Fail) { TEST_F(ValidatorTest, UsingUndefinedVariable_Fail) { // b = 2; - ast::type::I32Type i32; + ast::type::I32 i32; auto* lhs = create(Source{Source::Location{12, 34}}, "b"); @@ -95,7 +95,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableInBlockStatement_Fail) { // { // b = 2; // } - ast::type::I32Type i32; + ast::type::I32 i32; auto* lhs = create(Source{Source::Location{12, 34}}, "b"); @@ -114,7 +114,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableInBlockStatement_Fail) { TEST_F(ValidatorTest, AssignCompatibleTypes_Pass) { // var a :i32 = 2; // a = 2 - ast::type::I32Type i32; + ast::type::I32 i32; auto* var = create("a", ast::StorageClass::kNone, &i32); var->set_constructor(create( create(&i32, 2))); @@ -136,8 +136,8 @@ TEST_F(ValidatorTest, AssignIncompatibleTypes_Fail) { // var a :i32 = 2; // a = 2.3; // } - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::F32 f32; + ast::type::I32 i32; auto* var = create("a", ast::StorageClass::kNone, &i32); var->set_constructor(create( @@ -164,7 +164,7 @@ TEST_F(ValidatorTest, AssignCompatibleTypesInBlockStatement_Pass) { // var a :i32 = 2; // a = 2 // } - ast::type::I32Type i32; + ast::type::I32 i32; auto* var = create("a", ast::StorageClass::kNone, &i32); var->set_constructor(create( create(&i32, 2))); @@ -190,8 +190,8 @@ TEST_F(ValidatorTest, AssignIncompatibleTypesInBlockStatement_Fail) { // var a :i32 = 2; // a = 2.3; // } - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::F32 f32; + ast::type::I32 i32; auto* var = create("a", ast::StorageClass::kNone, &i32); var->set_constructor(create( @@ -218,7 +218,7 @@ TEST_F(ValidatorTest, AssignIncompatibleTypesInBlockStatement_Fail) { TEST_F(ValidatorTest, GlobalVariableWithStorageClass_Pass) { // var gloabl_var: f32; - ast::type::F32Type f32; + ast::type::F32 f32; auto* global_var = create(Source{Source::Location{12, 34}}, "global_var", ast::StorageClass::kInput, &f32); @@ -229,7 +229,7 @@ TEST_F(ValidatorTest, GlobalVariableWithStorageClass_Pass) { TEST_F(ValidatorTest, GlobalVariableNoStorageClass_Fail) { // var gloabl_var: f32; - ast::type::F32Type f32; + ast::type::F32 f32; auto* global_var = create(Source{Source::Location{12, 34}}, "global_var", ast::StorageClass::kNone, &f32); @@ -241,7 +241,7 @@ TEST_F(ValidatorTest, GlobalVariableNoStorageClass_Fail) { } TEST_F(ValidatorTest, GlobalConstantWithStorageClass_Fail) { // const gloabl_var: f32; - ast::type::F32Type f32; + ast::type::F32 f32; auto* global_var = create(Source{Source::Location{12, 34}}, "global_var", ast::StorageClass::kInput, &f32); @@ -257,7 +257,7 @@ TEST_F(ValidatorTest, GlobalConstantWithStorageClass_Fail) { TEST_F(ValidatorTest, GlobalConstNoStorageClass_Pass) { // const gloabl_var: f32; - ast::type::F32Type f32; + ast::type::F32 f32; auto* global_var = create(Source{Source::Location{12, 34}}, "global_var", ast::StorageClass::kNone, &f32); @@ -273,7 +273,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Fail) { // fn my_func() -> f32 { // not_global_var = 3.14f; // } - ast::type::F32Type f32; + ast::type::F32 f32; auto* global_var = create("global_var", ast::StorageClass::kPrivate, &f32); global_var->set_constructor(create( @@ -303,8 +303,8 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Pass) { // global_var = 3.14; // return; // } - ast::type::F32Type f32; - ast::type::VoidType void_type; + ast::type::F32 f32; + ast::type::Void void_type; auto* global_var = create("global_var", ast::StorageClass::kPrivate, &f32); @@ -336,12 +336,12 @@ TEST_F(ValidatorTest, UsingUndefinedVariableInnerScope_Fail) { // if (true) { var a : f32 = 2.0; } // a = 3.14; // } - ast::type::F32Type f32; + ast::type::F32 f32; auto* var = create("a", ast::StorageClass::kNone, &f32); var->set_constructor(create( create(&f32, 2.0))); - ast::type::BoolType bool_type; + ast::type::Bool bool_type; auto* cond = create( create(&bool_type, true)); auto* body = create(); @@ -369,7 +369,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableOuterScope_Pass) { // var a : f32 = 2.0; // if (true) { a = 3.14; } // } - ast::type::F32Type f32; + ast::type::F32 f32; auto* var = create("a", ast::StorageClass::kNone, &f32); var->set_constructor(create( create(&f32, 2.0))); @@ -379,7 +379,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableOuterScope_Pass) { auto* rhs = create( create(&f32, 3.14f)); - ast::type::BoolType bool_type; + ast::type::Bool bool_type; auto* cond = create( create(&bool_type, true)); auto* body = create(); @@ -398,8 +398,8 @@ TEST_F(ValidatorTest, UsingUndefinedVariableOuterScope_Pass) { TEST_F(ValidatorTest, GlobalVariableUnique_Pass) { // var global_var0 : f32 = 0.1; // var global_var1 : i32 = 0; - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::F32 f32; + ast::type::I32 i32; auto* var0 = create("global_var0", ast::StorageClass::kPrivate, &f32); var0->set_constructor(create( @@ -420,8 +420,8 @@ TEST_F(ValidatorTest, GlobalVariableUnique_Pass) { TEST_F(ValidatorTest, GlobalVariableNotUnique_Fail) { // var global_var : f32 = 0.1; // var global_var : i32 = 0; - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::F32 f32; + ast::type::I32 i32; auto* var0 = create("global_var", ast::StorageClass::kPrivate, &f32); var0->set_constructor(create( @@ -445,7 +445,7 @@ TEST_F(ValidatorTest, AssignToConstant_Fail) { // const a :i32 = 2; // a = 2 // } - ast::type::I32Type i32; + ast::type::I32 i32; auto* var = create("a", ast::StorageClass::kNone, &i32); var->set_constructor(create( create(&i32, 2))); @@ -475,8 +475,8 @@ TEST_F(ValidatorTest, GlobalVariableFunctionVariableNotUnique_Fail) { // return 0; // } - ast::type::VoidType void_type; - ast::type::F32Type f32; + ast::type::Void void_type; + ast::type::F32 f32; auto* global_var = create("a", ast::StorageClass::kPrivate, &f32); global_var->set_constructor(create( @@ -505,9 +505,9 @@ TEST_F(ValidatorTest, RedeclaredIndentifier_Fail) { // var a :i32 = 2; // var a :f21 = 2.0; // } - ast::type::VoidType void_type; - ast::type::I32Type i32; - ast::type::F32Type f32; + ast::type::Void void_type; + ast::type::I32 i32; + ast::type::F32 f32; auto* var = create("a", ast::StorageClass::kNone, &i32); var->set_constructor(create( create(&i32, 2))); @@ -537,12 +537,12 @@ TEST_F(ValidatorTest, RedeclaredIdentifierInnerScope_Pass) { // if (true) { var a : f32 = 2.0; } // var a : f32 = 3.14; // } - ast::type::F32Type f32; + ast::type::F32 f32; auto* var = create("a", ast::StorageClass::kNone, &f32); var->set_constructor(create( create(&f32, 2.0))); - ast::type::BoolType bool_type; + ast::type::Bool bool_type; auto* cond = create( create(&bool_type, true)); auto* body = create(); @@ -569,7 +569,7 @@ TEST_F(ValidatorTest, DISABLED_RedeclaredIdentifierInnerScope_False) { // var a : f32 = 3.14; // if (true) { var a : f32 = 2.0; } // } - ast::type::F32Type f32; + ast::type::F32 f32; auto* var_a_float = create("a", ast::StorageClass::kNone, &f32); var_a_float->set_constructor(create( @@ -579,7 +579,7 @@ TEST_F(ValidatorTest, DISABLED_RedeclaredIdentifierInnerScope_False) { var->set_constructor(create( create(&f32, 2.0))); - ast::type::BoolType bool_type; + ast::type::Bool bool_type; auto* cond = create( create(&bool_type, true)); auto* body = create(); @@ -598,8 +598,8 @@ TEST_F(ValidatorTest, DISABLED_RedeclaredIdentifierInnerScope_False) { TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) { // func0 { var a : f32 = 2.0; return; } // func1 { var a : f32 = 3.0; return; } - ast::type::F32Type f32; - ast::type::VoidType void_type; + ast::type::F32 f32; + ast::type::Void void_type; auto* var0 = create("a", ast::StorageClass::kNone, &f32); var0->set_constructor(create( create(&f32, 2.0))); @@ -636,7 +636,7 @@ TEST_F(ValidatorTest, VariableDeclNoConstructor_Pass) { // var a :i32; // a = 2; // } - ast::type::I32Type i32; + ast::type::I32 i32; auto* var = create("a", ast::StorageClass::kNone, &i32); td()->RegisterVariableForTesting(var); diff --git a/src/validator/validator_test_helper.h b/src/validator/validator_test_helper.h index b4db450298..f448d2fc80 100644 --- a/src/validator/validator_test_helper.h +++ b/src/validator/validator_test_helper.h @@ -55,7 +55,7 @@ class ValidatorTestHelper { Context ctx_; ast::Module mod_; std::unique_ptr td_; - ast::type::VoidType void_type_; + ast::type::Void void_type_; }; } // namespace tint diff --git a/src/validator/validator_type_test.cc b/src/validator/validator_type_test.cc index 738776da27..f9d6c7111a 100644 --- a/src/validator/validator_type_test.cc +++ b/src/validator/validator_type_test.cc @@ -42,8 +42,8 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsLast_Pass) { // rt: array; // }; - ast::type::F32Type f32; - ast::type::ArrayType arr(&f32); + ast::type::F32 f32; + ast::type::Array arr(&f32); ast::StructMemberList members; { ast::StructMemberDecorationList deco; @@ -57,7 +57,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsLast_Pass) { ast::StructDecorationList decos; decos.push_back(create(Source{})); auto* st = create(decos, members); - ast::type::StructType struct_type("Foo", st); + ast::type::Struct struct_type("Foo", st); mod()->AddConstructedType(&struct_type); EXPECT_TRUE(v()->ValidateConstructedTypes(mod()->constructed_types())); @@ -69,8 +69,8 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsLastNoBlock_Fail) { // rt: array; // }; - ast::type::F32Type f32; - ast::type::ArrayType arr(&f32); + ast::type::F32 f32; + ast::type::Array arr(&f32); ast::StructMemberList members; { ast::StructMemberDecorationList deco; @@ -83,7 +83,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsLastNoBlock_Fail) { } ast::StructDecorationList decos; auto* st = create(decos, members); - ast::type::StructType struct_type("Foo", st); + ast::type::Struct struct_type("Foo", st); mod()->AddConstructedType(&struct_type); EXPECT_FALSE(v()->ValidateConstructedTypes(mod()->constructed_types())); @@ -99,8 +99,8 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsNotLast_Fail) { // vf: f32; // }; - ast::type::F32Type f32; - ast::type::ArrayType arr(&f32); + ast::type::F32 f32; + ast::type::Array arr(&f32); ast::StructMemberList members; { ast::StructMemberDecorationList deco; @@ -114,7 +114,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsNotLast_Fail) { ast::StructDecorationList decos; decos.push_back(create(Source{})); auto* st = create(decos, members); - ast::type::StructType struct_type("Foo", st); + ast::type::Struct struct_type("Foo", st); mod()->AddConstructedType(&struct_type); EXPECT_FALSE(v()->ValidateConstructedTypes(mod()->constructed_types())); @@ -131,9 +131,9 @@ TEST_F(ValidatorTypeTest, AliasRuntimeArrayIsNotLast_Fail) { // a: u32; //} - ast::type::F32Type u32; - ast::type::ArrayType array(&u32); - ast::type::AliasType alias{"RTArr", &array}; + ast::type::F32 u32; + ast::type::Array array(&u32); + ast::type::Alias alias{"RTArr", &array}; ast::StructMemberList members; { @@ -149,7 +149,7 @@ TEST_F(ValidatorTypeTest, AliasRuntimeArrayIsNotLast_Fail) { ast::StructDecorationList decos; decos.push_back(create(Source{})); auto* st = create(decos, members); - ast::type::StructType struct_type("s", st); + ast::type::Struct struct_type("s", st); mod()->AddConstructedType(&struct_type); EXPECT_FALSE(v()->ValidateConstructedTypes(mod()->constructed_types())); EXPECT_EQ(v()->error(), @@ -165,9 +165,9 @@ TEST_F(ValidatorTypeTest, AliasRuntimeArrayIsLast_Pass) { // b: RTArr; //} - ast::type::F32Type u32; - ast::type::ArrayType array(&u32); - ast::type::AliasType alias{"RTArr", &array}; + ast::type::F32 u32; + ast::type::Array array(&u32); + ast::type::Alias alias{"RTArr", &array}; ast::StructMemberList members; { @@ -182,7 +182,7 @@ TEST_F(ValidatorTypeTest, AliasRuntimeArrayIsLast_Pass) { ast::StructDecorationList decos; decos.push_back(create(Source{})); auto* st = create(decos, members); - ast::type::StructType struct_type("s", st); + ast::type::Struct struct_type("s", st); mod()->AddConstructedType(&struct_type); EXPECT_TRUE(v()->ValidateConstructedTypes(mod()->constructed_types())); } @@ -190,12 +190,12 @@ TEST_F(ValidatorTypeTest, AliasRuntimeArrayIsLast_Pass) { TEST_F(ValidatorTypeTest, RuntimeArrayInFunction_Fail) { /// [[stage(vertex)]] // fn func -> void { var a : array; } - ast::type::I32Type i32; - ast::type::ArrayType array(&i32); + ast::type::I32 i32; + ast::type::Array array(&i32); auto* var = create("a", ast::StorageClass::kNone, &array); ast::VariableList params; - ast::type::VoidType void_type; + ast::type::Void void_type; auto* body = create(); body->append(create( Source{Source::Location{12, 34}}, var)); diff --git a/src/writer/hlsl/generator_impl.cc b/src/writer/hlsl/generator_impl.cc index 3bbd20baae..2979bb9113 100644 --- a/src/writer/hlsl/generator_impl.cc +++ b/src/writer/hlsl/generator_impl.cc @@ -219,12 +219,12 @@ bool GeneratorImpl::EmitConstructedType(std::ostream& out, const ast::type::Type* ty) { make_indent(out); - if (ty->Is()) { - auto* alias = ty->As(); + if (ty->Is()) { + auto* alias = ty->As(); // HLSL typedef is for intrinsic types only. For an alias'd struct, // generate a secondary struct with the new name. - if (alias->type()->Is()) { - if (!EmitStructType(out, alias->type()->As(), + if (alias->type()->Is()) { + if (!EmitStructType(out, alias->type()->As(), alias->name())) { return false; } @@ -235,8 +235,8 @@ bool GeneratorImpl::EmitConstructedType(std::ostream& out, return false; } out << " " << namer_.NameFor(alias->name()) << ";" << std::endl; - } else if (ty->Is()) { - auto* str = ty->As(); + } else if (ty->Is()) { + auto* str = ty->As(); if (!EmitStructType(out, str, str->name())) { return false; } @@ -272,9 +272,9 @@ bool GeneratorImpl::EmitArrayAccessor(std::ostream& pre, bool GeneratorImpl::EmitBitcast(std::ostream& pre, std::ostream& out, ast::BitcastExpression* expr) { - if (!expr->type()->Is() && - !expr->type()->Is() && - !expr->type()->Is()) { + if (!expr->type()->Is() && + !expr->type()->Is() && + !expr->type()->Is()) { error_ = "Unable to do bitcast to type " + expr->type()->type_name(); return false; } @@ -379,12 +379,12 @@ bool GeneratorImpl::EmitBinary(std::ostream& pre, // Multiplying by a matrix requires the use of `mul` in order to get the // type of multiply we desire. if (expr->op() == ast::BinaryOp::kMultiply && - ((lhs_type->Is() && - rhs_type->Is()) || - (lhs_type->Is() && - rhs_type->Is()) || - (lhs_type->Is() && - rhs_type->Is()))) { + ((lhs_type->Is() && + rhs_type->Is()) || + (lhs_type->Is() && + rhs_type->Is()) || + (lhs_type->Is() && + rhs_type->Is()))) { out << "mul("; if (!EmitExpression(pre, out, expr->lhs())) { return false; @@ -618,14 +618,14 @@ bool GeneratorImpl::EmitCall(std::ostream& pre, // out << "("; // auto param1_type = params[1]->result_type()->UnwrapPtrIfNeeded(); - // if (!param1_type->Is()) { + // if (!param1_type->Is()) { // error_ = "invalid param type in outer_product got: " + // param1_type->type_name(); // return false; // } // for (uint32_t i = 0; i < - // param1_type->As()->size(); ++i) { + // param1_type->As()->size(); ++i) { // if (i > 0) { // out << ", "; // } @@ -921,7 +921,7 @@ bool GeneratorImpl::EmitScalarConstructor( bool GeneratorImpl::EmitTypeConstructor(std::ostream& pre, std::ostream& out, ast::TypeConstructorExpression* expr) { - if (expr->type()->Is()) { + if (expr->type()->Is()) { out << "{"; } else { if (!EmitType(out, expr->type(), "")) { @@ -950,7 +950,7 @@ bool GeneratorImpl::EmitTypeConstructor(std::ostream& pre, } } - if (expr->type()->Is()) { + if (expr->type()->Is()) { out << "}"; } else { out << ")"; @@ -1231,7 +1231,7 @@ bool GeneratorImpl::EmitFunctionInternal(std::ostream& out, return false; } // Array name is output as part of the type - if (!v->type()->Is()) { + if (!v->type()->Is()) { out << " " << v->name(); } } @@ -1298,8 +1298,8 @@ bool GeneratorImpl::EmitEntryPointData( emitted_globals.insert(var->name()); auto* type = var->type()->UnwrapIfNeeded(); - if (type->Is()) { - auto* strct = type->As(); + if (type->Is()) { + auto* strct = type->As(); out << "ConstantBuffer<" << strct->name() << "> " << var->name() << " : register(b" << binding->value() << ");" << std::endl; @@ -1340,11 +1340,11 @@ bool GeneratorImpl::EmitEntryPointData( } emitted_globals.insert(var->name()); - if (!var->type()->Is()) { + if (!var->type()->Is()) { error_ = "access control type required for storage buffer"; return false; } - auto* ac = var->type()->As(); + auto* ac = var->type()->As(); if (ac->IsReadWrite()) { out << "RW"; @@ -1554,18 +1554,18 @@ bool GeneratorImpl::EmitLiteral(std::ostream& out, ast::Literal* lit) { } bool GeneratorImpl::EmitZeroValue(std::ostream& out, ast::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"; - } else if (type->Is()) { + } else if (type->Is()) { out << "0u"; - } else if (type->Is()) { - return EmitZeroValue(out, type->As()->type()); - } else if (type->Is()) { - auto* mat = type->As(); + } else if (type->Is()) { + return EmitZeroValue(out, type->As()->type()); + } else if (type->Is()) { + auto* mat = type->As(); for (uint32_t i = 0; i < (mat->rows() * mat->columns()); i++) { if (i != 0) { out << ", "; @@ -1692,8 +1692,8 @@ std::string GeneratorImpl::generate_storage_buffer_index_expression( first = false; if (auto* mem = expr->As()) { auto* res_type = mem->structure()->result_type()->UnwrapAll(); - if (res_type->Is()) { - auto* str_type = res_type->As()->impl(); + if (res_type->Is()) { + auto* str_type = res_type->As()->impl(); auto* str_member = str_type->get_member(mem->member()->name()); if (!str_member->has_offset_decoration()) { @@ -1702,7 +1702,7 @@ std::string GeneratorImpl::generate_storage_buffer_index_expression( } out << str_member->offset(); - } else if (res_type->Is()) { + } else if (res_type->Is()) { // This must be a single element swizzle if we've got a vector at this // point. if (mem->member()->name().size() != 1) { @@ -1728,15 +1728,15 @@ std::string GeneratorImpl::generate_storage_buffer_index_expression( auto* ary_type = ary->array()->result_type()->UnwrapAll(); out << "("; - if (ary_type->Is()) { - out << ary_type->As()->array_stride(); - } else if (ary_type->Is()) { + if (ary_type->Is()) { + out << ary_type->As()->array_stride(); + } else if (ary_type->Is()) { // TODO(dsinclair): This is a hack. Our vectors can only be f32, i32 // or u32 which are all 4 bytes. When we get f16 or other types we'll // have to ask the type for the byte size. out << "4"; - } else if (ary_type->Is()) { - auto* mat = ary_type->As(); + } else if (ary_type->Is()) { + auto* mat = ary_type->As(); if (mat->columns() == 2) { out << "8"; } else { @@ -1777,18 +1777,18 @@ bool GeneratorImpl::EmitStorageBufferAccessor(std::ostream& pre, bool is_store = rhs != nullptr; std::string access_method = is_store ? "Store" : "Load"; - if (result_type->Is()) { + if (result_type->Is()) { access_method += - std::to_string(result_type->As()->size()); - } else if (result_type->Is()) { + std::to_string(result_type->As()->size()); + } else if (result_type->Is()) { access_method += - std::to_string(result_type->As()->rows()); + std::to_string(result_type->As()->rows()); } // If we aren't storing then we need to put in the outer cast. if (!is_store) { if (result_type->is_float_scalar_or_vector() || - result_type->Is()) { + result_type->Is()) { out << "asfloat("; } else if (result_type->is_signed_scalar_or_vector()) { out << "asint("; @@ -1808,8 +1808,8 @@ bool GeneratorImpl::EmitStorageBufferAccessor(std::ostream& pre, return false; } - if (result_type->Is()) { - auto* mat = result_type->As(); + if (result_type->Is()) { + auto* mat = result_type->As(); // TODO(dsinclair): This is assuming 4 byte elements. Will need to be fixed // if we get matrixes of f16 or f64. @@ -1896,8 +1896,7 @@ bool GeneratorImpl::is_storage_buffer_access( auto* data_type = structure->result_type()->UnwrapAll(); // If the data is a multi-element swizzle then we will not load the swizzle // portion through the Load command. - if (data_type->Is() && - expr->member()->name().size() > 1) { + if (data_type->Is() && expr->member()->name().size() > 1) { return false; } @@ -2042,24 +2041,24 @@ bool GeneratorImpl::EmitSwitch(std::ostream& out, ast::SwitchStatement* stmt) { bool GeneratorImpl::EmitType(std::ostream& out, ast::type::Type* type, const std::string& name) { - if (type->Is()) { - auto* alias = type->As(); + if (type->Is()) { + auto* alias = type->As(); out << namer_.NameFor(alias->name()); - } else if (type->Is()) { - auto* ary = type->As(); + } else if (type->Is()) { + auto* ary = type->As(); ast::type::Type* base_type = ary; std::vector sizes; - while (base_type->Is()) { - if (base_type->As()->IsRuntimeArray()) { + while (base_type->Is()) { + if (base_type->As()->IsRuntimeArray()) { // TODO(dsinclair): Support runtime arrays // https://bugs.chromium.org/p/tint/issues/detail?id=185 error_ = "runtime array not supported yet."; return false; } else { - sizes.push_back(base_type->As()->size()); + sizes.push_back(base_type->As()->size()); } - base_type = base_type->As()->type(); + base_type = base_type->As()->type(); } if (!EmitType(out, base_type, "")) { return false; @@ -2070,35 +2069,35 @@ bool GeneratorImpl::EmitType(std::ostream& out, for (uint32_t size : sizes) { out << "[" << size << "]"; } - } 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 << "int"; - } else if (type->Is()) { - auto* mat = type->As(); + } else if (type->Is()) { + auto* mat = type->As(); if (!EmitType(out, mat->type(), "")) { return false; } out << mat->rows() << "x" << mat->columns(); - } else if (type->Is()) { + } else if (type->Is()) { // TODO(dsinclair): What do we do with pointers in HLSL? // https://bugs.chromium.org/p/tint/issues/detail?id=183 error_ = "pointers not supported in HLSL"; return false; - } else if (type->Is()) { - auto* sampler = type->As(); + } else if (type->Is()) { + auto* sampler = type->As(); out << "Sampler"; if (sampler->IsComparison()) { out << "Comparison"; } out << "State"; - } else if (type->Is()) { - out << type->As()->name(); - } else if (type->Is()) { - auto* tex = type->As(); - if (tex->Is()) { + } else if (type->Is()) { + out << type->As()->name(); + } else if (type->Is()) { + auto* tex = type->As(); + if (tex->Is()) { out << "RW"; } out << "Texture"; @@ -2130,18 +2129,16 @@ bool GeneratorImpl::EmitType(std::ostream& out, return false; } - } else if (type->Is()) { + } else if (type->Is()) { out << "uint"; - } else if (type->Is()) { - auto* vec = type->As(); + } else if (type->Is()) { + auto* vec = type->As(); auto size = vec->size(); - if (vec->type()->Is() && size >= 1 && size <= 4) { + if (vec->type()->Is() && size >= 1 && size <= 4) { out << "float" << size; - } else if (vec->type()->Is() && size >= 1 && - size <= 4) { + } else if (vec->type()->Is() && size >= 1 && size <= 4) { out << "int" << size; - } else if (vec->type()->Is() && size >= 1 && - size <= 4) { + } else if (vec->type()->Is() && size >= 1 && size <= 4) { out << "uint" << size; } else { out << "vector<"; @@ -2150,7 +2147,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, } out << ", " << size << ">"; } - } else if (type->Is()) { + } else if (type->Is()) { out << "void"; } else { error_ = "unknown type in EmitType"; @@ -2161,7 +2158,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, } bool GeneratorImpl::EmitStructType(std::ostream& out, - const ast::type::StructType* str, + const ast::type::Struct* str, const std::string& name) { // TODO(dsinclair): Block decoration? // if (str->impl()->decoration() != ast::StructDecoration::kNone) { @@ -2178,7 +2175,7 @@ bool GeneratorImpl::EmitStructType(std::ostream& out, return false; } // Array member name will be output with the type - if (!mem->type()->Is()) { + if (!mem->type()->Is()) { out << " " << namer_.NameFor(mem->name()); } out << ";" << std::endl; @@ -2241,7 +2238,7 @@ bool GeneratorImpl::EmitVariable(std::ostream& out, if (!EmitType(out, var->type(), var->name())) { return false; } - if (!var->type()->Is()) { + if (!var->type()->Is()) { out << " " << var->name(); } out << constructor_out.str() << ";" << std::endl; @@ -2298,7 +2295,7 @@ bool GeneratorImpl::EmitProgramConstVariable(std::ostream& out, if (!EmitType(out, var->type(), var->name())) { return false; } - if (!var->type()->Is()) { + if (!var->type()->Is()) { out << " " << var->name(); } diff --git a/src/writer/hlsl/generator_impl.h b/src/writer/hlsl/generator_impl.h index cbfc7cd850..44b4dd4610 100644 --- a/src/writer/hlsl/generator_impl.h +++ b/src/writer/hlsl/generator_impl.h @@ -301,7 +301,7 @@ class GeneratorImpl { /// @param name the struct name /// @returns true if the struct is emitted bool EmitStructType(std::ostream& out, - const ast::type::StructType* ty, + const ast::type::Struct* ty, const std::string& name); /// Handles a unary op expression /// @param pre the preamble for the expression stream diff --git a/src/writer/hlsl/generator_impl_alias_type_test.cc b/src/writer/hlsl/generator_impl_alias_type_test.cc index 4dbe93a425..1aa406a52e 100644 --- a/src/writer/hlsl/generator_impl_alias_type_test.cc +++ b/src/writer/hlsl/generator_impl_alias_type_test.cc @@ -26,29 +26,29 @@ namespace writer { namespace hlsl { namespace { -using HlslGeneratorImplTest_AliasType = TestHelper; +using HlslGeneratorImplTest_Alias = TestHelper; -TEST_F(HlslGeneratorImplTest_AliasType, EmitAliasType_F32) { - ast::type::F32Type f32; - ast::type::AliasType alias("a", &f32); +TEST_F(HlslGeneratorImplTest_Alias, EmitAlias_F32) { + ast::type::F32 f32; + ast::type::Alias alias("a", &f32); ASSERT_TRUE(gen.EmitConstructedType(out, &alias)) << gen.error(); EXPECT_EQ(result(), R"(typedef float a; )"); } -TEST_F(HlslGeneratorImplTest_AliasType, EmitAliasType_NameCollision) { - ast::type::F32Type f32; - ast::type::AliasType alias("float", &f32); +TEST_F(HlslGeneratorImplTest_Alias, EmitAlias_NameCollision) { + ast::type::F32 f32; + ast::type::Alias alias("float", &f32); ASSERT_TRUE(gen.EmitConstructedType(out, &alias)) << gen.error(); EXPECT_EQ(result(), R"(typedef float float_tint_0; )"); } -TEST_F(HlslGeneratorImplTest_AliasType, EmitAliasType_Struct) { - ast::type::I32Type i32; - ast::type::F32Type f32; +TEST_F(HlslGeneratorImplTest_Alias, EmitAlias_Struct) { + ast::type::I32 i32; + ast::type::F32 f32; auto* str = create(); str->set_members({ @@ -59,8 +59,8 @@ TEST_F(HlslGeneratorImplTest_AliasType, EmitAliasType_Struct) { create(4, Source{})}), }); - ast::type::StructType s("A", str); - ast::type::AliasType alias("B", &s); + ast::type::Struct s("A", str); + ast::type::Alias alias("B", &s); ASSERT_TRUE(gen.EmitConstructedType(out, &alias)) << gen.error(); EXPECT_EQ(result(), R"(struct B { diff --git a/src/writer/hlsl/generator_impl_array_accessor_test.cc b/src/writer/hlsl/generator_impl_array_accessor_test.cc index b803f8b846..53cee1abf2 100644 --- a/src/writer/hlsl/generator_impl_array_accessor_test.cc +++ b/src/writer/hlsl/generator_impl_array_accessor_test.cc @@ -30,7 +30,7 @@ namespace { using HlslGeneratorImplTest_Expression = TestHelper; TEST_F(HlslGeneratorImplTest_Expression, EmitExpression_ArrayAccessor) { - ast::type::I32Type i32; + ast::type::I32 i32; auto* lit = create(&i32, 5); auto* idx = create(lit); auto* ary = create("ary"); diff --git a/src/writer/hlsl/generator_impl_binary_test.cc b/src/writer/hlsl/generator_impl_binary_test.cc index 3f8d547d8f..18c46f3b5e 100644 --- a/src/writer/hlsl/generator_impl_binary_test.cc +++ b/src/writer/hlsl/generator_impl_binary_test.cc @@ -58,7 +58,7 @@ inline std::ostream& operator<<(std::ostream& out, BinaryData data) { using HlslBinaryTest = TestParamHelper; TEST_P(HlslBinaryTest, Emit_f32) { - ast::type::F32Type f32; + ast::type::F32 f32; auto params = GetParam(); @@ -80,7 +80,7 @@ TEST_P(HlslBinaryTest, Emit_f32) { EXPECT_EQ(result(), params.result); } TEST_P(HlslBinaryTest, Emit_u32) { - ast::type::U32Type u32; + ast::type::U32 u32; auto params = GetParam(); @@ -102,7 +102,7 @@ TEST_P(HlslBinaryTest, Emit_u32) { EXPECT_EQ(result(), params.result); } TEST_P(HlslBinaryTest, Emit_i32) { - ast::type::I32Type i32; + ast::type::I32 i32; auto params = GetParam(); @@ -145,8 +145,8 @@ INSTANTIATE_TEST_SUITE_P( BinaryData{"(left % right)", ast::BinaryOp::kModulo})); TEST_F(HlslGeneratorImplTest_Binary, Multiply_VectorScalar) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); auto* lhs = create( &vec3, ast::ExpressionList{ @@ -171,8 +171,8 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_VectorScalar) { } TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarVector) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); auto* lhs = create( create(&f32, 1.f)); @@ -196,8 +196,8 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarVector) { } TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixScalar) { - ast::type::F32Type f32; - ast::type::MatrixType mat3(&f32, 3, 3); + ast::type::F32 f32; + ast::type::Matrix mat3(&f32, 3, 3); auto* var = create("mat", ast::StorageClass::kFunction, &mat3); auto* lhs = create("mat"); @@ -214,8 +214,8 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixScalar) { } TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarMatrix) { - ast::type::F32Type f32; - ast::type::MatrixType mat3(&f32, 3, 3); + ast::type::F32 f32; + ast::type::Matrix mat3(&f32, 3, 3); auto* var = create("mat", ast::StorageClass::kFunction, &mat3); auto* lhs = create( @@ -232,9 +232,9 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarMatrix) { } TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixVector) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); - ast::type::MatrixType mat3(&f32, 3, 3); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); + ast::type::Matrix mat3(&f32, 3, 3); auto* var = create("mat", ast::StorageClass::kFunction, &mat3); auto* lhs = create("mat"); @@ -258,9 +258,9 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixVector) { } TEST_F(HlslGeneratorImplTest_Binary, Multiply_VectorMatrix) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); - ast::type::MatrixType mat3(&f32, 3, 3); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); + ast::type::Matrix mat3(&f32, 3, 3); auto* var = create("mat", ast::StorageClass::kFunction, &mat3); @@ -285,9 +285,9 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_VectorMatrix) { } TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixMatrix) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); - ast::type::MatrixType mat3(&f32, 3, 3); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); + ast::type::Matrix mat3(&f32, 3, 3); auto* var = create("mat", ast::StorageClass::kFunction, &mat3); auto* lhs = create("mat"); @@ -370,7 +370,7 @@ TEST_F(HlslGeneratorImplTest_Binary, If_WithLogical) { // return 3; // } - ast::type::I32Type i32; + ast::type::I32 i32; auto* body = create(); body->append( @@ -476,7 +476,7 @@ a = (_tint_tmp_0); TEST_F(HlslGeneratorImplTest_Binary, Decl_WithLogical) { // var a : bool = (b && c) || d; - ast::type::BoolType bool_type; + ast::type::Bool bool_type; auto* b = create("b"); auto* c = create("c"); @@ -505,7 +505,7 @@ bool a = (_tint_tmp_0); TEST_F(HlslGeneratorImplTest_Binary, Bitcast_WithLogical) { // as(a && (b || c)) - ast::type::I32Type i32; + ast::type::I32 i32; auto* a = create("a"); auto* b = create("b"); @@ -532,7 +532,7 @@ if (_tint_tmp) { TEST_F(HlslGeneratorImplTest_Binary, Call_WithLogical) { // foo(a && b, c || d, (a || c) && (b || d)) - ast::type::VoidType void_type; + ast::type::Void void_type; auto* func = create("foo", ast::VariableList{}, &void_type, create()); diff --git a/src/writer/hlsl/generator_impl_bitcast_test.cc b/src/writer/hlsl/generator_impl_bitcast_test.cc index 1fa7d2e698..9d6d214d27 100644 --- a/src/writer/hlsl/generator_impl_bitcast_test.cc +++ b/src/writer/hlsl/generator_impl_bitcast_test.cc @@ -30,7 +30,7 @@ namespace { using HlslGeneratorImplTest_Bitcast = TestHelper; TEST_F(HlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Float) { - ast::type::F32Type f32; + ast::type::F32 f32; auto* id = create("id"); ast::BitcastExpression bitcast(&f32, id); @@ -39,7 +39,7 @@ TEST_F(HlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Float) { } TEST_F(HlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Int) { - ast::type::I32Type i32; + ast::type::I32 i32; auto* id = create("id"); ast::BitcastExpression bitcast(&i32, id); @@ -48,7 +48,7 @@ TEST_F(HlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Int) { } TEST_F(HlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Uint) { - ast::type::U32Type u32; + ast::type::U32 u32; auto* id = create("id"); ast::BitcastExpression bitcast(&u32, id); diff --git a/src/writer/hlsl/generator_impl_call_test.cc b/src/writer/hlsl/generator_impl_call_test.cc index 39f20ed8b8..780b2533f3 100644 --- a/src/writer/hlsl/generator_impl_call_test.cc +++ b/src/writer/hlsl/generator_impl_call_test.cc @@ -30,7 +30,7 @@ namespace { using HlslGeneratorImplTest_Call = TestHelper; TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithoutParams) { - ast::type::VoidType void_type; + ast::type::Void void_type; auto* id = create("my_func"); ast::CallExpression call(id, {}); @@ -44,7 +44,7 @@ TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithoutParams) { } TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithParams) { - ast::type::VoidType void_type; + ast::type::Void void_type; auto* id = create("my_func"); ast::ExpressionList params; @@ -61,7 +61,7 @@ TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithParams) { } TEST_F(HlslGeneratorImplTest_Call, EmitStatement_Call) { - ast::type::VoidType void_type; + ast::type::Void void_type; auto* id = create("my_func"); ast::ExpressionList params; diff --git a/src/writer/hlsl/generator_impl_case_test.cc b/src/writer/hlsl/generator_impl_case_test.cc index efff3e9031..0efe976724 100644 --- a/src/writer/hlsl/generator_impl_case_test.cc +++ b/src/writer/hlsl/generator_impl_case_test.cc @@ -31,7 +31,7 @@ namespace { using HlslGeneratorImplTest_Case = TestHelper; TEST_F(HlslGeneratorImplTest_Case, Emit_Case) { - ast::type::I32Type i32; + ast::type::I32 i32; auto* body = create(); body->append(create()); @@ -50,7 +50,7 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case) { } TEST_F(HlslGeneratorImplTest_Case, Emit_Case_BreaksByDefault) { - ast::type::I32Type i32; + ast::type::I32 i32; ast::CaseSelectorList lit; lit.push_back(create(&i32, 5)); @@ -66,7 +66,7 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case_BreaksByDefault) { } TEST_F(HlslGeneratorImplTest_Case, Emit_Case_WithFallthrough) { - ast::type::I32Type i32; + ast::type::I32 i32; auto* body = create(); body->append(create()); @@ -85,7 +85,7 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case_WithFallthrough) { } TEST_F(HlslGeneratorImplTest_Case, Emit_Case_MultipleSelectors) { - ast::type::I32Type i32; + ast::type::I32 i32; auto* body = create(); body->append(create()); diff --git a/src/writer/hlsl/generator_impl_cast_test.cc b/src/writer/hlsl/generator_impl_cast_test.cc index 8002e279b6..1fc3c702d7 100644 --- a/src/writer/hlsl/generator_impl_cast_test.cc +++ b/src/writer/hlsl/generator_impl_cast_test.cc @@ -29,7 +29,7 @@ namespace { using HlslGeneratorImplTest_Cast = TestHelper; TEST_F(HlslGeneratorImplTest_Cast, EmitExpression_Cast_Scalar) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create("id")); @@ -41,8 +41,8 @@ TEST_F(HlslGeneratorImplTest_Cast, EmitExpression_Cast_Scalar) { } TEST_F(HlslGeneratorImplTest_Cast, EmitExpression_Cast_Vector) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); ast::ExpressionList params; params.push_back(create("id")); diff --git a/src/writer/hlsl/generator_impl_constructor_test.cc b/src/writer/hlsl/generator_impl_constructor_test.cc index 69c4768c92..12033c142d 100644 --- a/src/writer/hlsl/generator_impl_constructor_test.cc +++ b/src/writer/hlsl/generator_impl_constructor_test.cc @@ -36,7 +36,7 @@ namespace { using HlslGeneratorImplTest_Constructor = TestHelper; TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Bool) { - ast::type::BoolType bool_type; + ast::type::Bool bool_type; auto* lit = create(&bool_type, false); ast::ScalarConstructorExpression expr(lit); @@ -45,7 +45,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Bool) { } TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Int) { - ast::type::I32Type i32; + ast::type::I32 i32; auto* lit = create(&i32, -12345); ast::ScalarConstructorExpression expr(lit); @@ -54,7 +54,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Int) { } TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_UInt) { - ast::type::U32Type u32; + ast::type::U32 u32; auto* lit = create(&u32, 56779); ast::ScalarConstructorExpression expr(lit); @@ -63,7 +63,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_UInt) { } TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Float) { - ast::type::F32Type f32; + ast::type::F32 f32; // Use a number close to 1<<30 but whose decimal representation ends in 0. auto* lit = create(&f32, static_cast((1 << 30) - 4)); @@ -74,7 +74,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Float) { } TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Float) { - ast::type::F32Type f32; + ast::type::F32 f32; auto* lit = create(&f32, -1.2e-5); ast::ExpressionList values; @@ -87,7 +87,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Float) { } TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Bool) { - ast::type::BoolType b; + ast::type::Bool b; auto* lit = create(&b, true); ast::ExpressionList values; @@ -100,7 +100,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Bool) { } TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Int) { - ast::type::I32Type i32; + ast::type::I32 i32; auto* lit = create(&i32, -12345); ast::ExpressionList values; @@ -113,7 +113,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Int) { } TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Uint) { - ast::type::U32Type u32; + ast::type::U32 u32; auto* lit = create(&u32, 12345); ast::ExpressionList values; @@ -126,8 +126,8 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Uint) { } TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec) { - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); auto* lit1 = create(&f32, 1.f); auto* lit2 = create(&f32, 2.f); @@ -144,8 +144,8 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec) { } TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec_Empty) { - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::ExpressionList values; ast::TypeConstructorExpression expr(&vec, values); @@ -155,9 +155,9 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec_Empty) { } TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Mat) { - ast::type::F32Type f32; - ast::type::MatrixType mat(&f32, 3, 2); // 3 ROWS, 2 COLUMNS - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Matrix mat(&f32, 3, 2); // 3 ROWS, 2 COLUMNS + ast::type::Vector vec(&f32, 3); // WGSL matrix is mat2x3 (it flips for AST, sigh). With a type constructor // of @@ -191,9 +191,9 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Mat) { } TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Array) { - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); - ast::type::ArrayType ary(&vec, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); + ast::type::Array ary(&vec, 3); ast::ExpressionList ary_values; diff --git a/src/writer/hlsl/generator_impl_function_entry_point_data_test.cc b/src/writer/hlsl/generator_impl_function_entry_point_data_test.cc index d224cccc48..fe7b1711a0 100644 --- a/src/writer/hlsl/generator_impl_function_entry_point_data_test.cc +++ b/src/writer/hlsl/generator_impl_function_entry_point_data_test.cc @@ -50,8 +50,8 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, // int bar : TEXCOORD1; // }; - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::F32 f32; + ast::type::I32 i32; auto* foo_var = create( create("foo", ast::StorageClass::kInput, &f32)); @@ -104,8 +104,8 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, // int bar : TEXCOORD1; // }; - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::F32 f32; + ast::type::I32 i32; auto* foo_var = create( create("foo", ast::StorageClass::kOutput, &f32)); @@ -159,8 +159,8 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, // int bar : TEXCOORD1; // }; - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::F32 f32; + ast::type::I32 i32; auto* foo_var = create( create("foo", ast::StorageClass::kInput, &f32)); @@ -214,8 +214,8 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, // int bar : SV_Target1; // }; - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::F32 f32; + ast::type::I32 i32; auto* foo_var = create( create("foo", ast::StorageClass::kOutput, &f32)); @@ -265,8 +265,8 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, // // -> Error, not allowed - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::F32 f32; + ast::type::I32 i32; auto* foo_var = create( create("foo", ast::StorageClass::kInput, &f32)); @@ -315,8 +315,8 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, // // -> Error not allowed - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::F32 f32; + ast::type::I32 i32; auto* foo_var = create( create("foo", ast::StorageClass::kOutput, &f32)); @@ -371,9 +371,9 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, // float depth : SV_Depth; // }; - ast::type::F32Type f32; - ast::type::VoidType void_type; - ast::type::VectorType vec4(&f32, 4); + ast::type::F32 f32; + ast::type::Void void_type; + ast::type::Vector vec4(&f32, 4); auto* coord_var = create( create("coord", ast::StorageClass::kInput, &vec4)); diff --git a/src/writer/hlsl/generator_impl_function_test.cc b/src/writer/hlsl/generator_impl_function_test.cc index fc81bd5893..db623f664c 100644 --- a/src/writer/hlsl/generator_impl_function_test.cc +++ b/src/writer/hlsl/generator_impl_function_test.cc @@ -55,7 +55,7 @@ namespace { using HlslGeneratorImplTest_Function = TestHelper; TEST_F(HlslGeneratorImplTest_Function, Emit_Function) { - ast::type::VoidType void_type; + ast::type::Void void_type; auto* body = create(); body->append(create()); @@ -74,7 +74,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function) { } TEST_F(HlslGeneratorImplTest_Function, Emit_Function_Name_Collision) { - ast::type::VoidType void_type; + ast::type::Void void_type; auto* body = create(); body->append(create()); @@ -93,14 +93,14 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_Name_Collision) { } TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithParams) { - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::F32 f32; + ast::type::I32 i32; ast::VariableList params; params.push_back(create("a", ast::StorageClass::kNone, &f32)); params.push_back(create("b", ast::StorageClass::kNone, &i32)); - ast::type::VoidType void_type; + ast::type::Void void_type; auto* body = create(); body->append(create()); @@ -119,8 +119,8 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithParams) { TEST_F(HlslGeneratorImplTest_Function, Emit_FunctionDecoration_EntryPoint_WithInOutVars) { - ast::type::VoidType void_type; - ast::type::F32Type f32; + ast::type::Void void_type; + ast::type::F32 f32; auto* foo_var = create( create("foo", ast::StorageClass::kInput, &f32)); @@ -169,9 +169,9 @@ frag_main_out frag_main(frag_main_in tint_in) { TEST_F(HlslGeneratorImplTest_Function, Emit_FunctionDecoration_EntryPoint_WithInOut_Builtins) { - ast::type::VoidType void_type; - ast::type::F32Type f32; - ast::type::VectorType vec4(&f32, 4); + ast::type::Void void_type; + ast::type::F32 f32; + ast::type::Vector vec4(&f32, 4); auto* coord_var = create( create("coord", ast::StorageClass::kInput, &vec4)); @@ -225,9 +225,9 @@ frag_main_out frag_main(frag_main_in tint_in) { TEST_F(HlslGeneratorImplTest_Function, Emit_FunctionDecoration_EntryPoint_With_Uniform) { - ast::type::VoidType void_type; - ast::type::F32Type f32; - ast::type::VectorType vec4(&f32, 4); + ast::type::Void void_type; + ast::type::F32 f32; + ast::type::Vector vec4(&f32, 4); auto* coord_var = create( create("coord", ast::StorageClass::kUniform, &vec4)); @@ -271,9 +271,9 @@ void frag_main() { TEST_F(HlslGeneratorImplTest_Function, Emit_FunctionDecoration_EntryPoint_With_UniformStruct) { - ast::type::VoidType void_type; - ast::type::F32Type f32; - ast::type::VectorType vec4(&f32, 4); + ast::type::Void void_type; + ast::type::F32 f32; + ast::type::Vector vec4(&f32, 4); ast::StructMemberList members; members.push_back(create( @@ -282,7 +282,7 @@ TEST_F(HlslGeneratorImplTest_Function, auto* str = create(); str->set_members(members); - ast::type::StructType s("Uniforms", str); + ast::type::Struct s("Uniforms", str); auto* coord_var = create( create("uniforms", ast::StorageClass::kUniform, &s)); @@ -332,9 +332,9 @@ void frag_main() { TEST_F(HlslGeneratorImplTest_Function, Emit_FunctionDecoration_EntryPoint_With_RW_StorageBuffer_Read) { - ast::type::VoidType void_type; - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::Void void_type; + ast::type::F32 f32; + ast::type::I32 i32; ast::StructMemberList members; ast::StructMemberDecorationList a_deco; @@ -348,8 +348,8 @@ TEST_F(HlslGeneratorImplTest_Function, auto* str = create(); str->set_members(members); - ast::type::StructType s("Data", str); - ast::type::AccessControlType ac(ast::AccessControl::kReadWrite, &s); + ast::type::Struct s("Data", str); + ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); auto* coord_var = create( create("coord", ast::StorageClass::kStorageBuffer, &ac)); @@ -391,9 +391,9 @@ void frag_main() { TEST_F(HlslGeneratorImplTest_Function, Emit_FunctionDecoration_EntryPoint_With_RO_StorageBuffer_Read) { - ast::type::VoidType void_type; - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::Void void_type; + ast::type::F32 f32; + ast::type::I32 i32; ast::StructMemberList members; ast::StructMemberDecorationList a_deco; @@ -407,8 +407,8 @@ TEST_F(HlslGeneratorImplTest_Function, auto* str = create(); str->set_members(members); - ast::type::StructType s("Data", str); - ast::type::AccessControlType ac(ast::AccessControl::kReadOnly, &s); + ast::type::Struct s("Data", str); + ast::type::AccessControl ac(ast::AccessControl::kReadOnly, &s); auto* coord_var = create( create("coord", ast::StorageClass::kStorageBuffer, &ac)); @@ -450,9 +450,9 @@ void frag_main() { TEST_F(HlslGeneratorImplTest_Function, Emit_FunctionDecoration_EntryPoint_With_StorageBuffer_Store) { - ast::type::VoidType void_type; - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::Void void_type; + ast::type::F32 f32; + ast::type::I32 i32; ast::StructMemberList members; ast::StructMemberDecorationList a_deco; @@ -466,8 +466,8 @@ TEST_F(HlslGeneratorImplTest_Function, auto* str = create(); str->set_members(members); - ast::type::StructType s("Data", str); - ast::type::AccessControlType ac(ast::AccessControl::kReadWrite, &s); + ast::type::Struct s("Data", str); + ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); auto* coord_var = create( create("coord", ast::StorageClass::kStorageBuffer, &ac)); @@ -513,8 +513,8 @@ void frag_main() { TEST_F( HlslGeneratorImplTest_Function, Emit_FunctionDecoration_Called_By_EntryPoints_WithLocationGlobals_And_Params) { // NOLINT - ast::type::VoidType void_type; - ast::type::F32Type f32; + ast::type::Void void_type; + ast::type::F32 f32; auto* foo_var = create( create("foo", ast::StorageClass::kInput, &f32)); @@ -597,9 +597,9 @@ ep_1_out ep_1(ep_1_in tint_in) { TEST_F(HlslGeneratorImplTest_Function, Emit_FunctionDecoration_Called_By_EntryPoints_NoUsedGlobals) { - ast::type::VoidType void_type; - ast::type::F32Type f32; - ast::type::VectorType vec4(&f32, 4); + ast::type::Void void_type; + ast::type::F32 f32; + ast::type::Vector vec4(&f32, 4); auto* depth_var = create( create("depth", ast::StorageClass::kOutput, &f32)); @@ -662,9 +662,9 @@ ep_1_out ep_1() { TEST_F( HlslGeneratorImplTest_Function, Emit_FunctionDecoration_Called_By_EntryPoints_WithBuiltinGlobals_And_Params) { // NOLINT - ast::type::VoidType void_type; - ast::type::F32Type f32; - ast::type::VectorType vec4(&f32, 4); + ast::type::Void void_type; + ast::type::F32 f32; + ast::type::Vector vec4(&f32, 4); auto* coord_var = create( create("coord", ast::StorageClass::kInput, &vec4)); @@ -740,9 +740,9 @@ ep_1_out ep_1(ep_1_in tint_in) { TEST_F(HlslGeneratorImplTest_Function, Emit_FunctionDecoration_Called_By_EntryPoint_With_Uniform) { - ast::type::VoidType void_type; - ast::type::F32Type f32; - ast::type::VectorType vec4(&f32, 4); + ast::type::Void void_type; + ast::type::F32 f32; + ast::type::Vector vec4(&f32, 4); auto* coord_var = create( create("coord", ast::StorageClass::kUniform, &vec4)); @@ -806,10 +806,10 @@ void frag_main() { TEST_F(HlslGeneratorImplTest_Function, Emit_FunctionDecoration_Called_By_EntryPoint_With_StorageBuffer) { - ast::type::VoidType void_type; - ast::type::F32Type f32; - ast::type::VectorType vec4(&f32, 4); - ast::type::AccessControlType ac(ast::AccessControl::kReadWrite, &vec4); + ast::type::Void void_type; + ast::type::F32 f32; + ast::type::Vector vec4(&f32, 4); + ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &vec4); auto* coord_var = create( create("coord", ast::StorageClass::kStorageBuffer, &ac)); @@ -870,9 +870,9 @@ void frag_main() { TEST_F(HlslGeneratorImplTest_Function, Emit_FunctionDecoration_EntryPoints_WithGlobal_Nested_Return) { - ast::type::VoidType void_type; - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::Void void_type; + ast::type::F32 f32; + ast::type::I32 i32; auto* bar_var = create( create("bar", ast::StorageClass::kOutput, &f32)); @@ -928,7 +928,7 @@ ep_1_out ep_1() { TEST_F(HlslGeneratorImplTest_Function, Emit_FunctionDecoration_EntryPoint_WithNameCollision) { - ast::type::VoidType void_type; + ast::type::Void void_type; auto* func = create("GeometryShader", ast::VariableList{}, &void_type, create()); @@ -946,7 +946,7 @@ TEST_F(HlslGeneratorImplTest_Function, TEST_F(HlslGeneratorImplTest_Function, Emit_FunctionDecoration_EntryPoint_Compute) { - ast::type::VoidType void_type; + ast::type::Void void_type; ast::VariableList params; auto* body = create(); @@ -969,7 +969,7 @@ void main() { TEST_F(HlslGeneratorImplTest_Function, Emit_FunctionDecoration_EntryPoint_Compute_WithWorkgroup) { - ast::type::VoidType void_type; + ast::type::Void void_type; ast::VariableList params; auto* body = create(); @@ -992,13 +992,13 @@ void main() { } TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithArrayParams) { - ast::type::F32Type f32; - ast::type::ArrayType ary(&f32, 5); + ast::type::F32 f32; + ast::type::Array ary(&f32, 5); ast::VariableList params; params.push_back(create("a", ast::StorageClass::kNone, &ary)); - ast::type::VoidType void_type; + ast::type::Void void_type; auto* body = create(); body->append(create()); @@ -1033,8 +1033,8 @@ TEST_F(HlslGeneratorImplTest_Function, // return; // } - ast::type::VoidType void_type; - ast::type::F32Type f32; + ast::type::Void void_type; + ast::type::F32 f32; ast::StructMemberList members; ast::StructMemberDecorationList a_deco; @@ -1046,8 +1046,8 @@ TEST_F(HlslGeneratorImplTest_Function, auto* str = create(s_decos, members); - ast::type::StructType s("Data", str); - ast::type::AccessControlType ac(ast::AccessControl::kReadWrite, &s); + ast::type::Struct s("Data", str); + ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); auto* data_var = create( create("data", ast::StorageClass::kStorageBuffer, &ac)); diff --git a/src/writer/hlsl/generator_impl_import_test.cc b/src/writer/hlsl/generator_impl_import_test.cc index a55c452d96..237ce114c3 100644 --- a/src/writer/hlsl/generator_impl_import_test.cc +++ b/src/writer/hlsl/generator_impl_import_test.cc @@ -51,7 +51,7 @@ using HlslImportData_SingleParamTest = TestParamHelper; TEST_P(HlslImportData_SingleParamTest, FloatScalar) { auto param = GetParam(); - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( @@ -96,7 +96,7 @@ using HlslImportData_SingleIntParamTest = TestParamHelper; TEST_P(HlslImportData_SingleIntParamTest, IntScalar) { auto param = GetParam(); - ast::type::I32Type i32; + ast::type::I32 i32; ast::ExpressionList params; params.push_back(create( @@ -117,7 +117,7 @@ using HlslImportData_DualParamTest = TestParamHelper; TEST_P(HlslImportData_DualParamTest, FloatScalar) { auto param = GetParam(); - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( @@ -146,8 +146,8 @@ using HlslImportData_DualParam_VectorTest = TestParamHelper; TEST_P(HlslImportData_DualParam_VectorTest, FloatVector) { auto param = GetParam(); - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::ExpressionList params; params.push_back(create( @@ -187,7 +187,7 @@ using HlslImportData_DualParam_Int_Test = TestParamHelper; TEST_P(HlslImportData_DualParam_Int_Test, IntScalar) { auto param = GetParam(); - ast::type::I32Type i32; + ast::type::I32 i32; ast::ExpressionList params; params.push_back(create( @@ -211,7 +211,7 @@ using HlslImportData_TripleParamTest = TestParamHelper; TEST_P(HlslImportData_TripleParamTest, FloatScalar) { auto param = GetParam(); - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( @@ -244,7 +244,7 @@ using HlslImportData_TripleParam_Int_Test = TestParamHelper; TEST_P(HlslImportData_TripleParam_Int_Test, IntScalar) { auto param = GetParam(); - ast::type::I32Type i32; + ast::type::I32 i32; ast::ExpressionList params; params.push_back(create( @@ -266,8 +266,8 @@ INSTANTIATE_TEST_SUITE_P(HlslGeneratorImplTest_Import, testing::Values(HlslImportData{"clamp", "clamp"})); TEST_F(HlslGeneratorImplTest_Import, HlslImportData_Determinant) { - ast::type::F32Type f32; - ast::type::MatrixType mat(&f32, 3, 3); + ast::type::F32 f32; + ast::type::Matrix mat(&f32, 3, 3); auto* var = create("var", ast::StorageClass::kFunction, &mat); diff --git a/src/writer/hlsl/generator_impl_intrinsic_test.cc b/src/writer/hlsl/generator_impl_intrinsic_test.cc index b47a1e3b9a..669d91fd70 100644 --- a/src/writer/hlsl/generator_impl_intrinsic_test.cc +++ b/src/writer/hlsl/generator_impl_intrinsic_test.cc @@ -72,9 +72,9 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, DISABLED_Intrinsic_Select) { } TEST_F(HlslGeneratorImplTest_Intrinsic, DISABLED_Intrinsic_OuterProduct) { - ast::type::F32Type f32; - ast::type::VectorType vec2(&f32, 2); - ast::type::VectorType vec3(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec2(&f32, 2); + ast::type::Vector vec3(&f32, 3); auto* a = create("a", ast::StorageClass::kNone, &vec2); auto* b = create("b", ast::StorageClass::kNone, &vec3); @@ -105,8 +105,8 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, Intrinsic_Bad_Name) { } TEST_F(HlslGeneratorImplTest_Intrinsic, Intrinsic_Call) { - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::ExpressionList params; params.push_back(create("param1")); diff --git a/src/writer/hlsl/generator_impl_intrinsic_texture_test.cc b/src/writer/hlsl/generator_impl_intrinsic_texture_test.cc index 19c8612b8c..9da97e15a9 100644 --- a/src/writer/hlsl/generator_impl_intrinsic_texture_test.cc +++ b/src/writer/hlsl/generator_impl_intrinsic_texture_test.cc @@ -179,17 +179,17 @@ TEST_P(HlslGeneratorIntrinsicTextureTest, Call) { break; } - ast::type::SamplerType sampler_type{param.sampler_kind}; + ast::type::Sampler sampler_type{param.sampler_kind}; switch (param.texture_kind) { case ast::intrinsic::test::TextureKind::kRegular: Var("texture", ast::StorageClass::kNone, - mod->create(param.texture_dimension, - datatype)); + mod->create(param.texture_dimension, + datatype)); break; case ast::intrinsic::test::TextureKind::kDepth: Var("texture", ast::StorageClass::kNone, - mod->create(param.texture_dimension)); + mod->create(param.texture_dimension)); break; } diff --git a/src/writer/hlsl/generator_impl_loop_test.cc b/src/writer/hlsl/generator_impl_loop_test.cc index 4e7bfddb46..e180180a60 100644 --- a/src/writer/hlsl/generator_impl_loop_test.cc +++ b/src/writer/hlsl/generator_impl_loop_test.cc @@ -73,7 +73,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopWithContinuing) { } TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopNestedWithContinuing) { - ast::type::F32Type f32; + ast::type::F32 f32; auto* body = create(); body->append(create()); @@ -142,7 +142,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopWithVarUsedInContinuing) { // } // } - ast::type::F32Type f32; + ast::type::F32 f32; auto* var = create("lhs", ast::StorageClass::kFunction, &f32); var->set_constructor(create( diff --git a/src/writer/hlsl/generator_impl_member_accessor_test.cc b/src/writer/hlsl/generator_impl_member_accessor_test.cc index 5c15ab6b75..145e0c71cd 100644 --- a/src/writer/hlsl/generator_impl_member_accessor_test.cc +++ b/src/writer/hlsl/generator_impl_member_accessor_test.cc @@ -47,7 +47,7 @@ namespace { using HlslGeneratorImplTest_MemberAccessor = TestHelper; TEST_F(HlslGeneratorImplTest_MemberAccessor, EmitExpression_MemberAccessor) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::StructMemberList members; ast::StructMemberDecorationList deco; @@ -57,7 +57,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, EmitExpression_MemberAccessor) { auto* strct = create(); strct->set_members(members); - ast::type::StructType s("Str", strct); + ast::type::Struct s("Str", strct); auto* str_var = create( create("str", ast::StorageClass::kPrivate, &s)); @@ -86,8 +86,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, // data.b; // // -> asfloat(data.Load(4)); - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::F32 f32; + ast::type::I32 i32; ast::StructMemberList members; ast::StructMemberDecorationList a_deco; @@ -101,7 +101,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create(); str->set_members(members); - ast::type::StructType s("Data", str); + ast::type::Struct s("Data", str); auto* coord_var = create( create("data", ast::StorageClass::kStorageBuffer, &s)); @@ -130,8 +130,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, // data.a; // // -> asint(data.Load(0)); - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::F32 f32; + ast::type::I32 i32; ast::StructMemberList members; ast::StructMemberDecorationList a_deco; @@ -145,7 +145,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create(); str->set_members(members); - ast::type::StructType s("Data", str); + ast::type::Struct s("Data", str); auto* coord_var = create( create("data", ast::StorageClass::kStorageBuffer, &s)); @@ -176,9 +176,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, // -> float3x2 _tint_tmp = b; // data.Store3(4 + 0, asuint(_tint_tmp[0])); // data.Store3(4 + 16, asuint(_tint_tmp[1])); - ast::type::F32Type f32; - ast::type::I32Type i32; - ast::type::MatrixType mat(&f32, 3, 2); + ast::type::F32 f32; + ast::type::I32 i32; + ast::type::Matrix mat(&f32, 3, 2); auto* str = create(); str->set_members({ @@ -192,7 +192,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, create(4, Source{})}), }); - ast::type::StructType s("Data", str); + ast::type::Struct s("Data", str); auto* b_var = create("b", ast::StorageClass::kPrivate, &mat); @@ -236,9 +236,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, // 0.0f, 0.0f, 0.0f); // data.Store3(4 + 0, asuint(_tint_tmp[0]); // data.Store3(4 + 16, asuint(_tint_tmp[1])); - ast::type::F32Type f32; - ast::type::I32Type i32; - ast::type::MatrixType mat(&f32, 3, 2); + ast::type::F32 f32; + ast::type::I32 i32; + ast::type::Matrix mat(&f32, 3, 2); ast::StructMemberList members; ast::StructMemberDecorationList a_deco; @@ -252,7 +252,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create(); str->set_members(members); - ast::type::StructType s("Data", str); + ast::type::Struct s("Data", str); auto* coord_var = create( create("data", ast::StorageClass::kStorageBuffer, &s)); @@ -292,9 +292,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, // // -> asfloat(uint2x3(data.Load2(4 + 0), data.Load2(4 + 8), // data.Load2(4 + 16))); - ast::type::F32Type f32; - ast::type::I32Type i32; - ast::type::MatrixType mat(&f32, 2, 3); + ast::type::F32 f32; + ast::type::I32 i32; + ast::type::Matrix mat(&f32, 2, 3); ast::StructMemberList members; ast::StructMemberDecorationList a_deco; @@ -308,7 +308,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create(); str->set_members(members); - ast::type::StructType s("Data", str); + ast::type::Struct s("Data", str); auto* coord_var = create( create("data", ast::StorageClass::kStorageBuffer, &s)); @@ -343,9 +343,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, // data.b.a; // // -> asfloat(uint3x2(data.Load3(4 + 0), data.Load3(4 + 16))); - ast::type::F32Type f32; - ast::type::I32Type i32; - ast::type::MatrixType mat(&f32, 3, 2); + ast::type::F32 f32; + ast::type::I32 i32; + ast::type::Matrix mat(&f32, 3, 2); ast::StructMemberList members; ast::StructMemberDecorationList a_deco; @@ -359,7 +359,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create(); str->set_members(members); - ast::type::StructType s("Data", str); + ast::type::Struct s("Data", str); auto* coord_var = create( create("data", ast::StorageClass::kStorageBuffer, &s)); @@ -390,9 +390,9 @@ TEST_F( // // -> asfloat(uint3x3(data.Load3(0), data.Load3(16), // data.Load3(32))); - ast::type::F32Type f32; - ast::type::I32Type i32; - ast::type::MatrixType mat(&f32, 3, 3); + ast::type::F32 f32; + ast::type::I32 i32; + ast::type::Matrix mat(&f32, 3, 3); ast::StructMemberList members; ast::StructMemberDecorationList deco; @@ -402,7 +402,7 @@ TEST_F( auto* str = create(); str->set_members(members); - ast::type::StructType s("Data", str); + ast::type::Struct s("Data", str); auto* coord_var = create( create("data", ast::StorageClass::kStorageBuffer, &s)); @@ -433,9 +433,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, // data.a[2][1]; // // -> asfloat(data.Load((2 * 16) + (1 * 4) + 16))) - ast::type::F32Type f32; - ast::type::I32Type i32; - ast::type::MatrixType mat(&f32, 3, 4); + ast::type::F32 f32; + ast::type::I32 i32; + ast::type::Matrix mat(&f32, 3, 4); ast::StructMemberList members; ast::StructMemberDecorationList a_deco; @@ -449,7 +449,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create(); str->set_members(members); - ast::type::StructType s("Data", str); + ast::type::Struct s("Data", str); auto* coord_var = create( create("data", ast::StorageClass::kStorageBuffer, &s)); @@ -484,9 +484,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, // data.a[2]; // // -> asint(data.Load((2 * 4)); - ast::type::F32Type f32; - ast::type::I32Type i32; - ast::type::ArrayType ary(&i32, 5); + ast::type::F32 f32; + ast::type::I32 i32; + ast::type::Array ary(&i32, 5); ary.set_decorations({create(4, Source{})}); ast::StructMemberList members; @@ -497,7 +497,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create(); str->set_members(members); - ast::type::StructType s("Data", str); + ast::type::Struct s("Data", str); auto* coord_var = create( create("data", ast::StorageClass::kStorageBuffer, &s)); @@ -529,9 +529,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, // data.a[(2 + 4) - 3]; // // -> asint(data.Load((4 * ((2 + 4) - 3))); - ast::type::F32Type f32; - ast::type::I32Type i32; - ast::type::ArrayType ary(&i32, 5); + ast::type::F32 f32; + ast::type::I32 i32; + ast::type::Array ary(&i32, 5); ary.set_decorations({create(4, Source{})}); ast::StructMemberList members; @@ -542,7 +542,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create(); str->set_members(members); - ast::type::StructType s("Data", str); + ast::type::Struct s("Data", str); auto* coord_var = create( create("data", ast::StorageClass::kStorageBuffer, &s)); @@ -584,8 +584,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, // // -> data.Store(0, asuint(2.0f)); - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::F32 f32; + ast::type::I32 i32; ast::StructMemberList members; ast::StructMemberDecorationList a_deco; @@ -599,7 +599,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create(); str->set_members(members); - ast::type::StructType s("Data", str); + ast::type::Struct s("Data", str); auto* coord_var = create( create("data", ast::StorageClass::kStorageBuffer, &s)); @@ -633,9 +633,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, // // -> data.Store((2 * 4), asuint(2.3f)); - ast::type::F32Type f32; - ast::type::I32Type i32; - ast::type::ArrayType ary(&i32, 5); + ast::type::F32 f32; + ast::type::I32 i32; + ast::type::Array ary(&i32, 5); ary.set_decorations({create(4, Source{})}); ast::StructMemberList members; @@ -646,7 +646,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create(); str->set_members(members); - ast::type::StructType s("Data", str); + ast::type::Struct s("Data", str); auto* coord_var = create( create("data", ast::StorageClass::kStorageBuffer, &s)); @@ -684,8 +684,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, // // -> data.Store(0, asuint(2)); - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::F32 f32; + ast::type::I32 i32; ast::StructMemberList members; ast::StructMemberDecorationList a_deco; @@ -699,7 +699,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create(); str->set_members(members); - ast::type::StructType s("Data", str); + ast::type::Struct s("Data", str); auto* coord_var = create( create("data", ast::StorageClass::kStorageBuffer, &s)); @@ -734,10 +734,10 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, // // -> asfloat(data.Load(16)); - ast::type::F32Type f32; - ast::type::I32Type i32; - ast::type::VectorType ivec3(&i32, 3); - ast::type::VectorType fvec3(&f32, 3); + ast::type::F32 f32; + ast::type::I32 i32; + ast::type::Vector ivec3(&i32, 3); + ast::type::Vector fvec3(&f32, 3); ast::StructMemberList members; ast::StructMemberDecorationList a_deco; @@ -751,7 +751,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create(); str->set_members(members); - ast::type::StructType s("Data", str); + ast::type::Struct s("Data", str); auto* coord_var = create( create("data", ast::StorageClass::kStorageBuffer, &s)); @@ -781,10 +781,10 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, // // -> data.Store(16, asuint(float3(2.3f, 1.2f, 0.2f))); - ast::type::F32Type f32; - ast::type::I32Type i32; - ast::type::VectorType ivec3(&i32, 3); - ast::type::VectorType fvec3(&f32, 3); + ast::type::F32 f32; + ast::type::I32 i32; + ast::type::Vector ivec3(&i32, 3); + ast::type::Vector fvec3(&f32, 3); ast::StructMemberList members; ast::StructMemberDecorationList a_deco; @@ -798,7 +798,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create(); str->set_members(members); - ast::type::StructType s("Data", str); + ast::type::Struct s("Data", str); auto* coord_var = create( create("data", ast::StorageClass::kStorageBuffer, &s)); @@ -846,10 +846,10 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, // // -> asfloat(data.Load3(16 + (2 * 32))) - ast::type::F32Type f32; - ast::type::I32Type i32; - ast::type::VectorType ivec3(&i32, 3); - ast::type::VectorType fvec3(&f32, 3); + ast::type::F32 f32; + ast::type::I32 i32; + ast::type::Vector ivec3(&i32, 3); + ast::type::Vector fvec3(&f32, 3); auto* data_str = create(); data_str->set_members({ @@ -863,9 +863,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, create(16, Source{})}), }); - ast::type::StructType data("Data", data_str); + ast::type::Struct data("Data", data_str); - ast::type::ArrayType ary(&data, 4); + ast::type::Array ary(&data, 4); ary.set_decorations({create(32, Source{})}); auto* pre_str = create(); @@ -876,7 +876,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, create(0, Source{})}), }); - ast::type::StructType pre_struct("Pre", pre_str); + ast::type::Struct pre_struct("Pre", pre_str); auto* coord_var = create(create( "data", ast::StorageClass::kStorageBuffer, &pre_struct)); @@ -916,10 +916,10 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, // // -> asfloat(data.Load3(16 + (2 * 32))).xy - ast::type::F32Type f32; - ast::type::I32Type i32; - ast::type::VectorType ivec3(&i32, 3); - ast::type::VectorType fvec3(&f32, 3); + ast::type::F32 f32; + ast::type::I32 i32; + ast::type::Vector ivec3(&i32, 3); + ast::type::Vector fvec3(&f32, 3); ast::StructMemberList members; ast::StructMemberDecorationList deco; @@ -936,9 +936,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, create(16, Source{})}), }); - ast::type::StructType data("Data", data_str); + ast::type::Struct data("Data", data_str); - ast::type::ArrayType ary(&data, 4); + ast::type::Array ary(&data, 4); ary.set_decorations({create(32, Source{})}); auto* pre_str = create(); @@ -947,7 +947,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::StructMemberDecorationList{ create(0, Source{})})}); - ast::type::StructType pre_struct("Pre", pre_str); + ast::type::Struct pre_struct("Pre", pre_str); auto* coord_var = create(create( "data", ast::StorageClass::kStorageBuffer, &pre_struct)); @@ -990,10 +990,10 @@ TEST_F( // // -> asfloat(data.Load((4 * 1) + 16 + (2 * 32) + 0)) - ast::type::F32Type f32; - ast::type::I32Type i32; - ast::type::VectorType ivec3(&i32, 3); - ast::type::VectorType fvec3(&f32, 3); + ast::type::F32 f32; + ast::type::I32 i32; + ast::type::Vector ivec3(&i32, 3); + ast::type::Vector fvec3(&f32, 3); auto* data_str = create(); data_str->set_members({ @@ -1007,9 +1007,9 @@ TEST_F( create(16, Source{})}), }); - ast::type::StructType data("Data", data_str); + ast::type::Struct data("Data", data_str); - ast::type::ArrayType ary(&data, 4); + ast::type::Array ary(&data, 4); ary.set_decorations({create(32, Source{})}); auto* pre_str = create(); @@ -1018,7 +1018,7 @@ TEST_F( ast::StructMemberDecorationList{ create(0, Source{})})}); - ast::type::StructType pre_struct("Pre", pre_str); + ast::type::Struct pre_struct("Pre", pre_str); auto* coord_var = create(create( "data", ast::StorageClass::kStorageBuffer, &pre_struct)); @@ -1060,10 +1060,10 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, // // -> asfloat(data.Load(4 + 16 + (2 * 32))) - ast::type::F32Type f32; - ast::type::I32Type i32; - ast::type::VectorType ivec3(&i32, 3); - ast::type::VectorType fvec3(&f32, 3); + ast::type::F32 f32; + ast::type::I32 i32; + ast::type::Vector ivec3(&i32, 3); + ast::type::Vector fvec3(&f32, 3); auto* data_str = create(); data_str->set_members({ @@ -1077,9 +1077,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, create(16, Source{})}), }); - ast::type::StructType data("Data", data_str); + ast::type::Struct data("Data", data_str); - ast::type::ArrayType ary(&data, 4); + ast::type::Array ary(&data, 4); ary.set_decorations({create(32, Source{})}); auto* pre_str = create(); @@ -1088,7 +1088,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::StructMemberDecorationList{ create(0, Source{})})}); - ast::type::StructType pre_struct("Pre", pre_str); + ast::type::Struct pre_struct("Pre", pre_str); auto* coord_var = create(create( "data", ast::StorageClass::kStorageBuffer, &pre_struct)); @@ -1131,10 +1131,10 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, // // -> data.Store3(16 + (2 * 32), asuint(float3(1.0f, 2.0f, 3.0f))); - ast::type::F32Type f32; - ast::type::I32Type i32; - ast::type::VectorType ivec3(&i32, 3); - ast::type::VectorType fvec3(&f32, 3); + ast::type::F32 f32; + ast::type::I32 i32; + ast::type::Vector ivec3(&i32, 3); + ast::type::Vector fvec3(&f32, 3); auto* data_str = create(); data_str->set_members({ @@ -1148,9 +1148,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, create(16, Source{})}), }); - ast::type::StructType data("Data", data_str); + ast::type::Struct data("Data", data_str); - ast::type::ArrayType ary(&data, 4); + ast::type::Array ary(&data, 4); ary.set_decorations({create(32, Source{})}); auto* pre_str = create(); @@ -1159,7 +1159,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::StructMemberDecorationList{ create(0, Source{})})}); - ast::type::StructType pre_struct("Pre", pre_str); + ast::type::Struct pre_struct("Pre", pre_str); auto* coord_var = create(create( "data", ast::StorageClass::kStorageBuffer, &pre_struct)); @@ -1213,10 +1213,10 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, // // -> data.Store((4 * 1) + 16 + (2 * 32) + 0, asuint(1.0f)); - ast::type::F32Type f32; - ast::type::I32Type i32; - ast::type::VectorType ivec3(&i32, 3); - ast::type::VectorType fvec3(&f32, 3); + ast::type::F32 f32; + ast::type::I32 i32; + ast::type::Vector ivec3(&i32, 3); + ast::type::Vector fvec3(&f32, 3); auto* data_str = create(); data_str->set_members({ @@ -1230,9 +1230,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, create(16, Source{})}), }); - ast::type::StructType data("Data", data_str); + ast::type::Struct data("Data", data_str); - ast::type::ArrayType ary(&data, 4); + ast::type::Array ary(&data, 4); ary.set_decorations({create(32, Source{})}); auto* pre_str = create(); @@ -1241,7 +1241,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::StructMemberDecorationList{ create(0, Source{})})}); - ast::type::StructType pre_struct("Pre", pre_str); + ast::type::Struct pre_struct("Pre", pre_str); auto* coord_var = create(create( "data", ast::StorageClass::kStorageBuffer, &pre_struct)); diff --git a/src/writer/hlsl/generator_impl_module_constant_test.cc b/src/writer/hlsl/generator_impl_module_constant_test.cc index 84831d5d45..2e9603441a 100644 --- a/src/writer/hlsl/generator_impl_module_constant_test.cc +++ b/src/writer/hlsl/generator_impl_module_constant_test.cc @@ -34,8 +34,8 @@ namespace { using HlslGeneratorImplTest_ModuleConstant = TestHelper; TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_ModuleConstant) { - ast::type::F32Type f32; - ast::type::ArrayType ary(&f32, 3); + ast::type::F32 f32; + ast::type::Array ary(&f32, 3); ast::ExpressionList exprs; exprs.push_back(create( @@ -54,7 +54,7 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_ModuleConstant) { } TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_SpecConstant) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::VariableDecorationList decos; decos.push_back(create(23, Source{})); @@ -76,7 +76,7 @@ static const float pos = WGSL_SPEC_CONSTANT_23; } TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_SpecConstant_NoConstructor) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::VariableDecorationList decos; decos.push_back(create(23, Source{})); diff --git a/src/writer/hlsl/generator_impl_switch_test.cc b/src/writer/hlsl/generator_impl_switch_test.cc index ab33821e76..fa5f12d722 100644 --- a/src/writer/hlsl/generator_impl_switch_test.cc +++ b/src/writer/hlsl/generator_impl_switch_test.cc @@ -35,7 +35,7 @@ TEST_F(HlslGeneratorImplTest_Switch, Emit_Switch) { def_body->append(create()); auto* def = create(def_body); - ast::type::I32Type i32; + ast::type::I32 i32; ast::CaseSelectorList case_val; case_val.push_back(create(&i32, 5)); diff --git a/src/writer/hlsl/generator_impl_test.cc b/src/writer/hlsl/generator_impl_test.cc index f2854aaea1..4f0a14cd2c 100644 --- a/src/writer/hlsl/generator_impl_test.cc +++ b/src/writer/hlsl/generator_impl_test.cc @@ -28,7 +28,7 @@ namespace { using HlslGeneratorImplTest = TestHelper; TEST_F(HlslGeneratorImplTest, Generate) { - ast::type::VoidType void_type; + ast::type::Void void_type; auto* func = create("my_func", ast::VariableList{}, &void_type, create()); mod.AddFunction(func); diff --git a/src/writer/hlsl/generator_impl_type_test.cc b/src/writer/hlsl/generator_impl_type_test.cc index 592a600cec..e8fcb64795 100644 --- a/src/writer/hlsl/generator_impl_type_test.cc +++ b/src/writer/hlsl/generator_impl_type_test.cc @@ -44,33 +44,33 @@ namespace { using HlslGeneratorImplTest_Type = TestHelper; TEST_F(HlslGeneratorImplTest_Type, EmitType_Alias) { - ast::type::F32Type f32; - ast::type::AliasType alias("alias", &f32); + ast::type::F32 f32; + ast::type::Alias alias("alias", &f32); ASSERT_TRUE(gen.EmitType(out, &alias, "")) << gen.error(); EXPECT_EQ(result(), "alias"); } TEST_F(HlslGeneratorImplTest_Type, EmitType_Alias_NameCollision) { - ast::type::F32Type f32; - ast::type::AliasType alias("bool", &f32); + ast::type::F32 f32; + ast::type::Alias alias("bool", &f32); ASSERT_TRUE(gen.EmitType(out, &alias, "")) << gen.error(); EXPECT_EQ(result(), "bool_tint_0"); } TEST_F(HlslGeneratorImplTest_Type, EmitType_Array) { - ast::type::BoolType b; - ast::type::ArrayType a(&b, 4); + ast::type::Bool b; + ast::type::Array a(&b, 4); ASSERT_TRUE(gen.EmitType(out, &a, "ary")) << gen.error(); EXPECT_EQ(result(), "bool ary[4]"); } TEST_F(HlslGeneratorImplTest_Type, EmitType_ArrayOfArray) { - ast::type::BoolType b; - ast::type::ArrayType a(&b, 4); - ast::type::ArrayType c(&a, 5); + ast::type::Bool b; + ast::type::Array a(&b, 4); + ast::type::Array c(&a, 5); ASSERT_TRUE(gen.EmitType(out, &c, "ary")) << gen.error(); EXPECT_EQ(result(), "bool ary[5][4]"); @@ -79,44 +79,44 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_ArrayOfArray) { // TODO(dsinclair): Is this possible? What order should it output in? TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_ArrayOfArrayOfRuntimeArray) { - ast::type::BoolType b; - ast::type::ArrayType a(&b, 4); - ast::type::ArrayType c(&a, 5); - ast::type::ArrayType d(&c); + ast::type::Bool b; + ast::type::Array a(&b, 4); + ast::type::Array c(&a, 5); + ast::type::Array d(&c); ASSERT_TRUE(gen.EmitType(out, &c, "ary")) << gen.error(); EXPECT_EQ(result(), "bool ary[5][4][1]"); } TEST_F(HlslGeneratorImplTest_Type, EmitType_ArrayOfArrayOfArray) { - ast::type::BoolType b; - ast::type::ArrayType a(&b, 4); - ast::type::ArrayType c(&a, 5); - ast::type::ArrayType d(&c, 6); + ast::type::Bool b; + ast::type::Array a(&b, 4); + ast::type::Array c(&a, 5); + ast::type::Array d(&c, 6); ASSERT_TRUE(gen.EmitType(out, &d, "ary")) << gen.error(); EXPECT_EQ(result(), "bool ary[6][5][4]"); } TEST_F(HlslGeneratorImplTest_Type, EmitType_Array_NameCollision) { - ast::type::BoolType b; - ast::type::ArrayType a(&b, 4); + ast::type::Bool b; + ast::type::Array a(&b, 4); ASSERT_TRUE(gen.EmitType(out, &a, "bool")) << gen.error(); EXPECT_EQ(result(), "bool bool_tint_0[4]"); } TEST_F(HlslGeneratorImplTest_Type, EmitType_Array_WithoutName) { - ast::type::BoolType b; - ast::type::ArrayType a(&b, 4); + ast::type::Bool b; + ast::type::Array a(&b, 4); ASSERT_TRUE(gen.EmitType(out, &a, "")) << gen.error(); EXPECT_EQ(result(), "bool[4]"); } TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_RuntimeArray) { - ast::type::BoolType b; - ast::type::ArrayType a(&b); + ast::type::Bool b; + ast::type::Array a(&b); ASSERT_TRUE(gen.EmitType(out, &a, "ary")) << gen.error(); EXPECT_EQ(result(), "bool ary[]"); @@ -124,37 +124,37 @@ TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_RuntimeArray) { TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_RuntimeArray_NameCollision) { - ast::type::BoolType b; - ast::type::ArrayType a(&b); + ast::type::Bool b; + ast::type::Array a(&b); ASSERT_TRUE(gen.EmitType(out, &a, "double")) << gen.error(); EXPECT_EQ(result(), "bool double_tint_0[]"); } TEST_F(HlslGeneratorImplTest_Type, EmitType_Bool) { - ast::type::BoolType b; + ast::type::Bool b; ASSERT_TRUE(gen.EmitType(out, &b, "")) << gen.error(); EXPECT_EQ(result(), "bool"); } TEST_F(HlslGeneratorImplTest_Type, EmitType_F32) { - ast::type::F32Type f32; + ast::type::F32 f32; ASSERT_TRUE(gen.EmitType(out, &f32, "")) << gen.error(); EXPECT_EQ(result(), "float"); } TEST_F(HlslGeneratorImplTest_Type, EmitType_I32) { - ast::type::I32Type i32; + ast::type::I32 i32; ASSERT_TRUE(gen.EmitType(out, &i32, "")) << gen.error(); EXPECT_EQ(result(), "int"); } TEST_F(HlslGeneratorImplTest_Type, EmitType_Matrix) { - ast::type::F32Type f32; - ast::type::MatrixType m(&f32, 3, 2); + ast::type::F32 f32; + ast::type::Matrix m(&f32, 3, 2); ASSERT_TRUE(gen.EmitType(out, &m, "")) << gen.error(); EXPECT_EQ(result(), "float3x2"); @@ -162,16 +162,16 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Matrix) { // TODO(dsinclair): How to annotate as workgroup? TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_Pointer) { - ast::type::F32Type f32; - ast::type::PointerType p(&f32, ast::StorageClass::kWorkgroup); + ast::type::F32 f32; + ast::type::Pointer p(&f32, ast::StorageClass::kWorkgroup); ASSERT_TRUE(gen.EmitType(out, &p, "")) << gen.error(); EXPECT_EQ(result(), "float*"); } TEST_F(HlslGeneratorImplTest_Type, EmitType_StructDecl) { - ast::type::I32Type i32; - ast::type::F32Type f32; + ast::type::I32 i32; + ast::type::F32 f32; ast::StructMemberList members; members.push_back( @@ -184,7 +184,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_StructDecl) { auto* str = create(); str->set_members(members); - ast::type::StructType s("S", str); + ast::type::Struct s("S", str); ASSERT_TRUE(gen.EmitStructType(out, &s, "S")) << gen.error(); EXPECT_EQ(result(), R"(struct S { @@ -195,8 +195,8 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_StructDecl) { } TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct) { - ast::type::I32Type i32; - ast::type::F32Type f32; + ast::type::I32 i32; + ast::type::F32 f32; ast::StructMemberList members; members.push_back( @@ -209,15 +209,15 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct) { auto* str = create(); str->set_members(members); - ast::type::StructType s("S", str); + ast::type::Struct s("S", str); ASSERT_TRUE(gen.EmitType(out, &s, "")) << gen.error(); EXPECT_EQ(result(), "S"); } TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_Struct_InjectPadding) { - ast::type::I32Type i32; - ast::type::F32Type f32; + ast::type::I32 i32; + ast::type::F32 f32; ast::StructMemberDecorationList decos; decos.push_back(create(4, Source{})); @@ -234,7 +234,7 @@ TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_Struct_InjectPadding) { auto* str = create(); str->set_members(members); - ast::type::StructType s("S", str); + ast::type::Struct s("S", str); ASSERT_TRUE(gen.EmitType(out, &s, "")) << gen.error(); EXPECT_EQ(result(), R"(struct { @@ -248,8 +248,8 @@ TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_Struct_InjectPadding) { } TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct_NameCollision) { - ast::type::I32Type i32; - ast::type::F32Type f32; + ast::type::I32 i32; + ast::type::F32 f32; ast::StructMemberList members; members.push_back(create( @@ -261,7 +261,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct_NameCollision) { auto* str = create(); str->set_members(members); - ast::type::StructType s("S", str); + ast::type::Struct s("S", str); ASSERT_TRUE(gen.EmitStructType(out, &s, "S")) << gen.error(); EXPECT_EQ(result(), R"(struct S { @@ -273,8 +273,8 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct_NameCollision) { // TODO(dsinclair): How to translate [[block]] TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_Struct_WithDecoration) { - ast::type::I32Type i32; - ast::type::F32Type f32; + ast::type::I32 i32; + ast::type::F32 f32; ast::StructMemberList members; members.push_back( @@ -289,7 +289,7 @@ TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_Struct_WithDecoration) { auto* str = create(decos, members); - ast::type::StructType s("S", str); + ast::type::Struct s("S", str); ASSERT_TRUE(gen.EmitStructType(out, &s, "B")) << gen.error(); EXPECT_EQ(result(), R"(struct B { @@ -299,36 +299,36 @@ TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_Struct_WithDecoration) { } TEST_F(HlslGeneratorImplTest_Type, EmitType_U32) { - ast::type::U32Type u32; + ast::type::U32 u32; ASSERT_TRUE(gen.EmitType(out, &u32, "")) << gen.error(); EXPECT_EQ(result(), "uint"); } TEST_F(HlslGeneratorImplTest_Type, EmitType_Vector) { - ast::type::F32Type f32; - ast::type::VectorType v(&f32, 3); + ast::type::F32 f32; + ast::type::Vector v(&f32, 3); ASSERT_TRUE(gen.EmitType(out, &v, "")) << gen.error(); EXPECT_EQ(result(), "float3"); } TEST_F(HlslGeneratorImplTest_Type, EmitType_Void) { - ast::type::VoidType v; + ast::type::Void v; ASSERT_TRUE(gen.EmitType(out, &v, "")) << gen.error(); EXPECT_EQ(result(), "void"); } TEST_F(HlslGeneratorImplTest_Type, EmitSampler) { - ast::type::SamplerType sampler(ast::type::SamplerKind::kSampler); + ast::type::Sampler sampler(ast::type::SamplerKind::kSampler); ASSERT_TRUE(gen.EmitType(out, &sampler, "")) << gen.error(); EXPECT_EQ(result(), "SamplerState"); } TEST_F(HlslGeneratorImplTest_Type, EmitSamplerComparison) { - ast::type::SamplerType sampler(ast::type::SamplerKind::kComparisonSampler); + ast::type::Sampler sampler(ast::type::SamplerKind::kComparisonSampler); ASSERT_TRUE(gen.EmitType(out, &sampler, "")) << gen.error(); EXPECT_EQ(result(), "SamplerComparisonState"); @@ -346,7 +346,7 @@ using HlslDepthtexturesTest = TestParamHelper; TEST_P(HlslDepthtexturesTest, Emit) { auto params = GetParam(); - ast::type::DepthTextureType s(params.dim); + ast::type::DepthTexture s(params.dim); ASSERT_TRUE(gen.EmitType(out, &s, "")) << gen.error(); EXPECT_EQ(result(), params.result); @@ -374,8 +374,8 @@ using HlslSampledtexturesTest = TestParamHelper; TEST_P(HlslSampledtexturesTest, Emit) { auto params = GetParam(); - ast::type::F32Type f32; - ast::type::SampledTextureType s(params.dim, &f32); + ast::type::F32 f32; + ast::type::SampledTexture s(params.dim, &f32); ASSERT_TRUE(gen.EmitType(out, &s, "")) << gen.error(); EXPECT_EQ(result(), params.result); @@ -396,8 +396,8 @@ INSTANTIATE_TEST_SUITE_P( "TextureCubeArray"})); TEST_F(HlslGeneratorImplTest_Type, EmitMultisampledTexture) { - ast::type::F32Type f32; - ast::type::MultisampledTextureType s(ast::type::TextureDimension::k2d, &f32); + ast::type::F32 f32; + ast::type::MultisampledTexture s(ast::type::TextureDimension::k2d, &f32); ASSERT_TRUE(gen.EmitType(out, &s, "")) << gen.error(); EXPECT_EQ(result(), "Texture2D"); @@ -417,10 +417,10 @@ using HlslStoragetexturesTest = TestParamHelper; TEST_P(HlslStoragetexturesTest, Emit) { auto params = GetParam(); - ast::type::StorageTextureType s(params.dim, - params.ro ? ast::AccessControl::kReadOnly - : ast::AccessControl::kWriteOnly, - ast::type::ImageFormat::kR16Float); + ast::type::StorageTexture s(params.dim, + params.ro ? ast::AccessControl::kReadOnly + : ast::AccessControl::kWriteOnly, + ast::type::ImageFormat::kR16Float); ASSERT_TRUE(gen.EmitType(out, &s, "")) << gen.error(); EXPECT_EQ(result(), params.result); diff --git a/src/writer/hlsl/generator_impl_variable_decl_statement_test.cc b/src/writer/hlsl/generator_impl_variable_decl_statement_test.cc index b7da41dd1e..4638cf62e8 100644 --- a/src/writer/hlsl/generator_impl_variable_decl_statement_test.cc +++ b/src/writer/hlsl/generator_impl_variable_decl_statement_test.cc @@ -33,7 +33,7 @@ namespace { using HlslGeneratorImplTest_VariableDecl = TestHelper; TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement) { - ast::type::F32Type f32; + ast::type::F32 f32; auto* var = create("a", ast::StorageClass::kNone, &f32); ast::VariableDeclStatement stmt(var); @@ -44,7 +44,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement) { } TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const) { - ast::type::F32Type f32; + ast::type::F32 f32; auto* var = create("a", ast::StorageClass::kNone, &f32); var->set_is_const(true); @@ -56,8 +56,8 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const) { } TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Array) { - ast::type::F32Type f32; - ast::type::ArrayType ary(&f32, 5); + ast::type::F32 f32; + ast::type::Array ary(&f32, 5); auto* var = create("a", ast::StorageClass::kNone, &ary); @@ -70,7 +70,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Array) { TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Function) { - ast::type::F32Type f32; + ast::type::F32 f32; auto* var = create("a", ast::StorageClass::kFunction, &f32); ast::VariableDeclStatement stmt(var); @@ -81,7 +81,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, } TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Private) { - ast::type::F32Type f32; + ast::type::F32 f32; auto* var = create("a", ast::StorageClass::kPrivate, &f32); ast::VariableDeclStatement stmt(var); @@ -95,7 +95,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Initializer_Private) { auto* ident = create("initializer"); - ast::type::F32Type f32; + ast::type::F32 f32; auto* var = create("a", ast::StorageClass::kNone, &f32); var->set_constructor(ident); @@ -107,8 +107,8 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Initializer_ZeroVec) { - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::ExpressionList values; auto* zero_vec = create(&vec, values); @@ -124,8 +124,8 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Initializer_ZeroMat) { - ast::type::F32Type f32; - ast::type::MatrixType mat(&f32, 3, 2); + ast::type::F32 f32; + ast::type::Matrix mat(&f32, 3, 2); ast::ExpressionList values; auto* zero_mat = create(&mat, values); diff --git a/src/writer/msl/generator_impl.cc b/src/writer/msl/generator_impl.cc index 4bf91101dd..76dd99707d 100644 --- a/src/writer/msl/generator_impl.cc +++ b/src/writer/msl/generator_impl.cc @@ -166,55 +166,54 @@ bool GeneratorImpl::Generate() { return true; } -uint32_t GeneratorImpl::calculate_largest_alignment( - ast::type::StructType* type) { - auto* stct = type->As()->impl(); +uint32_t GeneratorImpl::calculate_largest_alignment(ast::type::Struct* type) { + auto* stct = type->As()->impl(); uint32_t largest_alignment = 0; for (auto* mem : stct->members()) { auto align = calculate_alignment_size(mem->type()); if (align == 0) { return 0; } - if (!mem->type()->Is()) { + if (!mem->type()->Is()) { largest_alignment = std::max(largest_alignment, align); } else { largest_alignment = std::max( - largest_alignment, calculate_largest_alignment( - mem->type()->As())); + largest_alignment, + calculate_largest_alignment(mem->type()->As())); } } return largest_alignment; } uint32_t GeneratorImpl::calculate_alignment_size(ast::type::Type* type) { - if (type->Is()) { - return calculate_alignment_size(type->As()->type()); + if (type->Is()) { + return calculate_alignment_size(type->As()->type()); } - if (type->Is()) { - auto* ary = type->As(); + if (type->Is()) { + auto* ary = type->As(); // TODO(dsinclair): Handle array stride and adjust for alignment. uint32_t type_size = calculate_alignment_size(ary->type()); return ary->size() * type_size; } - if (type->Is()) { + if (type->Is()) { return 1; } - if (type->Is()) { + if (type->Is()) { return 0; } - if (type->Is() || type->Is() || - type->Is()) { + if (type->Is() || type->Is() || + type->Is()) { return 4; } - if (type->Is()) { - auto* mat = type->As(); + if (type->Is()) { + auto* mat = type->As(); // TODO(dsinclair): Handle MatrixStride // https://github.com/gpuweb/gpuweb/issues/773 uint32_t type_size = calculate_alignment_size(mat->type()); return mat->rows() * mat->columns() * type_size; } - if (type->Is()) { - auto* stct = type->As()->impl(); + if (type->Is()) { + auto* stct = type->As()->impl(); uint32_t count = 0; uint32_t largest_alignment = 0; // Offset decorations in WGSL must be in increasing order. @@ -228,12 +227,12 @@ uint32_t GeneratorImpl::calculate_alignment_size(ast::type::Type* type) { if (align == 0) { return 0; } - if (!mem->type()->Is()) { + if (!mem->type()->Is()) { largest_alignment = std::max(largest_alignment, align); } else { largest_alignment = std::max( - largest_alignment, calculate_largest_alignment( - mem->type()->As())); + largest_alignment, + calculate_largest_alignment(mem->type()->As())); } // Round up to the alignment size @@ -244,8 +243,8 @@ uint32_t GeneratorImpl::calculate_alignment_size(ast::type::Type* type) { count = adjust_for_alignment(count, largest_alignment); return count; } - if (type->Is()) { - auto* vec = type->As(); + if (type->Is()) { + auto* vec = type->As(); uint32_t type_size = calculate_alignment_size(vec->type()); if (vec->size() == 2) { return 2 * type_size; @@ -258,16 +257,16 @@ uint32_t GeneratorImpl::calculate_alignment_size(ast::type::Type* type) { bool GeneratorImpl::EmitConstructedType(const ast::type::Type* ty) { make_indent(); - if (ty->Is()) { - auto* alias = ty->As(); + if (ty->Is()) { + auto* alias = ty->As(); out_ << "typedef "; if (!EmitType(alias->type(), "")) { return false; } out_ << " " << namer_.NameFor(alias->name()) << ";" << std::endl; - } else if (ty->Is()) { - if (!EmitStructType(ty->As())) { + } else if (ty->Is()) { + if (!EmitStructType(ty->As())) { return false; } } else { @@ -522,14 +521,14 @@ bool GeneratorImpl::EmitCall(ast::CallExpression* expr) { // out_ << "("; // auto param1_type = params[1]->result_type()->UnwrapPtrIfNeeded(); - // if (!param1_type->Is()) { + // if (!param1_type->Is()) { // error_ = "invalid param type in outer_product got: " + // param1_type->type_name(); // return false; // } // for (uint32_t i = 0; i < - // param1_type->As()->size(); ++i) { + // param1_type->As()->size(); ++i) { // if (i > 0) { // out_ << ", "; // } @@ -716,7 +715,7 @@ bool GeneratorImpl::EmitTextureCall(ast::CallExpression* expr) { auto dim = params[pidx.texture] ->result_type() ->UnwrapPtrIfNeeded() - ->As() + ->As() ->dim(); switch (dim) { case ast::type::TextureDimension::k2d: @@ -798,26 +797,26 @@ std::string GeneratorImpl::generate_builtin_name( out += ident->name(); break; case ast::Intrinsic::kAbs: - if (ident->result_type()->Is()) { + if (ident->result_type()->Is()) { out += "fabs"; - } else if (ident->result_type()->Is() || - ident->result_type()->Is()) { + } else if (ident->result_type()->Is() || + ident->result_type()->Is()) { out += "abs"; } break; case ast::Intrinsic::kMax: - if (ident->result_type()->Is()) { + if (ident->result_type()->Is()) { out += "fmax"; - } else if (ident->result_type()->Is() || - ident->result_type()->Is()) { + } else if (ident->result_type()->Is() || + ident->result_type()->Is()) { out += "max"; } break; case ast::Intrinsic::kMin: - if (ident->result_type()->Is()) { + if (ident->result_type()->Is()) { out += "fmin"; - } else if (ident->result_type()->Is() || - ident->result_type()->Is()) { + } else if (ident->result_type()->Is() || + ident->result_type()->Is()) { out += "min"; } break; @@ -895,7 +894,7 @@ bool GeneratorImpl::EmitContinue(ast::ContinueStatement*) { } bool GeneratorImpl::EmitTypeConstructor(ast::TypeConstructorExpression* expr) { - if (expr->type()->Is()) { + if (expr->type()->Is()) { out_ << "{"; } else { if (!EmitType(expr->type(), "")) { @@ -924,7 +923,7 @@ bool GeneratorImpl::EmitTypeConstructor(ast::TypeConstructorExpression* expr) { } } - if (expr->type()->Is()) { + if (expr->type()->Is()) { out_ << "}"; } else { out_ << ")"; @@ -933,25 +932,25 @@ bool GeneratorImpl::EmitTypeConstructor(ast::TypeConstructorExpression* expr) { } bool GeneratorImpl::EmitZeroValue(ast::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"; - } else if (type->Is()) { + } else if (type->Is()) { out_ << "0u"; - } else if (type->Is()) { - return EmitZeroValue(type->As()->type()); - } else if (type->Is()) { - return EmitZeroValue(type->As()->type()); - } else if (type->Is()) { + } else if (type->Is()) { + return EmitZeroValue(type->As()->type()); + } else if (type->Is()) { + return EmitZeroValue(type->As()->type()); + } else if (type->Is()) { out_ << "{"; - if (!EmitZeroValue(type->As()->type())) { + if (!EmitZeroValue(type->As()->type())) { return false; } out_ << "}"; - } else if (type->Is()) { + } else if (type->Is()) { out_ << "{}"; } else { error_ = "Invalid type for zero emission: " + type->type_name(); @@ -1287,11 +1286,11 @@ bool GeneratorImpl::EmitFunctionInternal(ast::Function* func, } first = false; - if (!var->type()->Is()) { + if (!var->type()->Is()) { error_ = "invalid type for storage buffer, expected access control"; return false; } - auto* ac = var->type()->As(); + auto* ac = var->type()->As(); if (ac->IsReadOnly()) { out_ << "const "; } @@ -1313,7 +1312,7 @@ bool GeneratorImpl::EmitFunctionInternal(ast::Function* func, return false; } // Array name is output as part of the type - if (!v->type()->Is()) { + if (!v->type()->Is()) { out_ << " " << v->name(); } } @@ -1448,11 +1447,11 @@ bool GeneratorImpl::EmitEntryPointFunction(ast::Function* func) { auto* binding = data.second.binding; // auto* set = data.second.set; - if (!var->type()->Is()) { + if (!var->type()->Is()) { error_ = "invalid type for storage buffer, expected access control"; return false; } - auto* ac = var->type()->As(); + auto* ac = var->type()->As(); if (ac->IsReadOnly()) { out_ << "const "; } @@ -1794,21 +1793,21 @@ bool GeneratorImpl::EmitSwitch(ast::SwitchStatement* stmt) { } bool GeneratorImpl::EmitType(ast::type::Type* type, const std::string& name) { - if (type->Is()) { - auto* alias = type->As(); + if (type->Is()) { + auto* alias = type->As(); out_ << namer_.NameFor(alias->name()); - } else if (type->Is()) { - auto* ary = type->As(); + } else if (type->Is()) { + auto* ary = type->As(); ast::type::Type* base_type = ary; std::vector sizes; - while (base_type->Is()) { - if (base_type->As()->IsRuntimeArray()) { + while (base_type->Is()) { + if (base_type->As()->IsRuntimeArray()) { sizes.push_back(1); } else { - sizes.push_back(base_type->As()->size()); + sizes.push_back(base_type->As()->size()); } - base_type = base_type->As()->type(); + base_type = base_type->As()->type(); } if (!EmitType(base_type, "")) { return false; @@ -1819,35 +1818,35 @@ bool GeneratorImpl::EmitType(ast::type::Type* type, const std::string& name) { for (uint32_t size : sizes) { out_ << "[" << size << "]"; } - } 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_ << "int"; - } else if (type->Is()) { - auto* mat = type->As(); + } else if (type->Is()) { + auto* mat = type->As(); if (!EmitType(mat->type(), "")) { return false; } out_ << mat->columns() << "x" << mat->rows(); - } else if (type->Is()) { - auto* ptr = type->As(); + } else if (type->Is()) { + auto* ptr = type->As(); // TODO(dsinclair): Storage class? if (!EmitType(ptr->type(), "")) { return false; } out_ << "*"; - } else if (type->Is()) { + } else if (type->Is()) { out_ << "sampler"; - } else if (type->Is()) { + } else if (type->Is()) { // The struct type emits as just the name. The declaration would be emitted // as part of emitting the constructed types. - out_ << type->As()->name(); - } else if (type->Is()) { - auto* tex = type->As(); + out_ << type->As()->name(); + } else if (type->Is()) { + auto* tex = type->As(); - if (tex->Is()) { + if (tex->Is()) { out_ << "depth"; } else { out_ << "texture"; @@ -1879,14 +1878,14 @@ bool GeneratorImpl::EmitType(ast::type::Type* type, const std::string& name) { error_ = "Invalid texture dimensions"; return false; } - if (tex->Is()) { + if (tex->Is()) { out_ << "_ms"; } out_ << "<"; - if (tex->Is()) { + if (tex->Is()) { out_ << "float, access::sample"; - } else if (tex->Is()) { - auto* storage = tex->As(); + } else if (tex->Is()) { + auto* storage = tex->As(); if (!EmitType(storage->type(), "")) { return false; } @@ -1899,14 +1898,13 @@ bool GeneratorImpl::EmitType(ast::type::Type* type, const std::string& name) { error_ = "Invalid access control for storage texture"; return false; } - } else if (tex->Is()) { - if (!EmitType(tex->As()->type(), - "")) { + } else if (tex->Is()) { + if (!EmitType(tex->As()->type(), "")) { return false; } out_ << ", access::sample"; - } else if (tex->Is()) { - if (!EmitType(tex->As()->type(), "")) { + } else if (tex->Is()) { + if (!EmitType(tex->As()->type(), "")) { return false; } out_ << ", access::sample"; @@ -1916,15 +1914,15 @@ bool GeneratorImpl::EmitType(ast::type::Type* type, const std::string& name) { } out_ << ">"; - } else if (type->Is()) { + } else if (type->Is()) { out_ << "uint"; - } else if (type->Is()) { - auto* vec = type->As(); + } else if (type->Is()) { + auto* vec = type->As(); if (!EmitType(vec->type(), "")) { return false; } out_ << vec->size(); - } else if (type->Is()) { + } else if (type->Is()) { out_ << "void"; } else { error_ = "unknown type in EmitType: " + type->type_name(); @@ -1934,7 +1932,7 @@ bool GeneratorImpl::EmitType(ast::type::Type* type, const std::string& name) { return true; } -bool GeneratorImpl::EmitStructType(const ast::type::StructType* str) { +bool GeneratorImpl::EmitStructType(const ast::type::Struct* str) { // TODO(dsinclair): Block decoration? // if (str->impl()->decoration() != ast::StructDecoration::kNone) { // } @@ -1972,7 +1970,7 @@ bool GeneratorImpl::EmitStructType(const ast::type::StructType* str) { current_offset += size; // Array member name will be output with the type - if (!mem->type()->Is()) { + if (!mem->type()->Is()) { out_ << " " << namer_.NameFor(mem->name()); } out_ << ";" << std::endl; @@ -2019,7 +2017,7 @@ bool GeneratorImpl::EmitVariable(ast::Variable* var, bool skip_constructor) { if (!EmitType(var->type(), var->name())) { return false; } - if (!var->type()->Is()) { + if (!var->type()->Is()) { out_ << " " << var->name(); } @@ -2060,7 +2058,7 @@ bool GeneratorImpl::EmitProgramConstVariable(const ast::Variable* var) { if (!EmitType(var->type(), var->name())) { return false; } - if (!var->type()->Is()) { + if (!var->type()->Is()) { out_ << " " << var->name(); } diff --git a/src/writer/msl/generator_impl.h b/src/writer/msl/generator_impl.h index 2b8a687e11..a1a4ae9e70 100644 --- a/src/writer/msl/generator_impl.h +++ b/src/writer/msl/generator_impl.h @@ -70,7 +70,7 @@ class GeneratorImpl : public TextGenerator { /// Calculates the largest alignment seen within a struct /// @param type the struct to calculate /// @returns the largest alignment value - uint32_t calculate_largest_alignment(ast::type::StructType* type); + uint32_t calculate_largest_alignment(ast::type::Struct* type); /// Handles generating a constructed /// @param ty the constructed type to generate @@ -209,7 +209,7 @@ class GeneratorImpl : public TextGenerator { /// Handles generating a struct declaration /// @param str the struct to generate /// @returns true if the struct is emitted - bool EmitStructType(const ast::type::StructType* str); + bool EmitStructType(const ast::type::Struct* str); /// Handles emitting a type constructor /// @param expr the type constructor expression /// @returns true if the constructor is emitted diff --git a/src/writer/msl/generator_impl_alias_type_test.cc b/src/writer/msl/generator_impl_alias_type_test.cc index beebfc08a0..ac4b895705 100644 --- a/src/writer/msl/generator_impl_alias_type_test.cc +++ b/src/writer/msl/generator_impl_alias_type_test.cc @@ -32,8 +32,8 @@ namespace { using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, EmitConstructedType_F32) { - ast::type::F32Type f32; - ast::type::AliasType alias("a", &f32); + ast::type::F32 f32; + ast::type::Alias alias("a", &f32); ASSERT_TRUE(gen.EmitConstructedType(&alias)) << gen.error(); EXPECT_EQ(gen.result(), R"(typedef float a; @@ -41,8 +41,8 @@ TEST_F(MslGeneratorImplTest, EmitConstructedType_F32) { } TEST_F(MslGeneratorImplTest, EmitConstructedType_NameCollision) { - ast::type::F32Type f32; - ast::type::AliasType alias("float", &f32); + ast::type::F32 f32; + ast::type::Alias alias("float", &f32); ASSERT_TRUE(gen.EmitConstructedType(&alias)) << gen.error(); EXPECT_EQ(gen.result(), R"(typedef float float_tint_0; @@ -50,8 +50,8 @@ TEST_F(MslGeneratorImplTest, EmitConstructedType_NameCollision) { } TEST_F(MslGeneratorImplTest, EmitConstructedType_Struct) { - ast::type::I32Type i32; - ast::type::F32Type f32; + ast::type::I32 i32; + ast::type::F32 f32; ast::StructMemberList members; members.push_back( @@ -64,7 +64,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructedType_Struct) { auto* str = create(); str->set_members(members); - ast::type::StructType s("a", str); + ast::type::Struct s("a", str); ASSERT_TRUE(gen.EmitConstructedType(&s)) << gen.error(); EXPECT_EQ(gen.result(), R"(struct a { @@ -75,8 +75,8 @@ TEST_F(MslGeneratorImplTest, EmitConstructedType_Struct) { } TEST_F(MslGeneratorImplTest, EmitConstructedType_AliasStructIdent) { - ast::type::I32Type i32; - ast::type::F32Type f32; + ast::type::I32 i32; + ast::type::F32 f32; ast::StructMemberList members; members.push_back( @@ -89,8 +89,8 @@ TEST_F(MslGeneratorImplTest, EmitConstructedType_AliasStructIdent) { auto* str = create(); str->set_members(members); - ast::type::StructType s("b", str); - ast::type::AliasType alias("a", &s); + ast::type::Struct s("b", str); + ast::type::Alias alias("a", &s); ASSERT_TRUE(gen.EmitConstructedType(&alias)) << gen.error(); EXPECT_EQ(gen.result(), R"(typedef b a; diff --git a/src/writer/msl/generator_impl_array_accessor_test.cc b/src/writer/msl/generator_impl_array_accessor_test.cc index ee85cb9745..a584f80006 100644 --- a/src/writer/msl/generator_impl_array_accessor_test.cc +++ b/src/writer/msl/generator_impl_array_accessor_test.cc @@ -32,7 +32,7 @@ namespace { using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, EmitExpression_ArrayAccessor) { - ast::type::I32Type i32; + ast::type::I32 i32; auto* lit = create(&i32, 5); auto* idx = create(lit); auto* ary = create("ary"); diff --git a/src/writer/msl/generator_impl_bitcast_test.cc b/src/writer/msl/generator_impl_bitcast_test.cc index 82fdcabd24..d6c1546b0c 100644 --- a/src/writer/msl/generator_impl_bitcast_test.cc +++ b/src/writer/msl/generator_impl_bitcast_test.cc @@ -30,7 +30,7 @@ namespace { using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, EmitExpression_Bitcast) { - ast::type::F32Type f32; + ast::type::F32 f32; auto* id = create("id"); ast::BitcastExpression bitcast(&f32, id); diff --git a/src/writer/msl/generator_impl_call_test.cc b/src/writer/msl/generator_impl_call_test.cc index 2a369389aa..0041ed76f1 100644 --- a/src/writer/msl/generator_impl_call_test.cc +++ b/src/writer/msl/generator_impl_call_test.cc @@ -32,7 +32,7 @@ namespace { using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithoutParams) { - ast::type::VoidType void_type; + ast::type::Void void_type; auto* id = create("my_func"); ast::CallExpression call(id, {}); @@ -46,7 +46,7 @@ TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithoutParams) { } TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithParams) { - ast::type::VoidType void_type; + ast::type::Void void_type; auto* id = create("my_func"); ast::ExpressionList params; @@ -63,7 +63,7 @@ TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithParams) { } TEST_F(MslGeneratorImplTest, EmitStatement_Call) { - ast::type::VoidType void_type; + ast::type::Void void_type; auto* id = create("my_func"); ast::ExpressionList params; diff --git a/src/writer/msl/generator_impl_case_test.cc b/src/writer/msl/generator_impl_case_test.cc index 72d07a91ac..e8e2244733 100644 --- a/src/writer/msl/generator_impl_case_test.cc +++ b/src/writer/msl/generator_impl_case_test.cc @@ -33,7 +33,7 @@ namespace { using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, Emit_Case) { - ast::type::I32Type i32; + ast::type::I32 i32; auto* body = create(); body->append(create()); @@ -52,7 +52,7 @@ TEST_F(MslGeneratorImplTest, Emit_Case) { } TEST_F(MslGeneratorImplTest, Emit_Case_BreaksByDefault) { - ast::type::I32Type i32; + ast::type::I32 i32; ast::CaseSelectorList lit; lit.push_back(create(&i32, 5)); @@ -68,7 +68,7 @@ TEST_F(MslGeneratorImplTest, Emit_Case_BreaksByDefault) { } TEST_F(MslGeneratorImplTest, Emit_Case_WithFallthrough) { - ast::type::I32Type i32; + ast::type::I32 i32; auto* body = create(); body->append(create()); @@ -87,7 +87,7 @@ TEST_F(MslGeneratorImplTest, Emit_Case_WithFallthrough) { } TEST_F(MslGeneratorImplTest, Emit_Case_MultipleSelectors) { - ast::type::I32Type i32; + ast::type::I32 i32; auto* body = create(); body->append(create()); diff --git a/src/writer/msl/generator_impl_cast_test.cc b/src/writer/msl/generator_impl_cast_test.cc index 05b4fed444..22ebedf7a9 100644 --- a/src/writer/msl/generator_impl_cast_test.cc +++ b/src/writer/msl/generator_impl_cast_test.cc @@ -31,7 +31,7 @@ namespace { using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, EmitExpression_Cast_Scalar) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create("id")); @@ -43,8 +43,8 @@ TEST_F(MslGeneratorImplTest, EmitExpression_Cast_Scalar) { } TEST_F(MslGeneratorImplTest, EmitExpression_Cast_Vector) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); ast::ExpressionList params; params.push_back(create("id")); diff --git a/src/writer/msl/generator_impl_constructor_test.cc b/src/writer/msl/generator_impl_constructor_test.cc index e1160b72a3..223257a6f4 100644 --- a/src/writer/msl/generator_impl_constructor_test.cc +++ b/src/writer/msl/generator_impl_constructor_test.cc @@ -38,7 +38,7 @@ namespace { using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, EmitConstructor_Bool) { - ast::type::BoolType bool_type; + ast::type::Bool bool_type; auto* lit = create(&bool_type, false); ast::ScalarConstructorExpression expr(lit); @@ -47,7 +47,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Bool) { } TEST_F(MslGeneratorImplTest, EmitConstructor_Int) { - ast::type::I32Type i32; + ast::type::I32 i32; auto* lit = create(&i32, -12345); ast::ScalarConstructorExpression expr(lit); @@ -56,7 +56,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Int) { } TEST_F(MslGeneratorImplTest, EmitConstructor_UInt) { - ast::type::U32Type u32; + ast::type::U32 u32; auto* lit = create(&u32, 56779); ast::ScalarConstructorExpression expr(lit); @@ -65,7 +65,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_UInt) { } TEST_F(MslGeneratorImplTest, EmitConstructor_Float) { - ast::type::F32Type f32; + ast::type::F32 f32; // Use a number close to 1<<30 but whose decimal representation ends in 0. auto* lit = create(&f32, static_cast((1 << 30) - 4)); @@ -76,7 +76,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Float) { } TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Float) { - ast::type::F32Type f32; + ast::type::F32 f32; auto* lit = create(&f32, -1.2e-5); ast::ExpressionList values; @@ -89,7 +89,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Float) { } TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Bool) { - ast::type::BoolType b; + ast::type::Bool b; auto* lit = create(&b, true); ast::ExpressionList values; @@ -102,7 +102,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Bool) { } TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Int) { - ast::type::I32Type i32; + ast::type::I32 i32; auto* lit = create(&i32, -12345); ast::ExpressionList values; @@ -115,7 +115,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Int) { } TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Uint) { - ast::type::U32Type u32; + ast::type::U32 u32; auto* lit = create(&u32, 12345); ast::ExpressionList values; @@ -128,8 +128,8 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Uint) { } TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Vec) { - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); auto* lit1 = create(&f32, 1.f); auto* lit2 = create(&f32, 2.f); @@ -146,8 +146,8 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Vec) { } TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Vec_Empty) { - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::ExpressionList values; ast::TypeConstructorExpression expr(&vec, values); @@ -157,9 +157,9 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Vec_Empty) { } TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Mat) { - ast::type::F32Type f32; - ast::type::MatrixType mat(&f32, 3, 2); // 3 ROWS, 2 COLUMNS - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Matrix mat(&f32, 3, 2); // 3 ROWS, 2 COLUMNS + ast::type::Vector vec(&f32, 3); // WGSL matrix is mat2x3 (it flips for AST, sigh). With a type constructor // of @@ -192,9 +192,9 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Mat) { } TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Array) { - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); - ast::type::ArrayType ary(&vec, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); + ast::type::Array ary(&vec, 3); ast::ExpressionList ary_values; diff --git a/src/writer/msl/generator_impl_function_entry_point_data_test.cc b/src/writer/msl/generator_impl_function_entry_point_data_test.cc index 492ffc8998..d4b3f87908 100644 --- a/src/writer/msl/generator_impl_function_entry_point_data_test.cc +++ b/src/writer/msl/generator_impl_function_entry_point_data_test.cc @@ -49,8 +49,8 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Vertex_Input) { // int bar [[attribute(1)]]; // }; - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::F32 f32; + ast::type::I32 i32; auto* foo_var = create( create("foo", ast::StorageClass::kInput, &f32)); @@ -101,8 +101,8 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Vertex_Output) { // int bar [[user(locn1)]]; // }; - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::F32 f32; + ast::type::I32 i32; auto* foo_var = create( create("foo", ast::StorageClass::kOutput, &f32)); @@ -153,8 +153,8 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Fragment_Input) { // int bar [[user(locn1)]]; // }; - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::F32 f32; + ast::type::I32 i32; auto* foo_var = create( create("foo", ast::StorageClass::kInput, &f32)); @@ -204,8 +204,8 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Fragment_Output) { // int bar [[color(1)]]; // }; - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::F32 f32; + ast::type::I32 i32; auto* foo_var = create( create("foo", ast::StorageClass::kOutput, &f32)); @@ -253,8 +253,8 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Compute_Input) { // // -> Error, not allowed - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::F32 f32; + ast::type::I32 i32; auto* foo_var = create( create("foo", ast::StorageClass::kInput, &f32)); @@ -301,8 +301,8 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Compute_Output) { // // -> Error not allowed - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::F32 f32; + ast::type::I32 i32; auto* foo_var = create( create("foo", ast::StorageClass::kOutput, &f32)); @@ -354,9 +354,9 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Builtins) { // float depth [[depth(any)]]; // }; - ast::type::F32Type f32; - ast::type::VoidType void_type; - ast::type::VectorType vec4(&f32, 4); + ast::type::F32 f32; + ast::type::Void void_type; + ast::type::Vector vec4(&f32, 4); auto* coord_var = create( create("coord", ast::StorageClass::kInput, &vec4)); diff --git a/src/writer/msl/generator_impl_function_test.cc b/src/writer/msl/generator_impl_function_test.cc index a2b69695b9..51697e97be 100644 --- a/src/writer/msl/generator_impl_function_test.cc +++ b/src/writer/msl/generator_impl_function_test.cc @@ -58,7 +58,7 @@ namespace { using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, Emit_Function) { - ast::type::VoidType void_type; + ast::type::Void void_type; auto* body = create(); body->append(create()); @@ -79,7 +79,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function) { } TEST_F(MslGeneratorImplTest, Emit_Function_Name_Collision) { - ast::type::VoidType void_type; + ast::type::Void void_type; auto* body = create(); body->append(create()); @@ -100,14 +100,14 @@ TEST_F(MslGeneratorImplTest, Emit_Function_Name_Collision) { } TEST_F(MslGeneratorImplTest, Emit_Function_WithParams) { - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::F32 f32; + ast::type::I32 i32; ast::VariableList params; params.push_back(create("a", ast::StorageClass::kNone, &f32)); params.push_back(create("b", ast::StorageClass::kNone, &i32)); - ast::type::VoidType void_type; + ast::type::Void void_type; auto* body = create(); body->append(create()); @@ -127,8 +127,8 @@ TEST_F(MslGeneratorImplTest, Emit_Function_WithParams) { } TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_WithInOutVars) { - ast::type::VoidType void_type; - ast::type::F32Type f32; + ast::type::Void void_type; + ast::type::F32 f32; auto* foo_var = create( create("foo", ast::StorageClass::kInput, &f32)); @@ -181,9 +181,9 @@ fragment frag_main_out frag_main(frag_main_in tint_in [[stage_in]]) { TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_WithInOut_Builtins) { - ast::type::VoidType void_type; - ast::type::F32Type f32; - ast::type::VectorType vec4(&f32, 4); + ast::type::Void void_type; + ast::type::F32 f32; + ast::type::Vector vec4(&f32, 4); auto* coord_var = create( create("coord", ast::StorageClass::kInput, &vec4)); @@ -235,9 +235,9 @@ fragment frag_main_out frag_main(float4 coord [[position]]) { } TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_With_Uniform) { - ast::type::VoidType void_type; - ast::type::F32Type f32; - ast::type::VectorType vec4(&f32, 4); + ast::type::Void void_type; + ast::type::F32 f32; + ast::type::Vector vec4(&f32, 4); auto* coord_var = create( create("coord", ast::StorageClass::kUniform, &vec4)); @@ -282,9 +282,9 @@ fragment void frag_main(constant float4& coord [[buffer(0)]]) { TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_With_RW_StorageBuffer) { - ast::type::VoidType void_type; - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::Void void_type; + ast::type::F32 f32; + ast::type::I32 i32; ast::StructMemberList members; ast::StructMemberDecorationList a_deco; @@ -298,8 +298,8 @@ TEST_F(MslGeneratorImplTest, auto* str = create(); str->set_members(members); - ast::type::StructType s("Data", str); - ast::type::AccessControlType ac(ast::AccessControl::kReadWrite, &s); + ast::type::Struct s("Data", str); + ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); mod.AddConstructedType(&s); @@ -350,9 +350,9 @@ fragment void frag_main(device Data& coord [[buffer(0)]]) { TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_With_RO_StorageBuffer) { - ast::type::VoidType void_type; - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::Void void_type; + ast::type::F32 f32; + ast::type::I32 i32; ast::StructMemberList members; ast::StructMemberDecorationList a_deco; @@ -366,8 +366,8 @@ TEST_F(MslGeneratorImplTest, auto* str = create(); str->set_members(members); - ast::type::StructType s("Data", str); - ast::type::AccessControlType ac(ast::AccessControl::kReadOnly, &s); + ast::type::Struct s("Data", str); + ast::type::AccessControl ac(ast::AccessControl::kReadOnly, &s); mod.AddConstructedType(&s); @@ -421,8 +421,8 @@ fragment void frag_main(const device Data& coord [[buffer(0)]]) { TEST_F( MslGeneratorImplTest, Emit_FunctionDecoration_Called_By_EntryPoints_WithLocationGlobals_And_Params) { // NOLINT - ast::type::VoidType void_type; - ast::type::F32Type f32; + ast::type::Void void_type; + ast::type::F32 f32; auto* foo_var = create( create("foo", ast::StorageClass::kInput, &f32)); @@ -508,9 +508,9 @@ fragment ep_1_out ep_1(ep_1_in tint_in [[stage_in]]) { TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_Called_By_EntryPoints_NoUsedGlobals) { - ast::type::VoidType void_type; - ast::type::F32Type f32; - ast::type::VectorType vec4(&f32, 4); + ast::type::Void void_type; + ast::type::F32 f32; + ast::type::Vector vec4(&f32, 4); auto* depth_var = create( create("depth", ast::StorageClass::kOutput, &f32)); @@ -577,9 +577,9 @@ fragment ep_1_out ep_1() { TEST_F( MslGeneratorImplTest, Emit_FunctionDecoration_Called_By_EntryPoints_WithBuiltinGlobals_And_Params) { // NOLINT - ast::type::VoidType void_type; - ast::type::F32Type f32; - ast::type::VectorType vec4(&f32, 4); + ast::type::Void void_type; + ast::type::F32 f32; + ast::type::Vector vec4(&f32, 4); auto* coord_var = create( create("coord", ast::StorageClass::kInput, &vec4)); @@ -653,9 +653,9 @@ fragment ep_1_out ep_1(float4 coord [[position]]) { TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_Called_By_EntryPoint_With_Uniform) { - ast::type::VoidType void_type; - ast::type::F32Type f32; - ast::type::VectorType vec4(&f32, 4); + ast::type::Void void_type; + ast::type::F32 f32; + ast::type::Vector vec4(&f32, 4); auto* coord_var = create( create("coord", ast::StorageClass::kUniform, &vec4)); @@ -718,9 +718,9 @@ fragment void frag_main(constant float4& coord [[buffer(0)]]) { TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_Called_By_EntryPoint_With_RW_StorageBuffer) { - ast::type::VoidType void_type; - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::Void void_type; + ast::type::F32 f32; + ast::type::I32 i32; ast::StructMemberList members; ast::StructMemberDecorationList a_deco; @@ -734,8 +734,8 @@ TEST_F(MslGeneratorImplTest, auto* str = create(); str->set_members(members); - ast::type::StructType s("Data", str); - ast::type::AccessControlType ac(ast::AccessControl::kReadWrite, &s); + ast::type::Struct s("Data", str); + ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); mod.AddConstructedType(&s); @@ -805,9 +805,9 @@ fragment void frag_main(device Data& coord [[buffer(0)]]) { TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_Called_By_EntryPoint_With_RO_StorageBuffer) { - ast::type::VoidType void_type; - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::Void void_type; + ast::type::F32 f32; + ast::type::I32 i32; ast::StructMemberList members; ast::StructMemberDecorationList a_deco; @@ -821,8 +821,8 @@ TEST_F(MslGeneratorImplTest, auto* str = create(); str->set_members(members); - ast::type::StructType s("Data", str); - ast::type::AccessControlType ac(ast::AccessControl::kReadOnly, &s); + ast::type::Struct s("Data", str); + ast::type::AccessControl ac(ast::AccessControl::kReadOnly, &s); mod.AddConstructedType(&s); @@ -892,9 +892,9 @@ fragment void frag_main(const device Data& coord [[buffer(0)]]) { TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoints_WithGlobal_Nested_Return) { - ast::type::VoidType void_type; - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::Void void_type; + ast::type::F32 f32; + ast::type::I32 i32; auto* bar_var = create( create("bar", ast::StorageClass::kOutput, &f32)); @@ -953,7 +953,7 @@ fragment ep_1_out ep_1() { TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_WithNameCollision) { - ast::type::VoidType void_type; + ast::type::Void void_type; auto* func = create("main", ast::VariableList{}, &void_type, create()); @@ -972,13 +972,13 @@ kernel void main_tint_0() { } TEST_F(MslGeneratorImplTest, Emit_Function_WithArrayParams) { - ast::type::F32Type f32; - ast::type::ArrayType ary(&f32, 5); + ast::type::F32 f32; + ast::type::Array ary(&f32, 5); ast::VariableList params; params.push_back(create("a", ast::StorageClass::kNone, &ary)); - ast::type::VoidType void_type; + ast::type::Void void_type; auto* body = create(); body->append(create()); @@ -1016,8 +1016,8 @@ TEST_F(MslGeneratorImplTest, // return; // } - ast::type::VoidType void_type; - ast::type::F32Type f32; + ast::type::Void void_type; + ast::type::F32 f32; ast::StructMemberList members; ast::StructMemberDecorationList a_deco; @@ -1029,8 +1029,8 @@ TEST_F(MslGeneratorImplTest, auto* str = create(s_decos, members); - ast::type::StructType s("Data", str); - ast::type::AccessControlType ac(ast::AccessControl::kReadWrite, &s); + ast::type::Struct s("Data", str); + ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); auto* data_var = create( create("data", ast::StorageClass::kStorageBuffer, &ac)); diff --git a/src/writer/msl/generator_impl_import_test.cc b/src/writer/msl/generator_impl_import_test.cc index ef5428de21..c6c1d57fd0 100644 --- a/src/writer/msl/generator_impl_import_test.cc +++ b/src/writer/msl/generator_impl_import_test.cc @@ -52,7 +52,7 @@ using MslImportData_SingleParamTest = TestParamHelper; TEST_P(MslImportData_SingleParamTest, FloatScalar) { auto param = GetParam(); - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( @@ -95,7 +95,7 @@ INSTANTIATE_TEST_SUITE_P(MslGeneratorImplTest, MslImportData{"trunc", "trunc"})); TEST_F(MslGeneratorImplTest, MslImportData_SingleParamTest_IntScalar) { - ast::type::I32Type i32; + ast::type::I32 i32; ast::ExpressionList params; params.push_back(create( @@ -113,7 +113,7 @@ using MslImportData_DualParamTest = TestParamHelper; TEST_P(MslImportData_DualParamTest, FloatScalar) { auto param = GetParam(); - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( @@ -143,8 +143,8 @@ using MslImportData_DualParam_VectorTest = TestParamHelper; TEST_P(MslImportData_DualParam_VectorTest, FloatVector) { auto param = GetParam(); - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::ExpressionList type_params; @@ -186,7 +186,7 @@ using MslImportData_DualParam_Int_Test = TestParamHelper; TEST_P(MslImportData_DualParam_Int_Test, IntScalar) { auto param = GetParam(); - ast::type::I32Type i32; + ast::type::I32 i32; ast::ExpressionList params; params.push_back(create( @@ -210,7 +210,7 @@ using MslImportData_TripleParamTest = TestParamHelper; TEST_P(MslImportData_TripleParamTest, FloatScalar) { auto param = GetParam(); - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create( @@ -241,7 +241,7 @@ using MslImportData_TripleParam_Int_Test = TestParamHelper; TEST_P(MslImportData_TripleParam_Int_Test, IntScalar) { auto param = GetParam(); - ast::type::I32Type i32; + ast::type::I32 i32; ast::ExpressionList params; params.push_back(create( @@ -265,8 +265,8 @@ INSTANTIATE_TEST_SUITE_P(MslGeneratorImplTest, MslImportData{"clamp", "clamp"})); TEST_F(MslGeneratorImplTest, MslImportData_Determinant) { - ast::type::F32Type f32; - ast::type::MatrixType mat(&f32, 3, 3); + ast::type::F32 f32; + ast::type::Matrix mat(&f32, 3, 3); auto* var = create("var", ast::StorageClass::kFunction, &mat); diff --git a/src/writer/msl/generator_impl_intrinsic_test.cc b/src/writer/msl/generator_impl_intrinsic_test.cc index 2bd7dbe730..f4d1b76e79 100644 --- a/src/writer/msl/generator_impl_intrinsic_test.cc +++ b/src/writer/msl/generator_impl_intrinsic_test.cc @@ -67,9 +67,9 @@ INSTANTIATE_TEST_SUITE_P( IntrinsicData{ast::Intrinsic::kSelect, "select"})); TEST_F(MslGeneratorImplTest, DISABLED_Intrinsic_OuterProduct) { - ast::type::F32Type f32; - ast::type::VectorType vec2(&f32, 2); - ast::type::VectorType vec3(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec2(&f32, 2); + ast::type::Vector vec3(&f32, 3); auto* a = create("a", ast::StorageClass::kNone, &vec2); auto* b = create("b", ast::StorageClass::kNone, &vec3); @@ -100,8 +100,8 @@ TEST_F(MslGeneratorImplTest, Intrinsic_Bad_Name) { } TEST_F(MslGeneratorImplTest, Intrinsic_Call) { - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::ExpressionList params; params.push_back(create("param1")); diff --git a/src/writer/msl/generator_impl_intrinsic_texture_test.cc b/src/writer/msl/generator_impl_intrinsic_texture_test.cc index c8079da894..f38e3aad62 100644 --- a/src/writer/msl/generator_impl_intrinsic_texture_test.cc +++ b/src/writer/msl/generator_impl_intrinsic_texture_test.cc @@ -170,17 +170,17 @@ TEST_P(MslGeneratorIntrinsicTextureTest, Call) { break; } - ast::type::SamplerType sampler_type{param.sampler_kind}; + ast::type::Sampler sampler_type{param.sampler_kind}; switch (param.texture_kind) { case ast::intrinsic::test::TextureKind::kRegular: Var("texture", ast::StorageClass::kNone, - mod->create(param.texture_dimension, - datatype)); + mod->create(param.texture_dimension, + datatype)); break; case ast::intrinsic::test::TextureKind::kDepth: Var("texture", ast::StorageClass::kNone, - mod->create(param.texture_dimension)); + mod->create(param.texture_dimension)); break; } diff --git a/src/writer/msl/generator_impl_loop_test.cc b/src/writer/msl/generator_impl_loop_test.cc index 46741e096e..bd46e637b7 100644 --- a/src/writer/msl/generator_impl_loop_test.cc +++ b/src/writer/msl/generator_impl_loop_test.cc @@ -77,7 +77,7 @@ TEST_F(MslGeneratorImplTest, Emit_LoopWithContinuing) { } TEST_F(MslGeneratorImplTest, Emit_LoopNestedWithContinuing) { - ast::type::F32Type f32; + ast::type::F32 f32; auto* body = create(); body->append(create()); @@ -147,7 +147,7 @@ TEST_F(MslGeneratorImplTest, Emit_LoopWithVarUsedInContinuing) { // } // } - ast::type::F32Type f32; + ast::type::F32 f32; auto* var = create("lhs", ast::StorageClass::kFunction, &f32); var->set_constructor(create( diff --git a/src/writer/msl/generator_impl_module_constant_test.cc b/src/writer/msl/generator_impl_module_constant_test.cc index 6c7b99772c..ae03c77cea 100644 --- a/src/writer/msl/generator_impl_module_constant_test.cc +++ b/src/writer/msl/generator_impl_module_constant_test.cc @@ -36,8 +36,8 @@ namespace { using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, Emit_ModuleConstant) { - ast::type::F32Type f32; - ast::type::ArrayType ary(&f32, 3); + ast::type::F32 f32; + ast::type::Array ary(&f32, 3); ast::ExpressionList exprs; exprs.push_back(create( @@ -56,7 +56,7 @@ TEST_F(MslGeneratorImplTest, Emit_ModuleConstant) { } TEST_F(MslGeneratorImplTest, Emit_SpecConstant) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::VariableDecorationList decos; decos.push_back(create(23, Source{})); diff --git a/src/writer/msl/generator_impl_switch_test.cc b/src/writer/msl/generator_impl_switch_test.cc index 25546b77db..88dd603062 100644 --- a/src/writer/msl/generator_impl_switch_test.cc +++ b/src/writer/msl/generator_impl_switch_test.cc @@ -37,7 +37,7 @@ TEST_F(MslGeneratorImplTest, Emit_Switch) { def_body->append(create()); auto* def = create(def_body); - ast::type::I32Type i32; + ast::type::I32 i32; ast::CaseSelectorList case_val; case_val.push_back(create(&i32, 5)); diff --git a/src/writer/msl/generator_impl_test.cc b/src/writer/msl/generator_impl_test.cc index e97b033341..15f488a278 100644 --- a/src/writer/msl/generator_impl_test.cc +++ b/src/writer/msl/generator_impl_test.cc @@ -48,7 +48,7 @@ namespace { using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, Generate) { - ast::type::VoidType void_type; + ast::type::Void void_type; auto* func = create("my_func", ast::VariableList{}, &void_type, create()); @@ -114,47 +114,47 @@ INSTANTIATE_TEST_SUITE_P( "thread_position_in_grid"})); TEST_F(MslGeneratorImplTest, calculate_alignment_size_alias) { - ast::type::F32Type f32; - ast::type::AliasType alias("a", &f32); + ast::type::F32 f32; + ast::type::Alias alias("a", &f32); EXPECT_EQ(4u, gen.calculate_alignment_size(&alias)); } TEST_F(MslGeneratorImplTest, calculate_alignment_size_array) { - ast::type::F32Type f32; - ast::type::ArrayType ary(&f32, 4); + ast::type::F32 f32; + ast::type::Array ary(&f32, 4); EXPECT_EQ(4u * 4u, gen.calculate_alignment_size(&ary)); } TEST_F(MslGeneratorImplTest, calculate_alignment_size_bool) { - ast::type::BoolType bool_type; + ast::type::Bool bool_type; EXPECT_EQ(1u, gen.calculate_alignment_size(&bool_type)); } TEST_F(MslGeneratorImplTest, calculate_alignment_size_f32) { - ast::type::F32Type f32; + ast::type::F32 f32; EXPECT_EQ(4u, gen.calculate_alignment_size(&f32)); } TEST_F(MslGeneratorImplTest, calculate_alignment_size_i32) { - ast::type::I32Type i32; + ast::type::I32 i32; EXPECT_EQ(4u, gen.calculate_alignment_size(&i32)); } TEST_F(MslGeneratorImplTest, calculate_alignment_size_matrix) { - ast::type::F32Type f32; - ast::type::MatrixType mat(&f32, 3, 2); + ast::type::F32 f32; + ast::type::Matrix mat(&f32, 3, 2); EXPECT_EQ(4u * 3u * 2u, gen.calculate_alignment_size(&mat)); } TEST_F(MslGeneratorImplTest, calculate_alignment_size_pointer) { - ast::type::BoolType bool_type; - ast::type::PointerType ptr(&bool_type, ast::StorageClass::kPrivate); + ast::type::Bool bool_type; + ast::type::Pointer ptr(&bool_type, ast::StorageClass::kPrivate); EXPECT_EQ(0u, gen.calculate_alignment_size(&ptr)); } TEST_F(MslGeneratorImplTest, calculate_alignment_size_struct) { - ast::type::I32Type i32; - ast::type::F32Type f32; + ast::type::I32 i32; + ast::type::F32 f32; ast::StructMemberDecorationList decos; decos.push_back(create(4, Source{})); @@ -171,15 +171,15 @@ TEST_F(MslGeneratorImplTest, calculate_alignment_size_struct) { auto* str = create(); str->set_members(members); - ast::type::StructType s("S", str); + ast::type::Struct s("S", str); EXPECT_EQ(132u, gen.calculate_alignment_size(&s)); } TEST_F(MslGeneratorImplTest, calculate_alignment_size_struct_of_struct) { - ast::type::I32Type i32; - ast::type::F32Type f32; - ast::type::VectorType fvec(&f32, 3); + ast::type::I32 i32; + ast::type::F32 f32; + ast::type::Vector fvec(&f32, 3); ast::StructMemberDecorationList decos; decos.push_back(create(0, Source{})); @@ -196,7 +196,7 @@ TEST_F(MslGeneratorImplTest, calculate_alignment_size_struct_of_struct) { auto* inner_str = create(); inner_str->set_members(members); - ast::type::StructType inner_s("Inner", inner_str); + ast::type::Struct inner_s("Inner", inner_str); decos.push_back(create(0, Source{})); members.push_back(create("d", &f32, decos)); @@ -210,13 +210,13 @@ TEST_F(MslGeneratorImplTest, calculate_alignment_size_struct_of_struct) { auto* outer_str = create(); outer_str->set_members(members); - ast::type::StructType outer_s("Outer", outer_str); + ast::type::Struct outer_s("Outer", outer_str); EXPECT_EQ(80u, gen.calculate_alignment_size(&outer_s)); } TEST_F(MslGeneratorImplTest, calculate_alignment_size_u32) { - ast::type::U32Type u32; + ast::type::U32 u32; EXPECT_EQ(4u, gen.calculate_alignment_size(&u32)); } @@ -232,8 +232,8 @@ using MslVectorSizeBoolTest = TestParamHelper; TEST_P(MslVectorSizeBoolTest, calculate) { auto param = GetParam(); - ast::type::BoolType bool_type; - ast::type::VectorType vec(&bool_type, param.elements); + ast::type::Bool bool_type; + ast::type::Vector vec(&bool_type, param.elements); EXPECT_EQ(param.byte_size, gen.calculate_alignment_size(&vec)); } INSTANTIATE_TEST_SUITE_P(MslGeneratorImplTest, @@ -246,8 +246,8 @@ using MslVectorSizeI32Test = TestParamHelper; TEST_P(MslVectorSizeI32Test, calculate) { auto param = GetParam(); - ast::type::I32Type i32; - ast::type::VectorType vec(&i32, param.elements); + ast::type::I32 i32; + ast::type::Vector vec(&i32, param.elements); EXPECT_EQ(param.byte_size, gen.calculate_alignment_size(&vec)); } INSTANTIATE_TEST_SUITE_P(MslGeneratorImplTest, @@ -260,8 +260,8 @@ using MslVectorSizeU32Test = TestParamHelper; TEST_P(MslVectorSizeU32Test, calculate) { auto param = GetParam(); - ast::type::U32Type u32; - ast::type::VectorType vec(&u32, param.elements); + ast::type::U32 u32; + ast::type::Vector vec(&u32, param.elements); EXPECT_EQ(param.byte_size, gen.calculate_alignment_size(&vec)); } INSTANTIATE_TEST_SUITE_P(MslGeneratorImplTest, @@ -274,8 +274,8 @@ using MslVectorSizeF32Test = TestParamHelper; TEST_P(MslVectorSizeF32Test, calculate) { auto param = GetParam(); - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, param.elements); + ast::type::F32 f32; + ast::type::Vector vec(&f32, param.elements); EXPECT_EQ(param.byte_size, gen.calculate_alignment_size(&vec)); } INSTANTIATE_TEST_SUITE_P(MslGeneratorImplTest, diff --git a/src/writer/msl/generator_impl_type_test.cc b/src/writer/msl/generator_impl_type_test.cc index 49f0399c53..02340e93f1 100644 --- a/src/writer/msl/generator_impl_type_test.cc +++ b/src/writer/msl/generator_impl_type_test.cc @@ -48,33 +48,33 @@ namespace { using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, EmitType_Alias) { - ast::type::F32Type f32; - ast::type::AliasType alias("alias", &f32); + ast::type::F32 f32; + ast::type::Alias alias("alias", &f32); ASSERT_TRUE(gen.EmitType(&alias, "")) << gen.error(); EXPECT_EQ(gen.result(), "alias"); } TEST_F(MslGeneratorImplTest, EmitType_Alias_NameCollision) { - ast::type::F32Type f32; - ast::type::AliasType alias("bool", &f32); + ast::type::F32 f32; + ast::type::Alias alias("bool", &f32); ASSERT_TRUE(gen.EmitType(&alias, "")) << gen.error(); EXPECT_EQ(gen.result(), "bool_tint_0"); } TEST_F(MslGeneratorImplTest, EmitType_Array) { - ast::type::BoolType b; - ast::type::ArrayType a(&b, 4); + ast::type::Bool b; + ast::type::Array a(&b, 4); ASSERT_TRUE(gen.EmitType(&a, "ary")) << gen.error(); EXPECT_EQ(gen.result(), "bool ary[4]"); } TEST_F(MslGeneratorImplTest, EmitType_ArrayOfArray) { - ast::type::BoolType b; - ast::type::ArrayType a(&b, 4); - ast::type::ArrayType c(&a, 5); + ast::type::Bool b; + ast::type::Array a(&b, 4); + ast::type::Array c(&a, 5); ASSERT_TRUE(gen.EmitType(&c, "ary")) << gen.error(); EXPECT_EQ(gen.result(), "bool ary[5][4]"); @@ -82,81 +82,81 @@ TEST_F(MslGeneratorImplTest, EmitType_ArrayOfArray) { // TODO(dsinclair): Is this possible? What order should it output in? TEST_F(MslGeneratorImplTest, DISABLED_EmitType_ArrayOfArrayOfRuntimeArray) { - ast::type::BoolType b; - ast::type::ArrayType a(&b, 4); - ast::type::ArrayType c(&a, 5); - ast::type::ArrayType d(&c); + ast::type::Bool b; + ast::type::Array a(&b, 4); + ast::type::Array c(&a, 5); + ast::type::Array d(&c); ASSERT_TRUE(gen.EmitType(&c, "ary")) << gen.error(); EXPECT_EQ(gen.result(), "bool ary[5][4][1]"); } TEST_F(MslGeneratorImplTest, EmitType_ArrayOfArrayOfArray) { - ast::type::BoolType b; - ast::type::ArrayType a(&b, 4); - ast::type::ArrayType c(&a, 5); - ast::type::ArrayType d(&c, 6); + ast::type::Bool b; + ast::type::Array a(&b, 4); + ast::type::Array c(&a, 5); + ast::type::Array d(&c, 6); ASSERT_TRUE(gen.EmitType(&d, "ary")) << gen.error(); EXPECT_EQ(gen.result(), "bool ary[6][5][4]"); } TEST_F(MslGeneratorImplTest, EmitType_Array_NameCollision) { - ast::type::BoolType b; - ast::type::ArrayType a(&b, 4); + ast::type::Bool b; + ast::type::Array a(&b, 4); ASSERT_TRUE(gen.EmitType(&a, "bool")) << gen.error(); EXPECT_EQ(gen.result(), "bool bool_tint_0[4]"); } TEST_F(MslGeneratorImplTest, EmitType_Array_WithoutName) { - ast::type::BoolType b; - ast::type::ArrayType a(&b, 4); + ast::type::Bool b; + ast::type::Array a(&b, 4); ASSERT_TRUE(gen.EmitType(&a, "")) << gen.error(); EXPECT_EQ(gen.result(), "bool[4]"); } TEST_F(MslGeneratorImplTest, EmitType_RuntimeArray) { - ast::type::BoolType b; - ast::type::ArrayType a(&b); + ast::type::Bool b; + ast::type::Array a(&b); ASSERT_TRUE(gen.EmitType(&a, "ary")) << gen.error(); EXPECT_EQ(gen.result(), "bool ary[1]"); } TEST_F(MslGeneratorImplTest, EmitType_RuntimeArray_NameCollision) { - ast::type::BoolType b; - ast::type::ArrayType a(&b); + ast::type::Bool b; + ast::type::Array a(&b); ASSERT_TRUE(gen.EmitType(&a, "discard_fragment")) << gen.error(); EXPECT_EQ(gen.result(), "bool discard_fragment_tint_0[1]"); } TEST_F(MslGeneratorImplTest, EmitType_Bool) { - ast::type::BoolType b; + ast::type::Bool b; ASSERT_TRUE(gen.EmitType(&b, "")) << gen.error(); EXPECT_EQ(gen.result(), "bool"); } TEST_F(MslGeneratorImplTest, EmitType_F32) { - ast::type::F32Type f32; + ast::type::F32 f32; ASSERT_TRUE(gen.EmitType(&f32, "")) << gen.error(); EXPECT_EQ(gen.result(), "float"); } TEST_F(MslGeneratorImplTest, EmitType_I32) { - ast::type::I32Type i32; + ast::type::I32 i32; ASSERT_TRUE(gen.EmitType(&i32, "")) << gen.error(); EXPECT_EQ(gen.result(), "int"); } TEST_F(MslGeneratorImplTest, EmitType_Matrix) { - ast::type::F32Type f32; - ast::type::MatrixType m(&f32, 3, 2); + ast::type::F32 f32; + ast::type::Matrix m(&f32, 3, 2); ASSERT_TRUE(gen.EmitType(&m, "")) << gen.error(); EXPECT_EQ(gen.result(), "float2x3"); @@ -164,16 +164,16 @@ TEST_F(MslGeneratorImplTest, EmitType_Matrix) { // TODO(dsinclair): How to annotate as workgroup? TEST_F(MslGeneratorImplTest, DISABLED_EmitType_Pointer) { - ast::type::F32Type f32; - ast::type::PointerType p(&f32, ast::StorageClass::kWorkgroup); + ast::type::F32 f32; + ast::type::Pointer p(&f32, ast::StorageClass::kWorkgroup); ASSERT_TRUE(gen.EmitType(&p, "")) << gen.error(); EXPECT_EQ(gen.result(), "float*"); } TEST_F(MslGeneratorImplTest, EmitType_Struct) { - ast::type::I32Type i32; - ast::type::F32Type f32; + ast::type::I32 i32; + ast::type::F32 f32; ast::StructMemberList members; members.push_back( @@ -186,15 +186,15 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct) { auto* str = create(); str->set_members(members); - ast::type::StructType s("S", str); + ast::type::Struct s("S", str); ASSERT_TRUE(gen.EmitType(&s, "")) << gen.error(); EXPECT_EQ(gen.result(), "S"); } TEST_F(MslGeneratorImplTest, EmitType_StructDecl) { - ast::type::I32Type i32; - ast::type::F32Type f32; + ast::type::I32 i32; + ast::type::F32 f32; ast::StructMemberList members; members.push_back( @@ -207,7 +207,7 @@ TEST_F(MslGeneratorImplTest, EmitType_StructDecl) { auto* str = create(); str->set_members(members); - ast::type::StructType s("S", str); + ast::type::Struct s("S", str); ASSERT_TRUE(gen.EmitStructType(&s)) << gen.error(); EXPECT_EQ(gen.result(), R"(struct S { @@ -218,8 +218,8 @@ TEST_F(MslGeneratorImplTest, EmitType_StructDecl) { } TEST_F(MslGeneratorImplTest, EmitType_Struct_InjectPadding) { - ast::type::I32Type i32; - ast::type::F32Type f32; + ast::type::I32 i32; + ast::type::F32 f32; auto* str = create(); str->set_members({ @@ -237,7 +237,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_InjectPadding) { create(128, Source{})}), }); - ast::type::StructType s("S", str); + ast::type::Struct s("S", str); ASSERT_TRUE(gen.EmitStructType(&s)) << gen.error(); EXPECT_EQ(gen.result(), R"(struct S { @@ -252,8 +252,8 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_InjectPadding) { } TEST_F(MslGeneratorImplTest, EmitType_Struct_NameCollision) { - ast::type::I32Type i32; - ast::type::F32Type f32; + ast::type::I32 i32; + ast::type::F32 f32; ast::StructMemberList members; members.push_back(create( @@ -265,7 +265,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_NameCollision) { auto* str = create(); str->set_members(members); - ast::type::StructType s("S", str); + ast::type::Struct s("S", str); ASSERT_TRUE(gen.EmitStructType(&s)) << gen.error(); EXPECT_EQ(gen.result(), R"(struct S { @@ -277,8 +277,8 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_NameCollision) { // TODO(dsinclair): How to translate [[block]] TEST_F(MslGeneratorImplTest, DISABLED_EmitType_Struct_WithDecoration) { - ast::type::I32Type i32; - ast::type::F32Type f32; + ast::type::I32 i32; + ast::type::F32 f32; ast::StructMemberList members; members.push_back( @@ -292,7 +292,7 @@ TEST_F(MslGeneratorImplTest, DISABLED_EmitType_Struct_WithDecoration) { decos.push_back(create(Source{})); auto* str = create(decos, members); - ast::type::StructType s("S", str); + ast::type::Struct s("S", str); ASSERT_TRUE(gen.EmitType(&s, "")) << gen.error(); EXPECT_EQ(gen.result(), R"(struct { @@ -302,36 +302,36 @@ TEST_F(MslGeneratorImplTest, DISABLED_EmitType_Struct_WithDecoration) { } TEST_F(MslGeneratorImplTest, EmitType_U32) { - ast::type::U32Type u32; + ast::type::U32 u32; ASSERT_TRUE(gen.EmitType(&u32, "")) << gen.error(); EXPECT_EQ(gen.result(), "uint"); } TEST_F(MslGeneratorImplTest, EmitType_Vector) { - ast::type::F32Type f32; - ast::type::VectorType v(&f32, 3); + ast::type::F32 f32; + ast::type::Vector v(&f32, 3); ASSERT_TRUE(gen.EmitType(&v, "")) << gen.error(); EXPECT_EQ(gen.result(), "float3"); } TEST_F(MslGeneratorImplTest, EmitType_Void) { - ast::type::VoidType v; + ast::type::Void v; ASSERT_TRUE(gen.EmitType(&v, "")) << gen.error(); EXPECT_EQ(gen.result(), "void"); } TEST_F(MslGeneratorImplTest, EmitType_Sampler) { - ast::type::SamplerType sampler(ast::type::SamplerKind::kSampler); + ast::type::Sampler sampler(ast::type::SamplerKind::kSampler); ASSERT_TRUE(gen.EmitType(&sampler, "")) << gen.error(); EXPECT_EQ(gen.result(), "sampler"); } TEST_F(MslGeneratorImplTest, EmitType_SamplerComparison) { - ast::type::SamplerType sampler(ast::type::SamplerKind::kComparisonSampler); + ast::type::Sampler sampler(ast::type::SamplerKind::kComparisonSampler); ASSERT_TRUE(gen.EmitType(&sampler, "")) << gen.error(); EXPECT_EQ(gen.result(), "sampler"); @@ -349,7 +349,7 @@ using MslDepthTexturesTest = TestParamHelper; TEST_P(MslDepthTexturesTest, Emit) { auto params = GetParam(); - ast::type::DepthTextureType s(params.dim); + ast::type::DepthTexture s(params.dim); ASSERT_TRUE(gen.EmitType(&s, "")) << gen.error(); EXPECT_EQ(gen.result(), params.result); @@ -379,8 +379,8 @@ using MslSampledtexturesTest = TestParamHelper; TEST_P(MslSampledtexturesTest, Emit) { auto params = GetParam(); - ast::type::F32Type f32; - ast::type::SampledTextureType s(params.dim, &f32); + ast::type::F32 f32; + ast::type::SampledTexture s(params.dim, &f32); ASSERT_TRUE(gen.EmitType(&s, "")) << gen.error(); EXPECT_EQ(gen.result(), params.result); @@ -405,8 +405,8 @@ INSTANTIATE_TEST_SUITE_P( "texturecube_array"})); TEST_F(MslGeneratorImplTest, Emit_TypeMultisampledTexture) { - ast::type::U32Type u32; - ast::type::MultisampledTextureType s(ast::type::TextureDimension::k2d, &u32); + ast::type::U32 u32; + ast::type::MultisampledTexture s(ast::type::TextureDimension::k2d, &u32); ASSERT_TRUE(gen.EmitType(&s, "")) << gen.error(); EXPECT_EQ(gen.result(), "texture2d_ms"); @@ -425,10 +425,10 @@ using MslStorageTexturesTest = TestParamHelper; TEST_P(MslStorageTexturesTest, Emit) { auto params = GetParam(); - ast::type::StorageTextureType s(params.dim, - params.ro ? ast::AccessControl::kReadOnly - : ast::AccessControl::kWriteOnly, - ast::type::ImageFormat::kR16Float); + ast::type::StorageTexture s(params.dim, + params.ro ? ast::AccessControl::kReadOnly + : ast::AccessControl::kWriteOnly, + ast::type::ImageFormat::kR16Float); ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error(); ASSERT_TRUE(gen.EmitType(&s, "")) << gen.error(); diff --git a/src/writer/msl/generator_impl_variable_decl_statement_test.cc b/src/writer/msl/generator_impl_variable_decl_statement_test.cc index f0ec7a0e51..315dfa5cae 100644 --- a/src/writer/msl/generator_impl_variable_decl_statement_test.cc +++ b/src/writer/msl/generator_impl_variable_decl_statement_test.cc @@ -41,7 +41,7 @@ namespace { using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement) { - ast::type::F32Type f32; + ast::type::F32 f32; auto* var = create("a", ast::StorageClass::kNone, &f32); ast::VariableDeclStatement stmt(var); @@ -53,7 +53,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement) { } TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Const) { - ast::type::F32Type f32; + ast::type::F32 f32; auto* var = create("a", ast::StorageClass::kNone, &f32); var->set_is_const(true); @@ -66,8 +66,8 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Const) { } TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Array) { - ast::type::F32Type f32; - ast::type::ArrayType ary(&f32, 5); + ast::type::F32 f32; + ast::type::Array ary(&f32, 5); auto* var = create("a", ast::StorageClass::kNone, &ary); @@ -80,7 +80,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Array) { } TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Struct) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::StructMemberList members; members.push_back( @@ -93,7 +93,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Struct) { auto* str = create(); str->set_members(members); - ast::type::StructType s("S", str); + ast::type::Struct s("S", str); auto* var = create("a", ast::StorageClass::kNone, &s); @@ -107,8 +107,8 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Struct) { } TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Vector) { - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 2); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 2); auto* var = create("a", ast::StorageClass::kFunction, &vec); @@ -121,8 +121,8 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Vector) { } TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Matrix) { - ast::type::F32Type f32; - ast::type::MatrixType mat(&f32, 2, 3); + ast::type::F32 f32; + ast::type::Matrix mat(&f32, 2, 3); auto* var = create("a", ast::StorageClass::kFunction, &mat); ast::VariableDeclStatement stmt(var); @@ -134,7 +134,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Matrix) { } TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Private) { - ast::type::F32Type f32; + ast::type::F32 f32; auto* var = create("a", ast::StorageClass::kPrivate, &f32); ast::VariableDeclStatement stmt(var); @@ -148,7 +148,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Private) { TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Initializer_Private) { auto* ident = create("initializer"); - ast::type::F32Type f32; + ast::type::F32 f32; auto* var = create("a", ast::StorageClass::kNone, &f32); var->set_constructor(ident); @@ -160,8 +160,8 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Initializer_Private) { } TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Initializer_ZeroVec) { - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::ExpressionList values; auto* zero_vec = create(&vec, values); diff --git a/src/writer/pack_coord_arrayidx.cc b/src/writer/pack_coord_arrayidx.cc index 6fb9b6d72e..051f0a9f4f 100644 --- a/src/writer/pack_coord_arrayidx.cc +++ b/src/writer/pack_coord_arrayidx.cc @@ -30,7 +30,7 @@ ast::TypeConstructorExpression* AsVectorConstructor(ast::Expression* expr) { if (type_constructor == nullptr) { return nullptr; } - if (!type_constructor->type()->Is()) { + if (!type_constructor->type()->Is()) { return nullptr; } return type_constructor; @@ -44,8 +44,8 @@ bool PackCoordAndArrayIndex( std::function callback) { uint32_t packed_size; ast::type::Type* packed_el_ty; // Currenly must be f32. - if (coords->result_type()->Is()) { - auto* vec = coords->result_type()->As(); + if (coords->result_type()->Is()) { + auto* vec = coords->result_type()->As(); packed_size = vec->size() + 1; packed_el_ty = vec->type(); } else { @@ -61,7 +61,7 @@ bool PackCoordAndArrayIndex( ast::TypeConstructorExpression array_index_cast(packed_el_ty, {array_idx}); array_index_cast.set_result_type(packed_el_ty); - ast::type::VectorType packed_ty(packed_el_ty, packed_size); + ast::type::Vector packed_ty(packed_el_ty, packed_size); // If the coordinates are already passed in a vector constructor, extract // the elements into the new vector instead of nesting a vector-in-vector. diff --git a/src/writer/spirv/builder.cc b/src/writer/spirv/builder.cc index 08f9eab14f..1527776a2a 100644 --- a/src/writer/spirv/builder.cc +++ b/src/writer/spirv/builder.cc @@ -151,12 +151,12 @@ uint32_t IndexFromName(char name) { /// one or more levels of an arrays inside of |type|. /// @param type the given type, which must not be null /// @returns the nested matrix type, or nullptr if none -ast::type::MatrixType* GetNestedMatrixType(ast::type::Type* type) { - while (type->Is()) { - type = type->As()->type(); +ast::type::Matrix* GetNestedMatrixType(ast::type::Type* type) { + while (type->Is()) { + type = type->As()->type(); } - return type->Is() ? type->As() - : nullptr; + return type->Is() ? type->As() + : nullptr; } uint32_t intrinsic_to_glsl_method(ast::type::Type* type, @@ -378,7 +378,7 @@ void Builder::GenerateLabel(uint32_t id) { } uint32_t Builder::GenerateU32Literal(uint32_t val) { - ast::type::U32Type u32; + ast::type::U32 u32; ast::SintLiteral lit(&u32, val); return GenerateLiteralIfNeeded(nullptr, &lit); } @@ -634,7 +634,7 @@ bool Builder::GenerateFunctionVariable(ast::Variable* var) { auto result = result_op(); auto var_id = result.to_i(); auto sc = ast::StorageClass::kFunction; - ast::type::PointerType pt(var->type(), sc); + ast::type::Pointer pt(var->type(), sc); auto type_id = GenerateTypeIfNeeded(&pt); if (type_id == 0) { return false; @@ -705,7 +705,7 @@ bool Builder::GenerateGlobalVariable(ast::Variable* var) { ? ast::StorageClass::kPrivate : var->storage_class(); - ast::type::PointerType pt(var->type(), sc); + ast::type::Pointer pt(var->type(), sc); auto type_id = GenerateTypeIfNeeded(&pt); if (type_id == 0) { return false; @@ -721,10 +721,10 @@ bool Builder::GenerateGlobalVariable(ast::Variable* var) { Operand::Int(ConvertStorageClass(sc))}; if (var->has_constructor()) { ops.push_back(Operand::Int(init_id)); - } else if (type->Is()) { + } else if (type->Is()) { // Decorate storage texture variables with NonRead/Writeable if needed. - if (type->Is()) { - switch (type->As()->access()) { + if (type->Is()) { + switch (type->As()->access()) { case ast::AccessControl::kWriteOnly: push_annot( spv::Op::OpDecorate, @@ -739,7 +739,7 @@ bool Builder::GenerateGlobalVariable(ast::Variable* var) { break; } } - } else if (!type->Is()) { + } else if (!type->Is()) { // Certain cases require us to generate a constructor value. // // 1- ConstantId's must be attached to the OpConstant, if we have a @@ -749,16 +749,16 @@ bool Builder::GenerateGlobalVariable(ast::Variable* var) { // then WGSL requires an initializer. if (var->Is() && var->As()->HasConstantIdDecoration()) { - if (type->Is()) { + if (type->Is()) { ast::FloatLiteral l(type, 0.0f); init_id = GenerateLiteralIfNeeded(var, &l); - } else if (type->Is()) { + } else if (type->Is()) { ast::UintLiteral l(type, 0); init_id = GenerateLiteralIfNeeded(var, &l); - } else if (type->Is()) { + } else if (type->Is()) { ast::SintLiteral l(type, 0); init_id = GenerateLiteralIfNeeded(var, &l); - } else if (type->Is()) { + } else if (type->Is()) { ast::BoolLiteral l(type, false); init_id = GenerateLiteralIfNeeded(var, &l); } else { @@ -825,9 +825,9 @@ bool Builder::GenerateArrayAccessor(ast::ArrayAccessorExpression* expr, // If the source is a pointer we access chain into it. We also access chain // into an array of non-scalar types. - if (info->source_type->Is() || - (info->source_type->Is() && - !info->source_type->As()->type()->is_scalar())) { + if (info->source_type->Is() || + (info->source_type->Is() && + !info->source_type->As()->type()->is_scalar())) { info->access_chain_indices.push_back(idx_id); info->source_type = expr->result_type(); return true; @@ -859,15 +859,15 @@ bool Builder::GenerateMemberAccessor(ast::MemberAccessorExpression* expr, // If the data_type is a structure we're accessing a member, if it's a // vector we're accessing a swizzle. - if (data_type->Is()) { - if (!info->source_type->Is()) { + if (data_type->Is()) { + if (!info->source_type->Is()) { error_ = "Attempting to access a struct member on a non-pointer. Something is " "wrong"; return false; } - auto* strct = data_type->As()->impl(); + auto* strct = data_type->As()->impl(); auto name = expr->member()->name(); uint32_t i = 0; @@ -887,7 +887,7 @@ bool Builder::GenerateMemberAccessor(ast::MemberAccessorExpression* expr, return true; } - if (!data_type->Is()) { + if (!data_type->Is()) { error_ = "Member accessor without a struct or vector. Something is wrong"; return false; } @@ -901,7 +901,7 @@ bool Builder::GenerateMemberAccessor(ast::MemberAccessorExpression* expr, return false; } - if (info->source_type->Is()) { + if (info->source_type->Is()) { auto idx_id = GenerateU32Literal(val); if (idx_id == 0) { return 0; @@ -1015,10 +1015,10 @@ uint32_t Builder::GenerateAccessorExpression(ast::Expression* expr) { if (auto* array = accessors[0]->As()) { auto* ary_res_type = array->array()->result_type(); - if (!ary_res_type->Is() && - (ary_res_type->Is() && - !ary_res_type->As()->type()->is_scalar())) { - ast::type::PointerType ptr(ary_res_type, ast::StorageClass::kFunction); + if (!ary_res_type->Is() && + (ary_res_type->Is() && + !ary_res_type->As()->type()->is_scalar())) { + ast::type::Pointer ptr(ary_res_type, ast::StorageClass::kFunction); auto result_type_id = GenerateTypeIfNeeded(&ptr); if (result_type_id == 0) { return 0; @@ -1093,7 +1093,7 @@ uint32_t Builder::GenerateIdentifierExpression( } uint32_t Builder::GenerateLoadIfNeeded(ast::type::Type* type, uint32_t id) { - if (!type->Is()) { + if (!type->Is()) { return id; } @@ -1197,7 +1197,7 @@ bool Builder::is_constructor_const(ast::Expression* expr, bool is_global_init) { return false; } - if (result_type->Is() && + if (result_type->Is() && !e->Is()) { return false; } @@ -1209,14 +1209,14 @@ bool Builder::is_constructor_const(ast::Expression* expr, bool is_global_init) { auto* sc = e->As(); ast::type::Type* subtype = result_type->UnwrapAll(); - if (subtype->Is()) { - subtype = subtype->As()->type()->UnwrapAll(); - } else if (subtype->Is()) { - subtype = subtype->As()->type()->UnwrapAll(); - } else if (subtype->Is()) { - subtype = subtype->As()->type()->UnwrapAll(); - } else if (subtype->Is()) { - subtype = subtype->As() + if (subtype->Is()) { + subtype = subtype->As()->type()->UnwrapAll(); + } else if (subtype->Is()) { + subtype = subtype->As()->type()->UnwrapAll(); + } else if (subtype->Is()) { + subtype = subtype->As()->type()->UnwrapAll(); + } else if (subtype->Is()) { + subtype = subtype->As() ->impl() ->members()[i] ->type() @@ -1251,14 +1251,14 @@ uint32_t Builder::GenerateTypeConstructorExpression( bool can_cast_or_copy = result_type->is_scalar(); - if (result_type->Is() && - result_type->As()->type()->is_scalar()) { + if (result_type->Is() && + result_type->As()->type()->is_scalar()) { auto* value_type = values[0]->result_type()->UnwrapAll(); can_cast_or_copy = - (value_type->Is() && - value_type->As()->type()->is_scalar() && - result_type->As()->size() == - value_type->As()->size()); + (value_type->Is() && + value_type->As()->type()->is_scalar() && + result_type->As()->size() == + value_type->As()->size()); } if (can_cast_or_copy) { return GenerateCastOrCopyOrPassthrough(result_type, values[0]); @@ -1272,8 +1272,8 @@ uint32_t Builder::GenerateTypeConstructorExpression( bool result_is_constant_composite = constructor_is_const; bool result_is_spec_composite = false; - if (result_type->Is()) { - result_type = result_type->As()->type(); + if (result_type->Is()) { + result_type = result_type->As()->type(); } OperandList ops; @@ -1294,9 +1294,9 @@ uint32_t Builder::GenerateTypeConstructorExpression( // If the result and value types are the same we can just use the object. // If the result is not a vector then we should have validated that the // value type is a correctly sized vector so we can just use it directly. - if (result_type == value_type || result_type->Is() || - result_type->Is() || - result_type->Is()) { + if (result_type == value_type || result_type->Is() || + result_type->Is() || + result_type->Is()) { out << "_" << id; ops.push_back(Operand::Int(id)); @@ -1321,8 +1321,8 @@ uint32_t Builder::GenerateTypeConstructorExpression( // // For cases 1 and 2, if the type is different we also may need to insert // a type cast. - if (value_type->Is()) { - auto* vec = value_type->As(); + if (value_type->Is()) { + auto* vec = value_type->As(); auto* vec_type = vec->type(); auto value_type_id = GenerateTypeIfNeeded(vec_type); @@ -1408,40 +1408,38 @@ uint32_t Builder::GenerateCastOrCopyOrPassthrough(ast::type::Type* to_type, auto* from_type = from_expr->result_type()->UnwrapPtrIfNeeded(); spv::Op op = spv::Op::OpNop; - if ((from_type->Is() && - to_type->Is()) || + if ((from_type->Is() && to_type->Is()) || (from_type->is_signed_integer_vector() && to_type->is_float_vector())) { op = spv::Op::OpConvertSToF; - } else if ((from_type->Is() && - to_type->Is()) || + } else if ((from_type->Is() && + to_type->Is()) || (from_type->is_unsigned_integer_vector() && to_type->is_float_vector())) { op = spv::Op::OpConvertUToF; - } else if ((from_type->Is() && - to_type->Is()) || + } else if ((from_type->Is() && + to_type->Is()) || (from_type->is_float_vector() && to_type->is_signed_integer_vector())) { op = spv::Op::OpConvertFToS; - } else if ((from_type->Is() && - to_type->Is()) || + } else if ((from_type->Is() && + to_type->Is()) || (from_type->is_float_vector() && to_type->is_unsigned_integer_vector())) { op = spv::Op::OpConvertFToU; - } else if ((from_type->Is() && - to_type->Is()) || - (from_type->Is() && - to_type->Is()) || - (from_type->Is() && - to_type->Is()) || - (from_type->Is() && - to_type->Is()) || - (from_type->Is() && - (from_type == to_type))) { + } else if ((from_type->Is() && + to_type->Is()) || + (from_type->Is() && + to_type->Is()) || + (from_type->Is() && + to_type->Is()) || + (from_type->Is() && + to_type->Is()) || + (from_type->Is() && (from_type == to_type))) { return val_id; - } 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() && @@ -1829,7 +1827,7 @@ uint32_t Builder::GenerateIntrinsic(ast::IdentifierExpression* ident, error_ = "missing param for runtime array length"; return 0; } else if (!call->params()[0]->Is()) { - if (call->params()[0]->result_type()->Is()) { + if (call->params()[0]->result_type()->Is()) { error_ = "pointer accessors not supported yet"; } else { error_ = "invalid accessor for runtime array length"; @@ -1844,14 +1842,14 @@ uint32_t Builder::GenerateIntrinsic(ast::IdentifierExpression* ident, params.push_back(Operand::Int(struct_id)); auto* type = accessor->structure()->result_type()->UnwrapAll(); - if (!type->Is()) { + if (!type->Is()) { error_ = "invalid type (" + type->type_name() + ") for runtime array length"; return 0; } // Runtime array must be the last member in the structure - params.push_back(Operand::Int(uint32_t( - type->As()->impl()->members().size() - 1))); + params.push_back(Operand::Int( + uint32_t(type->As()->impl()->members().size() - 1))); push_function_inst(spv::Op::OpArrayLength, params); return result_id; @@ -1933,10 +1931,8 @@ void Builder::GenerateTextureIntrinsic(ast::IdentifierExpression* ident, ast::CallExpression* call, spirv::Operand result_type, spirv::Operand result_id) { - auto* texture_type = call->params()[0] - ->result_type() - ->UnwrapAll() - ->As(); + auto* texture_type = + call->params()[0]->result_type()->UnwrapAll()->As(); auto* sig = static_cast( ident->intrinsic_signature()); @@ -1971,16 +1967,15 @@ void Builder::GenerateTextureIntrinsic(ast::IdentifierExpression* ident, spirv_operands.reserve(4); // Enough to fit most parameter lists if (ident->intrinsic() == ast::Intrinsic::kTextureLoad) { - op = texture_type->Is() - ? spv::Op::OpImageRead - : spv::Op::OpImageFetch; + op = texture_type->Is() ? spv::Op::OpImageRead + : spv::Op::OpImageFetch; spirv_params.emplace_back(gen_param(pidx.texture)); spirv_params.emplace_back(gen_param(pidx.coords)); // TODO(dsinclair): Remove the LOD param from textureLoad on storage // textures when https://github.com/gpuweb/gpuweb/pull/1032 gets merged. if (pidx.level != kNotUsed) { - if (texture_type->Is()) { + if (texture_type->Is()) { spirv_operand_mask |= SpvImageOperandsSampleMask; } else { spirv_operand_mask |= SpvImageOperandsLodMask; @@ -2053,7 +2048,7 @@ void Builder::GenerateTextureIntrinsic(ast::IdentifierExpression* ident, spirv_params.emplace_back(gen_param(pidx.depth_ref)); spirv_operand_mask |= SpvImageOperandsLodMask; - ast::type::F32Type f32; + ast::type::F32 f32; ast::FloatLiteral float_0(&f32, 0.0); spirv_operands.emplace_back( Operand::Int(GenerateLiteralIfNeeded(nullptr, &float_0))); @@ -2418,8 +2413,8 @@ uint32_t Builder::GenerateTypeIfNeeded(ast::type::Type* type) { } // The alias is a wrapper around the subtype, so emit the subtype - if (type->Is()) { - return GenerateTypeIfNeeded(type->As()->type()); + if (type->Is()) { + return GenerateTypeIfNeeded(type->As()->type()); } auto val = type_name_to_id_.find(type->type_name()); @@ -2430,53 +2425,53 @@ uint32_t Builder::GenerateTypeIfNeeded(ast::type::Type* type) { auto result = result_op(); auto id = result.to_i(); - if (type->Is()) { - auto* ac = type->As(); + if (type->Is()) { + auto* ac = type->As(); auto* subtype = ac->type()->UnwrapIfNeeded(); - if (!subtype->Is()) { + if (!subtype->Is()) { error_ = "Access control attached to non-struct type."; return 0; } - if (!GenerateStructType(subtype->As(), + if (!GenerateStructType(subtype->As(), ac->access_control(), result)) { return 0; } - } else if (type->Is()) { - if (!GenerateArrayType(type->As(), result)) { + } else if (type->Is()) { + if (!GenerateArray(type->As(), result)) { return 0; } - } else if (type->Is()) { + } else if (type->Is()) { push_type(spv::Op::OpTypeBool, {result}); - } else if (type->Is()) { + } else if (type->Is()) { push_type(spv::Op::OpTypeFloat, {result, Operand::Int(32)}); - } else if (type->Is()) { + } else if (type->Is()) { push_type(spv::Op::OpTypeInt, {result, Operand::Int(32), Operand::Int(1)}); - } else if (type->Is()) { - if (!GenerateMatrixType(type->As(), result)) { + } else if (type->Is()) { + if (!GenerateMatrixType(type->As(), result)) { return 0; } - } else if (type->Is()) { - if (!GeneratePointerType(type->As(), result)) { + } else if (type->Is()) { + if (!GeneratePointerType(type->As(), result)) { return 0; } - } else if (type->Is()) { - if (!GenerateStructType(type->As(), + } else if (type->Is()) { + if (!GenerateStructType(type->As(), ast::AccessControl::kReadWrite, result)) { return 0; } - } else if (type->Is()) { + } else if (type->Is()) { push_type(spv::Op::OpTypeInt, {result, Operand::Int(32), Operand::Int(0)}); - } else if (type->Is()) { - if (!GenerateVectorType(type->As(), result)) { + } else if (type->Is()) { + if (!GenerateVectorType(type->As(), result)) { return 0; } - } else if (type->Is()) { + } else if (type->Is()) { push_type(spv::Op::OpTypeVoid, {result}); - } else if (type->Is()) { - if (!GenerateTextureType(type->As(), result)) { + } else if (type->Is()) { + if (!GenerateTextureType(type->As(), result)) { return 0; } - } else if (type->Is()) { + } else if (type->Is()) { push_type(spv::Op::OpTypeSampler, {result}); // Register both of the sampler type names. In SPIR-V they're the same @@ -2494,7 +2489,7 @@ uint32_t Builder::GenerateTypeIfNeeded(ast::type::Type* type) { } // TODO(tommek): Cover multisampled textures here when they're included in AST -bool Builder::GenerateTextureType(ast::type::TextureType* texture, +bool Builder::GenerateTextureType(ast::type::Texture* texture, const Operand& result) { uint32_t array_literal = 0u; const auto dim = texture->dim(); @@ -2508,10 +2503,10 @@ bool Builder::GenerateTextureType(ast::type::TextureType* texture, if (dim == ast::type::TextureDimension::k1dArray || dim == ast::type::TextureDimension::k1d) { dim_literal = SpvDim1D; - if (texture->Is()) { + if (texture->Is()) { push_capability(SpvCapabilitySampled1D); } else { - assert(texture->Is()); + assert(texture->Is()); push_capability(SpvCapabilityImage1D); } } @@ -2524,47 +2519,47 @@ bool Builder::GenerateTextureType(ast::type::TextureType* texture, } uint32_t ms_literal = 0u; - if (texture->Is()) { + if (texture->Is()) { ms_literal = 1u; } uint32_t depth_literal = 0u; - if (texture->Is()) { + if (texture->Is()) { depth_literal = 1u; } uint32_t sampled_literal = 2u; - if (texture->Is() || - texture->Is() || - texture->Is()) { + if (texture->Is() || + texture->Is() || + texture->Is()) { sampled_literal = 1u; } if (dim == ast::type::TextureDimension::kCubeArray) { - if (texture->Is() || - texture->Is()) { + if (texture->Is() || + texture->Is()) { push_capability(SpvCapabilitySampledCubeArray); } } uint32_t type_id = 0u; - if (texture->Is()) { - ast::type::F32Type f32; + if (texture->Is()) { + ast::type::F32 f32; type_id = GenerateTypeIfNeeded(&f32); - } else if (texture->Is()) { + } else if (texture->Is()) { + type_id = + GenerateTypeIfNeeded(texture->As()->type()); + } else if (texture->Is()) { type_id = GenerateTypeIfNeeded( - texture->As()->type()); - } else if (texture->Is()) { - type_id = GenerateTypeIfNeeded( - texture->As()->type()); - } else if (texture->Is()) { - if (texture->As()->access() == + texture->As()->type()); + } else if (texture->Is()) { + if (texture->As()->access() == ast::AccessControl::kWriteOnly) { - ast::type::VoidType void_type; + ast::type::Void void_type; type_id = GenerateTypeIfNeeded(&void_type); } else { type_id = GenerateTypeIfNeeded( - texture->As()->type()); + texture->As()->type()); } } if (type_id == 0u) { @@ -2572,9 +2567,9 @@ bool Builder::GenerateTextureType(ast::type::TextureType* texture, } uint32_t format_literal = SpvImageFormat_::SpvImageFormatUnknown; - if (texture->Is()) { + if (texture->Is()) { format_literal = convert_image_format_to_spv( - texture->As()->image_format()); + texture->As()->image_format()); } push_type(spv::Op::OpTypeImage, @@ -2586,8 +2581,7 @@ bool Builder::GenerateTextureType(ast::type::TextureType* texture, return true; } -bool Builder::GenerateArrayType(ast::type::ArrayType* ary, - const Operand& result) { +bool Builder::GenerateArray(ast::type::Array* ary, const Operand& result) { auto elem_type = GenerateTypeIfNeeded(ary->type()); if (elem_type == 0) { return false; @@ -2614,9 +2608,9 @@ bool Builder::GenerateArrayType(ast::type::ArrayType* ary, return true; } -bool Builder::GenerateMatrixType(ast::type::MatrixType* mat, +bool Builder::GenerateMatrixType(ast::type::Matrix* mat, const Operand& result) { - ast::type::VectorType col_type(mat->type(), mat->rows()); + ast::type::Vector col_type(mat->type(), mat->rows()); auto col_type_id = GenerateTypeIfNeeded(&col_type); if (has_error()) { return false; @@ -2627,7 +2621,7 @@ bool Builder::GenerateMatrixType(ast::type::MatrixType* mat, return true; } -bool Builder::GeneratePointerType(ast::type::PointerType* ptr, +bool Builder::GeneratePointerType(ast::type::Pointer* ptr, const Operand& result) { auto pointee_id = GenerateTypeIfNeeded(ptr->type()); if (pointee_id == 0) { @@ -2646,7 +2640,7 @@ bool Builder::GeneratePointerType(ast::type::PointerType* ptr, return true; } -bool Builder::GenerateStructType(ast::type::StructType* struct_type, +bool Builder::GenerateStructType(ast::type::Struct* struct_type, ast::AccessControl access_control, const Operand& result) { auto struct_id = result.to_i(); @@ -2721,7 +2715,7 @@ uint32_t Builder::GenerateStructMember(uint32_t struct_id, push_annot(spv::Op::OpMemberDecorate, {Operand::Int(struct_id), Operand::Int(idx), Operand::Int(SpvDecorationColMajor)}); - if (!matrix_type->type()->Is()) { + if (!matrix_type->type()->Is()) { error_ = "matrix scalar element type must be f32"; return 0; } @@ -2737,7 +2731,7 @@ uint32_t Builder::GenerateStructMember(uint32_t struct_id, return GenerateTypeIfNeeded(member->type()); } -bool Builder::GenerateVectorType(ast::type::VectorType* vec, +bool Builder::GenerateVectorType(ast::type::Vector* vec, const Operand& result) { auto type_id = GenerateTypeIfNeeded(vec->type()); if (has_error()) { diff --git a/src/writer/spirv/builder.h b/src/writer/spirv/builder.h index d78a9a262b..0b3203689a 100644 --- a/src/writer/spirv/builder.h +++ b/src/writer/spirv/builder.h @@ -426,29 +426,28 @@ class Builder { /// @param texture the texture to generate /// @param result the result operand /// @returns true if the texture was successfully generated - bool GenerateTextureType(ast::type::TextureType* texture, - const Operand& result); + bool GenerateTextureType(ast::type::Texture* texture, const Operand& result); /// Generates an array type declaration /// @param ary the array to generate /// @param result the result operand /// @returns true if the array was successfully generated - bool GenerateArrayType(ast::type::ArrayType* ary, const Operand& result); + bool GenerateArray(ast::type::Array* ary, const Operand& result); /// Generates a matrix type declaration /// @param mat the matrix to generate /// @param result the result operand /// @returns true if the matrix was successfully generated - bool GenerateMatrixType(ast::type::MatrixType* mat, const Operand& result); + bool GenerateMatrixType(ast::type::Matrix* mat, const Operand& result); /// Generates a pointer type declaration /// @param ptr the pointer type to generate /// @param result the result operand /// @returns true if the pointer was successfully generated - bool GeneratePointerType(ast::type::PointerType* ptr, const Operand& result); + bool GeneratePointerType(ast::type::Pointer* ptr, const Operand& result); /// Generates a vector type declaration /// @param struct_type the vector to generate /// @param access_control the access controls to assign to the struct /// @param result the result operand /// @returns true if the vector was successfully generated - bool GenerateStructType(ast::type::StructType* struct_type, + bool GenerateStructType(ast::type::Struct* struct_type, ast::AccessControl access_control, const Operand& result); /// Generates a struct member @@ -467,7 +466,7 @@ class Builder { /// @param vec the vector to generate /// @param result the result operand /// @returns true if the vector was successfully generated - bool GenerateVectorType(ast::type::VectorType* vec, const Operand& result); + bool GenerateVectorType(ast::type::Vector* vec, const Operand& result); /// Converts AST image format to SPIR-V and pushes an appropriate capability. /// @param format AST image format type diff --git a/src/writer/spirv/builder_accessor_expression_test.cc b/src/writer/spirv/builder_accessor_expression_test.cc index 15c5987ebb..2f22a1dcea 100644 --- a/src/writer/spirv/builder_accessor_expression_test.cc +++ b/src/writer/spirv/builder_accessor_expression_test.cc @@ -47,9 +47,9 @@ namespace { using BuilderTest = TestHelper; TEST_F(BuilderTest, ArrayAccessor) { - ast::type::I32Type i32; - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); + ast::type::I32 i32; + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); // vec3 ary; // ary[1] -> ptr @@ -87,9 +87,9 @@ TEST_F(BuilderTest, ArrayAccessor) { } TEST_F(BuilderTest, Accessor_Array_LoadIndex) { - ast::type::I32Type i32; - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); + ast::type::I32 i32; + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); // ary : vec3; // idx : i32; @@ -133,9 +133,9 @@ TEST_F(BuilderTest, Accessor_Array_LoadIndex) { } TEST_F(BuilderTest, ArrayAccessor_Dynamic) { - ast::type::I32Type i32; - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); + ast::type::I32 i32; + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); // vec3 ary; // ary[1 + 2] -> ptr @@ -179,10 +179,10 @@ TEST_F(BuilderTest, ArrayAccessor_Dynamic) { } TEST_F(BuilderTest, ArrayAccessor_MultiLevel) { - ast::type::I32Type i32; - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); - ast::type::ArrayType ary4(&vec3, 4); + ast::type::I32 i32; + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); + ast::type::Array ary4(&vec3, 4); // ary = array, 4> // ary[3][2]; @@ -226,10 +226,10 @@ TEST_F(BuilderTest, ArrayAccessor_MultiLevel) { } TEST_F(BuilderTest, Accessor_ArrayWithSwizzle) { - ast::type::I32Type i32; - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); - ast::type::ArrayType ary4(&vec3, 4); + ast::type::I32 i32; + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); + ast::type::Array ary4(&vec3, 4); // var a : array, 4>; // a[2].xy; @@ -273,7 +273,7 @@ TEST_F(BuilderTest, Accessor_ArrayWithSwizzle) { } TEST_F(BuilderTest, MemberAccessor) { - ast::type::F32Type f32; + ast::type::F32 f32; // my_struct { // a : f32 @@ -288,7 +288,7 @@ TEST_F(BuilderTest, MemberAccessor) { members.push_back(create("b", &f32, decos)); auto* s = create(members); - ast::type::StructType s_type("my_struct", s); + ast::type::Struct s_type("my_struct", s); ast::Variable var("ident", ast::StorageClass::kFunction, &s_type); @@ -320,7 +320,7 @@ TEST_F(BuilderTest, MemberAccessor) { } TEST_F(BuilderTest, MemberAccessor_Nested) { - ast::type::F32Type f32; + ast::type::F32 f32; // inner_struct { // a : f32 @@ -336,14 +336,13 @@ TEST_F(BuilderTest, MemberAccessor_Nested) { inner_members.push_back(create("a", &f32, decos)); inner_members.push_back(create("b", &f32, decos)); - ast::type::StructType inner_struct("Inner", - create(inner_members)); + ast::type::Struct inner_struct("Inner", create(inner_members)); ast::StructMemberList outer_members; outer_members.push_back( create("inner", &inner_struct, decos)); - ast::type::StructType s_type("my_struct", create(outer_members)); + ast::type::Struct s_type("my_struct", create(outer_members)); ast::Variable var("ident", ast::StorageClass::kFunction, &s_type); @@ -379,7 +378,7 @@ TEST_F(BuilderTest, MemberAccessor_Nested) { } TEST_F(BuilderTest, MemberAccessor_Nested_WithAlias) { - ast::type::F32Type f32; + ast::type::F32 f32; // type Inner = struct { // a : f32 @@ -396,15 +395,14 @@ TEST_F(BuilderTest, MemberAccessor_Nested_WithAlias) { inner_members.push_back(create("a", &f32, decos)); inner_members.push_back(create("b", &f32, decos)); - ast::type::StructType inner_struct("Inner", - create(inner_members)); + ast::type::Struct inner_struct("Inner", create(inner_members)); - ast::type::AliasType alias("Inner", &inner_struct); + ast::type::Alias alias("Inner", &inner_struct); ast::StructMemberList outer_members; outer_members.push_back(create("inner", &alias, decos)); - ast::type::StructType s_type("Outer", create(outer_members)); + ast::type::Struct s_type("Outer", create(outer_members)); ast::Variable var("ident", ast::StorageClass::kFunction, &s_type); @@ -440,7 +438,7 @@ TEST_F(BuilderTest, MemberAccessor_Nested_WithAlias) { } TEST_F(BuilderTest, MemberAccessor_Nested_Assignment_LHS) { - ast::type::F32Type f32; + ast::type::F32 f32; // inner_struct { // a : f32 @@ -457,14 +455,13 @@ TEST_F(BuilderTest, MemberAccessor_Nested_Assignment_LHS) { inner_members.push_back(create("a", &f32, decos)); inner_members.push_back(create("b", &f32, decos)); - ast::type::StructType inner_struct("Inner", - create(inner_members)); + ast::type::Struct inner_struct("Inner", create(inner_members)); ast::StructMemberList outer_members; outer_members.push_back( create("inner", &inner_struct, decos)); - ast::type::StructType s_type("my_struct", create(outer_members)); + ast::type::Struct s_type("my_struct", create(outer_members)); ast::Variable var("ident", ast::StorageClass::kFunction, &s_type); @@ -507,7 +504,7 @@ OpStore %10 %11 } TEST_F(BuilderTest, MemberAccessor_Nested_Assignment_RHS) { - ast::type::F32Type f32; + ast::type::F32 f32; // inner_struct { // a : f32 @@ -524,14 +521,13 @@ TEST_F(BuilderTest, MemberAccessor_Nested_Assignment_RHS) { inner_members.push_back(create("a", &f32, decos)); inner_members.push_back(create("b", &f32, decos)); - ast::type::StructType inner_struct("Inner", - create(inner_members)); + ast::type::Struct inner_struct("Inner", create(inner_members)); ast::StructMemberList outer_members; outer_members.push_back( create("inner", &inner_struct, decos)); - ast::type::StructType s_type("my_struct", create(outer_members)); + ast::type::Struct s_type("my_struct", create(outer_members)); ast::Variable var("ident", ast::StorageClass::kFunction, &s_type); ast::Variable store("store", ast::StorageClass::kFunction, &f32); @@ -578,8 +574,8 @@ OpStore %7 %13 } TEST_F(BuilderTest, MemberAccessor_Swizzle_Single) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); // ident.y @@ -613,8 +609,8 @@ TEST_F(BuilderTest, MemberAccessor_Swizzle_Single) { } TEST_F(BuilderTest, MemberAccessor_Swizzle_MultipleNames) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); // ident.yx @@ -647,8 +643,8 @@ TEST_F(BuilderTest, MemberAccessor_Swizzle_MultipleNames) { } TEST_F(BuilderTest, MemberAccessor_Swizzle_of_Swizzle) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); // ident.yxz.xz @@ -685,8 +681,8 @@ TEST_F(BuilderTest, MemberAccessor_Swizzle_of_Swizzle) { } TEST_F(BuilderTest, MemberAccessor_Member_of_Swizzle) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); // ident.yxz.x @@ -722,9 +718,9 @@ TEST_F(BuilderTest, MemberAccessor_Member_of_Swizzle) { } TEST_F(BuilderTest, MemberAccessor_Array_of_Swizzle) { - ast::type::I32Type i32; - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); + ast::type::I32 i32; + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); // index.yxz[1] @@ -763,9 +759,9 @@ TEST_F(BuilderTest, MemberAccessor_Array_of_Swizzle) { } TEST_F(BuilderTest, Accessor_Mixed_ArrayAndMember) { - ast::type::I32Type i32; - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); + ast::type::I32 i32; + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); // type C = struct { // baz : vec3 @@ -783,19 +779,19 @@ TEST_F(BuilderTest, Accessor_Mixed_ArrayAndMember) { auto* s = create( ast::StructMemberList{create("baz", &vec3, decos)}); - ast::type::StructType c_type("C", s); + ast::type::Struct c_type("C", s); s = create( ast::StructMemberList{create("bar", &c_type, decos)}); - ast::type::StructType b_type("B", s); + ast::type::Struct b_type("B", s); - ast::type::ArrayType b_ary_type(&b_type, 3); + ast::type::Array b_ary_type(&b_type, 3); s = create(ast::StructMemberList{ create("foo", &b_ary_type, decos)}); - ast::type::StructType a_type("A", s); + ast::type::Struct a_type("A", s); - ast::type::ArrayType a_ary_type(&a_type, 2); + ast::type::Array a_ary_type(&a_type, 2); ast::Variable var("index", ast::StorageClass::kFunction, &a_ary_type); @@ -859,10 +855,10 @@ TEST_F(BuilderTest, Accessor_Array_Of_Vec) { // vec2(0.5, -0.5)); // pos[1] - ast::type::F32Type f32; - ast::type::U32Type u32; - ast::type::VectorType vec(&f32, 2); - ast::type::ArrayType arr(&vec, 3); + ast::type::F32 f32; + ast::type::U32 u32; + ast::type::Vector vec(&f32, 2); + ast::type::Array arr(&vec, 3); ast::ExpressionList ary_params; ary_params.push_back(create( @@ -935,9 +931,9 @@ TEST_F(BuilderTest, Accessor_Const_Vec) { // const pos : vec2 = vec2(0.0, 0.5); // pos[1] - ast::type::F32Type f32; - ast::type::U32Type u32; - ast::type::VectorType vec(&f32, 2); + ast::type::F32 f32; + ast::type::U32 u32; + ast::type::Vector vec(&f32, 2); ast::ExpressionList vec_params; vec_params.push_back(create( diff --git a/src/writer/spirv/builder_assign_test.cc b/src/writer/spirv/builder_assign_test.cc index b2a574e96a..7698c5f918 100644 --- a/src/writer/spirv/builder_assign_test.cc +++ b/src/writer/spirv/builder_assign_test.cc @@ -43,7 +43,7 @@ namespace { using BuilderTest = TestHelper; TEST_F(BuilderTest, Assign_Var) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::Variable v("var", ast::StorageClass::kOutput, &f32); @@ -76,8 +76,8 @@ TEST_F(BuilderTest, Assign_Var) { } TEST_F(BuilderTest, Assign_Var_ZeroConstructor) { - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::Variable v("var", ast::StorageClass::kOutput, &vec); @@ -110,9 +110,9 @@ TEST_F(BuilderTest, Assign_Var_ZeroConstructor) { } TEST_F(BuilderTest, Assign_Var_Complex_ConstructorWithExtract) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); - ast::type::VectorType vec2(&f32, 2); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); + ast::type::Vector vec2(&f32, 2); auto* first = create( &vec2, ast::ExpressionList{ @@ -164,8 +164,8 @@ OpStore %1 %13 } TEST_F(BuilderTest, Assign_Var_Complex_Constructor) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); ast::ExpressionList vals; vals.push_back(create( @@ -207,7 +207,7 @@ TEST_F(BuilderTest, Assign_Var_Complex_Constructor) { } TEST_F(BuilderTest, Assign_StructMember) { - ast::type::F32Type f32; + ast::type::F32 f32; // my_struct { // a : f32 @@ -222,7 +222,7 @@ TEST_F(BuilderTest, Assign_StructMember) { members.push_back(create("b", &f32, decos)); auto* s = create(members); - ast::type::StructType s_type("my_struct", s); + ast::type::Struct s_type("my_struct", s); ast::Variable v("ident", ast::StorageClass::kFunction, &s_type); @@ -263,8 +263,8 @@ OpStore %8 %9 } TEST_F(BuilderTest, Assign_Vector) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); ast::Variable v("var", ast::StorageClass::kOutput, &vec3); @@ -308,8 +308,8 @@ TEST_F(BuilderTest, Assign_Vector) { } TEST_F(BuilderTest, Assign_Vector_MemberByName) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); // var.y = 1 @@ -352,9 +352,9 @@ OpStore %9 %10 } TEST_F(BuilderTest, Assign_Vector_MemberByIndex) { - ast::type::I32Type i32; - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); + ast::type::I32 i32; + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); // var[1] = 1 diff --git a/src/writer/spirv/builder_binary_expression_test.cc b/src/writer/spirv/builder_binary_expression_test.cc index 3a761c9798..bc7463a250 100644 --- a/src/writer/spirv/builder_binary_expression_test.cc +++ b/src/writer/spirv/builder_binary_expression_test.cc @@ -55,7 +55,7 @@ using BinaryArithSignedIntegerTest = TestParamHelper; TEST_P(BinaryArithSignedIntegerTest, Scalar) { auto param = GetParam(); - ast::type::I32Type i32; + ast::type::I32 i32; auto* lhs = create( create(&i32, 3)); @@ -79,8 +79,8 @@ TEST_P(BinaryArithSignedIntegerTest, Scalar) { TEST_P(BinaryArithSignedIntegerTest, Vector) { auto param = GetParam(); - ast::type::I32Type i32; - ast::type::VectorType vec3(&i32, 3); + ast::type::I32 i32; + ast::type::Vector vec3(&i32, 3); auto* lhs = create( &vec3, ast::ExpressionList{ @@ -120,7 +120,7 @@ TEST_P(BinaryArithSignedIntegerTest, Vector) { TEST_P(BinaryArithSignedIntegerTest, Scalar_Loads) { auto param = GetParam(); - ast::type::I32Type i32; + ast::type::I32 i32; ast::Variable var("param", ast::StorageClass::kFunction, &i32); @@ -170,7 +170,7 @@ using BinaryArithUnsignedIntegerTest = TestParamHelper; TEST_P(BinaryArithUnsignedIntegerTest, Scalar) { auto param = GetParam(); - ast::type::U32Type u32; + ast::type::U32 u32; auto* lhs = create( create(&u32, 3)); @@ -194,8 +194,8 @@ TEST_P(BinaryArithUnsignedIntegerTest, Scalar) { TEST_P(BinaryArithUnsignedIntegerTest, Vector) { auto param = GetParam(); - ast::type::U32Type u32; - ast::type::VectorType vec3(&u32, 3); + ast::type::U32 u32; + ast::type::Vector vec3(&u32, 3); auto* lhs = create( &vec3, ast::ExpressionList{ @@ -251,7 +251,7 @@ using BinaryArithFloatTest = TestParamHelper; TEST_P(BinaryArithFloatTest, Scalar) { auto param = GetParam(); - ast::type::F32Type f32; + ast::type::F32 f32; auto* lhs = create( create(&f32, 3.2f)); @@ -275,8 +275,8 @@ TEST_P(BinaryArithFloatTest, Scalar) { TEST_P(BinaryArithFloatTest, Vector) { auto param = GetParam(); - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); auto* lhs = create( &vec3, ast::ExpressionList{ @@ -326,7 +326,7 @@ using BinaryCompareUnsignedIntegerTest = TestParamHelper; TEST_P(BinaryCompareUnsignedIntegerTest, Scalar) { auto param = GetParam(); - ast::type::U32Type u32; + ast::type::U32 u32; auto* lhs = create( create(&u32, 3)); @@ -352,8 +352,8 @@ TEST_P(BinaryCompareUnsignedIntegerTest, Scalar) { TEST_P(BinaryCompareUnsignedIntegerTest, Vector) { auto param = GetParam(); - ast::type::U32Type u32; - ast::type::VectorType vec3(&u32, 3); + ast::type::U32 u32; + ast::type::Vector vec3(&u32, 3); auto* lhs = create( &vec3, ast::ExpressionList{ @@ -407,7 +407,7 @@ using BinaryCompareSignedIntegerTest = TestParamHelper; TEST_P(BinaryCompareSignedIntegerTest, Scalar) { auto param = GetParam(); - ast::type::I32Type i32; + ast::type::I32 i32; auto* lhs = create( create(&i32, 3)); @@ -433,8 +433,8 @@ TEST_P(BinaryCompareSignedIntegerTest, Scalar) { TEST_P(BinaryCompareSignedIntegerTest, Vector) { auto param = GetParam(); - ast::type::I32Type i32; - ast::type::VectorType vec3(&i32, 3); + ast::type::I32 i32; + ast::type::Vector vec3(&i32, 3); auto* lhs = create( &vec3, ast::ExpressionList{ @@ -488,7 +488,7 @@ using BinaryCompareFloatTest = TestParamHelper; TEST_P(BinaryCompareFloatTest, Scalar) { auto param = GetParam(); - ast::type::F32Type f32; + ast::type::F32 f32; auto* lhs = create( create(&f32, 3.2f)); @@ -514,8 +514,8 @@ TEST_P(BinaryCompareFloatTest, Scalar) { TEST_P(BinaryCompareFloatTest, Vector) { auto param = GetParam(); - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); auto* lhs = create( &vec3, ast::ExpressionList{ @@ -566,8 +566,8 @@ INSTANTIATE_TEST_SUITE_P( BinaryData{ast::BinaryOp::kNotEqual, "OpFOrdNotEqual"})); TEST_F(BuilderTest, Binary_Multiply_VectorScalar) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); auto* lhs = create( &vec3, ast::ExpressionList{ @@ -599,8 +599,8 @@ TEST_F(BuilderTest, Binary_Multiply_VectorScalar) { } TEST_F(BuilderTest, Binary_Multiply_ScalarVector) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); auto* lhs = create( create(&f32, 1.f)); @@ -631,8 +631,8 @@ TEST_F(BuilderTest, Binary_Multiply_ScalarVector) { } TEST_F(BuilderTest, Binary_Multiply_MatrixScalar) { - ast::type::F32Type f32; - ast::type::MatrixType mat3(&f32, 3, 3); + ast::type::F32 f32; + ast::type::Matrix mat3(&f32, 3, 3); auto* var = create("mat", ast::StorageClass::kFunction, &mat3); auto* lhs = create("mat"); @@ -663,8 +663,8 @@ TEST_F(BuilderTest, Binary_Multiply_MatrixScalar) { } TEST_F(BuilderTest, Binary_Multiply_ScalarMatrix) { - ast::type::F32Type f32; - ast::type::MatrixType mat3(&f32, 3, 3); + ast::type::F32 f32; + ast::type::Matrix mat3(&f32, 3, 3); auto* var = create("mat", ast::StorageClass::kFunction, &mat3); auto* lhs = create( @@ -695,9 +695,9 @@ TEST_F(BuilderTest, Binary_Multiply_ScalarMatrix) { } TEST_F(BuilderTest, Binary_Multiply_MatrixVector) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); - ast::type::MatrixType mat3(&f32, 3, 3); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); + ast::type::Matrix mat3(&f32, 3, 3); auto* var = create("mat", ast::StorageClass::kFunction, &mat3); auto* lhs = create("mat"); @@ -736,9 +736,9 @@ TEST_F(BuilderTest, Binary_Multiply_MatrixVector) { } TEST_F(BuilderTest, Binary_Multiply_VectorMatrix) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); - ast::type::MatrixType mat3(&f32, 3, 3); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); + ast::type::Matrix mat3(&f32, 3, 3); auto* var = create("mat", ast::StorageClass::kFunction, &mat3); @@ -778,9 +778,9 @@ TEST_F(BuilderTest, Binary_Multiply_VectorMatrix) { } TEST_F(BuilderTest, Binary_Multiply_MatrixMatrix) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); - ast::type::MatrixType mat3(&f32, 3, 3); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); + ast::type::Matrix mat3(&f32, 3, 3); auto* var = create("mat", ast::StorageClass::kFunction, &mat3); auto* lhs = create("mat"); @@ -810,7 +810,7 @@ TEST_F(BuilderTest, Binary_Multiply_MatrixMatrix) { } TEST_F(BuilderTest, Binary_LogicalAnd) { - ast::type::I32Type i32; + ast::type::I32 i32; auto* lhs = create(ast::BinaryOp::kEqual, @@ -855,7 +855,7 @@ OpBranch %7 } TEST_F(BuilderTest, Binary_LogicalAnd_WithLoads) { - ast::type::BoolType bool_type; + ast::type::Bool bool_type; auto* a_var = create("a", ast::StorageClass::kFunction, &bool_type); @@ -904,7 +904,7 @@ OpBranch %9 } TEST_F(BuilderTest, Binary_logicalOr_Nested_LogicalAnd) { - ast::type::BoolType bool_ty; + ast::type::Bool bool_ty; // Test an expression like // a || (b && c) @@ -950,7 +950,7 @@ OpBranch %4 } TEST_F(BuilderTest, Binary_logicalAnd_Nested_LogicalOr) { - ast::type::BoolType bool_ty; + ast::type::Bool bool_ty; // Test an expression like // a && (b || c) @@ -996,7 +996,7 @@ OpBranch %4 } TEST_F(BuilderTest, Binary_LogicalOr) { - ast::type::I32Type i32; + ast::type::I32 i32; auto* lhs = create(ast::BinaryOp::kEqual, @@ -1041,7 +1041,7 @@ OpBranch %7 } TEST_F(BuilderTest, Binary_LogicalOr_WithLoads) { - ast::type::BoolType bool_type; + ast::type::Bool bool_type; auto* a_var = create("a", ast::StorageClass::kFunction, &bool_type); diff --git a/src/writer/spirv/builder_bitcast_expression_test.cc b/src/writer/spirv/builder_bitcast_expression_test.cc index 92996ca0f4..9db26dc82f 100644 --- a/src/writer/spirv/builder_bitcast_expression_test.cc +++ b/src/writer/spirv/builder_bitcast_expression_test.cc @@ -33,8 +33,8 @@ namespace { using BuilderTest = TestHelper; TEST_F(BuilderTest, Bitcast) { - ast::type::U32Type u32; - ast::type::F32Type f32; + ast::type::U32 u32; + ast::type::F32 f32; ast::BitcastExpression bitcast(&u32, create( @@ -55,7 +55,7 @@ TEST_F(BuilderTest, Bitcast) { } TEST_F(BuilderTest, Bitcast_DuplicateType) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::BitcastExpression bitcast(&f32, create( diff --git a/src/writer/spirv/builder_block_test.cc b/src/writer/spirv/builder_block_test.cc index 362536ac5c..bcb5a98925 100644 --- a/src/writer/spirv/builder_block_test.cc +++ b/src/writer/spirv/builder_block_test.cc @@ -36,7 +36,7 @@ namespace { using BuilderTest = TestHelper; TEST_F(BuilderTest, Block) { - ast::type::F32Type f32; + ast::type::F32 f32; // Note, this test uses shadow variables which aren't allowed in WGSL but // serves to prove the block code is pushing new scopes as needed. diff --git a/src/writer/spirv/builder_call_test.cc b/src/writer/spirv/builder_call_test.cc index 1fc8aa455d..67447cf998 100644 --- a/src/writer/spirv/builder_call_test.cc +++ b/src/writer/spirv/builder_call_test.cc @@ -40,8 +40,8 @@ namespace { using BuilderTest = TestHelper; TEST_F(BuilderTest, Expression_Call) { - ast::type::F32Type f32; - ast::type::VoidType void_type; + ast::type::F32 f32; + ast::type::Void void_type; ast::VariableList func_params; func_params.push_back( @@ -101,8 +101,8 @@ OpFunctionEnd } TEST_F(BuilderTest, Statement_Call) { - ast::type::F32Type f32; - ast::type::VoidType void_type; + ast::type::F32 f32; + ast::type::Void void_type; ast::VariableList func_params; func_params.push_back( diff --git a/src/writer/spirv/builder_constructor_expression_test.cc b/src/writer/spirv/builder_constructor_expression_test.cc index 4ac92c047b..bc06bd5645 100644 --- a/src/writer/spirv/builder_constructor_expression_test.cc +++ b/src/writer/spirv/builder_constructor_expression_test.cc @@ -103,7 +103,7 @@ TEST_F(SpvBuilderConstructorTest, Type_WithAlias) { // type Int = i32 // cast(2.3f) - ast::type::AliasType alias("Int", ty.i32); + ast::type::Alias alias("Int", ty.i32); ast::TypeConstructorExpression cast(&alias, ExprList(2.3f)); @@ -947,7 +947,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Struct) { create("a", ty.f32, decos), create("b", ty.vec3(), decos), }); - ast::type::StructType s_type("my_struct", s); + ast::type::Struct s_type("my_struct", s); auto* t = Construct(&s_type, 2.0f, vec3(2.0f, 2.0f, 2.0f)); @@ -1083,7 +1083,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ZeroInit_Struct) { auto* s = create(ast::StructMemberList{ create("a", ty.f32, decos), }); - ast::type::StructType s_type("my_struct", s); + ast::type::Struct s_type("my_struct", s); auto* t = Construct(&s_type); @@ -1496,7 +1496,7 @@ TEST_F(SpvBuilderConstructorTest, IsConstructorConst_Struct) { create("a", ty.f32, decos), create("b", ty.vec3(), decos), }); - ast::type::StructType s_type("my_struct", s); + ast::type::Struct s_type("my_struct", s); auto* t = Construct(&s_type, 2.f, vec3(2.f, 2.f, 2.f)); @@ -1514,7 +1514,7 @@ TEST_F(SpvBuilderConstructorTest, create("b", ty.vec3(), decos), }); - ast::type::StructType s_type("my_struct", s); + ast::type::Struct s_type("my_struct", s); auto* t = Construct(&s_type, 2.f, "a", 2.f); diff --git a/src/writer/spirv/builder_function_decoration_test.cc b/src/writer/spirv/builder_function_decoration_test.cc index 161966cbfd..e7ad94a732 100644 --- a/src/writer/spirv/builder_function_decoration_test.cc +++ b/src/writer/spirv/builder_function_decoration_test.cc @@ -40,7 +40,7 @@ namespace { using BuilderTest = TestHelper; TEST_F(BuilderTest, FunctionDecoration_Stage) { - ast::type::VoidType void_type; + ast::type::Void void_type; ast::Function func("main", {}, &void_type, create()); func.add_decoration( @@ -64,7 +64,7 @@ using FunctionDecoration_StageTest = TestParamHelper; TEST_P(FunctionDecoration_StageTest, Emit) { auto params = GetParam(); - ast::type::VoidType void_type; + ast::type::Void void_type; ast::Function func("main", {}, &void_type, create()); func.add_decoration(create(params.stage, Source{})); @@ -89,8 +89,8 @@ INSTANTIATE_TEST_SUITE_P( SpvExecutionModelGLCompute})); TEST_F(BuilderTest, FunctionDecoration_Stage_WithUnusedInterfaceIds) { - ast::type::F32Type f32; - ast::type::VoidType void_type; + ast::type::F32 f32; + ast::type::Void void_type; ast::Function func("main", {}, &void_type, create()); func.add_decoration( @@ -132,8 +132,8 @@ OpName %11 "tint_6d61696e" } TEST_F(BuilderTest, FunctionDecoration_Stage_WithUsedInterfaceIds) { - ast::type::F32Type f32; - ast::type::VoidType void_type; + ast::type::F32 f32; + ast::type::Void void_type; ast::Function func("main", {}, &void_type, create()); func.add_decoration( @@ -195,7 +195,7 @@ OpName %11 "tint_6d61696e" } TEST_F(BuilderTest, FunctionDecoration_ExecutionMode_Fragment_OriginUpperLeft) { - ast::type::VoidType void_type; + ast::type::Void void_type; ast::Function func("main", {}, &void_type, create()); func.add_decoration( @@ -208,7 +208,7 @@ TEST_F(BuilderTest, FunctionDecoration_ExecutionMode_Fragment_OriginUpperLeft) { } TEST_F(BuilderTest, FunctionDecoration_WorkgroupSize_Default) { - ast::type::VoidType void_type; + ast::type::Void void_type; ast::Function func("main", {}, &void_type, create()); func.add_decoration( @@ -221,7 +221,7 @@ TEST_F(BuilderTest, FunctionDecoration_WorkgroupSize_Default) { } TEST_F(BuilderTest, FunctionDecoration_WorkgroupSize) { - ast::type::VoidType void_type; + ast::type::Void void_type; ast::Function func("main", {}, &void_type, create()); func.add_decoration(create(2u, 4u, 6u, Source{})); @@ -235,7 +235,7 @@ TEST_F(BuilderTest, FunctionDecoration_WorkgroupSize) { } TEST_F(BuilderTest, FunctionDecoration_ExecutionMode_MultipleFragment) { - ast::type::VoidType void_type; + ast::type::Void void_type; ast::Function func1("main1", {}, &void_type, create()); func1.add_decoration( diff --git a/src/writer/spirv/builder_function_test.cc b/src/writer/spirv/builder_function_test.cc index 20cbf8a654..9e195c2e28 100644 --- a/src/writer/spirv/builder_function_test.cc +++ b/src/writer/spirv/builder_function_test.cc @@ -48,7 +48,7 @@ namespace { using BuilderTest = TestHelper; TEST_F(BuilderTest, Function_Empty) { - ast::type::VoidType void_type; + ast::type::Void void_type; ast::Function func("a_func", {}, &void_type, create()); ASSERT_TRUE(b.GenerateFunction(&func)); @@ -63,7 +63,7 @@ OpFunctionEnd } TEST_F(BuilderTest, Function_Terminator_Return) { - ast::type::VoidType void_type; + ast::type::Void void_type; auto* body = create(); body->append(create()); @@ -82,8 +82,8 @@ OpFunctionEnd } TEST_F(BuilderTest, Function_Terminator_ReturnValue) { - ast::type::VoidType void_type; - ast::type::F32Type f32; + ast::type::Void void_type; + ast::type::F32 f32; auto* var_a = create("a", ast::StorageClass::kPrivate, &f32); td.RegisterVariableForTesting(var_a); @@ -114,7 +114,7 @@ OpFunctionEnd } TEST_F(BuilderTest, Function_Terminator_Discard) { - ast::type::VoidType void_type; + ast::type::Void void_type; auto* body = create(); body->append(create()); @@ -133,9 +133,9 @@ OpFunctionEnd } TEST_F(BuilderTest, Function_WithParams) { - ast::type::VoidType void_type; - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::Void void_type; + ast::type::F32 f32; + ast::type::I32 i32; ast::VariableList params; auto* var_a = create("a", ast::StorageClass::kFunction, &f32); @@ -171,7 +171,7 @@ OpFunctionEnd } TEST_F(BuilderTest, Function_WithBody) { - ast::type::VoidType void_type; + ast::type::Void void_type; auto* body = create(); body->append(create()); @@ -190,7 +190,7 @@ OpFunctionEnd } TEST_F(BuilderTest, FunctionType) { - ast::type::VoidType void_type; + ast::type::Void void_type; ast::Function func("a_func", {}, &void_type, create()); ASSERT_TRUE(b.GenerateFunction(&func)); @@ -200,7 +200,7 @@ TEST_F(BuilderTest, FunctionType) { } TEST_F(BuilderTest, FunctionType_DeDuplicate) { - ast::type::VoidType void_type; + ast::type::Void void_type; ast::Function func1("a_func", {}, &void_type, create()); ast::Function func2("b_func", {}, &void_type, create()); @@ -228,8 +228,8 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) { // return; // } - ast::type::VoidType void_type; - ast::type::F32Type f32; + ast::type::Void void_type; + ast::type::F32 f32; ast::StructMemberList members; ast::StructMemberDecorationList a_deco; @@ -241,8 +241,8 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) { auto* str = create(s_decos, members); - ast::type::StructType s("Data", str); - ast::type::AccessControlType ac(ast::AccessControl::kReadWrite, &s); + ast::type::Struct s("Data", str); + ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); auto* data_var = create( create("data", ast::StorageClass::kStorageBuffer, &ac)); diff --git a/src/writer/spirv/builder_function_variable_test.cc b/src/writer/spirv/builder_function_variable_test.cc index dbbdb79d72..b28e73bf42 100644 --- a/src/writer/spirv/builder_function_variable_test.cc +++ b/src/writer/spirv/builder_function_variable_test.cc @@ -47,7 +47,7 @@ namespace { using BuilderTest = TestHelper; TEST_F(BuilderTest, FunctionVar_NoStorageClass) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::Variable v("var", ast::StorageClass::kNone, &f32); b.push_function(Function{}); @@ -66,8 +66,8 @@ TEST_F(BuilderTest, FunctionVar_NoStorageClass) { } TEST_F(BuilderTest, FunctionVar_WithConstantConstructor) { - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::ExpressionList vals; vals.push_back(create( @@ -108,8 +108,8 @@ TEST_F(BuilderTest, FunctionVar_WithConstantConstructor) { } TEST_F(BuilderTest, FunctionVar_WithNonConstantConstructor) { - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 2); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 2); auto* rel = create(ast::BinaryOp::kAdd, @@ -158,7 +158,7 @@ TEST_F(BuilderTest, FunctionVar_WithNonConstantConstructorLoadedFromVar) { // var v : f32 = 1.0; // var v2 : f32 = v; // Should generate the load and store automatically. - ast::type::F32Type f32; + ast::type::F32 f32; auto* init = create( create(&f32, 1.0f)); @@ -203,7 +203,7 @@ TEST_F(BuilderTest, FunctionVar_ConstWithVarInitializer) { // var v : f32 = 1.0; // const v2 : f32 = v; // Should generate the load - ast::type::F32Type f32; + ast::type::F32 f32; auto* init = create( create(&f32, 1.0f)); @@ -243,8 +243,8 @@ TEST_F(BuilderTest, FunctionVar_ConstWithVarInitializer) { } TEST_F(BuilderTest, FunctionVar_Const) { - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::ExpressionList vals; vals.push_back(create( diff --git a/src/writer/spirv/builder_global_variable_test.cc b/src/writer/spirv/builder_global_variable_test.cc index 9cfbd0f013..0b4782c654 100644 --- a/src/writer/spirv/builder_global_variable_test.cc +++ b/src/writer/spirv/builder_global_variable_test.cc @@ -52,7 +52,7 @@ namespace { using BuilderTest = TestHelper; TEST_F(BuilderTest, GlobalVar_NoStorageClass) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::Variable v("var", ast::StorageClass::kNone, &f32); EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error(); @@ -66,7 +66,7 @@ TEST_F(BuilderTest, GlobalVar_NoStorageClass) { } TEST_F(BuilderTest, GlobalVar_WithStorageClass) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::Variable v("var", ast::StorageClass::kOutput, &f32); EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error(); @@ -80,7 +80,7 @@ TEST_F(BuilderTest, GlobalVar_WithStorageClass) { } TEST_F(BuilderTest, GlobalVar_WithStorageClass_Input) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::Variable v("var", ast::StorageClass::kInput, &f32); EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error(); @@ -93,8 +93,8 @@ TEST_F(BuilderTest, GlobalVar_WithStorageClass_Input) { } TEST_F(BuilderTest, GlobalVar_WithConstructor) { - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::ExpressionList vals; vals.push_back(create( @@ -128,8 +128,8 @@ TEST_F(BuilderTest, GlobalVar_WithConstructor) { } TEST_F(BuilderTest, GlobalVar_Const) { - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::ExpressionList vals; vals.push_back(create( @@ -162,8 +162,8 @@ TEST_F(BuilderTest, GlobalVar_Const) { } TEST_F(BuilderTest, GlobalVar_Complex_Constructor) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); ast::ExpressionList vals; vals.push_back(create( @@ -194,9 +194,9 @@ TEST_F(BuilderTest, GlobalVar_Complex_Constructor) { } TEST_F(BuilderTest, GlobalVar_Complex_ConstructorWithExtract) { - ast::type::F32Type f32; - ast::type::VectorType vec3(&f32, 3); - ast::type::VectorType vec2(&f32, 2); + ast::type::F32 f32; + ast::type::Vector vec3(&f32, 3); + ast::type::Vector vec2(&f32, 2); auto* first = create( &vec2, ast::ExpressionList{ @@ -240,7 +240,7 @@ TEST_F(BuilderTest, GlobalVar_Complex_ConstructorWithExtract) { } TEST_F(BuilderTest, GlobalVar_WithLocation) { - ast::type::F32Type f32; + ast::type::F32 f32; auto* v = create("var", ast::StorageClass::kOutput, &f32); ast::VariableDecorationList decos; decos.push_back(create(5, Source{})); @@ -261,7 +261,7 @@ TEST_F(BuilderTest, GlobalVar_WithLocation) { } TEST_F(BuilderTest, GlobalVar_WithBindingAndSet) { - ast::type::F32Type f32; + ast::type::F32 f32; auto* v = create("var", ast::StorageClass::kOutput, &f32); ast::VariableDecorationList decos; decos.push_back(create(2, Source{})); @@ -284,7 +284,7 @@ OpDecorate %1 DescriptorSet 3 } TEST_F(BuilderTest, GlobalVar_WithBuiltin) { - ast::type::F32Type f32; + ast::type::F32 f32; auto* v = create("var", ast::StorageClass::kOutput, &f32); ast::VariableDecorationList decos; decos.push_back( @@ -306,7 +306,7 @@ TEST_F(BuilderTest, GlobalVar_WithBuiltin) { } TEST_F(BuilderTest, GlobalVar_ConstantId_Bool) { - ast::type::BoolType bool_type; + ast::type::Bool bool_type; ast::VariableDecorationList decos; decos.push_back(create(1200, Source{})); @@ -330,7 +330,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Bool) { } TEST_F(BuilderTest, GlobalVar_ConstantId_Bool_NoConstructor) { - ast::type::BoolType bool_type; + ast::type::Bool bool_type; ast::VariableDecorationList decos; decos.push_back(create(1200, Source{})); @@ -352,7 +352,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Bool_NoConstructor) { } TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::VariableDecorationList decos; decos.push_back(create(0, Source{})); @@ -376,7 +376,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar) { } TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_F32_NoConstructor) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::VariableDecorationList decos; decos.push_back(create(0, Source{})); @@ -398,7 +398,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_F32_NoConstructor) { } TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_I32_NoConstructor) { - ast::type::I32Type i32; + ast::type::I32 i32; ast::VariableDecorationList decos; decos.push_back(create(0, Source{})); @@ -420,7 +420,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_I32_NoConstructor) { } TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_U32_NoConstructor) { - ast::type::U32Type u32; + ast::type::U32 u32; ast::VariableDecorationList decos; decos.push_back(create(0, Source{})); @@ -481,15 +481,15 @@ TEST_F(BuilderTest, GlobalVar_DeclReadOnly) { // }; // var b : [[access(read)]] A - ast::type::I32Type i32; + ast::type::I32 i32; ast::StructMemberDecorationList decos; ast::StructMemberList members; members.push_back(create("a", &i32, decos)); members.push_back(create("b", &i32, decos)); - ast::type::StructType A("A", create(members)); - ast::type::AccessControlType ac{ast::AccessControl::kReadOnly, &A}; + ast::type::Struct A("A", create(members)); + ast::type::AccessControl ac{ast::AccessControl::kReadOnly, &A}; ast::Variable var("b", ast::StorageClass::kStorageBuffer, &ac); @@ -517,15 +517,15 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasDeclReadOnly) { // type B = A; // var b : [[access(read)]] B - ast::type::I32Type i32; + ast::type::I32 i32; ast::StructMemberDecorationList decos; ast::StructMemberList members; members.push_back(create("a", &i32, decos)); - ast::type::StructType A("A", create(members)); - ast::type::AliasType B("B", &A); - ast::type::AccessControlType ac{ast::AccessControl::kReadOnly, &B}; + ast::type::Struct A("A", create(members)); + ast::type::Alias B("B", &A); + ast::type::AccessControl ac{ast::AccessControl::kReadOnly, &B}; ast::Variable var("b", ast::StorageClass::kStorageBuffer, &ac); @@ -551,15 +551,15 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasAssignReadOnly) { // type B = [[access(read)]] A; // var b : B - ast::type::I32Type i32; + ast::type::I32 i32; ast::StructMemberDecorationList decos; ast::StructMemberList members; members.push_back(create("a", &i32, decos)); - ast::type::StructType A("A", create(members)); - ast::type::AccessControlType ac{ast::AccessControl::kReadOnly, &A}; - ast::type::AliasType B("B", &ac); + ast::type::Struct A("A", create(members)); + ast::type::AccessControl ac{ast::AccessControl::kReadOnly, &A}; + ast::type::Alias B("B", &ac); ast::Variable var("b", ast::StorageClass::kStorageBuffer, &B); @@ -585,15 +585,15 @@ TEST_F(BuilderTest, GlobalVar_TwoVarDeclReadOnly) { // var b : [[access(read)]] A // var c : [[access(read_write)]] A - ast::type::I32Type i32; + ast::type::I32 i32; ast::StructMemberDecorationList decos; ast::StructMemberList members; members.push_back(create("a", &i32, decos)); - ast::type::StructType A("A", create(members)); - ast::type::AccessControlType read{ast::AccessControl::kReadOnly, &A}; - ast::type::AccessControlType rw{ast::AccessControl::kReadWrite, &A}; + ast::type::Struct A("A", create(members)); + ast::type::AccessControl read{ast::AccessControl::kReadOnly, &A}; + ast::type::AccessControl rw{ast::AccessControl::kReadWrite, &A}; ast::Variable var_b("b", ast::StorageClass::kStorageBuffer, &read); ast::Variable var_c("c", ast::StorageClass::kStorageBuffer, &rw); @@ -622,9 +622,9 @@ OpName %5 "tint_63" TEST_F(BuilderTest, GlobalVar_TextureStorageReadOnly) { // var a : texture_storage_ro_2d; - ast::type::StorageTextureType type(ast::type::TextureDimension::k2d, - ast::AccessControl::kReadOnly, - ast::type::ImageFormat::kR32Uint); + ast::type::StorageTexture type(ast::type::TextureDimension::k2d, + ast::AccessControl::kReadOnly, + ast::type::ImageFormat::kR32Uint); ASSERT_TRUE(td.DetermineStorageTextureSubtype(&type)) << td.error(); ast::Variable var_a("a", ast::StorageClass::kUniformConstant, &type); @@ -642,9 +642,9 @@ TEST_F(BuilderTest, GlobalVar_TextureStorageReadOnly) { TEST_F(BuilderTest, GlobalVar_TextureStorageWriteOnly) { // var a : texture_storage_wo_2d; - ast::type::StorageTextureType type(ast::type::TextureDimension::k2d, - ast::AccessControl::kWriteOnly, - ast::type::ImageFormat::kR32Uint); + ast::type::StorageTexture type(ast::type::TextureDimension::k2d, + ast::AccessControl::kWriteOnly, + ast::type::ImageFormat::kR32Uint); ASSERT_TRUE(td.DetermineStorageTextureSubtype(&type)) << td.error(); ast::Variable var_a("a", ast::StorageClass::kUniformConstant, &type); diff --git a/src/writer/spirv/builder_ident_expression_test.cc b/src/writer/spirv/builder_ident_expression_test.cc index 40cd860ecd..7be7907d8c 100644 --- a/src/writer/spirv/builder_ident_expression_test.cc +++ b/src/writer/spirv/builder_ident_expression_test.cc @@ -39,8 +39,8 @@ namespace { using BuilderTest = TestHelper; TEST_F(BuilderTest, IdentifierExpression_GlobalConst) { - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::ExpressionList vals; vals.push_back(create( @@ -77,7 +77,7 @@ TEST_F(BuilderTest, IdentifierExpression_GlobalConst) { } TEST_F(BuilderTest, IdentifierExpression_GlobalVar) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::Variable v("var", ast::StorageClass::kOutput, &f32); td.RegisterVariableForTesting(&v); @@ -98,8 +98,8 @@ TEST_F(BuilderTest, IdentifierExpression_GlobalVar) { } TEST_F(BuilderTest, IdentifierExpression_FunctionConst) { - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::ExpressionList vals; vals.push_back(create( @@ -134,7 +134,7 @@ TEST_F(BuilderTest, IdentifierExpression_FunctionConst) { } TEST_F(BuilderTest, IdentifierExpression_FunctionVar) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::Variable v("var", ast::StorageClass::kNone, &f32); td.RegisterVariableForTesting(&v); @@ -159,7 +159,7 @@ TEST_F(BuilderTest, IdentifierExpression_FunctionVar) { } TEST_F(BuilderTest, IdentifierExpression_Load) { - ast::type::I32Type i32; + ast::type::I32 i32; ast::Variable var("var", ast::StorageClass::kPrivate, &i32); @@ -189,7 +189,7 @@ TEST_F(BuilderTest, IdentifierExpression_Load) { } TEST_F(BuilderTest, IdentifierExpression_NoLoadConst) { - ast::type::I32Type i32; + ast::type::I32 i32; ast::Variable var("var", ast::StorageClass::kNone, &i32); var.set_constructor(create( diff --git a/src/writer/spirv/builder_if_test.cc b/src/writer/spirv/builder_if_test.cc index e2303ca102..aa503be2cb 100644 --- a/src/writer/spirv/builder_if_test.cc +++ b/src/writer/spirv/builder_if_test.cc @@ -42,7 +42,7 @@ namespace { using BuilderTest = TestHelper; TEST_F(BuilderTest, If_Empty) { - ast::type::BoolType bool_type; + ast::type::Bool bool_type; // if (true) { // } @@ -69,8 +69,8 @@ OpBranch %3 } TEST_F(BuilderTest, If_WithStatements) { - ast::type::BoolType bool_type; - ast::type::I32Type i32; + ast::type::Bool bool_type; + ast::type::I32 i32; // if (true) { // v = 2; @@ -114,8 +114,8 @@ OpBranch %7 } TEST_F(BuilderTest, If_WithElse) { - ast::type::BoolType bool_type; - ast::type::I32Type i32; + ast::type::Bool bool_type; + ast::type::I32 i32; // if (true) { // v = 2; @@ -176,8 +176,8 @@ OpBranch %7 } TEST_F(BuilderTest, If_WithElseIf) { - ast::type::BoolType bool_type; - ast::type::I32Type i32; + ast::type::Bool bool_type; + ast::type::I32 i32; // if (true) { // v = 2; @@ -246,8 +246,8 @@ OpBranch %7 } TEST_F(BuilderTest, If_WithMultiple) { - ast::type::BoolType bool_type; - ast::type::I32Type i32; + ast::type::Bool bool_type; + ast::type::I32 i32; // if (true) { // v = 2; @@ -349,7 +349,7 @@ OpBranch %7 } TEST_F(BuilderTest, If_WithBreak) { - ast::type::BoolType bool_type; + ast::type::Bool bool_type; // loop { // if (true) { // break; @@ -395,7 +395,7 @@ OpBranch %1 } TEST_F(BuilderTest, If_WithElseBreak) { - ast::type::BoolType bool_type; + ast::type::Bool bool_type; // loop { // if (true) { // } else { @@ -448,7 +448,7 @@ OpBranch %1 } TEST_F(BuilderTest, If_WithContinue) { - ast::type::BoolType bool_type; + ast::type::Bool bool_type; // loop { // if (true) { // continue; @@ -494,7 +494,7 @@ OpBranch %1 } TEST_F(BuilderTest, If_WithElseContinue) { - ast::type::BoolType bool_type; + ast::type::Bool bool_type; // loop { // if (true) { // } else { @@ -547,7 +547,7 @@ OpBranch %1 } TEST_F(BuilderTest, If_WithReturn) { - ast::type::BoolType bool_type; + ast::type::Bool bool_type; // if (true) { // return; // } @@ -577,7 +577,7 @@ OpReturn } TEST_F(BuilderTest, If_WithReturnValue) { - ast::type::BoolType bool_type; + ast::type::Bool bool_type; // if (true) { // return false; // } @@ -614,7 +614,7 @@ TEST_F(BuilderTest, If_WithLoad_Bug327) { // if (a) { // } - ast::type::BoolType bool_type; + ast::type::Bool bool_type; auto* var = create("a", ast::StorageClass::kFunction, &bool_type); td.RegisterVariableForTesting(var); diff --git a/src/writer/spirv/builder_intrinsic_test.cc b/src/writer/spirv/builder_intrinsic_test.cc index 3b4b401451..2f9c33dab2 100644 --- a/src/writer/spirv/builder_intrinsic_test.cc +++ b/src/writer/spirv/builder_intrinsic_test.cc @@ -415,9 +415,9 @@ TEST_F(IntrinsicBuilderTest, Call_Select) { } TEST_F(IntrinsicBuilderTest, Call_TextureLoad_Storage_RO_1d) { - ast::type::StorageTextureType s(ast::type::TextureDimension::k1d, - ast::AccessControl::kReadOnly, - ast::type::ImageFormat::kR16Float); + ast::type::StorageTexture s(ast::type::TextureDimension::k1d, + ast::AccessControl::kReadOnly, + ast::type::ImageFormat::kR16Float); ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error(); @@ -449,9 +449,9 @@ TEST_F(IntrinsicBuilderTest, Call_TextureLoad_Storage_RO_1d) { } TEST_F(IntrinsicBuilderTest, Call_TextureLoad_Storage_RO_2d) { - ast::type::StorageTextureType s(ast::type::TextureDimension::k2d, - ast::AccessControl::kReadOnly, - ast::type::ImageFormat::kR16Float); + ast::type::StorageTexture s(ast::type::TextureDimension::k2d, + ast::AccessControl::kReadOnly, + ast::type::ImageFormat::kR16Float); ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error(); @@ -486,7 +486,7 @@ TEST_F(IntrinsicBuilderTest, Call_TextureLoad_Storage_RO_2d) { } TEST_F(IntrinsicBuilderTest, Call_TextureLoad_Sampled_1d) { - ast::type::SampledTextureType s(ast::type::TextureDimension::k1d, ty.f32); + ast::type::SampledTexture s(ast::type::TextureDimension::k1d, ty.f32); b.push_function(Function{}); @@ -516,7 +516,7 @@ TEST_F(IntrinsicBuilderTest, Call_TextureLoad_Sampled_1d) { } TEST_F(IntrinsicBuilderTest, Call_TextureLoad_Sampled_2d) { - ast::type::SampledTextureType s(ast::type::TextureDimension::k2d, ty.f32); + ast::type::SampledTexture s(ast::type::TextureDimension::k2d, ty.f32); b.push_function(Function{}); @@ -549,8 +549,7 @@ TEST_F(IntrinsicBuilderTest, Call_TextureLoad_Sampled_2d) { } TEST_F(IntrinsicBuilderTest, Call_TextureLoad_Multisampled_2d) { - ast::type::MultisampledTextureType s(ast::type::TextureDimension::k2d, - ty.f32); + ast::type::MultisampledTexture s(ast::type::TextureDimension::k2d, ty.f32); b.push_function(Function{}); @@ -584,8 +583,8 @@ TEST_F(IntrinsicBuilderTest, Call_TextureLoad_Multisampled_2d) { // This tests that we do not push OpTypeSampledImage and float_0 type twice. TEST_F(IntrinsicBuilderTest, Call_TextureSampleCompare_Twice) { - ast::type::SamplerType s(ast::type::SamplerKind::kComparisonSampler); - ast::type::DepthTextureType t(ast::type::TextureDimension::k2d); + ast::type::Sampler s(ast::type::SamplerKind::kComparisonSampler); + ast::type::DepthTexture t(ast::type::TextureDimension::k2d); b.push_function(Function{}); @@ -1428,7 +1427,7 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength) { members.push_back(create("a", ty.array(), decos)); auto* s = create(members); - ast::type::StructType s_type("my_struct", s); + ast::type::Struct s_type("my_struct", s); auto* var = Var("b", ast::StorageClass::kPrivate, &s_type); @@ -1467,7 +1466,7 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength_OtherMembersInStruct) { members.push_back(create("a", ty.array(), decos)); auto* s = create(members); - ast::type::StructType s_type("my_struct", s); + ast::type::Struct s_type("my_struct", s); auto* var = Var("b", ast::StorageClass::kPrivate, &s_type); auto expr = Call("arrayLength", @@ -1500,8 +1499,7 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength_OtherMembersInStruct) { // TODO(dsinclair): https://bugs.chromium.org/p/tint/issues/detail?id=266 TEST_F(IntrinsicBuilderTest, DISABLED_Call_ArrayLength_Ptr) { - ast::type::PointerType ptr(ty.array(), - ast::StorageClass::kStorageBuffer); + ast::type::Pointer ptr(ty.array(), ast::StorageClass::kStorageBuffer); ast::StructMemberDecorationList decos; ast::StructMemberList members; @@ -1509,7 +1507,7 @@ TEST_F(IntrinsicBuilderTest, DISABLED_Call_ArrayLength_Ptr) { members.push_back(create("a", ty.array(), decos)); auto* s = create(members); - ast::type::StructType s_type("my_struct", s); + ast::type::Struct s_type("my_struct", s); auto* var = Var("b", ast::StorageClass::kPrivate, &s_type); diff --git a/src/writer/spirv/builder_intrinsic_texture_test.cc b/src/writer/spirv/builder_intrinsic_texture_test.cc index 8f0c970d5c..f5c8c064fc 100644 --- a/src/writer/spirv/builder_intrinsic_texture_test.cc +++ b/src/writer/spirv/builder_intrinsic_texture_test.cc @@ -1525,19 +1525,18 @@ TEST_P(IntrinsicTextureTest, Call) { break; } - ast::type::SamplerType sampler_type{param.sampler_kind}; + ast::type::Sampler sampler_type{param.sampler_kind}; ast::Variable* tex = nullptr; switch (param.texture_kind) { case ast::intrinsic::test::TextureKind::kRegular: tex = Var("texture", ast::StorageClass::kNone, - mod->create( - param.texture_dimension, datatype)); + mod->create(param.texture_dimension, + datatype)); break; case ast::intrinsic::test::TextureKind::kDepth: - tex = Var( - "texture", ast::StorageClass::kNone, - mod->create(param.texture_dimension)); + tex = Var("texture", ast::StorageClass::kNone, + mod->create(param.texture_dimension)); break; } diff --git a/src/writer/spirv/builder_literal_test.cc b/src/writer/spirv/builder_literal_test.cc index de94c5f9cb..a50f0ca7b8 100644 --- a/src/writer/spirv/builder_literal_test.cc +++ b/src/writer/spirv/builder_literal_test.cc @@ -34,7 +34,7 @@ namespace spirv { using BuilderTest = TestHelper; TEST_F(BuilderTest, Literal_Bool_True) { - ast::type::BoolType bool_type; + ast::type::Bool bool_type; ast::BoolLiteral b_true(&bool_type, true); auto id = b.GenerateLiteralIfNeeded(nullptr, &b_true); @@ -47,7 +47,7 @@ TEST_F(BuilderTest, Literal_Bool_True) { } TEST_F(BuilderTest, Literal_Bool_False) { - ast::type::BoolType bool_type; + ast::type::Bool bool_type; ast::BoolLiteral b_false(&bool_type, false); auto id = b.GenerateLiteralIfNeeded(nullptr, &b_false); @@ -60,7 +60,7 @@ TEST_F(BuilderTest, Literal_Bool_False) { } TEST_F(BuilderTest, Literal_Bool_Dedup) { - ast::type::BoolType bool_type; + ast::type::Bool bool_type; ast::BoolLiteral b_true(&bool_type, true); ast::BoolLiteral b_false(&bool_type, false); @@ -78,7 +78,7 @@ TEST_F(BuilderTest, Literal_Bool_Dedup) { } TEST_F(BuilderTest, Literal_I32) { - ast::type::I32Type i32; + ast::type::I32 i32; ast::SintLiteral i(&i32, -23); auto id = b.GenerateLiteralIfNeeded(nullptr, &i); @@ -91,7 +91,7 @@ TEST_F(BuilderTest, Literal_I32) { } TEST_F(BuilderTest, Literal_I32_Dedup) { - ast::type::I32Type i32; + ast::type::I32 i32; ast::SintLiteral i1(&i32, -23); ast::SintLiteral i2(&i32, -23); @@ -105,7 +105,7 @@ TEST_F(BuilderTest, Literal_I32_Dedup) { } TEST_F(BuilderTest, Literal_U32) { - ast::type::U32Type u32; + ast::type::U32 u32; ast::UintLiteral i(&u32, 23); auto id = b.GenerateLiteralIfNeeded(nullptr, &i); @@ -118,7 +118,7 @@ TEST_F(BuilderTest, Literal_U32) { } TEST_F(BuilderTest, Literal_U32_Dedup) { - ast::type::U32Type u32; + ast::type::U32 u32; ast::UintLiteral i1(&u32, 23); ast::UintLiteral i2(&u32, 23); @@ -132,7 +132,7 @@ TEST_F(BuilderTest, Literal_U32_Dedup) { } TEST_F(BuilderTest, Literal_F32) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::FloatLiteral i(&f32, 23.245f); auto id = b.GenerateLiteralIfNeeded(nullptr, &i); @@ -145,7 +145,7 @@ TEST_F(BuilderTest, Literal_F32) { } TEST_F(BuilderTest, Literal_F32_Dedup) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::FloatLiteral i1(&f32, 23.245f); ast::FloatLiteral i2(&f32, 23.245f); diff --git a/src/writer/spirv/builder_loop_test.cc b/src/writer/spirv/builder_loop_test.cc index ecfe48ab9b..2345a55435 100644 --- a/src/writer/spirv/builder_loop_test.cc +++ b/src/writer/spirv/builder_loop_test.cc @@ -61,7 +61,7 @@ OpBranch %1 } TEST_F(BuilderTest, Loop_WithoutContinuing) { - ast::type::I32Type i32; + ast::type::I32 i32; // loop { // v = 2; @@ -104,7 +104,7 @@ OpBranch %5 } TEST_F(BuilderTest, Loop_WithContinuing) { - ast::type::I32Type i32; + ast::type::I32 i32; // loop { // a = 2; // continuing { diff --git a/src/writer/spirv/builder_return_test.cc b/src/writer/spirv/builder_return_test.cc index 738a12a3f0..132a6fd3b5 100644 --- a/src/writer/spirv/builder_return_test.cc +++ b/src/writer/spirv/builder_return_test.cc @@ -47,8 +47,8 @@ TEST_F(BuilderTest, Return) { } TEST_F(BuilderTest, Return_WithValue) { - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::ExpressionList vals; vals.push_back(create( @@ -80,7 +80,7 @@ TEST_F(BuilderTest, Return_WithValue) { } TEST_F(BuilderTest, Return_WithValue_GeneratesLoad) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::Variable var("param", ast::StorageClass::kFunction, &f32); diff --git a/src/writer/spirv/builder_switch_test.cc b/src/writer/spirv/builder_switch_test.cc index b4b110b292..25158f3669 100644 --- a/src/writer/spirv/builder_switch_test.cc +++ b/src/writer/spirv/builder_switch_test.cc @@ -41,7 +41,7 @@ namespace { using BuilderTest = TestHelper; TEST_F(BuilderTest, Switch_Empty) { - ast::type::I32Type i32; + ast::type::I32 i32; // switch (1) { // } @@ -68,7 +68,7 @@ OpBranch %1 } TEST_F(BuilderTest, Switch_WithCase) { - ast::type::I32Type i32; + ast::type::I32 i32; // switch(a) { // case 1: @@ -147,7 +147,7 @@ OpFunctionEnd } TEST_F(BuilderTest, Switch_WithDefault) { - ast::type::I32Type i32; + ast::type::I32 i32; // switch(true) { // default: @@ -205,7 +205,7 @@ OpFunctionEnd } TEST_F(BuilderTest, Switch_WithCaseAndDefault) { - ast::type::I32Type i32; + ast::type::I32 i32; // switch(a) { // case 1: @@ -296,7 +296,7 @@ OpFunctionEnd } TEST_F(BuilderTest, Switch_CaseWithFallthrough) { - ast::type::I32Type i32; + ast::type::I32 i32; // switch(a) { // case 1: @@ -388,7 +388,7 @@ OpFunctionEnd } TEST_F(BuilderTest, Switch_CaseFallthroughLastStatement) { - ast::type::I32Type i32; + ast::type::I32 i32; // switch(a) { // case 1: @@ -429,8 +429,8 @@ TEST_F(BuilderTest, Switch_CaseFallthroughLastStatement) { } TEST_F(BuilderTest, Switch_WithNestedBreak) { - ast::type::I32Type i32; - ast::type::BoolType bool_type; + ast::type::I32 i32; + ast::type::Bool bool_type; // switch (a) { // case 1: diff --git a/src/writer/spirv/builder_type_test.cc b/src/writer/spirv/builder_type_test.cc index f72120d5b4..f1c98d4e3e 100644 --- a/src/writer/spirv/builder_type_test.cc +++ b/src/writer/spirv/builder_type_test.cc @@ -52,8 +52,8 @@ namespace { using BuilderTest_Type = TestHelper; TEST_F(BuilderTest_Type, GenerateAlias) { - ast::type::F32Type f32; - ast::type::AliasType alias_type("my_type", &f32); + ast::type::F32 f32; + ast::type::Alias alias_type("my_type", &f32); auto id = b.GenerateTypeIfNeeded(&alias_type); ASSERT_FALSE(b.has_error()) << b.error(); @@ -65,9 +65,9 @@ TEST_F(BuilderTest_Type, GenerateAlias) { } TEST_F(BuilderTest_Type, ReturnsGeneratedAlias) { - ast::type::I32Type i32; - ast::type::F32Type f32; - ast::type::AliasType alias_type("my_type", &f32); + ast::type::I32 i32; + ast::type::F32 f32; + ast::type::Alias alias_type("my_type", &f32); EXPECT_EQ(b.GenerateTypeIfNeeded(&alias_type), 1u); ASSERT_FALSE(b.has_error()) << b.error(); @@ -80,8 +80,8 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedAlias) { } TEST_F(BuilderTest_Type, GenerateRuntimeArray) { - ast::type::I32Type i32; - ast::type::ArrayType ary(&i32); + ast::type::I32 i32; + ast::type::Array ary(&i32); auto id = b.GenerateTypeIfNeeded(&ary); ASSERT_FALSE(b.has_error()) << b.error(); @@ -93,8 +93,8 @@ TEST_F(BuilderTest_Type, GenerateRuntimeArray) { } TEST_F(BuilderTest_Type, ReturnsGeneratedRuntimeArray) { - ast::type::I32Type i32; - ast::type::ArrayType ary(&i32); + ast::type::I32 i32; + ast::type::Array ary(&i32); EXPECT_EQ(b.GenerateTypeIfNeeded(&ary), 1u); EXPECT_EQ(b.GenerateTypeIfNeeded(&ary), 1u); @@ -106,8 +106,8 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedRuntimeArray) { } TEST_F(BuilderTest_Type, GenerateArray) { - ast::type::I32Type i32; - ast::type::ArrayType ary(&i32, 4); + ast::type::I32 i32; + ast::type::Array ary(&i32, 4); auto id = b.GenerateTypeIfNeeded(&ary); ASSERT_FALSE(b.has_error()) << b.error(); @@ -121,12 +121,12 @@ TEST_F(BuilderTest_Type, GenerateArray) { } TEST_F(BuilderTest_Type, GenerateArray_WithStride) { - ast::type::I32Type i32; + ast::type::I32 i32; ast::ArrayDecorationList decos; decos.push_back(create(16u, Source{})); - ast::type::ArrayType ary(&i32, 4); + ast::type::Array ary(&i32, 4); ary.set_decorations(decos); auto id = b.GenerateTypeIfNeeded(&ary); @@ -144,8 +144,8 @@ TEST_F(BuilderTest_Type, GenerateArray_WithStride) { } TEST_F(BuilderTest_Type, ReturnsGeneratedArray) { - ast::type::I32Type i32; - ast::type::ArrayType ary(&i32, 4); + ast::type::I32 i32; + ast::type::Array ary(&i32, 4); EXPECT_EQ(b.GenerateTypeIfNeeded(&ary), 1u); EXPECT_EQ(b.GenerateTypeIfNeeded(&ary), 1u); @@ -159,7 +159,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedArray) { } TEST_F(BuilderTest_Type, GenerateBool) { - ast::type::BoolType bool_type; + ast::type::Bool bool_type; auto id = b.GenerateTypeIfNeeded(&bool_type); ASSERT_FALSE(b.has_error()) << b.error(); @@ -171,8 +171,8 @@ TEST_F(BuilderTest_Type, GenerateBool) { } TEST_F(BuilderTest_Type, ReturnsGeneratedBool) { - ast::type::I32Type i32; - ast::type::BoolType bool_type; + ast::type::I32 i32; + ast::type::Bool bool_type; EXPECT_EQ(b.GenerateTypeIfNeeded(&bool_type), 1u); ASSERT_FALSE(b.has_error()) << b.error(); @@ -183,7 +183,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedBool) { } TEST_F(BuilderTest_Type, GenerateF32) { - ast::type::F32Type f32; + ast::type::F32 f32; auto id = b.GenerateTypeIfNeeded(&f32); ASSERT_FALSE(b.has_error()) << b.error(); @@ -195,8 +195,8 @@ TEST_F(BuilderTest_Type, GenerateF32) { } TEST_F(BuilderTest_Type, ReturnsGeneratedF32) { - ast::type::I32Type i32; - ast::type::F32Type f32; + ast::type::I32 i32; + ast::type::F32 f32; EXPECT_EQ(b.GenerateTypeIfNeeded(&f32), 1u); ASSERT_FALSE(b.has_error()) << b.error(); @@ -207,7 +207,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedF32) { } TEST_F(BuilderTest_Type, GenerateI32) { - ast::type::I32Type i32; + ast::type::I32 i32; auto id = b.GenerateTypeIfNeeded(&i32); ASSERT_FALSE(b.has_error()) << b.error(); @@ -219,8 +219,8 @@ TEST_F(BuilderTest_Type, GenerateI32) { } TEST_F(BuilderTest_Type, ReturnsGeneratedI32) { - ast::type::I32Type i32; - ast::type::F32Type f32; + ast::type::I32 i32; + ast::type::F32 f32; EXPECT_EQ(b.GenerateTypeIfNeeded(&i32), 1u); ASSERT_FALSE(b.has_error()) << b.error(); @@ -231,8 +231,8 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedI32) { } TEST_F(BuilderTest_Type, GenerateMatrix) { - ast::type::F32Type f32; - ast::type::MatrixType mat_type(&f32, 3, 2); + ast::type::F32 f32; + ast::type::Matrix mat_type(&f32, 3, 2); auto id = b.GenerateTypeIfNeeded(&mat_type); ASSERT_FALSE(b.has_error()) << b.error(); @@ -246,8 +246,8 @@ TEST_F(BuilderTest_Type, GenerateMatrix) { } TEST_F(BuilderTest_Type, ReturnsGeneratedMatrix) { - ast::type::I32Type i32; - ast::type::MatrixType mat_type(&i32, 3, 4); + ast::type::I32 i32; + ast::type::Matrix mat_type(&i32, 3, 4); EXPECT_EQ(b.GenerateTypeIfNeeded(&mat_type), 1u); ASSERT_FALSE(b.has_error()) << b.error(); @@ -258,8 +258,8 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedMatrix) { } TEST_F(BuilderTest_Type, GeneratePtr) { - ast::type::I32Type i32; - ast::type::PointerType ptr(&i32, ast::StorageClass::kOutput); + ast::type::I32 i32; + ast::type::Pointer ptr(&i32, ast::StorageClass::kOutput); auto id = b.GenerateTypeIfNeeded(&ptr); ASSERT_FALSE(b.has_error()) << b.error(); @@ -271,8 +271,8 @@ TEST_F(BuilderTest_Type, GeneratePtr) { } TEST_F(BuilderTest_Type, ReturnsGeneratedPtr) { - ast::type::I32Type i32; - ast::type::PointerType ptr(&i32, ast::StorageClass::kOutput); + ast::type::I32 i32; + ast::type::Pointer ptr(&i32, ast::StorageClass::kOutput); EXPECT_EQ(b.GenerateTypeIfNeeded(&ptr), 1u); EXPECT_EQ(b.GenerateTypeIfNeeded(&ptr), 1u); @@ -280,7 +280,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedPtr) { TEST_F(BuilderTest_Type, GenerateStruct_Empty) { auto* s = create(); - ast::type::StructType s_type("S", s); + ast::type::Struct s_type("S", s); auto id = b.GenerateTypeIfNeeded(&s_type); ASSERT_FALSE(b.has_error()) << b.error(); @@ -294,14 +294,14 @@ TEST_F(BuilderTest_Type, GenerateStruct_Empty) { } TEST_F(BuilderTest_Type, GenerateStruct) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::StructMemberDecorationList decos; ast::StructMemberList members; members.push_back(create("a", &f32, decos)); auto* s = create(members); - ast::type::StructType s_type("my_struct", s); + ast::type::Struct s_type("my_struct", s); auto id = b.GenerateTypeIfNeeded(&s_type); ASSERT_FALSE(b.has_error()) << b.error(); @@ -316,7 +316,7 @@ OpMemberName %1 0 "tint_61" } TEST_F(BuilderTest_Type, GenerateStruct_Decorated) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::StructMemberDecorationList decos; ast::StructMemberList members; @@ -326,7 +326,7 @@ TEST_F(BuilderTest_Type, GenerateStruct_Decorated) { struct_decos.push_back(create(Source{})); auto* s = create(struct_decos, members); - ast::type::StructType s_type("my_struct", s); + ast::type::Struct s_type("my_struct", s); auto id = b.GenerateTypeIfNeeded(&s_type); ASSERT_FALSE(b.has_error()) << b.error(); @@ -343,7 +343,7 @@ OpMemberName %1 0 "tint_61" } TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::StructMemberDecorationList a_decos; a_decos.push_back(create(0, Source{})); @@ -355,7 +355,7 @@ TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers) { members.push_back(create("b", &f32, b_decos)); auto* s = create(members); - ast::type::StructType s_type("S", s); + ast::type::Struct s_type("S", s); auto id = b.GenerateTypeIfNeeded(&s_type); ASSERT_FALSE(b.has_error()) << b.error(); @@ -375,10 +375,10 @@ OpMemberDecorate %1 1 Offset 8 TEST_F(BuilderTest_Type, GenerateStruct_NonLayout_Matrix) { // Don't infer layout for matrix when there is no offset. - ast::type::F32Type f32; - ast::type::MatrixType glsl_mat2x2(&f32, 2, 2); - ast::type::MatrixType glsl_mat2x3(&f32, 3, 2); // 2 columns, 3 rows - ast::type::MatrixType glsl_mat4x4(&f32, 4, 4); + ast::type::F32 f32; + ast::type::Matrix glsl_mat2x2(&f32, 2, 2); + ast::type::Matrix glsl_mat2x3(&f32, 3, 2); // 2 columns, 3 rows + ast::type::Matrix glsl_mat4x4(&f32, 4, 4); ast::StructMemberDecorationList empty_a; ast::StructMemberDecorationList empty_b; @@ -389,7 +389,7 @@ TEST_F(BuilderTest_Type, GenerateStruct_NonLayout_Matrix) { members.push_back(create("c", &glsl_mat4x4, empty_c)); auto* s = create(members); - ast::type::StructType s_type("S", s); + ast::type::Struct s_type("S", s); auto id = b.GenerateTypeIfNeeded(&s_type); ASSERT_FALSE(b.has_error()) << b.error(); @@ -414,10 +414,10 @@ OpMemberName %1 2 "tint_63" TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers_LayoutMatrix) { // We have to infer layout for matrix when it also has an offset. - ast::type::F32Type f32; - ast::type::MatrixType glsl_mat2x2(&f32, 2, 2); - ast::type::MatrixType glsl_mat2x3(&f32, 3, 2); // 2 columns, 3 rows - ast::type::MatrixType glsl_mat4x4(&f32, 4, 4); + ast::type::F32 f32; + ast::type::Matrix glsl_mat2x2(&f32, 2, 2); + ast::type::Matrix glsl_mat2x3(&f32, 3, 2); // 2 columns, 3 rows + ast::type::Matrix glsl_mat4x4(&f32, 4, 4); ast::StructMemberDecorationList a_decos; a_decos.push_back(create(0, Source{})); @@ -432,7 +432,7 @@ TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers_LayoutMatrix) { members.push_back(create("c", &glsl_mat4x4, c_decos)); auto* s = create(members); - ast::type::StructType s_type("S", s); + ast::type::Struct s_type("S", s); auto id = b.GenerateTypeIfNeeded(&s_type); ASSERT_FALSE(b.has_error()) << b.error(); @@ -468,17 +468,17 @@ TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers_LayoutArraysOfMatrix) { // We have to infer layout for matrix when it also has an offset. // The decoration goes on the struct member, even if the matrix is buried // in levels of arrays. - ast::type::F32Type f32; + ast::type::F32 f32; - ast::type::MatrixType glsl_mat2x2(&f32, 2, 2); - ast::type::ArrayType arr_mat2x2(&glsl_mat2x2, 1); // Singly nested array + ast::type::Matrix glsl_mat2x2(&f32, 2, 2); + ast::type::Array arr_mat2x2(&glsl_mat2x2, 1); // Singly nested array - ast::type::MatrixType glsl_mat2x3(&f32, 3, 2); // 2 columns, 3 rows - ast::type::ArrayType arr_mat2x3(&glsl_mat2x3, 1); - ast::type::ArrayType arr_arr_mat2x2(&arr_mat2x3, 1); // Doubly nested array + ast::type::Matrix glsl_mat2x3(&f32, 3, 2); // 2 columns, 3 rows + ast::type::Array arr_mat2x3(&glsl_mat2x3, 1); + ast::type::Array arr_arr_mat2x2(&arr_mat2x3, 1); // Doubly nested array - ast::type::MatrixType glsl_mat4x4(&f32, 4, 4); - ast::type::ArrayType rtarr_mat4x4(&glsl_mat4x4); // Runtime array + ast::type::Matrix glsl_mat4x4(&f32, 4, 4); + ast::type::Array rtarr_mat4x4(&glsl_mat4x4); // Runtime array ast::StructMemberDecorationList a_decos; a_decos.push_back(create(0, Source{})); @@ -493,7 +493,7 @@ TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers_LayoutArraysOfMatrix) { members.push_back(create("c", &glsl_mat4x4, c_decos)); auto* s = create(members); - ast::type::StructType s_type("S", s); + ast::type::Struct s_type("S", s); auto id = b.GenerateTypeIfNeeded(&s_type); ASSERT_FALSE(b.has_error()) << b.error(); @@ -526,7 +526,7 @@ OpMemberDecorate %1 2 MatrixStride 16 } TEST_F(BuilderTest_Type, GenerateU32) { - ast::type::U32Type u32; + ast::type::U32 u32; auto id = b.GenerateTypeIfNeeded(&u32); ASSERT_FALSE(b.has_error()) << b.error(); @@ -538,8 +538,8 @@ TEST_F(BuilderTest_Type, GenerateU32) { } TEST_F(BuilderTest_Type, ReturnsGeneratedU32) { - ast::type::U32Type u32; - ast::type::F32Type f32; + ast::type::U32 u32; + ast::type::F32 f32; EXPECT_EQ(b.GenerateTypeIfNeeded(&u32), 1u); ASSERT_FALSE(b.has_error()) << b.error(); @@ -550,8 +550,8 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedU32) { } TEST_F(BuilderTest_Type, GenerateVector) { - ast::type::F32Type f32; - ast::type::VectorType vec_type(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec_type(&f32, 3); auto id = b.GenerateTypeIfNeeded(&vec_type); ASSERT_FALSE(b.has_error()) << b.error(); @@ -564,8 +564,8 @@ TEST_F(BuilderTest_Type, GenerateVector) { } TEST_F(BuilderTest_Type, ReturnsGeneratedVector) { - ast::type::I32Type i32; - ast::type::VectorType vec_type(&i32, 3); + ast::type::I32 i32; + ast::type::Vector vec_type(&i32, 3); EXPECT_EQ(b.GenerateTypeIfNeeded(&vec_type), 1u); ASSERT_FALSE(b.has_error()) << b.error(); @@ -576,7 +576,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedVector) { } TEST_F(BuilderTest_Type, GenerateVoid) { - ast::type::VoidType void_type; + ast::type::Void void_type; auto id = b.GenerateTypeIfNeeded(&void_type); ASSERT_FALSE(b.has_error()) << b.error(); @@ -588,8 +588,8 @@ TEST_F(BuilderTest_Type, GenerateVoid) { } TEST_F(BuilderTest_Type, ReturnsGeneratedVoid) { - ast::type::I32Type i32; - ast::type::VoidType void_type; + ast::type::I32 i32; + ast::type::Void void_type; EXPECT_EQ(b.GenerateTypeIfNeeded(&void_type), 1u); ASSERT_FALSE(b.has_error()) << b.error(); @@ -631,7 +631,7 @@ INSTANTIATE_TEST_SUITE_P( PtrData{ast::StorageClass::kFunction, SpvStorageClassFunction})); TEST_F(BuilderTest_Type, DepthTexture_Generate_2d) { - ast::type::DepthTextureType two_d(ast::type::TextureDimension::k2d); + ast::type::DepthTexture two_d(ast::type::TextureDimension::k2d); auto id_two_d = b.GenerateTypeIfNeeded(&two_d); ASSERT_FALSE(b.has_error()) << b.error(); @@ -643,8 +643,7 @@ TEST_F(BuilderTest_Type, DepthTexture_Generate_2d) { } TEST_F(BuilderTest_Type, DepthTexture_Generate_2dArray) { - ast::type::DepthTextureType two_d_array( - ast::type::TextureDimension::k2dArray); + ast::type::DepthTexture two_d_array(ast::type::TextureDimension::k2dArray); auto id_two_d_array = b.GenerateTypeIfNeeded(&two_d_array); ASSERT_FALSE(b.has_error()) << b.error(); @@ -656,7 +655,7 @@ TEST_F(BuilderTest_Type, DepthTexture_Generate_2dArray) { } TEST_F(BuilderTest_Type, DepthTexture_Generate_Cube) { - ast::type::DepthTextureType cube(ast::type::TextureDimension::kCube); + ast::type::DepthTexture cube(ast::type::TextureDimension::kCube); auto id_cube = b.GenerateTypeIfNeeded(&cube); ASSERT_FALSE(b.has_error()) << b.error(); @@ -669,8 +668,7 @@ TEST_F(BuilderTest_Type, DepthTexture_Generate_Cube) { } TEST_F(BuilderTest_Type, DepthTexture_Generate_CubeArray) { - ast::type::DepthTextureType cube_array( - ast::type::TextureDimension::kCubeArray); + ast::type::DepthTexture cube_array(ast::type::TextureDimension::kCubeArray); auto id_cube_array = b.GenerateTypeIfNeeded(&cube_array); ASSERT_FALSE(b.has_error()) << b.error(); @@ -685,8 +683,8 @@ TEST_F(BuilderTest_Type, DepthTexture_Generate_CubeArray) { } TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_i32) { - ast::type::I32Type i32; - ast::type::MultisampledTextureType ms(ast::type::TextureDimension::k2d, &i32); + ast::type::I32 i32; + ast::type::MultisampledTexture ms(ast::type::TextureDimension::k2d, &i32); EXPECT_EQ(1u, b.GenerateTypeIfNeeded(&ms)); ASSERT_FALSE(b.has_error()) << b.error(); @@ -696,8 +694,8 @@ TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_i32) { } TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_u32) { - ast::type::U32Type u32; - ast::type::MultisampledTextureType ms(ast::type::TextureDimension::k2d, &u32); + ast::type::U32 u32; + ast::type::MultisampledTexture ms(ast::type::TextureDimension::k2d, &u32); EXPECT_EQ(b.GenerateTypeIfNeeded(&ms), 1u); ASSERT_FALSE(b.has_error()) << b.error(); @@ -708,8 +706,8 @@ TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_u32) { } TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_f32) { - ast::type::F32Type f32; - ast::type::MultisampledTextureType ms(ast::type::TextureDimension::k2d, &f32); + ast::type::F32 f32; + ast::type::MultisampledTexture ms(ast::type::TextureDimension::k2d, &f32); EXPECT_EQ(b.GenerateTypeIfNeeded(&ms), 1u); ASSERT_FALSE(b.has_error()) << b.error(); @@ -720,8 +718,8 @@ TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_f32) { } TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_i32) { - ast::type::I32Type i32; - ast::type::SampledTextureType s(ast::type::TextureDimension::k1d, &i32); + ast::type::I32 i32; + ast::type::SampledTexture s(ast::type::TextureDimension::k1d, &i32); EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u); ASSERT_FALSE(b.has_error()) << b.error(); @@ -736,8 +734,8 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_i32) { } TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_u32) { - ast::type::U32Type u32; - ast::type::SampledTextureType s(ast::type::TextureDimension::k1d, &u32); + ast::type::U32 u32; + ast::type::SampledTexture s(ast::type::TextureDimension::k1d, &u32); EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u); ASSERT_FALSE(b.has_error()) << b.error(); @@ -752,8 +750,8 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_u32) { } TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_f32) { - ast::type::F32Type f32; - ast::type::SampledTextureType s(ast::type::TextureDimension::k1d, &f32); + ast::type::F32 f32; + ast::type::SampledTexture s(ast::type::TextureDimension::k1d, &f32); EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u); ASSERT_FALSE(b.has_error()) << b.error(); @@ -768,8 +766,8 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_f32) { } TEST_F(BuilderTest_Type, SampledTexture_Generate_1dArray) { - ast::type::F32Type f32; - ast::type::SampledTextureType s(ast::type::TextureDimension::k1dArray, &f32); + ast::type::F32 f32; + ast::type::SampledTexture s(ast::type::TextureDimension::k1dArray, &f32); EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u); ASSERT_FALSE(b.has_error()) << b.error(); @@ -784,8 +782,8 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_1dArray) { } TEST_F(BuilderTest_Type, SampledTexture_Generate_2d) { - ast::type::F32Type f32; - ast::type::SampledTextureType s(ast::type::TextureDimension::k2d, &f32); + ast::type::F32 f32; + ast::type::SampledTexture s(ast::type::TextureDimension::k2d, &f32); EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u); ASSERT_FALSE(b.has_error()) << b.error(); @@ -796,8 +794,8 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_2d) { } TEST_F(BuilderTest_Type, SampledTexture_Generate_2d_array) { - ast::type::F32Type f32; - ast::type::SampledTextureType s(ast::type::TextureDimension::k2dArray, &f32); + ast::type::F32 f32; + ast::type::SampledTexture s(ast::type::TextureDimension::k2dArray, &f32); EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u); ASSERT_FALSE(b.has_error()) << b.error(); @@ -808,8 +806,8 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_2d_array) { } TEST_F(BuilderTest_Type, SampledTexture_Generate_3d) { - ast::type::F32Type f32; - ast::type::SampledTextureType s(ast::type::TextureDimension::k3d, &f32); + ast::type::F32 f32; + ast::type::SampledTexture s(ast::type::TextureDimension::k3d, &f32); EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u); ASSERT_FALSE(b.has_error()) << b.error(); @@ -820,8 +818,8 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_3d) { } TEST_F(BuilderTest_Type, SampledTexture_Generate_Cube) { - ast::type::F32Type f32; - ast::type::SampledTextureType s(ast::type::TextureDimension::kCube, &f32); + ast::type::F32 f32; + ast::type::SampledTexture s(ast::type::TextureDimension::kCube, &f32); EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u); ASSERT_FALSE(b.has_error()) << b.error(); @@ -833,9 +831,8 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_Cube) { } TEST_F(BuilderTest_Type, SampledTexture_Generate_CubeArray) { - ast::type::F32Type f32; - ast::type::SampledTextureType s(ast::type::TextureDimension::kCubeArray, - &f32); + ast::type::F32 f32; + ast::type::SampledTexture s(ast::type::TextureDimension::kCubeArray, &f32); EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u); ASSERT_FALSE(b.has_error()) << b.error(); @@ -849,9 +846,9 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_CubeArray) { } TEST_F(BuilderTest_Type, StorageTexture_GenerateReadonly_1d_R16Float) { - ast::type::StorageTextureType s(ast::type::TextureDimension::k1d, - ast::AccessControl::kReadOnly, - ast::type::ImageFormat::kR16Float); + ast::type::StorageTexture s(ast::type::TextureDimension::k1d, + ast::AccessControl::kReadOnly, + ast::type::ImageFormat::kR16Float); ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error(); EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u); @@ -867,9 +864,9 @@ OpCapability StorageImageExtendedFormats } TEST_F(BuilderTest_Type, StorageTexture_GenerateReadonly_1d_R8SNorm) { - ast::type::StorageTextureType s(ast::type::TextureDimension::k1d, - ast::AccessControl::kReadOnly, - ast::type::ImageFormat::kR8Snorm); + ast::type::StorageTexture s(ast::type::TextureDimension::k1d, + ast::AccessControl::kReadOnly, + ast::type::ImageFormat::kR8Snorm); ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error(); EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u); @@ -885,9 +882,9 @@ OpCapability StorageImageExtendedFormats } TEST_F(BuilderTest_Type, StorageTexture_GenerateReadonly_1d_R8UNorm) { - ast::type::StorageTextureType s(ast::type::TextureDimension::k1d, - ast::AccessControl::kReadOnly, - ast::type::ImageFormat::kR8Unorm); + ast::type::StorageTexture s(ast::type::TextureDimension::k1d, + ast::AccessControl::kReadOnly, + ast::type::ImageFormat::kR8Unorm); ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error(); EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u); @@ -903,9 +900,9 @@ OpCapability StorageImageExtendedFormats } TEST_F(BuilderTest_Type, StorageTexture_GenerateReadonly_1d_R8Uint) { - ast::type::StorageTextureType s(ast::type::TextureDimension::k1d, - ast::AccessControl::kReadOnly, - ast::type::ImageFormat::kR8Uint); + ast::type::StorageTexture s(ast::type::TextureDimension::k1d, + ast::AccessControl::kReadOnly, + ast::type::ImageFormat::kR8Uint); ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error(); EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u); @@ -916,9 +913,9 @@ TEST_F(BuilderTest_Type, StorageTexture_GenerateReadonly_1d_R8Uint) { } TEST_F(BuilderTest_Type, StorageTexture_GenerateReadonly_1d_R8Sint) { - ast::type::StorageTextureType s(ast::type::TextureDimension::k1d, - ast::AccessControl::kReadOnly, - ast::type::ImageFormat::kR8Sint); + ast::type::StorageTexture s(ast::type::TextureDimension::k1d, + ast::AccessControl::kReadOnly, + ast::type::ImageFormat::kR8Sint); ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error(); EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u); @@ -929,9 +926,9 @@ TEST_F(BuilderTest_Type, StorageTexture_GenerateReadonly_1d_R8Sint) { } TEST_F(BuilderTest_Type, StorageTexture_GenerateReadonly_1d_array) { - ast::type::StorageTextureType s(ast::type::TextureDimension::k1dArray, - ast::AccessControl::kReadOnly, - ast::type::ImageFormat::kR16Float); + ast::type::StorageTexture s(ast::type::TextureDimension::k1dArray, + ast::AccessControl::kReadOnly, + ast::type::ImageFormat::kR16Float); ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error(); EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u); @@ -947,9 +944,9 @@ OpCapability StorageImageExtendedFormats } TEST_F(BuilderTest_Type, StorageTexture_GenerateReadonly_2d) { - ast::type::StorageTextureType s(ast::type::TextureDimension::k2d, - ast::AccessControl::kReadOnly, - ast::type::ImageFormat::kR16Float); + ast::type::StorageTexture s(ast::type::TextureDimension::k2d, + ast::AccessControl::kReadOnly, + ast::type::ImageFormat::kR16Float); ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error(); EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u); @@ -960,9 +957,9 @@ TEST_F(BuilderTest_Type, StorageTexture_GenerateReadonly_2d) { } TEST_F(BuilderTest_Type, StorageTexture_GenerateReadonly_2dArray) { - ast::type::StorageTextureType s(ast::type::TextureDimension::k2dArray, - ast::AccessControl::kReadOnly, - ast::type::ImageFormat::kR16Float); + ast::type::StorageTexture s(ast::type::TextureDimension::k2dArray, + ast::AccessControl::kReadOnly, + ast::type::ImageFormat::kR16Float); ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error(); EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u); @@ -973,9 +970,9 @@ TEST_F(BuilderTest_Type, StorageTexture_GenerateReadonly_2dArray) { } TEST_F(BuilderTest_Type, StorageTexture_GenerateReadonly_3d) { - ast::type::StorageTextureType s(ast::type::TextureDimension::k3d, - ast::AccessControl::kReadOnly, - ast::type::ImageFormat::kR16Float); + ast::type::StorageTexture s(ast::type::TextureDimension::k3d, + ast::AccessControl::kReadOnly, + ast::type::ImageFormat::kR16Float); ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error(); EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u); @@ -986,9 +983,9 @@ TEST_F(BuilderTest_Type, StorageTexture_GenerateReadonly_3d) { } TEST_F(BuilderTest_Type, StorageTexture_GenerateWriteonly_1d) { - ast::type::StorageTextureType s(ast::type::TextureDimension::k1d, - ast::AccessControl::kWriteOnly, - ast::type::ImageFormat::kR16Float); + ast::type::StorageTexture s(ast::type::TextureDimension::k1d, + ast::AccessControl::kWriteOnly, + ast::type::ImageFormat::kR16Float); ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error(); EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u); @@ -1004,9 +1001,9 @@ OpCapability StorageImageExtendedFormats } TEST_F(BuilderTest_Type, StorageTexture_GenerateWriteonly_1dArray) { - ast::type::StorageTextureType s(ast::type::TextureDimension::k1dArray, - ast::AccessControl::kWriteOnly, - ast::type::ImageFormat::kR16Float); + ast::type::StorageTexture s(ast::type::TextureDimension::k1dArray, + ast::AccessControl::kWriteOnly, + ast::type::ImageFormat::kR16Float); ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error(); EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u); @@ -1022,9 +1019,9 @@ OpCapability StorageImageExtendedFormats } TEST_F(BuilderTest_Type, StorageTexture_GenerateWriteonly_2d) { - ast::type::StorageTextureType s(ast::type::TextureDimension::k2d, - ast::AccessControl::kWriteOnly, - ast::type::ImageFormat::kR16Float); + ast::type::StorageTexture s(ast::type::TextureDimension::k2d, + ast::AccessControl::kWriteOnly, + ast::type::ImageFormat::kR16Float); ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error(); EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u); @@ -1035,9 +1032,9 @@ TEST_F(BuilderTest_Type, StorageTexture_GenerateWriteonly_2d) { } TEST_F(BuilderTest_Type, StorageTexture_GenerateWriteonly_2dArray) { - ast::type::StorageTextureType s(ast::type::TextureDimension::k2dArray, - ast::AccessControl::kWriteOnly, - ast::type::ImageFormat::kR16Float); + ast::type::StorageTexture s(ast::type::TextureDimension::k2dArray, + ast::AccessControl::kWriteOnly, + ast::type::ImageFormat::kR16Float); ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error(); EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u); @@ -1048,9 +1045,9 @@ TEST_F(BuilderTest_Type, StorageTexture_GenerateWriteonly_2dArray) { } TEST_F(BuilderTest_Type, StorageTexture_GenerateWriteonly_3d) { - ast::type::StorageTextureType s(ast::type::TextureDimension::k3d, - ast::AccessControl::kWriteOnly, - ast::type::ImageFormat::kR16Float); + ast::type::StorageTexture s(ast::type::TextureDimension::k3d, + ast::AccessControl::kWriteOnly, + ast::type::ImageFormat::kR16Float); ASSERT_TRUE(td.DetermineStorageTextureSubtype(&s)) << td.error(); EXPECT_EQ(b.GenerateTypeIfNeeded(&s), 1u); @@ -1061,25 +1058,24 @@ TEST_F(BuilderTest_Type, StorageTexture_GenerateWriteonly_3d) { } TEST_F(BuilderTest_Type, Sampler) { - ast::type::SamplerType sampler(ast::type::SamplerKind::kSampler); + ast::type::Sampler sampler(ast::type::SamplerKind::kSampler); EXPECT_EQ(b.GenerateTypeIfNeeded(&sampler), 1u); ASSERT_FALSE(b.has_error()) << b.error(); EXPECT_EQ(DumpInstructions(b.types()), "%1 = OpTypeSampler\n"); } TEST_F(BuilderTest_Type, ComparisonSampler) { - ast::type::SamplerType sampler(ast::type::SamplerKind::kComparisonSampler); + ast::type::Sampler sampler(ast::type::SamplerKind::kComparisonSampler); EXPECT_EQ(b.GenerateTypeIfNeeded(&sampler), 1u); ASSERT_FALSE(b.has_error()) << b.error(); EXPECT_EQ(DumpInstructions(b.types()), "%1 = OpTypeSampler\n"); } TEST_F(BuilderTest_Type, Dedup_Sampler_And_ComparisonSampler) { - ast::type::SamplerType comp_sampler( - ast::type::SamplerKind::kComparisonSampler); + ast::type::Sampler comp_sampler(ast::type::SamplerKind::kComparisonSampler); EXPECT_EQ(b.GenerateTypeIfNeeded(&comp_sampler), 1u); - ast::type::SamplerType sampler(ast::type::SamplerKind::kSampler); + ast::type::Sampler sampler(ast::type::SamplerKind::kSampler); EXPECT_EQ(b.GenerateTypeIfNeeded(&sampler), 1u); ASSERT_FALSE(b.has_error()) << b.error(); diff --git a/src/writer/spirv/builder_unary_op_expression_test.cc b/src/writer/spirv/builder_unary_op_expression_test.cc index 5795dee1af..c423293679 100644 --- a/src/writer/spirv/builder_unary_op_expression_test.cc +++ b/src/writer/spirv/builder_unary_op_expression_test.cc @@ -39,7 +39,7 @@ namespace { using BuilderTest = TestHelper; TEST_F(BuilderTest, UnaryOp_Negation_Integer) { - ast::type::I32Type i32; + ast::type::I32 i32; ast::UnaryOpExpression expr(ast::UnaryOp::kNegation, create( @@ -58,7 +58,7 @@ TEST_F(BuilderTest, UnaryOp_Negation_Integer) { } TEST_F(BuilderTest, UnaryOp_Negation_Float) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::UnaryOpExpression expr(ast::UnaryOp::kNegation, create( @@ -77,7 +77,7 @@ TEST_F(BuilderTest, UnaryOp_Negation_Float) { } TEST_F(BuilderTest, UnaryOp_Not) { - ast::type::BoolType bool_type; + ast::type::Bool bool_type; ast::UnaryOpExpression expr(ast::UnaryOp::kNot, create( @@ -96,8 +96,8 @@ TEST_F(BuilderTest, UnaryOp_Not) { } TEST_F(BuilderTest, UnaryOp_LoadRequired) { - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); ast::Variable var("param", ast::StorageClass::kFunction, &vec); diff --git a/src/writer/wgsl/generator_impl.cc b/src/writer/wgsl/generator_impl.cc index d038609466..85ac8bad65 100644 --- a/src/writer/wgsl/generator_impl.cc +++ b/src/writer/wgsl/generator_impl.cc @@ -173,15 +173,15 @@ bool GeneratorImpl::GenerateEntryPoint(const ast::Module& module, bool GeneratorImpl::EmitConstructedType(const ast::type::Type* ty) { make_indent(); - if (ty->Is()) { - auto* alias = ty->As(); + if (ty->Is()) { + auto* alias = ty->As(); out_ << "type " << alias->name() << " = "; if (!EmitType(alias->type())) { return false; } out_ << ";" << std::endl; - } else if (ty->Is()) { - if (!EmitStructType(ty->As())) { + } else if (ty->Is()) { + if (!EmitStructType(ty->As())) { return false; } } else { @@ -399,8 +399,8 @@ bool GeneratorImpl::EmitImageFormat(const ast::type::ImageFormat fmt) { } bool GeneratorImpl::EmitType(ast::type::Type* type) { - if (type->Is()) { - auto* ac = type->As(); + if (type->Is()) { + auto* ac = type->As(); out_ << "[[access("; if (ac->IsReadOnly()) { @@ -415,10 +415,10 @@ bool GeneratorImpl::EmitType(ast::type::Type* type) { if (!EmitType(ac->type())) { return false; } - } else if (type->Is()) { - out_ << type->As()->name(); - } else if (type->Is()) { - auto* ary = type->As(); + } else if (type->Is()) { + out_ << type->As()->name(); + } else if (type->Is()) { + auto* ary = type->As(); for (auto* deco : ary->decorations()) { if (auto* stride = deco->As()) { @@ -435,51 +435,51 @@ bool GeneratorImpl::EmitType(ast::type::Type* type) { out_ << ", " << ary->size(); out_ << ">"; - } else if (type->Is()) { + } else if (type->Is()) { out_ << "bool"; - } else if (type->Is()) { + } else if (type->Is()) { out_ << "f32"; - } else if (type->Is()) { + } else if (type->Is()) { out_ << "i32"; - } else if (type->Is()) { - auto* mat = type->As(); + } else if (type->Is()) { + auto* mat = type->As(); out_ << "mat" << mat->columns() << "x" << mat->rows() << "<"; if (!EmitType(mat->type())) { return false; } out_ << ">"; - } else if (type->Is()) { - auto* ptr = type->As(); + } else if (type->Is()) { + auto* ptr = type->As(); out_ << "ptr<" << ptr->storage_class() << ", "; if (!EmitType(ptr->type())) { return false; } out_ << ">"; - } else if (type->Is()) { - auto* sampler = type->As(); + } else if (type->Is()) { + auto* sampler = type->As(); out_ << "sampler"; if (sampler->IsComparison()) { out_ << "_comparison"; } - } else if (type->Is()) { + } else if (type->Is()) { // The struct, as a type, is just the name. We should have already emitted // the declaration through a call to |EmitStructType| earlier. - out_ << type->As()->name(); - } else if (type->Is()) { - auto* texture = type->As(); + out_ << type->As()->name(); + } else if (type->Is()) { + auto* texture = type->As(); out_ << "texture_"; - if (texture->Is()) { + if (texture->Is()) { out_ << "depth_"; - } else if (texture->Is()) { + } else if (texture->Is()) { /* nothing to emit */ - } else if (texture->Is()) { + } else if (texture->Is()) { out_ << "multisampled_"; - } else if (texture->Is()) { + } else if (texture->Is()) { out_ << "storage_"; - auto* storage = texture->As(); + auto* storage = texture->As(); if (storage->access() == ast::AccessControl::kReadOnly) { out_ << "ro_"; } else if (storage->access() == ast::AccessControl::kWriteOnly) { @@ -520,24 +520,24 @@ bool GeneratorImpl::EmitType(ast::type::Type* type) { return false; } - if (texture->Is()) { - auto* sampled = texture->As(); + if (texture->Is()) { + auto* sampled = texture->As(); out_ << "<"; if (!EmitType(sampled->type())) { return false; } out_ << ">"; - } else if (texture->Is()) { - auto* sampled = texture->As(); + } else if (texture->Is()) { + auto* sampled = texture->As(); out_ << "<"; if (!EmitType(sampled->type())) { return false; } out_ << ">"; - } else if (texture->Is()) { - auto* storage = texture->As(); + } else if (texture->Is()) { + auto* storage = texture->As(); out_ << "<"; if (!EmitImageFormat(storage->image_format())) { @@ -546,16 +546,16 @@ bool GeneratorImpl::EmitType(ast::type::Type* type) { out_ << ">"; } - } else if (type->Is()) { + } else if (type->Is()) { out_ << "u32"; - } else if (type->Is()) { - auto* vec = type->As(); + } else if (type->Is()) { + auto* vec = type->As(); out_ << "vec" << vec->size() << "<"; if (!EmitType(vec->type())) { return false; } out_ << ">"; - } else if (type->Is()) { + } else if (type->Is()) { out_ << "void"; } else { error_ = "unknown type in EmitType: " + type->type_name(); @@ -565,7 +565,7 @@ bool GeneratorImpl::EmitType(ast::type::Type* type) { return true; } -bool GeneratorImpl::EmitStructType(const ast::type::StructType* str) { +bool GeneratorImpl::EmitStructType(const ast::type::Struct* str) { auto* impl = str->impl(); for (auto* deco : impl->decorations()) { out_ << "[["; diff --git a/src/writer/wgsl/generator_impl.h b/src/writer/wgsl/generator_impl.h index 4680036254..3bc921a191 100644 --- a/src/writer/wgsl/generator_impl.h +++ b/src/writer/wgsl/generator_impl.h @@ -187,7 +187,7 @@ class GeneratorImpl : public TextGenerator { /// Handles generating a struct declaration /// @param str the struct /// @returns true if the struct is emitted - bool EmitStructType(const ast::type::StructType* str); + bool EmitStructType(const ast::type::Struct* str); /// Handles emitting an image format /// @param fmt the format to generate /// @returns true if the format is emitted diff --git a/src/writer/wgsl/generator_impl_alias_type_test.cc b/src/writer/wgsl/generator_impl_alias_type_test.cc index ce1249ed1f..693c75d035 100644 --- a/src/writer/wgsl/generator_impl_alias_type_test.cc +++ b/src/writer/wgsl/generator_impl_alias_type_test.cc @@ -30,9 +30,9 @@ namespace { using WgslGeneratorImplTest = TestHelper; -TEST_F(WgslGeneratorImplTest, EmitAliasType_F32) { - ast::type::F32Type f32; - ast::type::AliasType alias("a", &f32); +TEST_F(WgslGeneratorImplTest, EmitAlias_F32) { + ast::type::F32 f32; + ast::type::Alias alias("a", &f32); ASSERT_TRUE(gen.EmitConstructedType(&alias)) << gen.error(); EXPECT_EQ(gen.result(), R"(type a = f32; @@ -40,8 +40,8 @@ TEST_F(WgslGeneratorImplTest, EmitAliasType_F32) { } TEST_F(WgslGeneratorImplTest, EmitConstructedType_Struct) { - ast::type::I32Type i32; - ast::type::F32Type f32; + ast::type::I32 i32; + ast::type::F32 f32; ast::StructMemberList members; members.push_back( @@ -54,8 +54,8 @@ TEST_F(WgslGeneratorImplTest, EmitConstructedType_Struct) { auto* str = create(); str->set_members(members); - ast::type::StructType s("A", str); - ast::type::AliasType alias("B", &s); + ast::type::Struct s("A", str); + ast::type::Alias alias("B", &s); ASSERT_TRUE(gen.EmitConstructedType(&s)) << gen.error(); ASSERT_TRUE(gen.EmitConstructedType(&alias)) << gen.error(); @@ -68,9 +68,9 @@ type B = A; )"); } -TEST_F(WgslGeneratorImplTest, EmitAliasType_ToStruct) { - ast::type::I32Type i32; - ast::type::F32Type f32; +TEST_F(WgslGeneratorImplTest, EmitAlias_ToStruct) { + ast::type::I32 i32; + ast::type::F32 f32; ast::StructMemberList members; members.push_back( @@ -83,8 +83,8 @@ TEST_F(WgslGeneratorImplTest, EmitAliasType_ToStruct) { auto* str = create(); str->set_members(members); - ast::type::StructType s("A", str); - ast::type::AliasType alias("B", &s); + ast::type::Struct s("A", str); + ast::type::Alias alias("B", &s); ASSERT_TRUE(gen.EmitConstructedType(&alias)) << gen.error(); EXPECT_EQ(gen.result(), R"(type B = A; diff --git a/src/writer/wgsl/generator_impl_array_accessor_test.cc b/src/writer/wgsl/generator_impl_array_accessor_test.cc index e1876120f1..8678557aa3 100644 --- a/src/writer/wgsl/generator_impl_array_accessor_test.cc +++ b/src/writer/wgsl/generator_impl_array_accessor_test.cc @@ -31,7 +31,7 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, EmitExpression_ArrayAccessor) { - ast::type::I32Type i32; + ast::type::I32 i32; auto* lit = create(&i32, 5); auto* idx = create(lit); auto* ary = create("ary"); diff --git a/src/writer/wgsl/generator_impl_bitcast_test.cc b/src/writer/wgsl/generator_impl_bitcast_test.cc index 83ba9e68cc..2b9d5e881b 100644 --- a/src/writer/wgsl/generator_impl_bitcast_test.cc +++ b/src/writer/wgsl/generator_impl_bitcast_test.cc @@ -29,7 +29,7 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, EmitExpression_Bitcast) { - ast::type::F32Type f32; + ast::type::F32 f32; auto* id = create("id"); ast::BitcastExpression bitcast(&f32, id); diff --git a/src/writer/wgsl/generator_impl_case_test.cc b/src/writer/wgsl/generator_impl_case_test.cc index 5b5fc05517..b23348ff5c 100644 --- a/src/writer/wgsl/generator_impl_case_test.cc +++ b/src/writer/wgsl/generator_impl_case_test.cc @@ -31,7 +31,7 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, Emit_Case) { - ast::type::I32Type i32; + ast::type::I32 i32; auto* body = create(); body->append(create()); @@ -50,7 +50,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Case) { } TEST_F(WgslGeneratorImplTest, Emit_Case_MultipleSelectors) { - ast::type::I32Type i32; + ast::type::I32 i32; auto* body = create(); body->append(create()); diff --git a/src/writer/wgsl/generator_impl_cast_test.cc b/src/writer/wgsl/generator_impl_cast_test.cc index c2a86dc248..6b0e933ad0 100644 --- a/src/writer/wgsl/generator_impl_cast_test.cc +++ b/src/writer/wgsl/generator_impl_cast_test.cc @@ -29,7 +29,7 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, EmitExpression_Cast) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::ExpressionList params; params.push_back(create("id")); diff --git a/src/writer/wgsl/generator_impl_constructor_test.cc b/src/writer/wgsl/generator_impl_constructor_test.cc index 850f5ecd7d..099335547b 100644 --- a/src/writer/wgsl/generator_impl_constructor_test.cc +++ b/src/writer/wgsl/generator_impl_constructor_test.cc @@ -36,7 +36,7 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, EmitConstructor_Bool) { - ast::type::BoolType bool_type; + ast::type::Bool bool_type; auto* lit = create(&bool_type, false); ast::ScalarConstructorExpression expr(lit); @@ -45,7 +45,7 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Bool) { } TEST_F(WgslGeneratorImplTest, EmitConstructor_Int) { - ast::type::I32Type i32; + ast::type::I32 i32; auto* lit = create(&i32, -12345); ast::ScalarConstructorExpression expr(lit); @@ -54,7 +54,7 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Int) { } TEST_F(WgslGeneratorImplTest, EmitConstructor_UInt) { - ast::type::U32Type u32; + ast::type::U32 u32; auto* lit = create(&u32, 56779); ast::ScalarConstructorExpression expr(lit); @@ -63,7 +63,7 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_UInt) { } TEST_F(WgslGeneratorImplTest, EmitConstructor_Float) { - ast::type::F32Type f32; + ast::type::F32 f32; // Use a number close to 1<<30 but whose decimal representation ends in 0. auto* lit = create(&f32, static_cast((1 << 30) - 4)); @@ -74,7 +74,7 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Float) { } TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Float) { - ast::type::F32Type f32; + ast::type::F32 f32; auto* lit = create(&f32, -1.2e-5); ast::ExpressionList values; @@ -87,7 +87,7 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Float) { } TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Bool) { - ast::type::BoolType b; + ast::type::Bool b; auto* lit = create(&b, true); ast::ExpressionList values; @@ -100,7 +100,7 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Bool) { } TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Int) { - ast::type::I32Type i32; + ast::type::I32 i32; auto* lit = create(&i32, -12345); ast::ExpressionList values; @@ -113,7 +113,7 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Int) { } TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Uint) { - ast::type::U32Type u32; + ast::type::U32 u32; auto* lit = create(&u32, 12345); ast::ExpressionList values; @@ -126,8 +126,8 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Uint) { } TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Vec) { - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); auto* lit1 = create(&f32, 1.f); auto* lit2 = create(&f32, 2.f); @@ -144,10 +144,10 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Vec) { } TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Mat) { - ast::type::F32Type f32; - ast::type::MatrixType mat(&f32, 3, 2); + ast::type::F32 f32; + ast::type::Matrix mat(&f32, 3, 2); - ast::type::VectorType vec(&f32, 2); + ast::type::Vector vec(&f32, 2); ast::ExpressionList mat_values; @@ -172,9 +172,9 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Mat) { } TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Array) { - ast::type::F32Type f32; - ast::type::VectorType vec(&f32, 3); - ast::type::ArrayType ary(&vec, 3); + ast::type::F32 f32; + ast::type::Vector vec(&f32, 3); + ast::type::Array ary(&vec, 3); ast::ExpressionList ary_values; diff --git a/src/writer/wgsl/generator_impl_function_test.cc b/src/writer/wgsl/generator_impl_function_test.cc index 15815c1aab..3d337f8be4 100644 --- a/src/writer/wgsl/generator_impl_function_test.cc +++ b/src/writer/wgsl/generator_impl_function_test.cc @@ -47,7 +47,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Function) { body->append(create()); body->append(create()); - ast::type::VoidType void_type; + ast::type::Void void_type; ast::Function func("my_func", {}, &void_type, body); gen.increment_indent(); @@ -65,13 +65,13 @@ TEST_F(WgslGeneratorImplTest, Emit_Function_WithParams) { body->append(create()); body->append(create()); - ast::type::F32Type f32; - ast::type::I32Type i32; + ast::type::F32 f32; + ast::type::I32 i32; ast::VariableList params; params.push_back(create("a", ast::StorageClass::kNone, &f32)); params.push_back(create("b", ast::StorageClass::kNone, &i32)); - ast::type::VoidType void_type; + ast::type::Void void_type; ast::Function func("my_func", params, &void_type, body); gen.increment_indent(); @@ -89,7 +89,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Function_WithDecoration_WorkgroupSize) { body->append(create()); body->append(create()); - ast::type::VoidType void_type; + ast::type::Void void_type; ast::Function func("my_func", {}, &void_type, body); func.add_decoration(create(2u, 4u, 6u, Source{})); @@ -109,7 +109,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Function_WithDecoration_Stage) { body->append(create()); body->append(create()); - ast::type::VoidType void_type; + ast::type::Void void_type; ast::Function func("my_func", {}, &void_type, body); func.add_decoration( create(ast::PipelineStage::kFragment, Source{})); @@ -130,7 +130,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Function_WithDecoration_Multiple) { body->append(create()); body->append(create()); - ast::type::VoidType void_type; + ast::type::Void void_type; ast::Function func("my_func", {}, &void_type, body); func.add_decoration( create(ast::PipelineStage::kFragment, Source{})); @@ -166,8 +166,8 @@ TEST_F(WgslGeneratorImplTest, // return; // } - ast::type::VoidType void_type; - ast::type::F32Type f32; + ast::type::Void void_type; + ast::type::F32 f32; ast::StructMemberList members; ast::StructMemberDecorationList a_deco; @@ -179,8 +179,8 @@ TEST_F(WgslGeneratorImplTest, auto* str = create(s_decos, members); - ast::type::StructType s("Data", str); - ast::type::AccessControlType ac(ast::AccessControl::kReadWrite, &s); + ast::type::Struct s("Data", str); + ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); auto* data_var = create( create("data", ast::StorageClass::kStorageBuffer, &ac)); diff --git a/src/writer/wgsl/generator_impl_switch_test.cc b/src/writer/wgsl/generator_impl_switch_test.cc index 06904eee03..29f22cc256 100644 --- a/src/writer/wgsl/generator_impl_switch_test.cc +++ b/src/writer/wgsl/generator_impl_switch_test.cc @@ -36,7 +36,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Switch) { def_body->append(create()); auto* def = create(def_body); - ast::type::I32Type i32; + ast::type::I32 i32; ast::CaseSelectorList case_val; case_val.push_back(create(&i32, 5)); diff --git a/src/writer/wgsl/generator_impl_test.cc b/src/writer/wgsl/generator_impl_test.cc index d9ea548c9e..a088017a6e 100644 --- a/src/writer/wgsl/generator_impl_test.cc +++ b/src/writer/wgsl/generator_impl_test.cc @@ -30,7 +30,7 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, Generate) { - ast::type::VoidType void_type; + ast::type::Void void_type; mod.AddFunction(create("my_func", ast::VariableList{}, &void_type, diff --git a/src/writer/wgsl/generator_impl_type_test.cc b/src/writer/wgsl/generator_impl_type_test.cc index fd4d81dcaf..202e8fc5dc 100644 --- a/src/writer/wgsl/generator_impl_type_test.cc +++ b/src/writer/wgsl/generator_impl_type_test.cc @@ -48,23 +48,23 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, EmitType_Alias) { - ast::type::F32Type f32; - ast::type::AliasType alias("alias", &f32); + ast::type::F32 f32; + ast::type::Alias alias("alias", &f32); ASSERT_TRUE(gen.EmitType(&alias)) << gen.error(); EXPECT_EQ(gen.result(), "alias"); } TEST_F(WgslGeneratorImplTest, EmitType_Array) { - ast::type::BoolType b; - ast::type::ArrayType a(&b, 4); + ast::type::Bool b; + ast::type::Array a(&b, 4); ASSERT_TRUE(gen.EmitType(&a)) << gen.error(); EXPECT_EQ(gen.result(), "array"); } TEST_F(WgslGeneratorImplTest, EmitType_AccessControl_Read) { - ast::type::I32Type i32; + ast::type::I32 i32; ast::StructMember mem("a", &i32, ast::StructMemberDecorationList{}); ast::StructMemberList members; @@ -75,16 +75,16 @@ TEST_F(WgslGeneratorImplTest, EmitType_AccessControl_Read) { decos.push_back(&block_deco); ast::Struct str(decos, members); - ast::type::StructType s("S", &str); + ast::type::Struct s("S", &str); - ast::type::AccessControlType a(ast::AccessControl::kReadOnly, &s); + ast::type::AccessControl a(ast::AccessControl::kReadOnly, &s); ASSERT_TRUE(gen.EmitType(&a)) << gen.error(); EXPECT_EQ(gen.result(), "[[access(read)]]\nS"); } TEST_F(WgslGeneratorImplTest, EmitType_AccessControl_ReadWrite) { - ast::type::I32Type i32; + ast::type::I32 i32; ast::StructMember mem("a", &i32, ast::StructMemberDecorationList{}); ast::StructMemberList members; @@ -95,20 +95,20 @@ TEST_F(WgslGeneratorImplTest, EmitType_AccessControl_ReadWrite) { decos.push_back(&block_deco); ast::Struct str(decos, members); - ast::type::StructType s("S", &str); + ast::type::Struct s("S", &str); - ast::type::AccessControlType a(ast::AccessControl::kReadWrite, &s); + ast::type::AccessControl a(ast::AccessControl::kReadWrite, &s); ASSERT_TRUE(gen.EmitType(&a)) << gen.error(); EXPECT_EQ(gen.result(), "[[access(read_write)]]\nS"); } TEST_F(WgslGeneratorImplTest, EmitType_Array_Decoration) { - ast::type::BoolType b; + ast::type::Bool b; ast::ArrayDecorationList decos; decos.push_back(create(16u, Source{})); - ast::type::ArrayType a(&b, 4); + ast::type::Array a(&b, 4); a.set_decorations(decos); ASSERT_TRUE(gen.EmitType(&a)) << gen.error(); @@ -116,12 +116,12 @@ TEST_F(WgslGeneratorImplTest, EmitType_Array_Decoration) { } TEST_F(WgslGeneratorImplTest, EmitType_Array_MultipleDecorations) { - ast::type::BoolType b; + ast::type::Bool b; ast::ArrayDecorationList decos; decos.push_back(create(16u, Source{})); decos.push_back(create(32u, Source{})); - ast::type::ArrayType a(&b, 4); + ast::type::Array a(&b, 4); a.set_decorations(decos); ASSERT_TRUE(gen.EmitType(&a)) << gen.error(); @@ -129,53 +129,53 @@ TEST_F(WgslGeneratorImplTest, EmitType_Array_MultipleDecorations) { } TEST_F(WgslGeneratorImplTest, EmitType_RuntimeArray) { - ast::type::BoolType b; - ast::type::ArrayType a(&b); + ast::type::Bool b; + ast::type::Array a(&b); ASSERT_TRUE(gen.EmitType(&a)) << gen.error(); EXPECT_EQ(gen.result(), "array"); } TEST_F(WgslGeneratorImplTest, EmitType_Bool) { - ast::type::BoolType b; + ast::type::Bool b; ASSERT_TRUE(gen.EmitType(&b)) << gen.error(); EXPECT_EQ(gen.result(), "bool"); } TEST_F(WgslGeneratorImplTest, EmitType_F32) { - ast::type::F32Type f32; + ast::type::F32 f32; ASSERT_TRUE(gen.EmitType(&f32)) << gen.error(); EXPECT_EQ(gen.result(), "f32"); } TEST_F(WgslGeneratorImplTest, EmitType_I32) { - ast::type::I32Type i32; + ast::type::I32 i32; ASSERT_TRUE(gen.EmitType(&i32)) << gen.error(); EXPECT_EQ(gen.result(), "i32"); } TEST_F(WgslGeneratorImplTest, EmitType_Matrix) { - ast::type::F32Type f32; - ast::type::MatrixType m(&f32, 3, 2); + ast::type::F32 f32; + ast::type::Matrix m(&f32, 3, 2); ASSERT_TRUE(gen.EmitType(&m)) << gen.error(); EXPECT_EQ(gen.result(), "mat2x3"); } TEST_F(WgslGeneratorImplTest, EmitType_Pointer) { - ast::type::F32Type f32; - ast::type::PointerType p(&f32, ast::StorageClass::kWorkgroup); + ast::type::F32 f32; + ast::type::Pointer p(&f32, ast::StorageClass::kWorkgroup); ASSERT_TRUE(gen.EmitType(&p)) << gen.error(); EXPECT_EQ(gen.result(), "ptr"); } TEST_F(WgslGeneratorImplTest, EmitType_Struct) { - ast::type::I32Type i32; - ast::type::F32Type f32; + ast::type::I32 i32; + ast::type::F32 f32; ast::StructMemberList members; members.push_back( @@ -188,15 +188,15 @@ TEST_F(WgslGeneratorImplTest, EmitType_Struct) { auto* str = create(); str->set_members(members); - ast::type::StructType s("S", str); + ast::type::Struct s("S", str); ASSERT_TRUE(gen.EmitType(&s)) << gen.error(); EXPECT_EQ(gen.result(), "S"); } TEST_F(WgslGeneratorImplTest, EmitType_StructDecl) { - ast::type::I32Type i32; - ast::type::F32Type f32; + ast::type::I32 i32; + ast::type::F32 f32; ast::StructMemberList members; members.push_back( @@ -209,7 +209,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_StructDecl) { auto* str = create(); str->set_members(members); - ast::type::StructType s("S", str); + ast::type::Struct s("S", str); ASSERT_TRUE(gen.EmitStructType(&s)) << gen.error(); EXPECT_EQ(gen.result(), R"(struct S { @@ -221,8 +221,8 @@ TEST_F(WgslGeneratorImplTest, EmitType_StructDecl) { } TEST_F(WgslGeneratorImplTest, EmitType_Struct_WithDecoration) { - ast::type::I32Type i32; - ast::type::F32Type f32; + ast::type::I32 i32; + ast::type::F32 f32; ast::StructMemberList members; members.push_back( @@ -237,7 +237,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Struct_WithDecoration) { auto* str = create(decos, members); - ast::type::StructType s("S", str); + ast::type::Struct s("S", str); ASSERT_TRUE(gen.EmitStructType(&s)) << gen.error(); EXPECT_EQ(gen.result(), R"([[block]] @@ -250,22 +250,22 @@ struct S { } TEST_F(WgslGeneratorImplTest, EmitType_U32) { - ast::type::U32Type u32; + ast::type::U32 u32; ASSERT_TRUE(gen.EmitType(&u32)) << gen.error(); EXPECT_EQ(gen.result(), "u32"); } TEST_F(WgslGeneratorImplTest, EmitType_Vector) { - ast::type::F32Type f32; - ast::type::VectorType v(&f32, 3); + ast::type::F32 f32; + ast::type::Vector v(&f32, 3); ASSERT_TRUE(gen.EmitType(&v)) << gen.error(); EXPECT_EQ(gen.result(), "vec3"); } TEST_F(WgslGeneratorImplTest, EmitType_Void) { - ast::type::VoidType v; + ast::type::Void v; ASSERT_TRUE(gen.EmitType(&v)) << gen.error(); EXPECT_EQ(gen.result(), "void"); @@ -284,7 +284,7 @@ using WgslGenerator_DepthTextureTest = TestParamHelper; TEST_P(WgslGenerator_DepthTextureTest, EmitType_DepthTexture) { auto param = GetParam(); - ast::type::DepthTextureType d(param.dim); + ast::type::DepthTexture d(param.dim); ASSERT_TRUE(gen.EmitType(&d)) << gen.error(); EXPECT_EQ(gen.result(), param.name); @@ -304,8 +304,8 @@ using WgslGenerator_SampledTextureTest = TestParamHelper; TEST_P(WgslGenerator_SampledTextureTest, EmitType_SampledTexture_F32) { auto param = GetParam(); - ast::type::F32Type f32; - ast::type::SampledTextureType t(param.dim, &f32); + ast::type::F32 f32; + ast::type::SampledTexture t(param.dim, &f32); ASSERT_TRUE(gen.EmitType(&t)) << gen.error(); EXPECT_EQ(gen.result(), std::string(param.name) + ""); @@ -314,8 +314,8 @@ TEST_P(WgslGenerator_SampledTextureTest, EmitType_SampledTexture_F32) { TEST_P(WgslGenerator_SampledTextureTest, EmitType_SampledTexture_I32) { auto param = GetParam(); - ast::type::I32Type i32; - ast::type::SampledTextureType t(param.dim, &i32); + ast::type::I32 i32; + ast::type::SampledTexture t(param.dim, &i32); ASSERT_TRUE(gen.EmitType(&t)) << gen.error(); EXPECT_EQ(gen.result(), std::string(param.name) + ""); @@ -324,8 +324,8 @@ TEST_P(WgslGenerator_SampledTextureTest, EmitType_SampledTexture_I32) { TEST_P(WgslGenerator_SampledTextureTest, EmitType_SampledTexture_U32) { auto param = GetParam(); - ast::type::U32Type u32; - ast::type::SampledTextureType t(param.dim, &u32); + ast::type::U32 u32; + ast::type::SampledTexture t(param.dim, &u32); ASSERT_TRUE(gen.EmitType(&t)) << gen.error(); EXPECT_EQ(gen.result(), std::string(param.name) + ""); @@ -347,8 +347,8 @@ using WgslGenerator_MultiampledTextureTest = TestParamHelper; TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_F32) { auto param = GetParam(); - ast::type::F32Type f32; - ast::type::MultisampledTextureType t(param.dim, &f32); + ast::type::F32 f32; + ast::type::MultisampledTexture t(param.dim, &f32); ASSERT_TRUE(gen.EmitType(&t)) << gen.error(); EXPECT_EQ(gen.result(), std::string(param.name) + ""); @@ -357,8 +357,8 @@ TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_F32) { TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_I32) { auto param = GetParam(); - ast::type::I32Type i32; - ast::type::MultisampledTextureType t(param.dim, &i32); + ast::type::I32 i32; + ast::type::MultisampledTexture t(param.dim, &i32); ASSERT_TRUE(gen.EmitType(&t)) << gen.error(); EXPECT_EQ(gen.result(), std::string(param.name) + ""); @@ -367,8 +367,8 @@ TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_I32) { TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_U32) { auto param = GetParam(); - ast::type::U32Type u32; - ast::type::MultisampledTextureType t(param.dim, &u32); + ast::type::U32 u32; + ast::type::MultisampledTexture t(param.dim, &u32); ASSERT_TRUE(gen.EmitType(&t)) << gen.error(); EXPECT_EQ(gen.result(), std::string(param.name) + ""); @@ -393,7 +393,7 @@ using WgslGenerator_StorageTextureTest = TestParamHelper; TEST_P(WgslGenerator_StorageTextureTest, EmitType_StorageTexture) { auto param = GetParam(); - ast::type::StorageTextureType t(param.dim, param.access, param.fmt); + ast::type::StorageTexture t(param.dim, param.access, param.fmt); ASSERT_TRUE(gen.EmitType(&t)) << gen.error(); EXPECT_EQ(gen.result(), param.name); @@ -496,14 +496,14 @@ INSTANTIATE_TEST_SUITE_P( ImageFormatData{ast::type::ImageFormat::kRgba32Float, "rgba32float"})); TEST_F(WgslGeneratorImplTest, EmitType_Sampler) { - ast::type::SamplerType sampler(ast::type::SamplerKind::kSampler); + ast::type::Sampler sampler(ast::type::SamplerKind::kSampler); ASSERT_TRUE(gen.EmitType(&sampler)) << gen.error(); EXPECT_EQ(gen.result(), "sampler"); } TEST_F(WgslGeneratorImplTest, EmitType_SamplerComparison) { - ast::type::SamplerType sampler(ast::type::SamplerKind::kComparisonSampler); + ast::type::Sampler sampler(ast::type::SamplerKind::kComparisonSampler); ASSERT_TRUE(gen.EmitType(&sampler)) << gen.error(); EXPECT_EQ(gen.result(), "sampler_comparison"); diff --git a/src/writer/wgsl/generator_impl_variable_decl_statement_test.cc b/src/writer/wgsl/generator_impl_variable_decl_statement_test.cc index 7d19a1ed2e..375e2381e7 100644 --- a/src/writer/wgsl/generator_impl_variable_decl_statement_test.cc +++ b/src/writer/wgsl/generator_impl_variable_decl_statement_test.cc @@ -31,7 +31,7 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, Emit_VariableDeclStatement) { - ast::type::F32Type f32; + ast::type::F32 f32; auto* var = create("a", ast::StorageClass::kNone, &f32); ast::VariableDeclStatement stmt(var); @@ -46,7 +46,7 @@ TEST_F(WgslGeneratorImplTest, Emit_VariableDeclStatement_Function) { // Variable declarations with Function storage class don't mention their // storage class. Rely on defaulting. // https://github.com/gpuweb/gpuweb/issues/654 - ast::type::F32Type f32; + ast::type::F32 f32; auto* var = create("a", ast::StorageClass::kFunction, &f32); ast::VariableDeclStatement stmt(var); @@ -58,7 +58,7 @@ TEST_F(WgslGeneratorImplTest, Emit_VariableDeclStatement_Function) { } TEST_F(WgslGeneratorImplTest, Emit_VariableDeclStatement_Private) { - ast::type::F32Type f32; + ast::type::F32 f32; auto* var = create("a", ast::StorageClass::kPrivate, &f32); ast::VariableDeclStatement stmt(var); diff --git a/src/writer/wgsl/generator_impl_variable_test.cc b/src/writer/wgsl/generator_impl_variable_test.cc index 23b9adf7ca..d342ba4add 100644 --- a/src/writer/wgsl/generator_impl_variable_test.cc +++ b/src/writer/wgsl/generator_impl_variable_test.cc @@ -34,7 +34,7 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, EmitVariable) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::Variable v("a", ast::StorageClass::kNone, &f32); ASSERT_TRUE(gen.EmitVariable(&v)) << gen.error(); @@ -43,7 +43,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable) { } TEST_F(WgslGeneratorImplTest, EmitVariable_StorageClass) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::Variable v("a", ast::StorageClass::kInput, &f32); ASSERT_TRUE(gen.EmitVariable(&v)) << gen.error(); @@ -52,7 +52,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_StorageClass) { } TEST_F(WgslGeneratorImplTest, EmitVariable_Decorated) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::VariableDecorationList decos; decos.push_back(create(2, Source{})); @@ -68,7 +68,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Decorated) { } TEST_F(WgslGeneratorImplTest, EmitVariable_Decorated_Multiple) { - ast::type::F32Type f32; + ast::type::F32 f32; ast::VariableDecorationList decos; decos.push_back( @@ -93,7 +93,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Decorated_Multiple) { TEST_F(WgslGeneratorImplTest, EmitVariable_Constructor) { auto* ident = create("initializer"); - ast::type::F32Type f32; + ast::type::F32 f32; ast::Variable v("a", ast::StorageClass::kNone, &f32); v.set_constructor(ident); @@ -105,7 +105,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Constructor) { TEST_F(WgslGeneratorImplTest, EmitVariable_Const) { auto* ident = create("initializer"); - ast::type::F32Type f32; + ast::type::F32 f32; ast::Variable v("a", ast::StorageClass::kNone, &f32); v.set_constructor(ident); v.set_is_const(true);