blob: a9a640690cbc080eefaf4d75feae53c4dcc0fee3 [file] [log] [blame]
Austin Engcc2516a2023-10-17 20:57:54 +00001// Copyright 2020 The Dawn & Tint Authors
Ryan Harrisondbc13af2022-02-21 15:19:07 +00002//
Austin Engcc2516a2023-10-17 20:57:54 +00003// Redistribution and use in source and binary forms, with or without
4// modification, are permitted provided that the following conditions are met:
Ryan Harrisondbc13af2022-02-21 15:19:07 +00005//
Austin Engcc2516a2023-10-17 20:57:54 +00006// 1. Redistributions of source code must retain the above copyright notice, this
7// list of conditions and the following disclaimer.
Ryan Harrisondbc13af2022-02-21 15:19:07 +00008//
Austin Engcc2516a2023-10-17 20:57:54 +00009// 2. Redistributions in binary form must reproduce the above copyright notice,
10// this list of conditions and the following disclaimer in the documentation
11// and/or other materials provided with the distribution.
12//
13// 3. Neither the name of the copyright holder nor the names of its
14// contributors may be used to endorse or promote products derived from
15// this software without specific prior written permission.
16//
17// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Ryan Harrisondbc13af2022-02-21 15:19:07 +000027
Ben Claytona123b892022-07-27 16:36:35 +000028////////////////////////////////////////////////////////////////////////////////
Ben Clayton57ded6a2023-08-22 13:22:22 +000029// File generated by 'tools/src/cmd/gen' using the template:
Ben Claytoncd52f382023-08-07 13:11:08 +000030// src/tint/lang/core/address_space.cc.tmpl
Ben Claytona123b892022-07-27 16:36:35 +000031//
Ben Clayton57ded6a2023-08-22 13:22:22 +000032// To regenerate run: './tools/run gen'
33//
34// Do not modify this file directly
Ben Claytona123b892022-07-27 16:36:35 +000035////////////////////////////////////////////////////////////////////////////////
36
Ben Claytoncd52f382023-08-07 13:11:08 +000037#include "src/tint/lang/core/address_space.h"
Ryan Harrisondbc13af2022-02-21 15:19:07 +000038
Ben Claytoncd52f382023-08-07 13:11:08 +000039namespace tint::core {
Ryan Harrisondbc13af2022-02-21 15:19:07 +000040
dan sinclairff7cf212022-10-03 14:05:23 +000041/// ParseAddressSpace parses a AddressSpace from a string.
Ben Clayton48085842022-07-26 22:51:36 +000042/// @param str the string to parse
Ben Claytond2e0db32022-10-12 18:49:15 +000043/// @returns the parsed enum, or AddressSpace::kUndefined if the string could not be parsed.
dan sinclairff7cf212022-10-03 14:05:23 +000044AddressSpace ParseAddressSpace(std::string_view str) {
Ben Clayton79781f22023-02-18 17:13:18 +000045 if (str == "__in") {
46 return AddressSpace::kIn;
47 }
48 if (str == "__out") {
49 return AddressSpace::kOut;
50 }
Ben Clayton48085842022-07-26 22:51:36 +000051 if (str == "function") {
dan sinclairff7cf212022-10-03 14:05:23 +000052 return AddressSpace::kFunction;
dan sinclair41e4d9a2022-05-01 14:40:55 +000053 }
Ben Clayton6cd15d22023-09-06 10:41:09 +000054 if (str == "pixel_local") {
55 return AddressSpace::kPixelLocal;
56 }
Ben Clayton48085842022-07-26 22:51:36 +000057 if (str == "private") {
dan sinclairff7cf212022-10-03 14:05:23 +000058 return AddressSpace::kPrivate;
Ben Clayton48085842022-07-26 22:51:36 +000059 }
Ben Claytondb368f12022-10-11 18:26:18 +000060 if (str == "push_constant") {
61 return AddressSpace::kPushConstant;
Ben Clayton48085842022-07-26 22:51:36 +000062 }
63 if (str == "storage") {
dan sinclairff7cf212022-10-03 14:05:23 +000064 return AddressSpace::kStorage;
Ben Clayton48085842022-07-26 22:51:36 +000065 }
Ben Claytondb368f12022-10-11 18:26:18 +000066 if (str == "uniform") {
67 return AddressSpace::kUniform;
68 }
69 if (str == "workgroup") {
70 return AddressSpace::kWorkgroup;
dan sinclair4abf28e2022-08-02 15:55:35 +000071 }
Ben Claytond2e0db32022-10-12 18:49:15 +000072 return AddressSpace::kUndefined;
Ryan Harrisondbc13af2022-02-21 15:19:07 +000073}
Ben Clayton48085842022-07-26 22:51:36 +000074
Ben Clayton68919602023-07-28 22:51:18 +000075std::string_view ToString(AddressSpace value) {
Ben Clayton48085842022-07-26 22:51:36 +000076 switch (value) {
Ben Claytond2e0db32022-10-12 18:49:15 +000077 case AddressSpace::kUndefined:
Ben Clayton68919602023-07-28 22:51:18 +000078 return "undefined";
Ben Clayton79781f22023-02-18 17:13:18 +000079 case AddressSpace::kIn:
Ben Clayton68919602023-07-28 22:51:18 +000080 return "__in";
Ben Clayton79781f22023-02-18 17:13:18 +000081 case AddressSpace::kOut:
Ben Clayton68919602023-07-28 22:51:18 +000082 return "__out";
dan sinclairff7cf212022-10-03 14:05:23 +000083 case AddressSpace::kFunction:
Ben Clayton68919602023-07-28 22:51:18 +000084 return "function";
dan sinclairff7cf212022-10-03 14:05:23 +000085 case AddressSpace::kHandle:
Ben Clayton68919602023-07-28 22:51:18 +000086 return "handle";
Ben Clayton6cd15d22023-09-06 10:41:09 +000087 case AddressSpace::kPixelLocal:
88 return "pixel_local";
Ben Claytondb368f12022-10-11 18:26:18 +000089 case AddressSpace::kPrivate:
Ben Clayton68919602023-07-28 22:51:18 +000090 return "private";
Ben Claytondb368f12022-10-11 18:26:18 +000091 case AddressSpace::kPushConstant:
Ben Clayton68919602023-07-28 22:51:18 +000092 return "push_constant";
Ben Claytondb368f12022-10-11 18:26:18 +000093 case AddressSpace::kStorage:
Ben Clayton68919602023-07-28 22:51:18 +000094 return "storage";
Ben Claytondb368f12022-10-11 18:26:18 +000095 case AddressSpace::kUniform:
Ben Clayton68919602023-07-28 22:51:18 +000096 return "uniform";
Ben Claytondb368f12022-10-11 18:26:18 +000097 case AddressSpace::kWorkgroup:
Ben Clayton68919602023-07-28 22:51:18 +000098 return "workgroup";
Ben Clayton48085842022-07-26 22:51:36 +000099 }
Ben Clayton68919602023-07-28 22:51:18 +0000100 return "<unknown>";
Ryan Harrisondbc13af2022-02-21 15:19:07 +0000101}
102
Ben Claytoncd52f382023-08-07 13:11:08 +0000103} // namespace tint::core