| // Copyright 2020 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/lang/core/address_space.cc.tmpl |
| // |
| // To regenerate run: './tools/run gen' |
| // |
| // Do not modify this file directly |
| //////////////////////////////////////////////////////////////////////////////// |
| |
| #include "src/tint/lang/core/address_space.h" |
| |
| namespace tint::core { |
| |
| /// ParseAddressSpace parses a AddressSpace from a string. |
| /// @param str the string to parse |
| /// @returns the parsed enum, or AddressSpace::kUndefined if the string could not be parsed. |
| AddressSpace ParseAddressSpace(std::string_view str) { |
| if (str == "__in") { |
| return AddressSpace::kIn; |
| } |
| if (str == "__out") { |
| return AddressSpace::kOut; |
| } |
| if (str == "function") { |
| return AddressSpace::kFunction; |
| } |
| if (str == "pixel_local") { |
| return AddressSpace::kPixelLocal; |
| } |
| if (str == "private") { |
| return AddressSpace::kPrivate; |
| } |
| if (str == "push_constant") { |
| return AddressSpace::kPushConstant; |
| } |
| if (str == "storage") { |
| return AddressSpace::kStorage; |
| } |
| if (str == "uniform") { |
| return AddressSpace::kUniform; |
| } |
| if (str == "workgroup") { |
| return AddressSpace::kWorkgroup; |
| } |
| return AddressSpace::kUndefined; |
| } |
| |
| std::string_view ToString(AddressSpace value) { |
| switch (value) { |
| case AddressSpace::kUndefined: |
| return "undefined"; |
| case AddressSpace::kIn: |
| return "__in"; |
| case AddressSpace::kOut: |
| return "__out"; |
| case AddressSpace::kFunction: |
| return "function"; |
| case AddressSpace::kHandle: |
| return "handle"; |
| case AddressSpace::kPixelLocal: |
| return "pixel_local"; |
| case AddressSpace::kPrivate: |
| return "private"; |
| case AddressSpace::kPushConstant: |
| return "push_constant"; |
| case AddressSpace::kStorage: |
| return "storage"; |
| case AddressSpace::kUniform: |
| return "uniform"; |
| case AddressSpace::kWorkgroup: |
| return "workgroup"; |
| } |
| return "<unknown>"; |
| } |
| |
| } // namespace tint::core |