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 <string>
20
21namespace llvm {
22class StringRef;
23class Triple;
24
25/// Command line parser for toggling SPIR-V extensions.
26struct SPIRVExtensionsParser : public cl::parser<ExtensionSet> {
27public:
28 SPIRVExtensionsParser(cl::Option &O) : cl::parser<ExtensionSet>(O) {}
29
30 /// Parses SPIR-V extension name from CLI arguments.
31 ///
32 /// \return Returns true on error.
33 bool parse(cl::Option &O, StringRef ArgName, StringRef ArgValue,
34 ExtensionSet &Vals);
35
36 /// Validates and converts extension names into internal enum values.
37 ///
38 /// \return Returns a reference to the unknown SPIR-V extension name from the
39 /// list if present, or an empty StringRef on success.
40 static StringRef checkExtensions(const std::vector<std::string> &ExtNames,
41 ExtensionSet &AllowedExtensions);
42
43 /// Returns the list of extensions that are valid for a particular
44 /// target environment (i.e., OpenCL or Vulkan).
45 static ExtensionSet getValidExtensions(const Triple &TT);
46
47private:
48 static ExtensionSet DisabledExtensions;
49};
50
51} // namespace llvm
52#endif // LLVM_LIB_TARGET_SPIRV_COMMANDLINE_H
53