Move type/builtin to builtin.

This CL moves type::Builtin to builtin::Builtin.

Change-Id: I8b058dfcac38f782e07393b69e38534175f67524
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/120403
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
dan sinclair
2023-02-19 04:28:04 +00:00
committed by Dawn LUCI CQ
parent ba082fdb48
commit ef30aa400c
16 changed files with 145 additions and 144 deletions

View File

@@ -1,387 +0,0 @@
// Copyright 2022 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
////////////////////////////////////////////////////////////////////////////////
// File generated by tools/src/cmd/gen
// using the template:
// src/tint/type/builtin.cc.tmpl
//
// Do not modify this file directly
////////////////////////////////////////////////////////////////////////////////
#include "src/tint/type/builtin.h"
namespace tint::type {
/// ParseBuiltin parses a Builtin from a string.
/// @param str the string to parse
/// @returns the parsed enum, or Builtin::kUndefined if the string could not be parsed.
Builtin ParseBuiltin(std::string_view str) {
if (str == "array") {
return Builtin::kArray;
}
if (str == "atomic") {
return Builtin::kAtomic;
}
if (str == "bool") {
return Builtin::kBool;
}
if (str == "f16") {
return Builtin::kF16;
}
if (str == "f32") {
return Builtin::kF32;
}
if (str == "i32") {
return Builtin::kI32;
}
if (str == "mat2x2") {
return Builtin::kMat2X2;
}
if (str == "mat2x2f") {
return Builtin::kMat2X2F;
}
if (str == "mat2x2h") {
return Builtin::kMat2X2H;
}
if (str == "mat2x3") {
return Builtin::kMat2X3;
}
if (str == "mat2x3f") {
return Builtin::kMat2X3F;
}
if (str == "mat2x3h") {
return Builtin::kMat2X3H;
}
if (str == "mat2x4") {
return Builtin::kMat2X4;
}
if (str == "mat2x4f") {
return Builtin::kMat2X4F;
}
if (str == "mat2x4h") {
return Builtin::kMat2X4H;
}
if (str == "mat3x2") {
return Builtin::kMat3X2;
}
if (str == "mat3x2f") {
return Builtin::kMat3X2F;
}
if (str == "mat3x2h") {
return Builtin::kMat3X2H;
}
if (str == "mat3x3") {
return Builtin::kMat3X3;
}
if (str == "mat3x3f") {
return Builtin::kMat3X3F;
}
if (str == "mat3x3h") {
return Builtin::kMat3X3H;
}
if (str == "mat3x4") {
return Builtin::kMat3X4;
}
if (str == "mat3x4f") {
return Builtin::kMat3X4F;
}
if (str == "mat3x4h") {
return Builtin::kMat3X4H;
}
if (str == "mat4x2") {
return Builtin::kMat4X2;
}
if (str == "mat4x2f") {
return Builtin::kMat4X2F;
}
if (str == "mat4x2h") {
return Builtin::kMat4X2H;
}
if (str == "mat4x3") {
return Builtin::kMat4X3;
}
if (str == "mat4x3f") {
return Builtin::kMat4X3F;
}
if (str == "mat4x3h") {
return Builtin::kMat4X3H;
}
if (str == "mat4x4") {
return Builtin::kMat4X4;
}
if (str == "mat4x4f") {
return Builtin::kMat4X4F;
}
if (str == "mat4x4h") {
return Builtin::kMat4X4H;
}
if (str == "ptr") {
return Builtin::kPtr;
}
if (str == "sampler") {
return Builtin::kSampler;
}
if (str == "sampler_comparison") {
return Builtin::kSamplerComparison;
}
if (str == "texture_1d") {
return Builtin::kTexture1D;
}
if (str == "texture_2d") {
return Builtin::kTexture2D;
}
if (str == "texture_2d_array") {
return Builtin::kTexture2DArray;
}
if (str == "texture_3d") {
return Builtin::kTexture3D;
}
if (str == "texture_cube") {
return Builtin::kTextureCube;
}
if (str == "texture_cube_array") {
return Builtin::kTextureCubeArray;
}
if (str == "texture_depth_2d") {
return Builtin::kTextureDepth2D;
}
if (str == "texture_depth_2d_array") {
return Builtin::kTextureDepth2DArray;
}
if (str == "texture_depth_cube") {
return Builtin::kTextureDepthCube;
}
if (str == "texture_depth_cube_array") {
return Builtin::kTextureDepthCubeArray;
}
if (str == "texture_depth_multisampled_2d") {
return Builtin::kTextureDepthMultisampled2D;
}
if (str == "texture_external") {
return Builtin::kTextureExternal;
}
if (str == "texture_multisampled_2d") {
return Builtin::kTextureMultisampled2D;
}
if (str == "texture_storage_1d") {
return Builtin::kTextureStorage1D;
}
if (str == "texture_storage_2d") {
return Builtin::kTextureStorage2D;
}
if (str == "texture_storage_2d_array") {
return Builtin::kTextureStorage2DArray;
}
if (str == "texture_storage_3d") {
return Builtin::kTextureStorage3D;
}
if (str == "u32") {
return Builtin::kU32;
}
if (str == "vec2") {
return Builtin::kVec2;
}
if (str == "vec2f") {
return Builtin::kVec2F;
}
if (str == "vec2h") {
return Builtin::kVec2H;
}
if (str == "vec2i") {
return Builtin::kVec2I;
}
if (str == "vec2u") {
return Builtin::kVec2U;
}
if (str == "vec3") {
return Builtin::kVec3;
}
if (str == "vec3f") {
return Builtin::kVec3F;
}
if (str == "vec3h") {
return Builtin::kVec3H;
}
if (str == "vec3i") {
return Builtin::kVec3I;
}
if (str == "vec3u") {
return Builtin::kVec3U;
}
if (str == "vec4") {
return Builtin::kVec4;
}
if (str == "vec4f") {
return Builtin::kVec4F;
}
if (str == "vec4h") {
return Builtin::kVec4H;
}
if (str == "vec4i") {
return Builtin::kVec4I;
}
if (str == "vec4u") {
return Builtin::kVec4U;
}
return Builtin::kUndefined;
}
std::ostream& operator<<(std::ostream& out, Builtin value) {
switch (value) {
case Builtin::kUndefined:
return out << "undefined";
case Builtin::kArray:
return out << "array";
case Builtin::kAtomic:
return out << "atomic";
case Builtin::kBool:
return out << "bool";
case Builtin::kF16:
return out << "f16";
case Builtin::kF32:
return out << "f32";
case Builtin::kI32:
return out << "i32";
case Builtin::kMat2X2:
return out << "mat2x2";
case Builtin::kMat2X2F:
return out << "mat2x2f";
case Builtin::kMat2X2H:
return out << "mat2x2h";
case Builtin::kMat2X3:
return out << "mat2x3";
case Builtin::kMat2X3F:
return out << "mat2x3f";
case Builtin::kMat2X3H:
return out << "mat2x3h";
case Builtin::kMat2X4:
return out << "mat2x4";
case Builtin::kMat2X4F:
return out << "mat2x4f";
case Builtin::kMat2X4H:
return out << "mat2x4h";
case Builtin::kMat3X2:
return out << "mat3x2";
case Builtin::kMat3X2F:
return out << "mat3x2f";
case Builtin::kMat3X2H:
return out << "mat3x2h";
case Builtin::kMat3X3:
return out << "mat3x3";
case Builtin::kMat3X3F:
return out << "mat3x3f";
case Builtin::kMat3X3H:
return out << "mat3x3h";
case Builtin::kMat3X4:
return out << "mat3x4";
case Builtin::kMat3X4F:
return out << "mat3x4f";
case Builtin::kMat3X4H:
return out << "mat3x4h";
case Builtin::kMat4X2:
return out << "mat4x2";
case Builtin::kMat4X2F:
return out << "mat4x2f";
case Builtin::kMat4X2H:
return out << "mat4x2h";
case Builtin::kMat4X3:
return out << "mat4x3";
case Builtin::kMat4X3F:
return out << "mat4x3f";
case Builtin::kMat4X3H:
return out << "mat4x3h";
case Builtin::kMat4X4:
return out << "mat4x4";
case Builtin::kMat4X4F:
return out << "mat4x4f";
case Builtin::kMat4X4H:
return out << "mat4x4h";
case Builtin::kPtr:
return out << "ptr";
case Builtin::kSampler:
return out << "sampler";
case Builtin::kSamplerComparison:
return out << "sampler_comparison";
case Builtin::kTexture1D:
return out << "texture_1d";
case Builtin::kTexture2D:
return out << "texture_2d";
case Builtin::kTexture2DArray:
return out << "texture_2d_array";
case Builtin::kTexture3D:
return out << "texture_3d";
case Builtin::kTextureCube:
return out << "texture_cube";
case Builtin::kTextureCubeArray:
return out << "texture_cube_array";
case Builtin::kTextureDepth2D:
return out << "texture_depth_2d";
case Builtin::kTextureDepth2DArray:
return out << "texture_depth_2d_array";
case Builtin::kTextureDepthCube:
return out << "texture_depth_cube";
case Builtin::kTextureDepthCubeArray:
return out << "texture_depth_cube_array";
case Builtin::kTextureDepthMultisampled2D:
return out << "texture_depth_multisampled_2d";
case Builtin::kTextureExternal:
return out << "texture_external";
case Builtin::kTextureMultisampled2D:
return out << "texture_multisampled_2d";
case Builtin::kTextureStorage1D:
return out << "texture_storage_1d";
case Builtin::kTextureStorage2D:
return out << "texture_storage_2d";
case Builtin::kTextureStorage2DArray:
return out << "texture_storage_2d_array";
case Builtin::kTextureStorage3D:
return out << "texture_storage_3d";
case Builtin::kU32:
return out << "u32";
case Builtin::kVec2:
return out << "vec2";
case Builtin::kVec2F:
return out << "vec2f";
case Builtin::kVec2H:
return out << "vec2h";
case Builtin::kVec2I:
return out << "vec2i";
case Builtin::kVec2U:
return out << "vec2u";
case Builtin::kVec3:
return out << "vec3";
case Builtin::kVec3F:
return out << "vec3f";
case Builtin::kVec3H:
return out << "vec3h";
case Builtin::kVec3I:
return out << "vec3i";
case Builtin::kVec3U:
return out << "vec3u";
case Builtin::kVec4:
return out << "vec4";
case Builtin::kVec4F:
return out << "vec4f";
case Builtin::kVec4H:
return out << "vec4h";
case Builtin::kVec4I:
return out << "vec4i";
case Builtin::kVec4U:
return out << "vec4u";
}
return out << "<unknown>";
}
} // namespace tint::type

View File

@@ -1,26 +0,0 @@
{{- /*
--------------------------------------------------------------------------------
Template file for use with tools/src/cmd/gen to generate builtin.cc
To update the generated file, run:
./tools/run gen
See:
* tools/src/cmd/gen for structures used by this template
* https://golang.org/pkg/text/template/ for documentation on the template syntax
--------------------------------------------------------------------------------
*/ -}}
{{- Import "src/tint/templates/enums.tmpl.inc" -}}
{{- $enum := (Sem.Enum "builtin_type") -}}
{{- Eval "OverrideEnumName" "Enum" $enum "Name" "Builtin" -}}
#include "src/tint/type/builtin.h"
namespace tint::type {
{{ Eval "ParseEnum" $enum}}
{{ Eval "EnumOStream" $enum}}
} // namespace tint::type

View File

@@ -1,188 +0,0 @@
// Copyright 2022 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
////////////////////////////////////////////////////////////////////////////////
// File generated by tools/src/cmd/gen
// using the template:
// src/tint/type/builtin.h.tmpl
//
// Do not modify this file directly
////////////////////////////////////////////////////////////////////////////////
#ifndef SRC_TINT_TYPE_BUILTIN_H_
#define SRC_TINT_TYPE_BUILTIN_H_
#include <ostream>
namespace tint::type {
/// An enumerator of builtin types.
enum class Builtin {
kUndefined,
kArray,
kAtomic,
kBool,
kF16,
kF32,
kI32,
kMat2X2,
kMat2X2F,
kMat2X2H,
kMat2X3,
kMat2X3F,
kMat2X3H,
kMat2X4,
kMat2X4F,
kMat2X4H,
kMat3X2,
kMat3X2F,
kMat3X2H,
kMat3X3,
kMat3X3F,
kMat3X3H,
kMat3X4,
kMat3X4F,
kMat3X4H,
kMat4X2,
kMat4X2F,
kMat4X2H,
kMat4X3,
kMat4X3F,
kMat4X3H,
kMat4X4,
kMat4X4F,
kMat4X4H,
kPtr,
kSampler,
kSamplerComparison,
kTexture1D,
kTexture2D,
kTexture2DArray,
kTexture3D,
kTextureCube,
kTextureCubeArray,
kTextureDepth2D,
kTextureDepth2DArray,
kTextureDepthCube,
kTextureDepthCubeArray,
kTextureDepthMultisampled2D,
kTextureExternal,
kTextureMultisampled2D,
kTextureStorage1D,
kTextureStorage2D,
kTextureStorage2DArray,
kTextureStorage3D,
kU32,
kVec2,
kVec2F,
kVec2H,
kVec2I,
kVec2U,
kVec3,
kVec3F,
kVec3H,
kVec3I,
kVec3U,
kVec4,
kVec4F,
kVec4H,
kVec4I,
kVec4U,
};
/// @param out the std::ostream to write to
/// @param value the Builtin
/// @returns `out` so calls can be chained
std::ostream& operator<<(std::ostream& out, Builtin value);
/// ParseBuiltin parses a Builtin from a string.
/// @param str the string to parse
/// @returns the parsed enum, or Builtin::kUndefined if the string could not be parsed.
Builtin ParseBuiltin(std::string_view str);
constexpr const char* kBuiltinStrings[] = {
"array",
"atomic",
"bool",
"f16",
"f32",
"i32",
"mat2x2",
"mat2x2f",
"mat2x2h",
"mat2x3",
"mat2x3f",
"mat2x3h",
"mat2x4",
"mat2x4f",
"mat2x4h",
"mat3x2",
"mat3x2f",
"mat3x2h",
"mat3x3",
"mat3x3f",
"mat3x3h",
"mat3x4",
"mat3x4f",
"mat3x4h",
"mat4x2",
"mat4x2f",
"mat4x2h",
"mat4x3",
"mat4x3f",
"mat4x3h",
"mat4x4",
"mat4x4f",
"mat4x4h",
"ptr",
"sampler",
"sampler_comparison",
"texture_1d",
"texture_2d",
"texture_2d_array",
"texture_3d",
"texture_cube",
"texture_cube_array",
"texture_depth_2d",
"texture_depth_2d_array",
"texture_depth_cube",
"texture_depth_cube_array",
"texture_depth_multisampled_2d",
"texture_external",
"texture_multisampled_2d",
"texture_storage_1d",
"texture_storage_2d",
"texture_storage_2d_array",
"texture_storage_3d",
"u32",
"vec2",
"vec2f",
"vec2h",
"vec2i",
"vec2u",
"vec3",
"vec3f",
"vec3h",
"vec3i",
"vec3u",
"vec4",
"vec4f",
"vec4h",
"vec4i",
"vec4u",
};
} // namespace tint::type
#endif // SRC_TINT_TYPE_BUILTIN_H_

View File

@@ -1,30 +0,0 @@
{{- /*
--------------------------------------------------------------------------------
Template file for use with tools/src/cmd/gen to generate builtin.h
To update the generated file, run:
./tools/run gen
See:
* tools/src/cmd/gen for structures used by this template
* https://golang.org/pkg/text/template/ for documentation on the template syntax
--------------------------------------------------------------------------------
*/ -}}
{{- Import "src/tint/templates/enums.tmpl.inc" -}}
{{- $enum := (Sem.Enum "builtin_type") -}}
{{- Eval "OverrideEnumName" "Enum" $enum "Name" "Builtin" -}}
#ifndef SRC_TINT_TYPE_BUILTIN_H_
#define SRC_TINT_TYPE_BUILTIN_H_
#include <ostream>
namespace tint::type {
/// An enumerator of builtin types.
{{ Eval "DeclareEnum" $enum}}
} // namespace tint::type
#endif // SRC_TINT_TYPE_BUILTIN_H_

View File

@@ -1,529 +0,0 @@
// Copyright 2022 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
////////////////////////////////////////////////////////////////////////////////
// File generated by tools/src/cmd/gen
// using the template:
// src/tint/type/builtin_bench.cc.tmpl
//
// Do not modify this file directly
////////////////////////////////////////////////////////////////////////////////
#include "src/tint/type/builtin.h"
#include <array>
#include "benchmark/benchmark.h"
namespace tint::type {
namespace {
void BuiltinParser(::benchmark::State& state) {
const char* kStrings[] = {
"arccy",
"3a",
"aVray",
"array",
"arra1",
"qqrJy",
"arrll7y",
"atppmHHc",
"cto",
"abGmi",
"atomic",
"atvmiii",
"atWWm8c",
"xxtomc",
"bXgg",
"Xu",
"b3ol",
"bool",
"booE",
"TTPol",
"xxool",
"4416",
"fSVV6",
"RR2",
"f16",
"96",
"f1",
"VOR6",
"y3",
"l77rrn2",
"4032",
"f32",
"5",
"u377",
"kk2",
"ii",
"i3XX",
"55399II",
"i32",
"irSSHHa",
"U",
"jV3",
"ax2",
"t2SGG",
"q2x2",
"mat2x2",
"at2",
"majjx",
"a2xrf",
"mat2xjf",
"mNNw2x28",
"matx2f",
"mat2x2f",
"mrrt2x2f",
"Gat2x2f",
"mat2x2FF",
"at2h",
"marrx2h",
"t2x2h",
"mat2x2h",
"Da2xJJh",
"ma82",
"m11k2",
"matx3",
"maJx3",
"cat2x3",
"mat2x3",
"mat2O3",
"ttKavv2x__",
"5txxx8",
"__qatF3",
"matqx3f",
"33atOx3f",
"mat2x3f",
"mtt62x9oQQ",
"ma2x66f",
"mtOxzz66",
"mat2yy3h",
"ZaHH3Z",
"4WWt2q3h",
"mat2x3h",
"mOO2x3h",
"oatY3h",
"matx",
"ma2x4",
"matw4",
"ma2Gf",
"mat2x4",
"qatKKx4",
"mmmt2x4",
"at2x4",
"mt2x4q",
"mat2xbb",
"mi2x4f",
"mat2x4f",
"maOO2xq",
"matTvvx4f",
"maFF2x4f",
"Pa00xQh",
"mPt2x4h",
"ma772xss",
"mat2x4h",
"RRCbb2x4h",
"mXXt2x4h",
"qaCC2xOOh",
"mtsuL",
"mat3xX",
"mat3x",
"mat3x2",
"qqt2",
"mat3x22",
"mzzyt3x",
"matVViP",
"mannC2f",
"atx2AHHq",
"mat3x2f",
"may3x2",
"aOOOZZf",
"Vt12f",
"mff__3x2h",
"qaTMMl4h",
"mNNt3xg",
"mat3x2h",
"uub3XX2h",
"matx2h",
"Qt882h",
"maqx3",
"mat3113",
"Ft3xi22",
"mat3x3",
"m7t3x3",
"NNa323",
"VVat3x3",
"FaWW3w11f",
"mawwx3f",
"Dat3x3f",
"mat3x3f",
"mt3x3K",
"mat31PPhf",
"mat33f",
"mYYt3x3h",
"mttHH3kk",
"mat3rr3h",
"mat3x3h",
"WWas3x3h",
"Yt3x3h",
"mt3qfh",
"vvafu224",
"mt34",
"maY34",
"mat3x4",
"YYa7y3E4",
"Moatd4",
"mt3xMM",
"mat3x55f",
"maN34",
"ma3Ox33",
"mat3x4f",
"m3t3x4f",
"mam3xI",
"mnnt3r4K",
"m3XX",
"LatIx4h",
"at3fh",
"mat3x4h",
"mYtURD4",
"mah3x4h",
"uuIqt3x",
"mat4xH",
"at4Qvv",
"66ate",
"mat4x2",
"mat7x",
"m0t55DD2",
"IIaH4x2",
"at4x2",
"rat4x299",
"mGtt41W2f",
"mat4x2f",
"yatx2",
"mt4x2f",
"IIaBB4x2f",
"TTat4x833",
"ddUUnntYYx2h",
"m5CCxxdZ",
"mat4x2h",
"matkkq2h",
"005itpxh",
"maIInnx2h",
"ccaKx",
"mtKK",
"ma664x3",
"mat4x3",
"mKKtPx",
"maxx43",
"matqx3",
"MMayySrxf",
"mat3f",
"tx3f",
"mat4x3f",
"ma5F4x3f",
"rra444z3f",
"matWW",
"CatZJXx3h",
"maPPx3h",
"mat4c3h",
"mat4x3h",
"matPPll6h",
"mat993yy",
"mat4JKKh",
"ma_x4",
"a4K4",
"kVt4xz",
"mat4x4",
"qaSKx4",
"mat44",
"ma4xVV",
"AAatIxUf",
"mbj4f",
"YY444x",
"mat4x4f",
"mao4x4",
"mtx114f",
"mtmxccf",
"aJJ4x4h",
"fCCDD4x4U",
"mgt4x4h",
"mat4x4h",
"CCx4h",
"mat4x66",
"maN4M4h",
"pt",
"KW",
"pzzee",
"ptr",
"",
"w9",
"4tnn",
"sllDler",
"oamp4er",
"wEaggler",
"sampler",
"gamler",
"spleS",
"aampl",
"sampZcRTr_comparison",
"sampler_88TmparisOn",
"sampler_comparim00n",
"sampler_comparison",
"sampler_Bmomparison",
"Mamper_ppomarison",
"samper_compOOrison",
"teGtGre_1d",
"tex11ureHH1d",
"6exeeur_1FF",
"texture_1d",
"texure_1",
"tKiilure_1d",
"exture_1d",
"99etvIIre_2d",
"texture_d",
"texture_hd",
"texture_2d",
"llxzzure_PPd",
"exue2d",
"tffqqtre_2d",
"texJJre_2dd_arWay",
"teXXzzre_2darray",
"textu2_2d_array",
"texture_2d_array",
"tNyyture_2d_array",
"txture_2d_rOOa",
"textureErduaZPay",
"22lxtredd3ee",
"texVVe93d",
"teture_I1d",
"texture_3d",
"tebture_3d",
"ie7ure3d",
"teotiire_3d",
"entre_cube",
"texturScube",
"tex22r_cube",
"texture_cube",
"teC711recuGe",
"texture8cffbe",
"textue_cue",
"tJJxture_SSube_array",
"texture_9ue_arry",
"TbbJJxture_cube_array",
"texture_cube_array",
"t66ture_cube_aray",
"textur66_cubu_arra",
"textureWubeyarray",
"texture_deth_d",
"texture_epth_2d",
"texture_derth_2d",
"texture_depth_2d",
"tex2ure_depth_2B",
"texture_dpBBh_2d",
"texture_dpth_RRd",
"tLLxture_deptVV0darray",
"textuOOe_dethKK2d_arra",
"textuwe_ggepth_2d_rray",
"texture_depth_2d_array",
"textue_depthLh2d_arpay",
"texture_depEh2diiKrray",
"texture_dept_2d_array",
"textuUUe88dept_cbe",
"texrrure_depvvh_cube",
"texure_wepmmh_ube",
"texture_depth_cube",
"tjture_d44pth_cube",
"texture_depth_cXbe",
"t8xture_depth_cube",
"textre_depth_cubeEEarrvvy",
"tzzture_d9pth_cuie_array",
"teAture_depth_QQube_GGrrJJy",
"texture_depth_cube_array",
"texture_depth_cusse_array",
"texture_Pepth_cKbe_array",
"texture_dppp_cube_attray",
"texture_depth_multisample_2",
"texture_depth_multisamplMMd_2d",
"texJJure_de0th_multisampled_2d",
"texture_depth_multisampled_2d",
"textu8_dpth_mulisampled_2V",
"texture_dhhpth_mKltisggmpled_2d",
"texture_depth_multisampledf2d",
"tex77ure_exQernal",
"tYYxture_externa",
"tektur_exterSal",
"texture_external",
"txturn_ext2rnal",
"txture_FFternal",
"texUPPIre_GGxuernal",
"txtuEEe_mulaisFmpledv2d",
"ddexBBure_mltDDeampled_2d",
"teMture_EEulccisam55led_2",
"texture_multisampled_2d",
"texturemuKKtisample_d",
"texture_multisRmpled_2d",
"texturemulDisampl9d_2d",
"texturestorage_1d",
"textIre_storaa_1d",
"texture_sto77age_1d",
"texture_storage_1d",
"texIure_storage_1d",
"texture_storagedd",
"texture_storae_1d",
"texture_strate_d",
"texture33stoXXcge_2d",
"texturestorage_2E",
"texture_storage_2d",
"textuXXestorage_2d",
"texture_stoBaxxe_2d",
"texte_storWge_2G",
"texture_storage_2d_ar66ay",
"t0xTTr_storave_2d_array",
"kexure_orage_2d_rray",
"texture_storage_2d_array",
"textppre_stoae_2d_array",
"textre_stora11e_d_array",
"textureystorBEgeJ2d_array",
"textqreIImtxrage_3d",
"texture_toFage_3d",
"exture_Ytorage_3d",
"texture_storage_3d",
"heDture_sHHorage_3d",
"texturstorage23H",
"teture_strage_3d",
"u2",
"u2",
"dd32",
"u32",
"uPO",
"ba",
"u02",
"veh2",
"vgY2",
"Oec2",
"vec2",
"eh",
"ppfe2",
"vev",
"vc2zz",
"vaac2",
"Ouuicf",
"vec2f",
"vGc2f",
"22ecTTf",
"dlc2f",
"vecbh",
"ec2BB",
"IIScXPP",
"vec2h",
"jjec2h",
"cc_c2h",
"zz6xx2h",
"c2",
"4xx2N",
"p0AAei",
"vec2i",
"vey2",
"vbWW0i",
"meMMtti",
"du",
"vvc_",
"VEEc2u",
"vec2u",
"vec24",
"VVeX2u",
"veVou",
"vec",
"KKc3",
"G",
"vec3",
"ea3",
"OOc",
"G",
"v5c3f",
"99jcfff",
"XXvYY3R",
"vec3f",
"ccf",
"v8XX5",
"ec3",
"ppc3cc",
"vecvh",
"eEE3SS",
"vec3h",
"vec",
"eh",
"ec3ww",
"vecd99i",
"ve99P",
"KKec3",
"vec3i",
"ooMcDD",
"vei",
"vqi",
"veL30",
"vncvv66",
"vrrn3",
"vec3u",
"vxxce",
"NCCOc3u",
"vc3u",
"veca",
"veNNN",
"vec",
"vec4",
"vc",
"vAYS4",
"vec0",
"vecaaf",
"vmm4f",
"ec4f",
"vec4f",
"vE4U",
"veKD4",
"v0t4__",
"cpA",
"ec4h",
"vBBc4h",
"vec4h",
"vbnn99",
"EEcAAh",
"v5c66h",
"vHc4i",
"vecxi",
"vzyn40",
"vec4i",
"ve4i",
"kH4i",
"veci",
"oo4rr",
"JJc4",
"vcCC0",
"vec4u",
"xAA99F",
"veccu",
"vec4S",
};
for (auto _ : state) {
for (auto* str : kStrings) {
auto result = ParseBuiltin(str);
benchmark::DoNotOptimize(result);
}
}
}
BENCHMARK(BuiltinParser);
} // namespace
} // namespace tint::type

View File

@@ -1,30 +0,0 @@
{{- /*
--------------------------------------------------------------------------------
Template file for use with tools/src/cmd/gen to generate builtin_bench.cc
To update the generated file, run:
./tools/run gen
See:
* tools/src/cmd/gen for structures used by this template
* https://golang.org/pkg/text/template/ for documentation on the template syntax
--------------------------------------------------------------------------------
*/ -}}
{{- Import "src/tint/templates/enums.tmpl.inc" -}}
{{- $enum := (Sem.Enum "builtin_type") -}}
{{- Eval "OverrideEnumName" "Enum" $enum "Name" "Builtin" -}}
#include "src/tint/type/builtin.h"
#include <array>
#include "benchmark/benchmark.h"
namespace tint::type {
namespace {
{{ Eval "BenchmarkParseEnum" $enum }}
} // namespace
} // namespace tint::type

View File

@@ -1,351 +0,0 @@
// Copyright 2022 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
////////////////////////////////////////////////////////////////////////////////
// File generated by tools/src/cmd/gen
// using the template:
// src/tint/type/builtin_test.cc.tmpl
//
// Do not modify this file directly
////////////////////////////////////////////////////////////////////////////////
#include "src/tint/type/builtin.h"
#include <string>
#include "gtest/gtest.h"
#include "src/tint/utils/string.h"
namespace tint::type {
namespace {
namespace parse_print_tests {
struct Case {
const char* string;
Builtin value;
};
inline std::ostream& operator<<(std::ostream& out, Case c) {
return out << "'" << std::string(c.string) << "'";
}
static constexpr Case kValidCases[] = {
{"array", Builtin::kArray},
{"atomic", Builtin::kAtomic},
{"bool", Builtin::kBool},
{"f16", Builtin::kF16},
{"f32", Builtin::kF32},
{"i32", Builtin::kI32},
{"mat2x2", Builtin::kMat2X2},
{"mat2x2f", Builtin::kMat2X2F},
{"mat2x2h", Builtin::kMat2X2H},
{"mat2x3", Builtin::kMat2X3},
{"mat2x3f", Builtin::kMat2X3F},
{"mat2x3h", Builtin::kMat2X3H},
{"mat2x4", Builtin::kMat2X4},
{"mat2x4f", Builtin::kMat2X4F},
{"mat2x4h", Builtin::kMat2X4H},
{"mat3x2", Builtin::kMat3X2},
{"mat3x2f", Builtin::kMat3X2F},
{"mat3x2h", Builtin::kMat3X2H},
{"mat3x3", Builtin::kMat3X3},
{"mat3x3f", Builtin::kMat3X3F},
{"mat3x3h", Builtin::kMat3X3H},
{"mat3x4", Builtin::kMat3X4},
{"mat3x4f", Builtin::kMat3X4F},
{"mat3x4h", Builtin::kMat3X4H},
{"mat4x2", Builtin::kMat4X2},
{"mat4x2f", Builtin::kMat4X2F},
{"mat4x2h", Builtin::kMat4X2H},
{"mat4x3", Builtin::kMat4X3},
{"mat4x3f", Builtin::kMat4X3F},
{"mat4x3h", Builtin::kMat4X3H},
{"mat4x4", Builtin::kMat4X4},
{"mat4x4f", Builtin::kMat4X4F},
{"mat4x4h", Builtin::kMat4X4H},
{"ptr", Builtin::kPtr},
{"sampler", Builtin::kSampler},
{"sampler_comparison", Builtin::kSamplerComparison},
{"texture_1d", Builtin::kTexture1D},
{"texture_2d", Builtin::kTexture2D},
{"texture_2d_array", Builtin::kTexture2DArray},
{"texture_3d", Builtin::kTexture3D},
{"texture_cube", Builtin::kTextureCube},
{"texture_cube_array", Builtin::kTextureCubeArray},
{"texture_depth_2d", Builtin::kTextureDepth2D},
{"texture_depth_2d_array", Builtin::kTextureDepth2DArray},
{"texture_depth_cube", Builtin::kTextureDepthCube},
{"texture_depth_cube_array", Builtin::kTextureDepthCubeArray},
{"texture_depth_multisampled_2d", Builtin::kTextureDepthMultisampled2D},
{"texture_external", Builtin::kTextureExternal},
{"texture_multisampled_2d", Builtin::kTextureMultisampled2D},
{"texture_storage_1d", Builtin::kTextureStorage1D},
{"texture_storage_2d", Builtin::kTextureStorage2D},
{"texture_storage_2d_array", Builtin::kTextureStorage2DArray},
{"texture_storage_3d", Builtin::kTextureStorage3D},
{"u32", Builtin::kU32},
{"vec2", Builtin::kVec2},
{"vec2f", Builtin::kVec2F},
{"vec2h", Builtin::kVec2H},
{"vec2i", Builtin::kVec2I},
{"vec2u", Builtin::kVec2U},
{"vec3", Builtin::kVec3},
{"vec3f", Builtin::kVec3F},
{"vec3h", Builtin::kVec3H},
{"vec3i", Builtin::kVec3I},
{"vec3u", Builtin::kVec3U},
{"vec4", Builtin::kVec4},
{"vec4f", Builtin::kVec4F},
{"vec4h", Builtin::kVec4H},
{"vec4i", Builtin::kVec4I},
{"vec4u", Builtin::kVec4U},
};
static constexpr Case kInvalidCases[] = {
{"arccy", Builtin::kUndefined},
{"3a", Builtin::kUndefined},
{"aVray", Builtin::kUndefined},
{"1tomic", Builtin::kUndefined},
{"aoqqic", Builtin::kUndefined},
{"atomll77", Builtin::kUndefined},
{"ppqooH", Builtin::kUndefined},
{"c", Builtin::kUndefined},
{"bGo", Builtin::kUndefined},
{"f1vi", Builtin::kUndefined},
{"f8WW", Builtin::kUndefined},
{"fxx", Builtin::kUndefined},
{"fgg", Builtin::kUndefined},
{"X", Builtin::kUndefined},
{"332", Builtin::kUndefined},
{"iE2", Builtin::kUndefined},
{"iPTT", Builtin::kUndefined},
{"dxx2", Builtin::kUndefined},
{"44at2x2", Builtin::kUndefined},
{"mSSVV2x2", Builtin::kUndefined},
{"mat2R2", Builtin::kUndefined},
{"mF2x9f", Builtin::kUndefined},
{"matx2f", Builtin::kUndefined},
{"VOORRH2f", Builtin::kUndefined},
{"ma2xyh", Builtin::kUndefined},
{"llnarr2772h", Builtin::kUndefined},
{"mat24200", Builtin::kUndefined},
{"m2oo", Builtin::kUndefined},
{"atzz3", Builtin::kUndefined},
{"1it2xpp", Builtin::kUndefined},
{"mat2xXXf", Builtin::kUndefined},
{"9II5ann2x3f", Builtin::kUndefined},
{"mataSSrHHYf", Builtin::kUndefined},
{"makkh", Builtin::kUndefined},
{"jatgRx", Builtin::kUndefined},
{"mb2x3", Builtin::kUndefined},
{"mat2j4", Builtin::kUndefined},
{"mt2x4", Builtin::kUndefined},
{"m2q4", Builtin::kUndefined},
{"matNN4f", Builtin::kUndefined},
{"at24vv", Builtin::kUndefined},
{"QQt2x4f", Builtin::kUndefined},
{"maffxr", Builtin::kUndefined},
{"mat2xjh", Builtin::kUndefined},
{"mNNw2x48", Builtin::kUndefined},
{"mt3x2", Builtin::kUndefined},
{"rrat3x2", Builtin::kUndefined},
{"mGt3x2", Builtin::kUndefined},
{"mat3x2FF", Builtin::kUndefined},
{"at3f", Builtin::kUndefined},
{"marrx2f", Builtin::kUndefined},
{"t3x2h", Builtin::kUndefined},
{"Da3xJJh", Builtin::kUndefined},
{"ma82", Builtin::kUndefined},
{"1k33", Builtin::kUndefined},
{"matx3", Builtin::kUndefined},
{"maJx3", Builtin::kUndefined},
{"mat3c3f", Builtin::kUndefined},
{"mat3x3O", Builtin::kUndefined},
{"KK_atvvtt3f", Builtin::kUndefined},
{"xx83x3h", Builtin::kUndefined},
{"__qatF3", Builtin::kUndefined},
{"matqx3h", Builtin::kUndefined},
{"ma33x66", Builtin::kUndefined},
{"mttQQo3x4", Builtin::kUndefined},
{"mat66x", Builtin::kUndefined},
{"mtOxzz66", Builtin::kUndefined},
{"mat3yy4f", Builtin::kUndefined},
{"ZaHH4Z", Builtin::kUndefined},
{"4WWt3q4h", Builtin::kUndefined},
{"mOO3x4h", Builtin::kUndefined},
{"oatY4h", Builtin::kUndefined},
{"ax2", Builtin::kUndefined},
{"ma4x2", Builtin::kUndefined},
{"matw2", Builtin::kUndefined},
{"fGtxKf", Builtin::kUndefined},
{"matqKx2f", Builtin::kUndefined},
{"matmmxFf", Builtin::kUndefined},
{"at4x2h", Builtin::kUndefined},
{"mt4x2q", Builtin::kUndefined},
{"mat4xbb", Builtin::kUndefined},
{"it4x3", Builtin::kUndefined},
{"mOO4xq", Builtin::kUndefined},
{"mat4Tvv3", Builtin::kUndefined},
{"maFF4x3f", Builtin::kUndefined},
{"Pa00xQf", Builtin::kUndefined},
{"mPt4x3f", Builtin::kUndefined},
{"ma774xss", Builtin::kUndefined},
{"RRCbb4x3h", Builtin::kUndefined},
{"mXXt4x3h", Builtin::kUndefined},
{"CCt4OOOO", Builtin::kUndefined},
{"mtsuL", Builtin::kUndefined},
{"mat4xX", Builtin::kUndefined},
{"mat44f", Builtin::kUndefined},
{"qa4O4", Builtin::kUndefined},
{"mat4x22f", Builtin::kUndefined},
{"myzz40XX", Builtin::kUndefined},
{"matVViP", Builtin::kUndefined},
{"mannC4h", Builtin::kUndefined},
{"pHAq", Builtin::kUndefined},
{"tr", Builtin::kUndefined},
{"Kf", Builtin::kUndefined},
{"lmgger", Builtin::kUndefined},
{"samplr", Builtin::kUndefined},
{"NTTmcl4r", Builtin::kUndefined},
{"sampler_clmppri77on", Builtin::kUndefined},
{"samplg_czzmparNNso", Builtin::kUndefined},
{"smpleuuXXomparibbon", Builtin::kUndefined},
{"texture_1", Builtin::kUndefined},
{"t88tueQ1K", Builtin::kUndefined},
{"texturq9d", Builtin::kUndefined},
{"text11re_2d", Builtin::kUndefined},
{"teiiu22eF2d", Builtin::kUndefined},
{"tex77ur_2d", Builtin::kUndefined},
{"textNNr2_d_array", Builtin::kUndefined},
{"textVVre_2d_array", Builtin::kUndefined},
{"texwure_WWF_11rray", Builtin::kUndefined},
{"txture_3ww", Builtin::kUndefined},
{"texturD_3d", Builtin::kUndefined},
{"teKture_d", Builtin::kUndefined},
{"11exPPufe_cubh", Builtin::kUndefined},
{"textue_cube", Builtin::kUndefined},
{"texture_cubYY", Builtin::kUndefined},
{"texttr_cube_HHkkVay", Builtin::kUndefined},
{"texture_crrbe_array", Builtin::kUndefined},
{"texturesscubeWWaray", Builtin::kUndefined},
{"texture_deptY_d", Builtin::kUndefined},
{"teLturq_defh_2d", Builtin::kUndefined},
{"texvvre_duu22th_2d", Builtin::kUndefined},
{"texure_deth_2d_array", Builtin::kUndefined},
{"texturYY_depth_2daray", Builtin::kUndefined},
{"texturE_77epth_2d_aryYay", Builtin::kUndefined},
{"Mexdoore_depth_cue", Builtin::kUndefined},
{"texturedepMMh_cube", Builtin::kUndefined},
{"texture55depth_cube", Builtin::kUndefined},
{"textue_depth_cbe_aNray", Builtin::kUndefined},
{"texture_dpth_c33be_array", Builtin::kUndefined},
{"texture_depth_cub3_array", Builtin::kUndefined},
{"texIure_mepth_mulisampled_2d", Builtin::kUndefined},
{"texture_depthrmKltisampled_2nn", Builtin::kUndefined},
{"textur_depth_multismXld_2d", Builtin::kUndefined},
{"texpure_exLLeIna", Builtin::kUndefined},
{"txture_exfrnal", Builtin::kUndefined},
{"teUture_extYRRDl", Builtin::kUndefined},
{"texturehmultisampled_2d", Builtin::kUndefined},
{"texturqmultsIImuuled_2d", Builtin::kUndefined},
{"Hexture_multisampled_2d", Builtin::kUndefined},
{"texQQur_storge_vvd", Builtin::kUndefined},
{"texeure_66oage_1d", Builtin::kUndefined},
{"texture_stoage71d", Builtin::kUndefined},
{"texture_s55or0ge_2DD", Builtin::kUndefined},
{"teHture_storIIge_2d", Builtin::kUndefined},
{"textue_storage_2d", Builtin::kUndefined},
{"texturestorage_2d_rrray", Builtin::kUndefined},
{"textule_storage_2d_array", Builtin::kUndefined},
{"tetture_JJtorage_Gd_arra", Builtin::kUndefined},
{"yexture_storage3d", Builtin::kUndefined},
{"texturestorage_3d", Builtin::kUndefined},
{"texture_IItorBBge_3d", Builtin::kUndefined},
{"TTK33", Builtin::kUndefined},
{"nnUYdSS2", Builtin::kUndefined},
{"x5dZ", Builtin::kUndefined},
{"veckq", Builtin::kUndefined},
{"ii500", Builtin::kUndefined},
{"vecIIn", Builtin::kUndefined},
{"cceW", Builtin::kUndefined},
{"cKK", Builtin::kUndefined},
{"vec66f", Builtin::kUndefined},
{"vePPK", Builtin::kUndefined},
{"vexxh", Builtin::kUndefined},
{"qec2h", Builtin::kUndefined},
{"veSyMMr", Builtin::kUndefined},
{"v2u", Builtin::kUndefined},
{"ec", Builtin::kUndefined},
{"5eFF2u", Builtin::kUndefined},
{"rrecz44", Builtin::kUndefined},
{"vWW", Builtin::kUndefined},
{"ZJJCcX", Builtin::kUndefined},
{"vcPP", Builtin::kUndefined},
{"vec", Builtin::kUndefined},
{"3Le003f", Builtin::kUndefined},
{"MMec3RR", Builtin::kUndefined},
{"vec39K", Builtin::kUndefined},
{"yyecm", Builtin::kUndefined},
{"v__cD", Builtin::kUndefined},
{"vec3U", Builtin::kUndefined},
{"ze333i", Builtin::kUndefined},
{"eKti", Builtin::kUndefined},
{"ve3V", Builtin::kUndefined},
{"jbR3K", Builtin::kUndefined},
{"e44344", Builtin::kUndefined},
{"00u", Builtin::kUndefined},
{"WK4", Builtin::kUndefined},
{"m", Builtin::kUndefined},
{"vJJ", Builtin::kUndefined},
{"lDDcUfC", Builtin::kUndefined},
{"vec4g", Builtin::kUndefined},
{"CCe", Builtin::kUndefined},
{"ec4h", Builtin::kUndefined},
{"vIc__h", Builtin::kUndefined},
{"ePPtt", Builtin::kUndefined},
{"v3dc4i", Builtin::kUndefined},
{"vcyyi", Builtin::kUndefined},
{"u4", Builtin::kUndefined},
{"v03nnu", Builtin::kUndefined},
{"Cuuecnv", Builtin::kUndefined},
{"vX4ll", Builtin::kUndefined},
};
using BuiltinParseTest = testing::TestWithParam<Case>;
TEST_P(BuiltinParseTest, Parse) {
const char* string = GetParam().string;
Builtin expect = GetParam().value;
EXPECT_EQ(expect, ParseBuiltin(string));
}
INSTANTIATE_TEST_SUITE_P(ValidCases, BuiltinParseTest, testing::ValuesIn(kValidCases));
INSTANTIATE_TEST_SUITE_P(InvalidCases, BuiltinParseTest, testing::ValuesIn(kInvalidCases));
using BuiltinPrintTest = testing::TestWithParam<Case>;
TEST_P(BuiltinPrintTest, Print) {
Builtin value = GetParam().value;
const char* expect = GetParam().string;
EXPECT_EQ(expect, utils::ToString(value));
}
INSTANTIATE_TEST_SUITE_P(ValidCases, BuiltinPrintTest, testing::ValuesIn(kValidCases));
} // namespace parse_print_tests
} // namespace
} // namespace tint::type

View File

@@ -1,32 +0,0 @@
{{- /*
--------------------------------------------------------------------------------
Template file for use with tools/src/cmd/gen to generate builtin_test.cc
To update the generated file, run:
./tools/run gen
See:
* tools/src/cmd/gen for structures used by this template
* https://golang.org/pkg/text/template/ for documentation on the template syntax
--------------------------------------------------------------------------------
*/ -}}
{{- Import "src/tint/templates/enums.tmpl.inc" -}}
{{- $enum := (Sem.Enum "builtin_type") -}}
{{- Eval "OverrideEnumName" "Enum" $enum "Name" "Builtin" -}}
#include "src/tint/type/builtin.h"
#include <string>
#include "gtest/gtest.h"
#include "src/tint/utils/string.h"
namespace tint::type {
namespace {
{{ Eval "TestParsePrintEnum" $enum}}
} // namespace
} // namespace tint::type