tint/ast: Generate ast::Extension from intrinsics.def
Emit unit tests for parsing and printing.
Emit benchmarks for parsing.
Uses intrinsics.def as a single-source-of-truth.
The generators provide a way to optimize the enum parsers.
Change-Id: I7f13128f510b2156c2ef724c89df7bb85dae17ed
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97151
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt
index 3a80404..ccef6ee 100644
--- a/src/tint/CMakeLists.txt
+++ b/src/tint/CMakeLists.txt
@@ -1278,6 +1278,7 @@
set(TINT_BENCHMARK_SRC
"castable_bench.cc"
+ "ast/extension_bench.cc"
"ast/storage_class_bench.cc"
"bench/benchmark.cc"
"reader/wgsl/parser_bench.cc"
diff --git a/src/tint/ast/extension.cc b/src/tint/ast/extension.cc
index f03e3a0..4283df1 100644
--- a/src/tint/ast/extension.cc
+++ b/src/tint/ast/extension.cc
@@ -12,40 +12,46 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+////////////////////////////////////////////////////////////////////////////////
+// File generated by tools/src/cmd/gen
+// using the template:
+// src/tint/ast/extension.cc.tmpl
+//
+// Do not modify this file directly
+////////////////////////////////////////////////////////////////////////////////
+
#include "src/tint/ast/extension.h"
namespace tint::ast {
-Extension ParseExtension(const std::string& name) {
- if (name == "chromium_experimental_dp4a") {
- return Extension::kChromiumExperimentalDP4a;
- }
- if (name == "chromium_disable_uniformity_analysis") {
- return Extension::kChromiumDisableUniformityAnalysis;
- }
- if (name == "f16") {
+/// ParseExtension parses a Extension from a string.
+/// @param str the string to parse
+/// @returns the parsed enum, or Extension::kInvalid if the string could not be parsed.
+Extension ParseExtension(std::string_view str) {
+ if (str == "f16") {
return Extension::kF16;
}
- return Extension::kNone;
-}
-
-const char* str(Extension ext) {
- switch (ext) {
- case Extension::kChromiumExperimentalDP4a:
- return "chromium_experimental_dp4a";
- case Extension::kChromiumDisableUniformityAnalysis:
- return "chromium_disable_uniformity_analysis";
- case Extension::kF16:
- return "f16";
- case Extension::kNone:
- return "<none>";
+ if (str == "chromium_experimental_dp4a") {
+ return Extension::kChromiumExperimentalDp4A;
}
- return "<unknown>";
+ if (str == "chromium_disable_uniformity_analysis") {
+ return Extension::kChromiumDisableUniformityAnalysis;
+ }
+ return Extension::kInvalid;
}
-std::ostream& operator<<(std::ostream& out, Extension i) {
- out << str(i);
- return out;
+std::ostream& operator<<(std::ostream& out, Extension value) {
+ switch (value) {
+ case Extension::kInvalid:
+ return out << "invalid";
+ case Extension::kF16:
+ return out << "f16";
+ case Extension::kChromiumExperimentalDp4A:
+ return out << "chromium_experimental_dp4a";
+ case Extension::kChromiumDisableUniformityAnalysis:
+ return out << "chromium_disable_uniformity_analysis";
+ }
+ return out << "<unknown>";
}
} // namespace tint::ast
diff --git a/src/tint/ast/extension.cc.tmpl b/src/tint/ast/extension.cc.tmpl
new file mode 100644
index 0000000..e0f319e
--- /dev/null
+++ b/src/tint/ast/extension.cc.tmpl
@@ -0,0 +1,22 @@
+{{- /*
+--------------------------------------------------------------------------------
+Template file for use with tools/src/cmd/gen to generate extension.cc
+
+See:
+* tools/src/cmd/gen for structures used by this template
+* https://golang.org/pkg/text/template/ for documentation on the template syntax
+--------------------------------------------------------------------------------
+*/ -}}
+
+{{- Import "src/tint/templates/enums.tmpl.inc" -}}
+{{- $enum := (Sem.Enum "extension") -}}
+
+#include "src/tint/ast/extension.h"
+
+namespace tint::ast {
+
+{{ Eval "ParseEnum" $enum}}
+
+{{ Eval "EnumOStream" $enum}}
+
+} // namespace tint::ast
diff --git a/src/tint/ast/extension.h b/src/tint/ast/extension.h
index 21e9ac1..32bf507 100644
--- a/src/tint/ast/extension.h
+++ b/src/tint/ast/extension.h
@@ -12,53 +12,41 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+////////////////////////////////////////////////////////////////////////////////
+// File generated by tools/src/cmd/gen
+// using the template:
+// src/tint/ast/extension.h.tmpl
+//
+// Do not modify this file directly
+////////////////////////////////////////////////////////////////////////////////
+
#ifndef SRC_TINT_AST_EXTENSION_H_
#define SRC_TINT_AST_EXTENSION_H_
-#include <sstream>
-#include <string>
+#include <ostream>
#include "src/tint/utils/unique_vector.h"
namespace tint::ast {
/// An enumerator of WGSL extensions
+/// @see src/tint/intrinsics.def for extension descriptions
enum class Extension {
- /// WGSL Extension "f16"
+ kInvalid,
kF16,
-
- /// An extension for the experimental feature
- /// "chromium_experimental_dp4a".
- /// See crbug.com/tint/1497 for more details
- kChromiumExperimentalDP4a,
- /// A Chromium-specific extension for disabling uniformity analysis.
+ kChromiumExperimentalDp4A,
kChromiumDisableUniformityAnalysis,
-
- /// Reserved for representing "No extension required" or "Not a valid extension".
- kNone,
};
-/// Convert a string of extension name into one of Extension enum value, the result will be
-/// Extension::kNone if the name is not a known extension name. A extension node of kind
-/// kNone must not exist in the AST tree, and using a unknown extension name in WGSL code
-/// should result in a shader-creation error.
-/// @param name string of the extension name
-/// @return the Extension enum value for the extension of given name, or kNone if no known extension
-/// has the given name
-Extension ParseExtension(const std::string& name);
+/// @param out the std::ostream to write to
+/// @param value the Extension
+/// @returns `out` so calls can be chained
+std::ostream& operator<<(std::ostream& out, Extension value);
-/// Convert the Extension enum value to corresponding extension name string.
-/// @param ext the Extension enum value
-/// @return string of the extension name corresponding to the given kind, or
-/// an empty string if the given enum value is kNone or don't have a
-/// known corresponding name
-const char* ExtensionName(Extension ext);
-
-/// @returns the name of the extension.
-const char* str(Extension i);
-
-/// Emits the name of the extension type.
-std::ostream& operator<<(std::ostream& out, Extension i);
+/// ParseExtension parses a Extension from a string.
+/// @param str the string to parse
+/// @returns the parsed enum, or Extension::kInvalid if the string could not be parsed.
+Extension ParseExtension(std::string_view str);
// A unique vector of extensions
using Extensions = utils::UniqueVector<Extension>;
diff --git a/src/tint/ast/extension.h.tmpl b/src/tint/ast/extension.h.tmpl
new file mode 100644
index 0000000..395aeec
--- /dev/null
+++ b/src/tint/ast/extension.h.tmpl
@@ -0,0 +1,32 @@
+{{- /*
+--------------------------------------------------------------------------------
+Template file for use with tools/src/cmd/gen to generate extension.h
+
+See:
+* tools/src/cmd/gen for structures used by this template
+* https://golang.org/pkg/text/template/ for documentation on the template syntax
+--------------------------------------------------------------------------------
+*/ -}}
+
+{{- Import "src/tint/templates/enums.tmpl.inc" -}}
+{{- $enum := (Sem.Enum "extension") -}}
+
+#ifndef SRC_TINT_AST_EXTENSION_H_
+#define SRC_TINT_AST_EXTENSION_H_
+
+#include <ostream>
+
+#include "src/tint/utils/unique_vector.h"
+
+namespace tint::ast {
+
+/// An enumerator of WGSL extensions
+/// @see src/tint/intrinsics.def for extension descriptions
+{{ Eval "DeclareEnum" $enum}}
+
+// A unique vector of extensions
+using Extensions = utils::UniqueVector<Extension>;
+
+} // namespace tint::ast
+
+#endif // SRC_TINT_AST_EXTENSION_H_
diff --git a/src/tint/ast/extension_bench.cc b/src/tint/ast/extension_bench.cc
new file mode 100644
index 0000000..47787e3
--- /dev/null
+++ b/src/tint/ast/extension_bench.cc
@@ -0,0 +1,67 @@
+// Copyright 2022 The Tint Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// 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.
+
+////////////////////////////////////////////////////////////////////////////////
+// File generated by tools/src/cmd/gen
+// using the template:
+// src/tint/ast/extension_bench.cc.tmpl
+//
+// Do not modify this file directly
+////////////////////////////////////////////////////////////////////////////////
+
+#include "src/tint/ast/extension.h"
+
+#include <array>
+
+#include "benchmark/benchmark.h"
+
+namespace tint::ast {
+namespace {
+
+void ExtensionParser(::benchmark::State& state) {
+ std::array kStrings{
+ "cc6",
+ "s",
+ "HH6",
+ "f16",
+ "116",
+ "qJ6",
+ "f17ll",
+ "chromippHm_experqqmetal_dp4a",
+ "chrmium_expecimntal_dp4",
+ "chrmiumGexpebimental_dp4a",
+ "chromium_experimental_dp4a",
+ "chromium_exverimentiil_dp4a",
+ "chro8ium_experimenWWal_dp4a",
+ "chromiMm_eperimxxntal_dp4a",
+ "chXggmium_disable_uniformity_aalysis",
+ "Xhomiuu_disale_uniformity_analysis",
+ "chromium_3isable_uniformity_analysis",
+ "chromium_disable_uniformity_analysis",
+ "chromiuE_disable_uniformity_analysis",
+ "chromium_disable_uniTTormity_aPPalsis",
+ "ddhromium_disabexxuniformity_analysis",
+ };
+ for (auto _ : state) {
+ for (auto& str : kStrings) {
+ auto result = ParseExtension(str);
+ benchmark::DoNotOptimize(result);
+ }
+ }
+}
+
+BENCHMARK(ExtensionParser);
+
+} // namespace
+} // namespace tint::ast
diff --git a/src/tint/ast/extension_bench.cc.tmpl b/src/tint/ast/extension_bench.cc.tmpl
new file mode 100644
index 0000000..af3dc95
--- /dev/null
+++ b/src/tint/ast/extension_bench.cc.tmpl
@@ -0,0 +1,26 @@
+{{- /*
+--------------------------------------------------------------------------------
+Template file for use with tools/src/cmd/gen to generate extension_bench.cc
+
+See:
+* tools/src/cmd/gen for structures used by this template
+* https://golang.org/pkg/text/template/ for documentation on the template syntax
+--------------------------------------------------------------------------------
+*/ -}}
+
+{{- Import "src/tint/templates/enums.tmpl.inc" -}}
+{{- $enum := (Sem.Enum "extension") -}}
+
+#include "src/tint/ast/extension.h"
+
+#include <array>
+
+#include "benchmark/benchmark.h"
+
+namespace tint::ast {
+namespace {
+
+{{ Eval "BenchmarkParseEnum" $enum }}
+
+} // namespace
+} // namespace tint::ast
diff --git a/src/tint/ast/extension_test.cc b/src/tint/ast/extension_test.cc
index ed27674b..8c75613 100644
--- a/src/tint/ast/extension_test.cc
+++ b/src/tint/ast/extension_test.cc
@@ -1,4 +1,3 @@
-
// Copyright 2021 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,24 +12,75 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+////////////////////////////////////////////////////////////////////////////////
+// File generated by tools/src/cmd/gen
+// using the template:
+// src/tint/ast/extension_test.cc.tmpl
+//
+// Do not modify this file directly
+////////////////////////////////////////////////////////////////////////////////
+
#include "src/tint/ast/extension.h"
-#include "gtest/gtest.h"
+#include <string>
+
+#include "src/tint/ast/test_helper.h"
+#include "src/tint/utils/string.h"
namespace tint::ast {
namespace {
-TEST(ExtensionTest, NameToKind_InvalidName) {
- EXPECT_EQ(ParseExtension("f16"), Extension::kF16);
- EXPECT_EQ(ParseExtension(""), Extension::kNone);
- EXPECT_EQ(ParseExtension("__ImpossibleExtensionName"), Extension::kNone);
- EXPECT_EQ(ParseExtension("123"), Extension::kNone);
+namespace parse_print_tests {
+
+struct Case {
+ const char* string;
+ Extension value;
+};
+
+inline std::ostream& operator<<(std::ostream& out, Case c) {
+ return out << "'" << std::string(c.string) << "'";
}
-TEST(ExtensionTest, KindToName) {
- EXPECT_EQ(std::string(str(Extension::kF16)), "f16");
- EXPECT_EQ(std::string(str(Extension::kNone)), "<none>");
+static constexpr Case kValidCases[] = {
+ {"f16", Extension::kF16},
+ {"chromium_experimental_dp4a", Extension::kChromiumExperimentalDp4A},
+ {"chromium_disable_uniformity_analysis", Extension::kChromiumDisableUniformityAnalysis},
+};
+
+static constexpr Case kInvalidCases[] = {
+ {"cc6", Extension::kInvalid},
+ {"s", Extension::kInvalid},
+ {"HH6", Extension::kInvalid},
+ {"chro1ium_experimental_dp4a", Extension::kInvalid},
+ {"chrJmium_experiqqetal_dp4a", Extension::kInvalid},
+ {"chromium_experimenll77l_dp4a", Extension::kInvalid},
+ {"chromiumppdisableqquniformity_aalysHHs", Extension::kInvalid},
+ {"chromiu_disable_unifovmitc_analyi", Extension::kInvalid},
+ {"chromium_diable_uGbformity_analysis", Extension::kInvalid},
+};
+
+using ExtensionParseTest = testing::TestWithParam<Case>;
+
+TEST_P(ExtensionParseTest, Parse) {
+ const char* string = GetParam().string;
+ Extension expect = GetParam().value;
+ EXPECT_EQ(expect, ParseExtension(string));
}
+INSTANTIATE_TEST_SUITE_P(ValidCases, ExtensionParseTest, testing::ValuesIn(kValidCases));
+INSTANTIATE_TEST_SUITE_P(InvalidCases, ExtensionParseTest, testing::ValuesIn(kInvalidCases));
+
+using ExtensionPrintTest = testing::TestWithParam<Case>;
+
+TEST_P(ExtensionPrintTest, Print) {
+ Extension value = GetParam().value;
+ const char* expect = GetParam().string;
+ EXPECT_EQ(expect, utils::ToString(value));
+}
+
+INSTANTIATE_TEST_SUITE_P(ValidCases, ExtensionPrintTest, testing::ValuesIn(kValidCases));
+
+} // namespace parse_print_tests
+
} // namespace
} // namespace tint::ast
diff --git a/src/tint/ast/extension_test.cc.tmpl b/src/tint/ast/extension_test.cc.tmpl
new file mode 100644
index 0000000..8c7a6af
--- /dev/null
+++ b/src/tint/ast/extension_test.cc.tmpl
@@ -0,0 +1,27 @@
+{{- /*
+--------------------------------------------------------------------------------
+Template file for use with tools/src/cmd/gen to generate extension_test.cc
+
+See:
+* tools/src/cmd/gen for structures used by this template
+* https://golang.org/pkg/text/template/ for documentation on the template syntax
+--------------------------------------------------------------------------------
+*/ -}}
+
+{{- Import "src/tint/templates/enums.tmpl.inc" -}}
+{{- $enum := (Sem.Enum "extension") -}}
+
+#include "src/tint/ast/extension.h"
+
+#include <string>
+
+#include "src/tint/ast/test_helper.h"
+#include "src/tint/utils/string.h"
+
+namespace tint::ast {
+namespace {
+
+{{ Eval "TestParsePrintEnum" $enum}}
+
+} // namespace
+} // namespace tint::ast
diff --git a/src/tint/intrinsics.def b/src/tint/intrinsics.def
index 30bf8a8..c4b2313 100644
--- a/src/tint/intrinsics.def
+++ b/src/tint/intrinsics.def
@@ -23,6 +23,17 @@
// Enumerators //
////////////////////////////////////////////////////////////////////////////////
+// https://gpuweb.github.io/gpuweb/wgsl/#extension
+enum extension {
+ // WGSL Extension "f16"
+ f16
+ // An extension for the experimental feature "chromium_experimental_dp4a".
+ // See crbug.com/tint/1497 for more details
+ chromium_experimental_dp4a
+ // A Chromium-specific extension for disabling uniformity analysis.
+ chromium_disable_uniformity_analysis
+}
+
// https://gpuweb.github.io/gpuweb/wgsl/#storage-class
enum storage_class {
@internal none
diff --git a/src/tint/reader/wgsl/parser_impl.cc b/src/tint/reader/wgsl/parser_impl.cc
index 9830621..754b05e 100644
--- a/src/tint/reader/wgsl/parser_impl.cc
+++ b/src/tint/reader/wgsl/parser_impl.cc
@@ -418,7 +418,7 @@
}
auto extension = ast::ParseExtension(name.value);
- if (extension == ast::Extension::kNone) {
+ if (extension == ast::Extension::kInvalid) {
return add_error(name.source, "unsupported extension: '" + name.value + "'");
}
builder_.AST().AddEnable(create<ast::Enable>(name.source, extension));
diff --git a/src/tint/resolver/builtin_validation_test.cc b/src/tint/resolver/builtin_validation_test.cc
index 3737ae0..be7a23f 100644
--- a/src/tint/resolver/builtin_validation_test.cc
+++ b/src/tint/resolver/builtin_validation_test.cc
@@ -384,7 +384,7 @@
TEST_F(ResolverDP4aExtensionValidationTest, Dot4I8PackedWithExtension) {
// enable chromium_experimental_dp4a;
// fn func { return dot4I8Packed(1u, 2u); }
- Enable(ast::Extension::kChromiumExperimentalDP4a);
+ Enable(ast::Extension::kChromiumExperimentalDp4A);
Func("func", {}, ty.i32(),
{
@@ -412,7 +412,7 @@
TEST_F(ResolverDP4aExtensionValidationTest, Dot4U8PackedWithExtension) {
// enable chromium_experimental_dp4a;
// fn func { return dot4U8Packed(1u, 2u); }
- Enable(ast::Extension::kChromiumExperimentalDP4a);
+ Enable(ast::Extension::kChromiumExperimentalDp4A);
Func("func", {}, ty.u32(),
{
diff --git a/src/tint/resolver/intrinsic_table.inl b/src/tint/resolver/intrinsic_table.inl
index 91e03c3..6241a67 100644
--- a/src/tint/resolver/intrinsic_table.inl
+++ b/src/tint/resolver/intrinsic_table.inl
@@ -23,7 +23,7 @@
// clang-format off
/// TypeMatcher for 'type bool'
-/// @see src/tint/intrinsics.def:76:6
+/// @see src/tint/intrinsics.def:87:6
class Bool : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -50,7 +50,7 @@
}
/// TypeMatcher for 'type fa'
-/// @see src/tint/intrinsics.def:77:48
+/// @see src/tint/intrinsics.def:88:48
class Fa : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -79,7 +79,7 @@
}
/// TypeMatcher for 'type ia'
-/// @see src/tint/intrinsics.def:78:48
+/// @see src/tint/intrinsics.def:89:48
class Ia : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -108,7 +108,7 @@
}
/// TypeMatcher for 'type i32'
-/// @see src/tint/intrinsics.def:79:21
+/// @see src/tint/intrinsics.def:90:21
class I32 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -135,7 +135,7 @@
}
/// TypeMatcher for 'type u32'
-/// @see src/tint/intrinsics.def:80:21
+/// @see src/tint/intrinsics.def:91:21
class U32 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -162,7 +162,7 @@
}
/// TypeMatcher for 'type f32'
-/// @see src/tint/intrinsics.def:81:21
+/// @see src/tint/intrinsics.def:92:21
class F32 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -189,7 +189,7 @@
}
/// TypeMatcher for 'type f16'
-/// @see src/tint/intrinsics.def:82:21
+/// @see src/tint/intrinsics.def:93:21
class F16 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -216,7 +216,7 @@
}
/// TypeMatcher for 'type vec2'
-/// @see src/tint/intrinsics.def:83:6
+/// @see src/tint/intrinsics.def:94:6
class Vec2 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -249,7 +249,7 @@
}
/// TypeMatcher for 'type vec3'
-/// @see src/tint/intrinsics.def:84:6
+/// @see src/tint/intrinsics.def:95:6
class Vec3 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -282,7 +282,7 @@
}
/// TypeMatcher for 'type vec4'
-/// @see src/tint/intrinsics.def:85:6
+/// @see src/tint/intrinsics.def:96:6
class Vec4 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -315,7 +315,7 @@
}
/// TypeMatcher for 'type mat2x2'
-/// @see src/tint/intrinsics.def:86:6
+/// @see src/tint/intrinsics.def:97:6
class Mat2X2 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -348,7 +348,7 @@
}
/// TypeMatcher for 'type mat2x3'
-/// @see src/tint/intrinsics.def:87:6
+/// @see src/tint/intrinsics.def:98:6
class Mat2X3 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -381,7 +381,7 @@
}
/// TypeMatcher for 'type mat2x4'
-/// @see src/tint/intrinsics.def:88:6
+/// @see src/tint/intrinsics.def:99:6
class Mat2X4 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -414,7 +414,7 @@
}
/// TypeMatcher for 'type mat3x2'
-/// @see src/tint/intrinsics.def:89:6
+/// @see src/tint/intrinsics.def:100:6
class Mat3X2 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -447,7 +447,7 @@
}
/// TypeMatcher for 'type mat3x3'
-/// @see src/tint/intrinsics.def:90:6
+/// @see src/tint/intrinsics.def:101:6
class Mat3X3 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -480,7 +480,7 @@
}
/// TypeMatcher for 'type mat3x4'
-/// @see src/tint/intrinsics.def:91:6
+/// @see src/tint/intrinsics.def:102:6
class Mat3X4 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -513,7 +513,7 @@
}
/// TypeMatcher for 'type mat4x2'
-/// @see src/tint/intrinsics.def:92:6
+/// @see src/tint/intrinsics.def:103:6
class Mat4X2 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -546,7 +546,7 @@
}
/// TypeMatcher for 'type mat4x3'
-/// @see src/tint/intrinsics.def:93:6
+/// @see src/tint/intrinsics.def:104:6
class Mat4X3 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -579,7 +579,7 @@
}
/// TypeMatcher for 'type mat4x4'
-/// @see src/tint/intrinsics.def:94:6
+/// @see src/tint/intrinsics.def:105:6
class Mat4X4 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -612,7 +612,7 @@
}
/// TypeMatcher for 'type vec'
-/// @see src/tint/intrinsics.def:95:34
+/// @see src/tint/intrinsics.def:106:34
class Vec : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -653,7 +653,7 @@
}
/// TypeMatcher for 'type mat'
-/// @see src/tint/intrinsics.def:96:34
+/// @see src/tint/intrinsics.def:107:34
class Mat : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -700,7 +700,7 @@
}
/// TypeMatcher for 'type ptr'
-/// @see src/tint/intrinsics.def:97:6
+/// @see src/tint/intrinsics.def:108:6
class Ptr : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -745,7 +745,7 @@
}
/// TypeMatcher for 'type atomic'
-/// @see src/tint/intrinsics.def:98:6
+/// @see src/tint/intrinsics.def:109:6
class Atomic : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -778,7 +778,7 @@
}
/// TypeMatcher for 'type array'
-/// @see src/tint/intrinsics.def:99:6
+/// @see src/tint/intrinsics.def:110:6
class Array : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -811,7 +811,7 @@
}
/// TypeMatcher for 'type sampler'
-/// @see src/tint/intrinsics.def:100:6
+/// @see src/tint/intrinsics.def:111:6
class Sampler : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -838,7 +838,7 @@
}
/// TypeMatcher for 'type sampler_comparison'
-/// @see src/tint/intrinsics.def:101:6
+/// @see src/tint/intrinsics.def:112:6
class SamplerComparison : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -865,7 +865,7 @@
}
/// TypeMatcher for 'type texture_1d'
-/// @see src/tint/intrinsics.def:102:6
+/// @see src/tint/intrinsics.def:113:6
class Texture1D : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -898,7 +898,7 @@
}
/// TypeMatcher for 'type texture_2d'
-/// @see src/tint/intrinsics.def:103:6
+/// @see src/tint/intrinsics.def:114:6
class Texture2D : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -931,7 +931,7 @@
}
/// TypeMatcher for 'type texture_2d_array'
-/// @see src/tint/intrinsics.def:104:6
+/// @see src/tint/intrinsics.def:115:6
class Texture2DArray : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -964,7 +964,7 @@
}
/// TypeMatcher for 'type texture_3d'
-/// @see src/tint/intrinsics.def:105:6
+/// @see src/tint/intrinsics.def:116:6
class Texture3D : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -997,7 +997,7 @@
}
/// TypeMatcher for 'type texture_cube'
-/// @see src/tint/intrinsics.def:106:6
+/// @see src/tint/intrinsics.def:117:6
class TextureCube : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -1030,7 +1030,7 @@
}
/// TypeMatcher for 'type texture_cube_array'
-/// @see src/tint/intrinsics.def:107:6
+/// @see src/tint/intrinsics.def:118:6
class TextureCubeArray : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -1063,7 +1063,7 @@
}
/// TypeMatcher for 'type texture_multisampled_2d'
-/// @see src/tint/intrinsics.def:108:6
+/// @see src/tint/intrinsics.def:119:6
class TextureMultisampled2D : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -1096,7 +1096,7 @@
}
/// TypeMatcher for 'type texture_depth_2d'
-/// @see src/tint/intrinsics.def:109:6
+/// @see src/tint/intrinsics.def:120:6
class TextureDepth2D : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -1123,7 +1123,7 @@
}
/// TypeMatcher for 'type texture_depth_2d_array'
-/// @see src/tint/intrinsics.def:110:6
+/// @see src/tint/intrinsics.def:121:6
class TextureDepth2DArray : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -1150,7 +1150,7 @@
}
/// TypeMatcher for 'type texture_depth_cube'
-/// @see src/tint/intrinsics.def:111:6
+/// @see src/tint/intrinsics.def:122:6
class TextureDepthCube : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -1177,7 +1177,7 @@
}
/// TypeMatcher for 'type texture_depth_cube_array'
-/// @see src/tint/intrinsics.def:112:6
+/// @see src/tint/intrinsics.def:123:6
class TextureDepthCubeArray : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -1204,7 +1204,7 @@
}
/// TypeMatcher for 'type texture_depth_multisampled_2d'
-/// @see src/tint/intrinsics.def:113:6
+/// @see src/tint/intrinsics.def:124:6
class TextureDepthMultisampled2D : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -1231,7 +1231,7 @@
}
/// TypeMatcher for 'type texture_storage_1d'
-/// @see src/tint/intrinsics.def:114:6
+/// @see src/tint/intrinsics.def:125:6
class TextureStorage1D : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -1270,7 +1270,7 @@
}
/// TypeMatcher for 'type texture_storage_2d'
-/// @see src/tint/intrinsics.def:115:6
+/// @see src/tint/intrinsics.def:126:6
class TextureStorage2D : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -1309,7 +1309,7 @@
}
/// TypeMatcher for 'type texture_storage_2d_array'
-/// @see src/tint/intrinsics.def:116:6
+/// @see src/tint/intrinsics.def:127:6
class TextureStorage2DArray : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -1348,7 +1348,7 @@
}
/// TypeMatcher for 'type texture_storage_3d'
-/// @see src/tint/intrinsics.def:117:6
+/// @see src/tint/intrinsics.def:128:6
class TextureStorage3D : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -1387,7 +1387,7 @@
}
/// TypeMatcher for 'type texture_external'
-/// @see src/tint/intrinsics.def:118:6
+/// @see src/tint/intrinsics.def:129:6
class TextureExternal : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -1414,7 +1414,7 @@
}
/// TypeMatcher for 'type __modf_result'
-/// @see src/tint/intrinsics.def:120:6
+/// @see src/tint/intrinsics.def:131:6
class ModfResult : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -1441,7 +1441,7 @@
}
/// TypeMatcher for 'type __modf_result_vec'
-/// @see src/tint/intrinsics.def:121:39
+/// @see src/tint/intrinsics.def:132:39
class ModfResultVec : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -1476,7 +1476,7 @@
}
/// TypeMatcher for 'type __frexp_result'
-/// @see src/tint/intrinsics.def:122:6
+/// @see src/tint/intrinsics.def:133:6
class FrexpResult : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -1503,7 +1503,7 @@
}
/// TypeMatcher for 'type __frexp_result_vec'
-/// @see src/tint/intrinsics.def:123:40
+/// @see src/tint/intrinsics.def:134:40
class FrexpResultVec : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -1538,7 +1538,7 @@
}
/// TypeMatcher for 'type __atomic_compare_exchange_result'
-/// @see src/tint/intrinsics.def:125:6
+/// @see src/tint/intrinsics.def:136:6
class AtomicCompareExchangeResult : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
@@ -1571,7 +1571,7 @@
}
/// TypeMatcher for 'match abstract_or_scalar'
-/// @see src/tint/intrinsics.def:133:7
+/// @see src/tint/intrinsics.def:144:7
class AbstractOrScalar : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
@@ -1621,7 +1621,7 @@
}
/// TypeMatcher for 'match scalar'
-/// @see src/tint/intrinsics.def:134:7
+/// @see src/tint/intrinsics.def:145:7
class Scalar : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
@@ -1665,7 +1665,7 @@
}
/// TypeMatcher for 'match scalar_no_f32'
-/// @see src/tint/intrinsics.def:135:7
+/// @see src/tint/intrinsics.def:146:7
class ScalarNoF32 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
@@ -1706,7 +1706,7 @@
}
/// TypeMatcher for 'match scalar_no_f16'
-/// @see src/tint/intrinsics.def:136:7
+/// @see src/tint/intrinsics.def:147:7
class ScalarNoF16 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
@@ -1747,7 +1747,7 @@
}
/// TypeMatcher for 'match scalar_no_i32'
-/// @see src/tint/intrinsics.def:137:7
+/// @see src/tint/intrinsics.def:148:7
class ScalarNoI32 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
@@ -1788,7 +1788,7 @@
}
/// TypeMatcher for 'match scalar_no_u32'
-/// @see src/tint/intrinsics.def:138:7
+/// @see src/tint/intrinsics.def:149:7
class ScalarNoU32 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
@@ -1829,7 +1829,7 @@
}
/// TypeMatcher for 'match scalar_no_bool'
-/// @see src/tint/intrinsics.def:139:7
+/// @see src/tint/intrinsics.def:150:7
class ScalarNoBool : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
@@ -1870,7 +1870,7 @@
}
/// TypeMatcher for 'match fia_fi32_f16'
-/// @see src/tint/intrinsics.def:140:7
+/// @see src/tint/intrinsics.def:151:7
class FiaFi32F16 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
@@ -1914,7 +1914,7 @@
}
/// TypeMatcher for 'match fia_fiu32'
-/// @see src/tint/intrinsics.def:141:7
+/// @see src/tint/intrinsics.def:152:7
class FiaFiu32 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
@@ -1958,7 +1958,7 @@
}
/// TypeMatcher for 'match fa_f32'
-/// @see src/tint/intrinsics.def:142:7
+/// @see src/tint/intrinsics.def:153:7
class FaF32 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
@@ -1993,7 +1993,7 @@
}
/// TypeMatcher for 'match fa_f32_f16'
-/// @see src/tint/intrinsics.def:143:7
+/// @see src/tint/intrinsics.def:154:7
class FaF32F16 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
@@ -2031,7 +2031,7 @@
}
/// TypeMatcher for 'match ia_iu32'
-/// @see src/tint/intrinsics.def:144:7
+/// @see src/tint/intrinsics.def:155:7
class IaIu32 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
@@ -2069,7 +2069,7 @@
}
/// TypeMatcher for 'match fiu32_f16'
-/// @see src/tint/intrinsics.def:145:7
+/// @see src/tint/intrinsics.def:156:7
class Fiu32F16 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
@@ -2110,7 +2110,7 @@
}
/// TypeMatcher for 'match fiu32'
-/// @see src/tint/intrinsics.def:146:7
+/// @see src/tint/intrinsics.def:157:7
class Fiu32 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
@@ -2148,7 +2148,7 @@
}
/// TypeMatcher for 'match fi32_f16'
-/// @see src/tint/intrinsics.def:147:7
+/// @see src/tint/intrinsics.def:158:7
class Fi32F16 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
@@ -2186,7 +2186,7 @@
}
/// TypeMatcher for 'match fi32'
-/// @see src/tint/intrinsics.def:148:7
+/// @see src/tint/intrinsics.def:159:7
class Fi32 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
@@ -2221,7 +2221,7 @@
}
/// TypeMatcher for 'match f32_f16'
-/// @see src/tint/intrinsics.def:149:7
+/// @see src/tint/intrinsics.def:160:7
class F32F16 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
@@ -2256,7 +2256,7 @@
}
/// TypeMatcher for 'match iu32'
-/// @see src/tint/intrinsics.def:150:7
+/// @see src/tint/intrinsics.def:161:7
class Iu32 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
@@ -2291,7 +2291,7 @@
}
/// EnumMatcher for 'match f32_texel_format'
-/// @see src/tint/intrinsics.def:161:7
+/// @see src/tint/intrinsics.def:172:7
class F32TexelFormat : public NumberMatcher {
public:
/// Checks whether the given number matches the enum matcher rules.
@@ -2324,7 +2324,7 @@
}
/// EnumMatcher for 'match i32_texel_format'
-/// @see src/tint/intrinsics.def:168:7
+/// @see src/tint/intrinsics.def:179:7
class I32TexelFormat : public NumberMatcher {
public:
/// Checks whether the given number matches the enum matcher rules.
@@ -2356,7 +2356,7 @@
}
/// EnumMatcher for 'match u32_texel_format'
-/// @see src/tint/intrinsics.def:174:7
+/// @see src/tint/intrinsics.def:185:7
class U32TexelFormat : public NumberMatcher {
public:
/// Checks whether the given number matches the enum matcher rules.
@@ -2388,7 +2388,7 @@
}
/// EnumMatcher for 'match write'
-/// @see src/tint/intrinsics.def:181:7
+/// @see src/tint/intrinsics.def:192:7
class Write : public NumberMatcher {
public:
/// Checks whether the given number matches the enum matcher rules.
@@ -2414,7 +2414,7 @@
}
/// EnumMatcher for 'match read_write'
-/// @see src/tint/intrinsics.def:182:7
+/// @see src/tint/intrinsics.def:193:7
class ReadWrite : public NumberMatcher {
public:
/// Checks whether the given number matches the enum matcher rules.
@@ -2440,7 +2440,7 @@
}
/// EnumMatcher for 'match function_private_workgroup'
-/// @see src/tint/intrinsics.def:184:7
+/// @see src/tint/intrinsics.def:195:7
class FunctionPrivateWorkgroup : public NumberMatcher {
public:
/// Checks whether the given number matches the enum matcher rules.
@@ -2470,7 +2470,7 @@
}
/// EnumMatcher for 'match workgroup_or_storage'
-/// @see src/tint/intrinsics.def:188:7
+/// @see src/tint/intrinsics.def:199:7
class WorkgroupOrStorage : public NumberMatcher {
public:
/// Checks whether the given number matches the enum matcher rules.
@@ -2499,7 +2499,7 @@
}
/// EnumMatcher for 'match storage'
-/// @see src/tint/intrinsics.def:191:7
+/// @see src/tint/intrinsics.def:202:7
class Storage : public NumberMatcher {
public:
/// Checks whether the given number matches the enum matcher rules.
diff --git a/src/tint/resolver/validator.cc b/src/tint/resolver/validator.cc
index 834d275..c30e2b3 100644
--- a/src/tint/resolver/validator.cc
+++ b/src/tint/resolver/validator.cc
@@ -1708,13 +1708,13 @@
}
const auto extension = builtin->RequiredExtension();
- if (extension == ast::Extension::kNone) {
+ if (extension == ast::Extension::kInvalid) {
return true;
}
if (!enabled_extensions.contains(extension)) {
AddError("cannot call built-in function '" + std::string(builtin->str()) +
- "' without extension " + ast::str(extension),
+ "' without extension " + utils::ToString(extension),
call->Declaration()->source);
return false;
}
diff --git a/src/tint/sem/builtin.cc b/src/tint/sem/builtin.cc
index ee5a02b..7d0c56e 100644
--- a/src/tint/sem/builtin.cc
+++ b/src/tint/sem/builtin.cc
@@ -164,9 +164,9 @@
ast::Extension Builtin::RequiredExtension() const {
if (IsDP4a()) {
- return ast::Extension::kChromiumExperimentalDP4a;
+ return ast::Extension::kChromiumExperimentalDp4A;
}
- return ast::Extension::kNone;
+ return ast::Extension::kInvalid;
}
} // namespace tint::sem
diff --git a/src/tint/writer/hlsl/generator_impl_builtin_test.cc b/src/tint/writer/hlsl/generator_impl_builtin_test.cc
index d008ab8..008ea6c 100644
--- a/src/tint/writer/hlsl/generator_impl_builtin_test.cc
+++ b/src/tint/writer/hlsl/generator_impl_builtin_test.cc
@@ -725,7 +725,7 @@
}
TEST_F(HlslGeneratorImplTest_Builtin, Dot4I8Packed) {
- Enable(ast::Extension::kChromiumExperimentalDP4a);
+ Enable(ast::Extension::kChromiumExperimentalDp4A);
auto* val1 = Var("val1", ty.u32());
auto* val2 = Var("val2", ty.u32());
@@ -751,7 +751,7 @@
}
TEST_F(HlslGeneratorImplTest_Builtin, Dot4U8Packed) {
- Enable(ast::Extension::kChromiumExperimentalDP4a);
+ Enable(ast::Extension::kChromiumExperimentalDp4A);
auto* val1 = Var("val1", ty.u32());
auto* val2 = Var("val2", ty.u32());
diff --git a/src/tint/writer/spirv/builder.cc b/src/tint/writer/spirv/builder.cc
index 4737b54..5754f6b 100644
--- a/src/tint/writer/spirv/builder.cc
+++ b/src/tint/writer/spirv/builder.cc
@@ -380,7 +380,7 @@
bool Builder::GenerateExtension(ast::Extension extension) {
switch (extension) {
- case ast::Extension::kChromiumExperimentalDP4a:
+ case ast::Extension::kChromiumExperimentalDp4A:
push_extension("SPV_KHR_integer_dot_product");
push_capability(SpvCapabilityDotProductKHR);
push_capability(SpvCapabilityDotProductInput4x8BitPackedKHR);
diff --git a/src/tint/writer/spirv/builder_builtin_test.cc b/src/tint/writer/spirv/builder_builtin_test.cc
index f9f009d..4ed4826 100644
--- a/src/tint/writer/spirv/builder_builtin_test.cc
+++ b/src/tint/writer/spirv/builder_builtin_test.cc
@@ -2805,7 +2805,7 @@
TEST_F(BuiltinBuilderTest, Call_Dot4I8Packed) {
auto* ext =
create<ast::Enable>(Source{Source::Range{Source::Location{10, 2}, Source::Location{10, 5}}},
- ast::Extension::kChromiumExperimentalDP4a);
+ ast::Extension::kChromiumExperimentalDp4A);
AST().AddEnable(ext);
auto* val1 = Var("val1", ty.u32());
@@ -2845,7 +2845,7 @@
TEST_F(BuiltinBuilderTest, Call_Dot4U8Packed) {
auto* ext =
create<ast::Enable>(Source{Source::Range{Source::Location{10, 2}, Source::Location{10, 5}}},
- ast::Extension::kChromiumExperimentalDP4a);
+ ast::Extension::kChromiumExperimentalDp4A);
AST().AddEnable(ext);
auto* val1 = Var("val1", ty.u32());