Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 1 | // 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 Clayton | a123b89 | 2022-07-27 16:36:35 +0000 | [diff] [blame] | 15 | //////////////////////////////////////////////////////////////////////////////// |
Ben Clayton | 57ded6a | 2023-08-22 13:22:22 +0000 | [diff] [blame] | 16 | // File generated by 'tools/src/cmd/gen' using the template: |
Ben Clayton | cd52f38 | 2023-08-07 13:11:08 +0000 | [diff] [blame] | 17 | // src/tint/lang/core/address_space.cc.tmpl |
Ben Clayton | a123b89 | 2022-07-27 16:36:35 +0000 | [diff] [blame] | 18 | // |
Ben Clayton | 57ded6a | 2023-08-22 13:22:22 +0000 | [diff] [blame] | 19 | // To regenerate run: './tools/run gen' |
| 20 | // |
| 21 | // Do not modify this file directly |
Ben Clayton | a123b89 | 2022-07-27 16:36:35 +0000 | [diff] [blame] | 22 | //////////////////////////////////////////////////////////////////////////////// |
| 23 | |
Ben Clayton | cd52f38 | 2023-08-07 13:11:08 +0000 | [diff] [blame] | 24 | #include "src/tint/lang/core/address_space.h" |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 25 | |
Ben Clayton | cd52f38 | 2023-08-07 13:11:08 +0000 | [diff] [blame] | 26 | namespace tint::core { |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 27 | |
dan sinclair | ff7cf21 | 2022-10-03 14:05:23 +0000 | [diff] [blame] | 28 | /// ParseAddressSpace parses a AddressSpace from a string. |
Ben Clayton | 4808584 | 2022-07-26 22:51:36 +0000 | [diff] [blame] | 29 | /// @param str the string to parse |
Ben Clayton | d2e0db3 | 2022-10-12 18:49:15 +0000 | [diff] [blame] | 30 | /// @returns the parsed enum, or AddressSpace::kUndefined if the string could not be parsed. |
dan sinclair | ff7cf21 | 2022-10-03 14:05:23 +0000 | [diff] [blame] | 31 | AddressSpace ParseAddressSpace(std::string_view str) { |
Ben Clayton | 79781f2 | 2023-02-18 17:13:18 +0000 | [diff] [blame] | 32 | if (str == "__in") { |
| 33 | return AddressSpace::kIn; |
| 34 | } |
| 35 | if (str == "__out") { |
| 36 | return AddressSpace::kOut; |
| 37 | } |
Ben Clayton | 4808584 | 2022-07-26 22:51:36 +0000 | [diff] [blame] | 38 | if (str == "function") { |
dan sinclair | ff7cf21 | 2022-10-03 14:05:23 +0000 | [diff] [blame] | 39 | return AddressSpace::kFunction; |
dan sinclair | 41e4d9a | 2022-05-01 14:40:55 +0000 | [diff] [blame] | 40 | } |
Ben Clayton | 6cd15d2 | 2023-09-06 10:41:09 +0000 | [diff] [blame] | 41 | if (str == "pixel_local") { |
| 42 | return AddressSpace::kPixelLocal; |
| 43 | } |
Ben Clayton | 4808584 | 2022-07-26 22:51:36 +0000 | [diff] [blame] | 44 | if (str == "private") { |
dan sinclair | ff7cf21 | 2022-10-03 14:05:23 +0000 | [diff] [blame] | 45 | return AddressSpace::kPrivate; |
Ben Clayton | 4808584 | 2022-07-26 22:51:36 +0000 | [diff] [blame] | 46 | } |
Ben Clayton | db368f1 | 2022-10-11 18:26:18 +0000 | [diff] [blame] | 47 | if (str == "push_constant") { |
| 48 | return AddressSpace::kPushConstant; |
Ben Clayton | 4808584 | 2022-07-26 22:51:36 +0000 | [diff] [blame] | 49 | } |
| 50 | if (str == "storage") { |
dan sinclair | ff7cf21 | 2022-10-03 14:05:23 +0000 | [diff] [blame] | 51 | return AddressSpace::kStorage; |
Ben Clayton | 4808584 | 2022-07-26 22:51:36 +0000 | [diff] [blame] | 52 | } |
Ben Clayton | db368f1 | 2022-10-11 18:26:18 +0000 | [diff] [blame] | 53 | if (str == "uniform") { |
| 54 | return AddressSpace::kUniform; |
| 55 | } |
| 56 | if (str == "workgroup") { |
| 57 | return AddressSpace::kWorkgroup; |
dan sinclair | 4abf28e | 2022-08-02 15:55:35 +0000 | [diff] [blame] | 58 | } |
Ben Clayton | d2e0db3 | 2022-10-12 18:49:15 +0000 | [diff] [blame] | 59 | return AddressSpace::kUndefined; |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 60 | } |
Ben Clayton | 4808584 | 2022-07-26 22:51:36 +0000 | [diff] [blame] | 61 | |
Ben Clayton | 6891960 | 2023-07-28 22:51:18 +0000 | [diff] [blame] | 62 | std::string_view ToString(AddressSpace value) { |
Ben Clayton | 4808584 | 2022-07-26 22:51:36 +0000 | [diff] [blame] | 63 | switch (value) { |
Ben Clayton | d2e0db3 | 2022-10-12 18:49:15 +0000 | [diff] [blame] | 64 | case AddressSpace::kUndefined: |
Ben Clayton | 6891960 | 2023-07-28 22:51:18 +0000 | [diff] [blame] | 65 | return "undefined"; |
Ben Clayton | 79781f2 | 2023-02-18 17:13:18 +0000 | [diff] [blame] | 66 | case AddressSpace::kIn: |
Ben Clayton | 6891960 | 2023-07-28 22:51:18 +0000 | [diff] [blame] | 67 | return "__in"; |
Ben Clayton | 79781f2 | 2023-02-18 17:13:18 +0000 | [diff] [blame] | 68 | case AddressSpace::kOut: |
Ben Clayton | 6891960 | 2023-07-28 22:51:18 +0000 | [diff] [blame] | 69 | return "__out"; |
dan sinclair | ff7cf21 | 2022-10-03 14:05:23 +0000 | [diff] [blame] | 70 | case AddressSpace::kFunction: |
Ben Clayton | 6891960 | 2023-07-28 22:51:18 +0000 | [diff] [blame] | 71 | return "function"; |
dan sinclair | ff7cf21 | 2022-10-03 14:05:23 +0000 | [diff] [blame] | 72 | case AddressSpace::kHandle: |
Ben Clayton | 6891960 | 2023-07-28 22:51:18 +0000 | [diff] [blame] | 73 | return "handle"; |
Ben Clayton | 6cd15d2 | 2023-09-06 10:41:09 +0000 | [diff] [blame] | 74 | case AddressSpace::kPixelLocal: |
| 75 | return "pixel_local"; |
Ben Clayton | db368f1 | 2022-10-11 18:26:18 +0000 | [diff] [blame] | 76 | case AddressSpace::kPrivate: |
Ben Clayton | 6891960 | 2023-07-28 22:51:18 +0000 | [diff] [blame] | 77 | return "private"; |
Ben Clayton | db368f1 | 2022-10-11 18:26:18 +0000 | [diff] [blame] | 78 | case AddressSpace::kPushConstant: |
Ben Clayton | 6891960 | 2023-07-28 22:51:18 +0000 | [diff] [blame] | 79 | return "push_constant"; |
Ben Clayton | db368f1 | 2022-10-11 18:26:18 +0000 | [diff] [blame] | 80 | case AddressSpace::kStorage: |
Ben Clayton | 6891960 | 2023-07-28 22:51:18 +0000 | [diff] [blame] | 81 | return "storage"; |
Ben Clayton | db368f1 | 2022-10-11 18:26:18 +0000 | [diff] [blame] | 82 | case AddressSpace::kUniform: |
Ben Clayton | 6891960 | 2023-07-28 22:51:18 +0000 | [diff] [blame] | 83 | return "uniform"; |
Ben Clayton | db368f1 | 2022-10-11 18:26:18 +0000 | [diff] [blame] | 84 | case AddressSpace::kWorkgroup: |
Ben Clayton | 6891960 | 2023-07-28 22:51:18 +0000 | [diff] [blame] | 85 | return "workgroup"; |
Ben Clayton | 4808584 | 2022-07-26 22:51:36 +0000 | [diff] [blame] | 86 | } |
Ben Clayton | 6891960 | 2023-07-28 22:51:18 +0000 | [diff] [blame] | 87 | return "<unknown>"; |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 88 | } |
| 89 | |
Ben Clayton | cd52f38 | 2023-08-07 13:11:08 +0000 | [diff] [blame] | 90 | } // namespace tint::core |