[tint] Move core intrinsic table data to new subdir
Breaks a cyclic dependencies between src/tint/lang/core and sub-packages.
Also: Use PascalCase for the matcher / builder names to stick with the coding style.
Change-Id: I56c227222455836f7941fa9430abf4a710163bab
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/145522
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
diff --git a/src/tint/BUILD.gn b/src/tint/BUILD.gn
index 17968b9..17046b0 100644
--- a/src/tint/BUILD.gn
+++ b/src/tint/BUILD.gn
@@ -291,11 +291,11 @@
"lang/core/constant/eval.h",
"lang/core/intrinsic/ctor_conv.cc",
"lang/core/intrinsic/ctor_conv.h",
+ "lang/core/intrinsic/data/data.cc",
+ "lang/core/intrinsic/data/data.h",
+ "lang/core/intrinsic/data/type_matchers.h",
"lang/core/intrinsic/table.cc",
"lang/core/intrinsic/table.h",
- "lang/core/intrinsic_data.cc",
- "lang/core/intrinsic_data.h",
- "lang/core/intrinsic_type_matchers.h",
"lang/wgsl/program/clone_context.cc",
"lang/wgsl/program/program.cc",
"lang/wgsl/program/program_builder.cc",
diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt
index b8894b8..3358549 100644
--- a/src/tint/CMakeLists.txt
+++ b/src/tint/CMakeLists.txt
@@ -517,11 +517,11 @@
lang/core/constant/eval.h
lang/core/intrinsic/ctor_conv.cc
lang/core/intrinsic/ctor_conv.h
+ lang/core/intrinsic/data/data.cc
+ lang/core/intrinsic/data/data.h
+ lang/core/intrinsic/data/type_matchers.h
lang/core/intrinsic/table.cc
lang/core/intrinsic/table.h
- lang/core/intrinsic_data.cc
- lang/core/intrinsic_data.h
- lang/core/intrinsic_type_matchers.h
lang/wgsl/resolver/dependency_graph.cc
lang/wgsl/resolver/dependency_graph.h
lang/wgsl/resolver/resolve.cc
diff --git a/src/tint/lang/core/intrinsic_data.cc b/src/tint/lang/core/intrinsic/data/data.cc
similarity index 97%
rename from src/tint/lang/core/intrinsic_data.cc
rename to src/tint/lang/core/intrinsic/data/data.cc
index 40a1655..3c8c343 100644
--- a/src/tint/lang/core/intrinsic_data.cc
+++ b/src/tint/lang/core/intrinsic/data/data.cc
@@ -15,7 +15,7 @@
////////////////////////////////////////////////////////////////////////////////
// File generated by tools/src/cmd/gen
// using the template:
-// src/tint/lang/core/intrinsic_data.cc.tmpl
+// src/tint/lang/core/intrinsic/data/data.cc.tmpl
//
// Do not modify this file directly
////////////////////////////////////////////////////////////////////////////////
@@ -23,11 +23,12 @@
#include <limits>
#include <string>
-#include "src/tint/lang/core/intrinsic_data.h"
-#include "src/tint/lang/core/intrinsic_type_matchers.h"
+#include "src/tint/lang/core/intrinsic/data/data.h"
+#include "src/tint/lang/core/intrinsic/data/type_matchers.h"
#include "src/tint/utils/text/string_stream.h"
-namespace tint::core {
+namespace tint::core::intrinsic::data {
+
namespace {
using ConstEvalFunctionIndex = tint::core::intrinsic::ConstEvalFunctionIndex;
@@ -64,10 +65,10 @@
/// TypeMatcher for 'type bool'
constexpr TypeMatcher kBoolMatcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (!match_bool(state, ty)) {
+ if (!MatchBool(state, ty)) {
return nullptr;
}
- return build_bool(state);
+ return BuildBool(state);
},
/* string */ [](MatchState*) -> std::string {
return "bool";
@@ -78,10 +79,10 @@
/// TypeMatcher for 'type ia'
constexpr TypeMatcher kIaMatcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (!match_ia(state, ty)) {
+ if (!MatchIa(state, ty)) {
return nullptr;
}
- return build_ia(state);
+ return BuildIa(state);
},
/* string */ [](MatchState*) -> std::string {
StringStream ss;
@@ -94,10 +95,10 @@
/// TypeMatcher for 'type fa'
constexpr TypeMatcher kFaMatcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (!match_fa(state, ty)) {
+ if (!MatchFa(state, ty)) {
return nullptr;
}
- return build_fa(state);
+ return BuildFa(state);
},
/* string */ [](MatchState*) -> std::string {
StringStream ss;
@@ -110,10 +111,10 @@
/// TypeMatcher for 'type i32'
constexpr TypeMatcher kI32Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (!match_i32(state, ty)) {
+ if (!MatchI32(state, ty)) {
return nullptr;
}
- return build_i32(state);
+ return BuildI32(state);
},
/* string */ [](MatchState*) -> std::string {
return "i32";
@@ -124,10 +125,10 @@
/// TypeMatcher for 'type u32'
constexpr TypeMatcher kU32Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (!match_u32(state, ty)) {
+ if (!MatchU32(state, ty)) {
return nullptr;
}
- return build_u32(state);
+ return BuildU32(state);
},
/* string */ [](MatchState*) -> std::string {
return "u32";
@@ -138,10 +139,10 @@
/// TypeMatcher for 'type f32'
constexpr TypeMatcher kF32Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (!match_f32(state, ty)) {
+ if (!MatchF32(state, ty)) {
return nullptr;
}
- return build_f32(state);
+ return BuildF32(state);
},
/* string */ [](MatchState*) -> std::string {
return "f32";
@@ -152,10 +153,10 @@
/// TypeMatcher for 'type f16'
constexpr TypeMatcher kF16Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (!match_f16(state, ty)) {
+ if (!MatchF16(state, ty)) {
return nullptr;
}
- return build_f16(state);
+ return BuildF16(state);
},
/* string */ [](MatchState*) -> std::string {
return "f16";
@@ -167,14 +168,14 @@
constexpr TypeMatcher kVec2Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
const Type* T = nullptr;
- if (!match_vec2(state, ty, T)) {
+ if (!MatchVec2(state, ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
- return build_vec2(state, T);
+ return BuildVec2(state, T);
},
/* string */ [](MatchState* state) -> std::string {
const std::string T = state->TypeName();
@@ -187,14 +188,14 @@
constexpr TypeMatcher kVec3Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
const Type* T = nullptr;
- if (!match_vec3(state, ty, T)) {
+ if (!MatchVec3(state, ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
- return build_vec3(state, T);
+ return BuildVec3(state, T);
},
/* string */ [](MatchState* state) -> std::string {
const std::string T = state->TypeName();
@@ -207,14 +208,14 @@
constexpr TypeMatcher kVec4Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
const Type* T = nullptr;
- if (!match_vec4(state, ty, T)) {
+ if (!MatchVec4(state, ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
- return build_vec4(state, T);
+ return BuildVec4(state, T);
},
/* string */ [](MatchState* state) -> std::string {
const std::string T = state->TypeName();
@@ -227,14 +228,14 @@
constexpr TypeMatcher kMat2X2Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
const Type* T = nullptr;
- if (!match_mat2x2(state, ty, T)) {
+ if (!MatchMat2X2(state, ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
- return build_mat2x2(state, T);
+ return BuildMat2X2(state, T);
},
/* string */ [](MatchState* state) -> std::string {
const std::string T = state->TypeName();
@@ -247,14 +248,14 @@
constexpr TypeMatcher kMat2X3Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
const Type* T = nullptr;
- if (!match_mat2x3(state, ty, T)) {
+ if (!MatchMat2X3(state, ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
- return build_mat2x3(state, T);
+ return BuildMat2X3(state, T);
},
/* string */ [](MatchState* state) -> std::string {
const std::string T = state->TypeName();
@@ -267,14 +268,14 @@
constexpr TypeMatcher kMat2X4Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
const Type* T = nullptr;
- if (!match_mat2x4(state, ty, T)) {
+ if (!MatchMat2X4(state, ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
- return build_mat2x4(state, T);
+ return BuildMat2X4(state, T);
},
/* string */ [](MatchState* state) -> std::string {
const std::string T = state->TypeName();
@@ -287,14 +288,14 @@
constexpr TypeMatcher kMat3X2Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
const Type* T = nullptr;
- if (!match_mat3x2(state, ty, T)) {
+ if (!MatchMat3X2(state, ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
- return build_mat3x2(state, T);
+ return BuildMat3X2(state, T);
},
/* string */ [](MatchState* state) -> std::string {
const std::string T = state->TypeName();
@@ -307,14 +308,14 @@
constexpr TypeMatcher kMat3X3Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
const Type* T = nullptr;
- if (!match_mat3x3(state, ty, T)) {
+ if (!MatchMat3X3(state, ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
- return build_mat3x3(state, T);
+ return BuildMat3X3(state, T);
},
/* string */ [](MatchState* state) -> std::string {
const std::string T = state->TypeName();
@@ -327,14 +328,14 @@
constexpr TypeMatcher kMat3X4Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
const Type* T = nullptr;
- if (!match_mat3x4(state, ty, T)) {
+ if (!MatchMat3X4(state, ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
- return build_mat3x4(state, T);
+ return BuildMat3X4(state, T);
},
/* string */ [](MatchState* state) -> std::string {
const std::string T = state->TypeName();
@@ -347,14 +348,14 @@
constexpr TypeMatcher kMat4X2Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
const Type* T = nullptr;
- if (!match_mat4x2(state, ty, T)) {
+ if (!MatchMat4X2(state, ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
- return build_mat4x2(state, T);
+ return BuildMat4X2(state, T);
},
/* string */ [](MatchState* state) -> std::string {
const std::string T = state->TypeName();
@@ -367,14 +368,14 @@
constexpr TypeMatcher kMat4X3Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
const Type* T = nullptr;
- if (!match_mat4x3(state, ty, T)) {
+ if (!MatchMat4X3(state, ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
- return build_mat4x3(state, T);
+ return BuildMat4X3(state, T);
},
/* string */ [](MatchState* state) -> std::string {
const std::string T = state->TypeName();
@@ -387,14 +388,14 @@
constexpr TypeMatcher kMat4X4Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
const Type* T = nullptr;
- if (!match_mat4x4(state, ty, T)) {
+ if (!MatchMat4X4(state, ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
- return build_mat4x4(state, T);
+ return BuildMat4X4(state, T);
},
/* string */ [](MatchState* state) -> std::string {
const std::string T = state->TypeName();
@@ -408,7 +409,7 @@
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
Number N = Number::invalid;
const Type* T = nullptr;
- if (!match_vec(state, ty, N, T)) {
+ if (!MatchVec(state, ty, N, T)) {
return nullptr;
}
N = state.Num(N);
@@ -419,7 +420,7 @@
if (T == nullptr) {
return nullptr;
}
- return build_vec(state, N, T);
+ return BuildVec(state, N, T);
},
/* string */ [](MatchState* state) -> std::string {
const std::string N = state->NumName();
@@ -437,7 +438,7 @@
Number N = Number::invalid;
Number M = Number::invalid;
const Type* T = nullptr;
- if (!match_mat(state, ty, N, M, T)) {
+ if (!MatchMat(state, ty, N, M, T)) {
return nullptr;
}
N = state.Num(N);
@@ -452,7 +453,7 @@
if (T == nullptr) {
return nullptr;
}
- return build_mat(state, N, M, T);
+ return BuildMat(state, N, M, T);
},
/* string */ [](MatchState* state) -> std::string {
const std::string N = state->NumName();
@@ -471,7 +472,7 @@
Number S = Number::invalid;
const Type* T = nullptr;
Number A = Number::invalid;
- if (!match_ptr(state, ty, S, T, A)) {
+ if (!MatchPtr(state, ty, S, T, A)) {
return nullptr;
}
S = state.Num(S);
@@ -486,7 +487,7 @@
if (!A.IsValid()) {
return nullptr;
}
- return build_ptr(state, S, T, A);
+ return BuildPtr(state, S, T, A);
},
/* string */ [](MatchState* state) -> std::string {
const std::string S = state->NumName();
@@ -501,14 +502,14 @@
constexpr TypeMatcher kAtomicMatcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
const Type* T = nullptr;
- if (!match_atomic(state, ty, T)) {
+ if (!MatchAtomic(state, ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
- return build_atomic(state, T);
+ return BuildAtomic(state, T);
},
/* string */ [](MatchState* state) -> std::string {
const std::string T = state->TypeName();
@@ -521,14 +522,14 @@
constexpr TypeMatcher kArrayMatcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
const Type* T = nullptr;
- if (!match_array(state, ty, T)) {
+ if (!MatchArray(state, ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
- return build_array(state, T);
+ return BuildArray(state, T);
},
/* string */ [](MatchState* state) -> std::string {
const std::string T = state->TypeName();
@@ -540,10 +541,10 @@
/// TypeMatcher for 'type sampler'
constexpr TypeMatcher kSamplerMatcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (!match_sampler(state, ty)) {
+ if (!MatchSampler(state, ty)) {
return nullptr;
}
- return build_sampler(state);
+ return BuildSampler(state);
},
/* string */ [](MatchState*) -> std::string {
return "sampler";
@@ -554,10 +555,10 @@
/// TypeMatcher for 'type sampler_comparison'
constexpr TypeMatcher kSamplerComparisonMatcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (!match_sampler_comparison(state, ty)) {
+ if (!MatchSamplerComparison(state, ty)) {
return nullptr;
}
- return build_sampler_comparison(state);
+ return BuildSamplerComparison(state);
},
/* string */ [](MatchState*) -> std::string {
return "sampler_comparison";
@@ -569,14 +570,14 @@
constexpr TypeMatcher kTexture1DMatcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
const Type* T = nullptr;
- if (!match_texture_1d(state, ty, T)) {
+ if (!MatchTexture1D(state, ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
- return build_texture_1d(state, T);
+ return BuildTexture1D(state, T);
},
/* string */ [](MatchState* state) -> std::string {
const std::string T = state->TypeName();
@@ -589,14 +590,14 @@
constexpr TypeMatcher kTexture2DMatcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
const Type* T = nullptr;
- if (!match_texture_2d(state, ty, T)) {
+ if (!MatchTexture2D(state, ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
- return build_texture_2d(state, T);
+ return BuildTexture2D(state, T);
},
/* string */ [](MatchState* state) -> std::string {
const std::string T = state->TypeName();
@@ -609,14 +610,14 @@
constexpr TypeMatcher kTexture2DArrayMatcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
const Type* T = nullptr;
- if (!match_texture_2d_array(state, ty, T)) {
+ if (!MatchTexture2DArray(state, ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
- return build_texture_2d_array(state, T);
+ return BuildTexture2DArray(state, T);
},
/* string */ [](MatchState* state) -> std::string {
const std::string T = state->TypeName();
@@ -629,14 +630,14 @@
constexpr TypeMatcher kTexture3DMatcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
const Type* T = nullptr;
- if (!match_texture_3d(state, ty, T)) {
+ if (!MatchTexture3D(state, ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
- return build_texture_3d(state, T);
+ return BuildTexture3D(state, T);
},
/* string */ [](MatchState* state) -> std::string {
const std::string T = state->TypeName();
@@ -649,14 +650,14 @@
constexpr TypeMatcher kTextureCubeMatcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
const Type* T = nullptr;
- if (!match_texture_cube(state, ty, T)) {
+ if (!MatchTextureCube(state, ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
- return build_texture_cube(state, T);
+ return BuildTextureCube(state, T);
},
/* string */ [](MatchState* state) -> std::string {
const std::string T = state->TypeName();
@@ -669,14 +670,14 @@
constexpr TypeMatcher kTextureCubeArrayMatcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
const Type* T = nullptr;
- if (!match_texture_cube_array(state, ty, T)) {
+ if (!MatchTextureCubeArray(state, ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
- return build_texture_cube_array(state, T);
+ return BuildTextureCubeArray(state, T);
},
/* string */ [](MatchState* state) -> std::string {
const std::string T = state->TypeName();
@@ -689,14 +690,14 @@
constexpr TypeMatcher kTextureMultisampled2DMatcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
const Type* T = nullptr;
- if (!match_texture_multisampled_2d(state, ty, T)) {
+ if (!MatchTextureMultisampled2D(state, ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
- return build_texture_multisampled_2d(state, T);
+ return BuildTextureMultisampled2D(state, T);
},
/* string */ [](MatchState* state) -> std::string {
const std::string T = state->TypeName();
@@ -708,10 +709,10 @@
/// TypeMatcher for 'type texture_depth_2d'
constexpr TypeMatcher kTextureDepth2DMatcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (!match_texture_depth_2d(state, ty)) {
+ if (!MatchTextureDepth2D(state, ty)) {
return nullptr;
}
- return build_texture_depth_2d(state);
+ return BuildTextureDepth2D(state);
},
/* string */ [](MatchState*) -> std::string {
return "texture_depth_2d";
@@ -722,10 +723,10 @@
/// TypeMatcher for 'type texture_depth_2d_array'
constexpr TypeMatcher kTextureDepth2DArrayMatcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (!match_texture_depth_2d_array(state, ty)) {
+ if (!MatchTextureDepth2DArray(state, ty)) {
return nullptr;
}
- return build_texture_depth_2d_array(state);
+ return BuildTextureDepth2DArray(state);
},
/* string */ [](MatchState*) -> std::string {
return "texture_depth_2d_array";
@@ -736,10 +737,10 @@
/// TypeMatcher for 'type texture_depth_cube'
constexpr TypeMatcher kTextureDepthCubeMatcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (!match_texture_depth_cube(state, ty)) {
+ if (!MatchTextureDepthCube(state, ty)) {
return nullptr;
}
- return build_texture_depth_cube(state);
+ return BuildTextureDepthCube(state);
},
/* string */ [](MatchState*) -> std::string {
return "texture_depth_cube";
@@ -750,10 +751,10 @@
/// TypeMatcher for 'type texture_depth_cube_array'
constexpr TypeMatcher kTextureDepthCubeArrayMatcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (!match_texture_depth_cube_array(state, ty)) {
+ if (!MatchTextureDepthCubeArray(state, ty)) {
return nullptr;
}
- return build_texture_depth_cube_array(state);
+ return BuildTextureDepthCubeArray(state);
},
/* string */ [](MatchState*) -> std::string {
return "texture_depth_cube_array";
@@ -764,10 +765,10 @@
/// TypeMatcher for 'type texture_depth_multisampled_2d'
constexpr TypeMatcher kTextureDepthMultisampled2DMatcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (!match_texture_depth_multisampled_2d(state, ty)) {
+ if (!MatchTextureDepthMultisampled2D(state, ty)) {
return nullptr;
}
- return build_texture_depth_multisampled_2d(state);
+ return BuildTextureDepthMultisampled2D(state);
},
/* string */ [](MatchState*) -> std::string {
return "texture_depth_multisampled_2d";
@@ -780,7 +781,7 @@
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
Number F = Number::invalid;
Number A = Number::invalid;
- if (!match_texture_storage_1d(state, ty, F, A)) {
+ if (!MatchTextureStorage1D(state, ty, F, A)) {
return nullptr;
}
F = state.Num(F);
@@ -791,7 +792,7 @@
if (!A.IsValid()) {
return nullptr;
}
- return build_texture_storage_1d(state, F, A);
+ return BuildTextureStorage1D(state, F, A);
},
/* string */ [](MatchState* state) -> std::string {
const std::string F = state->NumName();
@@ -806,7 +807,7 @@
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
Number F = Number::invalid;
Number A = Number::invalid;
- if (!match_texture_storage_2d(state, ty, F, A)) {
+ if (!MatchTextureStorage2D(state, ty, F, A)) {
return nullptr;
}
F = state.Num(F);
@@ -817,7 +818,7 @@
if (!A.IsValid()) {
return nullptr;
}
- return build_texture_storage_2d(state, F, A);
+ return BuildTextureStorage2D(state, F, A);
},
/* string */ [](MatchState* state) -> std::string {
const std::string F = state->NumName();
@@ -832,7 +833,7 @@
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
Number F = Number::invalid;
Number A = Number::invalid;
- if (!match_texture_storage_2d_array(state, ty, F, A)) {
+ if (!MatchTextureStorage2DArray(state, ty, F, A)) {
return nullptr;
}
F = state.Num(F);
@@ -843,7 +844,7 @@
if (!A.IsValid()) {
return nullptr;
}
- return build_texture_storage_2d_array(state, F, A);
+ return BuildTextureStorage2DArray(state, F, A);
},
/* string */ [](MatchState* state) -> std::string {
const std::string F = state->NumName();
@@ -858,7 +859,7 @@
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
Number F = Number::invalid;
Number A = Number::invalid;
- if (!match_texture_storage_3d(state, ty, F, A)) {
+ if (!MatchTextureStorage3D(state, ty, F, A)) {
return nullptr;
}
F = state.Num(F);
@@ -869,7 +870,7 @@
if (!A.IsValid()) {
return nullptr;
}
- return build_texture_storage_3d(state, F, A);
+ return BuildTextureStorage3D(state, F, A);
},
/* string */ [](MatchState* state) -> std::string {
const std::string F = state->NumName();
@@ -882,10 +883,10 @@
/// TypeMatcher for 'type texture_external'
constexpr TypeMatcher kTextureExternalMatcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (!match_texture_external(state, ty)) {
+ if (!MatchTextureExternal(state, ty)) {
return nullptr;
}
- return build_texture_external(state);
+ return BuildTextureExternal(state);
},
/* string */ [](MatchState*) -> std::string {
return "texture_external";
@@ -897,14 +898,14 @@
constexpr TypeMatcher kPackedVec3Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
const Type* T = nullptr;
- if (!match_packedVec3(state, ty, T)) {
+ if (!MatchPackedVec3(state, ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
- return build_packedVec3(state, T);
+ return BuildPackedVec3(state, T);
},
/* string */ [](MatchState* state) -> std::string {
const std::string T = state->TypeName();
@@ -917,14 +918,14 @@
constexpr TypeMatcher kModfResultMatcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
const Type* T = nullptr;
- if (!match_modf_result(state, ty, T)) {
+ if (!MatchModfResult(state, ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
- return build_modf_result(state, T);
+ return BuildModfResult(state, T);
},
/* string */ [](MatchState* state) -> std::string {
const std::string T = state->TypeName();
@@ -940,7 +941,7 @@
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
Number N = Number::invalid;
const Type* T = nullptr;
- if (!match_modf_result_vec(state, ty, N, T)) {
+ if (!MatchModfResultVec(state, ty, N, T)) {
return nullptr;
}
N = state.Num(N);
@@ -951,7 +952,7 @@
if (T == nullptr) {
return nullptr;
}
- return build_modf_result_vec(state, N, T);
+ return BuildModfResultVec(state, N, T);
},
/* string */ [](MatchState* state) -> std::string {
const std::string N = state->NumName();
@@ -967,14 +968,14 @@
constexpr TypeMatcher kFrexpResultMatcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
const Type* T = nullptr;
- if (!match_frexp_result(state, ty, T)) {
+ if (!MatchFrexpResult(state, ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
- return build_frexp_result(state, T);
+ return BuildFrexpResult(state, T);
},
/* string */ [](MatchState* state) -> std::string {
const std::string T = state->TypeName();
@@ -990,7 +991,7 @@
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
Number N = Number::invalid;
const Type* T = nullptr;
- if (!match_frexp_result_vec(state, ty, N, T)) {
+ if (!MatchFrexpResultVec(state, ty, N, T)) {
return nullptr;
}
N = state.Num(N);
@@ -1001,7 +1002,7 @@
if (T == nullptr) {
return nullptr;
}
- return build_frexp_result_vec(state, N, T);
+ return BuildFrexpResultVec(state, N, T);
},
/* string */ [](MatchState* state) -> std::string {
const std::string N = state->NumName();
@@ -1017,14 +1018,14 @@
constexpr TypeMatcher kAtomicCompareExchangeResultMatcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
const Type* T = nullptr;
- if (!match_atomic_compare_exchange_result(state, ty, T)) {
+ if (!MatchAtomicCompareExchangeResult(state, ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
- return build_atomic_compare_exchange_result(state, T);
+ return BuildAtomicCompareExchangeResult(state, T);
},
/* string */ [](MatchState* state) -> std::string {
const std::string T = state->TypeName();
@@ -1036,26 +1037,26 @@
/// TypeMatcher for 'match scalar'
constexpr TypeMatcher kScalarMatcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (match_ia(state, ty)) {
- return build_ia(state);
+ if (MatchIa(state, ty)) {
+ return BuildIa(state);
}
- if (match_fa(state, ty)) {
- return build_fa(state);
+ if (MatchFa(state, ty)) {
+ return BuildFa(state);
}
- if (match_i32(state, ty)) {
- return build_i32(state);
+ if (MatchI32(state, ty)) {
+ return BuildI32(state);
}
- if (match_u32(state, ty)) {
- return build_u32(state);
+ if (MatchU32(state, ty)) {
+ return BuildU32(state);
}
- if (match_f32(state, ty)) {
- return build_f32(state);
+ if (MatchF32(state, ty)) {
+ return BuildF32(state);
}
- if (match_f16(state, ty)) {
- return build_f16(state);
+ if (MatchF16(state, ty)) {
+ return BuildF16(state);
}
- if (match_bool(state, ty)) {
- return build_bool(state);
+ if (MatchBool(state, ty)) {
+ return BuildBool(state);
}
return nullptr;
},
@@ -1071,20 +1072,20 @@
/// TypeMatcher for 'match concrete_scalar'
constexpr TypeMatcher kConcreteScalarMatcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (match_i32(state, ty)) {
- return build_i32(state);
+ if (MatchI32(state, ty)) {
+ return BuildI32(state);
}
- if (match_u32(state, ty)) {
- return build_u32(state);
+ if (MatchU32(state, ty)) {
+ return BuildU32(state);
}
- if (match_f32(state, ty)) {
- return build_f32(state);
+ if (MatchF32(state, ty)) {
+ return BuildF32(state);
}
- if (match_f16(state, ty)) {
- return build_f16(state);
+ if (MatchF16(state, ty)) {
+ return BuildF16(state);
}
- if (match_bool(state, ty)) {
- return build_bool(state);
+ if (MatchBool(state, ty)) {
+ return BuildBool(state);
}
return nullptr;
},
@@ -1100,23 +1101,23 @@
/// TypeMatcher for 'match scalar_no_f32'
constexpr TypeMatcher kScalarNoF32Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (match_ia(state, ty)) {
- return build_ia(state);
+ if (MatchIa(state, ty)) {
+ return BuildIa(state);
}
- if (match_fa(state, ty)) {
- return build_fa(state);
+ if (MatchFa(state, ty)) {
+ return BuildFa(state);
}
- if (match_i32(state, ty)) {
- return build_i32(state);
+ if (MatchI32(state, ty)) {
+ return BuildI32(state);
}
- if (match_u32(state, ty)) {
- return build_u32(state);
+ if (MatchU32(state, ty)) {
+ return BuildU32(state);
}
- if (match_f16(state, ty)) {
- return build_f16(state);
+ if (MatchF16(state, ty)) {
+ return BuildF16(state);
}
- if (match_bool(state, ty)) {
- return build_bool(state);
+ if (MatchBool(state, ty)) {
+ return BuildBool(state);
}
return nullptr;
},
@@ -1132,23 +1133,23 @@
/// TypeMatcher for 'match scalar_no_f16'
constexpr TypeMatcher kScalarNoF16Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (match_ia(state, ty)) {
- return build_ia(state);
+ if (MatchIa(state, ty)) {
+ return BuildIa(state);
}
- if (match_fa(state, ty)) {
- return build_fa(state);
+ if (MatchFa(state, ty)) {
+ return BuildFa(state);
}
- if (match_i32(state, ty)) {
- return build_i32(state);
+ if (MatchI32(state, ty)) {
+ return BuildI32(state);
}
- if (match_u32(state, ty)) {
- return build_u32(state);
+ if (MatchU32(state, ty)) {
+ return BuildU32(state);
}
- if (match_f32(state, ty)) {
- return build_f32(state);
+ if (MatchF32(state, ty)) {
+ return BuildF32(state);
}
- if (match_bool(state, ty)) {
- return build_bool(state);
+ if (MatchBool(state, ty)) {
+ return BuildBool(state);
}
return nullptr;
},
@@ -1164,23 +1165,23 @@
/// TypeMatcher for 'match scalar_no_i32'
constexpr TypeMatcher kScalarNoI32Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (match_ia(state, ty)) {
- return build_ia(state);
+ if (MatchIa(state, ty)) {
+ return BuildIa(state);
}
- if (match_fa(state, ty)) {
- return build_fa(state);
+ if (MatchFa(state, ty)) {
+ return BuildFa(state);
}
- if (match_u32(state, ty)) {
- return build_u32(state);
+ if (MatchU32(state, ty)) {
+ return BuildU32(state);
}
- if (match_f32(state, ty)) {
- return build_f32(state);
+ if (MatchF32(state, ty)) {
+ return BuildF32(state);
}
- if (match_f16(state, ty)) {
- return build_f16(state);
+ if (MatchF16(state, ty)) {
+ return BuildF16(state);
}
- if (match_bool(state, ty)) {
- return build_bool(state);
+ if (MatchBool(state, ty)) {
+ return BuildBool(state);
}
return nullptr;
},
@@ -1196,23 +1197,23 @@
/// TypeMatcher for 'match scalar_no_u32'
constexpr TypeMatcher kScalarNoU32Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (match_ia(state, ty)) {
- return build_ia(state);
+ if (MatchIa(state, ty)) {
+ return BuildIa(state);
}
- if (match_fa(state, ty)) {
- return build_fa(state);
+ if (MatchFa(state, ty)) {
+ return BuildFa(state);
}
- if (match_i32(state, ty)) {
- return build_i32(state);
+ if (MatchI32(state, ty)) {
+ return BuildI32(state);
}
- if (match_f32(state, ty)) {
- return build_f32(state);
+ if (MatchF32(state, ty)) {
+ return BuildF32(state);
}
- if (match_f16(state, ty)) {
- return build_f16(state);
+ if (MatchF16(state, ty)) {
+ return BuildF16(state);
}
- if (match_bool(state, ty)) {
- return build_bool(state);
+ if (MatchBool(state, ty)) {
+ return BuildBool(state);
}
return nullptr;
},
@@ -1228,23 +1229,23 @@
/// TypeMatcher for 'match scalar_no_bool'
constexpr TypeMatcher kScalarNoBoolMatcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (match_ia(state, ty)) {
- return build_ia(state);
+ if (MatchIa(state, ty)) {
+ return BuildIa(state);
}
- if (match_fa(state, ty)) {
- return build_fa(state);
+ if (MatchFa(state, ty)) {
+ return BuildFa(state);
}
- if (match_i32(state, ty)) {
- return build_i32(state);
+ if (MatchI32(state, ty)) {
+ return BuildI32(state);
}
- if (match_u32(state, ty)) {
- return build_u32(state);
+ if (MatchU32(state, ty)) {
+ return BuildU32(state);
}
- if (match_f32(state, ty)) {
- return build_f32(state);
+ if (MatchF32(state, ty)) {
+ return BuildF32(state);
}
- if (match_f16(state, ty)) {
- return build_f16(state);
+ if (MatchF16(state, ty)) {
+ return BuildF16(state);
}
return nullptr;
},
@@ -1260,23 +1261,23 @@
/// TypeMatcher for 'match fia_fiu32_f16'
constexpr TypeMatcher kFiaFiu32F16Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (match_ia(state, ty)) {
- return build_ia(state);
+ if (MatchIa(state, ty)) {
+ return BuildIa(state);
}
- if (match_fa(state, ty)) {
- return build_fa(state);
+ if (MatchFa(state, ty)) {
+ return BuildFa(state);
}
- if (match_i32(state, ty)) {
- return build_i32(state);
+ if (MatchI32(state, ty)) {
+ return BuildI32(state);
}
- if (match_u32(state, ty)) {
- return build_u32(state);
+ if (MatchU32(state, ty)) {
+ return BuildU32(state);
}
- if (match_f32(state, ty)) {
- return build_f32(state);
+ if (MatchF32(state, ty)) {
+ return BuildF32(state);
}
- if (match_f16(state, ty)) {
- return build_f16(state);
+ if (MatchF16(state, ty)) {
+ return BuildF16(state);
}
return nullptr;
},
@@ -1292,20 +1293,20 @@
/// TypeMatcher for 'match fia_fi32_f16'
constexpr TypeMatcher kFiaFi32F16Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (match_ia(state, ty)) {
- return build_ia(state);
+ if (MatchIa(state, ty)) {
+ return BuildIa(state);
}
- if (match_fa(state, ty)) {
- return build_fa(state);
+ if (MatchFa(state, ty)) {
+ return BuildFa(state);
}
- if (match_i32(state, ty)) {
- return build_i32(state);
+ if (MatchI32(state, ty)) {
+ return BuildI32(state);
}
- if (match_f32(state, ty)) {
- return build_f32(state);
+ if (MatchF32(state, ty)) {
+ return BuildF32(state);
}
- if (match_f16(state, ty)) {
- return build_f16(state);
+ if (MatchF16(state, ty)) {
+ return BuildF16(state);
}
return nullptr;
},
@@ -1321,20 +1322,20 @@
/// TypeMatcher for 'match fia_fiu32'
constexpr TypeMatcher kFiaFiu32Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (match_ia(state, ty)) {
- return build_ia(state);
+ if (MatchIa(state, ty)) {
+ return BuildIa(state);
}
- if (match_fa(state, ty)) {
- return build_fa(state);
+ if (MatchFa(state, ty)) {
+ return BuildFa(state);
}
- if (match_i32(state, ty)) {
- return build_i32(state);
+ if (MatchI32(state, ty)) {
+ return BuildI32(state);
}
- if (match_u32(state, ty)) {
- return build_u32(state);
+ if (MatchU32(state, ty)) {
+ return BuildU32(state);
}
- if (match_f32(state, ty)) {
- return build_f32(state);
+ if (MatchF32(state, ty)) {
+ return BuildF32(state);
}
return nullptr;
},
@@ -1350,11 +1351,11 @@
/// TypeMatcher for 'match fa_f32'
constexpr TypeMatcher kFaF32Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (match_fa(state, ty)) {
- return build_fa(state);
+ if (MatchFa(state, ty)) {
+ return BuildFa(state);
}
- if (match_f32(state, ty)) {
- return build_f32(state);
+ if (MatchF32(state, ty)) {
+ return BuildF32(state);
}
return nullptr;
},
@@ -1370,14 +1371,14 @@
/// TypeMatcher for 'match fa_f32_f16'
constexpr TypeMatcher kFaF32F16Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (match_fa(state, ty)) {
- return build_fa(state);
+ if (MatchFa(state, ty)) {
+ return BuildFa(state);
}
- if (match_f32(state, ty)) {
- return build_f32(state);
+ if (MatchF32(state, ty)) {
+ return BuildF32(state);
}
- if (match_f16(state, ty)) {
- return build_f16(state);
+ if (MatchF16(state, ty)) {
+ return BuildF16(state);
}
return nullptr;
},
@@ -1393,14 +1394,14 @@
/// TypeMatcher for 'match ia_iu32'
constexpr TypeMatcher kIaIu32Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (match_ia(state, ty)) {
- return build_ia(state);
+ if (MatchIa(state, ty)) {
+ return BuildIa(state);
}
- if (match_i32(state, ty)) {
- return build_i32(state);
+ if (MatchI32(state, ty)) {
+ return BuildI32(state);
}
- if (match_u32(state, ty)) {
- return build_u32(state);
+ if (MatchU32(state, ty)) {
+ return BuildU32(state);
}
return nullptr;
},
@@ -1416,11 +1417,11 @@
/// TypeMatcher for 'match ia_i32'
constexpr TypeMatcher kIaI32Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (match_ia(state, ty)) {
- return build_ia(state);
+ if (MatchIa(state, ty)) {
+ return BuildIa(state);
}
- if (match_i32(state, ty)) {
- return build_i32(state);
+ if (MatchI32(state, ty)) {
+ return BuildI32(state);
}
return nullptr;
},
@@ -1436,17 +1437,17 @@
/// TypeMatcher for 'match fiu32_f16'
constexpr TypeMatcher kFiu32F16Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (match_i32(state, ty)) {
- return build_i32(state);
+ if (MatchI32(state, ty)) {
+ return BuildI32(state);
}
- if (match_u32(state, ty)) {
- return build_u32(state);
+ if (MatchU32(state, ty)) {
+ return BuildU32(state);
}
- if (match_f32(state, ty)) {
- return build_f32(state);
+ if (MatchF32(state, ty)) {
+ return BuildF32(state);
}
- if (match_f16(state, ty)) {
- return build_f16(state);
+ if (MatchF16(state, ty)) {
+ return BuildF16(state);
}
return nullptr;
},
@@ -1462,14 +1463,14 @@
/// TypeMatcher for 'match fiu32'
constexpr TypeMatcher kFiu32Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (match_i32(state, ty)) {
- return build_i32(state);
+ if (MatchI32(state, ty)) {
+ return BuildI32(state);
}
- if (match_u32(state, ty)) {
- return build_u32(state);
+ if (MatchU32(state, ty)) {
+ return BuildU32(state);
}
- if (match_f32(state, ty)) {
- return build_f32(state);
+ if (MatchF32(state, ty)) {
+ return BuildF32(state);
}
return nullptr;
},
@@ -1485,14 +1486,14 @@
/// TypeMatcher for 'match fi32_f16'
constexpr TypeMatcher kFi32F16Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (match_i32(state, ty)) {
- return build_i32(state);
+ if (MatchI32(state, ty)) {
+ return BuildI32(state);
}
- if (match_f32(state, ty)) {
- return build_f32(state);
+ if (MatchF32(state, ty)) {
+ return BuildF32(state);
}
- if (match_f16(state, ty)) {
- return build_f16(state);
+ if (MatchF16(state, ty)) {
+ return BuildF16(state);
}
return nullptr;
},
@@ -1508,11 +1509,11 @@
/// TypeMatcher for 'match fi32'
constexpr TypeMatcher kFi32Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (match_i32(state, ty)) {
- return build_i32(state);
+ if (MatchI32(state, ty)) {
+ return BuildI32(state);
}
- if (match_f32(state, ty)) {
- return build_f32(state);
+ if (MatchF32(state, ty)) {
+ return BuildF32(state);
}
return nullptr;
},
@@ -1528,11 +1529,11 @@
/// TypeMatcher for 'match f32_f16'
constexpr TypeMatcher kF32F16Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (match_f32(state, ty)) {
- return build_f32(state);
+ if (MatchF32(state, ty)) {
+ return BuildF32(state);
}
- if (match_f16(state, ty)) {
- return build_f16(state);
+ if (MatchF16(state, ty)) {
+ return BuildF16(state);
}
return nullptr;
},
@@ -1548,11 +1549,11 @@
/// TypeMatcher for 'match iu32'
constexpr TypeMatcher kIu32Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
- if (match_i32(state, ty)) {
- return build_i32(state);
+ if (MatchI32(state, ty)) {
+ return BuildI32(state);
}
- if (match_u32(state, ty)) {
- return build_u32(state);
+ if (MatchU32(state, ty)) {
+ return BuildU32(state);
}
return nullptr;
},
@@ -11829,7 +11830,7 @@
} // anonymous namespace
-const core::intrinsic::TableData kIntrinsicData{
+const core::intrinsic::TableData kData{
/* template_types */ kTemplateTypes,
/* template_numbers */ kTemplateNumbers,
/* type_matcher_indices */ kTypeMatcherIndices,
@@ -11864,4 +11865,4 @@
/* unary_minus */ kUnaryOperators[kUnaryOperatorMinus],
};
-} // namespace tint::core
+} // namespace tint::core::intrinsic::data
diff --git a/src/tint/lang/core/intrinsic_data.cc.tmpl b/src/tint/lang/core/intrinsic/data/data.cc.tmpl
similarity index 73%
rename from src/tint/lang/core/intrinsic_data.cc.tmpl
rename to src/tint/lang/core/intrinsic/data/data.cc.tmpl
index 25d601d..0879608 100644
--- a/src/tint/lang/core/intrinsic_data.cc.tmpl
+++ b/src/tint/lang/core/intrinsic/data/data.cc.tmpl
@@ -19,8 +19,14 @@
#include <limits>
#include <string>
-#include "src/tint/lang/core/intrinsic_data.h"
-#include "src/tint/lang/core/intrinsic_type_matchers.h"
+#include "src/tint/lang/core/intrinsic/data/data.h"
+#include "src/tint/lang/core/intrinsic/data/type_matchers.h"
#include "src/tint/utils/text/string_stream.h"
-{{ Eval "Data" "Intrinsics" $I "Namespace" "tint::core" "Name" "kIntrinsicData" -}}
+namespace tint::core::intrinsic::data {
+
+{{ Eval "Data"
+ "Intrinsics" $I
+ "Name" "kData" -}}
+
+} // namespace tint::core::intrinsic::data
diff --git a/src/tint/lang/core/intrinsic_data.h b/src/tint/lang/core/intrinsic/data/data.h
similarity index 70%
rename from src/tint/lang/core/intrinsic_data.h
rename to src/tint/lang/core/intrinsic/data/data.h
index 7275126..8325e74 100644
--- a/src/tint/lang/core/intrinsic_data.h
+++ b/src/tint/lang/core/intrinsic/data/data.h
@@ -12,15 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_TINT_LANG_CORE_INTRINSIC_DATA_H_
-#define SRC_TINT_LANG_CORE_INTRINSIC_DATA_H_
+#ifndef SRC_TINT_LANG_CORE_INTRINSIC_DATA_DATA_H_
+#define SRC_TINT_LANG_CORE_INTRINSIC_DATA_DATA_H_
#include "src/tint/lang/core/intrinsic/table_data.h"
-namespace tint::core {
+namespace tint::core::intrinsic::data {
-extern const intrinsic::TableData kIntrinsicData;
+extern const TableData kData;
-} // namespace tint::core
+} // namespace tint::core::intrinsic::data
-#endif // SRC_TINT_LANG_CORE_INTRINSIC_DATA_H_
+#endif // SRC_TINT_LANG_CORE_INTRINSIC_DATA_DATA_H_
diff --git a/src/tint/lang/core/intrinsic/data/type_matchers.h b/src/tint/lang/core/intrinsic/data/type_matchers.h
new file mode 100644
index 0000000..c2beb3c
--- /dev/null
+++ b/src/tint/lang/core/intrinsic/data/type_matchers.h
@@ -0,0 +1,573 @@
+// Copyright 2023 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_TINT_LANG_CORE_INTRINSIC_DATA_TYPE_MATCHERS_H_
+#define SRC_TINT_LANG_CORE_INTRINSIC_DATA_TYPE_MATCHERS_H_
+
+#include "src/tint/lang/core/evaluation_stage.h"
+#include "src/tint/lang/core/intrinsic/table_data.h"
+#include "src/tint/lang/core/type/abstract_float.h"
+#include "src/tint/lang/core/type/abstract_int.h"
+#include "src/tint/lang/core/type/abstract_numeric.h"
+#include "src/tint/lang/core/type/array.h"
+#include "src/tint/lang/core/type/atomic.h"
+#include "src/tint/lang/core/type/bool.h"
+#include "src/tint/lang/core/type/builtin_structs.h"
+#include "src/tint/lang/core/type/depth_multisampled_texture.h"
+#include "src/tint/lang/core/type/depth_texture.h"
+#include "src/tint/lang/core/type/external_texture.h"
+#include "src/tint/lang/core/type/f16.h"
+#include "src/tint/lang/core/type/f32.h"
+#include "src/tint/lang/core/type/i32.h"
+#include "src/tint/lang/core/type/manager.h"
+#include "src/tint/lang/core/type/matrix.h"
+#include "src/tint/lang/core/type/multisampled_texture.h"
+#include "src/tint/lang/core/type/pointer.h"
+#include "src/tint/lang/core/type/sampled_texture.h"
+#include "src/tint/lang/core/type/storage_texture.h"
+#include "src/tint/lang/core/type/texture_dimension.h"
+#include "src/tint/lang/core/type/u32.h"
+#include "src/tint/lang/core/type/vector.h"
+
+namespace tint::core::intrinsic::data {
+
+inline bool MatchBool(intrinsic::MatchState&, const type::Type* ty) {
+ return ty->IsAnyOf<intrinsic::Any, type::Bool>();
+}
+
+inline const type::AbstractFloat* BuildFa(intrinsic::MatchState& state) {
+ return state.types.AFloat();
+}
+
+inline bool MatchFa(intrinsic::MatchState& state, const type::Type* ty) {
+ return (state.earliest_eval_stage <= EvaluationStage::kConstant) &&
+ ty->IsAnyOf<intrinsic::Any, core::type::AbstractNumeric>();
+}
+
+inline const type::AbstractInt* BuildIa(intrinsic::MatchState& state) {
+ return state.types.AInt();
+}
+
+inline bool MatchIa(intrinsic::MatchState& state, const type::Type* ty) {
+ return (state.earliest_eval_stage <= EvaluationStage::kConstant) &&
+ ty->IsAnyOf<intrinsic::Any, core::type::AbstractInt>();
+}
+
+inline const type::Bool* BuildBool(intrinsic::MatchState& state) {
+ return state.types.bool_();
+}
+
+inline const type::F16* BuildF16(intrinsic::MatchState& state) {
+ return state.types.f16();
+}
+
+inline bool MatchF16(intrinsic::MatchState&, const type::Type* ty) {
+ return ty->IsAnyOf<intrinsic::Any, type::F16, type::AbstractNumeric>();
+}
+
+inline const type::F32* BuildF32(intrinsic::MatchState& state) {
+ return state.types.f32();
+}
+
+inline bool MatchF32(intrinsic::MatchState&, const type::Type* ty) {
+ return ty->IsAnyOf<intrinsic::Any, type::F32, type::AbstractNumeric>();
+}
+
+inline const type::I32* BuildI32(intrinsic::MatchState& state) {
+ return state.types.i32();
+}
+
+inline bool MatchI32(intrinsic::MatchState&, const type::Type* ty) {
+ return ty->IsAnyOf<intrinsic::Any, type::I32, type::AbstractInt>();
+}
+
+inline const type::U32* BuildU32(intrinsic::MatchState& state) {
+ return state.types.u32();
+}
+
+inline bool MatchU32(intrinsic::MatchState&, const type::Type* ty) {
+ return ty->IsAnyOf<intrinsic::Any, type::U32, type::AbstractInt>();
+}
+
+inline bool MatchVec(intrinsic::MatchState&,
+ const type::Type* ty,
+ intrinsic::Number& N,
+ const type::Type*& T) {
+ if (ty->Is<intrinsic::Any>()) {
+ N = intrinsic::Number::any;
+ T = ty;
+ return true;
+ }
+
+ if (auto* v = ty->As<core::type::Vector>()) {
+ N = v->Width();
+ T = v->type();
+ return true;
+ }
+ return false;
+}
+
+template <uint32_t N>
+inline bool MatchVec(intrinsic::MatchState&, const type::Type* ty, const type::Type*& T) {
+ if (ty->Is<intrinsic::Any>()) {
+ T = ty;
+ return true;
+ }
+
+ if (auto* v = ty->As<core::type::Vector>()) {
+ if (v->Width() == N) {
+ T = v->type();
+ return true;
+ }
+ }
+ return false;
+}
+
+inline const type::Vector* BuildVec(intrinsic::MatchState& state,
+ intrinsic::Number N,
+ const type::Type* el) {
+ return state.types.vec(el, N.Value());
+}
+
+template <uint32_t N>
+inline const type::Vector* BuildVec(intrinsic::MatchState& state, const type::Type* el) {
+ return state.types.vec(el, N);
+}
+
+constexpr auto MatchVec2 = MatchVec<2>;
+constexpr auto MatchVec3 = MatchVec<3>;
+constexpr auto MatchVec4 = MatchVec<4>;
+
+constexpr auto BuildVec2 = BuildVec<2>;
+constexpr auto BuildVec3 = BuildVec<3>;
+constexpr auto BuildVec4 = BuildVec<4>;
+
+inline bool MatchPackedVec3(intrinsic::MatchState&, const type::Type* ty, const type::Type*& T) {
+ if (ty->Is<intrinsic::Any>()) {
+ T = ty;
+ return true;
+ }
+
+ if (auto* v = ty->As<core::type::Vector>()) {
+ if (v->Packed()) {
+ T = v->type();
+ return true;
+ }
+ }
+ return false;
+}
+
+inline const type::Vector* BuildPackedVec3(intrinsic::MatchState& state, const type::Type* el) {
+ return state.types.Get<type::Vector>(el, 3u, /* packed */ true);
+}
+
+inline bool MatchMat(intrinsic::MatchState&,
+ const type::Type* ty,
+ intrinsic::Number& M,
+ intrinsic::Number& N,
+ const type::Type*& T) {
+ if (ty->Is<intrinsic::Any>()) {
+ M = intrinsic::Number::any;
+ N = intrinsic::Number::any;
+ T = ty;
+ return true;
+ }
+ if (auto* m = ty->As<core::type::Matrix>()) {
+ M = m->columns();
+ N = m->ColumnType()->Width();
+ T = m->type();
+ return true;
+ }
+ return false;
+}
+
+template <uint32_t C, uint32_t R>
+inline bool MatchMat(intrinsic::MatchState&, const type::Type* ty, const type::Type*& T) {
+ if (ty->Is<intrinsic::Any>()) {
+ T = ty;
+ return true;
+ }
+ if (auto* m = ty->As<core::type::Matrix>()) {
+ if (m->columns() == C && m->rows() == R) {
+ T = m->type();
+ return true;
+ }
+ }
+ return false;
+}
+
+inline const type::Matrix* BuildMat(intrinsic::MatchState& state,
+ intrinsic::Number C,
+ intrinsic::Number R,
+ const type::Type* T) {
+ auto* column_type = state.types.vec(T, R.Value());
+ return state.types.mat(column_type, C.Value());
+}
+
+template <uint32_t C, uint32_t R>
+inline const type::Matrix* BuildMat(intrinsic::MatchState& state, const type::Type* T) {
+ auto* column_type = state.types.vec(T, R);
+ return state.types.mat(column_type, C);
+}
+
+constexpr auto BuildMat2X2 = BuildMat<2, 2>;
+constexpr auto BuildMat2X3 = BuildMat<2, 3>;
+constexpr auto BuildMat2X4 = BuildMat<2, 4>;
+constexpr auto BuildMat3X2 = BuildMat<3, 2>;
+constexpr auto BuildMat3X3 = BuildMat<3, 3>;
+constexpr auto BuildMat3X4 = BuildMat<3, 4>;
+constexpr auto BuildMat4X2 = BuildMat<4, 2>;
+constexpr auto BuildMat4X3 = BuildMat<4, 3>;
+constexpr auto BuildMat4X4 = BuildMat<4, 4>;
+
+constexpr auto MatchMat2X2 = MatchMat<2, 2>;
+constexpr auto MatchMat2X3 = MatchMat<2, 3>;
+constexpr auto MatchMat2X4 = MatchMat<2, 4>;
+constexpr auto MatchMat3X2 = MatchMat<3, 2>;
+constexpr auto MatchMat3X3 = MatchMat<3, 3>;
+constexpr auto MatchMat3X4 = MatchMat<3, 4>;
+constexpr auto MatchMat4X2 = MatchMat<4, 2>;
+constexpr auto MatchMat4X3 = MatchMat<4, 3>;
+constexpr auto MatchMat4X4 = MatchMat<4, 4>;
+
+inline bool MatchArray(intrinsic::MatchState&, const type::Type* ty, const type::Type*& T) {
+ if (ty->Is<intrinsic::Any>()) {
+ T = ty;
+ return true;
+ }
+
+ if (auto* a = ty->As<core::type::Array>()) {
+ if (a->Count()->Is<core::type::RuntimeArrayCount>()) {
+ T = a->ElemType();
+ return true;
+ }
+ }
+ return false;
+}
+
+inline const type::Array* BuildArray(intrinsic::MatchState& state, const type::Type* el) {
+ return state.types.Get<type::Array>(el,
+ /* count */ state.types.Get<type::RuntimeArrayCount>(),
+ /* align */ 0u,
+ /* size */ 0u,
+ /* stride */ 0u,
+ /* stride_implicit */ 0u);
+}
+
+inline bool MatchPtr(intrinsic::MatchState&,
+ const type::Type* ty,
+ intrinsic::Number& S,
+ const type::Type*& T,
+ intrinsic::Number& A) {
+ if (ty->Is<intrinsic::Any>()) {
+ S = intrinsic::Number::any;
+ T = ty;
+ A = intrinsic::Number::any;
+ return true;
+ }
+
+ if (auto* p = ty->As<core::type::Pointer>()) {
+ S = intrinsic::Number(static_cast<uint32_t>(p->AddressSpace()));
+ T = p->StoreType();
+ A = intrinsic::Number(static_cast<uint32_t>(p->Access()));
+ return true;
+ }
+ return false;
+}
+
+inline const type::Pointer* BuildPtr(intrinsic::MatchState& state,
+ intrinsic::Number S,
+ const type::Type* T,
+ intrinsic::Number& A) {
+ return state.types.ptr(static_cast<core::AddressSpace>(S.Value()), T,
+ static_cast<core::Access>(A.Value()));
+}
+
+inline bool MatchAtomic(intrinsic::MatchState&, const type::Type* ty, const type::Type*& T) {
+ if (ty->Is<intrinsic::Any>()) {
+ T = ty;
+ return true;
+ }
+
+ if (auto* a = ty->As<core::type::Atomic>()) {
+ T = a->Type();
+ return true;
+ }
+ return false;
+}
+
+inline const type::Atomic* BuildAtomic(intrinsic::MatchState& state, const type::Type* T) {
+ return state.types.atomic(T);
+}
+
+inline bool MatchSampler(intrinsic::MatchState&, const type::Type* ty) {
+ if (ty->Is<intrinsic::Any>()) {
+ return true;
+ }
+ return ty->Is([](const core::type::Sampler* s) {
+ return s->kind() == core::type::SamplerKind::kSampler;
+ });
+}
+
+inline const type::Sampler* BuildSampler(intrinsic::MatchState& state) {
+ return state.types.sampler();
+}
+
+inline bool MatchSamplerComparison(intrinsic::MatchState&, const type::Type* ty) {
+ if (ty->Is<intrinsic::Any>()) {
+ return true;
+ }
+ return ty->Is([](const core::type::Sampler* s) {
+ return s->kind() == core::type::SamplerKind::kComparisonSampler;
+ });
+}
+
+inline const type::Sampler* BuildSamplerComparison(intrinsic::MatchState& state) {
+ return state.types.comparison_sampler();
+}
+
+inline bool MatchTexture(intrinsic::MatchState&,
+ const type::Type* ty,
+ type::TextureDimension dim,
+ const type::Type*& T) {
+ if (ty->Is<intrinsic::Any>()) {
+ T = ty;
+ return true;
+ }
+ if (auto* v = ty->As<core::type::SampledTexture>()) {
+ if (v->dim() == dim) {
+ T = v->type();
+ return true;
+ }
+ }
+ return false;
+}
+
+#define JOIN(a, b) a##b
+
+#define DECLARE_SAMPLED_TEXTURE(suffix, dim) \
+ inline bool JOIN(MatchTexture, suffix)(intrinsic::MatchState & state, const type::Type* ty, \
+ const type::Type*& T) { \
+ return MatchTexture(state, ty, dim, T); \
+ } \
+ inline const type::SampledTexture* JOIN(BuildTexture, suffix)(intrinsic::MatchState & state, \
+ const type::Type* T) { \
+ return state.types.Get<type::SampledTexture>(dim, T); \
+ }
+
+DECLARE_SAMPLED_TEXTURE(1D, type::TextureDimension::k1d)
+DECLARE_SAMPLED_TEXTURE(2D, type::TextureDimension::k2d)
+DECLARE_SAMPLED_TEXTURE(2DArray, type::TextureDimension::k2dArray)
+DECLARE_SAMPLED_TEXTURE(3D, type::TextureDimension::k3d)
+DECLARE_SAMPLED_TEXTURE(Cube, type::TextureDimension::kCube)
+DECLARE_SAMPLED_TEXTURE(CubeArray, type::TextureDimension::kCubeArray)
+#undef DECLARE_SAMPLED_TEXTURE
+
+inline bool MatchTextureMultisampled(intrinsic::MatchState&,
+ const type::Type* ty,
+ type::TextureDimension dim,
+ const type::Type*& T) {
+ if (ty->Is<intrinsic::Any>()) {
+ T = ty;
+ return true;
+ }
+ if (auto* v = ty->As<core::type::MultisampledTexture>()) {
+ if (v->dim() == dim) {
+ T = v->type();
+ return true;
+ }
+ }
+ return false;
+}
+
+#define DECLARE_MULTISAMPLED_TEXTURE(suffix, dim) \
+ inline bool JOIN(MatchTextureMultisampled, suffix)( \
+ intrinsic::MatchState & state, const type::Type* ty, const type::Type*& T) { \
+ return MatchTextureMultisampled(state, ty, dim, T); \
+ } \
+ inline const type::MultisampledTexture* JOIN(BuildTextureMultisampled, suffix)( \
+ intrinsic::MatchState & state, const type::Type* T) { \
+ return state.types.Get<type::MultisampledTexture>(dim, T); \
+ }
+
+DECLARE_MULTISAMPLED_TEXTURE(2D, type::TextureDimension::k2d)
+#undef DECLARE_MULTISAMPLED_TEXTURE
+
+inline bool MatchTextureDepth(intrinsic::MatchState&,
+ const type::Type* ty,
+ type::TextureDimension dim) {
+ if (ty->Is<intrinsic::Any>()) {
+ return true;
+ }
+ return ty->Is([&](const core::type::DepthTexture* t) { return t->dim() == dim; });
+}
+
+#define DECLARE_DEPTH_TEXTURE(suffix, dim) \
+ inline bool JOIN(MatchTextureDepth, suffix)(intrinsic::MatchState & state, \
+ const type::Type* ty) { \
+ return MatchTextureDepth(state, ty, dim); \
+ } \
+ inline const type::DepthTexture* JOIN(BuildTextureDepth, \
+ suffix)(intrinsic::MatchState & state) { \
+ return state.types.Get<type::DepthTexture>(dim); \
+ }
+
+DECLARE_DEPTH_TEXTURE(2D, type::TextureDimension::k2d)
+DECLARE_DEPTH_TEXTURE(2DArray, type::TextureDimension::k2dArray)
+DECLARE_DEPTH_TEXTURE(Cube, type::TextureDimension::kCube)
+DECLARE_DEPTH_TEXTURE(CubeArray, type::TextureDimension::kCubeArray)
+#undef DECLARE_DEPTH_TEXTURE
+
+inline bool MatchTextureDepthMultisampled2D(intrinsic::MatchState&, const type::Type* ty) {
+ if (ty->Is<intrinsic::Any>()) {
+ return true;
+ }
+ return ty->Is([&](const core::type::DepthMultisampledTexture* t) {
+ return t->dim() == core::type::TextureDimension::k2d;
+ });
+}
+
+inline type::DepthMultisampledTexture* BuildTextureDepthMultisampled2D(
+ intrinsic::MatchState& state) {
+ return state.types.Get<core::type::DepthMultisampledTexture>(core::type::TextureDimension::k2d);
+}
+
+inline bool MatchTextureStorage(intrinsic::MatchState&,
+ const type::Type* ty,
+ type::TextureDimension dim,
+ intrinsic::Number& F,
+ intrinsic::Number& A) {
+ if (ty->Is<intrinsic::Any>()) {
+ F = intrinsic::Number::any;
+ A = intrinsic::Number::any;
+ return true;
+ }
+ if (auto* v = ty->As<core::type::StorageTexture>()) {
+ if (v->dim() == dim) {
+ F = intrinsic::Number(static_cast<uint32_t>(v->texel_format()));
+ A = intrinsic::Number(static_cast<uint32_t>(v->access()));
+ return true;
+ }
+ }
+ return false;
+}
+
+#define DECLARE_STORAGE_TEXTURE(suffix, dim) \
+ inline bool JOIN(MatchTextureStorage, suffix)(intrinsic::MatchState & state, \
+ const type::Type* ty, intrinsic::Number& F, \
+ intrinsic::Number& A) { \
+ return MatchTextureStorage(state, ty, dim, F, A); \
+ } \
+ inline const type::StorageTexture* JOIN(BuildTextureStorage, suffix)( \
+ intrinsic::MatchState & state, intrinsic::Number F, intrinsic::Number A) { \
+ auto format = static_cast<TexelFormat>(F.Value()); \
+ auto access = static_cast<Access>(A.Value()); \
+ auto* T = type::StorageTexture::SubtypeFor(format, state.types); \
+ return state.types.Get<type::StorageTexture>(dim, format, access, T); \
+ }
+
+DECLARE_STORAGE_TEXTURE(1D, type::TextureDimension::k1d)
+DECLARE_STORAGE_TEXTURE(2D, type::TextureDimension::k2d)
+DECLARE_STORAGE_TEXTURE(2DArray, type::TextureDimension::k2dArray)
+DECLARE_STORAGE_TEXTURE(3D, type::TextureDimension::k3d)
+#undef DECLARE_STORAGE_TEXTURE
+
+inline bool MatchTextureExternal(intrinsic::MatchState&, const type::Type* ty) {
+ return ty->IsAnyOf<intrinsic::Any, type::ExternalTexture>();
+}
+
+inline const type::ExternalTexture* BuildTextureExternal(intrinsic::MatchState& state) {
+ return state.types.Get<type::ExternalTexture>();
+}
+
+// Builtin types starting with a _ prefix cannot be declared in WGSL, so they
+// can only be used as return types. Because of this, they must only match Any,
+// which is used as the return type matcher.
+inline bool MatchModfResult(intrinsic::MatchState&, const type::Type* ty, const type::Type*& T) {
+ if (!ty->Is<intrinsic::Any>()) {
+ return false;
+ }
+ T = ty;
+ return true;
+}
+inline bool MatchModfResultVec(intrinsic::MatchState&,
+ const type::Type* ty,
+ intrinsic::Number& N,
+ const type::Type*& T) {
+ if (!ty->Is<intrinsic::Any>()) {
+ return false;
+ }
+ N = intrinsic::Number::any;
+ T = ty;
+ return true;
+}
+inline bool MatchFrexpResult(intrinsic::MatchState&, const type::Type* ty, const type::Type*& T) {
+ if (!ty->Is<intrinsic::Any>()) {
+ return false;
+ }
+ T = ty;
+ return true;
+}
+inline bool MatchFrexpResultVec(intrinsic::MatchState&,
+ const type::Type* ty,
+ intrinsic::Number& N,
+ const type::Type*& T) {
+ if (!ty->Is<intrinsic::Any>()) {
+ return false;
+ }
+ N = intrinsic::Number::any;
+ T = ty;
+ return true;
+}
+
+inline bool MatchAtomicCompareExchangeResult(intrinsic::MatchState&,
+ const type::Type* ty,
+ const type::Type*& T) {
+ if (ty->Is<intrinsic::Any>()) {
+ T = ty;
+ return true;
+ }
+ return false;
+}
+
+inline const type::Struct* BuildModfResult(intrinsic::MatchState& state, const type::Type* el) {
+ return type::CreateModfResult(state.types, state.symbols, el);
+}
+
+inline const type::Struct* BuildModfResultVec(intrinsic::MatchState& state,
+ intrinsic::Number& n,
+ const type::Type* el) {
+ auto* vec = state.types.vec(el, n.Value());
+ return core::type::CreateModfResult(state.types, state.symbols, vec);
+}
+
+inline const type::Struct* BuildFrexpResult(intrinsic::MatchState& state, const type::Type* el) {
+ return type::CreateFrexpResult(state.types, state.symbols, el);
+}
+
+inline const type::Struct* BuildFrexpResultVec(intrinsic::MatchState& state,
+ intrinsic::Number& n,
+ const type::Type* el) {
+ auto* vec = state.types.vec(el, n.Value());
+ return core::type::CreateFrexpResult(state.types, state.symbols, vec);
+}
+
+inline const type::Struct* BuildAtomicCompareExchangeResult(intrinsic::MatchState& state,
+ const type::Type* ty) {
+ return type::CreateAtomicCompareExchangeResult(state.types, state.symbols, ty);
+}
+
+} // namespace tint::core::intrinsic::data
+
+#endif // SRC_TINT_LANG_CORE_INTRINSIC_DATA_TYPE_MATCHERS_H_
diff --git a/src/tint/lang/core/intrinsic/table_test.cc b/src/tint/lang/core/intrinsic/table_test.cc
index 62aff6e..508571e 100644
--- a/src/tint/lang/core/intrinsic/table_test.cc
+++ b/src/tint/lang/core/intrinsic/table_test.cc
@@ -17,8 +17,8 @@
#include <utility>
#include "gmock/gmock.h"
+#include "src/tint/lang/core/intrinsic/data/data.h"
#include "src/tint/lang/core/intrinsic/table_data.h"
-#include "src/tint/lang/core/intrinsic_data.h"
#include "src/tint/lang/core/type/atomic.h"
#include "src/tint/lang/core/type/depth_multisampled_texture.h"
#include "src/tint/lang/core/type/depth_texture.h"
@@ -51,7 +51,7 @@
class IntrinsicTableTest : public testing::Test, public ProgramBuilder {
public:
std::unique_ptr<Table> table =
- Table::Create(core::kIntrinsicData, Types(), Symbols(), Diagnostics());
+ Table::Create(core::intrinsic::data::kData, Types(), Symbols(), Diagnostics());
};
TEST_F(IntrinsicTableTest, MatchF32) {
@@ -1032,7 +1032,7 @@
struct IntrinsicTableAbstractBinaryTest : public resolver::ResolverTestWithParam<Case> {
std::unique_ptr<Table> table =
- Table::Create(core::kIntrinsicData, Types(), Symbols(), Diagnostics());
+ Table::Create(core::intrinsic::data::kData, Types(), Symbols(), Diagnostics());
};
TEST_P(IntrinsicTableAbstractBinaryTest, MatchAdd) {
@@ -1217,7 +1217,7 @@
struct IntrinsicTableAbstractTernaryTest : public resolver::ResolverTestWithParam<Case> {
std::unique_ptr<Table> table =
- Table::Create(core::kIntrinsicData, Types(), Symbols(), Diagnostics());
+ Table::Create(core::intrinsic::data::kData, Types(), Symbols(), Diagnostics());
};
TEST_P(IntrinsicTableAbstractTernaryTest, MatchClamp) {
diff --git a/src/tint/lang/core/intrinsic_type_matchers.h b/src/tint/lang/core/intrinsic_type_matchers.h
deleted file mode 100644
index 2175958..0000000
--- a/src/tint/lang/core/intrinsic_type_matchers.h
+++ /dev/null
@@ -1,596 +0,0 @@
-// Copyright 2023 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_TINT_LANG_CORE_INTRINSIC_TYPE_MATCHERS_H_
-#define SRC_TINT_LANG_CORE_INTRINSIC_TYPE_MATCHERS_H_
-
-#include "src/tint/lang/core/evaluation_stage.h"
-#include "src/tint/lang/core/intrinsic/table_data.h"
-#include "src/tint/lang/core/type/abstract_float.h"
-#include "src/tint/lang/core/type/abstract_int.h"
-#include "src/tint/lang/core/type/abstract_numeric.h"
-#include "src/tint/lang/core/type/array.h"
-#include "src/tint/lang/core/type/atomic.h"
-#include "src/tint/lang/core/type/bool.h"
-#include "src/tint/lang/core/type/builtin_structs.h"
-#include "src/tint/lang/core/type/depth_multisampled_texture.h"
-#include "src/tint/lang/core/type/depth_texture.h"
-#include "src/tint/lang/core/type/external_texture.h"
-#include "src/tint/lang/core/type/f16.h"
-#include "src/tint/lang/core/type/f32.h"
-#include "src/tint/lang/core/type/i32.h"
-#include "src/tint/lang/core/type/manager.h"
-#include "src/tint/lang/core/type/matrix.h"
-#include "src/tint/lang/core/type/multisampled_texture.h"
-#include "src/tint/lang/core/type/pointer.h"
-#include "src/tint/lang/core/type/sampled_texture.h"
-#include "src/tint/lang/core/type/storage_texture.h"
-#include "src/tint/lang/core/type/texture_dimension.h"
-#include "src/tint/lang/core/type/u32.h"
-#include "src/tint/lang/core/type/vector.h"
-
-namespace tint::core {
-
-inline bool match_bool(intrinsic::MatchState&, const core::type::Type* ty) {
- return ty->IsAnyOf<intrinsic::Any, core::type::Bool>();
-}
-
-inline const core::type::AbstractFloat* build_fa(intrinsic::MatchState& state) {
- return state.types.AFloat();
-}
-
-inline bool match_fa(intrinsic::MatchState& state, const core::type::Type* ty) {
- return (state.earliest_eval_stage <= EvaluationStage::kConstant) &&
- ty->IsAnyOf<intrinsic::Any, core::type::AbstractNumeric>();
-}
-
-inline const core::type::AbstractInt* build_ia(intrinsic::MatchState& state) {
- return state.types.AInt();
-}
-
-inline bool match_ia(intrinsic::MatchState& state, const core::type::Type* ty) {
- return (state.earliest_eval_stage <= EvaluationStage::kConstant) &&
- ty->IsAnyOf<intrinsic::Any, core::type::AbstractInt>();
-}
-
-inline const core::type::Bool* build_bool(intrinsic::MatchState& state) {
- return state.types.bool_();
-}
-
-inline const core::type::F16* build_f16(intrinsic::MatchState& state) {
- return state.types.f16();
-}
-
-inline bool match_f16(intrinsic::MatchState&, const core::type::Type* ty) {
- return ty->IsAnyOf<intrinsic::Any, core::type::F16, core::type::AbstractNumeric>();
-}
-
-inline const core::type::F32* build_f32(intrinsic::MatchState& state) {
- return state.types.f32();
-}
-
-inline bool match_f32(intrinsic::MatchState&, const core::type::Type* ty) {
- return ty->IsAnyOf<intrinsic::Any, core::type::F32, core::type::AbstractNumeric>();
-}
-
-inline const core::type::I32* build_i32(intrinsic::MatchState& state) {
- return state.types.i32();
-}
-
-inline bool match_i32(intrinsic::MatchState&, const core::type::Type* ty) {
- return ty->IsAnyOf<intrinsic::Any, core::type::I32, core::type::AbstractInt>();
-}
-
-inline const core::type::U32* build_u32(intrinsic::MatchState& state) {
- return state.types.u32();
-}
-
-inline bool match_u32(intrinsic::MatchState&, const core::type::Type* ty) {
- return ty->IsAnyOf<intrinsic::Any, core::type::U32, core::type::AbstractInt>();
-}
-
-inline bool match_vec(intrinsic::MatchState&,
- const core::type::Type* ty,
- intrinsic::Number& N,
- const core::type::Type*& T) {
- if (ty->Is<intrinsic::Any>()) {
- N = intrinsic::Number::any;
- T = ty;
- return true;
- }
-
- if (auto* v = ty->As<core::type::Vector>()) {
- N = v->Width();
- T = v->type();
- return true;
- }
- return false;
-}
-
-template <uint32_t N>
-inline bool match_vec(intrinsic::MatchState&,
- const core::type::Type* ty,
- const core::type::Type*& T) {
- if (ty->Is<intrinsic::Any>()) {
- T = ty;
- return true;
- }
-
- if (auto* v = ty->As<core::type::Vector>()) {
- if (v->Width() == N) {
- T = v->type();
- return true;
- }
- }
- return false;
-}
-
-inline const core::type::Vector* build_vec(intrinsic::MatchState& state,
- intrinsic::Number N,
- const core::type::Type* el) {
- return state.types.vec(el, N.Value());
-}
-
-template <uint32_t N>
-inline const core::type::Vector* build_vec(intrinsic::MatchState& state,
- const core::type::Type* el) {
- return state.types.vec(el, N);
-}
-
-constexpr auto match_vec2 = match_vec<2>;
-constexpr auto match_vec3 = match_vec<3>;
-constexpr auto match_vec4 = match_vec<4>;
-
-constexpr auto build_vec2 = build_vec<2>;
-constexpr auto build_vec3 = build_vec<3>;
-constexpr auto build_vec4 = build_vec<4>;
-
-inline bool match_packedVec3(intrinsic::MatchState&,
- const core::type::Type* ty,
- const core::type::Type*& T) {
- if (ty->Is<intrinsic::Any>()) {
- T = ty;
- return true;
- }
-
- if (auto* v = ty->As<core::type::Vector>()) {
- if (v->Packed()) {
- T = v->type();
- return true;
- }
- }
- return false;
-}
-
-inline const core::type::Vector* build_packedVec3(intrinsic::MatchState& state,
- const core::type::Type* el) {
- return state.types.Get<core::type::Vector>(el, 3u, /* packed */ true);
-}
-
-inline bool match_mat(intrinsic::MatchState&,
- const core::type::Type* ty,
- intrinsic::Number& M,
- intrinsic::Number& N,
- const core::type::Type*& T) {
- if (ty->Is<intrinsic::Any>()) {
- M = intrinsic::Number::any;
- N = intrinsic::Number::any;
- T = ty;
- return true;
- }
- if (auto* m = ty->As<core::type::Matrix>()) {
- M = m->columns();
- N = m->ColumnType()->Width();
- T = m->type();
- return true;
- }
- return false;
-}
-
-template <uint32_t C, uint32_t R>
-inline bool match_mat(intrinsic::MatchState&,
- const core::type::Type* ty,
- const core::type::Type*& T) {
- if (ty->Is<intrinsic::Any>()) {
- T = ty;
- return true;
- }
- if (auto* m = ty->As<core::type::Matrix>()) {
- if (m->columns() == C && m->rows() == R) {
- T = m->type();
- return true;
- }
- }
- return false;
-}
-
-inline const core::type::Matrix* build_mat(intrinsic::MatchState& state,
- intrinsic::Number C,
- intrinsic::Number R,
- const core::type::Type* T) {
- auto* column_type = state.types.vec(T, R.Value());
- return state.types.mat(column_type, C.Value());
-}
-
-template <uint32_t C, uint32_t R>
-inline const core::type::Matrix* build_mat(intrinsic::MatchState& state,
- const core::type::Type* T) {
- auto* column_type = state.types.vec(T, R);
- return state.types.mat(column_type, C);
-}
-
-constexpr auto build_mat2x2 = build_mat<2, 2>;
-constexpr auto build_mat2x3 = build_mat<2, 3>;
-constexpr auto build_mat2x4 = build_mat<2, 4>;
-constexpr auto build_mat3x2 = build_mat<3, 2>;
-constexpr auto build_mat3x3 = build_mat<3, 3>;
-constexpr auto build_mat3x4 = build_mat<3, 4>;
-constexpr auto build_mat4x2 = build_mat<4, 2>;
-constexpr auto build_mat4x3 = build_mat<4, 3>;
-constexpr auto build_mat4x4 = build_mat<4, 4>;
-
-constexpr auto match_mat2x2 = match_mat<2, 2>;
-constexpr auto match_mat2x3 = match_mat<2, 3>;
-constexpr auto match_mat2x4 = match_mat<2, 4>;
-constexpr auto match_mat3x2 = match_mat<3, 2>;
-constexpr auto match_mat3x3 = match_mat<3, 3>;
-constexpr auto match_mat3x4 = match_mat<3, 4>;
-constexpr auto match_mat4x2 = match_mat<4, 2>;
-constexpr auto match_mat4x3 = match_mat<4, 3>;
-constexpr auto match_mat4x4 = match_mat<4, 4>;
-
-inline bool match_array(intrinsic::MatchState&,
- const core::type::Type* ty,
- const core::type::Type*& T) {
- if (ty->Is<intrinsic::Any>()) {
- T = ty;
- return true;
- }
-
- if (auto* a = ty->As<core::type::Array>()) {
- if (a->Count()->Is<core::type::RuntimeArrayCount>()) {
- T = a->ElemType();
- return true;
- }
- }
- return false;
-}
-
-inline const core::type::Array* build_array(intrinsic::MatchState& state,
- const core::type::Type* el) {
- return state.types.Get<core::type::Array>(
- el,
- /* count */ state.types.Get<core::type::RuntimeArrayCount>(),
- /* align */ 0u,
- /* size */ 0u,
- /* stride */ 0u,
- /* stride_implicit */ 0u);
-}
-
-inline bool match_ptr(intrinsic::MatchState&,
- const core::type::Type* ty,
- intrinsic::Number& S,
- const core::type::Type*& T,
- intrinsic::Number& A) {
- if (ty->Is<intrinsic::Any>()) {
- S = intrinsic::Number::any;
- T = ty;
- A = intrinsic::Number::any;
- return true;
- }
-
- if (auto* p = ty->As<core::type::Pointer>()) {
- S = intrinsic::Number(static_cast<uint32_t>(p->AddressSpace()));
- T = p->StoreType();
- A = intrinsic::Number(static_cast<uint32_t>(p->Access()));
- return true;
- }
- return false;
-}
-
-inline const core::type::Pointer* build_ptr(intrinsic::MatchState& state,
- intrinsic::Number S,
- const core::type::Type* T,
- intrinsic::Number& A) {
- return state.types.ptr(static_cast<core::AddressSpace>(S.Value()), T,
- static_cast<core::Access>(A.Value()));
-}
-
-inline bool match_atomic(intrinsic::MatchState&,
- const core::type::Type* ty,
- const core::type::Type*& T) {
- if (ty->Is<intrinsic::Any>()) {
- T = ty;
- return true;
- }
-
- if (auto* a = ty->As<core::type::Atomic>()) {
- T = a->Type();
- return true;
- }
- return false;
-}
-
-inline const core::type::Atomic* build_atomic(intrinsic::MatchState& state,
- const core::type::Type* T) {
- return state.types.atomic(T);
-}
-
-inline bool match_sampler(intrinsic::MatchState&, const core::type::Type* ty) {
- if (ty->Is<intrinsic::Any>()) {
- return true;
- }
- return ty->Is([](const core::type::Sampler* s) {
- return s->kind() == core::type::SamplerKind::kSampler;
- });
-}
-
-inline const core::type::Sampler* build_sampler(intrinsic::MatchState& state) {
- return state.types.sampler();
-}
-
-inline bool match_sampler_comparison(intrinsic::MatchState&, const core::type::Type* ty) {
- if (ty->Is<intrinsic::Any>()) {
- return true;
- }
- return ty->Is([](const core::type::Sampler* s) {
- return s->kind() == core::type::SamplerKind::kComparisonSampler;
- });
-}
-
-inline const core::type::Sampler* build_sampler_comparison(intrinsic::MatchState& state) {
- return state.types.comparison_sampler();
-}
-
-inline bool match_texture(intrinsic::MatchState&,
- const core::type::Type* ty,
- core::type::TextureDimension dim,
- const core::type::Type*& T) {
- if (ty->Is<intrinsic::Any>()) {
- T = ty;
- return true;
- }
- if (auto* v = ty->As<core::type::SampledTexture>()) {
- if (v->dim() == dim) {
- T = v->type();
- return true;
- }
- }
- return false;
-}
-
-#define JOIN(a, b) a##b
-
-#define DECLARE_SAMPLED_TEXTURE(suffix, dim) \
- inline bool JOIN(match_texture_, suffix)( \
- intrinsic::MatchState & state, const core::type::Type* ty, const core::type::Type*& T) { \
- return match_texture(state, ty, dim, T); \
- } \
- inline const core::type::SampledTexture* JOIN(build_texture_, suffix)( \
- intrinsic::MatchState & state, const core::type::Type* T) { \
- return state.types.Get<core::type::SampledTexture>(dim, T); \
- }
-
-DECLARE_SAMPLED_TEXTURE(1d, core::type::TextureDimension::k1d)
-DECLARE_SAMPLED_TEXTURE(2d, core::type::TextureDimension::k2d)
-DECLARE_SAMPLED_TEXTURE(2d_array, core::type::TextureDimension::k2dArray)
-DECLARE_SAMPLED_TEXTURE(3d, core::type::TextureDimension::k3d)
-DECLARE_SAMPLED_TEXTURE(cube, core::type::TextureDimension::kCube)
-DECLARE_SAMPLED_TEXTURE(cube_array, core::type::TextureDimension::kCubeArray)
-#undef DECLARE_SAMPLED_TEXTURE
-
-inline bool match_texture_multisampled(intrinsic::MatchState&,
- const core::type::Type* ty,
- core::type::TextureDimension dim,
- const core::type::Type*& T) {
- if (ty->Is<intrinsic::Any>()) {
- T = ty;
- return true;
- }
- if (auto* v = ty->As<core::type::MultisampledTexture>()) {
- if (v->dim() == dim) {
- T = v->type();
- return true;
- }
- }
- return false;
-}
-
-#define DECLARE_MULTISAMPLED_TEXTURE(suffix, dim) \
- inline bool JOIN(match_texture_multisampled_, suffix)( \
- intrinsic::MatchState & state, const core::type::Type* ty, const core::type::Type*& T) { \
- return match_texture_multisampled(state, ty, dim, T); \
- } \
- inline const core::type::MultisampledTexture* JOIN(build_texture_multisampled_, suffix)( \
- intrinsic::MatchState & state, const core::type::Type* T) { \
- return state.types.Get<core::type::MultisampledTexture>(dim, T); \
- }
-
-DECLARE_MULTISAMPLED_TEXTURE(2d, core::type::TextureDimension::k2d)
-#undef DECLARE_MULTISAMPLED_TEXTURE
-
-inline bool match_texture_depth(intrinsic::MatchState&,
- const core::type::Type* ty,
- core::type::TextureDimension dim) {
- if (ty->Is<intrinsic::Any>()) {
- return true;
- }
- return ty->Is([&](const core::type::DepthTexture* t) { return t->dim() == dim; });
-}
-
-#define DECLARE_DEPTH_TEXTURE(suffix, dim) \
- inline bool JOIN(match_texture_depth_, suffix)(intrinsic::MatchState & state, \
- const core::type::Type* ty) { \
- return match_texture_depth(state, ty, dim); \
- } \
- inline const core::type::DepthTexture* JOIN(build_texture_depth_, \
- suffix)(intrinsic::MatchState & state) { \
- return state.types.Get<core::type::DepthTexture>(dim); \
- }
-
-DECLARE_DEPTH_TEXTURE(2d, core::type::TextureDimension::k2d)
-DECLARE_DEPTH_TEXTURE(2d_array, core::type::TextureDimension::k2dArray)
-DECLARE_DEPTH_TEXTURE(cube, core::type::TextureDimension::kCube)
-DECLARE_DEPTH_TEXTURE(cube_array, core::type::TextureDimension::kCubeArray)
-#undef DECLARE_DEPTH_TEXTURE
-
-inline bool match_texture_depth_multisampled_2d(intrinsic::MatchState&,
- const core::type::Type* ty) {
- if (ty->Is<intrinsic::Any>()) {
- return true;
- }
- return ty->Is([&](const core::type::DepthMultisampledTexture* t) {
- return t->dim() == core::type::TextureDimension::k2d;
- });
-}
-
-inline core::type::DepthMultisampledTexture* build_texture_depth_multisampled_2d(
- intrinsic::MatchState& state) {
- return state.types.Get<core::type::DepthMultisampledTexture>(core::type::TextureDimension::k2d);
-}
-
-inline bool match_texture_storage(intrinsic::MatchState&,
- const core::type::Type* ty,
- core::type::TextureDimension dim,
- intrinsic::Number& F,
- intrinsic::Number& A) {
- if (ty->Is<intrinsic::Any>()) {
- F = intrinsic::Number::any;
- A = intrinsic::Number::any;
- return true;
- }
- if (auto* v = ty->As<core::type::StorageTexture>()) {
- if (v->dim() == dim) {
- F = intrinsic::Number(static_cast<uint32_t>(v->texel_format()));
- A = intrinsic::Number(static_cast<uint32_t>(v->access()));
- return true;
- }
- }
- return false;
-}
-
-#define DECLARE_STORAGE_TEXTURE(suffix, dim) \
- inline bool JOIN(match_texture_storage_, suffix)(intrinsic::MatchState & state, \
- const core::type::Type* ty, \
- intrinsic::Number& F, intrinsic::Number& A) { \
- return match_texture_storage(state, ty, dim, F, A); \
- } \
- inline const core::type::StorageTexture* JOIN(build_texture_storage_, suffix)( \
- intrinsic::MatchState & state, intrinsic::Number F, intrinsic::Number A) { \
- auto format = static_cast<TexelFormat>(F.Value()); \
- auto access = static_cast<Access>(A.Value()); \
- auto* T = core::type::StorageTexture::SubtypeFor(format, state.types); \
- return state.types.Get<core::type::StorageTexture>(dim, format, access, T); \
- }
-
-DECLARE_STORAGE_TEXTURE(1d, core::type::TextureDimension::k1d)
-DECLARE_STORAGE_TEXTURE(2d, core::type::TextureDimension::k2d)
-DECLARE_STORAGE_TEXTURE(2d_array, core::type::TextureDimension::k2dArray)
-DECLARE_STORAGE_TEXTURE(3d, core::type::TextureDimension::k3d)
-#undef DECLARE_STORAGE_TEXTURE
-
-inline bool match_texture_external(intrinsic::MatchState&, const core::type::Type* ty) {
- return ty->IsAnyOf<intrinsic::Any, core::type::ExternalTexture>();
-}
-
-inline const core::type::ExternalTexture* build_texture_external(intrinsic::MatchState& state) {
- return state.types.Get<core::type::ExternalTexture>();
-}
-
-// Builtin types starting with a _ prefix cannot be declared in WGSL, so they
-// can only be used as return types. Because of this, they must only match Any,
-// which is used as the return type matcher.
-inline bool match_modf_result(intrinsic::MatchState&,
- const core::type::Type* ty,
- const core::type::Type*& T) {
- if (!ty->Is<intrinsic::Any>()) {
- return false;
- }
- T = ty;
- return true;
-}
-inline bool match_modf_result_vec(intrinsic::MatchState&,
- const core::type::Type* ty,
- intrinsic::Number& N,
- const core::type::Type*& T) {
- if (!ty->Is<intrinsic::Any>()) {
- return false;
- }
- N = intrinsic::Number::any;
- T = ty;
- return true;
-}
-inline bool match_frexp_result(intrinsic::MatchState&,
- const core::type::Type* ty,
- const core::type::Type*& T) {
- if (!ty->Is<intrinsic::Any>()) {
- return false;
- }
- T = ty;
- return true;
-}
-inline bool match_frexp_result_vec(intrinsic::MatchState&,
- const core::type::Type* ty,
- intrinsic::Number& N,
- const core::type::Type*& T) {
- if (!ty->Is<intrinsic::Any>()) {
- return false;
- }
- N = intrinsic::Number::any;
- T = ty;
- return true;
-}
-
-inline bool match_atomic_compare_exchange_result(intrinsic::MatchState&,
- const core::type::Type* ty,
- const core::type::Type*& T) {
- if (ty->Is<intrinsic::Any>()) {
- T = ty;
- return true;
- }
- return false;
-}
-
-inline const core::type::Struct* build_modf_result(intrinsic::MatchState& state,
- const core::type::Type* el) {
- return core::type::CreateModfResult(state.types, state.symbols, el);
-}
-
-inline const core::type::Struct* build_modf_result_vec(intrinsic::MatchState& state,
- intrinsic::Number& n,
- const core::type::Type* el) {
- auto* vec = state.types.vec(el, n.Value());
- return core::type::CreateModfResult(state.types, state.symbols, vec);
-}
-
-inline const core::type::Struct* build_frexp_result(intrinsic::MatchState& state,
- const core::type::Type* el) {
- return core::type::CreateFrexpResult(state.types, state.symbols, el);
-}
-
-inline const core::type::Struct* build_frexp_result_vec(intrinsic::MatchState& state,
- intrinsic::Number& n,
- const core::type::Type* el) {
- auto* vec = state.types.vec(el, n.Value());
- return core::type::CreateFrexpResult(state.types, state.symbols, vec);
-}
-
-inline const core::type::Struct* build_atomic_compare_exchange_result(intrinsic::MatchState& state,
- const core::type::Type* ty) {
- return core::type::CreateAtomicCompareExchangeResult(state.types, state.symbols, ty);
-}
-
-} // namespace tint::core
-
-#endif // SRC_TINT_LANG_CORE_INTRINSIC_TYPE_MATCHERS_H_
diff --git a/src/tint/lang/wgsl/ast/transform/decompose_memory_access.cc b/src/tint/lang/wgsl/ast/transform/decompose_memory_access.cc
index 68e4b8a..5a04194 100644
--- a/src/tint/lang/wgsl/ast/transform/decompose_memory_access.cc
+++ b/src/tint/lang/wgsl/ast/transform/decompose_memory_access.cc
@@ -113,7 +113,7 @@
/// LoadStoreKey is the unordered map key to a load or store intrinsic.
struct LoadStoreKey {
core::type::Type const* el_ty = nullptr; // element type
- Symbol const buffer; // buffer name
+ Symbol const buffer; // buffer name
bool operator==(const LoadStoreKey& rhs) const {
return el_ty == rhs.el_ty && buffer == rhs.buffer;
}
@@ -127,8 +127,8 @@
/// AtomicKey is the unordered map key to an atomic intrinsic.
struct AtomicKey {
core::type::Type const* el_ty = nullptr; // element type
- core::Function const op; // atomic op
- Symbol const buffer; // buffer name
+ core::Function const op; // atomic op
+ Symbol const buffer; // buffer name
bool operator==(const AtomicKey& rhs) const {
return el_ty == rhs.el_ty && op == rhs.op && buffer == rhs.buffer;
}
diff --git a/src/tint/lang/wgsl/resolver/resolver.cc b/src/tint/lang/wgsl/resolver/resolver.cc
index 45e1d94..9d929f2 100644
--- a/src/tint/lang/wgsl/resolver/resolver.cc
+++ b/src/tint/lang/wgsl/resolver/resolver.cc
@@ -22,7 +22,7 @@
#include "src/tint/lang/core/builtin.h"
#include "src/tint/lang/core/constant/scalar.h"
-#include "src/tint/lang/core/intrinsic_data.h"
+#include "src/tint/lang/core/intrinsic/data/data.h"
#include "src/tint/lang/core/type/abstract_float.h"
#include "src/tint/lang/core/type/abstract_int.h"
#include "src/tint/lang/core/type/array.h"
@@ -114,7 +114,7 @@
: builder_(builder),
diagnostics_(builder->Diagnostics()),
const_eval_(builder->constants, diagnostics_),
- intrinsic_table_(core::intrinsic::Table::Create(core::kIntrinsicData,
+ intrinsic_table_(core::intrinsic::Table::Create(core::intrinsic::data::kData,
builder->Types(),
builder->Symbols(),
builder->Diagnostics())),
diff --git a/src/tint/utils/templates/intrinsic_table_data.tmpl.inc b/src/tint/utils/templates/intrinsic_table_data.tmpl.inc
index fe3f9da..8326ad6 100644
--- a/src/tint/utils/templates/intrinsic_table_data.tmpl.inc
+++ b/src/tint/utils/templates/intrinsic_table_data.tmpl.inc
@@ -18,7 +18,6 @@
{{- /* ------------------------------------------------------------------ */ -}}
{{- $I := $.Intrinsics -}}
-namespace {{$.Namespace}} {
namespace {
using ConstEvalFunctionIndex = tint::core::intrinsic::ConstEvalFunctionIndex;
@@ -290,8 +289,6 @@
/* unary_minus */ kUnaryOperators[kUnaryOperatorMinus],
};
-} // namespace {{$.Namespace}}
-
{{ end -}}
{{- end -}}
@@ -299,14 +296,14 @@
{{- /* ------------------------------------------------------------------ */ -}}
{{- define "Type" -}}
{{- /* ------------------------------------------------------------------ */ -}}
-{{- $class := PascalCase .Name -}}
+{{- $name := PascalCase .Name -}}
/// TypeMatcher for 'type {{.Name}}'
-constexpr TypeMatcher k{{$class}}Matcher {
+constexpr TypeMatcher k{{$name}}Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
{{- range .TemplateParams }}
{{- template "DeclareLocalTemplateParam" . }}
{{- end }}
- if (!match_{{TrimLeft .Name "_"}}(state, ty{{range .TemplateParams}}, {{.GetName}}{{end}})) {
+ if (!Match{{$name}}(state, ty{{range .TemplateParams}}, {{.GetName}}{{end}})) {
return nullptr;
}
{{- range .TemplateParams }}
@@ -315,7 +312,7 @@
return nullptr;
}
{{- end }}
- return build_{{TrimLeft .Name "_"}}(state{{range .TemplateParams}}, {{.GetName}}{{end}});
+ return Build{{$name}}(state{{range .TemplateParams}}, {{.GetName}}{{end}});
},
/* string */ [](MatchState*{{if .TemplateParams}} state{{end}}) -> std::string {
{{- range .TemplateParams }}
@@ -340,13 +337,13 @@
{{- /* ------------------------------------------------------------------ */ -}}
{{- define "TypeMatcher" -}}
{{- /* ------------------------------------------------------------------ */ -}}
-{{- $class := PascalCase .Name -}}
+{{- $name := PascalCase .Name -}}
/// TypeMatcher for 'match {{.Name}}'
-constexpr TypeMatcher k{{$class}}Matcher {
+constexpr TypeMatcher k{{$name}}Matcher {
/* match */ [](MatchState& state, const Type* ty) -> const Type* {
{{- range .PrecedenceSortedTypes }}
- if (match_{{.Name}}(state, ty)) {
- return build_{{.Name}}(state);
+ if (Match{{PascalCase .Name}}(state, ty)) {
+ return Build{{PascalCase .Name}}(state);
}
{{- end }}
return nullptr;