19#define DEBUG_TYPE "spirv-commandline"
23static const std::map<std::string, SPIRV::Extension::Extension>
25 {
"SPV_EXT_shader_atomic_float_add",
26 SPIRV::Extension::Extension::SPV_EXT_shader_atomic_float_add},
27 {
"SPV_EXT_shader_atomic_float16_add",
28 SPIRV::Extension::Extension::SPV_EXT_shader_atomic_float16_add},
29 {
"SPV_EXT_shader_atomic_float_min_max",
30 SPIRV::Extension::Extension::SPV_EXT_shader_atomic_float_min_max},
31 {
"SPV_INTEL_arbitrary_precision_integers",
32 SPIRV::Extension::Extension::SPV_INTEL_arbitrary_precision_integers},
33 {
"SPV_INTEL_cache_controls",
34 SPIRV::Extension::Extension::SPV_INTEL_cache_controls},
35 {
"SPV_INTEL_global_variable_fpga_decorations",
36 SPIRV::Extension::Extension::
37 SPV_INTEL_global_variable_fpga_decorations},
38 {
"SPV_INTEL_global_variable_host_access",
39 SPIRV::Extension::Extension::SPV_INTEL_global_variable_host_access},
40 {
"SPV_INTEL_optnone", SPIRV::Extension::Extension::SPV_INTEL_optnone},
41 {
"SPV_INTEL_usm_storage_classes",
42 SPIRV::Extension::Extension::SPV_INTEL_usm_storage_classes},
43 {
"SPV_INTEL_subgroups",
44 SPIRV::Extension::Extension::SPV_INTEL_subgroups},
45 {
"SPV_KHR_uniform_group_instructions",
46 SPIRV::Extension::Extension::SPV_KHR_uniform_group_instructions},
47 {
"SPV_KHR_no_integer_wrap_decoration",
48 SPIRV::Extension::Extension::SPV_KHR_no_integer_wrap_decoration},
49 {
"SPV_KHR_float_controls",
50 SPIRV::Extension::Extension::SPV_KHR_float_controls},
51 {
"SPV_KHR_expect_assume",
52 SPIRV::Extension::Extension::SPV_KHR_expect_assume},
53 {
"SPV_KHR_bit_instructions",
54 SPIRV::Extension::Extension::SPV_KHR_bit_instructions},
55 {
"SPV_KHR_linkonce_odr",
56 SPIRV::Extension::Extension::SPV_KHR_linkonce_odr},
57 {
"SPV_INTEL_inline_assembly",
58 SPIRV::Extension::Extension::SPV_INTEL_inline_assembly},
59 {
"SPV_INTEL_bfloat16_conversion",
60 SPIRV::Extension::Extension::SPV_INTEL_bfloat16_conversion},
61 {
"SPV_KHR_subgroup_rotate",
62 SPIRV::Extension::Extension::SPV_KHR_subgroup_rotate},
63 {
"SPV_INTEL_variable_length_array",
64 SPIRV::Extension::Extension::SPV_INTEL_variable_length_array},
65 {
"SPV_INTEL_function_pointers",
66 SPIRV::Extension::Extension::SPV_INTEL_function_pointers},
67 {
"SPV_KHR_shader_clock",
68 SPIRV::Extension::Extension::SPV_KHR_shader_clock},
69 {
"SPV_KHR_cooperative_matrix",
70 SPIRV::Extension::Extension::SPV_KHR_cooperative_matrix},
75 std::set<SPIRV::Extension::Extension> &Vals) {
77 ArgValue.
split(Tokens,
",", -1,
false);
78 std::sort(Tokens.
begin(), Tokens.
end());
80 std::set<SPIRV::Extension::Extension> EnabledExtensions;
82 for (
const auto &Token : Tokens) {
85 EnabledExtensions.insert(ExtensionEnum);
90 if (Token.empty() || (!Token.starts_with(
"+") && !Token.starts_with(
"-")))
91 return O.error(
"Invalid extension list format: " + Token.str());
97 return O.error(
"Unknown SPIR-V extension: " + Token.str());
99 if (Token.starts_with(
"+")) {
100 EnabledExtensions.insert(NameValuePair->second);
101 }
else if (EnabledExtensions.count(NameValuePair->second)) {
102 if (std::find(Tokens.
begin(), Tokens.
end(),
"+" + ExtensionName.
str()) !=
105 "Extension cannot be allowed and disallowed at the same time: " +
106 ExtensionName.
str());
108 EnabledExtensions.erase(NameValuePair->second);
112 Vals = std::move(EnabledExtensions);
static const std::map< std::string, SPIRV::Extension::Extension > SPIRVExtensionMap
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
std::string str() const
str - Get the contents as an std::string.
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
This is an optimization pass for GlobalISel generic memory operations.
bool parse(cl::Option &O, StringRef ArgName, StringRef ArgValue, std::set< SPIRV::Extension::Extension > &Vals)
Parses SPIR-V extension name from CLI arguments.