diff --git a/BUILD.gn b/BUILD.gn index 07c6aa40b64..d26ae65cac3 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -230,8 +230,6 @@ source_set("libtint_core_src") { "src/ast/access_decoration.h", "src/ast/array_accessor_expression.cc", "src/ast/array_accessor_expression.h", - "src/ast/array_decoration.cc", - "src/ast/array_decoration.h", "src/ast/assignment_statement.cc", "src/ast/assignment_statement.h", "src/ast/binary_expression.cc", @@ -276,8 +274,6 @@ source_set("libtint_core_src") { "src/ast/float_literal.h", "src/ast/function.cc", "src/ast/function.h", - "src/ast/function_decoration.cc", - "src/ast/function_decoration.h", "src/ast/group_decoration.cc", "src/ast/group_decoration.h", "src/ast/identifier_expression.cc", @@ -320,20 +316,14 @@ source_set("libtint_core_src") { "src/ast/struct.h", "src/ast/struct_block_decoration.cc", "src/ast/struct_block_decoration.h", - "src/ast/struct_decoration.cc", - "src/ast/struct_decoration.h", "src/ast/struct_member.cc", "src/ast/struct_member.h", - "src/ast/struct_member_decoration.cc", - "src/ast/struct_member_decoration.h", "src/ast/struct_member_offset_decoration.cc", "src/ast/struct_member_offset_decoration.h", "src/ast/switch_statement.cc", "src/ast/switch_statement.h", "src/ast/type_constructor_expression.cc", "src/ast/type_constructor_expression.h", - "src/ast/type_decoration.cc", - "src/ast/type_decoration.h", "src/ast/uint_literal.cc", "src/ast/uint_literal.h", "src/ast/unary_op.cc", @@ -344,8 +334,6 @@ source_set("libtint_core_src") { "src/ast/variable.h", "src/ast/variable_decl_statement.cc", "src/ast/variable_decl_statement.h", - "src/ast/variable_decoration.cc", - "src/ast/variable_decoration.h", "src/ast/workgroup_decoration.cc", "src/ast/workgroup_decoration.h", "src/block_allocator.h", @@ -797,7 +785,6 @@ source_set("tint_unittests_core_src") { "src/ast/case_statement_test.cc", "src/ast/constant_id_decoration_test.cc", "src/ast/continue_statement_test.cc", - "src/ast/decoration_test.cc", "src/ast/discard_statement_test.cc", "src/ast/else_statement_test.cc", "src/ast/fallthrough_statement_test.cc", @@ -883,6 +870,7 @@ source_set("tint_unittests_core_src") { "src/utils/unique_vector_test.cc", "src/validator/validator_builtins_test.cc", "src/validator/validator_control_block_test.cc", + "src/validator/validator_decoration_test.cc", "src/validator/validator_function_test.cc", "src/validator/validator_test.cc", "src/validator/validator_test_helper.cc", diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d5903bf2ed4..0ba3a57c731 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -44,8 +44,6 @@ set(TINT_LIB_SRCS ast/access_decoration.h ast/array_accessor_expression.cc ast/array_accessor_expression.h - ast/array_decoration.cc - ast/array_decoration.h ast/assignment_statement.cc ast/assignment_statement.h ast/binary_expression.cc @@ -90,8 +88,6 @@ set(TINT_LIB_SRCS ast/float_literal.h ast/function.cc ast/function.h - ast/function_decoration.cc - ast/function_decoration.h ast/group_decoration.cc ast/group_decoration.h ast/identifier_expression.cc @@ -134,20 +130,14 @@ set(TINT_LIB_SRCS ast/struct.h ast/struct_block_decoration.cc ast/struct_block_decoration.h - ast/struct_decoration.cc - ast/struct_decoration.h ast/struct_member.cc ast/struct_member.h - ast/struct_member_decoration.cc - ast/struct_member_decoration.h ast/struct_member_offset_decoration.cc ast/struct_member_offset_decoration.h ast/switch_statement.cc ast/switch_statement.h ast/type_constructor_expression.cc ast/type_constructor_expression.h - ast/type_decoration.cc - ast/type_decoration.h ast/uint_literal.cc ast/uint_literal.h ast/unary_op.cc @@ -156,8 +146,6 @@ set(TINT_LIB_SRCS ast/unary_op_expression.h ast/variable.cc ast/variable.h - ast/variable_decoration.cc - ast/variable_decoration.h ast/variable_decl_statement.cc ast/variable_decl_statement.h ast/workgroup_decoration.cc @@ -426,7 +414,6 @@ if(${TINT_BUILD_TESTS}) ast/case_statement_test.cc ast/constant_id_decoration_test.cc ast/continue_statement_test.cc - ast/decoration_test.cc ast/discard_statement_test.cc ast/else_statement_test.cc ast/fallthrough_statement_test.cc @@ -506,6 +493,7 @@ if(${TINT_BUILD_TESTS}) utils/unique_vector_test.cc validator/validator_builtins_test.cc validator/validator_control_block_test.cc + validator/validator_decoration_test.cc validator/validator_function_test.cc validator/validator_test.cc validator/validator_type_test.cc diff --git a/src/ast/access_decoration.h b/src/ast/access_decoration.h index 9b77f2bf694..fd7697f181c 100644 --- a/src/ast/access_decoration.h +++ b/src/ast/access_decoration.h @@ -16,13 +16,13 @@ #define SRC_AST_ACCESS_DECORATION_H_ #include "src/ast/access_control.h" -#include "src/ast/type_decoration.h" +#include "src/ast/decoration.h" namespace tint { namespace ast { /// An access decoration -class AccessDecoration : public Castable { +class AccessDecoration : public Castable { public: /// constructor /// @param source the source of this decoration diff --git a/src/ast/array_decoration.h b/src/ast/array_decoration.h deleted file mode 100644 index 91dee9f2796..00000000000 --- a/src/ast/array_decoration.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2020 The Tint Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef SRC_AST_ARRAY_DECORATION_H_ -#define SRC_AST_ARRAY_DECORATION_H_ - -#include - -#include "src/ast/decoration.h" - -namespace tint { -namespace ast { - -class StrideDecoration; - -/// A decoration attached to an array -class ArrayDecoration : public Castable { - public: - /// The kind of decoration that this type represents - static constexpr const DecorationKind Kind = DecorationKind::kArray; - - ~ArrayDecoration() override; - - /// @return the decoration kind - DecorationKind GetKind() const override; - - protected: - /// Constructor - /// @param source the source of this decoration - explicit ArrayDecoration(const Source& source); -}; - -/// A list of array decorations -using ArrayDecorationList = std::vector; - -} // namespace ast -} // namespace tint - -#endif // SRC_AST_ARRAY_DECORATION_H_ diff --git a/src/ast/binding_decoration.h b/src/ast/binding_decoration.h index 08107ffc243..f552b8845b0 100644 --- a/src/ast/binding_decoration.h +++ b/src/ast/binding_decoration.h @@ -15,14 +15,13 @@ #ifndef SRC_AST_BINDING_DECORATION_H_ #define SRC_AST_BINDING_DECORATION_H_ -#include "src/ast/variable_decoration.h" +#include "src/ast/decoration.h" namespace tint { namespace ast { /// A binding decoration -class BindingDecoration - : public Castable { +class BindingDecoration : public Castable { public: /// constructor /// @param value the binding value diff --git a/src/ast/builtin_decoration.h b/src/ast/builtin_decoration.h index 85dc0e5db8e..cbc9d06f14e 100644 --- a/src/ast/builtin_decoration.h +++ b/src/ast/builtin_decoration.h @@ -16,14 +16,13 @@ #define SRC_AST_BUILTIN_DECORATION_H_ #include "src/ast/builtin.h" -#include "src/ast/variable_decoration.h" +#include "src/ast/decoration.h" namespace tint { namespace ast { /// A builtin decoration -class BuiltinDecoration - : public Castable { +class BuiltinDecoration : public Castable { public: /// constructor /// @param source the source of this decoration diff --git a/src/ast/constant_id_decoration.h b/src/ast/constant_id_decoration.h index bc9c7c38e05..90b165f254d 100644 --- a/src/ast/constant_id_decoration.h +++ b/src/ast/constant_id_decoration.h @@ -15,14 +15,13 @@ #ifndef SRC_AST_CONSTANT_ID_DECORATION_H_ #define SRC_AST_CONSTANT_ID_DECORATION_H_ -#include "src/ast/variable_decoration.h" +#include "src/ast/decoration.h" namespace tint { namespace ast { /// A constant id decoration -class ConstantIdDecoration - : public Castable { +class ConstantIdDecoration : public Castable { public: /// constructor /// @param source the source of this decoration diff --git a/src/ast/decoration.cc b/src/ast/decoration.cc index 447105f0299..8b8beb852ef 100644 --- a/src/ast/decoration.cc +++ b/src/ast/decoration.cc @@ -21,23 +21,5 @@ namespace ast { Decoration::~Decoration() = default; -std::ostream& operator<<(std::ostream& out, DecorationKind data) { - switch (data) { - case DecorationKind::kArray: - return out << "array"; - case DecorationKind::kFunction: - return out << "function"; - case DecorationKind::kStruct: - return out << "struct"; - case DecorationKind::kStructMember: - return out << "struct member"; - case DecorationKind::kType: - return out << "type"; - case DecorationKind::kVariable: - return out << "variable"; - } - return out << ""; -} - } // namespace ast } // namespace tint diff --git a/src/ast/decoration.h b/src/ast/decoration.h index 32b1e600832..b9b5a3cb1ae 100644 --- a/src/ast/decoration.h +++ b/src/ast/decoration.h @@ -22,26 +22,11 @@ namespace tint { namespace ast { -/// The decoration kind enumerator -enum class DecorationKind { - kArray, - kFunction, - kStruct, - kStructMember, - kType, - kVariable, -}; - -std::ostream& operator<<(std::ostream& out, DecorationKind data); - /// The base class for all decorations class Decoration : public Castable { public: ~Decoration() override; - /// @return the decoration kind - virtual DecorationKind GetKind() const = 0; - protected: /// Constructor /// @param source the source of this decoration diff --git a/src/ast/decoration_test.cc b/src/ast/decoration_test.cc deleted file mode 100644 index 1bab2c019c6..00000000000 --- a/src/ast/decoration_test.cc +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2020 The Tint Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "src/ast/access_decoration.h" -#include "src/ast/constant_id_decoration.h" -#include "src/ast/stage_decoration.h" -#include "src/ast/test_helper.h" -#include "src/ast/workgroup_decoration.h" - -namespace tint { -namespace ast { -namespace { - -using DecorationTest = TestHelper; - -TEST_F(DecorationTest, AsCorrectType) { - auto* decoration = create(1); - auto* upcast = static_cast(decoration); - auto* downcast = As(upcast); - EXPECT_EQ(decoration, downcast); -} - -TEST_F(DecorationTest, AsIncorrectType) { - auto* decoration = create(1); - auto* upcast = static_cast(decoration); - auto* downcast = As(upcast); - EXPECT_EQ(nullptr, downcast); -} - -TEST_F(DecorationTest, Is) { - Decoration* decoration = create(1); - EXPECT_TRUE(decoration->Is()); - EXPECT_FALSE(decoration->Is()); -} - -TEST_F(DecorationTest, Kinds) { - EXPECT_EQ(ArrayDecoration::Kind, DecorationKind::kArray); - EXPECT_EQ(StrideDecoration::Kind, DecorationKind::kArray); - EXPECT_EQ(FunctionDecoration::Kind, DecorationKind::kFunction); - EXPECT_EQ(StageDecoration::Kind, DecorationKind::kFunction); - EXPECT_EQ(WorkgroupDecoration::Kind, DecorationKind::kFunction); - EXPECT_EQ(StructDecoration::Kind, DecorationKind::kStruct); - EXPECT_EQ(StructMemberDecoration::Kind, DecorationKind::kStructMember); - EXPECT_EQ(StructMemberOffsetDecoration::Kind, DecorationKind::kStructMember); - EXPECT_EQ(TypeDecoration::Kind, DecorationKind::kType); - EXPECT_EQ(AccessDecoration::Kind, DecorationKind::kType); - EXPECT_EQ(VariableDecoration::Kind, DecorationKind::kVariable); - EXPECT_EQ(BindingDecoration::Kind, DecorationKind::kVariable); - EXPECT_EQ(BuiltinDecoration::Kind, DecorationKind::kVariable); - EXPECT_EQ(ConstantIdDecoration::Kind, DecorationKind::kVariable); - EXPECT_EQ(LocationDecoration::Kind, DecorationKind::kVariable); -} - -} // namespace -} // namespace ast -} // namespace tint diff --git a/src/ast/function.cc b/src/ast/function.cc index 8f47a1b86eb..069b66cf092 100644 --- a/src/ast/function.cc +++ b/src/ast/function.cc @@ -28,7 +28,7 @@ Function::Function(const Source& source, VariableList params, type::Type* return_type, BlockStatement* body, - FunctionDecorationList decorations) + DecorationList decorations) : Base(source), symbol_(symbol), params_(std::move(params)), diff --git a/src/ast/function.h b/src/ast/function.h index 109c5df80fb..c3db11ffa1b 100644 --- a/src/ast/function.h +++ b/src/ast/function.h @@ -23,7 +23,7 @@ #include "src/ast/binding_decoration.h" #include "src/ast/block_statement.h" #include "src/ast/builtin_decoration.h" -#include "src/ast/function_decoration.h" +#include "src/ast/decoration.h" #include "src/ast/group_decoration.h" #include "src/ast/location_decoration.h" #include "src/ast/pipeline_stage.h" @@ -47,7 +47,7 @@ class Function : public Castable { VariableList params, type::Type* return_type, BlockStatement* body, - FunctionDecorationList decorations); + DecorationList decorations); /// Move constructor Function(Function&&); @@ -59,7 +59,7 @@ class Function : public Castable { const VariableList& params() const { return params_; } /// @returns the decorations attached to this function - const FunctionDecorationList& decorations() const { return decorations_; } + const DecorationList& decorations() const { return decorations_; } /// @returns the workgroup size {x, y, z} for the function. {1, 1, 1} will be /// return if no workgroup size was set. @@ -107,7 +107,7 @@ class Function : public Castable { VariableList const params_; type::Type* const return_type_; BlockStatement* const body_; - FunctionDecorationList const decorations_; + DecorationList const decorations_; }; /// A list of functions diff --git a/src/ast/function_decoration.cc b/src/ast/function_decoration.cc deleted file mode 100644 index 802bd9caa92..00000000000 --- a/src/ast/function_decoration.cc +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2020 The Tint Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "src/ast/function_decoration.h" - -TINT_INSTANTIATE_TYPEINFO(tint::ast::FunctionDecoration); - -namespace tint { -namespace ast { - -constexpr const DecorationKind FunctionDecoration::Kind; - -FunctionDecoration::FunctionDecoration(const Source& source) : Base(source) {} - -FunctionDecoration::~FunctionDecoration() = default; - -DecorationKind FunctionDecoration::GetKind() const { - return Kind; -} - -} // namespace ast -} // namespace tint diff --git a/src/ast/function_test.cc b/src/ast/function_test.cc index 39a478d7987..ccb9071fd93 100644 --- a/src/ast/function_test.cc +++ b/src/ast/function_test.cc @@ -29,8 +29,7 @@ TEST_F(FunctionTest, Creation) { params.push_back(Var("var", ty.i32(), StorageClass::kNone)); auto* var = params[0]; - auto* f = Func("func", params, ty.void_(), StatementList{}, - FunctionDecorationList{}); + auto* f = Func("func", params, ty.void_(), StatementList{}, DecorationList{}); EXPECT_EQ(f->symbol(), Symbols().Get("func")); ASSERT_EQ(f->params().size(), 1u); EXPECT_EQ(f->return_type(), ty.void_()); @@ -42,7 +41,7 @@ TEST_F(FunctionTest, Creation_WithSource) { params.push_back(Var("var", ty.i32(), StorageClass::kNone)); auto* f = Func(Source{Source::Location{20, 2}}, "func", params, ty.void_(), - StatementList{}, FunctionDecorationList{}); + StatementList{}, DecorationList{}); auto src = f->source(); EXPECT_EQ(src.range.begin.line, 20u); EXPECT_EQ(src.range.begin.column, 2u); @@ -53,7 +52,7 @@ TEST_F(FunctionTest, Assert_InvalidName) { { ProgramBuilder b; b.Func("", VariableList{}, b.ty.void_(), StatementList{}, - FunctionDecorationList{}); + DecorationList{}); }, "internal compiler error"); } @@ -62,8 +61,7 @@ TEST_F(FunctionTest, Assert_NullReturnType) { EXPECT_FATAL_FAILURE( { ProgramBuilder b; - b.Func("f", VariableList{}, nullptr, StatementList{}, - FunctionDecorationList{}); + b.Func("f", VariableList{}, nullptr, StatementList{}, DecorationList{}); }, "internal compiler error"); } @@ -76,8 +74,7 @@ TEST_F(FunctionTest, Assert_NullParam) { params.push_back(b.Var("var", b.ty.i32(), StorageClass::kNone)); params.push_back(nullptr); - b.Func("f", params, b.ty.void_(), StatementList{}, - FunctionDecorationList{}); + b.Func("f", params, b.ty.void_(), StatementList{}, DecorationList{}); }, "internal compiler error"); } @@ -87,7 +84,7 @@ TEST_F(FunctionTest, ToStr) { StatementList{ create(), }, - FunctionDecorationList{}); + DecorationList{}); EXPECT_EQ(str(f), R"(Function func -> __void () @@ -102,7 +99,7 @@ TEST_F(FunctionTest, ToStr_WithDecoration) { StatementList{ create(), }, - FunctionDecorationList{create(2, 4, 6)}); + DecorationList{create(2, 4, 6)}); EXPECT_EQ(str(f), R"(Function func -> __void WorkgroupDecoration{2 4 6} @@ -121,7 +118,7 @@ TEST_F(FunctionTest, ToStr_WithParams) { StatementList{ create(), }, - FunctionDecorationList{}); + DecorationList{}); EXPECT_EQ(str(f), R"(Function func -> __void ( @@ -139,7 +136,7 @@ TEST_F(FunctionTest, ToStr_WithParams) { TEST_F(FunctionTest, TypeName) { auto* f = Func("func", VariableList{}, ty.void_(), StatementList{}, - FunctionDecorationList{}); + DecorationList{}); EXPECT_EQ(f->type_name(), "__func__void"); } @@ -148,31 +145,29 @@ TEST_F(FunctionTest, TypeName_WithParams) { params.push_back(Var("var1", ty.i32(), StorageClass::kNone)); params.push_back(Var("var2", ty.f32(), StorageClass::kNone)); - auto* f = Func("func", params, ty.void_(), StatementList{}, - FunctionDecorationList{}); + auto* f = Func("func", params, ty.void_(), StatementList{}, DecorationList{}); EXPECT_EQ(f->type_name(), "__func__void__i32__f32"); } TEST_F(FunctionTest, GetLastStatement) { VariableList params; auto* stmt = create(); - auto* f = Func("func", params, ty.void_(), StatementList{stmt}, - FunctionDecorationList{}); + auto* f = + Func("func", params, ty.void_(), StatementList{stmt}, DecorationList{}); EXPECT_EQ(f->get_last_statement(), stmt); } TEST_F(FunctionTest, GetLastStatement_nullptr) { VariableList params; - auto* f = Func("func", params, ty.void_(), StatementList{}, - FunctionDecorationList{}); + auto* f = Func("func", params, ty.void_(), StatementList{}, DecorationList{}); EXPECT_EQ(f->get_last_statement(), nullptr); } TEST_F(FunctionTest, WorkgroupSize_NoneSet) { auto* f = Func("func", VariableList{}, ty.void_(), StatementList{}, - FunctionDecorationList{}); + DecorationList{}); uint32_t x = 0; uint32_t y = 0; uint32_t z = 0; @@ -183,9 +178,8 @@ TEST_F(FunctionTest, WorkgroupSize_NoneSet) { } TEST_F(FunctionTest, WorkgroupSize) { - auto* f = - Func("func", VariableList{}, ty.void_(), StatementList{}, - FunctionDecorationList{create(2u, 4u, 6u)}); + auto* f = Func("func", VariableList{}, ty.void_(), StatementList{}, + DecorationList{create(2u, 4u, 6u)}); uint32_t x = 0; uint32_t y = 0; @@ -200,7 +194,7 @@ using FunctionListTest = TestHelper; TEST_F(FunctionListTest, FindSymbol) { auto* func = Func("main", VariableList{}, ty.f32(), StatementList{}, - ast::FunctionDecorationList{}); + ast::DecorationList{}); FunctionList list; list.Add(func); EXPECT_EQ(func, list.Find(Symbols().Register("main"))); @@ -213,11 +207,11 @@ TEST_F(FunctionListTest, FindSymbolMissing) { TEST_F(FunctionListTest, FindSymbolStage) { auto* fs = Func("main", VariableList{}, ty.f32(), StatementList{}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(PipelineStage::kFragment), }); auto* vs = Func("main", VariableList{}, ty.f32(), StatementList{}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(PipelineStage::kVertex), }); FunctionList list; @@ -231,7 +225,7 @@ TEST_F(FunctionListTest, FindSymbolStage) { TEST_F(FunctionListTest, FindSymbolStageMissing) { FunctionList list; list.Add(Func("main", VariableList{}, ty.f32(), StatementList{}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(PipelineStage::kFragment), })); EXPECT_EQ(nullptr, @@ -241,7 +235,7 @@ TEST_F(FunctionListTest, FindSymbolStageMissing) { TEST_F(FunctionListTest, HasStage) { FunctionList list; list.Add(Func("main", VariableList{}, ty.f32(), StatementList{}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(PipelineStage::kFragment), })); EXPECT_TRUE(list.HasStage(PipelineStage::kFragment)); diff --git a/src/ast/group_decoration.h b/src/ast/group_decoration.h index 431ef869397..b7482f0b6c1 100644 --- a/src/ast/group_decoration.h +++ b/src/ast/group_decoration.h @@ -15,13 +15,13 @@ #ifndef SRC_AST_GROUP_DECORATION_H_ #define SRC_AST_GROUP_DECORATION_H_ -#include "src/ast/variable_decoration.h" +#include "src/ast/decoration.h" namespace tint { namespace ast { /// A group decoration -class GroupDecoration : public Castable { +class GroupDecoration : public Castable { public: /// constructor /// @param value the group value diff --git a/src/ast/intrinsic_texture_helper_test.cc b/src/ast/intrinsic_texture_helper_test.cc index 4a8748c12d5..894858a05a0 100644 --- a/src/ast/intrinsic_texture_helper_test.cc +++ b/src/ast/intrinsic_texture_helper_test.cc @@ -151,7 +151,7 @@ ast::Variable* TextureOverloadCase::buildTextureVariable( ProgramBuilder* b) const { auto* datatype = resultVectorComponentType(b); - VariableDecorationList decos = { + DecorationList decos = { b->create(0), b->create(0), }; @@ -189,7 +189,7 @@ ast::Variable* TextureOverloadCase::buildTextureVariable( ast::Variable* TextureOverloadCase::buildSamplerVariable( ProgramBuilder* b) const { - VariableDecorationList decos = { + DecorationList decos = { b->create(0), b->create(1), }; diff --git a/src/ast/location_decoration.h b/src/ast/location_decoration.h index c4715e5f01d..4318199a00a 100644 --- a/src/ast/location_decoration.h +++ b/src/ast/location_decoration.h @@ -15,14 +15,13 @@ #ifndef SRC_AST_LOCATION_DECORATION_H_ #define SRC_AST_LOCATION_DECORATION_H_ -#include "src/ast/variable_decoration.h" +#include "src/ast/decoration.h" namespace tint { namespace ast { /// A location decoration -class LocationDecoration - : public Castable { +class LocationDecoration : public Castable { public: /// constructor /// @param source the source of this decoration diff --git a/src/ast/module_test.cc b/src/ast/module_test.cc index ff3288ea0f2..568790defad 100644 --- a/src/ast/module_test.cc +++ b/src/ast/module_test.cc @@ -33,7 +33,7 @@ TEST_F(ModuleTest, ToStrEmitsPreambleAndPostamble) { TEST_F(ModuleTest, LookupFunction) { auto* func = Func("main", VariableList{}, ty.f32(), StatementList{}, - ast::FunctionDecorationList{}); + ast::DecorationList{}); Program program(std::move(*this)); EXPECT_EQ(func, diff --git a/src/ast/stage_decoration.h b/src/ast/stage_decoration.h index bd89394a0f4..9509501b7fd 100644 --- a/src/ast/stage_decoration.h +++ b/src/ast/stage_decoration.h @@ -15,14 +15,14 @@ #ifndef SRC_AST_STAGE_DECORATION_H_ #define SRC_AST_STAGE_DECORATION_H_ -#include "src/ast/function_decoration.h" +#include "src/ast/decoration.h" #include "src/ast/pipeline_stage.h" namespace tint { namespace ast { /// A workgroup decoration -class StageDecoration : public Castable { +class StageDecoration : public Castable { public: /// constructor /// @param stage the pipeline stage diff --git a/src/ast/stride_decoration.h b/src/ast/stride_decoration.h index 9b350dfa71b..b656c344ea0 100644 --- a/src/ast/stride_decoration.h +++ b/src/ast/stride_decoration.h @@ -15,13 +15,13 @@ #ifndef SRC_AST_STRIDE_DECORATION_H_ #define SRC_AST_STRIDE_DECORATION_H_ -#include "src/ast/array_decoration.h" +#include "src/ast/decoration.h" namespace tint { namespace ast { /// A stride decoration -class StrideDecoration : public Castable { +class StrideDecoration : public Castable { public: /// constructor /// @param stride the stride value diff --git a/src/ast/struct.cc b/src/ast/struct.cc index 66043995e2d..7d857b7c7d0 100644 --- a/src/ast/struct.cc +++ b/src/ast/struct.cc @@ -24,7 +24,7 @@ namespace ast { Struct::Struct(const Source& source, StructMemberList members, - StructDecorationList decorations) + DecorationList decorations) : Base(source), members_(std::move(members)), decorations_(std::move(decorations)) { diff --git a/src/ast/struct.h b/src/ast/struct.h index 58f165fbe35..aa581b6e7a6 100644 --- a/src/ast/struct.h +++ b/src/ast/struct.h @@ -17,7 +17,7 @@ #include -#include "src/ast/struct_decoration.h" +#include "src/ast/decoration.h" #include "src/ast/struct_member.h" namespace tint { @@ -32,14 +32,14 @@ class Struct : public Castable { /// @param decorations The struct decorations Struct(const Source& source, StructMemberList members, - StructDecorationList decorations); + DecorationList decorations); /// Move constructor Struct(Struct&&); ~Struct() override; /// @returns the struct decorations - const StructDecorationList& decorations() const { return decorations_; } + const DecorationList& decorations() const { return decorations_; } /// @returns the members const StructMemberList& members() const { return members_; } @@ -70,7 +70,7 @@ class Struct : public Castable { Struct(const Struct&) = delete; StructMemberList const members_; - StructDecorationList const decorations_; + DecorationList const decorations_; }; } // namespace ast diff --git a/src/ast/struct_block_decoration.h b/src/ast/struct_block_decoration.h index cd4bd4fc159..ca8a51e5a6f 100644 --- a/src/ast/struct_block_decoration.h +++ b/src/ast/struct_block_decoration.h @@ -17,14 +17,14 @@ #include -#include "src/ast/struct_decoration.h" +#include "src/ast/decoration.h" namespace tint { namespace ast { /// The struct decorations class StructBlockDecoration - : public Castable { + : public Castable { public: /// constructor /// @param source the source of this decoration @@ -47,7 +47,7 @@ class StructBlockDecoration }; /// List of struct decorations -using StructDecorationList = std::vector; +using DecorationList = std::vector; } // namespace ast } // namespace tint diff --git a/src/ast/struct_decoration.cc b/src/ast/struct_decoration.cc deleted file mode 100644 index 14ff5eb8b08..00000000000 --- a/src/ast/struct_decoration.cc +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2020 The Tint Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "src/ast/struct_decoration.h" - -TINT_INSTANTIATE_TYPEINFO(tint::ast::StructDecoration); - -namespace tint { -namespace ast { - -constexpr const DecorationKind StructDecoration::Kind; - -StructDecoration::StructDecoration(const Source& source) : Base(source) {} - -StructDecoration::~StructDecoration() = default; - -DecorationKind StructDecoration::GetKind() const { - return Kind; -} - -} // namespace ast -} // namespace tint diff --git a/src/ast/struct_member.cc b/src/ast/struct_member.cc index 4a3a18a375e..c576ee7b155 100644 --- a/src/ast/struct_member.cc +++ b/src/ast/struct_member.cc @@ -24,7 +24,7 @@ namespace ast { StructMember::StructMember(const Source& source, const Symbol& sym, type::Type* type, - StructMemberDecorationList decorations) + DecorationList decorations) : Base(source), symbol_(sym), type_(type), diff --git a/src/ast/struct_member.h b/src/ast/struct_member.h index 0595b34c730..c02cc7eb24c 100644 --- a/src/ast/struct_member.h +++ b/src/ast/struct_member.h @@ -18,7 +18,7 @@ #include #include -#include "src/ast/struct_member_decoration.h" +#include "src/ast/decoration.h" namespace tint { namespace ast { @@ -34,7 +34,7 @@ class StructMember : public Castable { StructMember(const Source& source, const Symbol& sym, type::Type* type, - StructMemberDecorationList decorations); + DecorationList decorations); /// Move constructor StructMember(StructMember&&); @@ -46,7 +46,7 @@ class StructMember : public Castable { type::Type* type() const { return type_; } /// @returns the decorations - const StructMemberDecorationList& decorations() const { return decorations_; } + const DecorationList& decorations() const { return decorations_; } /// @returns true if the struct member has an offset decoration bool has_offset_decoration() const; @@ -72,7 +72,7 @@ class StructMember : public Castable { Symbol const symbol_; type::Type* const type_; - StructMemberDecorationList const decorations_; + DecorationList const decorations_; }; /// A list of struct members diff --git a/src/ast/struct_member_decoration.h b/src/ast/struct_member_decoration.h deleted file mode 100644 index 6a028dd97af..00000000000 --- a/src/ast/struct_member_decoration.h +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2020 The Tint Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef SRC_AST_STRUCT_MEMBER_DECORATION_H_ -#define SRC_AST_STRUCT_MEMBER_DECORATION_H_ - -#include - -#include "src/ast/decoration.h" - -namespace tint { -namespace ast { - -/// A decoration attached to a struct member -class StructMemberDecoration - : public Castable { - public: - /// The kind of decoration that this type represents - static constexpr const DecorationKind Kind = DecorationKind::kStructMember; - - ~StructMemberDecoration() override; - - /// @return the decoration kind - DecorationKind GetKind() const override; - - protected: - /// Constructor - /// @param source the source of this decoration - explicit StructMemberDecoration(const Source& source); -}; - -/// A list of struct member decorations -using StructMemberDecorationList = std::vector; - -} // namespace ast -} // namespace tint - -#endif // SRC_AST_STRUCT_MEMBER_DECORATION_H_ diff --git a/src/ast/struct_member_offset_decoration.h b/src/ast/struct_member_offset_decoration.h index 1052c69cd23..d793e7532b6 100644 --- a/src/ast/struct_member_offset_decoration.h +++ b/src/ast/struct_member_offset_decoration.h @@ -15,14 +15,14 @@ #ifndef SRC_AST_STRUCT_MEMBER_OFFSET_DECORATION_H_ #define SRC_AST_STRUCT_MEMBER_OFFSET_DECORATION_H_ -#include "src/ast/struct_member_decoration.h" +#include "src/ast/decoration.h" namespace tint { namespace ast { /// A struct member offset decoration class StructMemberOffsetDecoration - : public Castable { + : public Castable { public: /// constructor /// @param source the source of this decoration diff --git a/src/ast/struct_test.cc b/src/ast/struct_test.cc index 421c50f7147..867696692c1 100644 --- a/src/ast/struct_test.cc +++ b/src/ast/struct_test.cc @@ -23,8 +23,8 @@ namespace { using StructTest = TestHelper; TEST_F(StructTest, Creation) { - auto* s = create(StructMemberList{Member("a", ty.i32())}, - StructDecorationList{}); + auto* s = + create(StructMemberList{Member("a", ty.i32())}, DecorationList{}); EXPECT_EQ(s->members().size(), 1u); EXPECT_TRUE(s->decorations().empty()); EXPECT_EQ(s->source().range.begin.line, 0u); @@ -34,7 +34,7 @@ TEST_F(StructTest, Creation) { } TEST_F(StructTest, Creation_WithDecorations) { - StructDecorationList decos; + DecorationList decos; decos.push_back(create()); auto* s = create(StructMemberList{Member("a", ty.i32())}, decos); @@ -48,7 +48,7 @@ TEST_F(StructTest, Creation_WithDecorations) { } TEST_F(StructTest, CreationWithSourceAndDecorations) { - StructDecorationList decos; + DecorationList decos; decos.push_back(create()); auto* s = create( @@ -68,7 +68,7 @@ TEST_F(StructTest, Assert_Null_StructMember) { { ProgramBuilder b; b.create(StructMemberList{b.Member("a", b.ty.i32()), nullptr}, - StructDecorationList{}); + DecorationList{}); }, "internal compiler error"); } @@ -78,13 +78,13 @@ TEST_F(StructTest, Assert_Null_Decoration) { { ProgramBuilder b; b.create(StructMemberList{b.Member("a", b.ty.i32())}, - StructDecorationList{nullptr}); + DecorationList{nullptr}); }, "internal compiler error"); } TEST_F(StructTest, ToStr) { - StructDecorationList decos; + DecorationList decos; decos.push_back(create()); auto* s = create(StructMemberList{Member("a", ty.i32())}, decos); diff --git a/src/ast/type_decoration.h b/src/ast/type_decoration.h deleted file mode 100644 index 46c34785962..00000000000 --- a/src/ast/type_decoration.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2020 The Tint Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef SRC_AST_TYPE_DECORATION_H_ -#define SRC_AST_TYPE_DECORATION_H_ - -#include - -#include "src/ast/decoration.h" - -namespace tint { -namespace ast { - -class AccessDecoration; - -/// A decoration attached to a type -class TypeDecoration : public Castable { - public: - /// The kind of decoration that this type represents - static constexpr const DecorationKind Kind = DecorationKind::kType; - - ~TypeDecoration() override; - - /// @return the decoration kind - DecorationKind GetKind() const override; - - protected: - /// Constructor - /// @param source the source of this decoration - explicit TypeDecoration(const Source& source); -}; - -/// A list of type decorations -using TypeDecorationList = std::vector; - -} // namespace ast -} // namespace tint - -#endif // SRC_AST_TYPE_DECORATION_H_ diff --git a/src/ast/variable.cc b/src/ast/variable.cc index 9606b331a6f..a7a5f1bc3c3 100644 --- a/src/ast/variable.cc +++ b/src/ast/variable.cc @@ -29,7 +29,7 @@ Variable::Variable(const Source& source, type::Type* type, bool is_const, Expression* constructor, - VariableDecorationList decorations) + DecorationList decorations) : Base(source), symbol_(sym), type_(type), diff --git a/src/ast/variable.h b/src/ast/variable.h index 3e44dcfb9fa..a7c7b652b69 100644 --- a/src/ast/variable.h +++ b/src/ast/variable.h @@ -18,9 +18,9 @@ #include #include +#include "src/ast/decoration.h" #include "src/ast/expression.h" #include "src/ast/storage_class.h" -#include "src/ast/variable_decoration.h" namespace tint { namespace ast { @@ -90,7 +90,7 @@ class Variable : public Castable { type::Type* type, bool is_const, Expression* constructor, - VariableDecorationList decorations); + DecorationList decorations); /// Move constructor Variable(Variable&&); @@ -115,7 +115,7 @@ class Variable : public Castable { bool is_const() const { return is_const_; } /// @returns the decorations attached to this variable - const VariableDecorationList& decorations() const { return decorations_; } + const DecorationList& decorations() const { return decorations_; } /// @returns true if the decorations include a LocationDecoration bool HasLocationDecoration() const; @@ -169,7 +169,7 @@ class Variable : public Castable { type::Type* const type_; bool const is_const_; Expression* const constructor_; - VariableDecorationList const decorations_; + DecorationList const decorations_; StorageClass const declared_storage_class_; }; diff --git a/src/ast/variable_decoration.h b/src/ast/variable_decoration.h deleted file mode 100644 index 74736802ac3..00000000000 --- a/src/ast/variable_decoration.h +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2020 The Tint Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef SRC_AST_VARIABLE_DECORATION_H_ -#define SRC_AST_VARIABLE_DECORATION_H_ - -#include - -#include "src/ast/decoration.h" - -namespace tint { -namespace ast { - -/// A decoration attached to a variable -class VariableDecoration : public Castable { - public: - /// The kind of decoration that this type represents - static constexpr const DecorationKind Kind = DecorationKind::kVariable; - - ~VariableDecoration() override; - - /// @return the decoration kind - DecorationKind GetKind() const override; - - protected: - /// Constructor - /// @param source the source of this decoration - explicit VariableDecoration(const Source& source); -}; - -/// A list of variable decorations -using VariableDecorationList = std::vector; - -} // namespace ast -} // namespace tint - -#endif // SRC_AST_VARIABLE_DECORATION_H_ diff --git a/src/ast/variable_test.cc b/src/ast/variable_test.cc index 51390803f5e..4d5b967146b 100644 --- a/src/ast/variable_test.cc +++ b/src/ast/variable_test.cc @@ -37,7 +37,7 @@ TEST_F(VariableTest, Creation) { TEST_F(VariableTest, CreationWithSource) { auto* v = Var( Source{Source::Range{Source::Location{27, 4}, Source::Location{27, 5}}}, - "i", ty.f32(), StorageClass::kPrivate, nullptr, VariableDecorationList{}); + "i", ty.f32(), StorageClass::kPrivate, nullptr, DecorationList{}); EXPECT_EQ(v->symbol(), Symbol(1)); EXPECT_EQ(v->declared_storage_class(), StorageClass::kPrivate); @@ -51,8 +51,7 @@ TEST_F(VariableTest, CreationWithSource) { TEST_F(VariableTest, CreationEmpty) { auto* v = Var( Source{Source::Range{Source::Location{27, 4}, Source::Location{27, 7}}}, - "a_var", ty.i32(), StorageClass::kWorkgroup, nullptr, - VariableDecorationList{}); + "a_var", ty.i32(), StorageClass::kWorkgroup, nullptr, DecorationList{}); EXPECT_EQ(v->symbol(), Symbol(1)); EXPECT_EQ(v->declared_storage_class(), StorageClass::kWorkgroup); @@ -93,7 +92,7 @@ TEST_F(VariableTest, to_str) { TEST_F(VariableTest, WithDecorations) { auto* var = Var("my_var", ty.i32(), StorageClass::kFunction, nullptr, - VariableDecorationList{ + DecorationList{ create(1), create(Builtin::kPosition), create(1200), @@ -110,7 +109,7 @@ TEST_F(VariableTest, WithDecorations) { TEST_F(VariableTest, ConstantId) { auto* var = Var("my_var", ty.i32(), StorageClass::kFunction, nullptr, - VariableDecorationList{ + DecorationList{ create(1200), }); @@ -119,7 +118,7 @@ TEST_F(VariableTest, ConstantId) { TEST_F(VariableTest, Decorated_to_str) { auto* var = Var("my_var", ty.f32(), StorageClass::kFunction, Expr("expr"), - VariableDecorationList{ + DecorationList{ create(2), create(1), }); diff --git a/src/ast/workgroup_decoration.h b/src/ast/workgroup_decoration.h index 16fe42a07e6..19c8dd100af 100644 --- a/src/ast/workgroup_decoration.h +++ b/src/ast/workgroup_decoration.h @@ -17,14 +17,13 @@ #include -#include "src/ast/function_decoration.h" +#include "src/ast/decoration.h" namespace tint { namespace ast { /// A workgroup decoration -class WorkgroupDecoration - : public Castable { +class WorkgroupDecoration : public Castable { public: /// constructor /// @param source the source of this decoration diff --git a/src/inspector/inspector_test.cc b/src/inspector/inspector_test.cc index fe735405d58..5e7b95ec66d 100644 --- a/src/inspector/inspector_test.cc +++ b/src/inspector/inspector_test.cc @@ -37,7 +37,7 @@ class InspectorHelper : public ProgramBuilder { /// @param name name of the function created /// @param decorations the function decorations void MakeEmptyBodyFunction(std::string name, - ast::FunctionDecorationList decorations) { + ast::DecorationList decorations) { Func(name, ast::VariableList(), ty.void_(), ast::StatementList{create()}, decorations); } @@ -48,7 +48,7 @@ class InspectorHelper : public ProgramBuilder { /// @param decorations the function decorations void MakeCallerBodyFunction(std::string caller, std::vector callees, - ast::FunctionDecorationList decorations) { + ast::DecorationList decorations) { ast::StatementList body; body.reserve(callees.size() + 1); for (auto callee : callees) { @@ -70,11 +70,9 @@ class InspectorHelper : public ProgramBuilder { std::tie(in, out) = inout; Global(in, ty.u32(), ast::StorageClass::kInput, nullptr, - ast::VariableDecorationList{ - create(location++)}); + ast::DecorationList{create(location++)}); Global(out, ty.u32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{ - create(location++)}); + ast::DecorationList{create(location++)}); } } @@ -86,7 +84,7 @@ class InspectorHelper : public ProgramBuilder { void MakeInOutVariableBodyFunction( std::string name, std::vector> inout_vars, - ast::FunctionDecorationList decorations) { + ast::DecorationList decorations) { ast::StatementList stmts; for (auto inout : inout_vars) { std::string in, out; @@ -109,7 +107,7 @@ class InspectorHelper : public ProgramBuilder { std::string caller, std::string callee, std::vector> inout_vars, - ast::FunctionDecorationList decorations) { + ast::DecorationList decorations) { ast::StatementList stmts; for (auto inout : inout_vars) { std::string in, out; @@ -136,7 +134,7 @@ class InspectorHelper : public ProgramBuilder { create(MakeLiteral(type, val)); } GlobalConst(name, type, constructor, - ast::VariableDecorationList{ + ast::DecorationList{ create(id), }); } @@ -210,7 +208,7 @@ class InspectorHelper : public ProgramBuilder { {MemberOffset(offset)})); } - ast::StructDecorationList decos; + ast::DecorationList decos; if (is_block) { decos.push_back(create()); } @@ -280,7 +278,7 @@ class InspectorHelper : public ProgramBuilder { uint32_t group, uint32_t binding) { Global(name, type, storage_class, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(binding), create(group), }); @@ -343,7 +341,7 @@ class InspectorHelper : public ProgramBuilder { stmts.emplace_back(create()); Func(func_name, ast::VariableList(), ty.void_(), stmts, - ast::FunctionDecorationList{}); + ast::DecorationList{}); } /// Adds a regular sampler variable to the program @@ -446,7 +444,7 @@ class InspectorHelper : public ProgramBuilder { const std::string& sampler_name, const std::string& coords_name, type::Type* base_type, - ast::FunctionDecorationList decorations) { + ast::DecorationList decorations) { std::string result_name = "sampler_result"; ast::StatementList stmts; @@ -478,7 +476,7 @@ class InspectorHelper : public ProgramBuilder { const std::string& coords_name, const std::string& array_index, type::Type* base_type, - ast::FunctionDecorationList decorations) { + ast::DecorationList decorations) { std::string result_name = "sampler_result"; ast::StatementList stmts; @@ -512,7 +510,7 @@ class InspectorHelper : public ProgramBuilder { const std::string& coords_name, const std::string& depth_name, type::Type* base_type, - ast::FunctionDecorationList decorations) { + ast::DecorationList decorations) { std::string result_name = "sampler_result"; ast::StatementList stmts; @@ -617,7 +615,7 @@ class InspectorHelper : public ProgramBuilder { const std::string& func_name, const std::string& st_name, type::Type* dim_type, - ast::FunctionDecorationList decorations) { + ast::DecorationList decorations) { ast::StatementList stmts; stmts.emplace_back(create( @@ -646,7 +644,7 @@ class InspectorHelper : public ProgramBuilder { if (array_type_memo_.find(count) == array_type_memo_.end()) { array_type_memo_[count] = create(ty.u32(), count, - ast::ArrayDecorationList{ + ast::DecorationList{ create(4), }); } @@ -763,7 +761,7 @@ TEST_F(InspectorGetEntryPointTest, NoEntryPoints) { TEST_F(InspectorGetEntryPointTest, OneEntryPoint) { MakeEmptyBodyFunction( - "foo", ast::FunctionDecorationList{ + "foo", ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -782,12 +780,12 @@ TEST_F(InspectorGetEntryPointTest, OneEntryPoint) { TEST_F(InspectorGetEntryPointTest, MultipleEntryPoints) { MakeEmptyBodyFunction( - "foo", ast::FunctionDecorationList{ + "foo", ast::DecorationList{ create(ast::PipelineStage::kVertex), }); MakeEmptyBodyFunction( - "bar", ast::FunctionDecorationList{ + "bar", ast::DecorationList{ create(ast::PipelineStage::kCompute), }); @@ -812,13 +810,13 @@ TEST_F(InspectorGetEntryPointTest, MixFunctionsAndEntryPoints) { MakeCallerBodyFunction( "foo", {"func"}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); MakeCallerBodyFunction( "bar", {"func"}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -840,7 +838,7 @@ TEST_F(InspectorGetEntryPointTest, MixFunctionsAndEntryPoints) { TEST_F(InspectorGetEntryPointTest, DefaultWorkgroupSize) { MakeEmptyBodyFunction( - "foo", ast::FunctionDecorationList{ + "foo", ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -859,7 +857,7 @@ TEST_F(InspectorGetEntryPointTest, DefaultWorkgroupSize) { TEST_F(InspectorGetEntryPointTest, NonDefaultWorkgroupSize) { MakeEmptyBodyFunction( - "foo", ast::FunctionDecorationList{ + "foo", ast::DecorationList{ create(ast::PipelineStage::kCompute), create(8u, 2u, 1u), }); @@ -882,7 +880,7 @@ TEST_F(InspectorGetEntryPointTest, NoInOutVariables) { MakeCallerBodyFunction( "foo", {"func"}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -901,7 +899,7 @@ TEST_F(InspectorGetEntryPointTest, EntryPointInOutVariables) { MakeInOutVariableBodyFunction( "foo", {{"in_var", "out_var"}}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -932,7 +930,7 @@ TEST_F(InspectorGetEntryPointTest, FunctionInOutVariables) { MakeCallerBodyFunction( "foo", {"func"}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -963,7 +961,7 @@ TEST_F(InspectorGetEntryPointTest, RepeatedInOutVariables) { MakeInOutVariableCallerBodyFunction( "foo", "func", {{"in_var", "out_var"}}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -992,7 +990,7 @@ TEST_F(InspectorGetEntryPointTest, EntryPointMultipleInOutVariables) { MakeInOutVariableBodyFunction( "foo", {{"in_var", "out_var"}, {"in2_var", "out2_var"}}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -1032,7 +1030,7 @@ TEST_F(InspectorGetEntryPointTest, FunctionMultipleInOutVariables) { MakeCallerBodyFunction( "foo", {"func"}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -1069,13 +1067,13 @@ TEST_F(InspectorGetEntryPointTest, MultipleEntryPointsInOutVariables) { MakeInOutVariableBodyFunction( "foo", {{"in_var", "out2_var"}}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); MakeInOutVariableBodyFunction( "bar", {{"in2_var", "out_var"}}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kCompute), }); @@ -1127,13 +1125,13 @@ TEST_F(InspectorGetEntryPointTest, MultipleEntryPointsSharedInOutVariables) { MakeInOutVariableCallerBodyFunction( "foo", "func", {{"in_var", "out_var"}}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); MakeCallerBodyFunction( "bar", {"func"}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kCompute), }); @@ -1188,16 +1186,16 @@ TEST_F(InspectorGetEntryPointTest, MultipleEntryPointsSharedInOutVariables) { TEST_F(InspectorGetEntryPointTest, BuiltInsNotStageVariables) { Global("in_var", ty.u32(), ast::StorageClass::kInput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(ast::Builtin::kPosition)}); Global("out_var", ty.u32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{create(0)}); + ast::DecorationList{create(0)}); MakeInOutVariableBodyFunction("func", {{"in_var", "out_var"}}, {}); MakeCallerBodyFunction( "foo", {"func"}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -1246,7 +1244,7 @@ TEST_F(InspectorGetRemappedNameForEntryPointTest, DISABLED_NoEntryPoints) { // through TEST_F(InspectorGetRemappedNameForEntryPointTest, DISABLED_OneEntryPoint) { MakeEmptyBodyFunction( - "foo", ast::FunctionDecorationList{ + "foo", ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -1266,7 +1264,7 @@ TEST_F(InspectorGetRemappedNameForEntryPointTest, DISABLED_OneEntryPoint) { TEST_F(InspectorGetRemappedNameForEntryPointTest, DISABLED_MultipleEntryPoints) { MakeEmptyBodyFunction( - "foo", ast::FunctionDecorationList{ + "foo", ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -1274,7 +1272,7 @@ TEST_F(InspectorGetRemappedNameForEntryPointTest, // available. MakeEmptyBodyFunction( - "bar", ast::FunctionDecorationList{ + "bar", ast::DecorationList{ create(ast::PipelineStage::kCompute), }); @@ -1391,7 +1389,7 @@ TEST_F(InspectorGetConstantIDsTest, Float) { TEST_F(InspectorGetResourceBindingsTest, Empty) { MakeCallerBodyFunction( "ep_func", {}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -1443,7 +1441,7 @@ TEST_F(InspectorGetResourceBindingsTest, Simple) { MakeCallerBodyFunction( "ep_func", {"ub_func", "sb_func", "ro_func", "s_func", "cs_func"}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -1508,7 +1506,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, NonEntryPointFunc) { MakeCallerBodyFunction( "ep_func", {"ub_func"}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -1520,7 +1518,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, NonEntryPointFunc) { } TEST_F(InspectorGetUniformBufferResourceBindingsTest, MissingBlockDeco) { - ast::StructDecorationList decos; + ast::DecorationList decos; auto* str = create( ast::StructMemberList{ Member(StructMemberName(0, ty.i32()), ty.i32(), {MemberOffset(0)})}, @@ -1533,7 +1531,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MissingBlockDeco) { MakeCallerBodyFunction( "ep_func", {"ub_func"}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -1555,7 +1553,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, Simple) { MakeCallerBodyFunction( "ep_func", {"ub_func"}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -1584,7 +1582,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleMembers) { MakeCallerBodyFunction( "ep_func", {"ub_func"}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -1627,7 +1625,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleUniformBuffers) { ast::StatementList{FuncCall("ub_foo_func"), FuncCall("ub_bar_func"), FuncCall("ub_baz_func"), create()}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -1667,7 +1665,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, ContainingArray) { MakeCallerBodyFunction( "ep_func", {"ub_func"}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -1695,7 +1693,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, Simple) { MakeCallerBodyFunction( "ep_func", {"sb_func"}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -1724,7 +1722,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleMembers) { MakeCallerBodyFunction( "ep_func", {"sb_func"}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -1770,7 +1768,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleStorageBuffers) { FuncCall("sb_baz_func"), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -1810,7 +1808,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingArray) { MakeCallerBodyFunction( "ep_func", {"sb_func"}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -1838,7 +1836,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingRuntimeArray) { MakeCallerBodyFunction( "ep_func", {"sb_func"}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -1866,7 +1864,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, SkipReadOnly) { MakeCallerBodyFunction( "ep_func", {"sb_func"}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -1888,7 +1886,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, Simple) { MakeCallerBodyFunction( "ep_func", {"sb_func"}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -1935,7 +1933,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, FuncCall("sb_baz_func"), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -1975,7 +1973,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, ContainingArray) { MakeCallerBodyFunction( "ep_func", {"sb_func"}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -2004,7 +2002,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, MakeCallerBodyFunction( "ep_func", {"sb_func"}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -2032,7 +2030,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, SkipNonReadOnly) { MakeCallerBodyFunction( "ep_func", {"sb_func"}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -2052,7 +2050,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, Simple) { MakeSamplerReferenceBodyFunction( "ep", "foo_texture", "foo_sampler", "foo_coords", ty.f32(), - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -2069,7 +2067,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, Simple) { TEST_F(InspectorGetSamplerResourceBindingsTest, NoSampler) { MakeEmptyBodyFunction( - "ep_func", ast::FunctionDecorationList{ + "ep_func", ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -2093,7 +2091,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, InFunction) { MakeCallerBodyFunction( "ep_func", {"foo_func"}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -2117,7 +2115,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, UnknownEntryPoint) { MakeSamplerReferenceBodyFunction( "ep", "foo_texture", "foo_sampler", "foo_coords", ty.f32(), - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -2136,7 +2134,7 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, SkipsComparisonSamplers) { MakeComparisonSamplerReferenceBodyFunction( "ep", "foo_texture", "foo_sampler", "foo_coords", "foo_depth", ty.f32(), - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -2157,7 +2155,7 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, Simple) { MakeComparisonSamplerReferenceBodyFunction( "ep", "foo_texture", "foo_sampler", "foo_coords", "foo_depth", ty.f32(), - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -2175,7 +2173,7 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, Simple) { TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, NoSampler) { MakeEmptyBodyFunction( - "ep_func", ast::FunctionDecorationList{ + "ep_func", ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -2200,7 +2198,7 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, InFunction) { MakeCallerBodyFunction( "ep_func", {"foo_func"}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -2225,7 +2223,7 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, UnknownEntryPoint) { MakeComparisonSamplerReferenceBodyFunction( "ep", "foo_texture", "foo_sampler", "foo_coords", "foo_depth", ty.f32(), - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -2244,7 +2242,7 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, SkipsSamplers) { MakeSamplerReferenceBodyFunction( "ep", "foo_texture", "foo_sampler", "foo_coords", ty.f32(), - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -2258,7 +2256,7 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, SkipsSamplers) { TEST_F(InspectorGetSampledTextureResourceBindingsTest, Empty) { MakeEmptyBodyFunction( - "foo", ast::FunctionDecorationList{ + "foo", ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -2281,7 +2279,7 @@ TEST_P(InspectorGetSampledTextureResourceBindingsTestWithParam, textureSample) { MakeSamplerReferenceBodyFunction( "ep", "foo_texture", "foo_sampler", "foo_coords", GetBaseType(GetParam().sampled_kind), - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -2340,7 +2338,7 @@ TEST_P(InspectorGetSampledArrayTextureResourceBindingsTestWithParam, MakeSamplerReferenceBodyFunction( "ep", "foo_texture", "foo_sampler", "foo_coords", "foo_array_index", GetBaseType(GetParam().sampled_kind), - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -2385,7 +2383,7 @@ TEST_P(InspectorGetMultisampledTextureResourceBindingsTestWithParam, create(Call("textureLoad", "foo_texture", "foo_coords", "foo_sample_index")), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -2429,7 +2427,7 @@ INSTANTIATE_TEST_SUITE_P( TEST_F(InspectorGetMultisampledArrayTextureResourceBindingsTest, Empty) { MakeEmptyBodyFunction( - "foo", ast::FunctionDecorationList{ + "foo", ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -2454,7 +2452,7 @@ TEST_P(InspectorGetMultisampledArrayTextureResourceBindingsTestWithParam, MakeSamplerReferenceBodyFunction( "ep", "foo_texture", "foo_sampler", "foo_coords", "foo_array_index", GetBaseType(GetParam().sampled_kind), - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -2491,7 +2489,7 @@ INSTANTIATE_TEST_SUITE_P( TEST_F(InspectorGetStorageTextureResourceBindingsTest, Empty) { MakeEmptyBodyFunction( - "ep", ast::FunctionDecorationList{ + "ep", ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -2548,7 +2546,7 @@ TEST_P(InspectorGetStorageTextureResourceBindingsTestWithParam, Simple) { MakeStorageTextureBodyFunction( "ep", "st_var", dim_type, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex)}); Inspector& inspector = Build(); @@ -2707,7 +2705,7 @@ TEST_P(InspectorGetDepthTextureResourceBindingsTestWithParam, create( Call("textureDimensions", "dt", "dt_level")), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); diff --git a/src/intrinsic_table.cc b/src/intrinsic_table.cc index 87adf7ea6bd..30f18d75354 100644 --- a/src/intrinsic_table.cc +++ b/src/intrinsic_table.cc @@ -414,7 +414,7 @@ class ArrayBuilder : public Builder { type::Type* Build(BuildState& state) const override { auto* el = element_builder_->Build(state); - return state.ty_mgr.Get(el, 0, ast::ArrayDecorationList{}); + return state.ty_mgr.Get(el, 0, ast::DecorationList{}); } std::string str() const override { diff --git a/src/program_builder.h b/src/program_builder.h index a5c2c413260..941f93ea365 100644 --- a/src/program_builder.h +++ b/src/program_builder.h @@ -408,8 +408,7 @@ class ProgramBuilder { /// @param n the array size. 0 represents a runtime-array. /// @return the tint AST type for a array of size `n` of type `T` type::Array* array(type::Type* subtype, uint32_t n) const { - return builder->create(subtype, n, - ast::ArrayDecorationList{}); + return builder->create(subtype, n, ast::DecorationList{}); } /// @param subtype the array element type @@ -419,7 +418,7 @@ class ProgramBuilder { type::Array* array(type::Type* subtype, uint32_t n, uint32_t stride) const { return builder->create( subtype, n, - ast::ArrayDecorationList{ + ast::DecorationList{ builder->create(stride), }); } @@ -755,7 +754,7 @@ class ProgramBuilder { type::Type* type, ast::StorageClass storage, ast::Expression* constructor = nullptr, - ast::VariableDecorationList decorations = {}) { + ast::DecorationList decorations = {}) { return create(Symbols().Register(name), storage, type, false, constructor, decorations); } @@ -772,7 +771,7 @@ class ProgramBuilder { type::Type* type, ast::StorageClass storage, ast::Expression* constructor = nullptr, - ast::VariableDecorationList decorations = {}) { + ast::DecorationList decorations = {}) { return create(source, Symbols().Register(name), storage, type, false, constructor, decorations); } @@ -787,7 +786,7 @@ class ProgramBuilder { type::Type* type, ast::StorageClass storage, ast::Expression* constructor = nullptr, - ast::VariableDecorationList decorations = {}) { + ast::DecorationList decorations = {}) { return create(symbol, storage, type, false, constructor, decorations); } @@ -804,7 +803,7 @@ class ProgramBuilder { type::Type* type, ast::StorageClass storage, ast::Expression* constructor = nullptr, - ast::VariableDecorationList decorations = {}) { + ast::DecorationList decorations = {}) { return create(source, symbol, storage, type, false, constructor, decorations); } @@ -817,7 +816,7 @@ class ProgramBuilder { ast::Variable* Const(const std::string& name, type::Type* type, ast::Expression* constructor = nullptr, - ast::VariableDecorationList decorations = {}) { + ast::DecorationList decorations = {}) { return create(Symbols().Register(name), ast::StorageClass::kNone, type, true, constructor, decorations); @@ -833,7 +832,7 @@ class ProgramBuilder { const std::string& name, type::Type* type, ast::Expression* constructor = nullptr, - ast::VariableDecorationList decorations = {}) { + ast::DecorationList decorations = {}) { return create(source, Symbols().Register(name), ast::StorageClass::kNone, type, true, constructor, decorations); @@ -848,7 +847,7 @@ class ProgramBuilder { ast::Variable* Const(Symbol symbol, type::Type* type, ast::Expression* constructor = nullptr, - ast::VariableDecorationList decorations = {}) { + ast::DecorationList decorations = {}) { return create(symbol, ast::StorageClass::kNone, type, true, constructor, decorations); } @@ -864,7 +863,7 @@ class ProgramBuilder { Symbol symbol, type::Type* type, ast::Expression* constructor = nullptr, - ast::VariableDecorationList decorations = {}) { + ast::DecorationList decorations = {}) { return create(source, symbol, ast::StorageClass::kNone, type, true, constructor, decorations); } @@ -969,7 +968,7 @@ class ProgramBuilder { ast::VariableList params, type::Type* type, ast::StatementList body, - ast::FunctionDecorationList decorations) { + ast::DecorationList decorations) { auto* func = create(source, Symbols().Register(name), params, type, create(body), decorations); @@ -988,7 +987,7 @@ class ProgramBuilder { ast::VariableList params, type::Type* type, ast::StatementList body, - ast::FunctionDecorationList decorations) { + ast::DecorationList decorations) { auto* func = create(Symbols().Register(name), params, type, create(body), decorations); @@ -1005,7 +1004,7 @@ class ProgramBuilder { const std::string& name, type::Type* type) { return create(source, Symbols().Register(name), type, - ast::StructMemberDecorationList{}); + ast::DecorationList{}); } /// Creates a ast::StructMember @@ -1014,7 +1013,7 @@ class ProgramBuilder { /// @returns the struct member pointer ast::StructMember* Member(const std::string& name, type::Type* type) { return create(source_, Symbols().Register(name), type, - ast::StructMemberDecorationList{}); + ast::DecorationList{}); } /// Creates a ast::StructMember @@ -1024,7 +1023,7 @@ class ProgramBuilder { /// @returns the struct member pointer ast::StructMember* Member(const std::string& name, type::Type* type, - ast::StructMemberDecorationList decorations) { + ast::DecorationList decorations) { return create(source_, Symbols().Register(name), type, decorations); } @@ -1039,7 +1038,7 @@ class ProgramBuilder { type::Type* type) { return create( source_, Symbols().Register(name), type, - ast::StructMemberDecorationList{ + ast::DecorationList{ create(offset), }); } diff --git a/src/reader/spirv/function.cc b/src/reader/spirv/function.cc index a5bb13888eb..350ef4baff0 100644 --- a/src/reader/spirv/function.cc +++ b/src/reader/spirv/function.cc @@ -887,7 +887,7 @@ bool FunctionEmitter::ParseFunctionDeclaration(FunctionDeclaration* decl) { if (ast_type != nullptr) { auto* ast_param = parser_impl_.MakeVariable( param->result_id(), ast::StorageClass::kNone, ast_type, true, - nullptr, ast::VariableDecorationList{}); + nullptr, ast::DecorationList{}); // Parameters are treated as const declarations. ast_params.emplace_back(ast_param); // The value is accessible by name. @@ -900,7 +900,7 @@ bool FunctionEmitter::ParseFunctionDeclaration(FunctionDeclaration* decl) { if (failed()) { return false; } - ast::FunctionDecorationList decos; + ast::DecorationList decos; if (ep_info_ != nullptr) { decos.emplace_back(create(Source{}, ep_info_->stage)); } @@ -1961,7 +1961,7 @@ bool FunctionEmitter::EmitFunctionVariables() { } auto* var = parser_impl_.MakeVariable( inst.result_id(), ast::StorageClass::kFunction, var_store_type, false, - constructor, ast::VariableDecorationList{}); + constructor, ast::DecorationList{}); auto* var_decl_stmt = create(Source{}, var); AddStatement(var_decl_stmt); // Save this as an already-named value. @@ -2287,7 +2287,7 @@ bool FunctionEmitter::EmitIfStart(const BlockInfo& block_info) { parser_impl_.Bool(), // type false, // is_const MakeTrue(Source{}), // constructor - ast::VariableDecorationList{}); // decorations + ast::DecorationList{}); // decorations auto* guard_decl = create(Source{}, guard_var); AddStatement(guard_decl); } @@ -2796,9 +2796,9 @@ bool FunctionEmitter::EmitStatementsInBasicBlock(const BlockInfo& block_info, auto* ast_type = RemapStorageClass(parser_impl_.ConvertType(def_inst->type_id()), id); AddStatement(create( - Source{}, parser_impl_.MakeVariable(id, ast::StorageClass::kFunction, - ast_type, false, nullptr, - ast::VariableDecorationList{}))); + Source{}, + parser_impl_.MakeVariable(id, ast::StorageClass::kFunction, ast_type, + false, nullptr, ast::DecorationList{}))); // Save this as an already-named value. identifier_values_.insert(id); } @@ -2815,7 +2815,7 @@ bool FunctionEmitter::EmitStatementsInBasicBlock(const BlockInfo& block_info, parser_impl_.ConvertType(def_inst->type_id()), // type false, // is_const nullptr, // constructor - ast::VariableDecorationList{}); // decorations + ast::DecorationList{}); // decorations AddStatement(create(Source{}, var)); } @@ -2866,7 +2866,7 @@ bool FunctionEmitter::EmitConstDefinition( } auto* ast_const = parser_impl_.MakeVariable( inst.result_id(), ast::StorageClass::kNone, ast_expr.type, true, - ast_expr.expr, ast::VariableDecorationList{}); + ast_expr.expr, ast::DecorationList{}); if (!ast_const) { return false; } @@ -4910,7 +4910,7 @@ bool FunctionEmitter::MakeVectorInsertDynamic( auto* temp_var = create( Source{}, registered_temp_name, ast::StorageClass::kFunction, ast_type, - false, src_vector.expr, ast::VariableDecorationList{}); + false, src_vector.expr, ast::DecorationList{}); AddStatement(create(Source{}, temp_var)); auto* lhs = create( @@ -4956,7 +4956,7 @@ bool FunctionEmitter::MakeCompositeInsert( auto* temp_var = create( Source{}, registered_temp_name, ast::StorageClass::kFunction, ast_type, - false, src_composite.expr, ast::VariableDecorationList{}); + false, src_composite.expr, ast::DecorationList{}); AddStatement(create(Source{}, temp_var)); TypedExpression seed_expr{ast_type, create( diff --git a/src/reader/spirv/function.h b/src/reader/spirv/function.h index 650d44b4625..4e20c1e39c2 100644 --- a/src/reader/spirv/function.h +++ b/src/reader/spirv/function.h @@ -849,7 +849,7 @@ class FunctionEmitter { /// Function return type type::Type* return_type; /// Function decorations - ast::FunctionDecorationList decorations; + ast::DecorationList decorations; }; /// Parse the function declaration, which comprises the name, parameters, and diff --git a/src/reader/spirv/parser_impl.cc b/src/reader/spirv/parser_impl.cc index b694b6d2059..7478bcf9246 100644 --- a/src/reader/spirv/parser_impl.cc +++ b/src/reader/spirv/parser_impl.cc @@ -377,7 +377,7 @@ std::string ParserImpl::ShowType(uint32_t type_id) { return "SPIR-V type " + std::to_string(type_id); } -ast::StructMemberDecoration* ParserImpl::ConvertMemberDecoration( +ast::Decoration* ParserImpl::ConvertMemberDecoration( uint32_t struct_type_id, uint32_t member_index, const Decoration& decoration) { @@ -729,7 +729,7 @@ type::Type* ParserImpl::ConvertType( if (ast_elem_ty == nullptr) { return nullptr; } - ast::ArrayDecorationList decorations; + ast::DecorationList decorations; if (!ParseArrayDecorations(rtarr_ty, &decorations)) { return nullptr; } @@ -770,7 +770,7 @@ type::Type* ParserImpl::ConvertType( << num_elem; return nullptr; } - ast::ArrayDecorationList decorations; + ast::DecorationList decorations; if (!ParseArrayDecorations(arr_ty, &decorations)) { return nullptr; } @@ -784,7 +784,7 @@ type::Type* ParserImpl::ConvertType( bool ParserImpl::ParseArrayDecorations( const spvtools::opt::analysis::Type* spv_type, - ast::ArrayDecorationList* decorations) { + ast::DecorationList* decorations) { bool has_array_stride = false; const auto type_id = type_mgr_->GetId(spv_type); for (auto& decoration : this->GetDecorationsFor(type_id)) { @@ -816,7 +816,7 @@ type::Type* ParserImpl::ConvertType( const spvtools::opt::analysis::Struct* struct_ty) { // Compute the struct decoration. auto struct_decorations = this->GetDecorationsFor(type_id); - ast::StructDecorationList ast_struct_decorations; + ast::DecorationList ast_struct_decorations; if (struct_decorations.size() == 1) { const auto decoration = struct_decorations[0][0]; if (decoration == SpvDecorationBlock) { @@ -849,7 +849,7 @@ type::Type* ParserImpl::ConvertType( // Already emitted diagnostics. return nullptr; } - ast::StructMemberDecorationList ast_member_decorations; + ast::DecorationList ast_member_decorations; bool is_non_writable = false; for (auto& decoration : GetDecorationsForMember(type_id, member_index)) { if (decoration.empty()) { @@ -1034,7 +1034,7 @@ bool ParserImpl::EmitScalarSpecConstants() { break; } if (ast_type && ast_expr) { - ast::VariableDecorationList spec_id_decos; + ast::DecorationList spec_id_decos; for (const auto& deco : GetDecorationsFor(inst.result_id())) { if ((deco.size() == 2) && (deco[0] == SpvDecorationSpecId)) { auto* cid = create(Source{}, deco[1]); @@ -1161,7 +1161,7 @@ bool ParserImpl::EmitModuleScopeVariables() { } auto* ast_var = MakeVariable(var.result_id(), ast_storage_class, ast_store_type, false, - ast_constructor, ast::VariableDecorationList{}); + ast_constructor, ast::DecorationList{}); // TODO(dneto): initializers (a.k.a. constructor expression) if (ast_var) { builder_.AST().AddGlobalVariable(ast_var); @@ -1177,7 +1177,7 @@ bool ParserImpl::EmitModuleScopeVariables() { builtin_position_.per_vertex_var_id, enum_converter_.ToStorageClass(builtin_position_.storage_class), ConvertType(builtin_position_.position_member_type_id), false, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(Source{}, ast::Builtin::kPosition), }); @@ -1211,13 +1211,12 @@ const spvtools::opt::analysis::IntConstant* ParserImpl::GetArraySize( return size->AsIntConstant(); } -ast::Variable* ParserImpl::MakeVariable( - uint32_t id, - ast::StorageClass sc, - type::Type* type, - bool is_const, - ast::Expression* constructor, - ast::VariableDecorationList decorations) { +ast::Variable* ParserImpl::MakeVariable(uint32_t id, + ast::StorageClass sc, + type::Type* type, + bool is_const, + ast::Expression* constructor, + ast::DecorationList decorations) { if (type == nullptr) { Fail() << "internal error: can't make ast::Variable for null type"; return nullptr; diff --git a/src/reader/spirv/parser_impl.h b/src/reader/spirv/parser_impl.h index 0747ca96975..4ebc47ae73f 100644 --- a/src/reader/spirv/parser_impl.h +++ b/src/reader/spirv/parser_impl.h @@ -177,10 +177,9 @@ class ParserImpl : Reader { /// @param member_index the index of the member /// @param decoration an encoded SPIR-V Decoration /// @returns the corresponding ast::StructuMemberDecoration - ast::StructMemberDecoration* ConvertMemberDecoration( - uint32_t struct_type_id, - uint32_t member_index, - const Decoration& decoration); + ast::Decoration* ConvertMemberDecoration(uint32_t struct_type_id, + uint32_t member_index, + const Decoration& decoration); /// Returns a string for the given type. If the type ID is invalid, /// then the resulting string only names the type ID. @@ -298,7 +297,7 @@ class ParserImpl : Reader { type::Type* type, bool is_const, ast::Expression* constructor, - ast::VariableDecorationList decorations); + ast::DecorationList decorations); /// Creates an AST expression node for a SPIR-V constant. /// @param id the SPIR-V ID of the constant @@ -537,7 +536,7 @@ class ParserImpl : Reader { /// @param decorations the populated decoration list /// @returns true on success. bool ParseArrayDecorations(const spvtools::opt::analysis::Type* spv_type, - ast::ArrayDecorationList* decorations); + ast::DecorationList* decorations); /// Creates a new `ast::Node` owned by the ProgramBuilder. /// @param args the arguments to pass to the type constructor diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc index 6f8184ad417..b025f44dbca 100644 --- a/src/reader/wgsl/parser_impl.cc +++ b/src/reader/wgsl/parser_impl.cc @@ -384,10 +384,6 @@ Maybe ParserImpl::global_variable_decl( if (!decl.matched) return Failure::kNoMatch; - auto var_decos = cast_decorations(decos); - if (var_decos.errored) - return Failure::kErrored; - ast::Expression* constructor = nullptr; if (match(Token::Type::kEqual)) { auto expr = expect_const_expr(); @@ -403,7 +399,7 @@ Maybe ParserImpl::global_variable_decl( decl->type, // type false, // is_const constructor, // constructor - std::move(var_decos.value)); // decorations + std::move(decos)); // decorations } // global_constant_decl @@ -426,10 +422,6 @@ Maybe ParserImpl::global_constant_decl( if (init.errored) return Failure::kErrored; - auto var_decos = cast_decorations(decos); - if (var_decos.errored) - return Failure::kErrored; - return create( decl->source, // source builder_.Symbols().Register(decl->name), // symbol @@ -437,7 +429,7 @@ Maybe ParserImpl::global_constant_decl( decl->type, // type true, // is_const init.value, // constructor - std::move(var_decos.value)); // decorations + std::move(decos)); // decorations } // variable_decl @@ -937,11 +929,7 @@ Maybe ParserImpl::type_decl(ast::DecorationList& decos) { return expect_type_decl_pointer(); if (match(Token::Type::kArray)) { - auto array_decos = cast_decorations(decos); - if (array_decos.errored) - return Failure::kErrored; - - return expect_type_decl_array(std::move(array_decos.value)); + return expect_type_decl_array(std::move(decos)); } if (t.IsMat2x2() || t.IsMat2x3() || t.IsMat2x4() || t.IsMat3x2() || @@ -1005,7 +993,7 @@ Expect ParserImpl::expect_type_decl_vector(Token t) { } Expect ParserImpl::expect_type_decl_array( - ast::ArrayDecorationList decos) { + ast::DecorationList decos) { const char* use = "array declaration"; return expect_lt_gt_block(use, [&]() -> Expect { @@ -1109,14 +1097,9 @@ Maybe ParserImpl::struct_decl(ast::DecorationList& decos) { if (body.errored) return Failure::kErrored; - auto struct_decos = cast_decorations(decos); - if (struct_decos.errored) - return Failure::kErrored; - return create( builder_.Symbols().Register(name.value), - create(source, std::move(body.value), - std::move(struct_decos.value))); + create(source, std::move(body.value), std::move(decos))); } // struct_body_decl @@ -1161,16 +1144,12 @@ Expect ParserImpl::expect_struct_member( if (decl.errored) return Failure::kErrored; - auto member_decos = cast_decorations(decos); - if (member_decos.errored) - return Failure::kErrored; - if (!expect("struct member", Token::Type::kSemicolon)) return Failure::kErrored; return create(decl->source, builder_.Symbols().Register(decl->name), - decl->type, std::move(member_decos.value)); + decl->type, std::move(decos)); } // function_decl @@ -1194,10 +1173,6 @@ Maybe ParserImpl::function_decl(ast::DecorationList& decos) { bool errored = false; - auto func_decos = cast_decorations(decos); - if (func_decos.errored) - errored = true; - auto body = expect_body_stmt(); if (body.errored) errored = true; @@ -1207,7 +1182,7 @@ Maybe ParserImpl::function_decl(ast::DecorationList& decos) { return create( header->source, builder_.Symbols().Register(header->name), header->params, - header->return_type, body.value, func_decos.value); + header->return_type, body.value, decos); } // function_type_decl @@ -1289,9 +1264,6 @@ Expect ParserImpl::expect_param_list() { // : decoration_list* variable_ident_decl Expect ParserImpl::expect_param() { auto decos = decoration_list(); - auto var_decos = cast_decorations(decos.value); - if (var_decos.errored) - return Failure::kErrored; auto decl = expect_variable_ident_decl("parameter"); if (decl.errored) @@ -1300,11 +1272,11 @@ Expect ParserImpl::expect_param() { auto* var = create(decl->source, // source builder_.Symbols().Register(decl->name), // symbol - ast::StorageClass::kNone, // storage_class - decl->type, // type - true, // is_const - nullptr, // constructor - std::move(var_decos.value)); // decorations + ast::StorageClass::kNone, // storage_class + decl->type, // type + true, // is_const + nullptr, // constructor + std::move(decos.value)); // decorations // Formal parameters are treated like a const declaration where the // initializer value is provided by the call's argument. The key point is // that it's not updatable after initially set. This is unlike C or GLSL @@ -1566,7 +1538,7 @@ Maybe ParserImpl::variable_stmt() { decl->type, // type true, // is_const constructor.value, // constructor - ast::VariableDecorationList{}); // decorations + ast::DecorationList{}); // decorations return create(decl->source, var); } @@ -1591,11 +1563,11 @@ Maybe ParserImpl::variable_stmt() { auto* var = create(decl->source, // source builder_.Symbols().Register(decl->name), // symbol - decl->storage_class, // storage_class - decl->type, // type - false, // is_const - constructor, // constructor - ast::VariableDecorationList{}); // decorations + decl->storage_class, // storage_class + decl->type, // type + false, // is_const + constructor, // constructor + ast::DecorationList{}); // decorations return create(var->source(), var); } @@ -2835,7 +2807,7 @@ Maybe ParserImpl::decoration() { if (val.errored) return Failure::kErrored; - return create(val.source, val.value); + return create(t.source(), val.value); }); } @@ -2846,7 +2818,7 @@ Maybe ParserImpl::decoration() { if (val.errored) return Failure::kErrored; - return create(val.source, val.value); + return create(t.source(), val.value); }); } @@ -2857,7 +2829,7 @@ Maybe ParserImpl::decoration() { if (val.errored) return Failure::kErrored; - return create(val.source, val.value); + return create(t.source(), val.value); }); } @@ -2868,7 +2840,7 @@ Maybe ParserImpl::decoration() { if (val.errored) return Failure::kErrored; - return create(val.source, val.value); + return create(t.source(), val.value); }); } @@ -2878,7 +2850,7 @@ Maybe ParserImpl::decoration() { if (builtin.errored) return Failure::kErrored; - return create(builtin.source, builtin.value); + return create(t.source(), builtin.value); }); } @@ -2917,7 +2889,7 @@ Maybe ParserImpl::decoration() { if (stage.errored) return Failure::kErrored; - return create(stage.source, stage.value); + return create(t.source(), stage.value); }); } @@ -2978,29 +2950,6 @@ std::vector ParserImpl::take_decorations(ast::DecorationList& in) { return out; } -template -Expect> ParserImpl::cast_decorations(ast::DecorationList& in) { - auto out = take_decorations(in); - - bool ok = true; - - for (auto* deco : in) { - std::stringstream msg; - msg << deco->GetKind() << " decoration type cannot be used for " << T::Kind; - add_error(deco->source(), msg.str()); - ok = false; - } - - // clear in so that expect_decorations_consumed() doesn't error again on the - // decorations we've already errored on. - in.clear(); - - if (!ok) - return Failure::kErrored; - - return out; -} - bool ParserImpl::expect_decorations_consumed(const ast::DecorationList& in) { if (in.empty()) { return true; diff --git a/src/reader/wgsl/parser_impl.h b/src/reader/wgsl/parser_impl.h index 2f3ba07eeb0..a2bf63d4393 100644 --- a/src/reader/wgsl/parser_impl.h +++ b/src/reader/wgsl/parser_impl.h @@ -772,18 +772,13 @@ class ParserImpl { template std::vector take_decorations(ast::DecorationList& list); - /// Downcasts all the decorations in `list` to the type `T`, raising a parser - /// error if any of the decorations aren't of the type `T`. - template - Expect> cast_decorations(ast::DecorationList& list); - /// Reports an error if the decoration list `list` is not empty. /// Used to ensure that all decorations are consumed. bool expect_decorations_consumed(const ast::DecorationList& list); Expect expect_type_decl_pointer(); Expect expect_type_decl_vector(Token t); - Expect expect_type_decl_array(ast::ArrayDecorationList decos); + Expect expect_type_decl_array(ast::DecorationList decos); Expect expect_type_decl_matrix(Token t); Expect expect_type(const std::string& use); diff --git a/src/reader/wgsl/parser_impl_error_resync_test.cc b/src/reader/wgsl/parser_impl_error_resync_test.cc index ff25da4ffac..13bf16f1e2a 100644 --- a/src/reader/wgsl/parser_impl_error_resync_test.cc +++ b/src/reader/wgsl/parser_impl_error_resync_test.cc @@ -119,7 +119,7 @@ struct S { a : i32; blah blah blah; b : i32; - [[block]] x : i32; + [[]] x : i32; c : i32; } )", @@ -131,10 +131,9 @@ struct S { " blah blah blah;\n" " ^^^^\n" "\n" - "test.wgsl:7:7 error: struct decoration type cannot be used for " - "struct member\n" - " [[block]] x : i32;\n" - " ^^^^^\n"); + "test.wgsl:7:7 error: empty decoration list\n" + " [[]] x : i32;\n" + " ^^\n"); } // Check that the forward scan in resynchronize() stop at nested sync points. diff --git a/src/reader/wgsl/parser_impl_function_decoration_list_test.cc b/src/reader/wgsl/parser_impl_function_decoration_list_test.cc index debee2fde6d..c2272c410f8 100644 --- a/src/reader/wgsl/parser_impl_function_decoration_list_test.cc +++ b/src/reader/wgsl/parser_impl_function_decoration_list_test.cc @@ -20,7 +20,7 @@ namespace reader { namespace wgsl { namespace { -TEST_F(ParserImplTest, FunctionDecorationList_Parses) { +TEST_F(ParserImplTest, DecorationList_Parses) { auto p = parser("[[workgroup_size(2), workgroup_size(3, 4, 5)]]"); auto decos = p->decoration_list(); EXPECT_FALSE(p->has_error()) << p->error(); @@ -28,8 +28,8 @@ TEST_F(ParserImplTest, FunctionDecorationList_Parses) { EXPECT_TRUE(decos.matched); ASSERT_EQ(decos.value.size(), 2u); - auto* deco_0 = decos.value[0]->As(); - auto* deco_1 = decos.value[1]->As(); + auto* deco_0 = decos.value[0]->As(); + auto* deco_1 = decos.value[1]->As(); ASSERT_NE(deco_0, nullptr); ASSERT_NE(deco_1, nullptr); @@ -47,7 +47,7 @@ TEST_F(ParserImplTest, FunctionDecorationList_Parses) { EXPECT_EQ(z, 5u); } -TEST_F(ParserImplTest, FunctionDecorationList_Empty) { +TEST_F(ParserImplTest, DecorationList_Empty) { auto p = parser("[[]]"); auto decos = p->decoration_list(); EXPECT_TRUE(p->has_error()); @@ -56,7 +56,7 @@ TEST_F(ParserImplTest, FunctionDecorationList_Empty) { EXPECT_EQ(p->error(), "1:3: empty decoration list"); } -TEST_F(ParserImplTest, FunctionDecorationList_Invalid) { +TEST_F(ParserImplTest, DecorationList_Invalid) { auto p = parser("[[invalid]]"); auto decos = p->decoration_list(); EXPECT_TRUE(p->has_error()); @@ -66,7 +66,7 @@ TEST_F(ParserImplTest, FunctionDecorationList_Invalid) { EXPECT_EQ(p->error(), "1:3: expected decoration"); } -TEST_F(ParserImplTest, FunctionDecorationList_ExtraComma) { +TEST_F(ParserImplTest, DecorationList_ExtraComma) { auto p = parser("[[workgroup_size(2), ]]"); auto decos = p->decoration_list(); EXPECT_TRUE(p->has_error()); @@ -75,7 +75,7 @@ TEST_F(ParserImplTest, FunctionDecorationList_ExtraComma) { EXPECT_EQ(p->error(), "1:22: expected decoration"); } -TEST_F(ParserImplTest, FunctionDecorationList_MissingComma) { +TEST_F(ParserImplTest, DecorationList_MissingComma) { auto p = parser("[[workgroup_size(2) workgroup_size(2)]]"); auto decos = p->decoration_list(); EXPECT_TRUE(p->has_error()); @@ -84,7 +84,7 @@ TEST_F(ParserImplTest, FunctionDecorationList_MissingComma) { EXPECT_EQ(p->error(), "1:21: expected ',' for decoration list"); } -TEST_F(ParserImplTest, FunctionDecorationList_BadDecoration) { +TEST_F(ParserImplTest, DecorationList_BadDecoration) { auto p = parser("[[workgroup_size()]]"); auto decos = p->decoration_list(); EXPECT_TRUE(p->has_error()); @@ -95,7 +95,7 @@ TEST_F(ParserImplTest, FunctionDecorationList_BadDecoration) { "1:18: expected signed integer literal for workgroup_size x parameter"); } -TEST_F(ParserImplTest, FunctionDecorationList_MissingRightAttr) { +TEST_F(ParserImplTest, DecorationList_MissingRightAttr) { auto p = parser("[[workgroup_size(2), workgroup_size(3, 4, 5)"); auto decos = p->decoration_list(); EXPECT_TRUE(p->has_error()); diff --git a/src/reader/wgsl/parser_impl_function_decoration_test.cc b/src/reader/wgsl/parser_impl_function_decoration_test.cc index e45f6062975..dc9fd1f1dce 100644 --- a/src/reader/wgsl/parser_impl_function_decoration_test.cc +++ b/src/reader/wgsl/parser_impl_function_decoration_test.cc @@ -21,14 +21,14 @@ namespace reader { namespace wgsl { namespace { -TEST_F(ParserImplTest, FunctionDecoration_Workgroup) { +TEST_F(ParserImplTest, Decoration_Workgroup) { auto p = parser("workgroup_size(4)"); auto deco = p->decoration(); EXPECT_TRUE(deco.matched); EXPECT_FALSE(deco.errored); ASSERT_NE(deco.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - auto* func_deco = deco.value->As(); + auto* func_deco = deco.value->As(); ASSERT_NE(func_deco, nullptr); ASSERT_TRUE(func_deco->Is()); @@ -41,14 +41,14 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup) { EXPECT_EQ(z, 1u); } -TEST_F(ParserImplTest, FunctionDecoration_Workgroup_2Param) { +TEST_F(ParserImplTest, Decoration_Workgroup_2Param) { auto p = parser("workgroup_size(4, 5)"); auto deco = p->decoration(); EXPECT_TRUE(deco.matched); EXPECT_FALSE(deco.errored); ASSERT_NE(deco.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - auto* func_deco = deco.value->As(); + auto* func_deco = deco.value->As(); ASSERT_NE(func_deco, nullptr) << p->error(); ASSERT_TRUE(func_deco->Is()); @@ -61,14 +61,14 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_2Param) { EXPECT_EQ(z, 1u); } -TEST_F(ParserImplTest, FunctionDecoration_Workgroup_3Param) { +TEST_F(ParserImplTest, Decoration_Workgroup_3Param) { auto p = parser("workgroup_size(4, 5, 6)"); auto deco = p->decoration(); EXPECT_TRUE(deco.matched); EXPECT_FALSE(deco.errored); ASSERT_NE(deco.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - auto* func_deco = deco.value->As(); + auto* func_deco = deco.value->As(); ASSERT_NE(func_deco, nullptr); ASSERT_TRUE(func_deco->Is()); @@ -81,7 +81,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_3Param) { EXPECT_EQ(z, 6u); } -TEST_F(ParserImplTest, FunctionDecoration_Workgroup_TooManyValues) { +TEST_F(ParserImplTest, Decoration_Workgroup_TooManyValues) { auto p = parser("workgroup_size(1, 2, 3, 4)"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -91,7 +91,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_TooManyValues) { EXPECT_EQ(p->error(), "1:23: expected ')' for workgroup_size decoration"); } -TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Invalid_X_Value) { +TEST_F(ParserImplTest, Decoration_Workgroup_Invalid_X_Value) { auto p = parser("workgroup_size(-2, 5, 6)"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -102,7 +102,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Invalid_X_Value) { "1:16: workgroup_size x parameter must be greater than 0"); } -TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Invalid_Y_Value) { +TEST_F(ParserImplTest, Decoration_Workgroup_Invalid_Y_Value) { auto p = parser("workgroup_size(4, 0, 6)"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -113,7 +113,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Invalid_Y_Value) { "1:19: workgroup_size y parameter must be greater than 0"); } -TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Invalid_Z_Value) { +TEST_F(ParserImplTest, Decoration_Workgroup_Invalid_Z_Value) { auto p = parser("workgroup_size(4, 5, -3)"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -124,7 +124,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Invalid_Z_Value) { "1:22: workgroup_size z parameter must be greater than 0"); } -TEST_F(ParserImplTest, FunctionDecoration_Workgroup_MissingLeftParam) { +TEST_F(ParserImplTest, Decoration_Workgroup_MissingLeftParam) { auto p = parser("workgroup_size 4, 5, 6)"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -134,7 +134,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_MissingLeftParam) { EXPECT_EQ(p->error(), "1:16: expected '(' for workgroup_size decoration"); } -TEST_F(ParserImplTest, FunctionDecoration_Workgroup_MissingRightParam) { +TEST_F(ParserImplTest, Decoration_Workgroup_MissingRightParam) { auto p = parser("workgroup_size(4, 5, 6"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -144,7 +144,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_MissingRightParam) { EXPECT_EQ(p->error(), "1:23: expected ')' for workgroup_size decoration"); } -TEST_F(ParserImplTest, FunctionDecoration_Workgroup_MissingValues) { +TEST_F(ParserImplTest, Decoration_Workgroup_MissingValues) { auto p = parser("workgroup_size()"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -156,7 +156,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_MissingValues) { "1:16: expected signed integer literal for workgroup_size x parameter"); } -TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Missing_X_Value) { +TEST_F(ParserImplTest, Decoration_Workgroup_Missing_X_Value) { auto p = parser("workgroup_size(, 2, 3)"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -168,7 +168,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Missing_X_Value) { "1:16: expected signed integer literal for workgroup_size x parameter"); } -TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Missing_Y_Comma) { +TEST_F(ParserImplTest, Decoration_Workgroup_Missing_Y_Comma) { auto p = parser("workgroup_size(1 2, 3)"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -178,7 +178,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Missing_Y_Comma) { EXPECT_EQ(p->error(), "1:18: expected ')' for workgroup_size decoration"); } -TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Missing_Y_Value) { +TEST_F(ParserImplTest, Decoration_Workgroup_Missing_Y_Value) { auto p = parser("workgroup_size(1, , 3)"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -190,7 +190,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Missing_Y_Value) { "1:19: expected signed integer literal for workgroup_size y parameter"); } -TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Missing_Z_Comma) { +TEST_F(ParserImplTest, Decoration_Workgroup_Missing_Z_Comma) { auto p = parser("workgroup_size(1, 2 3)"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -200,7 +200,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Missing_Z_Comma) { EXPECT_EQ(p->error(), "1:21: expected ')' for workgroup_size decoration"); } -TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Missing_Z_Value) { +TEST_F(ParserImplTest, Decoration_Workgroup_Missing_Z_Value) { auto p = parser("workgroup_size(1, 2, )"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -212,7 +212,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Missing_Z_Value) { "1:22: expected signed integer literal for workgroup_size z parameter"); } -TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Missing_X_Invalid) { +TEST_F(ParserImplTest, Decoration_Workgroup_Missing_X_Invalid) { auto p = parser("workgroup_size(nan)"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -224,7 +224,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Missing_X_Invalid) { "1:16: expected signed integer literal for workgroup_size x parameter"); } -TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Missing_Y_Invalid) { +TEST_F(ParserImplTest, Decoration_Workgroup_Missing_Y_Invalid) { auto p = parser("workgroup_size(2, nan)"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -236,7 +236,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Missing_Y_Invalid) { "1:19: expected signed integer literal for workgroup_size y parameter"); } -TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Missing_Z_Invalid) { +TEST_F(ParserImplTest, Decoration_Workgroup_Missing_Z_Invalid) { auto p = parser("workgroup_size(2, 3, nan)"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -248,21 +248,21 @@ TEST_F(ParserImplTest, FunctionDecoration_Workgroup_Missing_Z_Invalid) { "1:22: expected signed integer literal for workgroup_size z parameter"); } -TEST_F(ParserImplTest, FunctionDecoration_Stage) { +TEST_F(ParserImplTest, Decoration_Stage) { auto p = parser("stage(compute)"); auto deco = p->decoration(); EXPECT_TRUE(deco.matched); EXPECT_FALSE(deco.errored); ASSERT_NE(deco.value, nullptr) << p->error(); ASSERT_FALSE(p->has_error()); - auto* func_deco = deco.value->As(); + auto* func_deco = deco.value->As(); ASSERT_NE(func_deco, nullptr); ASSERT_TRUE(func_deco->Is()); EXPECT_EQ(func_deco->As()->value(), ast::PipelineStage::kCompute); } -TEST_F(ParserImplTest, FunctionDecoration_Stage_MissingValue) { +TEST_F(ParserImplTest, Decoration_Stage_MissingValue) { auto p = parser("stage()"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -272,7 +272,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Stage_MissingValue) { EXPECT_EQ(p->error(), "1:7: invalid value for stage decoration"); } -TEST_F(ParserImplTest, FunctionDecoration_Stage_MissingInvalid) { +TEST_F(ParserImplTest, Decoration_Stage_MissingInvalid) { auto p = parser("stage(nan)"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -282,7 +282,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Stage_MissingInvalid) { EXPECT_EQ(p->error(), "1:7: invalid value for stage decoration"); } -TEST_F(ParserImplTest, FunctionDecoration_Stage_MissingLeftParen) { +TEST_F(ParserImplTest, Decoration_Stage_MissingLeftParen) { auto p = parser("stage compute)"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -292,7 +292,7 @@ TEST_F(ParserImplTest, FunctionDecoration_Stage_MissingLeftParen) { EXPECT_EQ(p->error(), "1:7: expected '(' for stage decoration"); } -TEST_F(ParserImplTest, FunctionDecoration_Stage_MissingRightParen) { +TEST_F(ParserImplTest, Decoration_Stage_MissingRightParen) { auto p = parser("stage(compute"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); diff --git a/src/reader/wgsl/parser_impl_struct_decl_test.cc b/src/reader/wgsl/parser_impl_struct_decl_test.cc index 0980087b49f..23a3dd05d88 100644 --- a/src/reader/wgsl/parser_impl_struct_decl_test.cc +++ b/src/reader/wgsl/parser_impl_struct_decl_test.cc @@ -161,7 +161,7 @@ TEST_F(ParserImplTest, StructDecl_InvalidStructBody) { EXPECT_EQ(p->error(), "1:16: unknown constructed type 'B'"); } -TEST_F(ParserImplTest, StructDecl_InvalidStructDecorationDecl) { +TEST_F(ParserImplTest, StructDecl_InvalidDecorationDecl) { auto p = parser("[[block struct S { a : i32; }"); auto decos = p->decoration_list(); EXPECT_TRUE(decos.errored); diff --git a/src/reader/wgsl/parser_impl_struct_decoration_decl_test.cc b/src/reader/wgsl/parser_impl_struct_decoration_decl_test.cc index 8a5c4f7e34c..05eb0fcb11b 100644 --- a/src/reader/wgsl/parser_impl_struct_decoration_decl_test.cc +++ b/src/reader/wgsl/parser_impl_struct_decoration_decl_test.cc @@ -20,18 +20,18 @@ namespace reader { namespace wgsl { namespace { -TEST_F(ParserImplTest, StructDecorationDecl_Parses) { +TEST_F(ParserImplTest, DecorationDecl_Parses) { auto p = parser("[[block]]"); auto decos = p->decoration_list(); EXPECT_FALSE(p->has_error()); EXPECT_FALSE(decos.errored); EXPECT_TRUE(decos.matched); ASSERT_EQ(decos.value.size(), 1u); - auto* struct_deco = decos.value[0]->As(); + auto* struct_deco = decos.value[0]->As(); EXPECT_TRUE(struct_deco->Is()); } -TEST_F(ParserImplTest, StructDecorationDecl_MissingAttrRight) { +TEST_F(ParserImplTest, DecorationDecl_MissingAttrRight) { auto p = parser("[[block"); auto decos = p->decoration_list(); EXPECT_TRUE(p->has_error()); @@ -41,7 +41,7 @@ TEST_F(ParserImplTest, StructDecorationDecl_MissingAttrRight) { EXPECT_EQ(p->error(), "1:8: expected ']]' for decoration list"); } -TEST_F(ParserImplTest, StructDecorationDecl_InvalidDecoration) { +TEST_F(ParserImplTest, DecorationDecl_InvalidDecoration) { auto p = parser("[[invalid]]"); auto decos = p->decoration_list(); EXPECT_TRUE(p->has_error()); diff --git a/src/reader/wgsl/parser_impl_struct_decoration_test.cc b/src/reader/wgsl/parser_impl_struct_decoration_test.cc index 15a5d25efe9..055d55e7eec 100644 --- a/src/reader/wgsl/parser_impl_struct_decoration_test.cc +++ b/src/reader/wgsl/parser_impl_struct_decoration_test.cc @@ -20,19 +20,18 @@ namespace reader { namespace wgsl { namespace { -struct StructDecorationData { +struct DecorationData { const char* input; bool is_block; }; -inline std::ostream& operator<<(std::ostream& out, StructDecorationData data) { +inline std::ostream& operator<<(std::ostream& out, DecorationData data) { out << std::string(data.input); return out; } -class StructDecorationTest - : public ParserImplTestWithParam {}; +class DecorationTest : public ParserImplTestWithParam {}; -TEST_P(StructDecorationTest, Parses) { +TEST_P(DecorationTest, Parses) { auto params = GetParam(); auto p = parser(params.input); @@ -41,15 +40,15 @@ TEST_P(StructDecorationTest, Parses) { EXPECT_TRUE(deco.matched); EXPECT_FALSE(deco.errored); ASSERT_NE(deco.value, nullptr); - auto* struct_deco = deco.value->As(); + auto* struct_deco = deco.value->As(); ASSERT_NE(struct_deco, nullptr); EXPECT_EQ(struct_deco->Is(), params.is_block); } INSTANTIATE_TEST_SUITE_P(ParserImplTest, - StructDecorationTest, - testing::Values(StructDecorationData{"block", true})); + DecorationTest, + testing::Values(DecorationData{"block", true})); -TEST_F(ParserImplTest, StructDecoration_NoMatch) { +TEST_F(ParserImplTest, Decoration_NoMatch) { auto p = parser("not-a-stage"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); diff --git a/src/reader/wgsl/parser_impl_struct_member_decoration_decl_test.cc b/src/reader/wgsl/parser_impl_struct_member_decoration_decl_test.cc index 4b88e78139e..533a5bbdf14 100644 --- a/src/reader/wgsl/parser_impl_struct_member_decoration_decl_test.cc +++ b/src/reader/wgsl/parser_impl_struct_member_decoration_decl_test.cc @@ -19,7 +19,7 @@ namespace reader { namespace wgsl { namespace { -TEST_F(ParserImplTest, StructMemberDecorationDecl_EmptyStr) { +TEST_F(ParserImplTest, DecorationDecl_EmptyStr) { auto p = parser(""); auto decos = p->decoration_list(); EXPECT_FALSE(p->has_error()); @@ -28,7 +28,7 @@ TEST_F(ParserImplTest, StructMemberDecorationDecl_EmptyStr) { EXPECT_EQ(decos.value.size(), 0u); } -TEST_F(ParserImplTest, StructMemberDecorationDecl_EmptyBlock) { +TEST_F(ParserImplTest, DecorationDecl_EmptyBlock) { auto p = parser("[[]]"); auto decos = p->decoration_list(); EXPECT_TRUE(p->has_error()); @@ -38,19 +38,19 @@ TEST_F(ParserImplTest, StructMemberDecorationDecl_EmptyBlock) { EXPECT_EQ(p->error(), "1:3: empty decoration list"); } -TEST_F(ParserImplTest, StructMemberDecorationDecl_Single) { +TEST_F(ParserImplTest, DecorationDecl_Single) { auto p = parser("[[offset(4)]]"); auto decos = p->decoration_list(); EXPECT_FALSE(p->has_error()); EXPECT_FALSE(decos.errored); EXPECT_TRUE(decos.matched); ASSERT_EQ(decos.value.size(), 1u); - auto* deco = decos.value[0]->As(); + auto* deco = decos.value[0]->As(); ASSERT_NE(deco, nullptr); EXPECT_TRUE(deco->Is()); } -TEST_F(ParserImplTest, StructMemberDecorationDecl_InvalidDecoration) { +TEST_F(ParserImplTest, DecorationDecl_InvalidDecoration) { auto p = parser("[[offset(nan)]]"); auto decos = p->decoration_list(); EXPECT_TRUE(p->has_error()) << p->error(); @@ -60,7 +60,7 @@ TEST_F(ParserImplTest, StructMemberDecorationDecl_InvalidDecoration) { "1:10: expected signed integer literal for offset decoration"); } -TEST_F(ParserImplTest, StructMemberDecorationDecl_MissingClose) { +TEST_F(ParserImplTest, DecorationDecl_MissingClose) { auto p = parser("[[offset(4)"); auto decos = p->decoration_list(); EXPECT_TRUE(p->has_error()) << p->error(); diff --git a/src/reader/wgsl/parser_impl_struct_member_decoration_test.cc b/src/reader/wgsl/parser_impl_struct_member_decoration_test.cc index c15fdf11abc..fdee0f508b7 100644 --- a/src/reader/wgsl/parser_impl_struct_member_decoration_test.cc +++ b/src/reader/wgsl/parser_impl_struct_member_decoration_test.cc @@ -19,7 +19,7 @@ namespace reader { namespace wgsl { namespace { -TEST_F(ParserImplTest, StructMemberDecoration_Offset) { +TEST_F(ParserImplTest, Decoration_Offset) { auto p = parser("offset(4)"); auto deco = p->decoration(); EXPECT_TRUE(deco.matched); @@ -27,7 +27,7 @@ TEST_F(ParserImplTest, StructMemberDecoration_Offset) { ASSERT_NE(deco.value, nullptr); ASSERT_FALSE(p->has_error()); - auto* member_deco = deco.value->As(); + auto* member_deco = deco.value->As(); ASSERT_NE(member_deco, nullptr); ASSERT_TRUE(member_deco->Is()); @@ -35,7 +35,7 @@ TEST_F(ParserImplTest, StructMemberDecoration_Offset) { EXPECT_EQ(o->offset(), 4u); } -TEST_F(ParserImplTest, StructMemberDecoration_Offset_MissingLeftParen) { +TEST_F(ParserImplTest, Decoration_Offset_MissingLeftParen) { auto p = parser("offset 4)"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -45,7 +45,7 @@ TEST_F(ParserImplTest, StructMemberDecoration_Offset_MissingLeftParen) { EXPECT_EQ(p->error(), "1:8: expected '(' for offset decoration"); } -TEST_F(ParserImplTest, StructMemberDecoration_Offset_MissingRightParen) { +TEST_F(ParserImplTest, Decoration_Offset_MissingRightParen) { auto p = parser("offset(4"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -55,7 +55,7 @@ TEST_F(ParserImplTest, StructMemberDecoration_Offset_MissingRightParen) { EXPECT_EQ(p->error(), "1:9: expected ')' for offset decoration"); } -TEST_F(ParserImplTest, StructMemberDecoration_Offset_MissingValue) { +TEST_F(ParserImplTest, Decoration_Offset_MissingValue) { auto p = parser("offset()"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -66,7 +66,7 @@ TEST_F(ParserImplTest, StructMemberDecoration_Offset_MissingValue) { "1:8: expected signed integer literal for offset decoration"); } -TEST_F(ParserImplTest, StructMemberDecoration_Offset_MissingInvalid) { +TEST_F(ParserImplTest, Decoration_Offset_MissingInvalid) { auto p = parser("offset(nan)"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); diff --git a/src/reader/wgsl/parser_impl_variable_decoration_list_test.cc b/src/reader/wgsl/parser_impl_variable_decoration_list_test.cc index f5f33e0ab38..c265efbdf02 100644 --- a/src/reader/wgsl/parser_impl_variable_decoration_list_test.cc +++ b/src/reader/wgsl/parser_impl_variable_decoration_list_test.cc @@ -19,7 +19,7 @@ namespace reader { namespace wgsl { namespace { -TEST_F(ParserImplTest, VariableDecorationList_Parses) { +TEST_F(ParserImplTest, DecorationList_Parses) { auto p = parser(R"([[location(4), builtin(position)]])"); auto decos = p->decoration_list(); ASSERT_FALSE(p->has_error()) << p->error(); @@ -27,8 +27,8 @@ TEST_F(ParserImplTest, VariableDecorationList_Parses) { ASSERT_TRUE(decos.matched); ASSERT_EQ(decos.value.size(), 2u); - auto* deco_0 = decos.value[0]->As(); - auto* deco_1 = decos.value[1]->As(); + auto* deco_0 = decos.value[0]->As(); + auto* deco_1 = decos.value[1]->As(); ASSERT_NE(deco_0, nullptr); ASSERT_NE(deco_1, nullptr); @@ -39,7 +39,7 @@ TEST_F(ParserImplTest, VariableDecorationList_Parses) { ast::Builtin::kPosition); } -TEST_F(ParserImplTest, VariableDecorationList_Empty) { +TEST_F(ParserImplTest, DecorationList_Empty) { auto p = parser(R"([[]])"); auto decos = p->decoration_list(); EXPECT_TRUE(p->has_error()); @@ -49,7 +49,7 @@ TEST_F(ParserImplTest, VariableDecorationList_Empty) { EXPECT_EQ(p->error(), "1:3: empty decoration list"); } -TEST_F(ParserImplTest, VariableDecorationList_Invalid) { +TEST_F(ParserImplTest, DecorationList_Invalid) { auto p = parser(R"([[invalid]])"); auto decos = p->decoration_list(); EXPECT_TRUE(p->has_error()); @@ -59,7 +59,7 @@ TEST_F(ParserImplTest, VariableDecorationList_Invalid) { EXPECT_EQ(p->error(), "1:3: expected decoration"); } -TEST_F(ParserImplTest, VariableDecorationList_ExtraComma) { +TEST_F(ParserImplTest, DecorationList_ExtraComma) { auto p = parser(R"([[builtin(position), ]])"); auto decos = p->decoration_list(); EXPECT_TRUE(p->has_error()); @@ -69,7 +69,7 @@ TEST_F(ParserImplTest, VariableDecorationList_ExtraComma) { EXPECT_EQ(p->error(), "1:22: expected decoration"); } -TEST_F(ParserImplTest, VariableDecorationList_MissingComma) { +TEST_F(ParserImplTest, DecorationList_MissingComma) { auto p = parser(R"([[binding(4) location(5)]])"); auto decos = p->decoration_list(); EXPECT_TRUE(p->has_error()); @@ -79,7 +79,7 @@ TEST_F(ParserImplTest, VariableDecorationList_MissingComma) { EXPECT_EQ(p->error(), "1:14: expected ',' for decoration list"); } -TEST_F(ParserImplTest, VariableDecorationList_BadDecoration) { +TEST_F(ParserImplTest, DecorationList_BadDecoration) { auto p = parser(R"([[location(bad)]])"); auto decos = p->decoration_list(); EXPECT_TRUE(p->has_error()); @@ -90,7 +90,7 @@ TEST_F(ParserImplTest, VariableDecorationList_BadDecoration) { "1:12: expected signed integer literal for location decoration"); } -TEST_F(ParserImplTest, VariableDecorationList_InvalidBuiltin) { +TEST_F(ParserImplTest, DecorationList_InvalidBuiltin) { auto p = parser("[[builtin(invalid)]]"); auto decos = p->decoration_list(); EXPECT_TRUE(p->has_error()); diff --git a/src/reader/wgsl/parser_impl_variable_decoration_test.cc b/src/reader/wgsl/parser_impl_variable_decoration_test.cc index f73d3d5d4c4..4f4f6af3384 100644 --- a/src/reader/wgsl/parser_impl_variable_decoration_test.cc +++ b/src/reader/wgsl/parser_impl_variable_decoration_test.cc @@ -19,13 +19,13 @@ namespace reader { namespace wgsl { namespace { -TEST_F(ParserImplTest, VariableDecoration_Location) { +TEST_F(ParserImplTest, Decoration_Location) { auto p = parser("location(4)"); auto deco = p->decoration(); EXPECT_TRUE(deco.matched); EXPECT_FALSE(deco.errored); ASSERT_NE(deco.value, nullptr); - auto* var_deco = deco.value->As(); + auto* var_deco = deco.value->As(); ASSERT_NE(var_deco, nullptr); ASSERT_FALSE(p->has_error()); ASSERT_TRUE(var_deco->Is()); @@ -34,7 +34,7 @@ TEST_F(ParserImplTest, VariableDecoration_Location) { EXPECT_EQ(loc->value(), 4u); } -TEST_F(ParserImplTest, VariableDecoration_Location_MissingLeftParen) { +TEST_F(ParserImplTest, Decoration_Location_MissingLeftParen) { auto p = parser("location 4)"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -44,7 +44,7 @@ TEST_F(ParserImplTest, VariableDecoration_Location_MissingLeftParen) { EXPECT_EQ(p->error(), "1:10: expected '(' for location decoration"); } -TEST_F(ParserImplTest, VariableDecoration_Location_MissingRightParen) { +TEST_F(ParserImplTest, Decoration_Location_MissingRightParen) { auto p = parser("location(4"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -54,7 +54,7 @@ TEST_F(ParserImplTest, VariableDecoration_Location_MissingRightParen) { EXPECT_EQ(p->error(), "1:11: expected ')' for location decoration"); } -TEST_F(ParserImplTest, VariableDecoration_Location_MissingValue) { +TEST_F(ParserImplTest, Decoration_Location_MissingValue) { auto p = parser("location()"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -65,7 +65,7 @@ TEST_F(ParserImplTest, VariableDecoration_Location_MissingValue) { "1:10: expected signed integer literal for location decoration"); } -TEST_F(ParserImplTest, VariableDecoration_Location_MissingInvalid) { +TEST_F(ParserImplTest, Decoration_Location_MissingInvalid) { auto p = parser("location(nan)"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -87,7 +87,7 @@ inline std::ostream& operator<<(std::ostream& out, BuiltinData data) { class BuiltinTest : public ParserImplTestWithParam {}; -TEST_P(BuiltinTest, VariableDecoration_Builtin) { +TEST_P(BuiltinTest, Decoration_Builtin) { auto params = GetParam(); auto p = parser(std::string("builtin(") + params.input + ")"); @@ -95,7 +95,7 @@ TEST_P(BuiltinTest, VariableDecoration_Builtin) { EXPECT_TRUE(deco.matched); EXPECT_FALSE(deco.errored); ASSERT_NE(deco.value, nullptr); - auto* var_deco = deco.value->As(); + auto* var_deco = deco.value->As(); ASSERT_FALSE(p->has_error()) << p->error(); ASSERT_NE(var_deco, nullptr); ASSERT_TRUE(var_deco->Is()); @@ -125,7 +125,7 @@ INSTANTIATE_TEST_SUITE_P( BuiltinData{"sample_mask_in", ast::Builtin::kSampleMaskIn}, BuiltinData{"sample_mask_out", ast::Builtin::kSampleMaskOut})); -TEST_F(ParserImplTest, VariableDecoration_Builtin_MissingLeftParen) { +TEST_F(ParserImplTest, Decoration_Builtin_MissingLeftParen) { auto p = parser("builtin position)"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -135,7 +135,7 @@ TEST_F(ParserImplTest, VariableDecoration_Builtin_MissingLeftParen) { EXPECT_EQ(p->error(), "1:9: expected '(' for builtin decoration"); } -TEST_F(ParserImplTest, VariableDecoration_Builtin_MissingRightParen) { +TEST_F(ParserImplTest, Decoration_Builtin_MissingRightParen) { auto p = parser("builtin(position"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -145,7 +145,7 @@ TEST_F(ParserImplTest, VariableDecoration_Builtin_MissingRightParen) { EXPECT_EQ(p->error(), "1:17: expected ')' for builtin decoration"); } -TEST_F(ParserImplTest, VariableDecoration_Builtin_MissingValue) { +TEST_F(ParserImplTest, Decoration_Builtin_MissingValue) { auto p = parser("builtin()"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -155,7 +155,7 @@ TEST_F(ParserImplTest, VariableDecoration_Builtin_MissingValue) { EXPECT_EQ(p->error(), "1:9: expected identifier for builtin"); } -TEST_F(ParserImplTest, VariableDecoration_Builtin_InvalidValue) { +TEST_F(ParserImplTest, Decoration_Builtin_InvalidValue) { auto p = parser("builtin(other_thingy)"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -165,7 +165,7 @@ TEST_F(ParserImplTest, VariableDecoration_Builtin_InvalidValue) { EXPECT_EQ(p->error(), "1:9: invalid value for builtin decoration"); } -TEST_F(ParserImplTest, VariableDecoration_Builtin_MissingInvalid) { +TEST_F(ParserImplTest, Decoration_Builtin_MissingInvalid) { auto p = parser("builtin(3)"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -175,13 +175,13 @@ TEST_F(ParserImplTest, VariableDecoration_Builtin_MissingInvalid) { EXPECT_EQ(p->error(), "1:9: expected identifier for builtin"); } -TEST_F(ParserImplTest, VariableDecoration_Binding) { +TEST_F(ParserImplTest, Decoration_Binding) { auto p = parser("binding(4)"); auto deco = p->decoration(); EXPECT_TRUE(deco.matched); EXPECT_FALSE(deco.errored); ASSERT_NE(deco.value, nullptr); - auto* var_deco = deco.value->As(); + auto* var_deco = deco.value->As(); ASSERT_NE(var_deco, nullptr); ASSERT_FALSE(p->has_error()); ASSERT_TRUE(var_deco->Is()); @@ -190,7 +190,7 @@ TEST_F(ParserImplTest, VariableDecoration_Binding) { EXPECT_EQ(binding->value(), 4u); } -TEST_F(ParserImplTest, VariableDecoration_Binding_MissingLeftParen) { +TEST_F(ParserImplTest, Decoration_Binding_MissingLeftParen) { auto p = parser("binding 4)"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -200,7 +200,7 @@ TEST_F(ParserImplTest, VariableDecoration_Binding_MissingLeftParen) { EXPECT_EQ(p->error(), "1:9: expected '(' for binding decoration"); } -TEST_F(ParserImplTest, VariableDecoration_Binding_MissingRightParen) { +TEST_F(ParserImplTest, Decoration_Binding_MissingRightParen) { auto p = parser("binding(4"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -210,7 +210,7 @@ TEST_F(ParserImplTest, VariableDecoration_Binding_MissingRightParen) { EXPECT_EQ(p->error(), "1:10: expected ')' for binding decoration"); } -TEST_F(ParserImplTest, VariableDecoration_Binding_MissingValue) { +TEST_F(ParserImplTest, Decoration_Binding_MissingValue) { auto p = parser("binding()"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -221,7 +221,7 @@ TEST_F(ParserImplTest, VariableDecoration_Binding_MissingValue) { "1:9: expected signed integer literal for binding decoration"); } -TEST_F(ParserImplTest, VariableDecoration_Binding_MissingInvalid) { +TEST_F(ParserImplTest, Decoration_Binding_MissingInvalid) { auto p = parser("binding(nan)"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -233,13 +233,13 @@ TEST_F(ParserImplTest, VariableDecoration_Binding_MissingInvalid) { } // DEPRECATED -TEST_F(ParserImplTest, VariableDecoration_set) { +TEST_F(ParserImplTest, Decoration_set) { auto p = parser("set(4)"); auto deco = p->decoration(); EXPECT_TRUE(deco.matched); EXPECT_FALSE(deco.errored); ASSERT_NE(deco.value, nullptr); - auto* var_deco = deco.value->As(); + auto* var_deco = deco.value->As(); ASSERT_FALSE(p->has_error()); ASSERT_NE(var_deco, nullptr); ASSERT_TRUE(var_deco->Is()); @@ -248,13 +248,13 @@ TEST_F(ParserImplTest, VariableDecoration_set) { EXPECT_EQ(group->value(), 4u); } -TEST_F(ParserImplTest, VariableDecoration_group) { +TEST_F(ParserImplTest, Decoration_group) { auto p = parser("group(4)"); auto deco = p->decoration(); EXPECT_TRUE(deco.matched); EXPECT_FALSE(deco.errored); ASSERT_NE(deco.value, nullptr); - auto* var_deco = deco.value->As(); + auto* var_deco = deco.value->As(); ASSERT_FALSE(p->has_error()); ASSERT_NE(var_deco, nullptr); ASSERT_TRUE(var_deco->Is()); @@ -263,7 +263,7 @@ TEST_F(ParserImplTest, VariableDecoration_group) { EXPECT_EQ(group->value(), 4u); } -TEST_F(ParserImplTest, VariableDecoration_Group_MissingLeftParen) { +TEST_F(ParserImplTest, Decoration_Group_MissingLeftParen) { auto p = parser("group 2)"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -273,7 +273,7 @@ TEST_F(ParserImplTest, VariableDecoration_Group_MissingLeftParen) { EXPECT_EQ(p->error(), "1:7: expected '(' for group decoration"); } -TEST_F(ParserImplTest, VariableDecoration_Group_MissingRightParen) { +TEST_F(ParserImplTest, Decoration_Group_MissingRightParen) { auto p = parser("group(2"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -283,7 +283,7 @@ TEST_F(ParserImplTest, VariableDecoration_Group_MissingRightParen) { EXPECT_EQ(p->error(), "1:8: expected ')' for group decoration"); } -TEST_F(ParserImplTest, VariableDecoration_Group_MissingValue) { +TEST_F(ParserImplTest, Decoration_Group_MissingValue) { auto p = parser("group()"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); @@ -294,7 +294,7 @@ TEST_F(ParserImplTest, VariableDecoration_Group_MissingValue) { "1:7: expected signed integer literal for group decoration"); } -TEST_F(ParserImplTest, VariableDecoration_Group_MissingInvalid) { +TEST_F(ParserImplTest, Decoration_Group_MissingInvalid) { auto p = parser("group(nan)"); auto deco = p->decoration(); EXPECT_FALSE(deco.matched); 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 4555eeb03fd..2f9274f1eec 100644 --- a/src/reader/wgsl/parser_impl_variable_ident_decl_test.cc +++ b/src/reader/wgsl/parser_impl_variable_ident_decl_test.cc @@ -109,12 +109,12 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithTextureAccessDeco_Write) { TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) { auto p = parser("my_var : [[access(read)]] S"); - auto* mem = Member("a", ty.i32(), ast::StructMemberDecorationList{}); + auto* mem = Member("a", ty.i32(), ast::DecorationList{}); ast::StructMemberList members; members.push_back(mem); auto* block_deco = create(); - ast::StructDecorationList decos; + ast::DecorationList decos; decos.push_back(block_deco); auto* str = create(members, decos); @@ -134,12 +134,12 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) { TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) { auto p = parser("my_var : [[access(read_write)]] S"); - auto* mem = Member("a", ty.i32(), ast::StructMemberDecorationList{}); + auto* mem = Member("a", ty.i32(), ast::DecorationList{}); ast::StructMemberList members; members.push_back(mem); auto* block_deco = create(); - ast::StructDecorationList decos; + ast::DecorationList decos; decos.push_back(block_deco); auto* str = create(members, decos); @@ -159,12 +159,12 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) { TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDecoFail) { auto p = parser("my_var : [[access(read), access(read_write)]] S"); - auto* mem = Member("a", ty.i32(), ast::StructMemberDecorationList{}); + auto* mem = Member("a", ty.i32(), ast::DecorationList{}); ast::StructMemberList members; members.push_back(mem); auto* block_deco = create(); - ast::StructDecorationList decos; + ast::DecorationList decos; decos.push_back(block_deco); auto* str = create(members, decos); @@ -181,12 +181,12 @@ TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDecoFail) { TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDeco_MultiBlock_Fail) { auto p = parser("my_var : [[access(read)]][[access(read_write)]] S"); - auto* mem = Member("a", ty.i32(), ast::StructMemberDecorationList{}); + auto* mem = Member("a", ty.i32(), ast::DecorationList{}); ast::StructMemberList members; members.push_back(mem); auto* block_deco = create(); - ast::StructDecorationList decos; + ast::DecorationList decos; decos.push_back(block_deco); auto* str = create(members, decos); @@ -219,12 +219,12 @@ TEST_F(ParserImplTest, VariableIdentDecl_AccessDecoIllegalValue) { TEST_F(ParserImplTest, VariableIdentDecl_NonAccessDecoFail) { auto p = parser("my_var : [[stride(1)]] S"); - auto* mem = Member("a", ty.i32(), ast::StructMemberDecorationList{}); + auto* mem = Member("a", ty.i32(), ast::DecorationList{}); ast::StructMemberList members; members.push_back(mem); auto* block_deco = create(); - ast::StructDecorationList decos; + ast::DecorationList decos; decos.push_back(block_deco); auto* str = create(members, decos); diff --git a/src/resolver/resolver_test.cc b/src/resolver/resolver_test.cc index ab8bcee4931..66bf2af1255 100644 --- a/src/resolver/resolver_test.cc +++ b/src/resolver/resolver_test.cc @@ -248,7 +248,7 @@ TEST_F(ResolverTest, Stmt_Switch) { TEST_F(ResolverTest, Stmt_Call) { ast::VariableList params; Func("my_func", params, ty.f32(), ast::StatementList{}, - ast::FunctionDecorationList{}); + ast::DecorationList{}); auto* expr = Call("my_func"); @@ -337,7 +337,7 @@ TEST_F(ResolverTest, Stmt_VariableDecl_OuterScopeAfterInnerScope) { Func("func", params, ty.f32(), ast::StatementList{inner, foo_f32_decl, bar_f32_decl}, - ast::FunctionDecorationList{}); + ast::DecorationList{}); EXPECT_TRUE(r()->Resolve()); ASSERT_NE(TypeOf(foo_i32_init), nullptr); @@ -372,7 +372,7 @@ TEST_F(ResolverTest, Stmt_VariableDecl_ModuleScopeAfterFunctionScope) { auto* fn_i32_init = fn_i32->constructor(); auto* fn_i32_decl = create(fn_i32); Func("func_i32", params, ty.i32(), ast::StatementList{fn_i32_decl}, - ast::FunctionDecorationList{}); + ast::DecorationList{}); // Declare f32 "foo" at module scope auto* mod_f32 = Var("foo", ty.f32(), ast::StorageClass::kNone, Expr(2.f)); @@ -384,7 +384,7 @@ TEST_F(ResolverTest, Stmt_VariableDecl_ModuleScopeAfterFunctionScope) { auto* fn_f32_init = fn_f32->constructor(); auto* fn_f32_decl = create(fn_f32); Func("func_f32", params, ty.f32(), ast::StatementList{fn_f32_decl}, - ast::FunctionDecorationList{}); + ast::DecorationList{}); EXPECT_TRUE(r()->Resolve()); ASSERT_NE(TypeOf(mod_init), nullptr); @@ -506,7 +506,7 @@ TEST_F(ResolverTest, Expr_Bitcast) { TEST_F(ResolverTest, Expr_Call) { ast::VariableList params; Func("my_func", params, ty.f32(), ast::StatementList{}, - ast::FunctionDecorationList{}); + ast::DecorationList{}); auto* call = Call("my_func"); WrapInFunction(call); @@ -519,8 +519,7 @@ TEST_F(ResolverTest, Expr_Call) { TEST_F(ResolverTest, Expr_Call_InBinaryOp) { ast::VariableList params; - Func("func", params, ty.f32(), ast::StatementList{}, - ast::FunctionDecorationList{}); + Func("func", params, ty.f32(), ast::StatementList{}, ast::DecorationList{}); auto* expr = Add(Call("func"), Call("func")); WrapInFunction(expr); @@ -534,7 +533,7 @@ TEST_F(ResolverTest, Expr_Call_InBinaryOp) { TEST_F(ResolverTest, Expr_Call_WithParams) { ast::VariableList params; Func("my_func", params, ty.f32(), ast::StatementList{}, - ast::FunctionDecorationList{}); + ast::DecorationList{}); auto* param = Expr(2.4f); @@ -629,7 +628,7 @@ TEST_F(ResolverTest, Expr_Identifier_FunctionVariable_Const) { create(var), assign, }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -654,7 +653,7 @@ TEST_F(ResolverTest, Expr_Identifier_FunctionVariable) { create(var), assign, }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -681,7 +680,7 @@ TEST_F(ResolverTest, Expr_Identifier_Function_Ptr) { ast::StorageClass::kNone)), assign, }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -697,7 +696,7 @@ TEST_F(ResolverTest, Expr_Identifier_Function_Ptr) { TEST_F(ResolverTest, Expr_Call_Function) { Func("my_func", ast::VariableList{}, ty.f32(), ast::StatementList{}, - ast::FunctionDecorationList{}); + ast::DecorationList{}); auto* call = Call("my_func"); WrapInFunction(call); @@ -730,7 +729,7 @@ TEST_F(ResolverTest, Function_RegisterInputOutputVariables) { create(Expr("sb_var"), Expr("sb_var")), create(Expr("priv_var"), Expr("priv_var")), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -760,14 +759,14 @@ TEST_F(ResolverTest, Function_RegisterInputOutputVariables_SubFunction) { create(Expr("sb_var"), Expr("sb_var")), create(Expr("priv_var"), Expr("priv_var")), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); auto* func2 = Func( "func", ast::VariableList{}, ty.f32(), ast::StatementList{ create(Expr("out_var"), Call("my_func")), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -792,7 +791,7 @@ TEST_F(ResolverTest, Function_NotRegisterFunctionVariable) { create(var), create(Expr("var"), Expr(1.f)), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); Global("var", ty.f32(), ast::StorageClass::kFunction); @@ -808,7 +807,7 @@ TEST_F(ResolverTest, Expr_MemberAccessor_Struct) { auto* strct = create( ast::StructMemberList{Member("first_member", ty.i32()), Member("second_member", ty.f32())}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* st = ty.struct_("S", strct); Global("my_struct", st, ast::StorageClass::kNone); @@ -829,7 +828,7 @@ TEST_F(ResolverTest, Expr_MemberAccessor_Struct_Alias) { auto* strct = create( ast::StructMemberList{Member("first_member", ty.i32()), Member("second_member", ty.f32())}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* st = ty.struct_("alias", strct); auto* alias = ty.alias("alias", st); @@ -906,12 +905,12 @@ TEST_F(ResolverTest, Expr_Accessor_MultiLevel) { auto* strctB = create(ast::StructMemberList{Member("foo", ty.vec4())}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* stB = ty.struct_("B", strctB); type::Vector vecB(stB, 3); auto* strctA = create( - ast::StructMemberList{Member("mem", &vecB)}, ast::StructDecorationList{}); + ast::StructMemberList{Member("mem", &vecB)}, ast::DecorationList{}); auto* stA = ty.struct_("A", strctA); Global("c", stA, ast::StorageClass::kNone); @@ -933,7 +932,7 @@ TEST_F(ResolverTest, Expr_MemberAccessor_InBinaryOp) { auto* strct = create( ast::StructMemberList{Member("first_member", ty.f32()), Member("second_member", ty.f32())}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* st = ty.struct_("S", strct); Global("my_struct", st, ast::StorageClass::kNone); @@ -1214,7 +1213,7 @@ TEST_F(ResolverTest, StorageClass_SetsIfMissing) { auto* stmt = create(var); Func("func", ast::VariableList{}, ty.i32(), ast::StatementList{stmt}, - ast::FunctionDecorationList{}); + ast::DecorationList{}); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -1225,7 +1224,7 @@ TEST_F(ResolverTest, StorageClass_DoesNotSetOnConst) { auto* var = Const("var", ty.i32()); auto* stmt = create(var); Func("func", ast::VariableList{}, ty.i32(), ast::StatementList{stmt}, - ast::FunctionDecorationList{}); + ast::DecorationList{}); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -1246,21 +1245,21 @@ TEST_F(ResolverTest, Function_EntryPoints_StageDecoration) { // ep_2 -> {} ast::VariableList params; - auto* func_b = Func("b", params, ty.f32(), ast::StatementList{}, - ast::FunctionDecorationList{}); + auto* func_b = + Func("b", params, ty.f32(), ast::StatementList{}, ast::DecorationList{}); auto* func_c = Func("c", params, ty.f32(), ast::StatementList{ create(Expr("second"), Call("b")), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); auto* func_a = Func("a", params, ty.f32(), ast::StatementList{ create(Expr("first"), Call("c")), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); auto* ep_1 = Func("ep_1", params, ty.f32(), @@ -1268,7 +1267,7 @@ TEST_F(ResolverTest, Function_EntryPoints_StageDecoration) { create(Expr("call_a"), Call("a")), create(Expr("call_b"), Call("b")), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -1277,7 +1276,7 @@ TEST_F(ResolverTest, Function_EntryPoints_StageDecoration) { ast::StatementList{ create(Expr("call_c"), Call("c")), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); diff --git a/src/resolver/validation_test.cc b/src/resolver/validation_test.cc index 63811e2cd60..87c111eb431 100644 --- a/src/resolver/validation_test.cc +++ b/src/resolver/validation_test.cc @@ -95,13 +95,13 @@ TEST_F(ResolverValidationTest, Stmt_Call_undeclared) { create(call_expr), create(), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); Func("func", params0, ty.f32(), ast::StatementList{ create(), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); EXPECT_FALSE(r()->Resolve()); @@ -120,7 +120,7 @@ TEST_F(ResolverValidationTest, Stmt_Call_recursive) { ast::StatementList{ create(call_expr), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -246,7 +246,7 @@ TEST_F(ResolverValidationTest, StorageClass_NonFunctionClassError) { auto* stmt = create(var); Func("func", ast::VariableList{}, ty.i32(), ast::StatementList{stmt}, - ast::FunctionDecorationList{}); + ast::DecorationList{}); EXPECT_FALSE(r()->Resolve()); diff --git a/src/transform/emit_vertex_point_size.cc b/src/transform/emit_vertex_point_size.cc index 319999f2da9..ef2eb62f7f8 100644 --- a/src/transform/emit_vertex_point_size.cc +++ b/src/transform/emit_vertex_point_size.cc @@ -47,7 +47,7 @@ Transform::Output EmitVertexPointSize::Run(const Program* in) { f32, // type false, // is_const nullptr, // constructor - ast::VariableDecorationList{ + ast::DecorationList{ out.create(Source{}, ast::Builtin::kPointSize), }); diff --git a/src/transform/first_index_offset.cc b/src/transform/first_index_offset.cc index 6ad4a740cac..61ab7250d95 100644 --- a/src/transform/first_index_offset.cc +++ b/src/transform/first_index_offset.cc @@ -101,7 +101,7 @@ Transform::Output FirstIndexOffset::Run(const Program* in) { CloneContext ctx(&out, in); ctx.ReplaceAll([&](ast::Variable* var) -> ast::Variable* { - for (ast::VariableDecoration* dec : var->decorations()) { + for (ast::Decoration* dec : var->decorations()) { if (auto* blt_dec = dec->As()) { ast::Builtin blt_type = blt_dec->value(); if (blt_type == ast::Builtin::kVertexIndex) { @@ -157,7 +157,7 @@ ast::Variable* FirstIndexOffset::State::AddUniformBuffer() { ast::StructMemberList members; uint32_t offset = 0; if (has_vertex_index) { - ast::StructMemberDecorationList member_dec; + ast::DecorationList member_dec; member_dec.push_back( dst->create(Source{}, offset)); members.push_back(dst->create( @@ -168,7 +168,7 @@ ast::Variable* FirstIndexOffset::State::AddUniformBuffer() { } if (has_instance_index) { - ast::StructMemberDecorationList member_dec; + ast::DecorationList member_dec; member_dec.push_back( dst->create(Source{}, offset)); members.push_back(dst->create( @@ -178,7 +178,7 @@ ast::Variable* FirstIndexOffset::State::AddUniformBuffer() { offset += 4; } - ast::StructDecorationList decos; + ast::DecorationList decos; decos.push_back(dst->create(Source{})); auto* struct_type = dst->create( @@ -192,7 +192,7 @@ ast::Variable* FirstIndexOffset::State::AddUniformBuffer() { struct_type, // type false, // is_const nullptr, // constructor - ast::VariableDecorationList{ + ast::DecorationList{ dst->create(Source{}, binding), dst->create(Source{}, group), }); @@ -227,7 +227,7 @@ ast::VariableDeclStatement* FirstIndexOffset::State::CreateFirstIndexOffset( dst->create(), // type true, // is_const constructor, // constructor - ast::VariableDecorationList{}); // decorations + ast::DecorationList{}); // decorations return dst->create(Source{}, var); } diff --git a/src/transform/vertex_pulling.cc b/src/transform/vertex_pulling.cc index 71e35786257..b9d65257d52 100644 --- a/src/transform/vertex_pulling.cc +++ b/src/transform/vertex_pulling.cc @@ -135,7 +135,7 @@ void VertexPulling::State::FindOrInsertVertexIndexIfUsed() { GetI32Type(), // type false, // is_const nullptr, // constructor - ast::VariableDecorationList{ + ast::DecorationList{ ctx.dst->create(Source{}, ast::Builtin::kVertexIndex), }); @@ -182,7 +182,7 @@ void VertexPulling::State::FindOrInsertInstanceIndexIfUsed() { GetI32Type(), // type false, // is_const nullptr, // constructor - ast::VariableDecorationList{ + ast::DecorationList{ ctx.dst->create(Source{}, ast::Builtin::kInstanceIndex), }); @@ -210,7 +210,7 @@ void VertexPulling::State::ConvertVertexInputVariablesToPrivate() { ctx.Clone(v->type()), // type false, // is_const nullptr, // constructor - ast::VariableDecorationList{}); // decorations + ast::DecorationList{}); // decorations location_to_var[location] = replacement; location_replacements.emplace_back(LocationReplacement{v, replacement}); break; @@ -224,13 +224,13 @@ void VertexPulling::State::AddVertexStorageBuffers() { // The array inside the struct definition auto* internal_array_type = ctx.dst->create( GetU32Type(), 0, - ast::ArrayDecorationList{ + ast::DecorationList{ ctx.dst->create(Source{}, 4u), }); // Creating the struct type ast::StructMemberList members; - ast::StructMemberDecorationList member_dec; + ast::DecorationList member_dec; member_dec.push_back( ctx.dst->create(Source{}, 0u)); @@ -238,7 +238,7 @@ void VertexPulling::State::AddVertexStorageBuffers() { Source{}, ctx.dst->Symbols().Register(kStructBufferName), internal_array_type, std::move(member_dec))); - ast::StructDecorationList decos; + ast::DecorationList decos; decos.push_back(ctx.dst->create(Source{})); auto* struct_type = ctx.dst->create( @@ -256,7 +256,7 @@ void VertexPulling::State::AddVertexStorageBuffers() { struct_type, // type false, // is_const nullptr, // constructor - ast::VariableDecorationList{ + ast::DecorationList{ ctx.dst->create(Source{}, i), ctx.dst->create(Source{}, cfg.pulling_group), }); @@ -276,11 +276,11 @@ ast::BlockStatement* VertexPulling::State::CreateVertexPullingPreamble() const { Source{}, ctx.dst->create( Source{}, // source ctx.dst->Symbols().Register(kPullingPosVarName), // symbol - ast::StorageClass::kFunction, // storage_class - GetI32Type(), // type - false, // is_const - nullptr, // constructor - ast::VariableDecorationList{})); // decorations + ast::StorageClass::kFunction, // storage_class + GetI32Type(), // type + false, // is_const + nullptr, // constructor + ast::DecorationList{})); // decorations // |kPullingPosVarName| refers to the byte location of the current read. We // declare a variable in the shader to avoid having to reuse Expression diff --git a/src/type/access_control_type_test.cc b/src/type/access_control_type_test.cc index b6c29c126ca..22563457eb7 100644 --- a/src/type/access_control_type_test.cc +++ b/src/type/access_control_type_test.cc @@ -103,16 +103,14 @@ TEST_F(AccessControlTest, MinBufferBindingSizeU32) { TEST_F(AccessControlTest, MinBufferBindingSizeArray) { U32 u32; - Array array(&u32, 4, - ast::ArrayDecorationList{create(4)}); + Array array(&u32, 4, ast::DecorationList{create(4)}); AccessControl at{ast::AccessControl::kReadOnly, &array}; EXPECT_EQ(16u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); } TEST_F(AccessControlTest, MinBufferBindingSizeRuntimeArray) { U32 u32; - Array array(&u32, 0, - ast::ArrayDecorationList{create(4)}); + Array array(&u32, 0, ast::DecorationList{create(4)}); AccessControl at{ast::AccessControl::kReadOnly, &array}; EXPECT_EQ(4u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); } @@ -121,7 +119,7 @@ TEST_F(AccessControlTest, MinBufferBindingSizeStruct) { auto* str = create( ast::StructMemberList{Member("foo", ty.u32(), {MemberOffset(0)}), Member("bar", ty.u32(), {MemberOffset(4)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* struct_type = ty.struct_("struct_type", str); AccessControl at{ast::AccessControl::kReadOnly, struct_type}; @@ -137,16 +135,14 @@ TEST_F(AccessControlTest, BaseAlignmentU32) { TEST_F(AccessControlTest, BaseAlignmentArray) { U32 u32; - Array array(&u32, 4, - ast::ArrayDecorationList{create(4)}); + Array array(&u32, 4, ast::DecorationList{create(4)}); AccessControl at{ast::AccessControl::kReadOnly, &array}; EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer)); } TEST_F(AccessControlTest, BaseAlignmentRuntimeArray) { U32 u32; - Array array(&u32, 0, - ast::ArrayDecorationList{create(4)}); + Array array(&u32, 0, ast::DecorationList{create(4)}); AccessControl at{ast::AccessControl::kReadOnly, &array}; EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer)); } @@ -155,7 +151,7 @@ TEST_F(AccessControlTest, BaseAlignmentStruct) { auto* str = create( ast::StructMemberList{Member("foo", ty.u32(), {MemberOffset(0)}), Member("bar", ty.u32(), {MemberOffset(4)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* struct_type = ty.struct_("struct_type", str); AccessControl at{ast::AccessControl::kReadOnly, struct_type}; diff --git a/src/type/alias_type_test.cc b/src/type/alias_type_test.cc index 13690dd97f1..278ea6afa75 100644 --- a/src/type/alias_type_test.cc +++ b/src/type/alias_type_test.cc @@ -144,7 +144,7 @@ TEST_F(AliasTest, MinBufferBindingSizeU32) { TEST_F(AliasTest, MinBufferBindingSizeArray) { Array array(ty.u32(), 4, - ast::ArrayDecorationList{ + ast::DecorationList{ create(4), }); auto* alias = ty.alias("alias", &array); @@ -153,7 +153,7 @@ TEST_F(AliasTest, MinBufferBindingSizeArray) { TEST_F(AliasTest, MinBufferBindingSizeRuntimeArray) { Array array(ty.u32(), 0, - ast::ArrayDecorationList{ + ast::DecorationList{ create(4), }); auto* alias = ty.alias("alias", &array); @@ -164,7 +164,7 @@ TEST_F(AliasTest, MinBufferBindingSizeStruct) { auto* str = create( ast::StructMemberList{Member("foo", ty.u32(), {MemberOffset(0)}), Member("bar", ty.u32(), {MemberOffset(4)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* struct_type = ty.struct_("struct_type", str); auto* alias = ty.alias("alias", struct_type); @@ -179,7 +179,7 @@ TEST_F(AliasTest, BaseAlignmentU32) { TEST_F(AliasTest, BaseAlignmentArray) { Array array(ty.u32(), 4, - ast::ArrayDecorationList{ + ast::DecorationList{ create(4), }); auto* alias = ty.alias("alias", &array); @@ -188,7 +188,7 @@ TEST_F(AliasTest, BaseAlignmentArray) { TEST_F(AliasTest, BaseAlignmentRuntimeArray) { Array array(ty.u32(), 0, - ast::ArrayDecorationList{ + ast::DecorationList{ create(4), }); auto* alias = ty.alias("alias", &array); @@ -199,7 +199,7 @@ TEST_F(AliasTest, BaseAlignmentStruct) { auto* str = create( ast::StructMemberList{Member("foo", ty.u32(), {MemberOffset(0)}), Member("bar", ty.u32(), {MemberOffset(4)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* struct_type = ty.struct_("struct_type", str); auto* alias = ty.alias("alias", struct_type); diff --git a/src/type/array_type.cc b/src/type/array_type.cc index 6d0b82590fa..29ead9b004b 100644 --- a/src/type/array_type.cc +++ b/src/type/array_type.cc @@ -23,7 +23,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::Array); namespace tint { namespace type { -Array::Array(Type* subtype, uint32_t size, ast::ArrayDecorationList decorations) +Array::Array(Type* subtype, uint32_t size, ast::DecorationList decorations) : subtype_(subtype), size_(size), decos_(decorations) {} Array::Array(Array&&) = default; diff --git a/src/type/array_type.h b/src/type/array_type.h index 27bc891056f..c0f74aa74d3 100644 --- a/src/type/array_type.h +++ b/src/type/array_type.h @@ -17,7 +17,7 @@ #include -#include "src/ast/array_decoration.h" +#include "src/ast/decoration.h" #include "src/type/type.h" namespace tint { @@ -31,7 +31,7 @@ class Array : public Castable { /// @param size the number of elements in the array. `0` represents a /// runtime-sized array. /// @param decorations the array decorations - Array(Type* subtype, uint32_t size, ast::ArrayDecorationList decorations); + Array(Type* subtype, uint32_t size, ast::DecorationList decorations); /// Move constructor Array(Array&&); ~Array() override; @@ -51,7 +51,7 @@ class Array : public Castable { uint64_t BaseAlignment(MemoryLayout mem_layout) const override; /// @returns the array decorations - const ast::ArrayDecorationList& decorations() const { return decos_; } + const ast::DecorationList& decorations() const { return decos_; } /// @returns the array stride or 0 if none set. uint32_t array_stride() const; @@ -79,7 +79,7 @@ class Array : public Castable { private: Type* const subtype_; uint32_t const size_; - ast::ArrayDecorationList const decos_; + ast::DecorationList const decos_; }; } // namespace type diff --git a/src/type/array_type_test.cc b/src/type/array_type_test.cc index 8e2b07e6a8b..30bf850bc39 100644 --- a/src/type/array_type_test.cc +++ b/src/type/array_type_test.cc @@ -24,7 +24,7 @@ using ArrayTest = TestHelper; TEST_F(ArrayTest, CreateSizedArray) { U32 u32; - Array arr{&u32, 3, ast::ArrayDecorationList{}}; + Array arr{&u32, 3, ast::DecorationList{}}; EXPECT_EQ(arr.type(), &u32); EXPECT_EQ(arr.size(), 3u); EXPECT_TRUE(arr.Is()); @@ -33,7 +33,7 @@ TEST_F(ArrayTest, CreateSizedArray) { TEST_F(ArrayTest, CreateRuntimeArray) { U32 u32; - Array arr{&u32, 0, ast::ArrayDecorationList{}}; + Array arr{&u32, 0, ast::DecorationList{}}; EXPECT_EQ(arr.type(), &u32); EXPECT_EQ(arr.size(), 0u); EXPECT_TRUE(arr.Is()); @@ -43,7 +43,7 @@ TEST_F(ArrayTest, CreateRuntimeArray) { TEST_F(ArrayTest, Is) { I32 i32; - Array arr{&i32, 3, ast::ArrayDecorationList{}}; + Array arr{&i32, 3, ast::DecorationList{}}; Type* ty = &arr; EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); @@ -62,71 +62,66 @@ TEST_F(ArrayTest, Is) { TEST_F(ArrayTest, TypeName) { I32 i32; - Array arr{&i32, 0, ast::ArrayDecorationList{}}; + Array arr{&i32, 0, ast::DecorationList{}}; EXPECT_EQ(arr.type_name(), "__array__i32"); } TEST_F(ArrayTest, FriendlyNameRuntimeSized) { - Array arr{ty.i32(), 0, ast::ArrayDecorationList{}}; + Array arr{ty.i32(), 0, ast::DecorationList{}}; EXPECT_EQ(arr.FriendlyName(Symbols()), "array"); } TEST_F(ArrayTest, FriendlyNameStaticSized) { - Array arr{ty.i32(), 5, ast::ArrayDecorationList{}}; + Array arr{ty.i32(), 5, ast::DecorationList{}}; EXPECT_EQ(arr.FriendlyName(Symbols()), "array"); } TEST_F(ArrayTest, FriendlyNameWithStride) { Array arr{ty.i32(), 5, - ast::ArrayDecorationList{create(32)}}; + ast::DecorationList{create(32)}}; EXPECT_EQ(arr.FriendlyName(Symbols()), "[[stride(32)]] array"); } TEST_F(ArrayTest, TypeName_RuntimeArray) { I32 i32; - Array arr{&i32, 3, ast::ArrayDecorationList{}}; + Array arr{&i32, 3, ast::DecorationList{}}; EXPECT_EQ(arr.type_name(), "__array__i32_3"); } TEST_F(ArrayTest, TypeName_WithStride) { I32 i32; - Array arr{&i32, 3, - ast::ArrayDecorationList{create(16)}}; + Array arr{&i32, 3, ast::DecorationList{create(16)}}; EXPECT_EQ(arr.type_name(), "__array__i32_3_stride_16"); } TEST_F(ArrayTest, MinBufferBindingSizeNoStride) { U32 u32; - Array arr(&u32, 4, ast::ArrayDecorationList{}); + Array arr(&u32, 4, ast::DecorationList{}); EXPECT_EQ(0u, arr.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); } TEST_F(ArrayTest, MinBufferBindingSizeArray) { U32 u32; - Array arr(&u32, 4, - ast::ArrayDecorationList{create(4)}); + Array arr(&u32, 4, ast::DecorationList{create(4)}); EXPECT_EQ(16u, arr.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); } TEST_F(ArrayTest, MinBufferBindingSizeRuntimeArray) { U32 u32; - Array arr(&u32, 0, - ast::ArrayDecorationList{create(4)}); + Array arr(&u32, 0, ast::DecorationList{create(4)}); EXPECT_EQ(4u, arr.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); } TEST_F(ArrayTest, BaseAlignmentArray) { U32 u32; - Array arr(&u32, 4, - ast::ArrayDecorationList{create(4)}); + Array arr(&u32, 4, ast::DecorationList{create(4)}); EXPECT_EQ(16u, arr.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(4u, arr.BaseAlignment(MemoryLayout::kStorageBuffer)); } TEST_F(ArrayTest, BaseAlignmentRuntimeArray) { U32 u32; - Array arr(&u32, 0, - ast::ArrayDecorationList{create(4)}); + Array arr(&u32, 0, ast::DecorationList{create(4)}); EXPECT_EQ(16u, arr.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(4u, arr.BaseAlignment(MemoryLayout::kStorageBuffer)); } diff --git a/src/type/matrix_type.cc b/src/type/matrix_type.cc index 4d6293c2d28..d98c669a65b 100644 --- a/src/type/matrix_type.cc +++ b/src/type/matrix_type.cc @@ -53,7 +53,7 @@ uint64_t Matrix::MinBufferBindingSize(MemoryLayout mem_layout) const { uint64_t Matrix::BaseAlignment(MemoryLayout mem_layout) const { Vector vec(subtype_, rows_); - Array arr(&vec, columns_, ast::ArrayDecorationList{}); + Array arr(&vec, columns_, ast::DecorationList{}); return arr.BaseAlignment(mem_layout); } diff --git a/src/type/struct_type_test.cc b/src/type/struct_type_test.cc index 368362e2c7d..ec562bc3468 100644 --- a/src/type/struct_type_test.cc +++ b/src/type/struct_type_test.cc @@ -24,7 +24,7 @@ using StructTypeTest = TestHelper; TEST_F(StructTypeTest, Creation) { auto* impl = - create(ast::StructMemberList{}, ast::StructDecorationList{}); + create(ast::StructMemberList{}, ast::DecorationList{}); auto* ptr = impl; auto* s = ty.struct_("S", impl); EXPECT_EQ(s->impl(), ptr); @@ -32,7 +32,7 @@ TEST_F(StructTypeTest, Creation) { TEST_F(StructTypeTest, Is) { auto* impl = - create(ast::StructMemberList{}, ast::StructDecorationList{}); + create(ast::StructMemberList{}, ast::DecorationList{}); auto* s = ty.struct_("S", impl); type::Type* ty = s; EXPECT_FALSE(ty->Is()); @@ -52,14 +52,14 @@ TEST_F(StructTypeTest, Is) { TEST_F(StructTypeTest, TypeName) { auto* impl = - create(ast::StructMemberList{}, ast::StructDecorationList{}); + create(ast::StructMemberList{}, ast::DecorationList{}); auto* s = ty.struct_("my_struct", impl); EXPECT_EQ(s->type_name(), "__struct_tint_symbol_1"); } TEST_F(StructTypeTest, FriendlyName) { auto* impl = - create(ast::StructMemberList{}, ast::StructDecorationList{}); + create(ast::StructMemberList{}, ast::DecorationList{}); auto* s = ty.struct_("my_struct", impl); EXPECT_EQ(s->FriendlyName(Symbols()), "my_struct"); } @@ -68,7 +68,7 @@ TEST_F(StructTypeTest, MinBufferBindingSize) { auto* str = create( ast::StructMemberList{Member("foo", ty.u32(), {MemberOffset(0)}), Member("bar", ty.u32(), {MemberOffset(4)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s_ty = ty.struct_("s_ty", str); EXPECT_EQ(16u, s_ty->MinBufferBindingSize(MemoryLayout::kUniformBuffer)); @@ -76,14 +76,13 @@ TEST_F(StructTypeTest, MinBufferBindingSize) { } TEST_F(StructTypeTest, MinBufferBindingSizeArray) { - Array arr(ty.u32(), 4, - ast::ArrayDecorationList{create(4)}); + Array arr(ty.u32(), 4, ast::DecorationList{create(4)}); auto* str = create( ast::StructMemberList{Member("foo", ty.u32(), {MemberOffset(0)}), Member("bar", ty.u32(), {MemberOffset(4)}), Member("bar", &arr, {MemberOffset(8)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s_ty = ty.struct_("s_ty", str); EXPECT_EQ(32u, s_ty->MinBufferBindingSize(MemoryLayout::kUniformBuffer)); @@ -91,14 +90,13 @@ TEST_F(StructTypeTest, MinBufferBindingSizeArray) { } TEST_F(StructTypeTest, MinBufferBindingSizeRuntimeArray) { - Array arr(ty.u32(), 0, - ast::ArrayDecorationList{create(4)}); + Array arr(ty.u32(), 0, ast::DecorationList{create(4)}); auto* str = create( ast::StructMemberList{Member("foo", ty.u32(), {MemberOffset(0)}), Member("bar", ty.u32(), {MemberOffset(4)}), Member("bar", ty.u32(), {MemberOffset(8)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s_ty = ty.struct_("s_ty", str); EXPECT_EQ(12u, s_ty->MinBufferBindingSize(MemoryLayout::kStorageBuffer)); @@ -107,7 +105,7 @@ TEST_F(StructTypeTest, MinBufferBindingSizeRuntimeArray) { TEST_F(StructTypeTest, MinBufferBindingSizeVec2) { auto* str = create( ast::StructMemberList{Member("foo", ty.vec2(), {MemberOffset(0)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s_ty = ty.struct_("s_ty", str); EXPECT_EQ(16u, s_ty->MinBufferBindingSize(MemoryLayout::kUniformBuffer)); @@ -117,7 +115,7 @@ TEST_F(StructTypeTest, MinBufferBindingSizeVec2) { TEST_F(StructTypeTest, MinBufferBindingSizeVec3) { auto* str = create( ast::StructMemberList{Member("foo", ty.vec3(), {MemberOffset(0)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s_ty = ty.struct_("s_ty", str); EXPECT_EQ(16u, s_ty->MinBufferBindingSize(MemoryLayout::kUniformBuffer)); @@ -127,7 +125,7 @@ TEST_F(StructTypeTest, MinBufferBindingSizeVec3) { TEST_F(StructTypeTest, MinBufferBindingSizeVec4) { auto* str = create( ast::StructMemberList{Member("foo", ty.vec4(), {MemberOffset(0)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s_ty = ty.struct_("s_ty", str); EXPECT_EQ(16u, s_ty->MinBufferBindingSize(MemoryLayout::kUniformBuffer)); @@ -138,7 +136,7 @@ TEST_F(StructTypeTest, BaseAlignment) { auto* str = create( ast::StructMemberList{Member("foo", ty.u32(), {MemberOffset(0)}), Member("bar", ty.u32(), {MemberOffset(8)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s_ty = ty.struct_("s_ty", str); EXPECT_EQ(16u, s_ty->BaseAlignment(MemoryLayout::kUniformBuffer)); @@ -146,13 +144,12 @@ TEST_F(StructTypeTest, BaseAlignment) { } TEST_F(StructTypeTest, BaseAlignmentArray) { - Array arr(ty.u32(), 4, - ast::ArrayDecorationList{create(4)}); + Array arr(ty.u32(), 4, ast::DecorationList{create(4)}); auto* str = create( ast::StructMemberList{Member("foo", ty.u32(), {MemberOffset(0)}), Member("bar", ty.u32(), {MemberOffset(4)}), Member("bar", &arr, {MemberOffset(8)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s_ty = ty.struct_("s_ty", str); EXPECT_EQ(16u, s_ty->BaseAlignment(MemoryLayout::kUniformBuffer)); @@ -160,13 +157,12 @@ TEST_F(StructTypeTest, BaseAlignmentArray) { } TEST_F(StructTypeTest, BaseAlignmentRuntimeArray) { - Array arr(ty.u32(), 0, - ast::ArrayDecorationList{create(4)}); + Array arr(ty.u32(), 0, ast::DecorationList{create(4)}); auto* str = create( ast::StructMemberList{Member("foo", ty.u32(), {MemberOffset(0)}), Member("bar", ty.u32(), {MemberOffset(4)}), Member("bar", ty.u32(), {MemberOffset(8)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s_ty = ty.struct_("s_ty", str); EXPECT_EQ(4u, s_ty->BaseAlignment(MemoryLayout::kStorageBuffer)); @@ -175,7 +171,7 @@ TEST_F(StructTypeTest, BaseAlignmentRuntimeArray) { TEST_F(StructTypeTest, BaseAlignmentVec2) { auto* str = create( ast::StructMemberList{Member("foo", ty.vec2(), {MemberOffset(0)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s_ty = ty.struct_("s_ty", str); EXPECT_EQ(16u, s_ty->BaseAlignment(MemoryLayout::kUniformBuffer)); @@ -185,7 +181,7 @@ TEST_F(StructTypeTest, BaseAlignmentVec2) { TEST_F(StructTypeTest, BaseAlignmentVec3) { auto* str = create( ast::StructMemberList{Member("foo", ty.vec3(), {MemberOffset(0)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s_ty = ty.struct_("s_ty", str); EXPECT_EQ(16u, s_ty->BaseAlignment(MemoryLayout::kUniformBuffer)); @@ -195,7 +191,7 @@ TEST_F(StructTypeTest, BaseAlignmentVec3) { TEST_F(StructTypeTest, BaseAlignmentVec4) { auto* str = create( ast::StructMemberList{Member("foo", ty.vec4(), {MemberOffset(0)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s_ty = ty.struct_("s_ty", str); EXPECT_EQ(16u, s_ty->BaseAlignment(MemoryLayout::kUniformBuffer)); diff --git a/src/validator/validator_decoration_test.cc b/src/validator/validator_decoration_test.cc new file mode 100644 index 00000000000..67362c47e1b --- /dev/null +++ b/src/validator/validator_decoration_test.cc @@ -0,0 +1,253 @@ +// Copyright 2021 The Tint Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "src/ast/access_decoration.h" +#include "src/ast/binding_decoration.h" +#include "src/ast/builtin_decoration.h" +#include "src/ast/constant_id_decoration.h" +#include "src/ast/group_decoration.h" +#include "src/ast/location_decoration.h" +#include "src/ast/stage_decoration.h" +#include "src/ast/struct_block_decoration.h" +#include "src/ast/struct_member_offset_decoration.h" +#include "src/ast/workgroup_decoration.h" +#include "src/validator/validator_test_helper.h" + +namespace tint { +namespace { + +enum class DecorationKind { + kAccess, + kBinding, + kBuiltin, + kConstantId, + kGroup, + kLocation, + kStage, + kStride, + kStructBlock, + kStructMemberOffset, + kWorkgroup, +}; +struct DecorationTestParams { + DecorationKind kind; + bool should_pass; +}; +class ValidatorDecorationsTestWithParams + : public ValidatorTestHelper, + public testing::TestWithParam {}; + +ast::Decoration* createDecoration(ProgramBuilder& builder, + DecorationKind kind) { + switch (kind) { + case DecorationKind::kAccess: + return builder.create( + ast::AccessControl::kReadOnly); + case DecorationKind::kLocation: + return builder.create(1); + case DecorationKind::kBinding: + return builder.create(1); + case DecorationKind::kGroup: + return builder.create(1u); + case DecorationKind::kBuiltin: + return builder.create(ast::Builtin::kPosition); + case DecorationKind::kWorkgroup: + return builder.create(1u, 1u, 1u); + case DecorationKind::kStage: + return builder.create(ast::PipelineStage::kCompute); + case DecorationKind::kStructBlock: + return builder.create(); + case DecorationKind::kStride: + return builder.create(4u); + case DecorationKind::kStructMemberOffset: + return builder.create(4u); + case DecorationKind::kConstantId: + return builder.create(0u); + } +} + +using ArrayDecorationTest = ValidatorDecorationsTestWithParams; +TEST_P(ArrayDecorationTest, Decoration_IsValid) { + auto params = GetParam(); + + ast::StructMemberList members{Member( + "a", create( + ty.f32(), 0, + ast::DecorationList{createDecoration(*this, params.kind)}))}; + auto* s = create( + members, ast::DecorationList{create()}); + auto* s_ty = ty.struct_("mystruct", s); + + ValidatorImpl& v = Build(); + + if (params.should_pass) { + EXPECT_TRUE(v.ValidateConstructedType(s_ty)); + } else { + EXPECT_FALSE(v.ValidateConstructedType(s_ty)); + EXPECT_EQ(v.error(), "decoration is not valid for array types"); + } +} +INSTANTIATE_TEST_SUITE_P( + ValidatorTest, + ArrayDecorationTest, + testing::Values(DecorationTestParams{DecorationKind::kAccess, false}, + DecorationTestParams{DecorationKind::kBinding, false}, + DecorationTestParams{DecorationKind::kBuiltin, false}, + DecorationTestParams{DecorationKind::kConstantId, false}, + DecorationTestParams{DecorationKind::kGroup, false}, + DecorationTestParams{DecorationKind::kLocation, false}, + DecorationTestParams{DecorationKind::kStage, false}, + DecorationTestParams{DecorationKind::kStride, true}, + DecorationTestParams{DecorationKind::kStructBlock, false}, + DecorationTestParams{DecorationKind::kStructMemberOffset, + false}, + DecorationTestParams{DecorationKind::kWorkgroup, false})); + +using FunctionDecorationTest = ValidatorDecorationsTestWithParams; +TEST_P(FunctionDecorationTest, Decoration_IsValid) { + auto params = GetParam(); + + Func("foo", ast::VariableList{}, ty.void_(), ast::StatementList{}, + ast::DecorationList{ + create(ast::PipelineStage::kCompute), + createDecoration(*this, params.kind)}); + + ValidatorImpl& v = Build(); + + if (params.should_pass) { + EXPECT_TRUE(v.Validate()); + } else { + EXPECT_FALSE(v.Validate()); + EXPECT_EQ(v.error(), "decoration is not valid for functions"); + } +} +INSTANTIATE_TEST_SUITE_P( + ValidatorTest, + FunctionDecorationTest, + testing::Values(DecorationTestParams{DecorationKind::kAccess, false}, + DecorationTestParams{DecorationKind::kBinding, false}, + DecorationTestParams{DecorationKind::kBuiltin, false}, + DecorationTestParams{DecorationKind::kConstantId, false}, + DecorationTestParams{DecorationKind::kGroup, false}, + DecorationTestParams{DecorationKind::kLocation, false}, + // Skip kStage as we always apply it in this test + DecorationTestParams{DecorationKind::kStride, false}, + DecorationTestParams{DecorationKind::kStructBlock, false}, + DecorationTestParams{DecorationKind::kStructMemberOffset, + false}, + DecorationTestParams{DecorationKind::kWorkgroup, true})); + +using StructDecorationTest = ValidatorDecorationsTestWithParams; +TEST_P(StructDecorationTest, Decoration_IsValid) { + auto params = GetParam(); + + auto* s = create( + ast::StructMemberList{}, + ast::DecorationList{createDecoration(*this, params.kind)}); + auto* s_ty = ty.struct_("mystruct", s); + + ValidatorImpl& v = Build(); + + if (params.should_pass) { + EXPECT_TRUE(v.ValidateConstructedType(s_ty)); + } else { + EXPECT_FALSE(v.ValidateConstructedType(s_ty)); + EXPECT_EQ(v.error(), "decoration is not valid for struct declarations"); + } +} +INSTANTIATE_TEST_SUITE_P( + ValidatorTest, + StructDecorationTest, + testing::Values(DecorationTestParams{DecorationKind::kAccess, false}, + DecorationTestParams{DecorationKind::kBinding, false}, + DecorationTestParams{DecorationKind::kBuiltin, false}, + DecorationTestParams{DecorationKind::kConstantId, false}, + DecorationTestParams{DecorationKind::kGroup, false}, + DecorationTestParams{DecorationKind::kLocation, false}, + DecorationTestParams{DecorationKind::kStage, false}, + DecorationTestParams{DecorationKind::kStride, false}, + DecorationTestParams{DecorationKind::kStructBlock, true}, + DecorationTestParams{DecorationKind::kStructMemberOffset, + false}, + DecorationTestParams{DecorationKind::kWorkgroup, false})); + +using StructMemberDecorations = ValidatorDecorationsTestWithParams; +TEST_P(StructMemberDecorations, Decoration_IsValid) { + auto params = GetParam(); + + ast::StructMemberList members{ + Member("a", ty.i32(), + ast::DecorationList{createDecoration(*this, params.kind)})}; + auto* s = create(members, ast::DecorationList{}); + auto* s_ty = ty.struct_("mystruct", s); + + ValidatorImpl& v = Build(); + + if (params.should_pass) { + EXPECT_TRUE(v.ValidateConstructedType(s_ty)); + } else { + EXPECT_FALSE(v.ValidateConstructedType(s_ty)); + EXPECT_EQ(v.error(), "decoration is not valid for structure members"); + } +} +INSTANTIATE_TEST_SUITE_P( + ValidatorTest, + StructMemberDecorations, + testing::Values(DecorationTestParams{DecorationKind::kAccess, false}, + DecorationTestParams{DecorationKind::kBinding, false}, + DecorationTestParams{DecorationKind::kBuiltin, true}, + DecorationTestParams{DecorationKind::kConstantId, false}, + DecorationTestParams{DecorationKind::kGroup, false}, + DecorationTestParams{DecorationKind::kLocation, true}, + DecorationTestParams{DecorationKind::kStage, false}, + DecorationTestParams{DecorationKind::kStride, false}, + DecorationTestParams{DecorationKind::kStructBlock, false}, + DecorationTestParams{DecorationKind::kStructMemberOffset, + true}, + DecorationTestParams{DecorationKind::kWorkgroup, false})); + +using VariableDecorationTest = ValidatorDecorationsTestWithParams; +TEST_P(VariableDecorationTest, Decoration_IsValid) { + auto params = GetParam(); + + auto* var = Global("a", ty.f32(), ast::StorageClass::kInput, nullptr, + ast::DecorationList{createDecoration(*this, params.kind)}); + + ValidatorImpl& v = Build(); + + if (params.should_pass) { + EXPECT_TRUE(v.ValidateGlobalVariable(var)); + } else { + EXPECT_FALSE(v.ValidateGlobalVariable(var)); + EXPECT_EQ(v.error(), "decoration is not valid for variables"); + } +} +INSTANTIATE_TEST_SUITE_P( + ValidatorTest, + VariableDecorationTest, + testing::Values(DecorationTestParams{DecorationKind::kAccess, false}, + DecorationTestParams{DecorationKind::kBinding, true}, + DecorationTestParams{DecorationKind::kBuiltin, true}, + DecorationTestParams{DecorationKind::kConstantId, true}, + DecorationTestParams{DecorationKind::kGroup, true}, + DecorationTestParams{DecorationKind::kLocation, true}, + DecorationTestParams{DecorationKind::kStage, false}, + DecorationTestParams{DecorationKind::kStride, false}, + DecorationTestParams{DecorationKind::kStructBlock, false}, + DecorationTestParams{DecorationKind::kStructMemberOffset, + false}, + DecorationTestParams{DecorationKind::kWorkgroup, false})); + +} // namespace +} // namespace tint diff --git a/src/validator/validator_function_test.cc b/src/validator/validator_function_test.cc index 137736934f0..e939da4de8f 100644 --- a/src/validator/validator_function_test.cc +++ b/src/validator/validator_function_test.cc @@ -31,7 +31,7 @@ TEST_F(ValidateFunctionTest, VoidFunctionEndWithoutReturnStatement_Pass) { ast::StatementList{ create(var), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -47,7 +47,7 @@ TEST_F(ValidateFunctionTest, Func(Source{Source::Location{12, 34}}, "func", ast::VariableList{}, ty.void_(), ast::StatementList{}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -65,7 +65,7 @@ TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatement_Fail) { ast::StatementList{ create(var), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); ValidatorImpl& v = Build(); @@ -78,7 +78,7 @@ TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatementEmptyBody_Fail) { // fn func -> int {} Func(Source{Source::Location{12, 34}}, "func", ast::VariableList{}, ty.i32(), - ast::StatementList{}, ast::FunctionDecorationList{}); + ast::StatementList{}, ast::DecorationList{}); ValidatorImpl& v = Build(); @@ -95,7 +95,7 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_Pass) { ast::StatementList{ create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -111,7 +111,7 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_fail) { create(Source{Source::Location{12, 34}}, Expr(2)), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); ValidatorImpl& v = Build(); @@ -129,7 +129,7 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementTypeF32_fail) { create(Source{Source::Location{12, 34}}, Expr(2)), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); ValidatorImpl& v = Build(); @@ -147,13 +147,13 @@ TEST_F(ValidateFunctionTest, FunctionNamesMustBeUnique_fail) { ast::StatementList{ create(Expr(2)), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); Func(Source{Source::Location{12, 34}}, "func", ast::VariableList{}, ty.i32(), ast::StatementList{ create(Expr(2)), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); ValidatorImpl& v = Build(); @@ -170,7 +170,7 @@ TEST_F(ValidateFunctionTest, PipelineStage_MustBeUnique_Fail) { ast::StatementList{ create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), create(ast::PipelineStage::kFragment), }); @@ -191,7 +191,7 @@ TEST_F(ValidateFunctionTest, OnePipelineStageFunctionMustBePresent_Pass) { ast::StatementList{ create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -206,7 +206,7 @@ TEST_F(ValidateFunctionTest, OnePipelineStageFunctionMustBePresent_Fail) { ast::StatementList{ create(), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); ValidatorImpl& v = Build(); diff --git a/src/validator/validator_impl.cc b/src/validator/validator_impl.cc index a75dc9eab71..56f14a7701d 100644 --- a/src/validator/validator_impl.cc +++ b/src/validator/validator_impl.cc @@ -17,10 +17,15 @@ #include #include "src/ast/call_statement.h" +#include "src/ast/constant_id_decoration.h" #include "src/ast/fallthrough_statement.h" #include "src/ast/sint_literal.h" #include "src/ast/stage_decoration.h" +#include "src/ast/stride_decoration.h" +#include "src/ast/struct_block_decoration.h" +#include "src/ast/struct_member_offset_decoration.h" #include "src/ast/uint_literal.h" +#include "src/ast/workgroup_decoration.h" #include "src/semantic/call.h" #include "src/semantic/function.h" #include "src/semantic/variable.h" @@ -108,8 +113,34 @@ bool ValidatorImpl::ValidateConstructedType(const type::Type* type) { program_->Symbols().NameFor(st->symbol()) + "'"); return false; } + + for (auto* deco : r->decorations()) { + if (!deco->Is()) { + add_error(deco->source(), + "decoration is not valid for array types"); + return false; + } + } } } + + for (auto* deco : member->decorations()) { + if (!(deco->Is() || + deco->Is() || + deco->Is())) { + add_error(deco->source(), + "decoration is not valid for structure members"); + return false; + } + } + } + + for (auto* deco : st->impl()->decorations()) { + if (!(deco->Is())) { + add_error(deco->source(), + "decoration is not valid for struct declarations"); + return false; + } } } @@ -141,6 +172,18 @@ bool ValidatorImpl::ValidateGlobalVariable(const ast::Variable* var) { "global constants shouldn't have a storage class"); return false; } + + for (auto* deco : var->decorations()) { + if (!(deco->Is() || + deco->Is() || + deco->Is() || + deco->Is() || + deco->Is())) { + add_error(deco->source(), "decoration is not valid for variables"); + return false; + } + } + variable_stack_.set_global(var->symbol(), var); return true; } @@ -154,6 +197,9 @@ bool ValidatorImpl::ValidateEntryPoint(const ast::FunctionList& funcs) { for (auto* deco : func->decorations()) { if (deco->Is()) { stage_deco_count++; + } else if (!deco->Is()) { + add_error(func->source(), "decoration is not valid for functions"); + return false; } } if (stage_deco_count > 1) { diff --git a/src/validator/validator_test.cc b/src/validator/validator_test.cc index f4c8cefb8e5..491bed4c833 100644 --- a/src/validator/validator_test.cc +++ b/src/validator/validator_test.cc @@ -317,7 +317,7 @@ TEST_F(ValidatorTest, GlobalConstantWithStorageClass_Fail) { AST().AddGlobalVariable(create( Source{Source::Location{12, 34}}, Symbols().Register("global_var"), ast::StorageClass::kInput, ty.f32(), true, nullptr, - ast::VariableDecorationList{})); + ast::DecorationList{})); ValidatorImpl& v = Build(); @@ -350,7 +350,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariableAfter_Fail) { ast::StatementList{ create(lhs, rhs), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex)}); Global("global_var", ty.f32(), ast::StorageClass::kPrivate, Expr(2.1f)); @@ -376,7 +376,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Pass) { Expr("global_var"), Expr(3.14f)), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -553,7 +553,7 @@ TEST_F(ValidatorTest, GlobalVariableFunctionVariableNotUnique_Pass) { ast::StatementList{ create(var), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex)}); Global("a", ty.f32(), ast::StorageClass::kPrivate, Expr(2.1f)); @@ -579,7 +579,7 @@ TEST_F(ValidatorTest, GlobalVariableFunctionVariableNotUnique_Fail) { create(Source{Source::Location{12, 34}}, var), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); ValidatorImpl& v = Build(); @@ -602,7 +602,7 @@ TEST_F(ValidatorTest, RedeclaredIdentifier_Fail) { create(Source{Source::Location{12, 34}}, var_a_float), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); ValidatorImpl& v = Build(); @@ -728,7 +728,7 @@ TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) { var0), create(), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); Func("func1", ast::VariableList{}, ty.void_(), ast::StatementList{ @@ -736,7 +736,7 @@ TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) { var1), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -898,7 +898,7 @@ TEST_F(ValidatorTest, IsStorable_ArrayUnsizedOfNonStorable) { TEST_F(ValidatorTest, IsStorable_Struct_AllMembersStorable) { ast::StructMemberList members{Member("a", ty.i32()), Member("b", ty.f32())}; - auto* s = create(Source{}, members, ast::StructDecorationList{}); + auto* s = create(Source{}, members, ast::DecorationList{}); auto* s_ty = ty.struct_("mystruct", s); ValidatorImpl& v = Build(); @@ -909,7 +909,7 @@ TEST_F(ValidatorTest, IsStorable_Struct_AllMembersStorable) { TEST_F(ValidatorTest, IsStorable_Struct_SomeMembersNonStorable) { auto* ptr_ty = ty.pointer(ast::StorageClass::kPrivate); ast::StructMemberList members{Member("a", ty.i32()), Member("b", ptr_ty)}; - auto* s = create(Source{}, members, ast::StructDecorationList{}); + auto* s = create(Source{}, members, ast::DecorationList{}); auto* s_ty = ty.struct_("mystruct", s); ValidatorImpl& v = Build(); diff --git a/src/validator/validator_type_test.cc b/src/validator/validator_type_test.cc index 455e42fc6eb..da372c69d3d 100644 --- a/src/validator/validator_type_test.cc +++ b/src/validator/validator_type_test.cc @@ -28,7 +28,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsLast_Pass) { // rt: array; // }; - ast::StructDecorationList decos; + ast::DecorationList decos; decos.push_back(create()); auto* st = create(ast::StructMemberList{Member("vf", ty.f32()), @@ -50,7 +50,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsLastNoBlock_Fail) { // rt: array; // }; - ast::StructDecorationList decos; + ast::DecorationList decos; auto* st = create(ast::StructMemberList{Member("vf", ty.f32()), Member("rt", ty.array())}, @@ -74,7 +74,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsNotLast_Fail) { // vf: f32; // }; - ast::StructDecorationList decos; + ast::DecorationList decos; decos.push_back(create()); SetSource(Source::Location{12, 34}); @@ -105,7 +105,7 @@ TEST_F(ValidatorTypeTest, AliasRuntimeArrayIsNotLast_Fail) { auto* alias = ty.alias("RTArr", ty.array()); - ast::StructDecorationList decos; + ast::DecorationList decos; decos.push_back(create()); auto* st = create( ast::StructMemberList{Member("b", alias), Member("a", ty.u32())}, decos); @@ -131,7 +131,7 @@ TEST_F(ValidatorTypeTest, AliasRuntimeArrayIsLast_Pass) { auto* alias = ty.alias("RTArr", ty.array()); - ast::StructDecorationList decos; + ast::DecorationList decos; decos.push_back(create()); auto* st = create( ast::StructMemberList{Member("a", ty.u32()), Member("b", alias)}, decos); @@ -155,7 +155,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayInFunction_Fail) { create(Source{Source::Location{12, 34}}, var), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -178,13 +178,13 @@ TEST_F(ValidatorTypeTest, RuntimeArrayAsParameter_Fail) { ast::StatementList{ create(), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); Func("main", ast::VariableList{}, ty.void_(), ast::StatementList{ create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); diff --git a/src/writer/hlsl/generator_impl.cc b/src/writer/hlsl/generator_impl.cc index a8cf820dbc7..cf5d62aac12 100644 --- a/src/writer/hlsl/generator_impl.cc +++ b/src/writer/hlsl/generator_impl.cc @@ -1520,8 +1520,8 @@ bool GeneratorImpl::EmitEntryPointData( std::ostream& out, ast::Function* func, std::unordered_set& emitted_globals) { - std::vector> in_variables; - std::vector> outvariables; + std::vector> in_variables; + std::vector> outvariables; auto* func_sem = builder_.Sem().Get(func); auto func_sym = func->symbol(); @@ -2525,7 +2525,7 @@ bool GeneratorImpl::EmitStructType(std::ostream& out, const type::Struct* str, const std::string& name) { // TODO(dsinclair): Block decoration? - // if (str->impl()->decoration() != ast::StructDecoration::kNone) { + // if (str->impl()->decoration() != ast::Decoration::kNone) { // } out << "struct " << name << " {" << std::endl; diff --git a/src/writer/hlsl/generator_impl_alias_type_test.cc b/src/writer/hlsl/generator_impl_alias_type_test.cc index 2b1da05c013..a11551d3dee 100644 --- a/src/writer/hlsl/generator_impl_alias_type_test.cc +++ b/src/writer/hlsl/generator_impl_alias_type_test.cc @@ -45,7 +45,7 @@ TEST_F(HlslGeneratorImplTest_Alias, EmitAlias_Struct) { auto* str = create( ast::StructMemberList{Member("a", ty.f32()), Member("b", ty.i32(), {MemberOffset(4)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("A", str); auto* alias = ty.alias("B", s); diff --git a/src/writer/hlsl/generator_impl_binary_test.cc b/src/writer/hlsl/generator_impl_binary_test.cc index a64a7448efe..4b748b934a2 100644 --- a/src/writer/hlsl/generator_impl_binary_test.cc +++ b/src/writer/hlsl/generator_impl_binary_test.cc @@ -457,7 +457,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Call_WithLogical) { // foo(a && b, c || d, (a || c) && (b || d)) Func("foo", ast::VariableList{}, ty.void_(), ast::StatementList{}, - ast::FunctionDecorationList{}); + ast::DecorationList{}); Global("a", ty.bool_(), ast::StorageClass::kNone); Global("b", ty.bool_(), ast::StorageClass::kNone); Global("c", ty.bool_(), ast::StorageClass::kNone); diff --git a/src/writer/hlsl/generator_impl_call_test.cc b/src/writer/hlsl/generator_impl_call_test.cc index aa61e471144..ea505ee470f 100644 --- a/src/writer/hlsl/generator_impl_call_test.cc +++ b/src/writer/hlsl/generator_impl_call_test.cc @@ -24,7 +24,7 @@ using HlslGeneratorImplTest_Call = TestHelper; TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithoutParams) { Func("my_func", ast::VariableList{}, ty.void_(), ast::StatementList{}, - ast::FunctionDecorationList{}); + ast::DecorationList{}); auto* call = Call("my_func"); WrapInFunction(call); @@ -37,7 +37,7 @@ TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithoutParams) { TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithParams) { Func("my_func", ast::VariableList{}, ty.void_(), ast::StatementList{}, - ast::FunctionDecorationList{}); + ast::DecorationList{}); Global("param1", ty.f32(), ast::StorageClass::kNone); Global("param2", ty.f32(), ast::StorageClass::kNone); @@ -52,7 +52,7 @@ TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithParams) { TEST_F(HlslGeneratorImplTest_Call, EmitStatement_Call) { Func("my_func", ast::VariableList{}, ty.void_(), ast::StatementList{}, - ast::FunctionDecorationList{}); + ast::DecorationList{}); Global("param1", ty.f32(), ast::StorageClass::kNone); Global("param2", ty.f32(), ast::StorageClass::kNone); 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 df333171f24..f1c3bb3c1e4 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 @@ -33,12 +33,12 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, // }; Global("foo", ty.f32(), ast::StorageClass::kInput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(0), }); Global("bar", ty.i32(), ast::StorageClass::kInput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(1), }); @@ -47,7 +47,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, create(Expr("foo"), Expr("foo")), create(Expr("bar"), Expr("bar")), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -76,12 +76,12 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, // }; Global("foo", ty.f32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(0), }); Global("bar", ty.i32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(1), }); @@ -90,7 +90,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, create(Expr("foo"), Expr("foo")), create(Expr("bar"), Expr("bar")), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -119,12 +119,12 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, // }; Global("foo", ty.f32(), ast::StorageClass::kInput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(0), }); Global("bar", ty.i32(), ast::StorageClass::kInput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(1), }); @@ -133,7 +133,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, create(Expr("foo"), Expr("foo")), create(Expr("bar"), Expr("bar")), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -162,12 +162,12 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, // }; Global("foo", ty.f32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(0), }); Global("bar", ty.i32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(1), }); @@ -176,7 +176,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, create(Expr("foo"), Expr("foo")), create(Expr("bar"), Expr("bar")), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -202,12 +202,12 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, // -> Error, not allowed Global("foo", ty.f32(), ast::StorageClass::kInput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(0), }); Global("bar", ty.i32(), ast::StorageClass::kInput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(1), }); @@ -216,7 +216,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, create(Expr("foo"), Expr("foo")), create(Expr("bar"), Expr("bar")), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kCompute), }); @@ -238,12 +238,12 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, // -> Error not allowed Global("foo", ty.f32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(0), }); Global("bar", ty.i32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(1), }); @@ -252,7 +252,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, create(Expr("foo"), Expr("foo")), create(Expr("bar"), Expr("bar")), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kCompute), }); @@ -280,12 +280,12 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, // }; Global("coord", ty.vec4(), ast::StorageClass::kInput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(ast::Builtin::kFragCoord), }); Global("depth", ty.f32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(ast::Builtin::kFragDepth), }); @@ -294,7 +294,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, create(Expr("depth"), MemberAccessor("coord", "x")), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); diff --git a/src/writer/hlsl/generator_impl_function_test.cc b/src/writer/hlsl/generator_impl_function_test.cc index 3937442e3a4..c9858583881 100644 --- a/src/writer/hlsl/generator_impl_function_test.cc +++ b/src/writer/hlsl/generator_impl_function_test.cc @@ -31,7 +31,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function) { ast::StatementList{ create(), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); GeneratorImpl& gen = Build(); @@ -50,7 +50,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_Name_Collision) { ast::StatementList{ create(), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); GeneratorImpl& gen = Build(); @@ -72,7 +72,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithParams) { ast::StatementList{ create(), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); GeneratorImpl& gen = Build(); @@ -87,10 +87,10 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithParams) { } TEST_F(HlslGeneratorImplTest_Function, - Emit_FunctionDecoration_EntryPoint_NoReturn_Void) { + Emit_Decoration_EntryPoint_NoReturn_Void) { Func("main", ast::VariableList{}, ty.void_(), ast::StatementList{/* no explicit return */}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -105,14 +105,14 @@ TEST_F(HlslGeneratorImplTest_Function, } TEST_F(HlslGeneratorImplTest_Function, - Emit_FunctionDecoration_EntryPoint_NoReturn_InOut) { + Emit_Decoration_EntryPoint_NoReturn_InOut) { Global("foo", ty.f32(), ast::StorageClass::kInput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(0), }); Global("bar", ty.f32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(1), }); @@ -120,7 +120,7 @@ TEST_F(HlslGeneratorImplTest_Function, ast::StatementList{ create(Expr("bar"), Expr("foo")), /* no explicit return */}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -145,14 +145,14 @@ main_out main(main_in tint_in) { } TEST_F(HlslGeneratorImplTest_Function, - Emit_FunctionDecoration_EntryPoint_WithInOutVars) { + Emit_Decoration_EntryPoint_WithInOutVars) { Global("foo", ty.f32(), ast::StorageClass::kInput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(0), }); Global("bar", ty.f32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(1), }); @@ -161,7 +161,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(Expr("bar"), Expr("foo")), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -186,14 +186,14 @@ frag_main_out frag_main(frag_main_in tint_in) { } TEST_F(HlslGeneratorImplTest_Function, - Emit_FunctionDecoration_EntryPoint_WithInOut_Builtins) { + Emit_Decoration_EntryPoint_WithInOut_Builtins) { Global("coord", ty.vec4(), ast::StorageClass::kInput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(ast::Builtin::kFragCoord), }); Global("depth", ty.f32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(ast::Builtin::kFragDepth), }); @@ -203,7 +203,7 @@ TEST_F(HlslGeneratorImplTest_Function, MemberAccessor("coord", "x")), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -228,9 +228,9 @@ frag_main_out frag_main(frag_main_in tint_in) { } TEST_F(HlslGeneratorImplTest_Function, - Emit_FunctionDecoration_EntryPoint_With_Uniform) { + Emit_Decoration_EntryPoint_With_Uniform) { Global("coord", ty.vec4(), ast::StorageClass::kUniform, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(0), create(1), }); @@ -243,7 +243,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(var), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -263,15 +263,15 @@ void frag_main() { } TEST_F(HlslGeneratorImplTest_Function, - Emit_FunctionDecoration_EntryPoint_With_UniformStruct) { + Emit_Decoration_EntryPoint_With_UniformStruct) { auto* str = create( ast::StructMemberList{Member("coord", ty.vec4())}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("Uniforms", str); Global("uniforms", s, ast::StorageClass::kUniform, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(0), create(1), }); @@ -287,7 +287,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(var), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -309,17 +309,17 @@ void frag_main() { } TEST_F(HlslGeneratorImplTest_Function, - Emit_FunctionDecoration_EntryPoint_With_RW_StorageBuffer_Read) { + Emit_Decoration_EntryPoint_With_RW_StorageBuffer_Read) { auto* str = create( ast::StructMemberList{Member("a", ty.i32(), {MemberOffset(0)}), Member("b", ty.f32(), {MemberOffset(4)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("Data", str); type::AccessControl ac(ast::AccessControl::kReadWrite, s); Global("coord", &ac, ast::StorageClass::kStorage, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(0), create(1), }); @@ -332,7 +332,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(var), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -350,17 +350,17 @@ void frag_main() { } TEST_F(HlslGeneratorImplTest_Function, - Emit_FunctionDecoration_EntryPoint_With_RO_StorageBuffer_Read) { + Emit_Decoration_EntryPoint_With_RO_StorageBuffer_Read) { auto* str = create( ast::StructMemberList{Member("a", ty.i32(), {MemberOffset(0)}), Member("b", ty.f32(), {MemberOffset(4)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("Data", str); type::AccessControl ac(ast::AccessControl::kReadOnly, s); Global("coord", &ac, ast::StorageClass::kStorage, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(0), create(1), }); @@ -373,7 +373,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(var), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -391,17 +391,17 @@ void frag_main() { } TEST_F(HlslGeneratorImplTest_Function, - Emit_FunctionDecoration_EntryPoint_With_WO_StorageBuffer_Store) { + Emit_Decoration_EntryPoint_With_WO_StorageBuffer_Store) { auto* str = create( ast::StructMemberList{Member("a", ty.i32(), {MemberOffset(0)}), Member("b", ty.f32(), {MemberOffset(4)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("Data", str); type::AccessControl ac(ast::AccessControl::kWriteOnly, s); Global("coord", &ac, ast::StorageClass::kStorage, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(0), create(1), }); @@ -412,7 +412,7 @@ TEST_F(HlslGeneratorImplTest_Function, Expr(2.0f)), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -430,17 +430,17 @@ void frag_main() { } TEST_F(HlslGeneratorImplTest_Function, - Emit_FunctionDecoration_EntryPoint_With_StorageBuffer_Store) { + Emit_Decoration_EntryPoint_With_StorageBuffer_Store) { auto* str = create( ast::StructMemberList{Member("a", ty.i32(), {MemberOffset(0)}), Member("b", ty.f32(), {MemberOffset(4)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("Data", str); type::AccessControl ac(ast::AccessControl::kReadWrite, s); Global("coord", &ac, ast::StorageClass::kStorage, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(0), create(1), }); @@ -451,7 +451,7 @@ TEST_F(HlslGeneratorImplTest_Function, Expr(2.0f)), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -470,19 +470,19 @@ void frag_main() { TEST_F( HlslGeneratorImplTest_Function, - Emit_FunctionDecoration_Called_By_EntryPoints_WithLocationGlobals_And_Params) { // NOLINT + Emit_Decoration_Called_By_EntryPoints_WithLocationGlobals_And_Params) { // NOLINT Global("foo", ty.f32(), ast::StorageClass::kInput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(0), }); Global("bar", ty.f32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(1), }); Global("val", ty.f32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(0), }); @@ -494,7 +494,7 @@ TEST_F( create(Expr("val"), Expr("param")), create(Expr("foo")), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); Func( "ep_1", ast::VariableList{}, ty.void_(), @@ -502,7 +502,7 @@ TEST_F( create(Expr("bar"), Call("sub_func", 1.0f)), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -534,9 +534,9 @@ ep_1_out ep_1(ep_1_in tint_in) { } TEST_F(HlslGeneratorImplTest_Function, - Emit_FunctionDecoration_Called_By_EntryPoints_NoUsedGlobals) { + Emit_Decoration_Called_By_EntryPoints_NoUsedGlobals) { Global("depth", ty.f32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(ast::Builtin::kFragDepth), }); @@ -546,7 +546,7 @@ TEST_F(HlslGeneratorImplTest_Function, ast::StatementList{ create(Expr("param")), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); Func("ep_1", ast::VariableList{}, ty.void_(), ast::StatementList{ @@ -554,7 +554,7 @@ TEST_F(HlslGeneratorImplTest_Function, Call("sub_func", 1.0f)), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -580,14 +580,14 @@ ep_1_out ep_1() { TEST_F( HlslGeneratorImplTest_Function, - Emit_FunctionDecoration_Called_By_EntryPoints_WithBuiltinGlobals_And_Params) { // NOLINT + Emit_Decoration_Called_By_EntryPoints_WithBuiltinGlobals_And_Params) { // NOLINT Global("coord", ty.vec4(), ast::StorageClass::kInput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(ast::Builtin::kFragCoord), }); Global("depth", ty.f32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(ast::Builtin::kFragDepth), }); @@ -599,7 +599,7 @@ TEST_F( MemberAccessor("coord", "x")), create(Expr("param")), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); Func("ep_1", ast::VariableList{}, ty.void_(), ast::StatementList{ @@ -607,7 +607,7 @@ TEST_F( Call("sub_func", 1.0f)), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -637,9 +637,9 @@ ep_1_out ep_1(ep_1_in tint_in) { } TEST_F(HlslGeneratorImplTest_Function, - Emit_FunctionDecoration_Called_By_EntryPoint_With_Uniform) { + Emit_Decoration_Called_By_EntryPoint_With_Uniform) { Global("coord", ty.vec4(), ast::StorageClass::kUniform, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(0), create(1), }); @@ -650,7 +650,7 @@ TEST_F(HlslGeneratorImplTest_Function, ast::StatementList{ create(MemberAccessor("coord", "x")), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); auto* var = Var("v", ty.f32(), ast::StorageClass::kFunction, Call("sub_func", 1.0f)); @@ -660,7 +660,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(var), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -684,10 +684,10 @@ void frag_main() { } TEST_F(HlslGeneratorImplTest_Function, - Emit_FunctionDecoration_Called_By_EntryPoint_With_StorageBuffer) { + Emit_Decoration_Called_By_EntryPoint_With_StorageBuffer) { type::AccessControl ac(ast::AccessControl::kReadWrite, ty.vec4()); Global("coord", &ac, ast::StorageClass::kStorage, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(0), create(1), }); @@ -698,7 +698,7 @@ TEST_F(HlslGeneratorImplTest_Function, ast::StatementList{ create(MemberAccessor("coord", "x")), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); auto* var = Var("v", ty.f32(), ast::StorageClass::kFunction, Call("sub_func", 1.0f)); @@ -708,7 +708,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(var), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -730,9 +730,9 @@ void frag_main() { } TEST_F(HlslGeneratorImplTest_Function, - Emit_FunctionDecoration_EntryPoints_WithGlobal_Nested_Return) { + Emit_Decoration_EntryPoints_WithGlobal_Nested_Return) { Global("bar", ty.f32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(1), }); @@ -749,7 +749,7 @@ TEST_F(HlslGeneratorImplTest_Function, list, ast::ElseStatementList{}), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -773,9 +773,9 @@ ep_1_out ep_1() { } TEST_F(HlslGeneratorImplTest_Function, - Emit_FunctionDecoration_EntryPoint_WithNameCollision) { + Emit_Decoration_EntryPoint_WithNameCollision) { Func("GeometryShader", ast::VariableList{}, ty.void_(), ast::StatementList{}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -789,13 +789,12 @@ TEST_F(HlslGeneratorImplTest_Function, )"); } -TEST_F(HlslGeneratorImplTest_Function, - Emit_FunctionDecoration_EntryPoint_Compute) { +TEST_F(HlslGeneratorImplTest_Function, Emit_Decoration_EntryPoint_Compute) { Func("main", ast::VariableList{}, ty.void_(), ast::StatementList{ create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kCompute), }); @@ -811,12 +810,12 @@ void main() { } TEST_F(HlslGeneratorImplTest_Function, - Emit_FunctionDecoration_EntryPoint_Compute_WithWorkgroup) { + Emit_Decoration_EntryPoint_Compute_WithWorkgroup) { Func("main", ast::VariableList{}, ty.void_(), ast::StatementList{ create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kCompute), create(2u, 4u, 6u), }); @@ -840,7 +839,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithArrayParams) { ast::StatementList{ create(), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); GeneratorImpl& gen = Build(); @@ -874,7 +873,7 @@ TEST_F(HlslGeneratorImplTest_Function, auto* str = create( ast::StructMemberList{Member("d", ty.f32(), {MemberOffset(0)})}, - ast::StructDecorationList{create()}); + ast::DecorationList{create()}); auto* s = ty.struct_("Data", str); AST().AddConstructedType(s); @@ -882,7 +881,7 @@ TEST_F(HlslGeneratorImplTest_Function, type::AccessControl ac(ast::AccessControl::kReadWrite, s); Global("data", &ac, ast::StorageClass::kStorage, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(0), create(0), }); @@ -896,7 +895,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(var), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kCompute), }); } @@ -910,7 +909,7 @@ TEST_F(HlslGeneratorImplTest_Function, create(var), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kCompute), }); } diff --git a/src/writer/hlsl/generator_impl_intrinsic_texture_test.cc b/src/writer/hlsl/generator_impl_intrinsic_texture_test.cc index d2f8dda2023..055ec812f75 100644 --- a/src/writer/hlsl/generator_impl_intrinsic_texture_test.cc +++ b/src/writer/hlsl/generator_impl_intrinsic_texture_test.cc @@ -387,7 +387,7 @@ TEST_P(HlslGeneratorIntrinsicTextureTest, Call) { ast::StatementList{ create(call), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); diff --git a/src/writer/hlsl/generator_impl_member_accessor_test.cc b/src/writer/hlsl/generator_impl_member_accessor_test.cc index 5c42ab2b2a6..ffd588ca089 100644 --- a/src/writer/hlsl/generator_impl_member_accessor_test.cc +++ b/src/writer/hlsl/generator_impl_member_accessor_test.cc @@ -24,7 +24,7 @@ using HlslGeneratorImplTest_MemberAccessor = TestHelper; TEST_F(HlslGeneratorImplTest_MemberAccessor, EmitExpression_MemberAccessor) { auto* strct = create( ast::StructMemberList{Member("mem", ty.f32(), {MemberOffset(0)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("Str", strct); auto* str_var = Global("str", s, ast::StorageClass::kPrivate); @@ -54,7 +54,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create( ast::StructMemberList{Member("a", ty.i32(), {MemberOffset(0)}), Member("b", ty.f32(), {MemberOffset(4)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("Data", str); auto* coord_var = Global("data", s, ast::StorageClass::kStorage); @@ -84,7 +84,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create( ast::StructMemberList{Member("a", ty.i32(), {MemberOffset(0)}), Member("b", ty.f32(), {MemberOffset(4)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("Data", str); auto* coord_var = Global("data", s, ast::StorageClass::kStorage); @@ -116,7 +116,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create( ast::StructMemberList{Member("z", ty.i32(), {MemberOffset(0)}), Member("a", ty.mat2x3(), {MemberOffset(4)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("Data", str); auto* b_var = Global("b", ty.mat2x3(), ast::StorageClass::kPrivate); @@ -157,7 +157,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create( ast::StructMemberList{Member("z", ty.i32(), {MemberOffset(0)}), Member("a", ty.mat2x3(), {MemberOffset(4)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("Data", str); auto* coord_var = Global("data", s, ast::StorageClass::kStorage); @@ -196,7 +196,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create( ast::StructMemberList{Member("z", ty.i32(), {MemberOffset(0)}), Member("a", ty.mat3x2(), {MemberOffset(4)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("Data", str); auto* coord_var = Global("data", s, ast::StorageClass::kStorage); @@ -234,7 +234,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, Member("z", ty.i32(), {MemberOffset(0)}), Member("a", ty.mat2x3(), {MemberOffset(4)}), }, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("Data", str); auto* coord_var = Global("data", s, ast::StorageClass::kStorage); @@ -265,7 +265,7 @@ TEST_F( auto* str = create( ast::StructMemberList{Member("a", ty.mat3x3(), {MemberOffset(0)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("Data", str); auto* coord_var = Global("data", s, ast::StorageClass::kStorage); @@ -297,7 +297,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create( ast::StructMemberList{Member("z", ty.i32(), {MemberOffset(0)}), Member("a", ty.mat4x3(), {MemberOffset(16)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("Data", str); auto* coord_var = Global("data", s, ast::StorageClass::kStorage); @@ -324,13 +324,13 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, // // -> asint(data.Load((2 * 4)); type::Array ary(ty.i32(), 5, - ast::ArrayDecorationList{ + ast::DecorationList{ create(4), }); auto* str = create( ast::StructMemberList{Member("a", &ary, {MemberOffset(0)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("Data", str); auto* coord_var = Global("data", s, ast::StorageClass::kStorage); @@ -355,13 +355,13 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, // // -> asint(data.Load((4 * ((2 + 4) - 3))); type::Array ary(ty.i32(), 5, - ast::ArrayDecorationList{ + ast::DecorationList{ create(4), }); auto* str = create( ast::StructMemberList{Member("a", &ary, {MemberOffset(0)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("Data", str); auto* coord_var = Global("data", s, ast::StorageClass::kStorage); @@ -391,7 +391,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create( ast::StructMemberList{Member("a", ty.i32(), {MemberOffset(0)}), Member("b", ty.f32(), {MemberOffset(4)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("Data", str); auto* coord_var = Global("data", s, ast::StorageClass::kStorage); @@ -421,13 +421,13 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, // -> data.Store((2 * 4), asuint(2.3f)); type::Array ary(ty.i32(), 5, - ast::ArrayDecorationList{ + ast::DecorationList{ create(4), }); auto* str = create( ast::StructMemberList{Member("a", &ary, {MemberOffset(0)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("Data", str); auto* coord_var = Global("data", s, ast::StorageClass::kStorage); @@ -460,7 +460,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create( ast::StructMemberList{Member("a", ty.i32(), {MemberOffset(0)}), Member("b", ty.f32(), {MemberOffset(4)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("Data", str); auto* coord_var = Global("data", s, ast::StorageClass::kStorage); @@ -493,7 +493,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create( ast::StructMemberList{Member("a", ty.vec3(), {MemberOffset(0)}), Member("b", ty.vec3(), {MemberOffset(16)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("Data", str); auto* coord_var = Global("data", s, ast::StorageClass::kStorage); @@ -523,7 +523,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create( ast::StructMemberList{Member("a", ty.vec3(), {MemberOffset(0)}), Member("b", ty.vec3(), {MemberOffset(16)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("Data", str); auto* coord_var = Global("data", s, ast::StorageClass::kStorage); @@ -565,17 +565,17 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, Member("a", ty.vec3(), {MemberOffset(0)}), Member("b", ty.vec3(), {MemberOffset(16)}), }, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* data = ty.struct_("Data", data_str); type::Array ary(data, 4, - ast::ArrayDecorationList{ + ast::DecorationList{ create(32), }); auto* pre_str = create( ast::StructMemberList{Member("c", &ary, {MemberOffset(0)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* pre_struct = ty.struct_("Pre", pre_str); auto* coord_var = Global("data", pre_struct, ast::StorageClass::kStorage); @@ -612,15 +612,15 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, Member("a", ty.vec3(), {MemberOffset(0)}), Member("b", ty.vec3(), {MemberOffset(16)}), }, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* data = ty.struct_("Data", data_str); type::Array ary(data, 4, - ast::ArrayDecorationList{create(32)}); + ast::DecorationList{create(32)}); auto* pre_str = create( ast::StructMemberList{Member("c", &ary, {MemberOffset(0)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* pre_struct = ty.struct_("Pre", pre_str); auto* coord_var = Global("data", pre_struct, ast::StorageClass::kStorage); @@ -659,17 +659,17 @@ TEST_F( Member("a", ty.vec3(), {MemberOffset(0)}), Member("b", ty.vec3(), {MemberOffset(16)}), }, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* data = ty.struct_("Data", data_str); type::Array ary(data, 4, - ast::ArrayDecorationList{ + ast::DecorationList{ create(32), }); auto* pre_str = create( ast::StructMemberList{Member("c", &ary, {MemberOffset(0)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* pre_struct = ty.struct_("Pre", pre_str); auto* coord_var = Global("data", pre_struct, ast::StorageClass::kStorage); @@ -707,17 +707,17 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, Member("a", ty.vec3(), {MemberOffset(0)}), Member("b", ty.vec3(), {MemberOffset(16)}), }, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* data = ty.struct_("Data", data_str); type::Array ary(data, 4, - ast::ArrayDecorationList{ + ast::DecorationList{ create(32), }); auto* pre_str = create( ast::StructMemberList{Member("c", &ary, {MemberOffset(0)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* pre_struct = ty.struct_("Pre", pre_str); auto* coord_var = Global("data", pre_struct, ast::StorageClass::kStorage); @@ -755,17 +755,17 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, Member("a", ty.vec3(), {MemberOffset(0)}), Member("b", ty.vec3(), {MemberOffset(16)}), }, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* data = ty.struct_("Data", data_str); type::Array ary(data, 4, - ast::ArrayDecorationList{ + ast::DecorationList{ create(32), }); auto* pre_str = create( ast::StructMemberList{Member("c", &ary, {MemberOffset(0)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* pre_struct = ty.struct_("Pre", pre_str); auto* coord_var = Global("data", pre_struct, ast::StorageClass::kStorage); @@ -808,17 +808,17 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, Member("a", ty.vec3(), {MemberOffset(0)}), Member("b", ty.vec3(), {MemberOffset(16)}), }, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* data = ty.struct_("Data", data_str); type::Array ary(data, 4, - ast::ArrayDecorationList{ + ast::DecorationList{ create(32), }); auto* pre_str = create( ast::StructMemberList{Member("c", &ary, {MemberOffset(0)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* pre_struct = ty.struct_("Pre", pre_str); auto* coord_var = Global("data", pre_struct, ast::StorageClass::kStorage); diff --git a/src/writer/hlsl/generator_impl_module_constant_test.cc b/src/writer/hlsl/generator_impl_module_constant_test.cc index e25125a3d41..b3a197f5d72 100644 --- a/src/writer/hlsl/generator_impl_module_constant_test.cc +++ b/src/writer/hlsl/generator_impl_module_constant_test.cc @@ -33,7 +33,7 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_ModuleConstant) { TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_SpecConstant) { auto* var = Const("pos", ty.f32(), Expr(3.0f), - ast::VariableDecorationList{ + ast::DecorationList{ create(23), }); @@ -50,7 +50,7 @@ static const float pos = WGSL_SPEC_CONSTANT_23; TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_SpecConstant_NoConstructor) { auto* var = Const("pos", ty.f32(), nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(23), }); diff --git a/src/writer/hlsl/generator_impl_sanitizer_test.cc b/src/writer/hlsl/generator_impl_sanitizer_test.cc index d10d599e695..53b7cd1d73e 100644 --- a/src/writer/hlsl/generator_impl_sanitizer_test.cc +++ b/src/writer/hlsl/generator_impl_sanitizer_test.cc @@ -32,7 +32,7 @@ TEST_F(HlslSanitizerTest, PromoteArrayInitializerToConstVar) { ast::StatementList{ create(pos), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); diff --git a/src/writer/hlsl/generator_impl_test.cc b/src/writer/hlsl/generator_impl_test.cc index 577d40ebf7f..f800f0ec8f6 100644 --- a/src/writer/hlsl/generator_impl_test.cc +++ b/src/writer/hlsl/generator_impl_test.cc @@ -23,7 +23,7 @@ using HlslGeneratorImplTest = TestHelper; TEST_F(HlslGeneratorImplTest, Generate) { Func("my_func", ast::VariableList{}, ty.void_(), ast::StatementList{}, - ast::FunctionDecorationList{}); + ast::DecorationList{}); GeneratorImpl& gen = Build(); diff --git a/src/writer/hlsl/generator_impl_type_test.cc b/src/writer/hlsl/generator_impl_type_test.cc index bcb58e237ca..23a9ef795f1 100644 --- a/src/writer/hlsl/generator_impl_type_test.cc +++ b/src/writer/hlsl/generator_impl_type_test.cc @@ -170,7 +170,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_StructDecl) { auto* str = create( ast::StructMemberList{Member("a", ty.i32()), Member("b", ty.f32(), {MemberOffset(4)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("S", str); @@ -188,7 +188,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct) { auto* str = create( ast::StructMemberList{Member("a", ty.i32()), Member("b", ty.f32(), {MemberOffset(4)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("S", str); @@ -203,7 +203,7 @@ TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_Struct_InjectPadding) { ast::StructMemberList{Member("a", ty.i32(), {MemberOffset(4)}), Member("b", ty.f32(), {MemberOffset(32)}), Member("c", ty.f32(), {MemberOffset(128)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("S", str); @@ -224,7 +224,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct_NameCollision) { auto* str = create(ast::StructMemberList{Member("double", ty.i32()), Member("float", ty.f32())}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("S", str); @@ -240,7 +240,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct_NameCollision) { // TODO(dsinclair): How to translate [[block]] TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_Struct_WithDecoration) { - ast::StructDecorationList decos; + ast::DecorationList decos; decos.push_back(create()); auto* str = create( diff --git a/src/writer/msl/generator_impl.cc b/src/writer/msl/generator_impl.cc index 309cccb0130..c144b8924bf 100644 --- a/src/writer/msl/generator_impl.cc +++ b/src/writer/msl/generator_impl.cc @@ -1040,8 +1040,7 @@ bool GeneratorImpl::EmitEntryPointData(ast::Function* func) { auto* func_sem = program_->Sem().Get(func); std::vector> in_locations; - std::vector> - out_variables; + std::vector> out_variables; for (auto data : func_sem->ReferencedLocationVariables()) { auto* var = data.first; @@ -2028,7 +2027,7 @@ bool GeneratorImpl::EmitType(type::Type* type, const std::string& name) { bool GeneratorImpl::EmitStructType(const type::Struct* str) { // TODO(dsinclair): Block decoration? - // if (str->impl()->decoration() != ast::StructDecoration::kNone) { + // if (str->impl()->decoration() != ast::Decoration::kNone) { // } out_ << "struct " << program_->Symbols().NameFor(str->symbol()) << " {" << std::endl; diff --git a/src/writer/msl/generator_impl_alias_type_test.cc b/src/writer/msl/generator_impl_alias_type_test.cc index b66fbb7b780..d663ba924da 100644 --- a/src/writer/msl/generator_impl_alias_type_test.cc +++ b/src/writer/msl/generator_impl_alias_type_test.cc @@ -35,7 +35,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructedType_Struct) { auto* str = create( ast::StructMemberList{Member("a", ty.f32()), Member("b", ty.i32(), {MemberOffset(4)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("a", str); @@ -53,7 +53,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructedType_AliasStructIdent) { auto* str = create( ast::StructMemberList{Member("a", ty.f32()), Member("b", ty.i32(), {MemberOffset(4)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("b", str); auto* alias = ty.alias("a", s); diff --git a/src/writer/msl/generator_impl_call_test.cc b/src/writer/msl/generator_impl_call_test.cc index 34a313d75fb..03780ded4e5 100644 --- a/src/writer/msl/generator_impl_call_test.cc +++ b/src/writer/msl/generator_impl_call_test.cc @@ -24,7 +24,7 @@ using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithoutParams) { Func("my_func", ast::VariableList{}, ty.void_(), ast::StatementList{}, - ast::FunctionDecorationList{}); + ast::DecorationList{}); auto* call = Call("my_func"); WrapInFunction(call); @@ -37,7 +37,7 @@ TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithoutParams) { TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithParams) { Func("my_func", ast::VariableList{}, ty.void_(), ast::StatementList{}, - ast::FunctionDecorationList{}); + ast::DecorationList{}); Global("param1", ty.f32(), ast::StorageClass::kNone); Global("param2", ty.f32(), ast::StorageClass::kNone); @@ -52,7 +52,7 @@ TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithParams) { TEST_F(MslGeneratorImplTest, EmitStatement_Call) { Func("my_func", ast::VariableList{}, ty.void_(), ast::StatementList{}, - ast::FunctionDecorationList{}); + ast::DecorationList{}); Global("param1", ty.f32(), ast::StorageClass::kNone); Global("param2", ty.f32(), ast::StorageClass::kNone); diff --git a/src/writer/msl/generator_impl_constructor_test.cc b/src/writer/msl/generator_impl_constructor_test.cc index 8a73c1ca311..04bb0ad996f 100644 --- a/src/writer/msl/generator_impl_constructor_test.cc +++ b/src/writer/msl/generator_impl_constructor_test.cc @@ -134,7 +134,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Mat) { } TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Array) { - type::Array ary(ty.vec3(), 3, ast::ArrayDecorationList{}); + type::Array ary(ty.vec3(), 3, ast::DecorationList{}); 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 4f9ac96fa34..c31b79b782e 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 @@ -32,10 +32,10 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Vertex_Input) { // }; Global("foo", ty.f32(), ast::StorageClass::kInput, nullptr, - ast::VariableDecorationList{create(0)}); + ast::DecorationList{create(0)}); Global("bar", ty.i32(), ast::StorageClass::kInput, nullptr, - ast::VariableDecorationList{create(1)}); + ast::DecorationList{create(1)}); auto body = ast::StatementList{ create(Expr("foo"), Expr("foo")), @@ -43,7 +43,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Vertex_Input) { }; Func("vtx_main", ast::VariableList{}, ty.f32(), body, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -69,10 +69,10 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Vertex_Output) { // }; Global("foo", ty.f32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{create(0)}); + ast::DecorationList{create(0)}); Global("bar", ty.i32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{create(1)}); + ast::DecorationList{create(1)}); auto body = ast::StatementList{ create(Expr("foo"), Expr("foo")), @@ -80,7 +80,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Vertex_Output) { }; Func("vtx_main", ast::VariableList{}, ty.f32(), body, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -106,10 +106,10 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Fragment_Input) { // }; Global("foo", ty.f32(), ast::StorageClass::kInput, nullptr, - ast::VariableDecorationList{create(0)}); + ast::DecorationList{create(0)}); Global("bar", ty.i32(), ast::StorageClass::kInput, nullptr, - ast::VariableDecorationList{create(1)}); + ast::DecorationList{create(1)}); auto body = ast::StatementList{ create(Expr("foo"), Expr("foo")), @@ -117,7 +117,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Fragment_Input) { }; Func("main", ast::VariableList{}, ty.f32(), body, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -143,10 +143,10 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Fragment_Output) { // }; Global("foo", ty.f32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{create(0)}); + ast::DecorationList{create(0)}); Global("bar", ty.i32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{create(1)}); + ast::DecorationList{create(1)}); auto body = ast::StatementList{ create(Expr("foo"), Expr("foo")), @@ -154,7 +154,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Fragment_Output) { }; Func("main", ast::VariableList{}, ty.f32(), body, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -177,10 +177,10 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Compute_Input) { // -> Error, not allowed Global("foo", ty.f32(), ast::StorageClass::kInput, nullptr, - ast::VariableDecorationList{create(0)}); + ast::DecorationList{create(0)}); Global("bar", ty.i32(), ast::StorageClass::kInput, nullptr, - ast::VariableDecorationList{create(1)}); + ast::DecorationList{create(1)}); auto body = ast::StatementList{ create(Expr("foo"), Expr("foo")), @@ -188,7 +188,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Compute_Input) { }; Func("main", ast::VariableList{}, ty.f32(), body, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kCompute), }); @@ -207,10 +207,10 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Compute_Output) { // -> Error not allowed Global("foo", ty.f32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{create(0)}); + ast::DecorationList{create(0)}); Global("bar", ty.i32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{create(1)}); + ast::DecorationList{create(1)}); auto body = ast::StatementList{ create(Expr("foo"), Expr("foo")), @@ -218,7 +218,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Compute_Output) { }; Func("main", ast::VariableList{}, ty.f32(), body, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kCompute), }); @@ -242,18 +242,18 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Builtins) { // }; Global("coord", ty.vec4(), ast::StorageClass::kInput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(ast::Builtin::kFragCoord)}); Global("depth", ty.f32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(ast::Builtin::kFragDepth)}); auto body = ast::StatementList{create( Expr("depth"), MemberAccessor("coord", "x"))}; Func("main", ast::VariableList{}, ty.void_(), body, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); diff --git a/src/writer/msl/generator_impl_function_test.cc b/src/writer/msl/generator_impl_function_test.cc index d117e1d001b..18486a76e77 100644 --- a/src/writer/msl/generator_impl_function_test.cc +++ b/src/writer/msl/generator_impl_function_test.cc @@ -30,7 +30,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function) { ast::StatementList{ create(), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); GeneratorImpl& gen = Build(); @@ -56,7 +56,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_WithParams) { ast::StatementList{ create(), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); GeneratorImpl& gen = Build(); @@ -73,10 +73,10 @@ using namespace metal; )"); } -TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_NoReturn_Void) { +TEST_F(MslGeneratorImplTest, Emit_Decoration_EntryPoint_NoReturn_Void) { Func("main", ast::VariableList{}, ty.void_(), ast::StatementList{/* no explicit return */}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment)}); GeneratorImpl& gen = Build(); @@ -92,19 +92,18 @@ fragment void main() { )"); } -TEST_F(MslGeneratorImplTest, - Emit_FunctionDecoration_EntryPoint_NoReturn_InOut) { +TEST_F(MslGeneratorImplTest, Emit_Decoration_EntryPoint_NoReturn_InOut) { Global("foo", ty.f32(), ast::StorageClass::kInput, nullptr, - ast::VariableDecorationList{create(0)}); + ast::DecorationList{create(0)}); Global("bar", ty.f32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{create(1)}); + ast::DecorationList{create(1)}); Func("main", ast::VariableList{}, ty.void_(), ast::StatementList{ create(Expr("bar"), Expr("foo")), /* no explicit return */}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment)}); GeneratorImpl& gen = Build(); @@ -130,19 +129,19 @@ fragment main_out main(main_in _tint_in [[stage_in]]) { )"); } -TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_WithInOutVars) { +TEST_F(MslGeneratorImplTest, Emit_Decoration_EntryPoint_WithInOutVars) { Global("foo", ty.f32(), ast::StorageClass::kInput, nullptr, - ast::VariableDecorationList{create(0)}); + ast::DecorationList{create(0)}); Global("bar", ty.f32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{create(1)}); + ast::DecorationList{create(1)}); auto body = ast::StatementList{ create(Expr("bar"), Expr("foo")), create(), }; Func("frag_main", ast::VariableList{}, ty.void_(), body, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment)}); GeneratorImpl& gen = Build(); @@ -168,14 +167,13 @@ fragment frag_main_out frag_main(frag_main_in _tint_in [[stage_in]]) { )"); } -TEST_F(MslGeneratorImplTest, - Emit_FunctionDecoration_EntryPoint_WithInOut_Builtins) { +TEST_F(MslGeneratorImplTest, Emit_Decoration_EntryPoint_WithInOut_Builtins) { Global("coord", ty.vec4(), ast::StorageClass::kInput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(ast::Builtin::kFragCoord)}); Global("depth", ty.f32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(ast::Builtin::kFragDepth)}); auto body = ast::StatementList{ @@ -185,7 +183,7 @@ TEST_F(MslGeneratorImplTest, }; Func("frag_main", ast::VariableList{}, ty.void_(), body, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -208,10 +206,10 @@ fragment frag_main_out frag_main(float4 coord [[position]]) { )"); } -TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_With_Uniform) { +TEST_F(MslGeneratorImplTest, Emit_Decoration_EntryPoint_With_Uniform) { Global("coord", ty.vec4(), ast::StorageClass::kUniform, nullptr, - ast::VariableDecorationList{create(0), - create(1)}); + ast::DecorationList{create(0), + create(1)}); auto* var = Var("v", ty.f32(), ast::StorageClass::kFunction, MemberAccessor("coord", "x")); @@ -221,7 +219,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_With_Uniform) { create(var), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -239,12 +237,11 @@ fragment void frag_main(constant float4& coord [[buffer(0)]]) { )"); } -TEST_F(MslGeneratorImplTest, - Emit_FunctionDecoration_EntryPoint_With_RW_StorageBuffer) { +TEST_F(MslGeneratorImplTest, Emit_Decoration_EntryPoint_With_RW_StorageBuffer) { auto* str = create( ast::StructMemberList{Member("a", ty.i32(), {MemberOffset(0)}), Member("b", ty.f32(), {MemberOffset(4)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("Data", str); type::AccessControl ac(ast::AccessControl::kReadWrite, s); @@ -252,8 +249,8 @@ TEST_F(MslGeneratorImplTest, AST().AddConstructedType(s); Global("coord", &ac, ast::StorageClass::kStorage, nullptr, - ast::VariableDecorationList{create(0), - create(1)}); + ast::DecorationList{create(0), + create(1)}); auto* var = Var("v", ty.f32(), ast::StorageClass::kFunction, MemberAccessor("coord", "b")); @@ -263,7 +260,7 @@ TEST_F(MslGeneratorImplTest, create(var), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -286,20 +283,19 @@ fragment void frag_main(device Data& coord [[buffer(0)]]) { )"); } -TEST_F(MslGeneratorImplTest, - Emit_FunctionDecoration_EntryPoint_With_RO_StorageBuffer) { +TEST_F(MslGeneratorImplTest, Emit_Decoration_EntryPoint_With_RO_StorageBuffer) { auto* str = create( ast::StructMemberList{Member("a", ty.i32(), {MemberOffset(0)}), Member("b", ty.f32(), {MemberOffset(4)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("Data", str); type::AccessControl ac(ast::AccessControl::kReadOnly, s); AST().AddConstructedType(s); Global("coord", &ac, ast::StorageClass::kStorage, nullptr, - ast::VariableDecorationList{create(0), - create(1)}); + ast::DecorationList{create(0), + create(1)}); auto* var = Var("v", ty.f32(), ast::StorageClass::kFunction, MemberAccessor("coord", "b")); @@ -309,7 +305,7 @@ TEST_F(MslGeneratorImplTest, create(var), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -334,15 +330,15 @@ fragment void frag_main(const device Data& coord [[buffer(0)]]) { TEST_F( MslGeneratorImplTest, - Emit_FunctionDecoration_Called_By_EntryPoints_WithLocationGlobals_And_Params) { // NOLINT + Emit_Decoration_Called_By_EntryPoints_WithLocationGlobals_And_Params) { // NOLINT Global("foo", ty.f32(), ast::StorageClass::kInput, nullptr, - ast::VariableDecorationList{create(0)}); + ast::DecorationList{create(0)}); Global("bar", ty.f32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{create(1)}); + ast::DecorationList{create(1)}); Global("val", ty.f32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{create(0)}); + ast::DecorationList{create(0)}); ast::VariableList params; params.push_back(Var("param", ty.f32(), ast::StorageClass::kFunction)); @@ -352,7 +348,7 @@ TEST_F( create(Expr("val"), Expr("param")), create(Expr("foo"))}; - Func("sub_func", params, ty.f32(), body, ast::FunctionDecorationList{}); + Func("sub_func", params, ty.f32(), body, ast::DecorationList{}); body = ast::StatementList{ create(Expr("bar"), Call("sub_func", 1.0f)), @@ -360,7 +356,7 @@ TEST_F( }; Func("ep_1", ast::VariableList{}, ty.void_(), body, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -395,9 +391,9 @@ fragment ep_1_out ep_1(ep_1_in _tint_in [[stage_in]]) { } TEST_F(MslGeneratorImplTest, - Emit_FunctionDecoration_Called_By_EntryPoints_NoUsedGlobals) { + Emit_Decoration_Called_By_EntryPoints_NoUsedGlobals) { Global("depth", ty.f32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(ast::Builtin::kFragDepth)}); ast::VariableList params; @@ -407,7 +403,7 @@ TEST_F(MslGeneratorImplTest, ast::StatementList{ create(Expr("param")), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); auto body = ast::StatementList{ create(Expr("depth"), Call("sub_func", 1.0f)), @@ -415,7 +411,7 @@ TEST_F(MslGeneratorImplTest, }; Func("ep_1", ast::VariableList{}, ty.void_(), body, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -444,13 +440,13 @@ fragment ep_1_out ep_1() { TEST_F( MslGeneratorImplTest, - Emit_FunctionDecoration_Called_By_EntryPoints_WithBuiltinGlobals_And_Params) { // NOLINT + Emit_Decoration_Called_By_EntryPoints_WithBuiltinGlobals_And_Params) { // NOLINT Global("coord", ty.vec4(), ast::StorageClass::kInput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(ast::Builtin::kFragCoord)}); Global("depth", ty.f32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(ast::Builtin::kFragDepth)}); ast::VariableList params; @@ -462,7 +458,7 @@ TEST_F( create(Expr("param")), }; - Func("sub_func", params, ty.f32(), body, ast::FunctionDecorationList{}); + Func("sub_func", params, ty.f32(), body, ast::DecorationList{}); body = ast::StatementList{ create(Expr("depth"), Call("sub_func", 1.0f)), @@ -470,7 +466,7 @@ TEST_F( }; Func("ep_1", ast::VariableList{}, ty.void_(), body, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -499,10 +495,10 @@ fragment ep_1_out ep_1(float4 coord [[position]]) { } TEST_F(MslGeneratorImplTest, - Emit_FunctionDecoration_Called_By_EntryPoint_With_Uniform) { + Emit_Decoration_Called_By_EntryPoint_With_Uniform) { Global("coord", ty.vec4(), ast::StorageClass::kUniform, nullptr, - ast::VariableDecorationList{create(0), - create(1)}); + ast::DecorationList{create(0), + create(1)}); ast::VariableList params; params.push_back(Var("param", ty.f32(), ast::StorageClass::kFunction)); @@ -511,7 +507,7 @@ TEST_F(MslGeneratorImplTest, create(MemberAccessor("coord", "x")), }; - Func("sub_func", params, ty.f32(), body, ast::FunctionDecorationList{}); + Func("sub_func", params, ty.f32(), body, ast::DecorationList{}); ast::ExpressionList expr; expr.push_back(Expr(1.0f)); @@ -524,7 +520,7 @@ TEST_F(MslGeneratorImplTest, create(var), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -547,19 +543,19 @@ fragment void frag_main(constant float4& coord [[buffer(0)]]) { } TEST_F(MslGeneratorImplTest, - Emit_FunctionDecoration_Called_By_EntryPoint_With_RW_StorageBuffer) { + Emit_Decoration_Called_By_EntryPoint_With_RW_StorageBuffer) { auto* str = create( ast::StructMemberList{Member("a", ty.i32(), {MemberOffset(0)}), Member("b", ty.f32(), {MemberOffset(4)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("Data", str); type::AccessControl ac(ast::AccessControl::kReadWrite, s); AST().AddConstructedType(s); Global("coord", &ac, ast::StorageClass::kStorage, nullptr, - ast::VariableDecorationList{create(0), - create(1)}); + ast::DecorationList{create(0), + create(1)}); ast::VariableList params; params.push_back(Var("param", ty.f32(), ast::StorageClass::kFunction)); @@ -567,7 +563,7 @@ TEST_F(MslGeneratorImplTest, auto body = ast::StatementList{ create(MemberAccessor("coord", "b"))}; - Func("sub_func", params, ty.f32(), body, ast::FunctionDecorationList{}); + Func("sub_func", params, ty.f32(), body, ast::DecorationList{}); auto* var = Var("v", ty.f32(), ast::StorageClass::kFunction, Call("sub_func", 1.0f)); @@ -577,7 +573,7 @@ TEST_F(MslGeneratorImplTest, create(var), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -605,19 +601,19 @@ fragment void frag_main(device Data& coord [[buffer(0)]]) { } TEST_F(MslGeneratorImplTest, - Emit_FunctionDecoration_Called_By_EntryPoint_With_RO_StorageBuffer) { + Emit_Decoration_Called_By_EntryPoint_With_RO_StorageBuffer) { auto* str = create( ast::StructMemberList{Member("a", ty.i32(), {MemberOffset(0)}), Member("b", ty.f32(), {MemberOffset(4)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("Data", str); type::AccessControl ac(ast::AccessControl::kReadOnly, s); AST().AddConstructedType(s); Global("coord", &ac, ast::StorageClass::kStorage, nullptr, - ast::VariableDecorationList{create(0), - create(1)}); + ast::DecorationList{create(0), + create(1)}); ast::VariableList params; params.push_back(Var("param", ty.f32(), ast::StorageClass::kFunction)); @@ -625,7 +621,7 @@ TEST_F(MslGeneratorImplTest, auto body = ast::StatementList{ create(MemberAccessor("coord", "b"))}; - Func("sub_func", params, ty.f32(), body, ast::FunctionDecorationList{}); + Func("sub_func", params, ty.f32(), body, ast::DecorationList{}); ast::ExpressionList expr; expr.push_back(Expr(1.0f)); @@ -638,7 +634,7 @@ TEST_F(MslGeneratorImplTest, create(var), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -666,9 +662,9 @@ fragment void frag_main(const device Data& coord [[buffer(0)]]) { } TEST_F(MslGeneratorImplTest, - Emit_FunctionDecoration_EntryPoints_WithGlobal_Nested_Return) { + Emit_Decoration_EntryPoints_WithGlobal_Nested_Return) { Global("bar", ty.f32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{create(1)}); + ast::DecorationList{create(1)}); auto* list = create(ast::StatementList{ create(), @@ -683,7 +679,7 @@ TEST_F(MslGeneratorImplTest, }; Func("ep_1", ast::VariableList{}, ty.void_(), body, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -717,7 +713,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_WithArrayParams) { ast::StatementList{ create(), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); GeneratorImpl& gen = Build(); @@ -752,7 +748,7 @@ TEST_F(MslGeneratorImplTest, // return; // } - ast::StructDecorationList s_decos; + ast::DecorationList s_decos; s_decos.push_back(create()); auto* str = create( @@ -762,8 +758,8 @@ TEST_F(MslGeneratorImplTest, type::AccessControl ac(ast::AccessControl::kReadWrite, s); Global("data", &ac, ast::StorageClass::kStorage, nullptr, - ast::VariableDecorationList{create(0), - create(0)}); + ast::DecorationList{create(0), + create(0)}); AST().AddConstructedType(s); @@ -776,7 +772,7 @@ TEST_F(MslGeneratorImplTest, create(var), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kCompute), }); } @@ -788,7 +784,7 @@ TEST_F(MslGeneratorImplTest, Func("b", ast::VariableList{}, ty.void_(), ast::StatementList{create(var), create()}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kCompute)}); } diff --git a/src/writer/msl/generator_impl_member_accessor_test.cc b/src/writer/msl/generator_impl_member_accessor_test.cc index 4f97d59b01a..a50cbf03583 100644 --- a/src/writer/msl/generator_impl_member_accessor_test.cc +++ b/src/writer/msl/generator_impl_member_accessor_test.cc @@ -27,7 +27,7 @@ TEST_F(MslGeneratorImplTest, EmitExpression_MemberAccessor) { ast::StructMemberList{ Member("mem", ty.f32()), }, - ast::StructDecorationList{})), + ast::DecorationList{})), ast::StorageClass::kPrivate); auto* expr = MemberAccessor("str", "mem"); WrapInFunction(expr); diff --git a/src/writer/msl/generator_impl_module_constant_test.cc b/src/writer/msl/generator_impl_module_constant_test.cc index d7873b29840..b17ce9d3039 100644 --- a/src/writer/msl/generator_impl_module_constant_test.cc +++ b/src/writer/msl/generator_impl_module_constant_test.cc @@ -33,7 +33,7 @@ TEST_F(MslGeneratorImplTest, Emit_ModuleConstant) { TEST_F(MslGeneratorImplTest, Emit_SpecConstant) { auto* var = Const("pos", ty.f32(), Expr(3.f), - ast::VariableDecorationList{ + ast::DecorationList{ create(23), }); diff --git a/src/writer/msl/generator_impl_test.cc b/src/writer/msl/generator_impl_test.cc index ffe023c222d..9c6dfade7e1 100644 --- a/src/writer/msl/generator_impl_test.cc +++ b/src/writer/msl/generator_impl_test.cc @@ -24,7 +24,7 @@ using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, Generate) { Func("my_func", ast::VariableList{}, ty.void_(), ast::StatementList{}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kCompute), }); @@ -139,7 +139,7 @@ TEST_F(MslGeneratorImplTest, calculate_alignment_size_struct) { ast::StructMemberList{Member("a", ty.i32(), {MemberOffset(4)}), Member("b", ty.f32(), {MemberOffset(32)}), Member("c", ty.f32(), {MemberOffset(128)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("S", str); @@ -153,7 +153,7 @@ TEST_F(MslGeneratorImplTest, calculate_alignment_size_struct_of_struct) { ast::StructMemberList{Member("a", ty.i32(), {MemberOffset(0)}), Member("b", ty.vec3(), {MemberOffset(16)}), Member("c", ty.f32(), {MemberOffset(32)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* inner_s = ty.struct_("Inner", inner_str); @@ -161,7 +161,7 @@ TEST_F(MslGeneratorImplTest, calculate_alignment_size_struct_of_struct) { ast::StructMemberList{Member("d", ty.f32(), {MemberOffset(0)}), Member("e", inner_s, {MemberOffset(32)}), Member("f", ty.f32(), {MemberOffset(64)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* outer_s = ty.struct_("Outer", outer_str); diff --git a/src/writer/msl/generator_impl_type_test.cc b/src/writer/msl/generator_impl_type_test.cc index 51bafce3959..1e998157643 100644 --- a/src/writer/msl/generator_impl_type_test.cc +++ b/src/writer/msl/generator_impl_type_test.cc @@ -146,7 +146,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct) { auto* str = create( ast::StructMemberList{Member("a", ty.i32()), Member("b", ty.f32(), {MemberOffset(4)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("S", str); @@ -160,7 +160,7 @@ TEST_F(MslGeneratorImplTest, EmitType_StructDecl) { auto* str = create( ast::StructMemberList{Member("a", ty.i32()), Member("b", ty.f32(), {MemberOffset(4)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("S", str); @@ -181,7 +181,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_InjectPadding) { Member("b", ty.f32(), {MemberOffset(32)}), Member("c", ty.f32(), {MemberOffset(128)}), }, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("S", str); @@ -201,7 +201,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_InjectPadding) { // TODO(dsinclair): How to translate [[block]] TEST_F(MslGeneratorImplTest, DISABLED_EmitType_Struct_WithDecoration) { - ast::StructDecorationList decos; + ast::DecorationList decos; decos.push_back(create()); auto* str = create( ast::StructMemberList{Member("a", ty.i32()), 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 24e2ed2a591..095aa9dfd6f 100644 --- a/src/writer/msl/generator_impl_variable_decl_statement_test.cc +++ b/src/writer/msl/generator_impl_variable_decl_statement_test.cc @@ -49,7 +49,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Const) { } TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Array) { - type::Array ary(ty.f32(), 5, ast::ArrayDecorationList{}); + type::Array ary(ty.f32(), 5, ast::DecorationList{}); auto* var = Var("a", &ary, ast::StorageClass::kNone); auto* stmt = create(var); @@ -67,7 +67,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Struct) { auto* str = create( ast::StructMemberList{Member("a", ty.f32()), Member("b", ty.f32(), {MemberOffset(4)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("S", str); auto* var = Var("a", s, ast::StorageClass::kNone); diff --git a/src/writer/spirv/builder_accessor_expression_test.cc b/src/writer/spirv/builder_accessor_expression_test.cc index eaa79d8365e..e69f08de4c9 100644 --- a/src/writer/spirv/builder_accessor_expression_test.cc +++ b/src/writer/spirv/builder_accessor_expression_test.cc @@ -135,7 +135,7 @@ TEST_F(BuilderTest, ArrayAccessor_Dynamic) { } TEST_F(BuilderTest, ArrayAccessor_MultiLevel) { - type::Array ary4(ty.vec3(), 4, ast::ArrayDecorationList{}); + type::Array ary4(ty.vec3(), 4, ast::DecorationList{}); // ary = array, 4> // ary[3][2]; @@ -173,7 +173,7 @@ TEST_F(BuilderTest, ArrayAccessor_MultiLevel) { } TEST_F(BuilderTest, Accessor_ArrayWithSwizzle) { - type::Array ary4(ty.vec3(), 4, ast::ArrayDecorationList{}); + type::Array ary4(ty.vec3(), 4, ast::DecorationList{}); // var a : array, 4>; // a[2].xy; @@ -221,7 +221,7 @@ TEST_F(BuilderTest, MemberAccessor) { auto* s = create( ast::StructMemberList{Member("a", ty.f32()), Member("b", ty.f32())}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s_type = ty.struct_("my_struct", s); auto* var = Global("ident", s_type, ast::StorageClass::kFunction); @@ -265,12 +265,12 @@ TEST_F(BuilderTest, MemberAccessor_Nested) { auto* inner_struct = ty.struct_( "Inner", create(ast::StructMemberList{Member("a", ty.f32()), Member("b", ty.f32())}, - ast::StructDecorationList{})); + ast::DecorationList{})); auto* s_type = ty.struct_( "my_struct", create(ast::StructMemberList{Member("inner", inner_struct)}, - ast::StructDecorationList{})); + ast::DecorationList{})); auto* var = Global("ident", s_type, ast::StorageClass::kFunction); auto* expr = MemberAccessor(MemberAccessor("ident", "inner"), "a"); @@ -314,13 +314,13 @@ TEST_F(BuilderTest, MemberAccessor_Nested_WithAlias) { auto* inner_struct = ty.struct_( "Inner", create(ast::StructMemberList{Member("a", ty.f32()), Member("b", ty.f32())}, - ast::StructDecorationList{})); + ast::DecorationList{})); auto* alias = ty.alias("Inner", inner_struct); auto* s_type = ty.struct_( "Outer", create(ast::StructMemberList{Member("inner", alias)}, - ast::StructDecorationList{})); + ast::DecorationList{})); auto* var = Global("ident", s_type, ast::StorageClass::kFunction); auto* expr = MemberAccessor(MemberAccessor("ident", "inner"), "a"); @@ -363,12 +363,12 @@ TEST_F(BuilderTest, MemberAccessor_Nested_Assignment_LHS) { auto* inner_struct = ty.struct_( "Inner", create(ast::StructMemberList{Member("a", ty.f32()), Member("b", ty.f32())}, - ast::StructDecorationList{})); + ast::DecorationList{})); auto* s_type = ty.struct_( "my_struct", create(ast::StructMemberList{Member("inner", inner_struct)}, - ast::StructDecorationList{})); + ast::DecorationList{})); auto* var = Global("ident", s_type, ast::StorageClass::kFunction); auto* expr = create( @@ -415,12 +415,12 @@ TEST_F(BuilderTest, MemberAccessor_Nested_Assignment_RHS) { auto* inner_struct = ty.struct_( "Inner", create(ast::StructMemberList{Member("a", ty.f32()), Member("b", ty.f32())}, - ast::StructDecorationList{})); + ast::DecorationList{})); auto* s_type = ty.struct_( "my_struct", create(ast::StructMemberList{Member("inner", inner_struct)}, - ast::StructDecorationList{})); + ast::DecorationList{})); auto* var = Global("ident", s_type, ast::StorageClass::kFunction); auto* store = Global("store", ty.f32(), ast::StorageClass::kFunction); @@ -627,18 +627,18 @@ TEST_F(BuilderTest, Accessor_Mixed_ArrayAndMember) { auto* s = create(ast::StructMemberList{Member("baz", ty.vec3())}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* c_type = ty.struct_("C", s); s = create(ast::StructMemberList{Member("bar", c_type)}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* b_type = ty.struct_("B", s); - type::Array b_ary_type(b_type, 3, ast::ArrayDecorationList{}); + type::Array b_ary_type(b_type, 3, ast::DecorationList{}); s = create(ast::StructMemberList{Member("foo", &b_ary_type)}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* a_type = ty.struct_("A", s); - type::Array a_ary_type(a_type, 2, ast::ArrayDecorationList{}); + type::Array a_ary_type(a_type, 2, ast::DecorationList{}); auto* var = Global("index", &a_ary_type, ast::StorageClass::kFunction); auto* expr = MemberAccessor( MemberAccessor( @@ -693,7 +693,7 @@ TEST_F(BuilderTest, Accessor_Array_Of_Vec) { // vec2(0.5, -0.5)); // pos[1] - type::Array arr(ty.vec2(), 3, ast::ArrayDecorationList{}); + type::Array arr(ty.vec2(), 3, ast::DecorationList{}); auto* var = GlobalConst("pos", &arr, diff --git a/src/writer/spirv/builder_assign_test.cc b/src/writer/spirv/builder_assign_test.cc index 805a96fdf69..45d37698ab9 100644 --- a/src/writer/spirv/builder_assign_test.cc +++ b/src/writer/spirv/builder_assign_test.cc @@ -178,7 +178,7 @@ TEST_F(BuilderTest, Assign_StructMember) { auto* s = create( ast::StructMemberList{Member("a", ty.f32()), Member("b", ty.f32())}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s_type = ty.struct_("my_struct", s); auto* v = Global("ident", s_type, ast::StorageClass::kFunction); diff --git a/src/writer/spirv/builder_call_test.cc b/src/writer/spirv/builder_call_test.cc index 0d384b6669b..de6fc29726f 100644 --- a/src/writer/spirv/builder_call_test.cc +++ b/src/writer/spirv/builder_call_test.cc @@ -32,10 +32,10 @@ TEST_F(BuilderTest, Expression_Call) { auto* a_func = Func("a_func", func_params, ty.f32(), ast::StatementList{create(Add("a", "b"))}, - ast::FunctionDecorationList{}); + ast::DecorationList{}); - auto* func = Func("main", {}, ty.void_(), ast::StatementList{}, - ast::FunctionDecorationList{}); + auto* func = + Func("main", {}, ty.void_(), ast::StatementList{}, ast::DecorationList{}); auto* expr = Call("a_func", 1.f, 1.f); @@ -81,10 +81,10 @@ TEST_F(BuilderTest, Statement_Call) { auto* a_func = Func("a_func", func_params, ty.void_(), ast::StatementList{create(Add("a", "b"))}, - ast::FunctionDecorationList{}); + ast::DecorationList{}); - auto* func = Func("main", {}, ty.void_(), ast::StatementList{}, - ast::FunctionDecorationList{}); + auto* func = + Func("main", {}, ty.void_(), ast::StatementList{}, ast::DecorationList{}); auto* expr = create(Call("a_func", 1.f, 1.f)); diff --git a/src/writer/spirv/builder_constructor_expression_test.cc b/src/writer/spirv/builder_constructor_expression_test.cc index d1272bf82d2..4525ba4ef61 100644 --- a/src/writer/spirv/builder_constructor_expression_test.cc +++ b/src/writer/spirv/builder_constructor_expression_test.cc @@ -979,7 +979,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Struct) { Member("a", ty.f32()), Member("b", ty.vec3()), }, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s_type = ty.struct_("my_struct", s); auto* t = Construct(s_type, 2.0f, vec3(2.0f, 2.0f, 2.0f)); @@ -1131,7 +1131,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ZeroInit_Struct) { ast::StructMemberList{ Member("a", ty.f32()), }, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s_type = ty.struct_("my_struct", s); auto* t = Construct(s_type); WrapInFunction(t); @@ -1569,7 +1569,7 @@ TEST_F(SpvBuilderConstructorTest, IsConstructorConst_Struct) { Member("a", ty.f32()), Member("b", ty.vec3()), }, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s_type = ty.struct_("my_struct", s); auto* t = Construct(s_type, 2.f, vec3(2.f, 2.f, 2.f)); WrapInFunction(t); @@ -1587,7 +1587,7 @@ TEST_F(SpvBuilderConstructorTest, Member("a", ty.f32()), Member("b", ty.vec3()), }, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s_type = ty.struct_("my_struct", s); auto* t = Construct(s_type, 2.f, "a", 2.f); diff --git a/src/writer/spirv/builder_entry_point_test.cc b/src/writer/spirv/builder_entry_point_test.cc index c9f782d2b93..a0c52c375ca 100644 --- a/src/writer/spirv/builder_entry_point_test.cc +++ b/src/writer/spirv/builder_entry_point_test.cc @@ -51,7 +51,7 @@ TEST_F(BuilderTest, EntryPoint_Parameters) { auto* col = Var("col", f32, ast::StorageClass::kFunction, mul, {}); Func("frag_main", ast::VariableList{coord, loc1}, ty.void_(), ast::StatementList{WrapInStatement(col)}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); diff --git a/src/writer/spirv/builder_function_decoration_test.cc b/src/writer/spirv/builder_function_decoration_test.cc index 12afe063caf..34b8e89beb4 100644 --- a/src/writer/spirv/builder_function_decoration_test.cc +++ b/src/writer/spirv/builder_function_decoration_test.cc @@ -24,10 +24,10 @@ namespace { using BuilderTest = TestHelper; -TEST_F(BuilderTest, FunctionDecoration_Stage) { +TEST_F(BuilderTest, Decoration_Stage) { auto* func = Func("main", {}, ty.void_(), ast::StatementList{}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -47,12 +47,12 @@ inline std::ostream& operator<<(std::ostream& out, FunctionStageData data) { out << data.stage; return out; } -using FunctionDecoration_StageTest = TestParamHelper; -TEST_P(FunctionDecoration_StageTest, Emit) { +using Decoration_StageTest = TestParamHelper; +TEST_P(Decoration_StageTest, Emit) { auto params = GetParam(); auto* func = Func("main", {}, ty.void_(), ast::StatementList{}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(params.stage), }); @@ -69,7 +69,7 @@ TEST_P(FunctionDecoration_StageTest, Emit) { } INSTANTIATE_TEST_SUITE_P( BuilderTest, - FunctionDecoration_StageTest, + Decoration_StageTest, testing::Values(FunctionStageData{ast::PipelineStage::kVertex, SpvExecutionModelVertex}, FunctionStageData{ast::PipelineStage::kFragment, @@ -77,10 +77,10 @@ INSTANTIATE_TEST_SUITE_P( FunctionStageData{ast::PipelineStage::kCompute, SpvExecutionModelGLCompute})); -TEST_F(BuilderTest, FunctionDecoration_Stage_WithUnusedInterfaceIds) { +TEST_F(BuilderTest, Decoration_Stage_WithUnusedInterfaceIds) { auto* func = Func("main", {}, ty.void_(), ast::StatementList{}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -116,7 +116,7 @@ OpName %11 "main" )"); } -TEST_F(BuilderTest, FunctionDecoration_Stage_WithUsedInterfaceIds) { +TEST_F(BuilderTest, Decoration_Stage_WithUsedInterfaceIds) { auto* func = Func("main", {}, ty.void_(), ast::StatementList{ @@ -125,7 +125,7 @@ TEST_F(BuilderTest, FunctionDecoration_Stage_WithUsedInterfaceIds) { // Add duplicate usages so we show they don't get // output multiple times. create(Expr("my_out"), Expr("my_in"))}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -161,10 +161,10 @@ OpName %11 "main" )"); } -TEST_F(BuilderTest, FunctionDecoration_ExecutionMode_Fragment_OriginUpperLeft) { +TEST_F(BuilderTest, Decoration_ExecutionMode_Fragment_OriginUpperLeft) { auto* func = Func("main", {}, ty.void_(), ast::StatementList{}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -176,10 +176,10 @@ TEST_F(BuilderTest, FunctionDecoration_ExecutionMode_Fragment_OriginUpperLeft) { )"); } -TEST_F(BuilderTest, FunctionDecoration_ExecutionMode_WorkgroupSize_Default) { +TEST_F(BuilderTest, Decoration_ExecutionMode_WorkgroupSize_Default) { auto* func = Func("main", {}, ty.void_(), ast::StatementList{}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kCompute), }); @@ -191,10 +191,10 @@ TEST_F(BuilderTest, FunctionDecoration_ExecutionMode_WorkgroupSize_Default) { )"); } -TEST_F(BuilderTest, FunctionDecoration_ExecutionMode_WorkgroupSize) { +TEST_F(BuilderTest, Decoration_ExecutionMode_WorkgroupSize) { auto* func = Func("main", {}, ty.void_(), ast::StatementList{}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(2u, 4u, 6u), create(ast::PipelineStage::kCompute), }); @@ -207,16 +207,16 @@ TEST_F(BuilderTest, FunctionDecoration_ExecutionMode_WorkgroupSize) { )"); } -TEST_F(BuilderTest, FunctionDecoration_ExecutionMode_MultipleFragment) { +TEST_F(BuilderTest, Decoration_ExecutionMode_MultipleFragment) { auto* func1 = Func("main1", {}, ty.void_(), ast::StatementList{}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); auto* func2 = Func("main2", {}, ty.void_(), ast::StatementList{}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -244,9 +244,9 @@ OpFunctionEnd )"); } -TEST_F(BuilderTest, FunctionDecoration_ExecutionMode_FragDepth) { +TEST_F(BuilderTest, Decoration_ExecutionMode_FragDepth) { Global("fragdepth", ty.f32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(ast::Builtin::kFragDepth), }); @@ -255,7 +255,7 @@ TEST_F(BuilderTest, FunctionDecoration_ExecutionMode_FragDepth) { ast::StatementList{ create(Expr("fragdepth"), Expr(1.f)), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); spirv::Builder& b = Build(); diff --git a/src/writer/spirv/builder_function_test.cc b/src/writer/spirv/builder_function_test.cc index 785ca0c3844..feecfacce8c 100644 --- a/src/writer/spirv/builder_function_test.cc +++ b/src/writer/spirv/builder_function_test.cc @@ -25,8 +25,7 @@ namespace { using BuilderTest = TestHelper; TEST_F(BuilderTest, Function_Empty) { - Func("a_func", {}, ty.void_(), ast::StatementList{}, - ast::FunctionDecorationList{}); + Func("a_func", {}, ty.void_(), ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -47,7 +46,7 @@ TEST_F(BuilderTest, Function_Terminator_Return) { ast::StatementList{ create(), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); spirv::Builder& b = Build(); @@ -68,7 +67,7 @@ TEST_F(BuilderTest, Function_Terminator_ReturnValue) { Func("a_func", {}, ty.void_(), ast::StatementList{create(Expr("a"))}, - ast::FunctionDecorationList{}); + ast::DecorationList{}); spirv::Builder& b = Build(); @@ -98,7 +97,7 @@ TEST_F(BuilderTest, Function_Terminator_Discard) { ast::StatementList{ create(), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); spirv::Builder& b = Build(); @@ -120,7 +119,7 @@ TEST_F(BuilderTest, Function_WithParams) { Func("a_func", params, ty.f32(), ast::StatementList{create(Expr("a"))}, - ast::FunctionDecorationList{}); + ast::DecorationList{}); spirv::Builder& b = Build(); @@ -147,7 +146,7 @@ TEST_F(BuilderTest, Function_WithBody) { ast::StatementList{ create(), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); spirv::Builder& b = Build(); @@ -164,8 +163,7 @@ OpFunctionEnd } TEST_F(BuilderTest, FunctionType) { - Func("a_func", {}, ty.void_(), ast::StatementList{}, - ast::FunctionDecorationList{}); + Func("a_func", {}, ty.void_(), ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -178,9 +176,9 @@ TEST_F(BuilderTest, FunctionType) { TEST_F(BuilderTest, FunctionType_DeDuplicate) { auto* func1 = Func("a_func", {}, ty.void_(), ast::StatementList{}, - ast::FunctionDecorationList{}); + ast::DecorationList{}); auto* func2 = Func("b_func", {}, ty.void_(), ast::StatementList{}, - ast::FunctionDecorationList{}); + ast::DecorationList{}); spirv::Builder& b = Build(); @@ -208,7 +206,7 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) { // return; // } - ast::StructDecorationList s_decos; + ast::DecorationList s_decos; s_decos.push_back(create()); auto* str = create( @@ -218,7 +216,7 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) { type::AccessControl ac(ast::AccessControl::kReadWrite, s); Global("data", &ac, ast::StorageClass::kStorage, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(0), create(0), }); @@ -234,7 +232,7 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) { create(var), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kCompute), }); } @@ -248,7 +246,7 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) { create(var), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kCompute), }); } diff --git a/src/writer/spirv/builder_global_variable_test.cc b/src/writer/spirv/builder_global_variable_test.cc index de729c73230..6a379280039 100644 --- a/src/writer/spirv/builder_global_variable_test.cc +++ b/src/writer/spirv/builder_global_variable_test.cc @@ -157,7 +157,7 @@ TEST_F(BuilderTest, GlobalVar_Complex_ConstructorWithExtract) { TEST_F(BuilderTest, GlobalVar_WithLocation) { auto* v = Global("var", ty.f32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(5), }); @@ -177,7 +177,7 @@ TEST_F(BuilderTest, GlobalVar_WithLocation) { TEST_F(BuilderTest, GlobalVar_WithBindingAndGroup) { auto* v = Global("var", ty.f32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(2), create(3), }); @@ -199,7 +199,7 @@ OpDecorate %1 DescriptorSet 3 TEST_F(BuilderTest, GlobalVar_WithBuiltin) { auto* v = Global("var", ty.f32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(ast::Builtin::kPosition), }); @@ -219,7 +219,7 @@ TEST_F(BuilderTest, GlobalVar_WithBuiltin) { TEST_F(BuilderTest, GlobalVar_ConstantId_Bool) { auto* v = Global("var", ty.bool_(), ast::StorageClass::kNone, Expr(true), - ast::VariableDecorationList{ + ast::DecorationList{ create(1200), }); @@ -239,7 +239,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Bool) { TEST_F(BuilderTest, GlobalVar_ConstantId_Bool_NoConstructor) { auto* v = Global("var", ty.bool_(), ast::StorageClass::kNone, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(1200), }); @@ -259,7 +259,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Bool_NoConstructor) { TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar) { auto* v = Global("var", ty.f32(), ast::StorageClass::kNone, Expr(2.f), - ast::VariableDecorationList{ + ast::DecorationList{ create(0), }); @@ -279,7 +279,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar) { TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_F32_NoConstructor) { auto* v = Global("var", ty.f32(), ast::StorageClass::kNone, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(0), }); @@ -299,7 +299,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_F32_NoConstructor) { TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_I32_NoConstructor) { auto* v = Global("var", ty.i32(), ast::StorageClass::kNone, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(0), }); @@ -319,7 +319,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_I32_NoConstructor) { TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_U32_NoConstructor) { auto* v = Global("var", ty.u32(), ast::StorageClass::kNone, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(0), }); @@ -386,7 +386,7 @@ TEST_F(BuilderTest, GlobalVar_DeclReadOnly) { auto* A = ty.struct_( "A", create(ast::StructMemberList{Member("a", ty.i32()), Member("b", ty.i32())}, - ast::StructDecorationList{})); + ast::DecorationList{})); auto* ac = create(ast::AccessControl::kReadOnly, A); auto* var = Global("b", ac, ast::StorageClass::kStorage); @@ -419,7 +419,7 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasDeclReadOnly) { auto* A = ty.struct_( "A", create(ast::StructMemberList{Member("a", ty.i32())}, - ast::StructDecorationList{})); + ast::DecorationList{})); auto* B = ty.alias("B", A); auto* ac = create(ast::AccessControl::kReadOnly, B); auto* var = Global("b", ac, ast::StorageClass::kStorage); @@ -450,7 +450,7 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasAssignReadOnly) { auto* A = ty.struct_( "A", create(ast::StructMemberList{Member("a", ty.i32())}, - ast::StructDecorationList{})); + ast::DecorationList{})); auto* ac = create(ast::AccessControl::kReadOnly, A); auto* B = ty.alias("B", ac); auto* var = Global("b", B, ast::StorageClass::kStorage); @@ -481,7 +481,7 @@ TEST_F(BuilderTest, GlobalVar_TwoVarDeclReadOnly) { auto* A = ty.struct_( "A", create(ast::StructMemberList{Member("a", ty.i32())}, - ast::StructDecorationList{})); + ast::DecorationList{})); type::AccessControl read{ast::AccessControl::kReadOnly, A}; type::AccessControl rw{ast::AccessControl::kReadWrite, A}; @@ -606,7 +606,7 @@ OpDecorate %5 NonReadable TEST_F(BuilderTest, SampleIndex) { auto* var = Global("sample_index", ty.u32(), ast::StorageClass::kInput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(ast::Builtin::kSampleIndex), }); @@ -640,18 +640,18 @@ TEST_F(BuilderTest, SampleMask) { // } Global("mask_in", ty.u32(), ast::StorageClass::kInput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(ast::Builtin::kSampleMaskIn), }); Global("mask_out", ty.u32(), ast::StorageClass::kOutput, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(ast::Builtin::kSampleMaskOut), }); Func("main", ast::VariableList{}, ty.void_(), ast::StatementList{ create(Expr("mask_out"), Expr("mask_in")), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kCompute), }); diff --git a/src/writer/spirv/builder_intrinsic_test.cc b/src/writer/spirv/builder_intrinsic_test.cc index e99fe17a6d9..3d1510d11cb 100644 --- a/src/writer/spirv/builder_intrinsic_test.cc +++ b/src/writer/spirv/builder_intrinsic_test.cc @@ -429,7 +429,7 @@ TEST_F(IntrinsicBuilderTest, Call_GLSLMethod_WithLoad) { WrapInFunction(expr); auto* func = Func("a_func", ast::VariableList{}, ty.void_(), - ast::StatementList{}, ast::FunctionDecorationList{}); + ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -464,7 +464,7 @@ TEST_P(Intrinsic_Builtin_SingleParam_Float_Test, Call_Scalar) { WrapInFunction(expr); auto* func = Func("a_func", ast::VariableList{}, ty.void_(), - ast::StatementList{}, ast::FunctionDecorationList{}); + ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -493,7 +493,7 @@ TEST_P(Intrinsic_Builtin_SingleParam_Float_Test, Call_Vector) { WrapInFunction(expr); auto* func = Func("a_func", ast::VariableList{}, ty.void_(), - ast::StatementList{}, ast::FunctionDecorationList{}); + ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -548,7 +548,7 @@ TEST_F(IntrinsicBuilderTest, Call_Length_Scalar) { WrapInFunction(expr); auto* func = Func("a_func", ast::VariableList{}, ty.void_(), - ast::StatementList{}, ast::FunctionDecorationList{}); + ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -574,7 +574,7 @@ TEST_F(IntrinsicBuilderTest, Call_Length_Vector) { WrapInFunction(expr); auto* func = Func("a_func", ast::VariableList{}, ty.void_(), - ast::StatementList{}, ast::FunctionDecorationList{}); + ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -602,7 +602,7 @@ TEST_F(IntrinsicBuilderTest, Call_Normalize) { WrapInFunction(expr); auto* func = Func("a_func", ast::VariableList{}, ty.void_(), - ast::StatementList{}, ast::FunctionDecorationList{}); + ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -635,7 +635,7 @@ TEST_P(Intrinsic_Builtin_DualParam_Float_Test, Call_Scalar) { WrapInFunction(expr); auto* func = Func("a_func", ast::VariableList{}, ty.void_(), - ast::StatementList{}, ast::FunctionDecorationList{}); + ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -665,7 +665,7 @@ TEST_P(Intrinsic_Builtin_DualParam_Float_Test, Call_Vector) { WrapInFunction(expr); auto* func = Func("a_func", ast::VariableList{}, ty.void_(), - ast::StatementList{}, ast::FunctionDecorationList{}); + ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -703,7 +703,7 @@ TEST_F(IntrinsicBuilderTest, Call_Distance_Scalar) { WrapInFunction(expr); auto* func = Func("a_func", ast::VariableList{}, ty.void_(), - ast::StatementList{}, ast::FunctionDecorationList{}); + ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -730,7 +730,7 @@ TEST_F(IntrinsicBuilderTest, Call_Distance_Vector) { WrapInFunction(expr); auto* func = Func("a_func", ast::VariableList{}, ty.void_(), - ast::StatementList{}, ast::FunctionDecorationList{}); + ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -760,7 +760,7 @@ TEST_F(IntrinsicBuilderTest, Call_Cross) { WrapInFunction(expr); auto* func = Func("a_func", ast::VariableList{}, ty.void_(), - ast::StatementList{}, ast::FunctionDecorationList{}); + ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -792,7 +792,7 @@ TEST_P(Intrinsic_Builtin_ThreeParam_Float_Test, Call_Scalar) { WrapInFunction(expr); auto* func = Func("a_func", ast::VariableList{}, ty.void_(), - ast::StatementList{}, ast::FunctionDecorationList{}); + ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -823,7 +823,7 @@ TEST_P(Intrinsic_Builtin_ThreeParam_Float_Test, Call_Vector) { WrapInFunction(expr); auto* func = Func("a_func", ast::VariableList{}, ty.void_(), - ast::StatementList{}, ast::FunctionDecorationList{}); + ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -865,7 +865,7 @@ TEST_P(Intrinsic_Builtin_SingleParam_Sint_Test, Call_Scalar) { WrapInFunction(expr); auto* func = Func("a_func", ast::VariableList{}, ty.void_(), - ast::StatementList{}, ast::FunctionDecorationList{}); + ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -894,7 +894,7 @@ TEST_P(Intrinsic_Builtin_SingleParam_Sint_Test, Call_Vector) { WrapInFunction(expr); auto* func = Func("a_func", ast::VariableList{}, ty.void_(), - ast::StatementList{}, ast::FunctionDecorationList{}); + ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -930,7 +930,7 @@ TEST_P(Intrinsic_Builtin_SingleParam_Uint_Test, Call_Scalar) { WrapInFunction(expr); auto* func = Func("a_func", ast::VariableList{}, ty.void_(), - ast::StatementList{}, ast::FunctionDecorationList{}); + ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -959,7 +959,7 @@ TEST_P(Intrinsic_Builtin_SingleParam_Uint_Test, Call_Vector) { WrapInFunction(expr); auto* func = Func("a_func", ast::VariableList{}, ty.void_(), - ast::StatementList{}, ast::FunctionDecorationList{}); + ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -995,7 +995,7 @@ TEST_P(Intrinsic_Builtin_DualParam_SInt_Test, Call_Scalar) { WrapInFunction(expr); auto* func = Func("a_func", ast::VariableList{}, ty.void_(), - ast::StatementList{}, ast::FunctionDecorationList{}); + ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -1024,7 +1024,7 @@ TEST_P(Intrinsic_Builtin_DualParam_SInt_Test, Call_Vector) { WrapInFunction(expr); auto* func = Func("a_func", ast::VariableList{}, ty.void_(), - ast::StatementList{}, ast::FunctionDecorationList{}); + ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -1061,7 +1061,7 @@ TEST_P(Intrinsic_Builtin_DualParam_UInt_Test, Call_Scalar) { WrapInFunction(expr); auto* func = Func("a_func", ast::VariableList{}, ty.void_(), - ast::StatementList{}, ast::FunctionDecorationList{}); + ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -1090,7 +1090,7 @@ TEST_P(Intrinsic_Builtin_DualParam_UInt_Test, Call_Vector) { WrapInFunction(expr); auto* func = Func("a_func", ast::VariableList{}, ty.void_(), - ast::StatementList{}, ast::FunctionDecorationList{}); + ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -1127,7 +1127,7 @@ TEST_P(Intrinsic_Builtin_ThreeParam_Sint_Test, Call_Scalar) { WrapInFunction(expr); auto* func = Func("a_func", ast::VariableList{}, ty.void_(), - ast::StatementList{}, ast::FunctionDecorationList{}); + ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -1158,7 +1158,7 @@ TEST_P(Intrinsic_Builtin_ThreeParam_Sint_Test, Call_Vector) { WrapInFunction(expr); auto* func = Func("a_func", ast::VariableList{}, ty.void_(), - ast::StatementList{}, ast::FunctionDecorationList{}); + ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -1194,7 +1194,7 @@ TEST_P(Intrinsic_Builtin_ThreeParam_Uint_Test, Call_Scalar) { WrapInFunction(expr); auto* func = Func("a_func", ast::VariableList{}, ty.void_(), - ast::StatementList{}, ast::FunctionDecorationList{}); + ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -1225,7 +1225,7 @@ TEST_P(Intrinsic_Builtin_ThreeParam_Uint_Test, Call_Vector) { WrapInFunction(expr); auto* func = Func("a_func", ast::VariableList{}, ty.void_(), - ast::StatementList{}, ast::FunctionDecorationList{}); + ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -1260,7 +1260,7 @@ TEST_F(IntrinsicBuilderTest, Call_Modf) { create(out), create(expr), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -1303,7 +1303,7 @@ TEST_F(IntrinsicBuilderTest, Call_Frexp) { create(out), create(expr), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -1347,7 +1347,7 @@ TEST_F(IntrinsicBuilderTest, Call_Determinant) { WrapInFunction(expr); auto* func = Func("a_func", ast::VariableList{}, ty.void_(), - ast::StatementList{}, ast::FunctionDecorationList{}); + ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -1379,12 +1379,12 @@ OpFunctionEnd TEST_F(IntrinsicBuilderTest, Call_ArrayLength) { auto* s = create( ast::StructMemberList{Member(0, "a", ty.array(4))}, - ast::StructDecorationList{ + ast::DecorationList{ create(), }); auto* s_type = ty.struct_("my_struct", s); Global("b", s_type, ast::StorageClass::kStorage, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(1), create(2), }); @@ -1395,7 +1395,7 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength) { ast::StatementList{ create(expr), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -1429,13 +1429,13 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength_OtherMembersInStruct) { auto* s = create( ast::StructMemberList{Member(0, "z", ty.f32()), Member(4, "a", ty.array(4))}, - ast::StructDecorationList{ + ast::DecorationList{ create(), }); auto* s_type = ty.struct_("my_struct", s); Global("b", s_type, ast::StorageClass::kStorage, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(1), create(2), }); @@ -1446,7 +1446,7 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength_OtherMembersInStruct) { ast::StatementList{ create(expr), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kVertex), }); @@ -1487,7 +1487,7 @@ TEST_P(Intrinsic_Builtin_DataPacking_Test, Binary) { WrapInFunction(call); auto* func = Func("a_func", ast::VariableList{}, ty.void_(), - ast::StatementList{}, ast::FunctionDecorationList{}); + ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -1550,7 +1550,7 @@ TEST_P(Intrinsic_Builtin_DataUnpacking_Test, Binary) { WrapInFunction(call); auto* func = Func("a_func", ast::VariableList{}, ty.void_(), - ast::StatementList{}, ast::FunctionDecorationList{}); + ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); diff --git a/src/writer/spirv/builder_intrinsic_texture_test.cc b/src/writer/spirv/builder_intrinsic_texture_test.cc index 5c7f25d6cab..328de289a54 100644 --- a/src/writer/spirv/builder_intrinsic_texture_test.cc +++ b/src/writer/spirv/builder_intrinsic_texture_test.cc @@ -3627,7 +3627,7 @@ TEST_P(IntrinsicTextureTest, ValidateSPIRV) { ast::StatementList{ create(call), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); diff --git a/src/writer/spirv/builder_switch_test.cc b/src/writer/spirv/builder_switch_test.cc index ba103ead9de..cff64ccf89b 100644 --- a/src/writer/spirv/builder_switch_test.cc +++ b/src/writer/spirv/builder_switch_test.cc @@ -79,8 +79,8 @@ TEST_F(BuilderTest, Switch_WithCase) { WrapInFunction(expr); - auto* func = Func("a_func", {}, ty.i32(), ast::StatementList{}, - ast::FunctionDecorationList{}); + auto* func = + Func("a_func", {}, ty.i32(), ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -151,8 +151,8 @@ TEST_F(BuilderTest, Switch_WithCase_Unsigned) { WrapInFunction(expr); - auto* func = Func("a_func", {}, ty.i32(), ast::StatementList{}, - ast::FunctionDecorationList{}); + auto* func = + Func("a_func", {}, ty.i32(), ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -215,8 +215,8 @@ TEST_F(BuilderTest, Switch_WithDefault) { WrapInFunction(expr); - auto* func = Func("a_func", {}, ty.i32(), ast::StatementList{}, - ast::FunctionDecorationList{}); + auto* func = + Func("a_func", {}, ty.i32(), ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -289,8 +289,8 @@ TEST_F(BuilderTest, Switch_WithCaseAndDefault) { WrapInFunction(expr); - auto* func = Func("a_func", {}, ty.i32(), ast::StatementList{}, - ast::FunctionDecorationList{}); + auto* func = + Func("a_func", {}, ty.i32(), ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -372,8 +372,8 @@ TEST_F(BuilderTest, Switch_CaseWithFallthrough) { WrapInFunction(expr); - auto* func = Func("a_func", {}, ty.i32(), ast::StatementList{}, - ast::FunctionDecorationList{}); + auto* func = + Func("a_func", {}, ty.i32(), ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -439,8 +439,8 @@ TEST_F(BuilderTest, Switch_CaseFallthroughLastStatement) { WrapInFunction(expr); - auto* func = Func("a_func", {}, ty.i32(), ast::StatementList{}, - ast::FunctionDecorationList{}); + auto* func = + Func("a_func", {}, ty.i32(), ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -482,8 +482,8 @@ TEST_F(BuilderTest, Switch_WithNestedBreak) { WrapInFunction(expr); - auto* func = Func("a_func", {}, ty.i32(), ast::StatementList{}, - ast::FunctionDecorationList{}); + auto* func = + Func("a_func", {}, ty.i32(), ast::StatementList{}, ast::DecorationList{}); spirv::Builder& b = Build(); diff --git a/src/writer/spirv/builder_type_test.cc b/src/writer/spirv/builder_type_test.cc index 51dc2eb22c1..cb8a1d1cd05 100644 --- a/src/writer/spirv/builder_type_test.cc +++ b/src/writer/spirv/builder_type_test.cc @@ -58,7 +58,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedAlias) { } TEST_F(BuilderTest_Type, GenerateRuntimeArray) { - type::Array ary(ty.i32(), 0, ast::ArrayDecorationList{}); + type::Array ary(ty.i32(), 0, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -72,7 +72,7 @@ TEST_F(BuilderTest_Type, GenerateRuntimeArray) { } TEST_F(BuilderTest_Type, ReturnsGeneratedRuntimeArray) { - type::Array ary(ty.i32(), 0, ast::ArrayDecorationList{}); + type::Array ary(ty.i32(), 0, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -86,7 +86,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedRuntimeArray) { } TEST_F(BuilderTest_Type, GenerateArray) { - type::Array ary(ty.i32(), 4, ast::ArrayDecorationList{}); + type::Array ary(ty.i32(), 4, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -103,7 +103,7 @@ TEST_F(BuilderTest_Type, GenerateArray) { TEST_F(BuilderTest_Type, GenerateArray_WithStride) { type::Array ary(ty.i32(), 4, - ast::ArrayDecorationList{ + ast::DecorationList{ create(16u), }); @@ -124,7 +124,7 @@ TEST_F(BuilderTest_Type, GenerateArray_WithStride) { } TEST_F(BuilderTest_Type, ReturnsGeneratedArray) { - type::Array ary(ty.i32(), 4, ast::ArrayDecorationList{}); + type::Array ary(ty.i32(), 4, ast::DecorationList{}); spirv::Builder& b = Build(); @@ -277,8 +277,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedPtr) { } TEST_F(BuilderTest_Type, GenerateStruct_Empty) { - auto* s = - create(ast::StructMemberList{}, ast::StructDecorationList{}); + auto* s = create(ast::StructMemberList{}, ast::DecorationList{}); auto* s_type = ty.struct_("S", s); spirv::Builder& b = Build(); @@ -296,7 +295,7 @@ TEST_F(BuilderTest_Type, GenerateStruct_Empty) { TEST_F(BuilderTest_Type, GenerateStruct) { auto* s = create(ast::StructMemberList{Member("a", ty.f32())}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s_type = ty.struct_("my_struct", s); spirv::Builder& b = Build(); @@ -314,7 +313,7 @@ OpMemberName %1 0 "a" } TEST_F(BuilderTest_Type, GenerateStruct_Decorated) { - ast::StructDecorationList struct_decos; + ast::DecorationList struct_decos; struct_decos.push_back(create()); auto* s = create(ast::StructMemberList{Member("a", ty.f32())}, @@ -341,7 +340,7 @@ TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers) { auto* s = create( ast::StructMemberList{Member("a", ty.f32(), {MemberOffset(0)}), Member("b", ty.f32(), {MemberOffset(8)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s_type = ty.struct_("S", s); spirv::Builder& b = Build(); @@ -367,7 +366,7 @@ TEST_F(BuilderTest_Type, GenerateStruct_NonLayout_Matrix) { create(ast::StructMemberList{Member("a", ty.mat2x2()), Member("b", ty.mat2x3()), Member("c", ty.mat4x4())}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s_type = ty.struct_("S", s); spirv::Builder& b = Build(); @@ -399,7 +398,7 @@ TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers_LayoutMatrix) { ast::StructMemberList{Member("a", ty.mat2x2(), {MemberOffset(0)}), Member("b", ty.mat2x3(), {MemberOffset(16)}), Member("c", ty.mat4x4(), {MemberOffset(48)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s_type = ty.struct_("S", s); spirv::Builder& b = Build(); @@ -439,20 +438,20 @@ TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers_LayoutArraysOfMatrix) { // The decoration goes on the struct member, even if the matrix is buried // in levels of arrays. type::Array arr_mat2x2(ty.mat2x2(), 1, - ast::ArrayDecorationList{}); // Singly nested array + ast::DecorationList{}); // Singly nested array - type::Array arr_mat2x3(ty.mat2x3(), 1, ast::ArrayDecorationList{}); - type::Array arr_arr_mat2x3( - ty.mat2x3(), 1, ast::ArrayDecorationList{}); // Doubly nested array + type::Array arr_mat2x3(ty.mat2x3(), 1, ast::DecorationList{}); + type::Array arr_arr_mat2x3(ty.mat2x3(), 1, + ast::DecorationList{}); // Doubly nested array type::Array rtarr_mat4x4(ty.mat4x4(), 0, - ast::ArrayDecorationList{}); // Runtime array + ast::DecorationList{}); // Runtime array auto* s = create( ast::StructMemberList{Member("a", &arr_mat2x2, {MemberOffset(0)}), Member("b", &arr_arr_mat2x3, {MemberOffset(16)}), Member("c", &rtarr_mat4x4, {MemberOffset(48)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s_type = ty.struct_("S", s); spirv::Builder& b = Build(); diff --git a/src/writer/wgsl/generator_impl_alias_type_test.cc b/src/writer/wgsl/generator_impl_alias_type_test.cc index 01fb28852fb..1155aa32205 100644 --- a/src/writer/wgsl/generator_impl_alias_type_test.cc +++ b/src/writer/wgsl/generator_impl_alias_type_test.cc @@ -34,7 +34,7 @@ TEST_F(WgslGeneratorImplTest, EmitConstructedType_Struct) { auto* str = create( ast::StructMemberList{Member("a", ty.f32()), Member("b", ty.i32(), {MemberOffset(4)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("A", str); auto* alias = ty.alias("B", s); @@ -56,7 +56,7 @@ TEST_F(WgslGeneratorImplTest, EmitAlias_ToStruct) { auto* str = create( ast::StructMemberList{Member("a", ty.f32()), Member("b", ty.i32(), {MemberOffset(4)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("A", str); auto* alias = ty.alias("B", s); diff --git a/src/writer/wgsl/generator_impl_entry_point_test.cc b/src/writer/wgsl/generator_impl_entry_point_test.cc index 5415e6219ef..e4521dcd3f2 100644 --- a/src/writer/wgsl/generator_impl_entry_point_test.cc +++ b/src/writer/wgsl/generator_impl_entry_point_test.cc @@ -26,10 +26,10 @@ using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, Emit_EntryPoint_UnusedFunction) { Func("func_unused", ast::VariableList{}, ty.void_(), ast::StatementList{}, - ast::FunctionDecorationList{}); + ast::DecorationList{}); Func("func_used", ast::VariableList{}, ty.void_(), ast::StatementList{}, - ast::FunctionDecorationList{}); + ast::DecorationList{}); auto* call_func = Call("func_used"); @@ -37,7 +37,7 @@ TEST_F(WgslGeneratorImplTest, Emit_EntryPoint_UnusedFunction) { ast::StatementList{ create(call_func), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kCompute), }); @@ -71,7 +71,7 @@ TEST_F(WgslGeneratorImplTest, Emit_EntryPoint_UnusedVariable) { ast::StatementList{ create(Expr("global_used"), Expr(1.f)), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kCompute), }); @@ -96,7 +96,7 @@ TEST_F(WgslGeneratorImplTest, Emit_EntryPoint_GlobalsInterleaved) { create(global0); auto* str0 = create(ast::StructMemberList{Member("a", ty.i32())}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s0 = ty.struct_("S0", str0); AST().AddConstructedType(s0); @@ -104,13 +104,13 @@ TEST_F(WgslGeneratorImplTest, Emit_EntryPoint_GlobalsInterleaved) { ast::StatementList{ create(Expr("a0")), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); auto* global1 = Global("a1", ty.f32(), ast::StorageClass::kOutput); create(global1); auto* str1 = create(ast::StructMemberList{Member("a", ty.i32())}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s1 = ty.struct_("S1", str1); AST().AddConstructedType(s1); @@ -124,7 +124,7 @@ TEST_F(WgslGeneratorImplTest, Emit_EntryPoint_GlobalsInterleaved) { Var("s1", s1, ast::StorageClass::kFunction)), create(Expr("a1"), Expr(call_func)), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kCompute), }); diff --git a/src/writer/wgsl/generator_impl_function_test.cc b/src/writer/wgsl/generator_impl_function_test.cc index dfc99cf62a9..63cc1f2f97b 100644 --- a/src/writer/wgsl/generator_impl_function_test.cc +++ b/src/writer/wgsl/generator_impl_function_test.cc @@ -32,7 +32,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Function) { create(), create(), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); GeneratorImpl& gen = Build(); @@ -56,7 +56,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Function_WithParams) { create(), create(), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); GeneratorImpl& gen = Build(); @@ -76,7 +76,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Function_WithDecoration_WorkgroupSize) { create(), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(2u, 4u, 6u), }); @@ -100,7 +100,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Function_WithDecoration_Stage) { create(), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -124,7 +124,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Function_WithDecoration_Multiple) { create(), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), create(2u, 4u, 6u), }); @@ -152,7 +152,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Function_EntryPoint_Parameters) { auto* func = Func("frag_main", ast::VariableList{coord, loc1}, ty.void_(), ast::StatementList{}, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kFragment), }); @@ -185,7 +185,7 @@ TEST_F(WgslGeneratorImplTest, // return; // } - ast::StructDecorationList s_decos; + ast::DecorationList s_decos; s_decos.push_back(create()); auto* str = create( @@ -196,7 +196,7 @@ TEST_F(WgslGeneratorImplTest, AST().AddConstructedType(s); Global("data", &ac, ast::StorageClass::kStorage, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(0), create(0), }); @@ -211,7 +211,7 @@ TEST_F(WgslGeneratorImplTest, create(var), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kCompute), }); } @@ -226,7 +226,7 @@ TEST_F(WgslGeneratorImplTest, create(var), create(), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kCompute), }); } diff --git a/src/writer/wgsl/generator_impl_global_decl_test.cc b/src/writer/wgsl/generator_impl_global_decl_test.cc index 9c74d156672..19f2bdbe6b9 100644 --- a/src/writer/wgsl/generator_impl_global_decl_test.cc +++ b/src/writer/wgsl/generator_impl_global_decl_test.cc @@ -48,7 +48,7 @@ TEST_F(WgslGeneratorImplTest, Emit_GlobalsInterleaved) { create(global0); auto* str0 = create(ast::StructMemberList{Member("a", ty.i32())}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s0 = ty.struct_("S0", str0); AST().AddConstructedType(s0); @@ -56,13 +56,13 @@ TEST_F(WgslGeneratorImplTest, Emit_GlobalsInterleaved) { ast::StatementList{ create(Expr("a0")), }, - ast::FunctionDecorationList{}); + ast::DecorationList{}); auto* global1 = Global("a1", ty.f32(), ast::StorageClass::kOutput); create(global1); auto* str1 = create(ast::StructMemberList{Member("a", ty.i32())}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s1 = ty.struct_("S1", str1); AST().AddConstructedType(s1); @@ -76,7 +76,7 @@ TEST_F(WgslGeneratorImplTest, Emit_GlobalsInterleaved) { Var("s1", s1, ast::StorageClass::kFunction)), create(Expr("a1"), Expr(call_func)), }, - ast::FunctionDecorationList{ + ast::DecorationList{ create(ast::PipelineStage::kCompute), }); diff --git a/src/writer/wgsl/generator_impl_test.cc b/src/writer/wgsl/generator_impl_test.cc index 695ddc485a2..515c8b7af20 100644 --- a/src/writer/wgsl/generator_impl_test.cc +++ b/src/writer/wgsl/generator_impl_test.cc @@ -24,7 +24,7 @@ using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, Generate) { Func("my_func", ast::VariableList{}, ty.void_(), ast::StatementList{}, - ast::FunctionDecorationList{}); + ast::DecorationList{}); GeneratorImpl& gen = Build(); @@ -47,7 +47,7 @@ TEST_P(WgslBuiltinConversionTest, Emit) { auto params = GetParam(); auto* var = Global("a", ty.f32(), ast::StorageClass::kNone, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(params.builtin), }); diff --git a/src/writer/wgsl/generator_impl_type_test.cc b/src/writer/wgsl/generator_impl_type_test.cc index 8b1b49888b8..0bd2acf402a 100644 --- a/src/writer/wgsl/generator_impl_type_test.cc +++ b/src/writer/wgsl/generator_impl_type_test.cc @@ -46,7 +46,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Array) { TEST_F(WgslGeneratorImplTest, EmitType_AccessControl_Read) { auto* block_deco = create(); - ast::StructDecorationList decos; + ast::DecorationList decos; decos.push_back(block_deco); auto* str = @@ -63,7 +63,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_AccessControl_Read) { TEST_F(WgslGeneratorImplTest, EmitType_AccessControl_ReadWrite) { auto* block_deco = create(); - ast::StructDecorationList decos; + ast::DecorationList decos; decos.push_back(block_deco); auto* str = @@ -80,7 +80,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_AccessControl_ReadWrite) { TEST_F(WgslGeneratorImplTest, EmitType_Array_Decoration) { type::Array a(ty.bool_(), 4, - ast::ArrayDecorationList{ + ast::DecorationList{ create(16u), }); @@ -92,7 +92,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Array_Decoration) { TEST_F(WgslGeneratorImplTest, EmitType_Array_MultipleDecorations) { type::Array a(ty.bool_(), 4, - ast::ArrayDecorationList{ + ast::DecorationList{ create(16u), create(32u), }); @@ -104,7 +104,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Array_MultipleDecorations) { } TEST_F(WgslGeneratorImplTest, EmitType_RuntimeArray) { - type::Array a(ty.bool_(), 0, ast::ArrayDecorationList{}); + type::Array a(ty.bool_(), 0, ast::DecorationList{}); GeneratorImpl& gen = Build(); @@ -161,7 +161,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Struct) { auto* str = create( ast::StructMemberList{Member("a", ty.i32()), Member("b", ty.f32(), {MemberOffset(4)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("S", str); GeneratorImpl& gen = Build(); @@ -174,7 +174,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_StructDecl) { auto* str = create( ast::StructMemberList{Member("a", ty.i32()), Member("b", ty.f32(), {MemberOffset(4)})}, - ast::StructDecorationList{}); + ast::DecorationList{}); auto* s = ty.struct_("S", str); GeneratorImpl& gen = Build(); @@ -189,7 +189,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_StructDecl) { } TEST_F(WgslGeneratorImplTest, EmitType_Struct_WithDecoration) { - ast::StructDecorationList decos; + ast::DecorationList decos; decos.push_back(create()); auto* str = create( diff --git a/src/writer/wgsl/generator_impl_variable_test.cc b/src/writer/wgsl/generator_impl_variable_test.cc index 598f2625481..b80d4bfd39d 100644 --- a/src/writer/wgsl/generator_impl_variable_test.cc +++ b/src/writer/wgsl/generator_impl_variable_test.cc @@ -44,7 +44,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_StorageClass) { TEST_F(WgslGeneratorImplTest, EmitVariable_Decorated) { auto* v = Global("a", ty.f32(), ast::StorageClass::kNone, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(2), }); @@ -57,7 +57,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Decorated) { TEST_F(WgslGeneratorImplTest, EmitVariable_Decorated_Multiple) { auto* v = Global("a", ty.f32(), ast::StorageClass::kNone, nullptr, - ast::VariableDecorationList{ + ast::DecorationList{ create(ast::Builtin::kPosition), create(0), create(1),