blob: c09e8a7cb3db2a7da618573785c1346829c2518a [file] [log] [blame]
Ryan Harrisondbc13af2022-02-21 15:19:07 +00001// Copyright 2020 The Tint Authors.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
Ben Claytona123b892022-07-27 16:36:35 +000015////////////////////////////////////////////////////////////////////////////////
Ben Clayton57ded6a2023-08-22 13:22:22 +000016// File generated by 'tools/src/cmd/gen' using the template:
Ben Claytoncd52f382023-08-07 13:11:08 +000017// src/tint/lang/core/address_space.cc.tmpl
Ben Claytona123b892022-07-27 16:36:35 +000018//
Ben Clayton57ded6a2023-08-22 13:22:22 +000019// To regenerate run: './tools/run gen'
20//
21// Do not modify this file directly
Ben Claytona123b892022-07-27 16:36:35 +000022////////////////////////////////////////////////////////////////////////////////
23
Ben Claytoncd52f382023-08-07 13:11:08 +000024#include "src/tint/lang/core/address_space.h"
Ryan Harrisondbc13af2022-02-21 15:19:07 +000025
Ben Claytoncd52f382023-08-07 13:11:08 +000026namespace tint::core {
Ryan Harrisondbc13af2022-02-21 15:19:07 +000027
dan sinclairff7cf212022-10-03 14:05:23 +000028/// ParseAddressSpace parses a AddressSpace from a string.
Ben Clayton48085842022-07-26 22:51:36 +000029/// @param str the string to parse
Ben Claytond2e0db32022-10-12 18:49:15 +000030/// @returns the parsed enum, or AddressSpace::kUndefined if the string could not be parsed.
dan sinclairff7cf212022-10-03 14:05:23 +000031AddressSpace ParseAddressSpace(std::string_view str) {
Ben Clayton79781f22023-02-18 17:13:18 +000032 if (str == "__in") {
33 return AddressSpace::kIn;
34 }
35 if (str == "__out") {
36 return AddressSpace::kOut;
37 }
Ben Clayton48085842022-07-26 22:51:36 +000038 if (str == "function") {
dan sinclairff7cf212022-10-03 14:05:23 +000039 return AddressSpace::kFunction;
dan sinclair41e4d9a2022-05-01 14:40:55 +000040 }
Ben Clayton6cd15d22023-09-06 10:41:09 +000041 if (str == "pixel_local") {
42 return AddressSpace::kPixelLocal;
43 }
Ben Clayton48085842022-07-26 22:51:36 +000044 if (str == "private") {
dan sinclairff7cf212022-10-03 14:05:23 +000045 return AddressSpace::kPrivate;
Ben Clayton48085842022-07-26 22:51:36 +000046 }
Ben Claytondb368f12022-10-11 18:26:18 +000047 if (str == "push_constant") {
48 return AddressSpace::kPushConstant;
Ben Clayton48085842022-07-26 22:51:36 +000049 }
50 if (str == "storage") {
dan sinclairff7cf212022-10-03 14:05:23 +000051 return AddressSpace::kStorage;
Ben Clayton48085842022-07-26 22:51:36 +000052 }
Ben Claytondb368f12022-10-11 18:26:18 +000053 if (str == "uniform") {
54 return AddressSpace::kUniform;
55 }
56 if (str == "workgroup") {
57 return AddressSpace::kWorkgroup;
dan sinclair4abf28e2022-08-02 15:55:35 +000058 }
Ben Claytond2e0db32022-10-12 18:49:15 +000059 return AddressSpace::kUndefined;
Ryan Harrisondbc13af2022-02-21 15:19:07 +000060}
Ben Clayton48085842022-07-26 22:51:36 +000061
Ben Clayton68919602023-07-28 22:51:18 +000062std::string_view ToString(AddressSpace value) {
Ben Clayton48085842022-07-26 22:51:36 +000063 switch (value) {
Ben Claytond2e0db32022-10-12 18:49:15 +000064 case AddressSpace::kUndefined:
Ben Clayton68919602023-07-28 22:51:18 +000065 return "undefined";
Ben Clayton79781f22023-02-18 17:13:18 +000066 case AddressSpace::kIn:
Ben Clayton68919602023-07-28 22:51:18 +000067 return "__in";
Ben Clayton79781f22023-02-18 17:13:18 +000068 case AddressSpace::kOut:
Ben Clayton68919602023-07-28 22:51:18 +000069 return "__out";
dan sinclairff7cf212022-10-03 14:05:23 +000070 case AddressSpace::kFunction:
Ben Clayton68919602023-07-28 22:51:18 +000071 return "function";
dan sinclairff7cf212022-10-03 14:05:23 +000072 case AddressSpace::kHandle:
Ben Clayton68919602023-07-28 22:51:18 +000073 return "handle";
Ben Clayton6cd15d22023-09-06 10:41:09 +000074 case AddressSpace::kPixelLocal:
75 return "pixel_local";
Ben Claytondb368f12022-10-11 18:26:18 +000076 case AddressSpace::kPrivate:
Ben Clayton68919602023-07-28 22:51:18 +000077 return "private";
Ben Claytondb368f12022-10-11 18:26:18 +000078 case AddressSpace::kPushConstant:
Ben Clayton68919602023-07-28 22:51:18 +000079 return "push_constant";
Ben Claytondb368f12022-10-11 18:26:18 +000080 case AddressSpace::kStorage:
Ben Clayton68919602023-07-28 22:51:18 +000081 return "storage";
Ben Claytondb368f12022-10-11 18:26:18 +000082 case AddressSpace::kUniform:
Ben Clayton68919602023-07-28 22:51:18 +000083 return "uniform";
Ben Claytondb368f12022-10-11 18:26:18 +000084 case AddressSpace::kWorkgroup:
Ben Clayton68919602023-07-28 22:51:18 +000085 return "workgroup";
Ben Clayton48085842022-07-26 22:51:36 +000086 }
Ben Clayton68919602023-07-28 22:51:18 +000087 return "<unknown>";
Ryan Harrisondbc13af2022-02-21 15:19:07 +000088}
89
Ben Claytoncd52f382023-08-07 13:11:08 +000090} // namespace tint::core