blob: 55eb8b9a87e4bb799862f6bbdf57f35c224b198e [file] [log] [blame]
// Copyright 2021 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
////////////////////////////////////////////////////////////////////////////////
// File generated by tools/src/cmd/gen
// using the template:
// src/tint/resolver/intrinsic_table.inl.tmpl
//
// Do not modify this file directly
////////////////////////////////////////////////////////////////////////////////
// clang-format off
/// TypeMatcher for 'type bool'
class Bool : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* Bool::Match(MatchState& state, const sem::Type* ty) const {
if (!match_bool(ty)) {
return nullptr;
}
return build_bool(state);
}
std::string Bool::String(MatchState*) const {
return "bool";
}
/// TypeMatcher for 'type ia'
class Ia : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* Ia::Match(MatchState& state, const sem::Type* ty) const {
if (!match_ia(ty)) {
return nullptr;
}
return build_ia(state);
}
std::string Ia::String(MatchState*) const {
std::stringstream ss;
ss << "abstract-int";
return ss.str();
}
/// TypeMatcher for 'type fa'
class Fa : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* Fa::Match(MatchState& state, const sem::Type* ty) const {
if (!match_fa(ty)) {
return nullptr;
}
return build_fa(state);
}
std::string Fa::String(MatchState*) const {
std::stringstream ss;
ss << "abstract-float";
return ss.str();
}
/// TypeMatcher for 'type i32'
class I32 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* I32::Match(MatchState& state, const sem::Type* ty) const {
if (!match_i32(ty)) {
return nullptr;
}
return build_i32(state);
}
std::string I32::String(MatchState*) const {
return "i32";
}
/// TypeMatcher for 'type u32'
class U32 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* U32::Match(MatchState& state, const sem::Type* ty) const {
if (!match_u32(ty)) {
return nullptr;
}
return build_u32(state);
}
std::string U32::String(MatchState*) const {
return "u32";
}
/// TypeMatcher for 'type f32'
class F32 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* F32::Match(MatchState& state, const sem::Type* ty) const {
if (!match_f32(ty)) {
return nullptr;
}
return build_f32(state);
}
std::string F32::String(MatchState*) const {
return "f32";
}
/// TypeMatcher for 'type f16'
class F16 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* F16::Match(MatchState& state, const sem::Type* ty) const {
if (!match_f16(ty)) {
return nullptr;
}
return build_f16(state);
}
std::string F16::String(MatchState*) const {
return "f16";
}
/// TypeMatcher for 'type vec2'
class Vec2 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* Vec2::Match(MatchState& state, const sem::Type* ty) const {
const sem::Type* T = nullptr;
if (!match_vec2(ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
return build_vec2(state, T);
}
std::string Vec2::String(MatchState* state) const {
const std::string T = state->TypeName();
return "vec2<" + T + ">";
}
/// TypeMatcher for 'type vec3'
class Vec3 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* Vec3::Match(MatchState& state, const sem::Type* ty) const {
const sem::Type* T = nullptr;
if (!match_vec3(ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
return build_vec3(state, T);
}
std::string Vec3::String(MatchState* state) const {
const std::string T = state->TypeName();
return "vec3<" + T + ">";
}
/// TypeMatcher for 'type vec4'
class Vec4 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* Vec4::Match(MatchState& state, const sem::Type* ty) const {
const sem::Type* T = nullptr;
if (!match_vec4(ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
return build_vec4(state, T);
}
std::string Vec4::String(MatchState* state) const {
const std::string T = state->TypeName();
return "vec4<" + T + ">";
}
/// TypeMatcher for 'type mat2x2'
class Mat2X2 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* Mat2X2::Match(MatchState& state, const sem::Type* ty) const {
const sem::Type* T = nullptr;
if (!match_mat2x2(ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
return build_mat2x2(state, T);
}
std::string Mat2X2::String(MatchState* state) const {
const std::string T = state->TypeName();
return "mat2x2<" + T + ">";
}
/// TypeMatcher for 'type mat2x3'
class Mat2X3 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* Mat2X3::Match(MatchState& state, const sem::Type* ty) const {
const sem::Type* T = nullptr;
if (!match_mat2x3(ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
return build_mat2x3(state, T);
}
std::string Mat2X3::String(MatchState* state) const {
const std::string T = state->TypeName();
return "mat2x3<" + T + ">";
}
/// TypeMatcher for 'type mat2x4'
class Mat2X4 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* Mat2X4::Match(MatchState& state, const sem::Type* ty) const {
const sem::Type* T = nullptr;
if (!match_mat2x4(ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
return build_mat2x4(state, T);
}
std::string Mat2X4::String(MatchState* state) const {
const std::string T = state->TypeName();
return "mat2x4<" + T + ">";
}
/// TypeMatcher for 'type mat3x2'
class Mat3X2 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* Mat3X2::Match(MatchState& state, const sem::Type* ty) const {
const sem::Type* T = nullptr;
if (!match_mat3x2(ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
return build_mat3x2(state, T);
}
std::string Mat3X2::String(MatchState* state) const {
const std::string T = state->TypeName();
return "mat3x2<" + T + ">";
}
/// TypeMatcher for 'type mat3x3'
class Mat3X3 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* Mat3X3::Match(MatchState& state, const sem::Type* ty) const {
const sem::Type* T = nullptr;
if (!match_mat3x3(ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
return build_mat3x3(state, T);
}
std::string Mat3X3::String(MatchState* state) const {
const std::string T = state->TypeName();
return "mat3x3<" + T + ">";
}
/// TypeMatcher for 'type mat3x4'
class Mat3X4 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* Mat3X4::Match(MatchState& state, const sem::Type* ty) const {
const sem::Type* T = nullptr;
if (!match_mat3x4(ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
return build_mat3x4(state, T);
}
std::string Mat3X4::String(MatchState* state) const {
const std::string T = state->TypeName();
return "mat3x4<" + T + ">";
}
/// TypeMatcher for 'type mat4x2'
class Mat4X2 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* Mat4X2::Match(MatchState& state, const sem::Type* ty) const {
const sem::Type* T = nullptr;
if (!match_mat4x2(ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
return build_mat4x2(state, T);
}
std::string Mat4X2::String(MatchState* state) const {
const std::string T = state->TypeName();
return "mat4x2<" + T + ">";
}
/// TypeMatcher for 'type mat4x3'
class Mat4X3 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* Mat4X3::Match(MatchState& state, const sem::Type* ty) const {
const sem::Type* T = nullptr;
if (!match_mat4x3(ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
return build_mat4x3(state, T);
}
std::string Mat4X3::String(MatchState* state) const {
const std::string T = state->TypeName();
return "mat4x3<" + T + ">";
}
/// TypeMatcher for 'type mat4x4'
class Mat4X4 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* Mat4X4::Match(MatchState& state, const sem::Type* ty) const {
const sem::Type* T = nullptr;
if (!match_mat4x4(ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
return build_mat4x4(state, T);
}
std::string Mat4X4::String(MatchState* state) const {
const std::string T = state->TypeName();
return "mat4x4<" + T + ">";
}
/// TypeMatcher for 'type vec'
class Vec : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* Vec::Match(MatchState& state, const sem::Type* ty) const {
Number N = Number::invalid;
const sem::Type* T = nullptr;
if (!match_vec(ty, N, T)) {
return nullptr;
}
N = state.Num(N);
if (!N.IsValid()) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
return build_vec(state, N, T);
}
std::string Vec::String(MatchState* state) const {
const std::string N = state->NumName();
const std::string T = state->TypeName();
std::stringstream ss;
ss << "vec" << N << "<" << T << ">";
return ss.str();
}
/// TypeMatcher for 'type mat'
class Mat : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* Mat::Match(MatchState& state, const sem::Type* ty) const {
Number N = Number::invalid;
Number M = Number::invalid;
const sem::Type* T = nullptr;
if (!match_mat(ty, N, M, T)) {
return nullptr;
}
N = state.Num(N);
if (!N.IsValid()) {
return nullptr;
}
M = state.Num(M);
if (!M.IsValid()) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
return build_mat(state, N, M, T);
}
std::string Mat::String(MatchState* state) const {
const std::string N = state->NumName();
const std::string M = state->NumName();
const std::string T = state->TypeName();
std::stringstream ss;
ss << "mat" << N << "x" << M << "<" << T << ">";
return ss.str();
}
/// TypeMatcher for 'type ptr'
class Ptr : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* Ptr::Match(MatchState& state, const sem::Type* ty) const {
Number S = Number::invalid;
const sem::Type* T = nullptr;
Number A = Number::invalid;
if (!match_ptr(ty, S, T, A)) {
return nullptr;
}
S = state.Num(S);
if (!S.IsValid()) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
A = state.Num(A);
if (!A.IsValid()) {
return nullptr;
}
return build_ptr(state, S, T, A);
}
std::string Ptr::String(MatchState* state) const {
const std::string S = state->NumName();
const std::string T = state->TypeName();
const std::string A = state->NumName();
return "ptr<" + S + ", " + T + ", " + A + ">";
}
/// TypeMatcher for 'type atomic'
class Atomic : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* Atomic::Match(MatchState& state, const sem::Type* ty) const {
const sem::Type* T = nullptr;
if (!match_atomic(ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
return build_atomic(state, T);
}
std::string Atomic::String(MatchState* state) const {
const std::string T = state->TypeName();
return "atomic<" + T + ">";
}
/// TypeMatcher for 'type array'
class Array : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* Array::Match(MatchState& state, const sem::Type* ty) const {
const sem::Type* T = nullptr;
if (!match_array(ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
return build_array(state, T);
}
std::string Array::String(MatchState* state) const {
const std::string T = state->TypeName();
return "array<" + T + ">";
}
/// TypeMatcher for 'type sampler'
class Sampler : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* Sampler::Match(MatchState& state, const sem::Type* ty) const {
if (!match_sampler(ty)) {
return nullptr;
}
return build_sampler(state);
}
std::string Sampler::String(MatchState*) const {
return "sampler";
}
/// TypeMatcher for 'type sampler_comparison'
class SamplerComparison : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* SamplerComparison::Match(MatchState& state, const sem::Type* ty) const {
if (!match_sampler_comparison(ty)) {
return nullptr;
}
return build_sampler_comparison(state);
}
std::string SamplerComparison::String(MatchState*) const {
return "sampler_comparison";
}
/// TypeMatcher for 'type texture_1d'
class Texture1D : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* Texture1D::Match(MatchState& state, const sem::Type* ty) const {
const sem::Type* T = nullptr;
if (!match_texture_1d(ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
return build_texture_1d(state, T);
}
std::string Texture1D::String(MatchState* state) const {
const std::string T = state->TypeName();
return "texture_1d<" + T + ">";
}
/// TypeMatcher for 'type texture_2d'
class Texture2D : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* Texture2D::Match(MatchState& state, const sem::Type* ty) const {
const sem::Type* T = nullptr;
if (!match_texture_2d(ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
return build_texture_2d(state, T);
}
std::string Texture2D::String(MatchState* state) const {
const std::string T = state->TypeName();
return "texture_2d<" + T + ">";
}
/// TypeMatcher for 'type texture_2d_array'
class Texture2DArray : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* Texture2DArray::Match(MatchState& state, const sem::Type* ty) const {
const sem::Type* T = nullptr;
if (!match_texture_2d_array(ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
return build_texture_2d_array(state, T);
}
std::string Texture2DArray::String(MatchState* state) const {
const std::string T = state->TypeName();
return "texture_2d_array<" + T + ">";
}
/// TypeMatcher for 'type texture_3d'
class Texture3D : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* Texture3D::Match(MatchState& state, const sem::Type* ty) const {
const sem::Type* T = nullptr;
if (!match_texture_3d(ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
return build_texture_3d(state, T);
}
std::string Texture3D::String(MatchState* state) const {
const std::string T = state->TypeName();
return "texture_3d<" + T + ">";
}
/// TypeMatcher for 'type texture_cube'
class TextureCube : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* TextureCube::Match(MatchState& state, const sem::Type* ty) const {
const sem::Type* T = nullptr;
if (!match_texture_cube(ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
return build_texture_cube(state, T);
}
std::string TextureCube::String(MatchState* state) const {
const std::string T = state->TypeName();
return "texture_cube<" + T + ">";
}
/// TypeMatcher for 'type texture_cube_array'
class TextureCubeArray : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* TextureCubeArray::Match(MatchState& state, const sem::Type* ty) const {
const sem::Type* T = nullptr;
if (!match_texture_cube_array(ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
return build_texture_cube_array(state, T);
}
std::string TextureCubeArray::String(MatchState* state) const {
const std::string T = state->TypeName();
return "texture_cube_array<" + T + ">";
}
/// TypeMatcher for 'type texture_multisampled_2d'
class TextureMultisampled2D : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* TextureMultisampled2D::Match(MatchState& state, const sem::Type* ty) const {
const sem::Type* T = nullptr;
if (!match_texture_multisampled_2d(ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
return build_texture_multisampled_2d(state, T);
}
std::string TextureMultisampled2D::String(MatchState* state) const {
const std::string T = state->TypeName();
return "texture_multisampled_2d<" + T + ">";
}
/// TypeMatcher for 'type texture_depth_2d'
class TextureDepth2D : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* TextureDepth2D::Match(MatchState& state, const sem::Type* ty) const {
if (!match_texture_depth_2d(ty)) {
return nullptr;
}
return build_texture_depth_2d(state);
}
std::string TextureDepth2D::String(MatchState*) const {
return "texture_depth_2d";
}
/// TypeMatcher for 'type texture_depth_2d_array'
class TextureDepth2DArray : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* TextureDepth2DArray::Match(MatchState& state, const sem::Type* ty) const {
if (!match_texture_depth_2d_array(ty)) {
return nullptr;
}
return build_texture_depth_2d_array(state);
}
std::string TextureDepth2DArray::String(MatchState*) const {
return "texture_depth_2d_array";
}
/// TypeMatcher for 'type texture_depth_cube'
class TextureDepthCube : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* TextureDepthCube::Match(MatchState& state, const sem::Type* ty) const {
if (!match_texture_depth_cube(ty)) {
return nullptr;
}
return build_texture_depth_cube(state);
}
std::string TextureDepthCube::String(MatchState*) const {
return "texture_depth_cube";
}
/// TypeMatcher for 'type texture_depth_cube_array'
class TextureDepthCubeArray : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* TextureDepthCubeArray::Match(MatchState& state, const sem::Type* ty) const {
if (!match_texture_depth_cube_array(ty)) {
return nullptr;
}
return build_texture_depth_cube_array(state);
}
std::string TextureDepthCubeArray::String(MatchState*) const {
return "texture_depth_cube_array";
}
/// TypeMatcher for 'type texture_depth_multisampled_2d'
class TextureDepthMultisampled2D : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* TextureDepthMultisampled2D::Match(MatchState& state, const sem::Type* ty) const {
if (!match_texture_depth_multisampled_2d(ty)) {
return nullptr;
}
return build_texture_depth_multisampled_2d(state);
}
std::string TextureDepthMultisampled2D::String(MatchState*) const {
return "texture_depth_multisampled_2d";
}
/// TypeMatcher for 'type texture_storage_1d'
class TextureStorage1D : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* TextureStorage1D::Match(MatchState& state, const sem::Type* ty) const {
Number F = Number::invalid;
Number A = Number::invalid;
if (!match_texture_storage_1d(ty, F, A)) {
return nullptr;
}
F = state.Num(F);
if (!F.IsValid()) {
return nullptr;
}
A = state.Num(A);
if (!A.IsValid()) {
return nullptr;
}
return build_texture_storage_1d(state, F, A);
}
std::string TextureStorage1D::String(MatchState* state) const {
const std::string F = state->NumName();
const std::string A = state->NumName();
return "texture_storage_1d<" + F + ", " + A + ">";
}
/// TypeMatcher for 'type texture_storage_2d'
class TextureStorage2D : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* TextureStorage2D::Match(MatchState& state, const sem::Type* ty) const {
Number F = Number::invalid;
Number A = Number::invalid;
if (!match_texture_storage_2d(ty, F, A)) {
return nullptr;
}
F = state.Num(F);
if (!F.IsValid()) {
return nullptr;
}
A = state.Num(A);
if (!A.IsValid()) {
return nullptr;
}
return build_texture_storage_2d(state, F, A);
}
std::string TextureStorage2D::String(MatchState* state) const {
const std::string F = state->NumName();
const std::string A = state->NumName();
return "texture_storage_2d<" + F + ", " + A + ">";
}
/// TypeMatcher for 'type texture_storage_2d_array'
class TextureStorage2DArray : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* TextureStorage2DArray::Match(MatchState& state, const sem::Type* ty) const {
Number F = Number::invalid;
Number A = Number::invalid;
if (!match_texture_storage_2d_array(ty, F, A)) {
return nullptr;
}
F = state.Num(F);
if (!F.IsValid()) {
return nullptr;
}
A = state.Num(A);
if (!A.IsValid()) {
return nullptr;
}
return build_texture_storage_2d_array(state, F, A);
}
std::string TextureStorage2DArray::String(MatchState* state) const {
const std::string F = state->NumName();
const std::string A = state->NumName();
return "texture_storage_2d_array<" + F + ", " + A + ">";
}
/// TypeMatcher for 'type texture_storage_3d'
class TextureStorage3D : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* TextureStorage3D::Match(MatchState& state, const sem::Type* ty) const {
Number F = Number::invalid;
Number A = Number::invalid;
if (!match_texture_storage_3d(ty, F, A)) {
return nullptr;
}
F = state.Num(F);
if (!F.IsValid()) {
return nullptr;
}
A = state.Num(A);
if (!A.IsValid()) {
return nullptr;
}
return build_texture_storage_3d(state, F, A);
}
std::string TextureStorage3D::String(MatchState* state) const {
const std::string F = state->NumName();
const std::string A = state->NumName();
return "texture_storage_3d<" + F + ", " + A + ">";
}
/// TypeMatcher for 'type texture_external'
class TextureExternal : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* TextureExternal::Match(MatchState& state, const sem::Type* ty) const {
if (!match_texture_external(ty)) {
return nullptr;
}
return build_texture_external(state);
}
std::string TextureExternal::String(MatchState*) const {
return "texture_external";
}
/// TypeMatcher for 'type __modf_result'
class ModfResult : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* ModfResult::Match(MatchState& state, const sem::Type* ty) const {
const sem::Type* T = nullptr;
if (!match_modf_result(ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
return build_modf_result(state, T);
}
std::string ModfResult::String(MatchState* state) const {
const std::string T = state->TypeName();
std::stringstream ss;
ss << "__modf_result_" << T;
return ss.str();
}
/// TypeMatcher for 'type __modf_result_vec'
class ModfResultVec : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* ModfResultVec::Match(MatchState& state, const sem::Type* ty) const {
Number N = Number::invalid;
const sem::Type* T = nullptr;
if (!match_modf_result_vec(ty, N, T)) {
return nullptr;
}
N = state.Num(N);
if (!N.IsValid()) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
return build_modf_result_vec(state, N, T);
}
std::string ModfResultVec::String(MatchState* state) const {
const std::string N = state->NumName();
const std::string T = state->TypeName();
std::stringstream ss;
ss << "__modf_result_vec" << N << "_" << T;
return ss.str();
}
/// TypeMatcher for 'type __frexp_result'
class FrexpResult : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* FrexpResult::Match(MatchState& state, const sem::Type* ty) const {
const sem::Type* T = nullptr;
if (!match_frexp_result(ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
return build_frexp_result(state, T);
}
std::string FrexpResult::String(MatchState* state) const {
const std::string T = state->TypeName();
std::stringstream ss;
ss << "__frexp_result_" << T;
return ss.str();
}
/// TypeMatcher for 'type __frexp_result_vec'
class FrexpResultVec : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* FrexpResultVec::Match(MatchState& state, const sem::Type* ty) const {
Number N = Number::invalid;
const sem::Type* T = nullptr;
if (!match_frexp_result_vec(ty, N, T)) {
return nullptr;
}
N = state.Num(N);
if (!N.IsValid()) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
return build_frexp_result_vec(state, N, T);
}
std::string FrexpResultVec::String(MatchState* state) const {
const std::string N = state->NumName();
const std::string T = state->TypeName();
std::stringstream ss;
ss << "__frexp_result_vec" << N << "_" << T;
return ss.str();
}
/// TypeMatcher for 'type __atomic_compare_exchange_result'
class AtomicCompareExchangeResult : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* AtomicCompareExchangeResult::Match(MatchState& state, const sem::Type* ty) const {
const sem::Type* T = nullptr;
if (!match_atomic_compare_exchange_result(ty, T)) {
return nullptr;
}
T = state.Type(T);
if (T == nullptr) {
return nullptr;
}
return build_atomic_compare_exchange_result(state, T);
}
std::string AtomicCompareExchangeResult::String(MatchState* state) const {
const std::string T = state->TypeName();
return "__atomic_compare_exchange_result<" + T + ">";
}
/// TypeMatcher for 'match abstract_or_scalar'
class AbstractOrScalar : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
/// expected, canonicalized type on success.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* AbstractOrScalar::Match(MatchState& state, const sem::Type* ty) const {
if (match_ia(ty)) {
return build_ia(state);
}
if (match_fa(ty)) {
return build_fa(state);
}
if (match_i32(ty)) {
return build_i32(state);
}
if (match_u32(ty)) {
return build_u32(state);
}
if (match_f32(ty)) {
return build_f32(state);
}
if (match_f16(ty)) {
return build_f16(state);
}
if (match_bool(ty)) {
return build_bool(state);
}
return nullptr;
}
std::string AbstractOrScalar::String(MatchState*) const {
std::stringstream ss;
// Note: We pass nullptr to the TypeMatcher::String() functions, as 'matcher's do not support
// template arguments, nor can they match sub-types. As such, they have no use for the MatchState.
ss << Ia().String(nullptr) << ", " << Fa().String(nullptr) << ", " << F32().String(nullptr) << ", " << F16().String(nullptr) << ", " << I32().String(nullptr) << ", " << U32().String(nullptr) << " or " << Bool().String(nullptr);
return ss.str();
}
/// TypeMatcher for 'match scalar'
class Scalar : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
/// expected, canonicalized type on success.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* Scalar::Match(MatchState& state, const sem::Type* ty) const {
if (match_i32(ty)) {
return build_i32(state);
}
if (match_u32(ty)) {
return build_u32(state);
}
if (match_f32(ty)) {
return build_f32(state);
}
if (match_f16(ty)) {
return build_f16(state);
}
if (match_bool(ty)) {
return build_bool(state);
}
return nullptr;
}
std::string Scalar::String(MatchState*) const {
std::stringstream ss;
// Note: We pass nullptr to the TypeMatcher::String() functions, as 'matcher's do not support
// template arguments, nor can they match sub-types. As such, they have no use for the MatchState.
ss << F32().String(nullptr) << ", " << F16().String(nullptr) << ", " << I32().String(nullptr) << ", " << U32().String(nullptr) << " or " << Bool().String(nullptr);
return ss.str();
}
/// TypeMatcher for 'match scalar_no_f32'
class ScalarNoF32 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
/// expected, canonicalized type on success.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* ScalarNoF32::Match(MatchState& state, const sem::Type* ty) const {
if (match_i32(ty)) {
return build_i32(state);
}
if (match_u32(ty)) {
return build_u32(state);
}
if (match_f16(ty)) {
return build_f16(state);
}
if (match_bool(ty)) {
return build_bool(state);
}
return nullptr;
}
std::string ScalarNoF32::String(MatchState*) const {
std::stringstream ss;
// Note: We pass nullptr to the TypeMatcher::String() functions, as 'matcher's do not support
// template arguments, nor can they match sub-types. As such, they have no use for the MatchState.
ss << I32().String(nullptr) << ", " << F16().String(nullptr) << ", " << U32().String(nullptr) << " or " << Bool().String(nullptr);
return ss.str();
}
/// TypeMatcher for 'match scalar_no_f16'
class ScalarNoF16 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
/// expected, canonicalized type on success.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* ScalarNoF16::Match(MatchState& state, const sem::Type* ty) const {
if (match_i32(ty)) {
return build_i32(state);
}
if (match_u32(ty)) {
return build_u32(state);
}
if (match_f32(ty)) {
return build_f32(state);
}
if (match_bool(ty)) {
return build_bool(state);
}
return nullptr;
}
std::string ScalarNoF16::String(MatchState*) const {
std::stringstream ss;
// Note: We pass nullptr to the TypeMatcher::String() functions, as 'matcher's do not support
// template arguments, nor can they match sub-types. As such, they have no use for the MatchState.
ss << F32().String(nullptr) << ", " << I32().String(nullptr) << ", " << U32().String(nullptr) << " or " << Bool().String(nullptr);
return ss.str();
}
/// TypeMatcher for 'match scalar_no_i32'
class ScalarNoI32 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
/// expected, canonicalized type on success.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* ScalarNoI32::Match(MatchState& state, const sem::Type* ty) const {
if (match_u32(ty)) {
return build_u32(state);
}
if (match_f32(ty)) {
return build_f32(state);
}
if (match_f16(ty)) {
return build_f16(state);
}
if (match_bool(ty)) {
return build_bool(state);
}
return nullptr;
}
std::string ScalarNoI32::String(MatchState*) const {
std::stringstream ss;
// Note: We pass nullptr to the TypeMatcher::String() functions, as 'matcher's do not support
// template arguments, nor can they match sub-types. As such, they have no use for the MatchState.
ss << F32().String(nullptr) << ", " << F16().String(nullptr) << ", " << U32().String(nullptr) << " or " << Bool().String(nullptr);
return ss.str();
}
/// TypeMatcher for 'match scalar_no_u32'
class ScalarNoU32 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
/// expected, canonicalized type on success.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* ScalarNoU32::Match(MatchState& state, const sem::Type* ty) const {
if (match_i32(ty)) {
return build_i32(state);
}
if (match_f32(ty)) {
return build_f32(state);
}
if (match_f16(ty)) {
return build_f16(state);
}
if (match_bool(ty)) {
return build_bool(state);
}
return nullptr;
}
std::string ScalarNoU32::String(MatchState*) const {
std::stringstream ss;
// Note: We pass nullptr to the TypeMatcher::String() functions, as 'matcher's do not support
// template arguments, nor can they match sub-types. As such, they have no use for the MatchState.
ss << F32().String(nullptr) << ", " << F16().String(nullptr) << ", " << I32().String(nullptr) << " or " << Bool().String(nullptr);
return ss.str();
}
/// TypeMatcher for 'match scalar_no_bool'
class ScalarNoBool : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
/// expected, canonicalized type on success.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* ScalarNoBool::Match(MatchState& state, const sem::Type* ty) const {
if (match_i32(ty)) {
return build_i32(state);
}
if (match_u32(ty)) {
return build_u32(state);
}
if (match_f32(ty)) {
return build_f32(state);
}
if (match_f16(ty)) {
return build_f16(state);
}
return nullptr;
}
std::string ScalarNoBool::String(MatchState*) const {
std::stringstream ss;
// Note: We pass nullptr to the TypeMatcher::String() functions, as 'matcher's do not support
// template arguments, nor can they match sub-types. As such, they have no use for the MatchState.
ss << F32().String(nullptr) << ", " << F16().String(nullptr) << ", " << I32().String(nullptr) << " or " << U32().String(nullptr);
return ss.str();
}
/// TypeMatcher for 'match fia_fiu32_f16'
class FiaFiu32F16 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
/// expected, canonicalized type on success.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* FiaFiu32F16::Match(MatchState& state, const sem::Type* ty) const {
if (match_ia(ty)) {
return build_ia(state);
}
if (match_fa(ty)) {
return build_fa(state);
}
if (match_i32(ty)) {
return build_i32(state);
}
if (match_u32(ty)) {
return build_u32(state);
}
if (match_f32(ty)) {
return build_f32(state);
}
if (match_f16(ty)) {
return build_f16(state);
}
return nullptr;
}
std::string FiaFiu32F16::String(MatchState*) const {
std::stringstream ss;
// Note: We pass nullptr to the TypeMatcher::String() functions, as 'matcher's do not support
// template arguments, nor can they match sub-types. As such, they have no use for the MatchState.
ss << Fa().String(nullptr) << ", " << Ia().String(nullptr) << ", " << F32().String(nullptr) << ", " << I32().String(nullptr) << ", " << U32().String(nullptr) << " or " << F16().String(nullptr);
return ss.str();
}
/// TypeMatcher for 'match fia_fi32_f16'
class FiaFi32F16 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
/// expected, canonicalized type on success.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* FiaFi32F16::Match(MatchState& state, const sem::Type* ty) const {
if (match_ia(ty)) {
return build_ia(state);
}
if (match_fa(ty)) {
return build_fa(state);
}
if (match_i32(ty)) {
return build_i32(state);
}
if (match_f32(ty)) {
return build_f32(state);
}
if (match_f16(ty)) {
return build_f16(state);
}
return nullptr;
}
std::string FiaFi32F16::String(MatchState*) const {
std::stringstream ss;
// Note: We pass nullptr to the TypeMatcher::String() functions, as 'matcher's do not support
// template arguments, nor can they match sub-types. As such, they have no use for the MatchState.
ss << Fa().String(nullptr) << ", " << Ia().String(nullptr) << ", " << F32().String(nullptr) << ", " << I32().String(nullptr) << " or " << F16().String(nullptr);
return ss.str();
}
/// TypeMatcher for 'match fia_fiu32'
class FiaFiu32 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
/// expected, canonicalized type on success.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* FiaFiu32::Match(MatchState& state, const sem::Type* ty) const {
if (match_ia(ty)) {
return build_ia(state);
}
if (match_fa(ty)) {
return build_fa(state);
}
if (match_i32(ty)) {
return build_i32(state);
}
if (match_u32(ty)) {
return build_u32(state);
}
if (match_f32(ty)) {
return build_f32(state);
}
return nullptr;
}
std::string FiaFiu32::String(MatchState*) const {
std::stringstream ss;
// Note: We pass nullptr to the TypeMatcher::String() functions, as 'matcher's do not support
// template arguments, nor can they match sub-types. As such, they have no use for the MatchState.
ss << Fa().String(nullptr) << ", " << Ia().String(nullptr) << ", " << F32().String(nullptr) << ", " << I32().String(nullptr) << " or " << U32().String(nullptr);
return ss.str();
}
/// TypeMatcher for 'match fa_f32'
class FaF32 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
/// expected, canonicalized type on success.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* FaF32::Match(MatchState& state, const sem::Type* ty) const {
if (match_fa(ty)) {
return build_fa(state);
}
if (match_f32(ty)) {
return build_f32(state);
}
return nullptr;
}
std::string FaF32::String(MatchState*) const {
std::stringstream ss;
// Note: We pass nullptr to the TypeMatcher::String() functions, as 'matcher's do not support
// template arguments, nor can they match sub-types. As such, they have no use for the MatchState.
ss << Fa().String(nullptr) << " or " << F32().String(nullptr);
return ss.str();
}
/// TypeMatcher for 'match fa_f32_f16'
class FaF32F16 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
/// expected, canonicalized type on success.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* FaF32F16::Match(MatchState& state, const sem::Type* ty) const {
if (match_fa(ty)) {
return build_fa(state);
}
if (match_f32(ty)) {
return build_f32(state);
}
if (match_f16(ty)) {
return build_f16(state);
}
return nullptr;
}
std::string FaF32F16::String(MatchState*) const {
std::stringstream ss;
// Note: We pass nullptr to the TypeMatcher::String() functions, as 'matcher's do not support
// template arguments, nor can they match sub-types. As such, they have no use for the MatchState.
ss << Fa().String(nullptr) << ", " << F32().String(nullptr) << " or " << F16().String(nullptr);
return ss.str();
}
/// TypeMatcher for 'match ia_iu32'
class IaIu32 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
/// expected, canonicalized type on success.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* IaIu32::Match(MatchState& state, const sem::Type* ty) const {
if (match_ia(ty)) {
return build_ia(state);
}
if (match_i32(ty)) {
return build_i32(state);
}
if (match_u32(ty)) {
return build_u32(state);
}
return nullptr;
}
std::string IaIu32::String(MatchState*) const {
std::stringstream ss;
// Note: We pass nullptr to the TypeMatcher::String() functions, as 'matcher's do not support
// template arguments, nor can they match sub-types. As such, they have no use for the MatchState.
ss << Ia().String(nullptr) << ", " << I32().String(nullptr) << " or " << U32().String(nullptr);
return ss.str();
}
/// TypeMatcher for 'match fiu32_f16'
class Fiu32F16 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
/// expected, canonicalized type on success.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* Fiu32F16::Match(MatchState& state, const sem::Type* ty) const {
if (match_i32(ty)) {
return build_i32(state);
}
if (match_u32(ty)) {
return build_u32(state);
}
if (match_f32(ty)) {
return build_f32(state);
}
if (match_f16(ty)) {
return build_f16(state);
}
return nullptr;
}
std::string Fiu32F16::String(MatchState*) const {
std::stringstream ss;
// Note: We pass nullptr to the TypeMatcher::String() functions, as 'matcher's do not support
// template arguments, nor can they match sub-types. As such, they have no use for the MatchState.
ss << F32().String(nullptr) << ", " << I32().String(nullptr) << ", " << U32().String(nullptr) << " or " << F16().String(nullptr);
return ss.str();
}
/// TypeMatcher for 'match fiu32'
class Fiu32 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
/// expected, canonicalized type on success.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* Fiu32::Match(MatchState& state, const sem::Type* ty) const {
if (match_i32(ty)) {
return build_i32(state);
}
if (match_u32(ty)) {
return build_u32(state);
}
if (match_f32(ty)) {
return build_f32(state);
}
return nullptr;
}
std::string Fiu32::String(MatchState*) const {
std::stringstream ss;
// Note: We pass nullptr to the TypeMatcher::String() functions, as 'matcher's do not support
// template arguments, nor can they match sub-types. As such, they have no use for the MatchState.
ss << F32().String(nullptr) << ", " << I32().String(nullptr) << " or " << U32().String(nullptr);
return ss.str();
}
/// TypeMatcher for 'match fi32_f16'
class Fi32F16 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
/// expected, canonicalized type on success.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* Fi32F16::Match(MatchState& state, const sem::Type* ty) const {
if (match_i32(ty)) {
return build_i32(state);
}
if (match_f32(ty)) {
return build_f32(state);
}
if (match_f16(ty)) {
return build_f16(state);
}
return nullptr;
}
std::string Fi32F16::String(MatchState*) const {
std::stringstream ss;
// Note: We pass nullptr to the TypeMatcher::String() functions, as 'matcher's do not support
// template arguments, nor can they match sub-types. As such, they have no use for the MatchState.
ss << F32().String(nullptr) << ", " << I32().String(nullptr) << " or " << F16().String(nullptr);
return ss.str();
}
/// TypeMatcher for 'match fi32'
class Fi32 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
/// expected, canonicalized type on success.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* Fi32::Match(MatchState& state, const sem::Type* ty) const {
if (match_i32(ty)) {
return build_i32(state);
}
if (match_f32(ty)) {
return build_f32(state);
}
return nullptr;
}
std::string Fi32::String(MatchState*) const {
std::stringstream ss;
// Note: We pass nullptr to the TypeMatcher::String() functions, as 'matcher's do not support
// template arguments, nor can they match sub-types. As such, they have no use for the MatchState.
ss << F32().String(nullptr) << " or " << I32().String(nullptr);
return ss.str();
}
/// TypeMatcher for 'match f32_f16'
class F32F16 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
/// expected, canonicalized type on success.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* F32F16::Match(MatchState& state, const sem::Type* ty) const {
if (match_f32(ty)) {
return build_f32(state);
}
if (match_f16(ty)) {
return build_f16(state);
}
return nullptr;
}
std::string F32F16::String(MatchState*) const {
std::stringstream ss;
// Note: We pass nullptr to the TypeMatcher::String() functions, as 'matcher's do not support
// template arguments, nor can they match sub-types. As such, they have no use for the MatchState.
ss << F32().String(nullptr) << " or " << F16().String(nullptr);
return ss.str();
}
/// TypeMatcher for 'match iu32'
class Iu32 : public TypeMatcher {
public:
/// Checks whether the given type matches the matcher rules, and returns the
/// expected, canonicalized type on success.
/// Match may define and refine the template types and numbers in state.
/// @param state the MatchState
/// @param type the type to match
/// @returns the canonicalized type on match, otherwise nullptr
const sem::Type* Match(MatchState& state,
const sem::Type* type) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
const sem::Type* Iu32::Match(MatchState& state, const sem::Type* ty) const {
if (match_i32(ty)) {
return build_i32(state);
}
if (match_u32(ty)) {
return build_u32(state);
}
return nullptr;
}
std::string Iu32::String(MatchState*) const {
std::stringstream ss;
// Note: We pass nullptr to the TypeMatcher::String() functions, as 'matcher's do not support
// template arguments, nor can they match sub-types. As such, they have no use for the MatchState.
ss << I32().String(nullptr) << " or " << U32().String(nullptr);
return ss.str();
}
/// EnumMatcher for 'match f32_texel_format'
class F32TexelFormat : public NumberMatcher {
public:
/// Checks whether the given number matches the enum matcher rules.
/// Match may define template numbers in state.
/// @param state the MatchState
/// @param number the enum value as a Number
/// @return true if the enum value matches the set
Number Match(MatchState& state, Number number) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
Number F32TexelFormat::Match(MatchState&, Number number) const {
switch (static_cast<TexelFormat>(number.Value())) {
case TexelFormat::kRgba8Unorm:
case TexelFormat::kRgba8Snorm:
case TexelFormat::kRgba16Float:
case TexelFormat::kR32Float:
case TexelFormat::kRg32Float:
case TexelFormat::kRgba32Float:
return number;
default:
return Number::invalid;
}
}
std::string F32TexelFormat::String(MatchState*) const {
return "rgba8unorm, rgba8snorm, rgba16float, r32float, rg32float or rgba32float";
}
/// EnumMatcher for 'match i32_texel_format'
class I32TexelFormat : public NumberMatcher {
public:
/// Checks whether the given number matches the enum matcher rules.
/// Match may define template numbers in state.
/// @param state the MatchState
/// @param number the enum value as a Number
/// @return true if the enum value matches the set
Number Match(MatchState& state, Number number) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
Number I32TexelFormat::Match(MatchState&, Number number) const {
switch (static_cast<TexelFormat>(number.Value())) {
case TexelFormat::kRgba8Sint:
case TexelFormat::kRgba16Sint:
case TexelFormat::kR32Sint:
case TexelFormat::kRg32Sint:
case TexelFormat::kRgba32Sint:
return number;
default:
return Number::invalid;
}
}
std::string I32TexelFormat::String(MatchState*) const {
return "rgba8sint, rgba16sint, r32sint, rg32sint or rgba32sint";
}
/// EnumMatcher for 'match u32_texel_format'
class U32TexelFormat : public NumberMatcher {
public:
/// Checks whether the given number matches the enum matcher rules.
/// Match may define template numbers in state.
/// @param state the MatchState
/// @param number the enum value as a Number
/// @return true if the enum value matches the set
Number Match(MatchState& state, Number number) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
Number U32TexelFormat::Match(MatchState&, Number number) const {
switch (static_cast<TexelFormat>(number.Value())) {
case TexelFormat::kRgba8Uint:
case TexelFormat::kRgba16Uint:
case TexelFormat::kR32Uint:
case TexelFormat::kRg32Uint:
case TexelFormat::kRgba32Uint:
return number;
default:
return Number::invalid;
}
}
std::string U32TexelFormat::String(MatchState*) const {
return "rgba8uint, rgba16uint, r32uint, rg32uint or rgba32uint";
}
/// EnumMatcher for 'match write'
class Write : public NumberMatcher {
public:
/// Checks whether the given number matches the enum matcher rules.
/// Match may define template numbers in state.
/// @param state the MatchState
/// @param number the enum value as a Number
/// @return true if the enum value matches the set
Number Match(MatchState& state, Number number) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
Number Write::Match(MatchState&, Number number) const {
if (number.IsAny() || number.Value() == static_cast<uint32_t>(Access::kWrite)) {
return Number(static_cast<uint32_t>(Access::kWrite));
}
return Number::invalid;
}
std::string Write::String(MatchState*) const {
return "write";
}
/// EnumMatcher for 'match read_write'
class ReadWrite : public NumberMatcher {
public:
/// Checks whether the given number matches the enum matcher rules.
/// Match may define template numbers in state.
/// @param state the MatchState
/// @param number the enum value as a Number
/// @return true if the enum value matches the set
Number Match(MatchState& state, Number number) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
Number ReadWrite::Match(MatchState&, Number number) const {
if (number.IsAny() || number.Value() == static_cast<uint32_t>(Access::kReadWrite)) {
return Number(static_cast<uint32_t>(Access::kReadWrite));
}
return Number::invalid;
}
std::string ReadWrite::String(MatchState*) const {
return "read_write";
}
/// EnumMatcher for 'match function_private_workgroup'
class FunctionPrivateWorkgroup : public NumberMatcher {
public:
/// Checks whether the given number matches the enum matcher rules.
/// Match may define template numbers in state.
/// @param state the MatchState
/// @param number the enum value as a Number
/// @return true if the enum value matches the set
Number Match(MatchState& state, Number number) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
Number FunctionPrivateWorkgroup::Match(MatchState&, Number number) const {
switch (static_cast<StorageClass>(number.Value())) {
case StorageClass::kFunction:
case StorageClass::kPrivate:
case StorageClass::kWorkgroup:
return number;
default:
return Number::invalid;
}
}
std::string FunctionPrivateWorkgroup::String(MatchState*) const {
return "function, private or workgroup";
}
/// EnumMatcher for 'match workgroup_or_storage'
class WorkgroupOrStorage : public NumberMatcher {
public:
/// Checks whether the given number matches the enum matcher rules.
/// Match may define template numbers in state.
/// @param state the MatchState
/// @param number the enum value as a Number
/// @return true if the enum value matches the set
Number Match(MatchState& state, Number number) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
Number WorkgroupOrStorage::Match(MatchState&, Number number) const {
switch (static_cast<StorageClass>(number.Value())) {
case StorageClass::kWorkgroup:
case StorageClass::kStorage:
return number;
default:
return Number::invalid;
}
}
std::string WorkgroupOrStorage::String(MatchState*) const {
return "workgroup or storage";
}
/// EnumMatcher for 'match storage'
class Storage : public NumberMatcher {
public:
/// Checks whether the given number matches the enum matcher rules.
/// Match may define template numbers in state.
/// @param state the MatchState
/// @param number the enum value as a Number
/// @return true if the enum value matches the set
Number Match(MatchState& state, Number number) const override;
/// @param state the MatchState
/// @return a string representation of the matcher.
std::string String(MatchState* state) const override;
};
Number Storage::Match(MatchState&, Number number) const {
if (number.IsAny() || number.Value() == static_cast<uint32_t>(StorageClass::kStorage)) {
return Number(static_cast<uint32_t>(StorageClass::kStorage));
}
return Number::invalid;
}
std::string Storage::String(MatchState*) const {
return "storage";
}
/// Matchers holds type and number matchers
class Matchers {
private:
TemplateTypeMatcher template_type_0_{0};
TemplateTypeMatcher template_type_1_{1};
TemplateNumberMatcher template_number_0_{0};
TemplateNumberMatcher template_number_1_{1};
TemplateNumberMatcher template_number_2_{2};
Bool Bool_;
Ia Ia_;
Fa Fa_;
I32 I32_;
U32 U32_;
F32 F32_;