Remove the RowMajorAttribute from the AST
This attribute is no longer needed with the AST spirv-reader removed.
Bug: 42250952
Change-Id: Ib51dfd4d991412e1ace5bf024e8e65c8218cfa95
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/258282
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
diff --git a/src/tint/lang/wgsl/ast/BUILD.bazel b/src/tint/lang/wgsl/ast/BUILD.bazel
index 5f001e7..4313747 100644
--- a/src/tint/lang/wgsl/ast/BUILD.bazel
+++ b/src/tint/lang/wgsl/ast/BUILD.bazel
@@ -99,7 +99,6 @@
"pipeline_stage.cc",
"requires.cc",
"return_statement.cc",
- "row_major_attribute.cc",
"stage_attribute.cc",
"statement.cc",
"stride_attribute.cc",
@@ -181,7 +180,6 @@
"pipeline_stage.h",
"requires.h",
"return_statement.h",
- "row_major_attribute.h",
"stage_attribute.h",
"statement.h",
"stride_attribute.h",
diff --git a/src/tint/lang/wgsl/ast/BUILD.cmake b/src/tint/lang/wgsl/ast/BUILD.cmake
index 5d44c3c..c9ab39b 100644
--- a/src/tint/lang/wgsl/ast/BUILD.cmake
+++ b/src/tint/lang/wgsl/ast/BUILD.cmake
@@ -160,8 +160,6 @@
lang/wgsl/ast/requires.h
lang/wgsl/ast/return_statement.cc
lang/wgsl/ast/return_statement.h
- lang/wgsl/ast/row_major_attribute.cc
- lang/wgsl/ast/row_major_attribute.h
lang/wgsl/ast/stage_attribute.cc
lang/wgsl/ast/stage_attribute.h
lang/wgsl/ast/statement.cc
diff --git a/src/tint/lang/wgsl/ast/BUILD.gn b/src/tint/lang/wgsl/ast/BUILD.gn
index 897abb8..dd66cb6 100644
--- a/src/tint/lang/wgsl/ast/BUILD.gn
+++ b/src/tint/lang/wgsl/ast/BUILD.gn
@@ -166,8 +166,6 @@
"requires.h",
"return_statement.cc",
"return_statement.h",
- "row_major_attribute.cc",
- "row_major_attribute.h",
"stage_attribute.cc",
"stage_attribute.h",
"statement.cc",
diff --git a/src/tint/lang/wgsl/ast/builder.h b/src/tint/lang/wgsl/ast/builder.h
index 06ee086..16ffecb 100644
--- a/src/tint/lang/wgsl/ast/builder.h
+++ b/src/tint/lang/wgsl/ast/builder.h
@@ -83,7 +83,6 @@
#include "src/tint/lang/wgsl/ast/phony_expression.h"
#include "src/tint/lang/wgsl/ast/requires.h"
#include "src/tint/lang/wgsl/ast/return_statement.h"
-#include "src/tint/lang/wgsl/ast/row_major_attribute.h"
#include "src/tint/lang/wgsl/ast/stage_attribute.h"
#include "src/tint/lang/wgsl/ast/stride_attribute.h"
#include "src/tint/lang/wgsl/ast/struct.h"
@@ -3375,17 +3374,6 @@
Expr(std::forward<EXPR_Z>(z)));
}
- /// Creates an ast::RowMajorAttribute
- /// @param source the source information
- /// @returns the row-major attribute pointer
- const ast::RowMajorAttribute* RowMajor(const Source& source) {
- return create<ast::RowMajorAttribute>(source);
- }
-
- /// Creates an ast::RowMajorAttribute
- /// @returns the row-major attribute pointer
- const ast::RowMajorAttribute* RowMajor() { return create<ast::RowMajorAttribute>(source_); }
-
/// Creates an ast::DisableValidationAttribute
/// @param validation the validation to disable
/// @returns the disable validation attribute pointer
diff --git a/src/tint/lang/wgsl/ast/row_major_attribute.cc b/src/tint/lang/wgsl/ast/row_major_attribute.cc
deleted file mode 100644
index e7f683b..0000000
--- a/src/tint/lang/wgsl/ast/row_major_attribute.cc
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2024 The Dawn & Tint Authors
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// 1. Redistributions of source code must retain the above copyright notice, this
-// list of conditions and the following disclaimer.
-//
-// 2. Redistributions in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// 3. Neither the name of the copyright holder nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#include "src/tint/lang/wgsl/ast/row_major_attribute.h"
-
-#include "src/tint/lang/wgsl/ast/builder.h"
-
-TINT_INSTANTIATE_TYPEINFO(tint::ast::RowMajorAttribute);
-
-namespace tint::ast {
-
-RowMajorAttribute::RowMajorAttribute(GenerationID pid, NodeID nid, const Source& src)
- : Base(pid, nid, src) {}
-
-RowMajorAttribute::~RowMajorAttribute() = default;
-
-std::string RowMajorAttribute::Name() const {
- return "row_major";
-}
-
-} // namespace tint::ast
diff --git a/src/tint/lang/wgsl/ast/row_major_attribute.h b/src/tint/lang/wgsl/ast/row_major_attribute.h
deleted file mode 100644
index 9084004..0000000
--- a/src/tint/lang/wgsl/ast/row_major_attribute.h
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright 2024 The Dawn & Tint Authors
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// 1. Redistributions of source code must retain the above copyright notice, this
-// list of conditions and the following disclaimer.
-//
-// 2. Redistributions in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// 3. Neither the name of the copyright holder nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#ifndef SRC_TINT_LANG_WGSL_AST_ROW_MAJOR_ATTRIBUTE_H_
-#define SRC_TINT_LANG_WGSL_AST_ROW_MAJOR_ATTRIBUTE_H_
-
-#include <string>
-
-#include "src/tint/lang/wgsl/ast/attribute.h"
-
-namespace tint::ast {
-
-/// The row_major attribute
-class RowMajorAttribute final : public Castable<RowMajorAttribute, Attribute> {
- public:
- /// constructor
- /// @param pid the identifier of the program that owns this node
- /// @param nid the unique node identifier
- /// @param src the source of this node
- RowMajorAttribute(GenerationID pid, NodeID nid, const Source& src);
- ~RowMajorAttribute() override;
-
- /// @returns the WGSL name for the attribute
- std::string Name() const override;
-};
-
-} // namespace tint::ast
-
-#endif // SRC_TINT_LANG_WGSL_AST_ROW_MAJOR_ATTRIBUTE_H_
diff --git a/src/tint/lang/wgsl/resolver/attribute_validation_test.cc b/src/tint/lang/wgsl/resolver/attribute_validation_test.cc
index b8fb751..85c16d9 100644
--- a/src/tint/lang/wgsl/resolver/attribute_validation_test.cc
+++ b/src/tint/lang/wgsl/resolver/attribute_validation_test.cc
@@ -2899,57 +2899,6 @@
} // namespace
} // namespace InternalAttributeDeps
-namespace RowMajorAttributeTests {
-
-using RowMajorAttributeTest = ResolverTest;
-
-TEST_F(RowMajorAttributeTest, StructMember_Matrix) {
- Structure("S", Vector{
- Member(Source{{12, 34}}, "m", ty.mat3x4<f32>(), Vector{RowMajor()}),
- });
-
- EXPECT_TRUE(r()->Resolve()) << r()->error();
-}
-
-TEST_F(RowMajorAttributeTest, StructMember_ArrayOfMatrix) {
- Structure("S",
- Vector{
- Member(Source{{12, 34}}, "arr", ty.array<mat3x4<f32>, 4>(), Vector{RowMajor()}),
- });
-
- EXPECT_TRUE(r()->Resolve()) << r()->error();
-}
-
-TEST_F(RowMajorAttributeTest, StructMember_NonMatrix) {
- Structure("S", Vector{
- Member(Source{{12, 34}}, "f", ty.vec4<f32>(), Vector{RowMajor()}),
- });
-
- EXPECT_FALSE(r()->Resolve());
- EXPECT_EQ(r()->error(),
- R"(error: '@row_major' can only be applied to matrices or arrays of matrices)");
-}
-
-TEST_F(RowMajorAttributeTest, StructMember_ArrayOfNonMatrix) {
- Structure("S",
- Vector{
- Member(Source{{12, 34}}, "arr", ty.array<vec4<f32>, 4>(), Vector{RowMajor()}),
- });
-
- EXPECT_FALSE(r()->Resolve());
- EXPECT_EQ(r()->error(),
- R"(error: '@row_major' can only be applied to matrices or arrays of matrices)");
-}
-
-TEST_F(RowMajorAttributeTest, Variable) {
- GlobalVar(Source{{12, 34}}, "v", ty.mat3x4<f32>(), Vector{RowMajor()});
-
- EXPECT_FALSE(r()->Resolve());
- EXPECT_EQ(r()->error(), R"(error: '@row_major' is not valid for module-scope 'var')");
-}
-
-} // namespace RowMajorAttributeTests
-
} // namespace tint::resolver
TINT_INSTANTIATE_TYPEINFO(tint::resolver::InternalAttributeDeps::TestAttribute);
diff --git a/src/tint/lang/wgsl/resolver/dependency_graph.cc b/src/tint/lang/wgsl/resolver/dependency_graph.cc
index f9d7965..6bd35e8 100644
--- a/src/tint/lang/wgsl/resolver/dependency_graph.cc
+++ b/src/tint/lang/wgsl/resolver/dependency_graph.cc
@@ -61,7 +61,6 @@
#include "src/tint/lang/wgsl/ast/must_use_attribute.h"
#include "src/tint/lang/wgsl/ast/override.h"
#include "src/tint/lang/wgsl/ast/return_statement.h"
-#include "src/tint/lang/wgsl/ast/row_major_attribute.h"
#include "src/tint/lang/wgsl/ast/stage_attribute.h"
#include "src/tint/lang/wgsl/ast/stride_attribute.h"
#include "src/tint/lang/wgsl/ast/struct.h"
@@ -397,8 +396,7 @@
[&](Default) {
if (!attr->IsAnyOf<ast::BuiltinAttribute, ast::DiagnosticAttribute,
ast::InterpolateAttribute, ast::InvariantAttribute,
- ast::MustUseAttribute, ast::RowMajorAttribute,
- ast::StageAttribute, ast::StrideAttribute,
+ ast::MustUseAttribute, ast::StageAttribute, ast::StrideAttribute,
ast::StructMemberOffsetAttribute>()) {
TINT_ICE() << "unhandled attribute type: " << attr->TypeInfo().name;
}
diff --git a/src/tint/lang/wgsl/resolver/resolver.cc b/src/tint/lang/wgsl/resolver/resolver.cc
index 0b25077..46aac9e 100644
--- a/src/tint/lang/wgsl/resolver/resolver.cc
+++ b/src/tint/lang/wgsl/resolver/resolver.cc
@@ -70,7 +70,6 @@
#include "src/tint/lang/wgsl/ast/interpolate_attribute.h"
#include "src/tint/lang/wgsl/ast/loop_statement.h"
#include "src/tint/lang/wgsl/ast/return_statement.h"
-#include "src/tint/lang/wgsl/ast/row_major_attribute.h"
#include "src/tint/lang/wgsl/ast/switch_statement.h"
#include "src/tint/lang/wgsl/ast/traverse_expressions.h"
#include "src/tint/lang/wgsl/ast/unary_op_expression.h"
@@ -4507,19 +4506,6 @@
attributes.invariant = true;
return true;
},
- [&](const ast::RowMajorAttribute* attr) {
- const auto* element_type = type;
- while (auto* arr = element_type->As<core::type::Array>()) {
- element_type = arr->ElemType();
- }
- if (!element_type->Is<core::type::Matrix>()) {
- AddError(attr->source)
- << style::Attribute("@row_major")
- << " can only be applied to matrices or arrays of matrices";
- return false;
- }
- return true;
- },
[&](const ast::StrideAttribute* attr) {
if (validator_.IsValidationEnabled(
member->attributes, ast::DisabledValidation::kIgnoreStrideAttribute)) {
diff --git a/src/tint/lang/wgsl/writer/ast_printer/ast_printer.cc b/src/tint/lang/wgsl/writer/ast_printer/ast_printer.cc
index d568bc9..e30676a 100644
--- a/src/tint/lang/wgsl/writer/ast_printer/ast_printer.cc
+++ b/src/tint/lang/wgsl/writer/ast_printer/ast_printer.cc
@@ -68,7 +68,6 @@
#include "src/tint/lang/wgsl/ast/override.h"
#include "src/tint/lang/wgsl/ast/phony_expression.h"
#include "src/tint/lang/wgsl/ast/return_statement.h"
-#include "src/tint/lang/wgsl/ast/row_major_attribute.h"
#include "src/tint/lang/wgsl/ast/stage_attribute.h"
#include "src/tint/lang/wgsl/ast/stride_attribute.h"
#include "src/tint/lang/wgsl/ast/struct_member_align_attribute.h"
@@ -557,7 +556,6 @@
out << ")";
},
[&](const ast::MustUseAttribute*) { out << "must_use"; },
- [&](const ast::RowMajorAttribute*) { out << "row_major"; },
[&](const ast::StructMemberOffsetAttribute* offset) {
out << "offset(";
EmitExpression(out, offset->expr);