| 1 | //===--- SPIRVCommandLine.h ---- Command Line Options -----------*- C++ -*-===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This file contains classes and functions needed for processing, parsing, and |
| 10 | // using CLI options for the SPIR-V backend. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LLVM_LIB_TARGET_SPIRV_COMMANDLINE_H |
| 15 | #define LLVM_LIB_TARGET_SPIRV_COMMANDLINE_H |
| 16 | |
| 17 | #include "MCTargetDesc/SPIRVBaseInfo.h" |
| 18 | #include "llvm/Support/CommandLine.h" |
| 19 | #include <set> |
| 20 | #include <string> |
| 21 | |
| 22 | namespace llvm { |
| 23 | class StringRef; |
| 24 | |
| 25 | /// Command line parser for toggling SPIR-V extensions. |
| 26 | struct SPIRVExtensionsParser |
| 27 | : public cl::parser<std::set<SPIRV::Extension::Extension>> { |
| 28 | public: |
| 29 | SPIRVExtensionsParser(cl::Option &O) |
| 30 | : cl::parser<std::set<SPIRV::Extension::Extension>>(O) {} |
| 31 | |
| 32 | /// Parses SPIR-V extension name from CLI arguments. |
| 33 | /// |
| 34 | /// \return Returns true on error. |
| 35 | bool parse(cl::Option &O, StringRef ArgName, StringRef ArgValue, |
| 36 | std::set<SPIRV::Extension::Extension> &Vals); |
| 37 | |
| 38 | /// Validates and converts extension names into internal enum values. |
| 39 | /// |
| 40 | /// \return Returns a reference to the unknown SPIR-V extension name from the |
| 41 | /// list if present, or an empty StringRef on success. |
| 42 | static StringRef |
| 43 | checkExtensions(const std::vector<std::string> &ExtNames, |
| 44 | std::set<SPIRV::Extension::Extension> &AllowedExtensions); |
| 45 | }; |
| 46 | |
| 47 | } // namespace llvm |
| 48 | #endif // LLVM_LIB_TARGET_SPIRV_COMMANDLINE_H |
| 49 | |