[llvm] [SPIRV] Filter disallowed extensions for env (PR #150051)

Steven Perron via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 24 13:04:07 PDT 2025


https://github.com/s-perron updated https://github.com/llvm/llvm-project/pull/150051

>From 1bb22a24c921114a0d0565e1cc645570bd0203b2 Mon Sep 17 00:00:00 2001
From: Steven Perron <stevenperron at google.com>
Date: Tue, 22 Jul 2025 10:28:13 -0400
Subject: [PATCH 1/8] [SPIRV] Filter the out disallows extensions for env

Not all SPIR-V extensions are allows in every environment. When we use
the `-spirv-ext=all` option, the backend currently believes that all
extensions can be used.

This commit filters out the extensions on the command line to remove
those that are not known to be allowed for the current environment.

Alternatives considered: I considered modifying the
SPIRVExtensionsParser::parse to use a different list of extensions for
"all" depending on the target triple. However that does not work because
the target triple is not available, and cannot be made available in a
reasonable way.

Fixes #147717
---
 llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp    | 92 ++++++++++++++++++-
 llvm/lib/Target/SPIRV/SPIRVCommandLine.h      |  6 ++
 llvm/lib/Target/SPIRV/SPIRVSubtarget.cpp      |  8 +-
 .../enable-all-extensions-avoid-invalid.ll    | 16 ++++
 4 files changed, 120 insertions(+), 2 deletions(-)
 create mode 100644 llvm/test/CodeGen/SPIRV/extensions/enable-all-extensions-avoid-invalid.ll

diff --git a/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp b/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp
index 2726203d253ad..be3a6a93a5a51 100644
--- a/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp
@@ -12,7 +12,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "SPIRVCommandLine.h"
-#include "llvm/ADT/StringRef.h"
+#include "llvm/TargetParser/Triple.h"
 #include <algorithm>
 #include <map>
 
@@ -20,6 +20,69 @@
 
 using namespace llvm;
 
+// List of extensions allowed for Vulkan environment.
+// This should not contain an extension that is not listed in
+// https://github.com/KhronosGroup/Vulkan-Headers/blob/main/registry/vk.xml.
+static const std::set<SPIRV::Extension::Extension> ValidVulkanExtensions = {
+    SPIRV::Extension::SPV_EXT_demote_to_helper_invocation,
+    SPIRV::Extension::SPV_EXT_shader_atomic_float_add,
+    SPIRV::Extension::SPV_EXT_shader_atomic_float16_add,
+    SPIRV::Extension::SPV_EXT_shader_atomic_float_min_max,
+    SPIRV::Extension::SPV_KHR_cooperative_matrix,
+    SPIRV::Extension::SPV_KHR_expect_assume,
+    SPIRV::Extension::SPV_KHR_float_controls,
+    SPIRV::Extension::SPV_KHR_float_controls2,
+    SPIRV::Extension::SPV_KHR_integer_dot_product,
+    SPIRV::Extension::SPV_KHR_non_semantic_info,
+    SPIRV::Extension::SPV_KHR_shader_clock,
+    SPIRV::Extension::SPV_KHR_subgroup_rotate};
+
+// List of extensions allowed for OpenCL environment.
+// TODO: Remove extension not used by OpenCL. I do not know how to get that
+// information.
+static const std::set<SPIRV::Extension::Extension> ValidOpenCLExtensions = {
+    SPIRV::Extension::SPV_EXT_shader_atomic_float_add,
+    SPIRV::Extension::SPV_EXT_shader_atomic_float16_add,
+    SPIRV::Extension::SPV_EXT_shader_atomic_float_min_max,
+    SPIRV::Extension::SPV_EXT_arithmetic_fence,
+    SPIRV::Extension::SPV_EXT_demote_to_helper_invocation,
+    SPIRV::Extension::SPV_INTEL_arbitrary_precision_integers,
+    SPIRV::Extension::SPV_INTEL_cache_controls,
+    SPIRV::Extension::SPV_INTEL_float_controls2,
+    SPIRV::Extension::SPV_INTEL_global_variable_fpga_decorations,
+    SPIRV::Extension::SPV_INTEL_global_variable_host_access,
+    SPIRV::Extension::SPV_INTEL_optnone,
+    SPIRV::Extension::SPV_EXT_optnone,
+    SPIRV::Extension::SPV_INTEL_usm_storage_classes,
+    SPIRV::Extension::SPV_INTEL_split_barrier,
+    SPIRV::Extension::SPV_INTEL_subgroups,
+    SPIRV::Extension::SPV_INTEL_media_block_io,
+    SPIRV::Extension::SPV_INTEL_memory_access_aliasing,
+    SPIRV::Extension::SPV_INTEL_joint_matrix,
+    SPIRV::Extension::SPV_KHR_uniform_group_instructions,
+    SPIRV::Extension::SPV_KHR_no_integer_wrap_decoration,
+    SPIRV::Extension::SPV_KHR_float_controls,
+    SPIRV::Extension::SPV_KHR_expect_assume,
+    SPIRV::Extension::SPV_KHR_bit_instructions,
+    SPIRV::Extension::SPV_KHR_integer_dot_product,
+    SPIRV::Extension::SPV_KHR_linkonce_odr,
+    SPIRV::Extension::SPV_INTEL_inline_assembly,
+    SPIRV::Extension::SPV_INTEL_bindless_images,
+    SPIRV::Extension::SPV_INTEL_bfloat16_conversion,
+    SPIRV::Extension::SPV_KHR_subgroup_rotate,
+    SPIRV::Extension::SPV_INTEL_variable_length_array,
+    SPIRV::Extension::SPV_INTEL_function_pointers,
+    SPIRV::Extension::SPV_KHR_shader_clock,
+    SPIRV::Extension::SPV_KHR_cooperative_matrix,
+    SPIRV::Extension::SPV_KHR_non_semantic_info,
+    SPIRV::Extension::SPV_INTEL_long_composites,
+    SPIRV::Extension::SPV_INTEL_fp_max_error,
+    SPIRV::Extension::SPV_INTEL_subgroup_matrix_multiply_accumulate,
+    SPIRV::Extension::SPV_INTEL_ternary_bitwise_function,
+    SPIRV::Extension::SPV_INTEL_2d_block_io,
+    SPIRV::Extension::SPV_INTEL_int4,
+    SPIRV::Extension::SPV_KHR_float_controls2};
+
 static const std::map<std::string, SPIRV::Extension::Extension, std::less<>>
     SPIRVExtensionMap = {
         {"SPV_EXT_shader_atomic_float_add",
@@ -104,6 +167,26 @@ static const std::map<std::string, SPIRV::Extension::Extension, std::less<>>
         {"SPV_KHR_float_controls2",
          SPIRV::Extension::Extension::SPV_KHR_float_controls2}};
 
+/*
+
+TODO: std::set_union is not constexpr in c++17. I would still like a way to make
+sure the environment lists are added.
+
+// Check that every extension is in at least one of the two lists.
+constexpr bool AreAllExtensionsInAnEnvList() noexcept {
+      SPIRV::Extension::Extension ExtensionsInEnvList[100] = {};
+      constexpr auto* end = std::set_union(ValidVulkanExtensions.begin(),
+ValidVulkanExtensions.end(), ValidOpenCLExtensions.begin(),
+ValidOpenCLExtensions.end(), ExtensionsInEnvList); return
+(end-ExtensionsInEnvList) == SPIRVExtensionMap.size();
+}
+
+static_assert(
+    AreAllExtensionsInAnEnvList(),
+    "Not all extensions are in ValidVulkanExtensions or "
+    "ValidOpenCLExtensions");
+*/
+
 bool SPIRVExtensionsParser::parse(cl::Option &O, StringRef ArgName,
                                   StringRef ArgValue,
                                   std::set<SPIRV::Extension::Extension> &Vals) {
@@ -169,3 +252,10 @@ StringRef SPIRVExtensionsParser::checkExtensions(
   }
   return StringRef();
 }
+
+const std::set<SPIRV::Extension::Extension> &
+SPIRVExtensionsParser::getValidExtensions(const Triple &TT) {
+  if (TT.getOS() == Triple::Vulkan)
+    return ValidVulkanExtensions;
+  return ValidOpenCLExtensions;
+}
diff --git a/llvm/lib/Target/SPIRV/SPIRVCommandLine.h b/llvm/lib/Target/SPIRV/SPIRVCommandLine.h
index 3e3b22bde8603..dbde2397ab214 100644
--- a/llvm/lib/Target/SPIRV/SPIRVCommandLine.h
+++ b/llvm/lib/Target/SPIRV/SPIRVCommandLine.h
@@ -21,6 +21,7 @@
 
 namespace llvm {
 class StringRef;
+class Triple;
 
 /// Command line parser for toggling SPIR-V extensions.
 struct SPIRVExtensionsParser
@@ -42,6 +43,11 @@ struct SPIRVExtensionsParser
   static StringRef
   checkExtensions(const std::vector<std::string> &ExtNames,
                   std::set<SPIRV::Extension::Extension> &AllowedExtensions);
+
+  /// Returns the list of extensions that are valid for a particular
+  /// target environment (i.e., OpenCL or Vulkan).
+  static const std::set<SPIRV::Extension::Extension> &
+  getValidExtensions(const Triple &TT);
 };
 
 } // namespace llvm
diff --git a/llvm/lib/Target/SPIRV/SPIRVSubtarget.cpp b/llvm/lib/Target/SPIRV/SPIRVSubtarget.cpp
index cdf3c6224d4c8..690493fb426bc 100644
--- a/llvm/lib/Target/SPIRV/SPIRVSubtarget.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVSubtarget.cpp
@@ -166,7 +166,13 @@ void SPIRVSubtarget::initAvailableExtInstSets() {
 void SPIRVSubtarget::initAvailableExtensions(
     const std::set<SPIRV::Extension::Extension> &AllowedExtIds) {
   AvailableExtensions.clear();
-  AvailableExtensions.insert_range(AllowedExtIds);
+  const std::set<SPIRV::Extension::Extension> &ValidExtensions =
+      SPIRVExtensionsParser::getValidExtensions(TargetTriple);
+
+  for (const auto &Ext : AllowedExtIds) {
+    if (ValidExtensions.count(Ext))
+      AvailableExtensions.insert(Ext);
+  }
 
   accountForAMDShaderTrinaryMinmax();
 }
diff --git a/llvm/test/CodeGen/SPIRV/extensions/enable-all-extensions-avoid-invalid.ll b/llvm/test/CodeGen/SPIRV/extensions/enable-all-extensions-avoid-invalid.ll
new file mode 100644
index 0000000000000..2de7fff0bc900
--- /dev/null
+++ b/llvm/test/CodeGen/SPIRV/extensions/enable-all-extensions-avoid-invalid.ll
@@ -0,0 +1,16 @@
+; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv1.6-vulkan1.3-compute --spirv-ext=all %s -o - | FileCheck %s
+; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv1.6-vulkan1.3-compute --spirv-ext=all %s -o - -filetype=obj | spirv-val --target-env vulkan1.3 %}
+
+; CHECK-NOT: OpExtension "SPV_KHR_no_integer_wrap_decoration"
+
+define internal void @foo(i32 %i) local_unnamed_addr {
+  %sub.i = sub nsw i32 0, %i
+  ret void
+}
+
+define internal void @main() local_unnamed_addr #0 {
+entry:
+  ret void
+}
+
+attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
\ No newline at end of file

>From 72e56290eb68e401ed55a25ead3bbfe3fc54c1b3 Mon Sep 17 00:00:00 2001
From: Steven Perron <stevenperron at google.com>
Date: Thu, 24 Jul 2025 11:23:17 -0400
Subject: [PATCH 2/8] Update llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp

Co-authored-by: Victor Lomuller <victor at codeplay.com>
---
 llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp b/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp
index be3a6a93a5a51..86ff897269416 100644
--- a/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp
@@ -45,7 +45,6 @@ static const std::set<SPIRV::Extension::Extension> ValidOpenCLExtensions = {
     SPIRV::Extension::SPV_EXT_shader_atomic_float16_add,
     SPIRV::Extension::SPV_EXT_shader_atomic_float_min_max,
     SPIRV::Extension::SPV_EXT_arithmetic_fence,
-    SPIRV::Extension::SPV_EXT_demote_to_helper_invocation,
     SPIRV::Extension::SPV_INTEL_arbitrary_precision_integers,
     SPIRV::Extension::SPV_INTEL_cache_controls,
     SPIRV::Extension::SPV_INTEL_float_controls2,

>From 25aa10b3a3ee45cad675ab80e619e7f7a4d06ebb Mon Sep 17 00:00:00 2001
From: Steven Perron <stevenperron at google.com>
Date: Thu, 24 Jul 2025 11:50:40 -0400
Subject: [PATCH 3/8] Change symbolic operands.

---
 .../lib/Target/SPIRV/SPIRVSymbolicOperands.td | 256 +++++++++---------
 1 file changed, 129 insertions(+), 127 deletions(-)

diff --git a/llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td b/llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td
index 548e9b717c161..dd9531c37a5ec 100644
--- a/llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td
+++ b/llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td
@@ -187,139 +187,141 @@ def Extension : GenericEnum, Operand<i32> {
   let PrintMethod = "printExtension";
 }
 
+class Capability;
+
 class Extension<string name, bits<32> value> {
   string Name = name;
   bits<32> Value = value;
 }
 
-multiclass ExtensionOperand<bits<32> value> {
+multiclass ExtensionOperand<bits<32> value, list<Capability> reqCapabilities> {
   def NAME : Extension<NAME, value>;
-  defm : SymbolicOperandWithRequirements<ExtensionOperand, value, NAME, 0, 0, [], []>;
-}
-
-defm SPV_AMD_shader_explicit_vertex_parameter : ExtensionOperand<1>;
-defm SPV_AMD_shader_trinary_minmax_extension : ExtensionOperand<2>;
-defm SPV_AMD_gcn_shader : ExtensionOperand<3>;
-defm SPV_KHR_shader_ballot : ExtensionOperand<4>;
-defm SPV_AMD_shader_ballot : ExtensionOperand<5>;
-defm SPV_AMD_gpu_shader_half_float : ExtensionOperand<6>;
-defm SPV_KHR_shader_draw_parameters : ExtensionOperand<7>;
-defm SPV_KHR_subgroup_vote : ExtensionOperand<8>;
-defm SPV_KHR_16bit_storage : ExtensionOperand<9>;
-defm SPV_KHR_device_group : ExtensionOperand<10>;
-defm SPV_KHR_multiview : ExtensionOperand<11>;
-defm SPV_NVX_multiview_per_view_attributes : ExtensionOperand<12>;
-defm SPV_NV_viewport_array2 : ExtensionOperand<13>;
-defm SPV_NV_stereo_view_rendering : ExtensionOperand<14>;
-defm SPV_NV_sample_mask_override_coverage : ExtensionOperand<15>;
-defm SPV_NV_geometry_shader_passthrough : ExtensionOperand<16>;
-defm SPV_AMD_texture_gather_bias_lod : ExtensionOperand<17>;
-defm SPV_KHR_storage_buffer_storage_class : ExtensionOperand<18>;
-defm SPV_KHR_variable_pointers : ExtensionOperand<19>;
-defm SPV_AMD_gpu_shader_int16 : ExtensionOperand<20>;
-defm SPV_KHR_post_depth_coverage : ExtensionOperand<21>;
-defm SPV_KHR_shader_atomic_counter_ops : ExtensionOperand<22>;
-defm SPV_EXT_shader_stencil_export : ExtensionOperand<23>;
-defm SPV_EXT_shader_viewport_index_layer : ExtensionOperand<24>;
-defm SPV_AMD_shader_image_load_store_lod : ExtensionOperand<25>;
-defm SPV_AMD_shader_fragment_mask : ExtensionOperand<26>;
-defm SPV_EXT_fragment_fully_covered : ExtensionOperand<27>;
-defm SPV_AMD_gpu_shader_half_float_fetch : ExtensionOperand<28>;
-defm SPV_GOOGLE_decorate_string : ExtensionOperand<29>;
-defm SPV_GOOGLE_hlsl_functionality1 : ExtensionOperand<30>;
-defm SPV_NV_shader_subgroup_partitioned : ExtensionOperand<31>;
-defm SPV_EXT_descriptor_indexing : ExtensionOperand<32>;
-defm SPV_KHR_8bit_storage : ExtensionOperand<33>;
-defm SPV_KHR_vulkan_memory_model : ExtensionOperand<34>;
-defm SPV_NV_ray_tracing : ExtensionOperand<35>;
-defm SPV_NV_compute_shader_derivatives : ExtensionOperand<36>;
-defm SPV_NV_fragment_shader_barycentric : ExtensionOperand<37>;
-defm SPV_NV_mesh_shader : ExtensionOperand<38>;
-defm SPV_NV_shader_image_footprint : ExtensionOperand<39>;
-defm SPV_NV_shading_rate : ExtensionOperand<40>;
-defm SPV_INTEL_subgroups : ExtensionOperand<41>;
-defm SPV_INTEL_media_block_io : ExtensionOperand<42>;
-defm SPV_EXT_fragment_invocation_density : ExtensionOperand<44>;
-defm SPV_KHR_no_integer_wrap_decoration : ExtensionOperand<45>;
-defm SPV_KHR_float_controls : ExtensionOperand<46>;
-defm SPV_EXT_physical_storage_buffer : ExtensionOperand<47>;
-defm SPV_INTEL_fpga_memory_attributes : ExtensionOperand<48>;
-defm SPV_NV_cooperative_matrix : ExtensionOperand<49>;
-defm SPV_INTEL_shader_integer_functions2 : ExtensionOperand<50>;
-defm SPV_INTEL_fpga_loop_controls : ExtensionOperand<51>;
-defm SPV_EXT_fragment_shader_interlock : ExtensionOperand<52>;
-defm SPV_NV_shader_sm_builtins : ExtensionOperand<53>;
-defm SPV_KHR_shader_clock : ExtensionOperand<54>;
-defm SPV_INTEL_unstructured_loop_controls : ExtensionOperand<55>;
-defm SPV_EXT_demote_to_helper_invocation : ExtensionOperand<56>;
-defm SPV_INTEL_fpga_reg : ExtensionOperand<57>;
-defm SPV_INTEL_blocking_pipes : ExtensionOperand<58>;
-defm SPV_GOOGLE_user_type : ExtensionOperand<59>;
-defm SPV_KHR_physical_storage_buffer : ExtensionOperand<60>;
-defm SPV_INTEL_kernel_attributes : ExtensionOperand<61>;
-defm SPV_KHR_non_semantic_info : ExtensionOperand<62>;
-defm SPV_INTEL_io_pipes : ExtensionOperand<63>;
-defm SPV_KHR_ray_tracing : ExtensionOperand<64>;
-defm SPV_KHR_ray_query : ExtensionOperand<65>;
-defm SPV_INTEL_fpga_memory_accesses : ExtensionOperand<66>;
-defm SPV_INTEL_arbitrary_precision_integers : ExtensionOperand<67>;
-defm SPV_EXT_shader_atomic_float_add : ExtensionOperand<68>;
-defm SPV_KHR_terminate_invocation : ExtensionOperand<69>;
-defm SPV_KHR_fragment_shading_rate : ExtensionOperand<70>;
-defm SPV_EXT_shader_image_int64 : ExtensionOperand<71>;
-defm SPV_INTEL_fp_fast_math_mode : ExtensionOperand<72>;
-defm SPV_INTEL_fpga_cluster_attributes : ExtensionOperand<73>;
-defm SPV_INTEL_loop_fuse : ExtensionOperand<74>;
-defm SPV_EXT_shader_atomic_float_min_max : ExtensionOperand<75>;
-defm SPV_KHR_workgroup_memory_explicit_layout : ExtensionOperand<76>;
-defm SPV_KHR_linkonce_odr : ExtensionOperand<77>;
-defm SPV_KHR_expect_assume : ExtensionOperand<78>;
-defm SPV_INTEL_fpga_dsp_control : ExtensionOperand<79>;
-defm SPV_NV_bindless_texture : ExtensionOperand<80>;
-defm SPV_INTEL_fpga_invocation_pipelining_attributes : ExtensionOperand<81>;
-defm SPV_KHR_subgroup_uniform_control_flow : ExtensionOperand<82>;
-defm SPV_HUAWEI_subpass_shading : ExtensionOperand<83>;
-defm SPV_KHR_integer_dot_product : ExtensionOperand<84>;
-defm SPV_EXT_shader_atomic_float16_add : ExtensionOperand<85>;
-defm SPV_INTEL_runtime_aligned : ExtensionOperand<86>;
-defm SPV_KHR_bit_instructions : ExtensionOperand<87>;
-defm SPV_NV_ray_tracing_motion_blur : ExtensionOperand<88>;
-defm SPV_KHR_uniform_group_instructions : ExtensionOperand<89>;
-defm SPV_KHR_subgroup_rotate : ExtensionOperand<90>;
-defm SPV_INTEL_split_barrier : ExtensionOperand<91>;
-defm SPV_KHR_ray_cull_mask : ExtensionOperand<92>;
-defm SPV_KHR_fragment_shader_barycentric : ExtensionOperand<93>;
-defm SPV_EXT_relaxed_printf_string_address_space : ExtensionOperand<94>;
-defm SPV_EXT_ycbcr_attachments : ExtensionOperand<95>;
-defm SPV_EXT_mesh_shader : ExtensionOperand<96>;
-defm SPV_ARM_core_builtins : ExtensionOperand<97>;
-defm SPV_EXT_opacity_micromap : ExtensionOperand<98>;
-defm SPV_NV_shader_invocation_reorder : ExtensionOperand<99>;
-defm SPV_INTEL_usm_storage_classes : ExtensionOperand<100>;
-defm SPV_INTEL_fpga_latency_control : ExtensionOperand<101>;
-defm SPV_INTEL_fpga_argument_interfaces : ExtensionOperand<102>;
-defm SPV_INTEL_optnone : ExtensionOperand<103>;
-defm SPV_INTEL_function_pointers : ExtensionOperand<104>;
-defm SPV_INTEL_variable_length_array : ExtensionOperand<105>;
-defm SPV_INTEL_bfloat16_conversion : ExtensionOperand<106>;
-defm SPV_INTEL_inline_assembly : ExtensionOperand<107>;
-defm SPV_INTEL_cache_controls : ExtensionOperand<108>;
-defm SPV_INTEL_global_variable_host_access : ExtensionOperand<109>;
-defm SPV_INTEL_global_variable_fpga_decorations : ExtensionOperand<110>;
-defm SPV_KHR_cooperative_matrix : ExtensionOperand<111>;
-defm SPV_EXT_arithmetic_fence : ExtensionOperand<112>;
-defm SPV_EXT_optnone : ExtensionOperand<113>;
-defm SPV_INTEL_joint_matrix : ExtensionOperand<114>;
-defm SPV_INTEL_float_controls2 : ExtensionOperand<115>;
-defm SPV_INTEL_bindless_images : ExtensionOperand<116>;
-defm SPV_INTEL_long_composites : ExtensionOperand<117>;
-defm SPV_INTEL_memory_access_aliasing : ExtensionOperand<118>;
-defm SPV_INTEL_fp_max_error : ExtensionOperand<119>;
-defm SPV_INTEL_ternary_bitwise_function : ExtensionOperand<120>;
-defm SPV_INTEL_subgroup_matrix_multiply_accumulate : ExtensionOperand<121>;
-defm SPV_INTEL_2d_block_io : ExtensionOperand<122>;
-defm SPV_INTEL_int4 : ExtensionOperand<123>;
-defm SPV_KHR_float_controls2 : ExtensionOperand<124>;
+  defm : SymbolicOperandWithRequirements<ExtensionOperand, value, NAME, 0, 0, [], reqCapabilities>;
+}
+
+defm SPV_AMD_shader_explicit_vertex_parameter : ExtensionOperand<1, []>;
+defm SPV_AMD_shader_trinary_minmax_extension : ExtensionOperand<2, []>;
+defm SPV_AMD_gcn_shader : ExtensionOperand<3, []>;
+defm SPV_KHR_shader_ballot : ExtensionOperand<4, []>;
+defm SPV_AMD_shader_ballot : ExtensionOperand<5, []>;
+defm SPV_AMD_gpu_shader_half_float : ExtensionOperand<6, []>;
+defm SPV_KHR_shader_draw_parameters : ExtensionOperand<7, []>;
+defm SPV_KHR_subgroup_vote : ExtensionOperand<8, []>;
+defm SPV_KHR_16bit_storage : ExtensionOperand<9, []>;
+defm SPV_KHR_device_group : ExtensionOperand<10, []>;
+defm SPV_KHR_multiview : ExtensionOperand<11, []>;
+defm SPV_NVX_multiview_per_view_attributes : ExtensionOperand<12, []>;
+defm SPV_NV_viewport_array2 : ExtensionOperand<13, []>;
+defm SPV_NV_stereo_view_rendering : ExtensionOperand<14, []>;
+defm SPV_NV_sample_mask_override_coverage : ExtensionOperand<15, []>;
+defm SPV_NV_geometry_shader_passthrough : ExtensionOperand<16, []>;
+defm SPV_AMD_texture_gather_bias_lod : ExtensionOperand<17, []>;
+defm SPV_KHR_storage_buffer_storage_class : ExtensionOperand<18, []>;
+defm SPV_KHR_variable_pointers : ExtensionOperand<19, []>;
+defm SPV_AMD_gpu_shader_int16 : ExtensionOperand<20, []>;
+defm SPV_KHR_post_depth_coverage : ExtensionOperand<21, []>;
+defm SPV_KHR_shader_atomic_counter_ops : ExtensionOperand<22, []>;
+defm SPV_EXT_shader_stencil_export : ExtensionOperand<23, []>;
+defm SPV_EXT_shader_viewport_index_layer : ExtensionOperand<24, []>;
+defm SPV_AMD_shader_image_load_store_lod : ExtensionOperand<25, []>;
+defm SPV_AMD_shader_fragment_mask : ExtensionOperand<26, []>;
+defm SPV_EXT_fragment_fully_covered : ExtensionOperand<27, []>;
+defm SPV_AMD_gpu_shader_half_float_fetch : ExtensionOperand<28, []>;
+defm SPV_GOOGLE_decorate_string : ExtensionOperand<29, []>;
+defm SPV_GOOGLE_hlsl_functionality1 : ExtensionOperand<30, []>;
+defm SPV_NV_shader_subgroup_partitioned : ExtensionOperand<31, []>;
+defm SPV_EXT_descriptor_indexing : ExtensionOperand<32, []>;
+defm SPV_KHR_8bit_storage : ExtensionOperand<33, []>;
+defm SPV_KHR_vulkan_memory_model : ExtensionOperand<34, []>;
+defm SPV_NV_ray_tracing : ExtensionOperand<35, []>;
+defm SPV_NV_compute_shader_derivatives : ExtensionOperand<36, []>;
+defm SPV_NV_fragment_shader_barycentric : ExtensionOperand<37, []>;
+defm SPV_NV_mesh_shader : ExtensionOperand<38, []>;
+defm SPV_NV_shader_image_footprint : ExtensionOperand<39, []>;
+defm SPV_NV_shading_rate : ExtensionOperand<40, []>;
+defm SPV_INTEL_subgroups : ExtensionOperand<41, []>;
+defm SPV_INTEL_media_block_io : ExtensionOperand<42, []>;
+defm SPV_EXT_fragment_invocation_density : ExtensionOperand<44, []>;
+defm SPV_KHR_no_integer_wrap_decoration : ExtensionOperand<45, []>;
+defm SPV_KHR_float_controls : ExtensionOperand<46, []>;
+defm SPV_EXT_physical_storage_buffer : ExtensionOperand<47, []>;
+defm SPV_INTEL_fpga_memory_attributes : ExtensionOperand<48, []>;
+defm SPV_NV_cooperative_matrix : ExtensionOperand<49, []>;
+defm SPV_INTEL_shader_integer_functions2 : ExtensionOperand<50, []>;
+defm SPV_INTEL_fpga_loop_controls : ExtensionOperand<51, []>;
+defm SPV_EXT_fragment_shader_interlock : ExtensionOperand<52, []>;
+defm SPV_NV_shader_sm_builtins : ExtensionOperand<53, []>;
+defm SPV_KHR_shader_clock : ExtensionOperand<54, []>;
+defm SPV_INTEL_unstructured_loop_controls : ExtensionOperand<55, []>;
+defm SPV_EXT_demote_to_helper_invocation : ExtensionOperand<56, []>;
+defm SPV_INTEL_fpga_reg : ExtensionOperand<57, []>;
+defm SPV_INTEL_blocking_pipes : ExtensionOperand<58, []>;
+defm SPV_GOOGLE_user_type : ExtensionOperand<59, []>;
+defm SPV_KHR_physical_storage_buffer : ExtensionOperand<60, []>;
+defm SPV_INTEL_kernel_attributes : ExtensionOperand<61, []>;
+defm SPV_KHR_non_semantic_info : ExtensionOperand<62, []>;
+defm SPV_INTEL_io_pipes : ExtensionOperand<63, []>;
+defm SPV_KHR_ray_tracing : ExtensionOperand<64, []>;
+defm SPV_KHR_ray_query : ExtensionOperand<65, []>;
+defm SPV_INTEL_fpga_memory_accesses : ExtensionOperand<66, []>;
+defm SPV_INTEL_arbitrary_precision_integers : ExtensionOperand<67, []>;
+defm SPV_EXT_shader_atomic_float_add : ExtensionOperand<68, []>;
+defm SPV_KHR_terminate_invocation : ExtensionOperand<69, []>;
+defm SPV_KHR_fragment_shading_rate : ExtensionOperand<70, []>;
+defm SPV_EXT_shader_image_int64 : ExtensionOperand<71, []>;
+defm SPV_INTEL_fp_fast_math_mode : ExtensionOperand<72, []>;
+defm SPV_INTEL_fpga_cluster_attributes : ExtensionOperand<73, []>;
+defm SPV_INTEL_loop_fuse : ExtensionOperand<74, []>;
+defm SPV_EXT_shader_atomic_float_min_max : ExtensionOperand<75, []>;
+defm SPV_KHR_workgroup_memory_explicit_layout : ExtensionOperand<76, []>;
+defm SPV_KHR_linkonce_odr : ExtensionOperand<77, []>;
+defm SPV_KHR_expect_assume : ExtensionOperand<78, []>;
+defm SPV_INTEL_fpga_dsp_control : ExtensionOperand<79, []>;
+defm SPV_NV_bindless_texture : ExtensionOperand<80, []>;
+defm SPV_INTEL_fpga_invocation_pipelining_attributes : ExtensionOperand<81, []>;
+defm SPV_KHR_subgroup_uniform_control_flow : ExtensionOperand<82, []>;
+defm SPV_HUAWEI_subpass_shading : ExtensionOperand<83, []>;
+defm SPV_KHR_integer_dot_product : ExtensionOperand<84, []>;
+defm SPV_EXT_shader_atomic_float16_add : ExtensionOperand<85, []>;
+defm SPV_INTEL_runtime_aligned : ExtensionOperand<86, []>;
+defm SPV_KHR_bit_instructions : ExtensionOperand<87, []>;
+defm SPV_NV_ray_tracing_motion_blur : ExtensionOperand<88, []>;
+defm SPV_KHR_uniform_group_instructions : ExtensionOperand<89, []>;
+defm SPV_KHR_subgroup_rotate : ExtensionOperand<90, []>;
+defm SPV_INTEL_split_barrier : ExtensionOperand<91, []>;
+defm SPV_KHR_ray_cull_mask : ExtensionOperand<92, []>;
+defm SPV_KHR_fragment_shader_barycentric : ExtensionOperand<93, []>;
+defm SPV_EXT_relaxed_printf_string_address_space : ExtensionOperand<94, []>;
+defm SPV_EXT_ycbcr_attachments : ExtensionOperand<95, []>;
+defm SPV_EXT_mesh_shader : ExtensionOperand<96, []>;
+defm SPV_ARM_core_builtins : ExtensionOperand<97, []>;
+defm SPV_EXT_opacity_micromap : ExtensionOperand<98, []>;
+defm SPV_NV_shader_invocation_reorder : ExtensionOperand<99, []>;
+defm SPV_INTEL_usm_storage_classes : ExtensionOperand<100, []>;
+defm SPV_INTEL_fpga_latency_control : ExtensionOperand<101, []>;
+defm SPV_INTEL_fpga_argument_interfaces : ExtensionOperand<102, []>;
+defm SPV_INTEL_optnone : ExtensionOperand<103, []>;
+defm SPV_INTEL_function_pointers : ExtensionOperand<104, []>;
+defm SPV_INTEL_variable_length_array : ExtensionOperand<105, []>;
+defm SPV_INTEL_bfloat16_conversion : ExtensionOperand<106, []>;
+defm SPV_INTEL_inline_assembly : ExtensionOperand<107, []>;
+defm SPV_INTEL_cache_controls : ExtensionOperand<108, []>;
+defm SPV_INTEL_global_variable_host_access : ExtensionOperand<109, []>;
+defm SPV_INTEL_global_variable_fpga_decorations : ExtensionOperand<110, []>;
+defm SPV_KHR_cooperative_matrix : ExtensionOperand<111, []>;
+defm SPV_EXT_arithmetic_fence : ExtensionOperand<112, []>;
+defm SPV_EXT_optnone : ExtensionOperand<113, []>;
+defm SPV_INTEL_joint_matrix : ExtensionOperand<114, []>;
+defm SPV_INTEL_float_controls2 : ExtensionOperand<115, []>;
+defm SPV_INTEL_bindless_images : ExtensionOperand<116, []>;
+defm SPV_INTEL_long_composites : ExtensionOperand<117, []>;
+defm SPV_INTEL_memory_access_aliasing : ExtensionOperand<118, []>;
+defm SPV_INTEL_fp_max_error : ExtensionOperand<119, []>;
+defm SPV_INTEL_ternary_bitwise_function : ExtensionOperand<120, []>;
+defm SPV_INTEL_subgroup_matrix_multiply_accumulate : ExtensionOperand<121, []>;
+defm SPV_INTEL_2d_block_io : ExtensionOperand<122, []>;
+defm SPV_INTEL_int4 : ExtensionOperand<123, []>;
+defm SPV_KHR_float_controls2 : ExtensionOperand<124, []>;
 
 //===----------------------------------------------------------------------===//
 // Multiclass used to define Capabilities enum values and at the same time

>From e8ed6e21b5fd7e2ba48e5ddeeae6f95691e39f66 Mon Sep 17 00:00:00 2001
From: Steven Perron <stevenperron at google.com>
Date: Thu, 24 Jul 2025 14:23:35 -0400
Subject: [PATCH 4/8] Revert "Change symbolic operands."

This reverts commit 25aa10b3a3ee45cad675ab80e619e7f7a4d06ebb.
---
 .../lib/Target/SPIRV/SPIRVSymbolicOperands.td | 256 +++++++++---------
 1 file changed, 127 insertions(+), 129 deletions(-)

diff --git a/llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td b/llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td
index dd9531c37a5ec..548e9b717c161 100644
--- a/llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td
+++ b/llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td
@@ -187,141 +187,139 @@ def Extension : GenericEnum, Operand<i32> {
   let PrintMethod = "printExtension";
 }
 
-class Capability;
-
 class Extension<string name, bits<32> value> {
   string Name = name;
   bits<32> Value = value;
 }
 
-multiclass ExtensionOperand<bits<32> value, list<Capability> reqCapabilities> {
+multiclass ExtensionOperand<bits<32> value> {
   def NAME : Extension<NAME, value>;
-  defm : SymbolicOperandWithRequirements<ExtensionOperand, value, NAME, 0, 0, [], reqCapabilities>;
-}
-
-defm SPV_AMD_shader_explicit_vertex_parameter : ExtensionOperand<1, []>;
-defm SPV_AMD_shader_trinary_minmax_extension : ExtensionOperand<2, []>;
-defm SPV_AMD_gcn_shader : ExtensionOperand<3, []>;
-defm SPV_KHR_shader_ballot : ExtensionOperand<4, []>;
-defm SPV_AMD_shader_ballot : ExtensionOperand<5, []>;
-defm SPV_AMD_gpu_shader_half_float : ExtensionOperand<6, []>;
-defm SPV_KHR_shader_draw_parameters : ExtensionOperand<7, []>;
-defm SPV_KHR_subgroup_vote : ExtensionOperand<8, []>;
-defm SPV_KHR_16bit_storage : ExtensionOperand<9, []>;
-defm SPV_KHR_device_group : ExtensionOperand<10, []>;
-defm SPV_KHR_multiview : ExtensionOperand<11, []>;
-defm SPV_NVX_multiview_per_view_attributes : ExtensionOperand<12, []>;
-defm SPV_NV_viewport_array2 : ExtensionOperand<13, []>;
-defm SPV_NV_stereo_view_rendering : ExtensionOperand<14, []>;
-defm SPV_NV_sample_mask_override_coverage : ExtensionOperand<15, []>;
-defm SPV_NV_geometry_shader_passthrough : ExtensionOperand<16, []>;
-defm SPV_AMD_texture_gather_bias_lod : ExtensionOperand<17, []>;
-defm SPV_KHR_storage_buffer_storage_class : ExtensionOperand<18, []>;
-defm SPV_KHR_variable_pointers : ExtensionOperand<19, []>;
-defm SPV_AMD_gpu_shader_int16 : ExtensionOperand<20, []>;
-defm SPV_KHR_post_depth_coverage : ExtensionOperand<21, []>;
-defm SPV_KHR_shader_atomic_counter_ops : ExtensionOperand<22, []>;
-defm SPV_EXT_shader_stencil_export : ExtensionOperand<23, []>;
-defm SPV_EXT_shader_viewport_index_layer : ExtensionOperand<24, []>;
-defm SPV_AMD_shader_image_load_store_lod : ExtensionOperand<25, []>;
-defm SPV_AMD_shader_fragment_mask : ExtensionOperand<26, []>;
-defm SPV_EXT_fragment_fully_covered : ExtensionOperand<27, []>;
-defm SPV_AMD_gpu_shader_half_float_fetch : ExtensionOperand<28, []>;
-defm SPV_GOOGLE_decorate_string : ExtensionOperand<29, []>;
-defm SPV_GOOGLE_hlsl_functionality1 : ExtensionOperand<30, []>;
-defm SPV_NV_shader_subgroup_partitioned : ExtensionOperand<31, []>;
-defm SPV_EXT_descriptor_indexing : ExtensionOperand<32, []>;
-defm SPV_KHR_8bit_storage : ExtensionOperand<33, []>;
-defm SPV_KHR_vulkan_memory_model : ExtensionOperand<34, []>;
-defm SPV_NV_ray_tracing : ExtensionOperand<35, []>;
-defm SPV_NV_compute_shader_derivatives : ExtensionOperand<36, []>;
-defm SPV_NV_fragment_shader_barycentric : ExtensionOperand<37, []>;
-defm SPV_NV_mesh_shader : ExtensionOperand<38, []>;
-defm SPV_NV_shader_image_footprint : ExtensionOperand<39, []>;
-defm SPV_NV_shading_rate : ExtensionOperand<40, []>;
-defm SPV_INTEL_subgroups : ExtensionOperand<41, []>;
-defm SPV_INTEL_media_block_io : ExtensionOperand<42, []>;
-defm SPV_EXT_fragment_invocation_density : ExtensionOperand<44, []>;
-defm SPV_KHR_no_integer_wrap_decoration : ExtensionOperand<45, []>;
-defm SPV_KHR_float_controls : ExtensionOperand<46, []>;
-defm SPV_EXT_physical_storage_buffer : ExtensionOperand<47, []>;
-defm SPV_INTEL_fpga_memory_attributes : ExtensionOperand<48, []>;
-defm SPV_NV_cooperative_matrix : ExtensionOperand<49, []>;
-defm SPV_INTEL_shader_integer_functions2 : ExtensionOperand<50, []>;
-defm SPV_INTEL_fpga_loop_controls : ExtensionOperand<51, []>;
-defm SPV_EXT_fragment_shader_interlock : ExtensionOperand<52, []>;
-defm SPV_NV_shader_sm_builtins : ExtensionOperand<53, []>;
-defm SPV_KHR_shader_clock : ExtensionOperand<54, []>;
-defm SPV_INTEL_unstructured_loop_controls : ExtensionOperand<55, []>;
-defm SPV_EXT_demote_to_helper_invocation : ExtensionOperand<56, []>;
-defm SPV_INTEL_fpga_reg : ExtensionOperand<57, []>;
-defm SPV_INTEL_blocking_pipes : ExtensionOperand<58, []>;
-defm SPV_GOOGLE_user_type : ExtensionOperand<59, []>;
-defm SPV_KHR_physical_storage_buffer : ExtensionOperand<60, []>;
-defm SPV_INTEL_kernel_attributes : ExtensionOperand<61, []>;
-defm SPV_KHR_non_semantic_info : ExtensionOperand<62, []>;
-defm SPV_INTEL_io_pipes : ExtensionOperand<63, []>;
-defm SPV_KHR_ray_tracing : ExtensionOperand<64, []>;
-defm SPV_KHR_ray_query : ExtensionOperand<65, []>;
-defm SPV_INTEL_fpga_memory_accesses : ExtensionOperand<66, []>;
-defm SPV_INTEL_arbitrary_precision_integers : ExtensionOperand<67, []>;
-defm SPV_EXT_shader_atomic_float_add : ExtensionOperand<68, []>;
-defm SPV_KHR_terminate_invocation : ExtensionOperand<69, []>;
-defm SPV_KHR_fragment_shading_rate : ExtensionOperand<70, []>;
-defm SPV_EXT_shader_image_int64 : ExtensionOperand<71, []>;
-defm SPV_INTEL_fp_fast_math_mode : ExtensionOperand<72, []>;
-defm SPV_INTEL_fpga_cluster_attributes : ExtensionOperand<73, []>;
-defm SPV_INTEL_loop_fuse : ExtensionOperand<74, []>;
-defm SPV_EXT_shader_atomic_float_min_max : ExtensionOperand<75, []>;
-defm SPV_KHR_workgroup_memory_explicit_layout : ExtensionOperand<76, []>;
-defm SPV_KHR_linkonce_odr : ExtensionOperand<77, []>;
-defm SPV_KHR_expect_assume : ExtensionOperand<78, []>;
-defm SPV_INTEL_fpga_dsp_control : ExtensionOperand<79, []>;
-defm SPV_NV_bindless_texture : ExtensionOperand<80, []>;
-defm SPV_INTEL_fpga_invocation_pipelining_attributes : ExtensionOperand<81, []>;
-defm SPV_KHR_subgroup_uniform_control_flow : ExtensionOperand<82, []>;
-defm SPV_HUAWEI_subpass_shading : ExtensionOperand<83, []>;
-defm SPV_KHR_integer_dot_product : ExtensionOperand<84, []>;
-defm SPV_EXT_shader_atomic_float16_add : ExtensionOperand<85, []>;
-defm SPV_INTEL_runtime_aligned : ExtensionOperand<86, []>;
-defm SPV_KHR_bit_instructions : ExtensionOperand<87, []>;
-defm SPV_NV_ray_tracing_motion_blur : ExtensionOperand<88, []>;
-defm SPV_KHR_uniform_group_instructions : ExtensionOperand<89, []>;
-defm SPV_KHR_subgroup_rotate : ExtensionOperand<90, []>;
-defm SPV_INTEL_split_barrier : ExtensionOperand<91, []>;
-defm SPV_KHR_ray_cull_mask : ExtensionOperand<92, []>;
-defm SPV_KHR_fragment_shader_barycentric : ExtensionOperand<93, []>;
-defm SPV_EXT_relaxed_printf_string_address_space : ExtensionOperand<94, []>;
-defm SPV_EXT_ycbcr_attachments : ExtensionOperand<95, []>;
-defm SPV_EXT_mesh_shader : ExtensionOperand<96, []>;
-defm SPV_ARM_core_builtins : ExtensionOperand<97, []>;
-defm SPV_EXT_opacity_micromap : ExtensionOperand<98, []>;
-defm SPV_NV_shader_invocation_reorder : ExtensionOperand<99, []>;
-defm SPV_INTEL_usm_storage_classes : ExtensionOperand<100, []>;
-defm SPV_INTEL_fpga_latency_control : ExtensionOperand<101, []>;
-defm SPV_INTEL_fpga_argument_interfaces : ExtensionOperand<102, []>;
-defm SPV_INTEL_optnone : ExtensionOperand<103, []>;
-defm SPV_INTEL_function_pointers : ExtensionOperand<104, []>;
-defm SPV_INTEL_variable_length_array : ExtensionOperand<105, []>;
-defm SPV_INTEL_bfloat16_conversion : ExtensionOperand<106, []>;
-defm SPV_INTEL_inline_assembly : ExtensionOperand<107, []>;
-defm SPV_INTEL_cache_controls : ExtensionOperand<108, []>;
-defm SPV_INTEL_global_variable_host_access : ExtensionOperand<109, []>;
-defm SPV_INTEL_global_variable_fpga_decorations : ExtensionOperand<110, []>;
-defm SPV_KHR_cooperative_matrix : ExtensionOperand<111, []>;
-defm SPV_EXT_arithmetic_fence : ExtensionOperand<112, []>;
-defm SPV_EXT_optnone : ExtensionOperand<113, []>;
-defm SPV_INTEL_joint_matrix : ExtensionOperand<114, []>;
-defm SPV_INTEL_float_controls2 : ExtensionOperand<115, []>;
-defm SPV_INTEL_bindless_images : ExtensionOperand<116, []>;
-defm SPV_INTEL_long_composites : ExtensionOperand<117, []>;
-defm SPV_INTEL_memory_access_aliasing : ExtensionOperand<118, []>;
-defm SPV_INTEL_fp_max_error : ExtensionOperand<119, []>;
-defm SPV_INTEL_ternary_bitwise_function : ExtensionOperand<120, []>;
-defm SPV_INTEL_subgroup_matrix_multiply_accumulate : ExtensionOperand<121, []>;
-defm SPV_INTEL_2d_block_io : ExtensionOperand<122, []>;
-defm SPV_INTEL_int4 : ExtensionOperand<123, []>;
-defm SPV_KHR_float_controls2 : ExtensionOperand<124, []>;
+  defm : SymbolicOperandWithRequirements<ExtensionOperand, value, NAME, 0, 0, [], []>;
+}
+
+defm SPV_AMD_shader_explicit_vertex_parameter : ExtensionOperand<1>;
+defm SPV_AMD_shader_trinary_minmax_extension : ExtensionOperand<2>;
+defm SPV_AMD_gcn_shader : ExtensionOperand<3>;
+defm SPV_KHR_shader_ballot : ExtensionOperand<4>;
+defm SPV_AMD_shader_ballot : ExtensionOperand<5>;
+defm SPV_AMD_gpu_shader_half_float : ExtensionOperand<6>;
+defm SPV_KHR_shader_draw_parameters : ExtensionOperand<7>;
+defm SPV_KHR_subgroup_vote : ExtensionOperand<8>;
+defm SPV_KHR_16bit_storage : ExtensionOperand<9>;
+defm SPV_KHR_device_group : ExtensionOperand<10>;
+defm SPV_KHR_multiview : ExtensionOperand<11>;
+defm SPV_NVX_multiview_per_view_attributes : ExtensionOperand<12>;
+defm SPV_NV_viewport_array2 : ExtensionOperand<13>;
+defm SPV_NV_stereo_view_rendering : ExtensionOperand<14>;
+defm SPV_NV_sample_mask_override_coverage : ExtensionOperand<15>;
+defm SPV_NV_geometry_shader_passthrough : ExtensionOperand<16>;
+defm SPV_AMD_texture_gather_bias_lod : ExtensionOperand<17>;
+defm SPV_KHR_storage_buffer_storage_class : ExtensionOperand<18>;
+defm SPV_KHR_variable_pointers : ExtensionOperand<19>;
+defm SPV_AMD_gpu_shader_int16 : ExtensionOperand<20>;
+defm SPV_KHR_post_depth_coverage : ExtensionOperand<21>;
+defm SPV_KHR_shader_atomic_counter_ops : ExtensionOperand<22>;
+defm SPV_EXT_shader_stencil_export : ExtensionOperand<23>;
+defm SPV_EXT_shader_viewport_index_layer : ExtensionOperand<24>;
+defm SPV_AMD_shader_image_load_store_lod : ExtensionOperand<25>;
+defm SPV_AMD_shader_fragment_mask : ExtensionOperand<26>;
+defm SPV_EXT_fragment_fully_covered : ExtensionOperand<27>;
+defm SPV_AMD_gpu_shader_half_float_fetch : ExtensionOperand<28>;
+defm SPV_GOOGLE_decorate_string : ExtensionOperand<29>;
+defm SPV_GOOGLE_hlsl_functionality1 : ExtensionOperand<30>;
+defm SPV_NV_shader_subgroup_partitioned : ExtensionOperand<31>;
+defm SPV_EXT_descriptor_indexing : ExtensionOperand<32>;
+defm SPV_KHR_8bit_storage : ExtensionOperand<33>;
+defm SPV_KHR_vulkan_memory_model : ExtensionOperand<34>;
+defm SPV_NV_ray_tracing : ExtensionOperand<35>;
+defm SPV_NV_compute_shader_derivatives : ExtensionOperand<36>;
+defm SPV_NV_fragment_shader_barycentric : ExtensionOperand<37>;
+defm SPV_NV_mesh_shader : ExtensionOperand<38>;
+defm SPV_NV_shader_image_footprint : ExtensionOperand<39>;
+defm SPV_NV_shading_rate : ExtensionOperand<40>;
+defm SPV_INTEL_subgroups : ExtensionOperand<41>;
+defm SPV_INTEL_media_block_io : ExtensionOperand<42>;
+defm SPV_EXT_fragment_invocation_density : ExtensionOperand<44>;
+defm SPV_KHR_no_integer_wrap_decoration : ExtensionOperand<45>;
+defm SPV_KHR_float_controls : ExtensionOperand<46>;
+defm SPV_EXT_physical_storage_buffer : ExtensionOperand<47>;
+defm SPV_INTEL_fpga_memory_attributes : ExtensionOperand<48>;
+defm SPV_NV_cooperative_matrix : ExtensionOperand<49>;
+defm SPV_INTEL_shader_integer_functions2 : ExtensionOperand<50>;
+defm SPV_INTEL_fpga_loop_controls : ExtensionOperand<51>;
+defm SPV_EXT_fragment_shader_interlock : ExtensionOperand<52>;
+defm SPV_NV_shader_sm_builtins : ExtensionOperand<53>;
+defm SPV_KHR_shader_clock : ExtensionOperand<54>;
+defm SPV_INTEL_unstructured_loop_controls : ExtensionOperand<55>;
+defm SPV_EXT_demote_to_helper_invocation : ExtensionOperand<56>;
+defm SPV_INTEL_fpga_reg : ExtensionOperand<57>;
+defm SPV_INTEL_blocking_pipes : ExtensionOperand<58>;
+defm SPV_GOOGLE_user_type : ExtensionOperand<59>;
+defm SPV_KHR_physical_storage_buffer : ExtensionOperand<60>;
+defm SPV_INTEL_kernel_attributes : ExtensionOperand<61>;
+defm SPV_KHR_non_semantic_info : ExtensionOperand<62>;
+defm SPV_INTEL_io_pipes : ExtensionOperand<63>;
+defm SPV_KHR_ray_tracing : ExtensionOperand<64>;
+defm SPV_KHR_ray_query : ExtensionOperand<65>;
+defm SPV_INTEL_fpga_memory_accesses : ExtensionOperand<66>;
+defm SPV_INTEL_arbitrary_precision_integers : ExtensionOperand<67>;
+defm SPV_EXT_shader_atomic_float_add : ExtensionOperand<68>;
+defm SPV_KHR_terminate_invocation : ExtensionOperand<69>;
+defm SPV_KHR_fragment_shading_rate : ExtensionOperand<70>;
+defm SPV_EXT_shader_image_int64 : ExtensionOperand<71>;
+defm SPV_INTEL_fp_fast_math_mode : ExtensionOperand<72>;
+defm SPV_INTEL_fpga_cluster_attributes : ExtensionOperand<73>;
+defm SPV_INTEL_loop_fuse : ExtensionOperand<74>;
+defm SPV_EXT_shader_atomic_float_min_max : ExtensionOperand<75>;
+defm SPV_KHR_workgroup_memory_explicit_layout : ExtensionOperand<76>;
+defm SPV_KHR_linkonce_odr : ExtensionOperand<77>;
+defm SPV_KHR_expect_assume : ExtensionOperand<78>;
+defm SPV_INTEL_fpga_dsp_control : ExtensionOperand<79>;
+defm SPV_NV_bindless_texture : ExtensionOperand<80>;
+defm SPV_INTEL_fpga_invocation_pipelining_attributes : ExtensionOperand<81>;
+defm SPV_KHR_subgroup_uniform_control_flow : ExtensionOperand<82>;
+defm SPV_HUAWEI_subpass_shading : ExtensionOperand<83>;
+defm SPV_KHR_integer_dot_product : ExtensionOperand<84>;
+defm SPV_EXT_shader_atomic_float16_add : ExtensionOperand<85>;
+defm SPV_INTEL_runtime_aligned : ExtensionOperand<86>;
+defm SPV_KHR_bit_instructions : ExtensionOperand<87>;
+defm SPV_NV_ray_tracing_motion_blur : ExtensionOperand<88>;
+defm SPV_KHR_uniform_group_instructions : ExtensionOperand<89>;
+defm SPV_KHR_subgroup_rotate : ExtensionOperand<90>;
+defm SPV_INTEL_split_barrier : ExtensionOperand<91>;
+defm SPV_KHR_ray_cull_mask : ExtensionOperand<92>;
+defm SPV_KHR_fragment_shader_barycentric : ExtensionOperand<93>;
+defm SPV_EXT_relaxed_printf_string_address_space : ExtensionOperand<94>;
+defm SPV_EXT_ycbcr_attachments : ExtensionOperand<95>;
+defm SPV_EXT_mesh_shader : ExtensionOperand<96>;
+defm SPV_ARM_core_builtins : ExtensionOperand<97>;
+defm SPV_EXT_opacity_micromap : ExtensionOperand<98>;
+defm SPV_NV_shader_invocation_reorder : ExtensionOperand<99>;
+defm SPV_INTEL_usm_storage_classes : ExtensionOperand<100>;
+defm SPV_INTEL_fpga_latency_control : ExtensionOperand<101>;
+defm SPV_INTEL_fpga_argument_interfaces : ExtensionOperand<102>;
+defm SPV_INTEL_optnone : ExtensionOperand<103>;
+defm SPV_INTEL_function_pointers : ExtensionOperand<104>;
+defm SPV_INTEL_variable_length_array : ExtensionOperand<105>;
+defm SPV_INTEL_bfloat16_conversion : ExtensionOperand<106>;
+defm SPV_INTEL_inline_assembly : ExtensionOperand<107>;
+defm SPV_INTEL_cache_controls : ExtensionOperand<108>;
+defm SPV_INTEL_global_variable_host_access : ExtensionOperand<109>;
+defm SPV_INTEL_global_variable_fpga_decorations : ExtensionOperand<110>;
+defm SPV_KHR_cooperative_matrix : ExtensionOperand<111>;
+defm SPV_EXT_arithmetic_fence : ExtensionOperand<112>;
+defm SPV_EXT_optnone : ExtensionOperand<113>;
+defm SPV_INTEL_joint_matrix : ExtensionOperand<114>;
+defm SPV_INTEL_float_controls2 : ExtensionOperand<115>;
+defm SPV_INTEL_bindless_images : ExtensionOperand<116>;
+defm SPV_INTEL_long_composites : ExtensionOperand<117>;
+defm SPV_INTEL_memory_access_aliasing : ExtensionOperand<118>;
+defm SPV_INTEL_fp_max_error : ExtensionOperand<119>;
+defm SPV_INTEL_ternary_bitwise_function : ExtensionOperand<120>;
+defm SPV_INTEL_subgroup_matrix_multiply_accumulate : ExtensionOperand<121>;
+defm SPV_INTEL_2d_block_io : ExtensionOperand<122>;
+defm SPV_INTEL_int4 : ExtensionOperand<123>;
+defm SPV_KHR_float_controls2 : ExtensionOperand<124>;
 
 //===----------------------------------------------------------------------===//
 // Multiclass used to define Capabilities enum values and at the same time

>From 50ea4b6d5eacbf15f22af859fad3e7aebd1293eb Mon Sep 17 00:00:00 2001
From: Steven Perron <stevenperron at google.com>
Date: Thu, 24 Jul 2025 14:56:56 -0400
Subject: [PATCH 5/8] Add allowed env for extensions

---
 .../lib/Target/SPIRV/SPIRVSymbolicOperands.td | 372 ++++++++++--------
 1 file changed, 209 insertions(+), 163 deletions(-)

diff --git a/llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td b/llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td
index 548e9b717c161..8c3854ad923e4 100644
--- a/llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td
+++ b/llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td
@@ -109,12 +109,38 @@ def CapabilityEntries : GenericTable {
   let PrimaryKeyName = "lookupCapabilityByCategoryAndValue";
 }
 
+//===----------------------------------------------------------------------===//
+// Lookup table for matching symbolic operands (category + 32-bit value) to
+// SPIR-V environments. If an operand is allows in more than one environment,
+// there will be multiple consecutive entries present in the table.
+//===----------------------------------------------------------------------===//
+
+// Forward-declare classes used in ExtensionEntry
+class Environment;
+
+class EnvironmentEntry<OperandCategory category, bits<32> value, Environment allowedEnvironment> {
+  OperandCategory Category = category;
+  bits<32> Value = value;
+  Environment AllowedEnvironment = allowedEnvironment;
+}
+
+def EnvironmentEntries : GenericTable {
+  let FilterClass = "EnvironmentEntry";
+  let Fields = ["Category", "Value", "AllowedEnvironment"];
+  string TypeOf_Category = "OperandCategory";
+  string TypeOf_AllowedEnvironment = "Environment";
+  let PrimaryKey = ["Category", "Value"];
+  // Function for looking up a (the first) environment by category + value. Next
+  // environment should be consecutive.
+  let PrimaryKeyName = "lookupEnvironmentByCategoryAndValue";
+}
+
 //===----------------------------------------------------------------------===//
 // Multiclass used to define a SymbolicOperand and at the same time declare
 // required extension and capabilities.
 //===----------------------------------------------------------------------===//
 
-multiclass SymbolicOperandWithRequirements<OperandCategory category, bits<32> value, string mnemonic, bits<32> minVersion, bits<32> maxVersion, list<Extension> reqExtensions, list<Capability> reqCapabilities> {
+multiclass SymbolicOperandWithRequirements<OperandCategory category, bits<32> value, string mnemonic, bits<32> minVersion, bits<32> maxVersion, list<Extension> reqExtensions, list<Capability> reqCapabilities, list<Environment> allowedEnvironments> {
     assert !ge(!size(mnemonic), 1), "No mnemonic/string representation provided for symbolic operand with value " # value;
     def : SymbolicOperand<category, value, mnemonic, minVersion, maxVersion>;
 
@@ -126,6 +152,10 @@ multiclass SymbolicOperandWithRequirements<OperandCategory category, bits<32> va
     foreach capability = reqCapabilities in {
         def : CapabilityEntry<category, value, capability>;
     }
+
+    foreach environment = allowedEnvironments in {
+        def : EnvironmentEntry<category, value, environment>;
+    }
 }
 
 //===----------------------------------------------------------------------===//
@@ -175,6 +205,22 @@ def CooperativeMatrixOperandsOperand : OperandCategory;
 def SpecConstantOpOperandsOperand : OperandCategory;
 def MatrixMultiplyAccumulateOperandsOperand : OperandCategory;
 
+//===----------------------------------------------------------------------===//
+// Definition of the Environments
+//===----------------------------------------------------------------------===//
+
+def Environment : GenericEnum, Operand<i32> {
+  let FilterClass = "Environment";
+  let ValueField = "Value";
+}
+
+class Environment<bits<32> value> {
+  bits<32> Value = value;
+}
+
+def EnvOpenCL : Environment<0>;
+def EnvVulkan : Environment<1>;
+
 //===----------------------------------------------------------------------===//
 // Multiclass used to define Extesions enum values and at the same time
 // SymbolicOperand entries.
@@ -192,134 +238,134 @@ class Extension<string name, bits<32> value> {
   bits<32> Value = value;
 }
 
-multiclass ExtensionOperand<bits<32> value> {
+multiclass ExtensionOperand<bits<32> value, list<Environment> allowedEnvironments> {
   def NAME : Extension<NAME, value>;
-  defm : SymbolicOperandWithRequirements<ExtensionOperand, value, NAME, 0, 0, [], []>;
-}
-
-defm SPV_AMD_shader_explicit_vertex_parameter : ExtensionOperand<1>;
-defm SPV_AMD_shader_trinary_minmax_extension : ExtensionOperand<2>;
-defm SPV_AMD_gcn_shader : ExtensionOperand<3>;
-defm SPV_KHR_shader_ballot : ExtensionOperand<4>;
-defm SPV_AMD_shader_ballot : ExtensionOperand<5>;
-defm SPV_AMD_gpu_shader_half_float : ExtensionOperand<6>;
-defm SPV_KHR_shader_draw_parameters : ExtensionOperand<7>;
-defm SPV_KHR_subgroup_vote : ExtensionOperand<8>;
-defm SPV_KHR_16bit_storage : ExtensionOperand<9>;
-defm SPV_KHR_device_group : ExtensionOperand<10>;
-defm SPV_KHR_multiview : ExtensionOperand<11>;
-defm SPV_NVX_multiview_per_view_attributes : ExtensionOperand<12>;
-defm SPV_NV_viewport_array2 : ExtensionOperand<13>;
-defm SPV_NV_stereo_view_rendering : ExtensionOperand<14>;
-defm SPV_NV_sample_mask_override_coverage : ExtensionOperand<15>;
-defm SPV_NV_geometry_shader_passthrough : ExtensionOperand<16>;
-defm SPV_AMD_texture_gather_bias_lod : ExtensionOperand<17>;
-defm SPV_KHR_storage_buffer_storage_class : ExtensionOperand<18>;
-defm SPV_KHR_variable_pointers : ExtensionOperand<19>;
-defm SPV_AMD_gpu_shader_int16 : ExtensionOperand<20>;
-defm SPV_KHR_post_depth_coverage : ExtensionOperand<21>;
-defm SPV_KHR_shader_atomic_counter_ops : ExtensionOperand<22>;
-defm SPV_EXT_shader_stencil_export : ExtensionOperand<23>;
-defm SPV_EXT_shader_viewport_index_layer : ExtensionOperand<24>;
-defm SPV_AMD_shader_image_load_store_lod : ExtensionOperand<25>;
-defm SPV_AMD_shader_fragment_mask : ExtensionOperand<26>;
-defm SPV_EXT_fragment_fully_covered : ExtensionOperand<27>;
-defm SPV_AMD_gpu_shader_half_float_fetch : ExtensionOperand<28>;
-defm SPV_GOOGLE_decorate_string : ExtensionOperand<29>;
-defm SPV_GOOGLE_hlsl_functionality1 : ExtensionOperand<30>;
-defm SPV_NV_shader_subgroup_partitioned : ExtensionOperand<31>;
-defm SPV_EXT_descriptor_indexing : ExtensionOperand<32>;
-defm SPV_KHR_8bit_storage : ExtensionOperand<33>;
-defm SPV_KHR_vulkan_memory_model : ExtensionOperand<34>;
-defm SPV_NV_ray_tracing : ExtensionOperand<35>;
-defm SPV_NV_compute_shader_derivatives : ExtensionOperand<36>;
-defm SPV_NV_fragment_shader_barycentric : ExtensionOperand<37>;
-defm SPV_NV_mesh_shader : ExtensionOperand<38>;
-defm SPV_NV_shader_image_footprint : ExtensionOperand<39>;
-defm SPV_NV_shading_rate : ExtensionOperand<40>;
-defm SPV_INTEL_subgroups : ExtensionOperand<41>;
-defm SPV_INTEL_media_block_io : ExtensionOperand<42>;
-defm SPV_EXT_fragment_invocation_density : ExtensionOperand<44>;
-defm SPV_KHR_no_integer_wrap_decoration : ExtensionOperand<45>;
-defm SPV_KHR_float_controls : ExtensionOperand<46>;
-defm SPV_EXT_physical_storage_buffer : ExtensionOperand<47>;
-defm SPV_INTEL_fpga_memory_attributes : ExtensionOperand<48>;
-defm SPV_NV_cooperative_matrix : ExtensionOperand<49>;
-defm SPV_INTEL_shader_integer_functions2 : ExtensionOperand<50>;
-defm SPV_INTEL_fpga_loop_controls : ExtensionOperand<51>;
-defm SPV_EXT_fragment_shader_interlock : ExtensionOperand<52>;
-defm SPV_NV_shader_sm_builtins : ExtensionOperand<53>;
-defm SPV_KHR_shader_clock : ExtensionOperand<54>;
-defm SPV_INTEL_unstructured_loop_controls : ExtensionOperand<55>;
-defm SPV_EXT_demote_to_helper_invocation : ExtensionOperand<56>;
-defm SPV_INTEL_fpga_reg : ExtensionOperand<57>;
-defm SPV_INTEL_blocking_pipes : ExtensionOperand<58>;
-defm SPV_GOOGLE_user_type : ExtensionOperand<59>;
-defm SPV_KHR_physical_storage_buffer : ExtensionOperand<60>;
-defm SPV_INTEL_kernel_attributes : ExtensionOperand<61>;
-defm SPV_KHR_non_semantic_info : ExtensionOperand<62>;
-defm SPV_INTEL_io_pipes : ExtensionOperand<63>;
-defm SPV_KHR_ray_tracing : ExtensionOperand<64>;
-defm SPV_KHR_ray_query : ExtensionOperand<65>;
-defm SPV_INTEL_fpga_memory_accesses : ExtensionOperand<66>;
-defm SPV_INTEL_arbitrary_precision_integers : ExtensionOperand<67>;
-defm SPV_EXT_shader_atomic_float_add : ExtensionOperand<68>;
-defm SPV_KHR_terminate_invocation : ExtensionOperand<69>;
-defm SPV_KHR_fragment_shading_rate : ExtensionOperand<70>;
-defm SPV_EXT_shader_image_int64 : ExtensionOperand<71>;
-defm SPV_INTEL_fp_fast_math_mode : ExtensionOperand<72>;
-defm SPV_INTEL_fpga_cluster_attributes : ExtensionOperand<73>;
-defm SPV_INTEL_loop_fuse : ExtensionOperand<74>;
-defm SPV_EXT_shader_atomic_float_min_max : ExtensionOperand<75>;
-defm SPV_KHR_workgroup_memory_explicit_layout : ExtensionOperand<76>;
-defm SPV_KHR_linkonce_odr : ExtensionOperand<77>;
-defm SPV_KHR_expect_assume : ExtensionOperand<78>;
-defm SPV_INTEL_fpga_dsp_control : ExtensionOperand<79>;
-defm SPV_NV_bindless_texture : ExtensionOperand<80>;
-defm SPV_INTEL_fpga_invocation_pipelining_attributes : ExtensionOperand<81>;
-defm SPV_KHR_subgroup_uniform_control_flow : ExtensionOperand<82>;
-defm SPV_HUAWEI_subpass_shading : ExtensionOperand<83>;
-defm SPV_KHR_integer_dot_product : ExtensionOperand<84>;
-defm SPV_EXT_shader_atomic_float16_add : ExtensionOperand<85>;
-defm SPV_INTEL_runtime_aligned : ExtensionOperand<86>;
-defm SPV_KHR_bit_instructions : ExtensionOperand<87>;
-defm SPV_NV_ray_tracing_motion_blur : ExtensionOperand<88>;
-defm SPV_KHR_uniform_group_instructions : ExtensionOperand<89>;
-defm SPV_KHR_subgroup_rotate : ExtensionOperand<90>;
-defm SPV_INTEL_split_barrier : ExtensionOperand<91>;
-defm SPV_KHR_ray_cull_mask : ExtensionOperand<92>;
-defm SPV_KHR_fragment_shader_barycentric : ExtensionOperand<93>;
-defm SPV_EXT_relaxed_printf_string_address_space : ExtensionOperand<94>;
-defm SPV_EXT_ycbcr_attachments : ExtensionOperand<95>;
-defm SPV_EXT_mesh_shader : ExtensionOperand<96>;
-defm SPV_ARM_core_builtins : ExtensionOperand<97>;
-defm SPV_EXT_opacity_micromap : ExtensionOperand<98>;
-defm SPV_NV_shader_invocation_reorder : ExtensionOperand<99>;
-defm SPV_INTEL_usm_storage_classes : ExtensionOperand<100>;
-defm SPV_INTEL_fpga_latency_control : ExtensionOperand<101>;
-defm SPV_INTEL_fpga_argument_interfaces : ExtensionOperand<102>;
-defm SPV_INTEL_optnone : ExtensionOperand<103>;
-defm SPV_INTEL_function_pointers : ExtensionOperand<104>;
-defm SPV_INTEL_variable_length_array : ExtensionOperand<105>;
-defm SPV_INTEL_bfloat16_conversion : ExtensionOperand<106>;
-defm SPV_INTEL_inline_assembly : ExtensionOperand<107>;
-defm SPV_INTEL_cache_controls : ExtensionOperand<108>;
-defm SPV_INTEL_global_variable_host_access : ExtensionOperand<109>;
-defm SPV_INTEL_global_variable_fpga_decorations : ExtensionOperand<110>;
-defm SPV_KHR_cooperative_matrix : ExtensionOperand<111>;
-defm SPV_EXT_arithmetic_fence : ExtensionOperand<112>;
-defm SPV_EXT_optnone : ExtensionOperand<113>;
-defm SPV_INTEL_joint_matrix : ExtensionOperand<114>;
-defm SPV_INTEL_float_controls2 : ExtensionOperand<115>;
-defm SPV_INTEL_bindless_images : ExtensionOperand<116>;
-defm SPV_INTEL_long_composites : ExtensionOperand<117>;
-defm SPV_INTEL_memory_access_aliasing : ExtensionOperand<118>;
-defm SPV_INTEL_fp_max_error : ExtensionOperand<119>;
-defm SPV_INTEL_ternary_bitwise_function : ExtensionOperand<120>;
-defm SPV_INTEL_subgroup_matrix_multiply_accumulate : ExtensionOperand<121>;
-defm SPV_INTEL_2d_block_io : ExtensionOperand<122>;
-defm SPV_INTEL_int4 : ExtensionOperand<123>;
-defm SPV_KHR_float_controls2 : ExtensionOperand<124>;
+  defm : SymbolicOperandWithRequirements<ExtensionOperand, value, NAME, 0, 0, [], [], allowedEnvironments>;
+}
+
+defm SPV_AMD_shader_explicit_vertex_parameter : ExtensionOperand<1, []>;
+defm SPV_AMD_shader_trinary_minmax_extension : ExtensionOperand<2, []>;
+defm SPV_AMD_gcn_shader : ExtensionOperand<3, []>;
+defm SPV_KHR_shader_ballot : ExtensionOperand<4, [EnvVulkan]>;
+defm SPV_AMD_shader_ballot : ExtensionOperand<5, []>;
+defm SPV_AMD_gpu_shader_half_float : ExtensionOperand<6, []>;
+defm SPV_KHR_shader_draw_parameters : ExtensionOperand<7, []>;
+defm SPV_KHR_subgroup_vote : ExtensionOperand<8, []>;
+defm SPV_KHR_16bit_storage : ExtensionOperand<9, []>;
+defm SPV_KHR_device_group : ExtensionOperand<10, []>;
+defm SPV_KHR_multiview : ExtensionOperand<11, []>;
+defm SPV_NVX_multiview_per_view_attributes : ExtensionOperand<12, []>;
+defm SPV_NV_viewport_array2 : ExtensionOperand<13, []>;
+defm SPV_NV_stereo_view_rendering : ExtensionOperand<14, []>;
+defm SPV_NV_sample_mask_override_coverage : ExtensionOperand<15, []>;
+defm SPV_NV_geometry_shader_passthrough : ExtensionOperand<16, []>;
+defm SPV_AMD_texture_gather_bias_lod : ExtensionOperand<17, []>;
+defm SPV_KHR_storage_buffer_storage_class : ExtensionOperand<18, []>;
+defm SPV_KHR_variable_pointers : ExtensionOperand<19, []>;
+defm SPV_AMD_gpu_shader_int16 : ExtensionOperand<20, []>;
+defm SPV_KHR_post_depth_coverage : ExtensionOperand<21, []>;
+defm SPV_KHR_shader_atomic_counter_ops : ExtensionOperand<22, []>;
+defm SPV_EXT_shader_stencil_export : ExtensionOperand<23, []>;
+defm SPV_EXT_shader_viewport_index_layer : ExtensionOperand<24, []>;
+defm SPV_AMD_shader_image_load_store_lod : ExtensionOperand<25, []>;
+defm SPV_AMD_shader_fragment_mask : ExtensionOperand<26, []>;
+defm SPV_EXT_fragment_fully_covered : ExtensionOperand<27, []>;
+defm SPV_AMD_gpu_shader_half_float_fetch : ExtensionOperand<28, []>;
+defm SPV_GOOGLE_decorate_string : ExtensionOperand<29, []>;
+defm SPV_GOOGLE_hlsl_functionality1 : ExtensionOperand<30, []>;
+defm SPV_NV_shader_subgroup_partitioned : ExtensionOperand<31, []>;
+defm SPV_EXT_descriptor_indexing : ExtensionOperand<32, []>;
+defm SPV_KHR_8bit_storage : ExtensionOperand<33, []>;
+defm SPV_KHR_vulkan_memory_model : ExtensionOperand<34, []>;
+defm SPV_NV_ray_tracing : ExtensionOperand<35, []>;
+defm SPV_NV_compute_shader_derivatives : ExtensionOperand<36, []>;
+defm SPV_NV_fragment_shader_barycentric : ExtensionOperand<37, []>;
+defm SPV_NV_mesh_shader : ExtensionOperand<38, []>;
+defm SPV_NV_shader_image_footprint : ExtensionOperand<39, []>;
+defm SPV_NV_shading_rate : ExtensionOperand<40, []>;
+defm SPV_INTEL_subgroups : ExtensionOperand<41, []>;
+defm SPV_INTEL_media_block_io : ExtensionOperand<42, []>;
+defm SPV_EXT_fragment_invocation_density : ExtensionOperand<44, []>;
+defm SPV_KHR_no_integer_wrap_decoration : ExtensionOperand<45, []>;
+defm SPV_KHR_float_controls : ExtensionOperand<46, []>;
+defm SPV_EXT_physical_storage_buffer : ExtensionOperand<47, []>;
+defm SPV_INTEL_fpga_memory_attributes : ExtensionOperand<48, []>;
+defm SPV_NV_cooperative_matrix : ExtensionOperand<49, []>;
+defm SPV_INTEL_shader_integer_functions2 : ExtensionOperand<50, []>;
+defm SPV_INTEL_fpga_loop_controls : ExtensionOperand<51, []>;
+defm SPV_EXT_fragment_shader_interlock : ExtensionOperand<52, []>;
+defm SPV_NV_shader_sm_builtins : ExtensionOperand<53, []>;
+defm SPV_KHR_shader_clock : ExtensionOperand<54, []>;
+defm SPV_INTEL_unstructured_loop_controls : ExtensionOperand<55, []>;
+defm SPV_EXT_demote_to_helper_invocation : ExtensionOperand<56, []>;
+defm SPV_INTEL_fpga_reg : ExtensionOperand<57, []>;
+defm SPV_INTEL_blocking_pipes : ExtensionOperand<58, []>;
+defm SPV_GOOGLE_user_type : ExtensionOperand<59, []>;
+defm SPV_KHR_physical_storage_buffer : ExtensionOperand<60, []>;
+defm SPV_INTEL_kernel_attributes : ExtensionOperand<61, []>;
+defm SPV_KHR_non_semantic_info : ExtensionOperand<62, []>;
+defm SPV_INTEL_io_pipes : ExtensionOperand<63, []>;
+defm SPV_KHR_ray_tracing : ExtensionOperand<64, []>;
+defm SPV_KHR_ray_query : ExtensionOperand<65, []>;
+defm SPV_INTEL_fpga_memory_accesses : ExtensionOperand<66, []>;
+defm SPV_INTEL_arbitrary_precision_integers : ExtensionOperand<67, []>;
+defm SPV_EXT_shader_atomic_float_add : ExtensionOperand<68, []>;
+defm SPV_KHR_terminate_invocation : ExtensionOperand<69, []>;
+defm SPV_KHR_fragment_shading_rate : ExtensionOperand<70, []>;
+defm SPV_EXT_shader_image_int64 : ExtensionOperand<71, []>;
+defm SPV_INTEL_fp_fast_math_mode : ExtensionOperand<72, []>;
+defm SPV_INTEL_fpga_cluster_attributes : ExtensionOperand<73, []>;
+defm SPV_INTEL_loop_fuse : ExtensionOperand<74, []>;
+defm SPV_EXT_shader_atomic_float_min_max : ExtensionOperand<75, []>;
+defm SPV_KHR_workgroup_memory_explicit_layout : ExtensionOperand<76, []>;
+defm SPV_KHR_linkonce_odr : ExtensionOperand<77, []>;
+defm SPV_KHR_expect_assume : ExtensionOperand<78, []>;
+defm SPV_INTEL_fpga_dsp_control : ExtensionOperand<79, []>;
+defm SPV_NV_bindless_texture : ExtensionOperand<80, []>;
+defm SPV_INTEL_fpga_invocation_pipelining_attributes : ExtensionOperand<81, []>;
+defm SPV_KHR_subgroup_uniform_control_flow : ExtensionOperand<82, []>;
+defm SPV_HUAWEI_subpass_shading : ExtensionOperand<83, []>;
+defm SPV_KHR_integer_dot_product : ExtensionOperand<84, []>;
+defm SPV_EXT_shader_atomic_float16_add : ExtensionOperand<85, []>;
+defm SPV_INTEL_runtime_aligned : ExtensionOperand<86, []>;
+defm SPV_KHR_bit_instructions : ExtensionOperand<87, []>;
+defm SPV_NV_ray_tracing_motion_blur : ExtensionOperand<88, []>;
+defm SPV_KHR_uniform_group_instructions : ExtensionOperand<89, []>;
+defm SPV_KHR_subgroup_rotate : ExtensionOperand<90, []>;
+defm SPV_INTEL_split_barrier : ExtensionOperand<91, []>;
+defm SPV_KHR_ray_cull_mask : ExtensionOperand<92, []>;
+defm SPV_KHR_fragment_shader_barycentric : ExtensionOperand<93, []>;
+defm SPV_EXT_relaxed_printf_string_address_space : ExtensionOperand<94, []>;
+defm SPV_EXT_ycbcr_attachments : ExtensionOperand<95, []>;
+defm SPV_EXT_mesh_shader : ExtensionOperand<96, []>;
+defm SPV_ARM_core_builtins : ExtensionOperand<97, []>;
+defm SPV_EXT_opacity_micromap : ExtensionOperand<98, []>;
+defm SPV_NV_shader_invocation_reorder : ExtensionOperand<99, []>;
+defm SPV_INTEL_usm_storage_classes : ExtensionOperand<100, []>;
+defm SPV_INTEL_fpga_latency_control : ExtensionOperand<101, []>;
+defm SPV_INTEL_fpga_argument_interfaces : ExtensionOperand<102, []>;
+defm SPV_INTEL_optnone : ExtensionOperand<103, []>;
+defm SPV_INTEL_function_pointers : ExtensionOperand<104, []>;
+defm SPV_INTEL_variable_length_array : ExtensionOperand<105, []>;
+defm SPV_INTEL_bfloat16_conversion : ExtensionOperand<106, []>;
+defm SPV_INTEL_inline_assembly : ExtensionOperand<107, []>;
+defm SPV_INTEL_cache_controls : ExtensionOperand<108, []>;
+defm SPV_INTEL_global_variable_host_access : ExtensionOperand<109, []>;
+defm SPV_INTEL_global_variable_fpga_decorations : ExtensionOperand<110, []>;
+defm SPV_KHR_cooperative_matrix : ExtensionOperand<111, []>;
+defm SPV_EXT_arithmetic_fence : ExtensionOperand<112, []>;
+defm SPV_EXT_optnone : ExtensionOperand<113, []>;
+defm SPV_INTEL_joint_matrix : ExtensionOperand<114, []>;
+defm SPV_INTEL_float_controls2 : ExtensionOperand<115, []>;
+defm SPV_INTEL_bindless_images : ExtensionOperand<116, []>;
+defm SPV_INTEL_long_composites : ExtensionOperand<117, []>;
+defm SPV_INTEL_memory_access_aliasing : ExtensionOperand<118, []>;
+defm SPV_INTEL_fp_max_error : ExtensionOperand<119, []>;
+defm SPV_INTEL_ternary_bitwise_function : ExtensionOperand<120, []>;
+defm SPV_INTEL_subgroup_matrix_multiply_accumulate : ExtensionOperand<121, []>;
+defm SPV_INTEL_2d_block_io : ExtensionOperand<122, []>;
+defm SPV_INTEL_int4 : ExtensionOperand<123, []>;
+defm SPV_KHR_float_controls2 : ExtensionOperand<124, []>;
 
 //===----------------------------------------------------------------------===//
 // Multiclass used to define Capabilities enum values and at the same time
@@ -341,7 +387,7 @@ class Capability<string name, bits<32> value> {
 
 multiclass CapabilityOperand<bits<32> value, bits<32> minVersion, bits<32> maxVersion, list<Extension> reqExtensions, list<Capability> reqCapabilities> {
   def NAME : Capability<NAME, value>;
-  defm : SymbolicOperandWithRequirements<CapabilityOperand, value, NAME, minVersion, maxVersion, reqExtensions, reqCapabilities>;
+  defm : SymbolicOperandWithRequirements<CapabilityOperand, value, NAME, minVersion, maxVersion, reqExtensions, reqCapabilities, []>;
 }
 
 defm Matrix : CapabilityOperand<0, 0, 0, [], []>;
@@ -549,7 +595,7 @@ class SourceLanguage<string name, bits<32> value> {
 
 multiclass SourceLanguageOperand<bits<32> value> {
   def : SourceLanguage<NAME, value>;
-  defm : SymbolicOperandWithRequirements<SourceLanguageOperand, value, NAME, 0, 0, [], []>;
+  defm : SymbolicOperandWithRequirements<SourceLanguageOperand, value, NAME, 0, 0, [], [], []>;
 }
 
 defm Unknown : SourceLanguageOperand<0>;
@@ -578,7 +624,7 @@ class AddressingModel<string name, bits<32> value> {
 
 multiclass AddressingModelOperand<bits<32> value, list<Capability> reqCapabilities> {
   def : AddressingModel<NAME, value>;
-  defm : SymbolicOperandWithRequirements<AddressingModelOperand, value, NAME, 0, 0, [], reqCapabilities>;
+  defm : SymbolicOperandWithRequirements<AddressingModelOperand, value, NAME, 0, 0, [], reqCapabilities, []>;
 }
 
 defm Logical : AddressingModelOperand<0, []>;
@@ -605,7 +651,7 @@ class ExecutionModel<string name, bits<32> value> {
 
 multiclass ExecutionModelOperand<bits<32> value, list<Capability> reqCapabilities> {
   def : ExecutionModel<NAME, value>;
-  defm : SymbolicOperandWithRequirements<ExecutionModelOperand, value, NAME, 0, 0, [], reqCapabilities>;
+  defm : SymbolicOperandWithRequirements<ExecutionModelOperand, value, NAME, 0, 0, [], reqCapabilities, []>;
 }
 
 defm Vertex : ExecutionModelOperand<0, [Shader]>;
@@ -643,7 +689,7 @@ class MemoryModel<string name, bits<32> value> {
 
 multiclass MemoryModelOperand<bits<32> value, list<Capability> reqCapabilities> {
   def : MemoryModel<NAME, value>;
-  defm : SymbolicOperandWithRequirements<MemoryModelOperand, value, NAME, 0, 0, [], reqCapabilities>;
+  defm : SymbolicOperandWithRequirements<MemoryModelOperand, value, NAME, 0, 0, [], reqCapabilities, []>;
 }
 
 defm Simple : MemoryModelOperand<0, [Shader]>;
@@ -670,7 +716,7 @@ class ExecutionMode<string name, bits<32> value> {
 
 multiclass ExecutionModeOperand<bits<32> value, list<Capability> reqCapabilities> {
   def : ExecutionMode<NAME, value>;
-  defm : SymbolicOperandWithRequirements<ExecutionModeOperand, value, NAME, 0, 0, [], reqCapabilities>;
+  defm : SymbolicOperandWithRequirements<ExecutionModeOperand, value, NAME, 0, 0, [], reqCapabilities, []>;
 }
 
 defm Invocations : ExecutionModeOperand<0, [Geometry]>;
@@ -746,7 +792,7 @@ class StorageClass<string name, bits<32> value> {
 
 multiclass StorageClassOperand<bits<32> value, list<Extension> reqExtensions, list<Capability> reqCapabilities> {
   def : StorageClass<NAME, value>;
-  defm : SymbolicOperandWithRequirements<StorageClassOperand, value, NAME, 0, 0, reqExtensions, reqCapabilities>;
+  defm : SymbolicOperandWithRequirements<StorageClassOperand, value, NAME, 0, 0, reqExtensions, reqCapabilities, []>;
 }
 
 defm UniformConstant : StorageClassOperand<0, [], []>;
@@ -792,7 +838,7 @@ class Dim<string name, bits<32> value> {
 
 multiclass DimOperand<bits<32> value, string mnemonic, list<Capability> reqCapabilities> {
   def NAME : Dim<NAME, value>;
-  defm : SymbolicOperandWithRequirements<DimOperand, value, mnemonic, 0, 0, [], reqCapabilities>;
+  defm : SymbolicOperandWithRequirements<DimOperand, value, mnemonic, 0, 0, [], reqCapabilities, []>;
 }
 
 defm DIM_1D : DimOperand<0, "1D", [Sampled1D, Image1D]>;
@@ -822,7 +868,7 @@ class SamplerAddressingMode<string name, bits<32> value> {
 
 multiclass SamplerAddressingModeOperand<bits<32> value, list<Capability> reqCapabilities> {
   def : SamplerAddressingMode<NAME, value>;
-  defm : SymbolicOperandWithRequirements<SamplerAddressingModeOperand, value, NAME, 0, 0, [], reqCapabilities>;
+  defm : SymbolicOperandWithRequirements<SamplerAddressingModeOperand, value, NAME, 0, 0, [], reqCapabilities, []>;
 }
 
 defm None : SamplerAddressingModeOperand<0, [Kernel]>;
@@ -850,7 +896,7 @@ class SamplerFilterMode<string name, bits<32> value> {
 
 multiclass SamplerFilterModeOperand<bits<32> value, list<Capability> reqCapabilities> {
   def : SamplerFilterMode<NAME, value>;
-  defm : SymbolicOperandWithRequirements<SamplerFilterModeOperand, value, NAME, 0, 0, [], reqCapabilities>;
+  defm : SymbolicOperandWithRequirements<SamplerFilterModeOperand, value, NAME, 0, 0, [], reqCapabilities, []>;
 }
 
 defm Nearest : SamplerFilterModeOperand<0, [Kernel]>;
@@ -875,7 +921,7 @@ class ImageFormat<string name, bits<32> value> {
 
 multiclass ImageFormatOperand<bits<32> value, list<Capability> reqCapabilities> {
   def NAME : ImageFormat<NAME, value>;
-  defm : SymbolicOperandWithRequirements<ImageFormatOperand, value, NAME, 0, 0, [], reqCapabilities>;
+  defm : SymbolicOperandWithRequirements<ImageFormatOperand, value, NAME, 0, 0, [], reqCapabilities, []>;
 }
 
 defm Unknown : ImageFormatOperand<0, []>;
@@ -938,7 +984,7 @@ class ImageChannelOrder<string name, bits<32> value> {
 
 multiclass ImageChannelOrderOperand<bits<32> value, list<Capability> reqCapabilities> {
   def : ImageChannelOrder<NAME, value>;
-  defm : SymbolicOperandWithRequirements<ImageChannelOrderOperand, value, NAME, 0, 0, [], reqCapabilities>;
+  defm : SymbolicOperandWithRequirements<ImageChannelOrderOperand, value, NAME, 0, 0, [], reqCapabilities, []>;
 }
 
 defm R : ImageChannelOrderOperand<0, [Kernel]>;
@@ -981,7 +1027,7 @@ class ImageChannelDataType<string name, bits<32> value> {
 
 multiclass ImageChannelDataTypeOperand<bits<32> value, list<Capability> reqCapabilities> {
   def : ImageChannelDataType<NAME, value>;
-  defm : SymbolicOperandWithRequirements<ImageChannelDataTypeOperand, value, NAME, 0, 0, [], reqCapabilities>;
+  defm : SymbolicOperandWithRequirements<ImageChannelDataTypeOperand, value, NAME, 0, 0, [], reqCapabilities, []>;
 }
 
 defm SnormInt8 : ImageChannelDataTypeOperand<0, []>;
@@ -1021,7 +1067,7 @@ class ImageOperand<string name, bits<32> value> {
 
 multiclass ImageOperandOperand<bits<32> value, list<Capability> reqCapabilities> {
   def : ImageOperand<NAME, value>;
-  defm : SymbolicOperandWithRequirements<ImageOperandOperand, value, NAME, 0, 0, [], reqCapabilities>;
+  defm : SymbolicOperandWithRequirements<ImageOperandOperand, value, NAME, 0, 0, [], reqCapabilities, []>;
 }
 
 defm None : ImageOperandOperand<0x0, []>;
@@ -1059,7 +1105,7 @@ class FPFastMathMode<string name, bits<32> value> {
 
 multiclass FPFastMathModeOperand<bits<32> value, list<Capability> reqCapabilities> {
   def : FPFastMathMode<NAME, value>;
-  defm : SymbolicOperandWithRequirements<FPFastMathModeOperand, value, NAME, 0, 0, [], reqCapabilities>;
+  defm : SymbolicOperandWithRequirements<FPFastMathModeOperand, value, NAME, 0, 0, [], reqCapabilities, []>;
 }
 
 defm None : FPFastMathModeOperand<0x0, []>;
@@ -1088,7 +1134,7 @@ class FPRoundingMode<string name, bits<32> value> {
 
 multiclass FPRoundingModeOperand<bits<32> value> {
   def NAME : FPRoundingMode<NAME, value>;
-  defm : SymbolicOperandWithRequirements<FPRoundingModeOperand, value, NAME, 0, 0, [], []>;
+  defm : SymbolicOperandWithRequirements<FPRoundingModeOperand, value, NAME, 0, 0, [], [], []>;
 }
 
 defm RTE : FPRoundingModeOperand<0>;
@@ -1115,7 +1161,7 @@ class LinkageType<string name, bits<32> value> {
 
 multiclass LinkageTypeOperand<bits<32> value, list<Capability> reqCapabilities> {
   def : LinkageType<NAME, value>;
-  defm : SymbolicOperandWithRequirements<LinkageTypeOperand, value, NAME, 0, 0, [], reqCapabilities>;
+  defm : SymbolicOperandWithRequirements<LinkageTypeOperand, value, NAME, 0, 0, [], reqCapabilities, []>;
 }
 
 defm Export : LinkageTypeOperand<0, [Linkage]>;
@@ -1141,7 +1187,7 @@ class AccessQualifier<string name, bits<32> value> {
 
 multiclass AccessQualifierOperand<bits<32> value, list<Capability> reqCapabilities> {
   def NAME : AccessQualifier<NAME, value>;
-  defm : SymbolicOperandWithRequirements<AccessQualifierOperand, value, NAME, 0, 0, [], reqCapabilities>;
+  defm : SymbolicOperandWithRequirements<AccessQualifierOperand, value, NAME, 0, 0, [], reqCapabilities, []>;
 }
 
 defm ReadOnly : AccessQualifierOperand<0, [Kernel]>;
@@ -1168,7 +1214,7 @@ class FunctionParameterAttribute<string name, bits<32> value> {
 
 multiclass FunctionParameterAttributeOperand<bits<32> value, list<Capability> reqCapabilities> {
   def : FunctionParameterAttribute<NAME, value>;
-  defm : SymbolicOperandWithRequirements<FunctionParameterAttributeOperand, value, NAME, 0, 0, [], reqCapabilities>;
+  defm : SymbolicOperandWithRequirements<FunctionParameterAttributeOperand, value, NAME, 0, 0, [], reqCapabilities, []>;
 }
 
 defm Zext : FunctionParameterAttributeOperand<0, [Kernel]>;
@@ -1200,7 +1246,7 @@ class Decoration<string name, bits<32> value> {
 
 multiclass DecorationOperand<bits<32> value, bits<32> minVersion, bits<32> maxVersion, list<Extension> reqExtensions, list<Capability> reqCapabilities> {
   def : Decoration<NAME, value>;
-  defm : SymbolicOperandWithRequirements<DecorationOperand, value, NAME, minVersion, maxVersion, reqExtensions, reqCapabilities>;
+  defm : SymbolicOperandWithRequirements<DecorationOperand, value, NAME, minVersion, maxVersion, reqExtensions, reqCapabilities, []>;
 }
 
 defm RelaxedPrecision : DecorationOperand<0, 0, 0, [], [Shader]>;
@@ -1301,7 +1347,7 @@ class BuiltIn<string name, bits<32> value> {
 
 multiclass BuiltInOperand<bits<32> value, bits<32> minVersion, bits<32> maxVersion, list<Extension> reqExtensions, list<Capability> reqCapabilities> {
   def NAME : BuiltIn<NAME, value>;
-  defm : SymbolicOperandWithRequirements<BuiltInOperand, value, NAME, minVersion, maxVersion, reqExtensions, reqCapabilities>;
+  defm : SymbolicOperandWithRequirements<BuiltInOperand, value, NAME, minVersion, maxVersion, reqExtensions, reqCapabilities, []>;
 }
 
 defm Position : BuiltInOperand<0, 0, 0, [], [Shader]>;
@@ -1415,7 +1461,7 @@ class SelectionControl<string name, bits<32> value> {
 
 multiclass SelectionControlOperand<bits<32> value> {
   def : SelectionControl<NAME, value>;
-  defm : SymbolicOperandWithRequirements<SelectionControlOperand, value, NAME, 0, 0, [], []>;
+  defm : SymbolicOperandWithRequirements<SelectionControlOperand, value, NAME, 0, 0, [], [], []>;
 }
 
 defm None : SelectionControlOperand<0x0>;
@@ -1441,7 +1487,7 @@ class LoopControl<string name, bits<32> value> {
 
 multiclass LoopControlOperand<bits<32> value> {
   def : LoopControl<NAME, value>;
-  defm : SymbolicOperandWithRequirements<LoopControlOperand, value, NAME, 0, 0, [], []>;
+  defm : SymbolicOperandWithRequirements<LoopControlOperand, value, NAME, 0, 0, [], [], []>;
 }
 
 defm None : LoopControlOperand<0x0>;
@@ -1474,7 +1520,7 @@ class FunctionControl<string name, bits<32> value> {
 
 multiclass FunctionControlOperand<bits<32> value> {
   def : FunctionControl<NAME, value>;
-  defm : SymbolicOperandWithRequirements<FunctionControlOperand, value, NAME, 0, 0, [], []>;
+  defm : SymbolicOperandWithRequirements<FunctionControlOperand, value, NAME, 0, 0, [], [], []>;
 }
 
 defm None : FunctionControlOperand<0x0>;
@@ -1504,7 +1550,7 @@ class MemorySemantics<string name, bits<32> value> {
 
 multiclass MemorySemanticsOperand<bits<32> value, bits<32> minVersion, bits<32> maxVersion, list<Extension> reqExtensions, list<Capability> reqCapabilities> {
   def : MemorySemantics<NAME, value>;
-  defm : SymbolicOperandWithRequirements<MemorySemanticsOperand, value, NAME, minVersion, maxVersion, reqExtensions, reqCapabilities>;
+  defm : SymbolicOperandWithRequirements<MemorySemanticsOperand, value, NAME, minVersion, maxVersion, reqExtensions, reqCapabilities, []>;
 }
 
 defm None : MemorySemanticsOperand<0x0, 0, 0, [], []>;
@@ -1542,7 +1588,7 @@ class MemoryOperand<string name, bits<32> value> {
 
 multiclass MemoryOperandOperand<bits<32> value, bits<32> minVersion, bits<32> maxVersion, list<Extension> reqExtensions, list<Capability> reqCapabilities> {
   def : MemoryOperand<NAME, value>;
-  defm : SymbolicOperandWithRequirements<MemoryOperandOperand, value, NAME, minVersion, maxVersion, reqExtensions, reqCapabilities>;
+  defm : SymbolicOperandWithRequirements<MemoryOperandOperand, value, NAME, minVersion, maxVersion, reqExtensions, reqCapabilities, []>;
 }
 
 defm None : MemoryOperandOperand<0x0, 0, 0, [], []>;
@@ -1575,7 +1621,7 @@ class Scope<string name, bits<32> value> {
 
 multiclass ScopeOperand<bits<32> value, bits<32> minVersion, bits<32> maxVersion, list<Extension> reqExtensions, list<Capability> reqCapabilities> {
   def : Scope<NAME, value>;
-  defm : SymbolicOperandWithRequirements<ScopeOperand, value, NAME, minVersion, maxVersion, reqExtensions, reqCapabilities>;
+  defm : SymbolicOperandWithRequirements<ScopeOperand, value, NAME, minVersion, maxVersion, reqExtensions, reqCapabilities, []>;
 }
 
 defm CrossDevice : ScopeOperand<0, 0, 0, [], []>;
@@ -1605,7 +1651,7 @@ class GroupOperation<string name, bits<32> value> {
 
 multiclass GroupOperationOperand<bits<32> value, bits<32> minVersion, bits<32> maxVersion, list<Extension> reqExtensions, list<Capability> reqCapabilities> {
   def NAME : GroupOperation<NAME, value>;
-  defm : SymbolicOperandWithRequirements<GroupOperationOperand, value, NAME, minVersion, maxVersion, reqExtensions, reqCapabilities>;
+  defm : SymbolicOperandWithRequirements<GroupOperationOperand, value, NAME, minVersion, maxVersion, reqExtensions, reqCapabilities, []>;
 }
 
 defm Reduce : GroupOperationOperand<0, 0, 0, [], [Kernel, GroupNonUniformArithmetic, GroupNonUniformBallot]>;
@@ -1636,7 +1682,7 @@ class KernelEnqueueFlags<string name, bits<32> value> {
 
 multiclass KernelEnqueueFlagsOperand<bits<32> value, bits<32> minVersion, bits<32> maxVersion, list<Extension> reqExtensions, list<Capability> reqCapabilities> {
   def : KernelEnqueueFlags<NAME, value>;
-  defm : SymbolicOperandWithRequirements<KernelEnqueueFlagsOperand, value, NAME, minVersion, maxVersion, reqExtensions, reqCapabilities>;
+  defm : SymbolicOperandWithRequirements<KernelEnqueueFlagsOperand, value, NAME, minVersion, maxVersion, reqExtensions, reqCapabilities, []>;
 }
 
 defm NoWait : KernelEnqueueFlagsOperand<0, 0, 0, [], [Kernel]>;
@@ -1663,7 +1709,7 @@ class KernelProfilingInfo<string name, bits<32> value> {
 
 multiclass KernelProfilingInfoOperand<bits<32> value, bits<32> minVersion, bits<32> maxVersion, list<Extension> reqExtensions, list<Capability> reqCapabilities> {
   def : KernelProfilingInfo<NAME, value>;
-  defm : SymbolicOperandWithRequirements<KernelProfilingInfoOperand, value, NAME, minVersion, maxVersion, reqExtensions, reqCapabilities>;
+  defm : SymbolicOperandWithRequirements<KernelProfilingInfoOperand, value, NAME, minVersion, maxVersion, reqExtensions, reqCapabilities, []>;
 }
 
 defm None : KernelProfilingInfoOperand<0x0, 0, 0, [], []>;
@@ -1688,7 +1734,7 @@ class Opcode<string name, bits<32> value> {
 
 multiclass OpcodeOperand<bits<32> value> {
   def : Opcode<NAME, value>;
-  defm : SymbolicOperandWithRequirements<OpcodeOperand, value, NAME, 0, 0, [], []>;
+  defm : SymbolicOperandWithRequirements<OpcodeOperand, value, NAME, 0, 0, [], [], []>;
 }
 // TODO: implement other mnemonics.
 defm InBoundsAccessChain : OpcodeOperand<66>;
@@ -1718,7 +1764,7 @@ class CooperativeMatrixLayout<string name, bits<32> value> {
 
 multiclass CooperativeMatrixLayoutOperand<bits<32> value, list<Extension> reqExtensions, list<Capability> reqCapabilities> {
   def : CooperativeMatrixLayout<NAME, value>;
-  defm : SymbolicOperandWithRequirements<CooperativeMatrixLayoutOperand, value, NAME, 0, 0, reqExtensions, reqCapabilities>;
+  defm : SymbolicOperandWithRequirements<CooperativeMatrixLayoutOperand, value, NAME, 0, 0, reqExtensions, reqCapabilities, []>;
 }
 
 defm RowMajorKHR : CooperativeMatrixLayoutOperand<0x0, [SPV_KHR_cooperative_matrix], [CooperativeMatrixKHR]>;
@@ -1745,7 +1791,7 @@ class CooperativeMatrixOperands<string name, bits<32> value> {
 
 multiclass CooperativeMatrixOperandsOperand<bits<32> value, list<Extension> reqExtensions, list<Capability> reqCapabilities> {
   def : CooperativeMatrixOperands<NAME, value>;
-  defm : SymbolicOperandWithRequirements<CooperativeMatrixOperandsOperand, value, NAME, 0, 0, reqExtensions, reqCapabilities>;
+  defm : SymbolicOperandWithRequirements<CooperativeMatrixOperandsOperand, value, NAME, 0, 0, reqExtensions, reqCapabilities, []>;
 }
 
 defm NoneKHR : CooperativeMatrixOperandsOperand<0x0, [SPV_KHR_cooperative_matrix], [CooperativeMatrixKHR]>;
@@ -1778,7 +1824,7 @@ class SpecConstantOpOperands<string name, bits<32> value> {
 
 multiclass SpecConstantOpOperandsOperand<bits<32> value, list<Extension> reqExtensions, list<Capability> reqCapabilities> {
   def : SpecConstantOpOperands<NAME, value>;
-  defm : SymbolicOperandWithRequirements<SpecConstantOpOperandsOperand, value, NAME, 0, 0, reqExtensions, reqCapabilities>;
+  defm : SymbolicOperandWithRequirements<SpecConstantOpOperandsOperand, value, NAME, 0, 0, reqExtensions, reqCapabilities, []>;
 }
 
 // Conversion
@@ -1866,7 +1912,7 @@ class MatrixMultiplyAccumulateOperands<string name, bits<32> value> {
 
 multiclass  MatrixMultiplyAccumulateOperandsOperand<bits<32> value, list<Extension> reqExtensions> {
   def : MatrixMultiplyAccumulateOperands<NAME, value>;
-  defm : SymbolicOperandWithRequirements<MatrixMultiplyAccumulateOperandsOperand, value, NAME, 0, 0, reqExtensions, []>;
+  defm : SymbolicOperandWithRequirements<MatrixMultiplyAccumulateOperandsOperand, value, NAME, 0, 0, reqExtensions, [], []>;
 }
 
 defm None :  MatrixMultiplyAccumulateOperandsOperand<0x0, [SPV_INTEL_subgroup_matrix_multiply_accumulate]>;

>From c71d034d543703f36b48c9759279d4fad98fc7b4 Mon Sep 17 00:00:00 2001
From: Steven Perron <stevenperron at google.com>
Date: Thu, 24 Jul 2025 15:13:49 -0400
Subject: [PATCH 6/8] Add allowed env

---
 .../lib/Target/SPIRV/SPIRVSymbolicOperands.td | 200 +++++++++---------
 1 file changed, 100 insertions(+), 100 deletions(-)

diff --git a/llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td b/llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td
index 8c3854ad923e4..6d72154b61ad5 100644
--- a/llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td
+++ b/llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td
@@ -243,129 +243,129 @@ multiclass ExtensionOperand<bits<32> value, list<Environment> allowedEnvironment
   defm : SymbolicOperandWithRequirements<ExtensionOperand, value, NAME, 0, 0, [], [], allowedEnvironments>;
 }
 
-defm SPV_AMD_shader_explicit_vertex_parameter : ExtensionOperand<1, []>;
-defm SPV_AMD_shader_trinary_minmax_extension : ExtensionOperand<2, []>;
-defm SPV_AMD_gcn_shader : ExtensionOperand<3, []>;
+defm SPV_AMD_shader_explicit_vertex_parameter : ExtensionOperand<1, [EnvVulkan]>;
+defm SPV_AMD_shader_trinary_minmax_extension : ExtensionOperand<2, [EnvVulkan]>;
+defm SPV_AMD_gcn_shader : ExtensionOperand<3, [EnvVulkan]>;
 defm SPV_KHR_shader_ballot : ExtensionOperand<4, [EnvVulkan]>;
-defm SPV_AMD_shader_ballot : ExtensionOperand<5, []>;
-defm SPV_AMD_gpu_shader_half_float : ExtensionOperand<6, []>;
-defm SPV_KHR_shader_draw_parameters : ExtensionOperand<7, []>;
-defm SPV_KHR_subgroup_vote : ExtensionOperand<8, []>;
-defm SPV_KHR_16bit_storage : ExtensionOperand<9, []>;
-defm SPV_KHR_device_group : ExtensionOperand<10, []>;
-defm SPV_KHR_multiview : ExtensionOperand<11, []>;
-defm SPV_NVX_multiview_per_view_attributes : ExtensionOperand<12, []>;
-defm SPV_NV_viewport_array2 : ExtensionOperand<13, []>;
+defm SPV_AMD_shader_ballot : ExtensionOperand<5, [EnvVulkan]>;
+defm SPV_AMD_gpu_shader_half_float : ExtensionOperand<6, [EnvVulkan]>;
+defm SPV_KHR_shader_draw_parameters : ExtensionOperand<7, [EnvVulkan]>;
+defm SPV_KHR_subgroup_vote : ExtensionOperand<8, [EnvVulkan]>;
+defm SPV_KHR_16bit_storage : ExtensionOperand<9, [EnvVulkan]>;
+defm SPV_KHR_device_group : ExtensionOperand<10, [EnvVulkan]>;
+defm SPV_KHR_multiview : ExtensionOperand<11, [EnvVulkan]>;
+defm SPV_NVX_multiview_per_view_attributes : ExtensionOperand<12, [EnvVulkan]>;
+defm SPV_NV_viewport_array2 : ExtensionOperand<13, [EnvVulkan]>;
 defm SPV_NV_stereo_view_rendering : ExtensionOperand<14, []>;
-defm SPV_NV_sample_mask_override_coverage : ExtensionOperand<15, []>;
-defm SPV_NV_geometry_shader_passthrough : ExtensionOperand<16, []>;
-defm SPV_AMD_texture_gather_bias_lod : ExtensionOperand<17, []>;
-defm SPV_KHR_storage_buffer_storage_class : ExtensionOperand<18, []>;
-defm SPV_KHR_variable_pointers : ExtensionOperand<19, []>;
-defm SPV_AMD_gpu_shader_int16 : ExtensionOperand<20, []>;
-defm SPV_KHR_post_depth_coverage : ExtensionOperand<21, []>;
+defm SPV_NV_sample_mask_override_coverage : ExtensionOperand<15, [EnvVulkan]>;
+defm SPV_NV_geometry_shader_passthrough : ExtensionOperand<16, [EnvVulkan]>;
+defm SPV_AMD_texture_gather_bias_lod : ExtensionOperand<17, [EnvVulkan]>;
+defm SPV_KHR_storage_buffer_storage_class : ExtensionOperand<18, [EnvVulkan]>;
+defm SPV_KHR_variable_pointers : ExtensionOperand<19, [EnvVulkan]>;
+defm SPV_AMD_gpu_shader_int16 : ExtensionOperand<20, [EnvVulkan]>;
+defm SPV_KHR_post_depth_coverage : ExtensionOperand<21, [EnvVulkan]>;
 defm SPV_KHR_shader_atomic_counter_ops : ExtensionOperand<22, []>;
-defm SPV_EXT_shader_stencil_export : ExtensionOperand<23, []>;
-defm SPV_EXT_shader_viewport_index_layer : ExtensionOperand<24, []>;
-defm SPV_AMD_shader_image_load_store_lod : ExtensionOperand<25, []>;
-defm SPV_AMD_shader_fragment_mask : ExtensionOperand<26, []>;
-defm SPV_EXT_fragment_fully_covered : ExtensionOperand<27, []>;
+defm SPV_EXT_shader_stencil_export : ExtensionOperand<23, [EnvVulkan]>;
+defm SPV_EXT_shader_viewport_index_layer : ExtensionOperand<24, [EnvVulkan]>;
+defm SPV_AMD_shader_image_load_store_lod : ExtensionOperand<25, [EnvVulkan]>;
+defm SPV_AMD_shader_fragment_mask : ExtensionOperand<26, [EnvVulkan]>;
+defm SPV_EXT_fragment_fully_covered : ExtensionOperand<27, [EnvVulkan]>;
 defm SPV_AMD_gpu_shader_half_float_fetch : ExtensionOperand<28, []>;
-defm SPV_GOOGLE_decorate_string : ExtensionOperand<29, []>;
-defm SPV_GOOGLE_hlsl_functionality1 : ExtensionOperand<30, []>;
-defm SPV_NV_shader_subgroup_partitioned : ExtensionOperand<31, []>;
-defm SPV_EXT_descriptor_indexing : ExtensionOperand<32, []>;
-defm SPV_KHR_8bit_storage : ExtensionOperand<33, []>;
-defm SPV_KHR_vulkan_memory_model : ExtensionOperand<34, []>;
-defm SPV_NV_ray_tracing : ExtensionOperand<35, []>;
-defm SPV_NV_compute_shader_derivatives : ExtensionOperand<36, []>;
-defm SPV_NV_fragment_shader_barycentric : ExtensionOperand<37, []>;
-defm SPV_NV_mesh_shader : ExtensionOperand<38, []>;
-defm SPV_NV_shader_image_footprint : ExtensionOperand<39, []>;
-defm SPV_NV_shading_rate : ExtensionOperand<40, []>;
-defm SPV_INTEL_subgroups : ExtensionOperand<41, []>;
-defm SPV_INTEL_media_block_io : ExtensionOperand<42, []>;
-defm SPV_EXT_fragment_invocation_density : ExtensionOperand<44, []>;
-defm SPV_KHR_no_integer_wrap_decoration : ExtensionOperand<45, []>;
-defm SPV_KHR_float_controls : ExtensionOperand<46, []>;
-defm SPV_EXT_physical_storage_buffer : ExtensionOperand<47, []>;
+defm SPV_GOOGLE_decorate_string : ExtensionOperand<29, [EnvVulkan]>;
+defm SPV_GOOGLE_hlsl_functionality1 : ExtensionOperand<30, [EnvVulkan]>;
+defm SPV_NV_shader_subgroup_partitioned : ExtensionOperand<31, [EnvVulkan]>;
+defm SPV_EXT_descriptor_indexing : ExtensionOperand<32, [EnvVulkan]>;
+defm SPV_KHR_8bit_storage : ExtensionOperand<33, [EnvVulkan]>;
+defm SPV_KHR_vulkan_memory_model : ExtensionOperand<34, [EnvVulkan]>;
+defm SPV_NV_ray_tracing : ExtensionOperand<35, [EnvVulkan]>;
+defm SPV_NV_compute_shader_derivatives : ExtensionOperand<36, [EnvVulkan]>;
+defm SPV_NV_fragment_shader_barycentric : ExtensionOperand<37, [EnvVulkan]>;
+defm SPV_NV_mesh_shader : ExtensionOperand<38, [EnvVulkan]>;
+defm SPV_NV_shader_image_footprint : ExtensionOperand<39, [EnvVulkan]>;
+defm SPV_NV_shading_rate : ExtensionOperand<40, [EnvVulkan]>;
+defm SPV_INTEL_subgroups : ExtensionOperand<41, [EnvOpenCL]>;
+defm SPV_INTEL_media_block_io : ExtensionOperand<42, [EnvOpenCL]>;
+defm SPV_EXT_fragment_invocation_density : ExtensionOperand<44, [EnvVulkan]>;
+defm SPV_KHR_no_integer_wrap_decoration : ExtensionOperand<45, [EnvOpenCL]>;
+defm SPV_KHR_float_controls : ExtensionOperand<46, [EnvVulkan, EnvOpenCL]>;
+defm SPV_EXT_physical_storage_buffer : ExtensionOperand<47, [EnvVulkan]>;
 defm SPV_INTEL_fpga_memory_attributes : ExtensionOperand<48, []>;
-defm SPV_NV_cooperative_matrix : ExtensionOperand<49, []>;
-defm SPV_INTEL_shader_integer_functions2 : ExtensionOperand<50, []>;
+defm SPV_NV_cooperative_matrix : ExtensionOperand<49, [EnvVulkan]>;
+defm SPV_INTEL_shader_integer_functions2 : ExtensionOperand<50, [EnvVulkan, EnvOpenCL]>;
 defm SPV_INTEL_fpga_loop_controls : ExtensionOperand<51, []>;
-defm SPV_EXT_fragment_shader_interlock : ExtensionOperand<52, []>;
-defm SPV_NV_shader_sm_builtins : ExtensionOperand<53, []>;
-defm SPV_KHR_shader_clock : ExtensionOperand<54, []>;
+defm SPV_EXT_fragment_shader_interlock : ExtensionOperand<52, [EnvVulkan]>;
+defm SPV_NV_shader_sm_builtins : ExtensionOperand<53, [EnvVulkan]>;
+defm SPV_KHR_shader_clock : ExtensionOperand<54, [EnvVulkan, EnvOpenCL]>;
 defm SPV_INTEL_unstructured_loop_controls : ExtensionOperand<55, []>;
-defm SPV_EXT_demote_to_helper_invocation : ExtensionOperand<56, []>;
+defm SPV_EXT_demote_to_helper_invocation : ExtensionOperand<56, [EnvVulkan]>;
 defm SPV_INTEL_fpga_reg : ExtensionOperand<57, []>;
 defm SPV_INTEL_blocking_pipes : ExtensionOperand<58, []>;
-defm SPV_GOOGLE_user_type : ExtensionOperand<59, []>;
-defm SPV_KHR_physical_storage_buffer : ExtensionOperand<60, []>;
+defm SPV_GOOGLE_user_type : ExtensionOperand<59, [EnvVulkan]>;
+defm SPV_KHR_physical_storage_buffer : ExtensionOperand<60, [EnvVulkan]>;
 defm SPV_INTEL_kernel_attributes : ExtensionOperand<61, []>;
-defm SPV_KHR_non_semantic_info : ExtensionOperand<62, []>;
+defm SPV_KHR_non_semantic_info : ExtensionOperand<62, [EnvVulkan, EnvOpenCL]>;
 defm SPV_INTEL_io_pipes : ExtensionOperand<63, []>;
-defm SPV_KHR_ray_tracing : ExtensionOperand<64, []>;
-defm SPV_KHR_ray_query : ExtensionOperand<65, []>;
+defm SPV_KHR_ray_tracing : ExtensionOperand<64, [EnvVulkan]>;
+defm SPV_KHR_ray_query : ExtensionOperand<65, [EnvVulkan]>;
 defm SPV_INTEL_fpga_memory_accesses : ExtensionOperand<66, []>;
-defm SPV_INTEL_arbitrary_precision_integers : ExtensionOperand<67, []>;
-defm SPV_EXT_shader_atomic_float_add : ExtensionOperand<68, []>;
-defm SPV_KHR_terminate_invocation : ExtensionOperand<69, []>;
-defm SPV_KHR_fragment_shading_rate : ExtensionOperand<70, []>;
-defm SPV_EXT_shader_image_int64 : ExtensionOperand<71, []>;
+defm SPV_INTEL_arbitrary_precision_integers : ExtensionOperand<67, [EnvOpenCL]>;
+defm SPV_EXT_shader_atomic_float_add : ExtensionOperand<68, [EnvVulkan, EnvOpenCL]>;
+defm SPV_KHR_terminate_invocation : ExtensionOperand<69, [EnvVulkan]>;
+defm SPV_KHR_fragment_shading_rate : ExtensionOperand<70, [EnvVulkan]>;
+defm SPV_EXT_shader_image_int64 : ExtensionOperand<71, [EnvVulkan]>;
 defm SPV_INTEL_fp_fast_math_mode : ExtensionOperand<72, []>;
 defm SPV_INTEL_fpga_cluster_attributes : ExtensionOperand<73, []>;
 defm SPV_INTEL_loop_fuse : ExtensionOperand<74, []>;
-defm SPV_EXT_shader_atomic_float_min_max : ExtensionOperand<75, []>;
-defm SPV_KHR_workgroup_memory_explicit_layout : ExtensionOperand<76, []>;
-defm SPV_KHR_linkonce_odr : ExtensionOperand<77, []>;
-defm SPV_KHR_expect_assume : ExtensionOperand<78, []>;
+defm SPV_EXT_shader_atomic_float_min_max : ExtensionOperand<75, [EnvVulkan, EnvOpenCL]>;
+defm SPV_KHR_workgroup_memory_explicit_layout : ExtensionOperand<76, [EnvVulkan]>;
+defm SPV_KHR_linkonce_odr : ExtensionOperand<77, [EnvOpenCL]>;
+defm SPV_KHR_expect_assume : ExtensionOperand<78, [EnvVulkan, EnvOpenCL]>;
 defm SPV_INTEL_fpga_dsp_control : ExtensionOperand<79, []>;
 defm SPV_NV_bindless_texture : ExtensionOperand<80, []>;
 defm SPV_INTEL_fpga_invocation_pipelining_attributes : ExtensionOperand<81, []>;
-defm SPV_KHR_subgroup_uniform_control_flow : ExtensionOperand<82, []>;
-defm SPV_HUAWEI_subpass_shading : ExtensionOperand<83, []>;
-defm SPV_KHR_integer_dot_product : ExtensionOperand<84, []>;
-defm SPV_EXT_shader_atomic_float16_add : ExtensionOperand<85, []>;
+defm SPV_KHR_subgroup_uniform_control_flow : ExtensionOperand<82, [EnvVulkan]>;
+defm SPV_HUAWEI_subpass_shading : ExtensionOperand<83, [EnvVulkan]>;
+defm SPV_KHR_integer_dot_product : ExtensionOperand<84, [EnvVulkan, EnvOpenCL]>;
+defm SPV_EXT_shader_atomic_float16_add : ExtensionOperand<85, [EnvVulkan, EnvOpenCL]>;
 defm SPV_INTEL_runtime_aligned : ExtensionOperand<86, []>;
-defm SPV_KHR_bit_instructions : ExtensionOperand<87, []>;
-defm SPV_NV_ray_tracing_motion_blur : ExtensionOperand<88, []>;
-defm SPV_KHR_uniform_group_instructions : ExtensionOperand<89, []>;
-defm SPV_KHR_subgroup_rotate : ExtensionOperand<90, []>;
-defm SPV_INTEL_split_barrier : ExtensionOperand<91, []>;
-defm SPV_KHR_ray_cull_mask : ExtensionOperand<92, []>;
-defm SPV_KHR_fragment_shader_barycentric : ExtensionOperand<93, []>;
+defm SPV_KHR_bit_instructions : ExtensionOperand<87, [EnvOpenCL]>;
+defm SPV_NV_ray_tracing_motion_blur : ExtensionOperand<88, [EnvVulkan]>;
+defm SPV_KHR_uniform_group_instructions : ExtensionOperand<89, [EnvOpenCL]>;
+defm SPV_KHR_subgroup_rotate : ExtensionOperand<90, [EnvVulkan, EnvOpenCL]>;
+defm SPV_INTEL_split_barrier : ExtensionOperand<91, [EnvOpenCL]>;
+defm SPV_KHR_ray_cull_mask : ExtensionOperand<92, [EnvVulkan]>;
+defm SPV_KHR_fragment_shader_barycentric : ExtensionOperand<93, [EnvVulkan]>;
 defm SPV_EXT_relaxed_printf_string_address_space : ExtensionOperand<94, []>;
 defm SPV_EXT_ycbcr_attachments : ExtensionOperand<95, []>;
-defm SPV_EXT_mesh_shader : ExtensionOperand<96, []>;
-defm SPV_ARM_core_builtins : ExtensionOperand<97, []>;
-defm SPV_EXT_opacity_micromap : ExtensionOperand<98, []>;
-defm SPV_NV_shader_invocation_reorder : ExtensionOperand<99, []>;
-defm SPV_INTEL_usm_storage_classes : ExtensionOperand<100, []>;
+defm SPV_EXT_mesh_shader : ExtensionOperand<96, [EnvVulkan]>;
+defm SPV_ARM_core_builtins : ExtensionOperand<97, [EnvVulkan]>;
+defm SPV_EXT_opacity_micromap : ExtensionOperand<98, [EnvVulkan]>;
+defm SPV_NV_shader_invocation_reorder : ExtensionOperand<99, [EnvVulkan]>;
+defm SPV_INTEL_usm_storage_classes : ExtensionOperand<100, [EnvOpenCL]>;
 defm SPV_INTEL_fpga_latency_control : ExtensionOperand<101, []>;
 defm SPV_INTEL_fpga_argument_interfaces : ExtensionOperand<102, []>;
-defm SPV_INTEL_optnone : ExtensionOperand<103, []>;
-defm SPV_INTEL_function_pointers : ExtensionOperand<104, []>;
-defm SPV_INTEL_variable_length_array : ExtensionOperand<105, []>;
-defm SPV_INTEL_bfloat16_conversion : ExtensionOperand<106, []>;
-defm SPV_INTEL_inline_assembly : ExtensionOperand<107, []>;
-defm SPV_INTEL_cache_controls : ExtensionOperand<108, []>;
-defm SPV_INTEL_global_variable_host_access : ExtensionOperand<109, []>;
-defm SPV_INTEL_global_variable_fpga_decorations : ExtensionOperand<110, []>;
-defm SPV_KHR_cooperative_matrix : ExtensionOperand<111, []>;
-defm SPV_EXT_arithmetic_fence : ExtensionOperand<112, []>;
-defm SPV_EXT_optnone : ExtensionOperand<113, []>;
-defm SPV_INTEL_joint_matrix : ExtensionOperand<114, []>;
-defm SPV_INTEL_float_controls2 : ExtensionOperand<115, []>;
-defm SPV_INTEL_bindless_images : ExtensionOperand<116, []>;
-defm SPV_INTEL_long_composites : ExtensionOperand<117, []>;
-defm SPV_INTEL_memory_access_aliasing : ExtensionOperand<118, []>;
-defm SPV_INTEL_fp_max_error : ExtensionOperand<119, []>;
-defm SPV_INTEL_ternary_bitwise_function : ExtensionOperand<120, []>;
-defm SPV_INTEL_subgroup_matrix_multiply_accumulate : ExtensionOperand<121, []>;
-defm SPV_INTEL_2d_block_io : ExtensionOperand<122, []>;
-defm SPV_INTEL_int4 : ExtensionOperand<123, []>;
-defm SPV_KHR_float_controls2 : ExtensionOperand<124, []>;
+defm SPV_INTEL_optnone : ExtensionOperand<103, [EnvOpenCL]>;
+defm SPV_INTEL_function_pointers : ExtensionOperand<104, [EnvOpenCL]>;
+defm SPV_INTEL_variable_length_array : ExtensionOperand<105, [EnvOpenCL]>;
+defm SPV_INTEL_bfloat16_conversion : ExtensionOperand<106, [EnvOpenCL]>;
+defm SPV_INTEL_inline_assembly : ExtensionOperand<107, [EnvOpenCL]>;
+defm SPV_INTEL_cache_controls : ExtensionOperand<108, [EnvOpenCL]>;
+defm SPV_INTEL_global_variable_host_access : ExtensionOperand<109, [EnvOpenCL]>;
+defm SPV_INTEL_global_variable_fpga_decorations : ExtensionOperand<110, [EnvOpenCL]>;
+defm SPV_KHR_cooperative_matrix : ExtensionOperand<111, [EnvVulkan, EnvOpenCL]>;
+defm SPV_EXT_arithmetic_fence : ExtensionOperand<112, [EnvOpenCL]>;
+defm SPV_EXT_optnone : ExtensionOperand<113, [EnvOpenCL]>;
+defm SPV_INTEL_joint_matrix : ExtensionOperand<114, [EnvOpenCL]>;
+defm SPV_INTEL_float_controls2 : ExtensionOperand<115, [EnvOpenCL]>;
+defm SPV_INTEL_bindless_images : ExtensionOperand<116, [EnvOpenCL]>;
+defm SPV_INTEL_long_composites : ExtensionOperand<117, [EnvOpenCL]>;
+defm SPV_INTEL_memory_access_aliasing : ExtensionOperand<118, [EnvOpenCL]>;
+defm SPV_INTEL_fp_max_error : ExtensionOperand<119, [EnvOpenCL]>;
+defm SPV_INTEL_ternary_bitwise_function : ExtensionOperand<120, [EnvOpenCL]>;
+defm SPV_INTEL_subgroup_matrix_multiply_accumulate : ExtensionOperand<121, [EnvOpenCL]>;
+defm SPV_INTEL_2d_block_io : ExtensionOperand<122, [EnvOpenCL]>;
+defm SPV_INTEL_int4 : ExtensionOperand<123, [EnvOpenCL]>;
+defm SPV_KHR_float_controls2 : ExtensionOperand<124, [EnvVulkan, EnvOpenCL]>;
 
 //===----------------------------------------------------------------------===//
 // Multiclass used to define Capabilities enum values and at the same time

>From c1d4fc529200fdbb586516b2dc35db308482d574 Mon Sep 17 00:00:00 2001
From: Steven Perron <stevenperron at google.com>
Date: Thu, 24 Jul 2025 15:27:25 -0400
Subject: [PATCH 7/8] Add more allowed env

---
 llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp    | 85 +------------------
 llvm/lib/Target/SPIRV/SPIRVCommandLine.h      |  2 +-
 .../lib/Target/SPIRV/SPIRVSymbolicOperands.td | 40 ++++-----
 3 files changed, 23 insertions(+), 104 deletions(-)

diff --git a/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp b/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp
index 86ff897269416..f74ab3b722c81 100644
--- a/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp
@@ -20,68 +20,6 @@
 
 using namespace llvm;
 
-// List of extensions allowed for Vulkan environment.
-// This should not contain an extension that is not listed in
-// https://github.com/KhronosGroup/Vulkan-Headers/blob/main/registry/vk.xml.
-static const std::set<SPIRV::Extension::Extension> ValidVulkanExtensions = {
-    SPIRV::Extension::SPV_EXT_demote_to_helper_invocation,
-    SPIRV::Extension::SPV_EXT_shader_atomic_float_add,
-    SPIRV::Extension::SPV_EXT_shader_atomic_float16_add,
-    SPIRV::Extension::SPV_EXT_shader_atomic_float_min_max,
-    SPIRV::Extension::SPV_KHR_cooperative_matrix,
-    SPIRV::Extension::SPV_KHR_expect_assume,
-    SPIRV::Extension::SPV_KHR_float_controls,
-    SPIRV::Extension::SPV_KHR_float_controls2,
-    SPIRV::Extension::SPV_KHR_integer_dot_product,
-    SPIRV::Extension::SPV_KHR_non_semantic_info,
-    SPIRV::Extension::SPV_KHR_shader_clock,
-    SPIRV::Extension::SPV_KHR_subgroup_rotate};
-
-// List of extensions allowed for OpenCL environment.
-// TODO: Remove extension not used by OpenCL. I do not know how to get that
-// information.
-static const std::set<SPIRV::Extension::Extension> ValidOpenCLExtensions = {
-    SPIRV::Extension::SPV_EXT_shader_atomic_float_add,
-    SPIRV::Extension::SPV_EXT_shader_atomic_float16_add,
-    SPIRV::Extension::SPV_EXT_shader_atomic_float_min_max,
-    SPIRV::Extension::SPV_EXT_arithmetic_fence,
-    SPIRV::Extension::SPV_INTEL_arbitrary_precision_integers,
-    SPIRV::Extension::SPV_INTEL_cache_controls,
-    SPIRV::Extension::SPV_INTEL_float_controls2,
-    SPIRV::Extension::SPV_INTEL_global_variable_fpga_decorations,
-    SPIRV::Extension::SPV_INTEL_global_variable_host_access,
-    SPIRV::Extension::SPV_INTEL_optnone,
-    SPIRV::Extension::SPV_EXT_optnone,
-    SPIRV::Extension::SPV_INTEL_usm_storage_classes,
-    SPIRV::Extension::SPV_INTEL_split_barrier,
-    SPIRV::Extension::SPV_INTEL_subgroups,
-    SPIRV::Extension::SPV_INTEL_media_block_io,
-    SPIRV::Extension::SPV_INTEL_memory_access_aliasing,
-    SPIRV::Extension::SPV_INTEL_joint_matrix,
-    SPIRV::Extension::SPV_KHR_uniform_group_instructions,
-    SPIRV::Extension::SPV_KHR_no_integer_wrap_decoration,
-    SPIRV::Extension::SPV_KHR_float_controls,
-    SPIRV::Extension::SPV_KHR_expect_assume,
-    SPIRV::Extension::SPV_KHR_bit_instructions,
-    SPIRV::Extension::SPV_KHR_integer_dot_product,
-    SPIRV::Extension::SPV_KHR_linkonce_odr,
-    SPIRV::Extension::SPV_INTEL_inline_assembly,
-    SPIRV::Extension::SPV_INTEL_bindless_images,
-    SPIRV::Extension::SPV_INTEL_bfloat16_conversion,
-    SPIRV::Extension::SPV_KHR_subgroup_rotate,
-    SPIRV::Extension::SPV_INTEL_variable_length_array,
-    SPIRV::Extension::SPV_INTEL_function_pointers,
-    SPIRV::Extension::SPV_KHR_shader_clock,
-    SPIRV::Extension::SPV_KHR_cooperative_matrix,
-    SPIRV::Extension::SPV_KHR_non_semantic_info,
-    SPIRV::Extension::SPV_INTEL_long_composites,
-    SPIRV::Extension::SPV_INTEL_fp_max_error,
-    SPIRV::Extension::SPV_INTEL_subgroup_matrix_multiply_accumulate,
-    SPIRV::Extension::SPV_INTEL_ternary_bitwise_function,
-    SPIRV::Extension::SPV_INTEL_2d_block_io,
-    SPIRV::Extension::SPV_INTEL_int4,
-    SPIRV::Extension::SPV_KHR_float_controls2};
-
 static const std::map<std::string, SPIRV::Extension::Extension, std::less<>>
     SPIRVExtensionMap = {
         {"SPV_EXT_shader_atomic_float_add",
@@ -166,26 +104,6 @@ static const std::map<std::string, SPIRV::Extension::Extension, std::less<>>
         {"SPV_KHR_float_controls2",
          SPIRV::Extension::Extension::SPV_KHR_float_controls2}};
 
-/*
-
-TODO: std::set_union is not constexpr in c++17. I would still like a way to make
-sure the environment lists are added.
-
-// Check that every extension is in at least one of the two lists.
-constexpr bool AreAllExtensionsInAnEnvList() noexcept {
-      SPIRV::Extension::Extension ExtensionsInEnvList[100] = {};
-      constexpr auto* end = std::set_union(ValidVulkanExtensions.begin(),
-ValidVulkanExtensions.end(), ValidOpenCLExtensions.begin(),
-ValidOpenCLExtensions.end(), ExtensionsInEnvList); return
-(end-ExtensionsInEnvList) == SPIRVExtensionMap.size();
-}
-
-static_assert(
-    AreAllExtensionsInAnEnvList(),
-    "Not all extensions are in ValidVulkanExtensions or "
-    "ValidOpenCLExtensions");
-*/
-
 bool SPIRVExtensionsParser::parse(cl::Option &O, StringRef ArgName,
                                   StringRef ArgValue,
                                   std::set<SPIRV::Extension::Extension> &Vals) {
@@ -252,8 +170,9 @@ StringRef SPIRVExtensionsParser::checkExtensions(
   return StringRef();
 }
 
-const std::set<SPIRV::Extension::Extension> &
+std::set<SPIRV::Extension::Extension>
 SPIRVExtensionsParser::getValidExtensions(const Triple &TT) {
+  // TODO: First build a set of all extensions in the SPIRVExtensionMap. Then if hte OS is Vulkan, then remove entries that are not allowed in the vulkan environment. Otherwise, remove the entries not allowed in the opencl environment.
   if (TT.getOS() == Triple::Vulkan)
     return ValidVulkanExtensions;
   return ValidOpenCLExtensions;
diff --git a/llvm/lib/Target/SPIRV/SPIRVCommandLine.h b/llvm/lib/Target/SPIRV/SPIRVCommandLine.h
index dbde2397ab214..02e847b322a77 100644
--- a/llvm/lib/Target/SPIRV/SPIRVCommandLine.h
+++ b/llvm/lib/Target/SPIRV/SPIRVCommandLine.h
@@ -46,7 +46,7 @@ struct SPIRVExtensionsParser
 
   /// Returns the list of extensions that are valid for a particular
   /// target environment (i.e., OpenCL or Vulkan).
-  static const std::set<SPIRV::Extension::Extension> &
+  static std::set<SPIRV::Extension::Extension>
   getValidExtensions(const Triple &TT);
 };
 
diff --git a/llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td b/llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td
index 6d72154b61ad5..9291714f92fdb 100644
--- a/llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td
+++ b/llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td
@@ -256,7 +256,7 @@ defm SPV_KHR_device_group : ExtensionOperand<10, [EnvVulkan]>;
 defm SPV_KHR_multiview : ExtensionOperand<11, [EnvVulkan]>;
 defm SPV_NVX_multiview_per_view_attributes : ExtensionOperand<12, [EnvVulkan]>;
 defm SPV_NV_viewport_array2 : ExtensionOperand<13, [EnvVulkan]>;
-defm SPV_NV_stereo_view_rendering : ExtensionOperand<14, []>;
+defm SPV_NV_stereo_view_rendering : ExtensionOperand<14, [EnvVulkan]>;
 defm SPV_NV_sample_mask_override_coverage : ExtensionOperand<15, [EnvVulkan]>;
 defm SPV_NV_geometry_shader_passthrough : ExtensionOperand<16, [EnvVulkan]>;
 defm SPV_AMD_texture_gather_bias_lod : ExtensionOperand<17, [EnvVulkan]>;
@@ -264,13 +264,13 @@ defm SPV_KHR_storage_buffer_storage_class : ExtensionOperand<18, [EnvVulkan]>;
 defm SPV_KHR_variable_pointers : ExtensionOperand<19, [EnvVulkan]>;
 defm SPV_AMD_gpu_shader_int16 : ExtensionOperand<20, [EnvVulkan]>;
 defm SPV_KHR_post_depth_coverage : ExtensionOperand<21, [EnvVulkan]>;
-defm SPV_KHR_shader_atomic_counter_ops : ExtensionOperand<22, []>;
+defm SPV_KHR_shader_atomic_counter_ops : ExtensionOperand<22, [EnvVulkan]>;
 defm SPV_EXT_shader_stencil_export : ExtensionOperand<23, [EnvVulkan]>;
 defm SPV_EXT_shader_viewport_index_layer : ExtensionOperand<24, [EnvVulkan]>;
 defm SPV_AMD_shader_image_load_store_lod : ExtensionOperand<25, [EnvVulkan]>;
 defm SPV_AMD_shader_fragment_mask : ExtensionOperand<26, [EnvVulkan]>;
 defm SPV_EXT_fragment_fully_covered : ExtensionOperand<27, [EnvVulkan]>;
-defm SPV_AMD_gpu_shader_half_float_fetch : ExtensionOperand<28, []>;
+defm SPV_AMD_gpu_shader_half_float_fetch : ExtensionOperand<28, [EnvVulkan]>;
 defm SPV_GOOGLE_decorate_string : ExtensionOperand<29, [EnvVulkan]>;
 defm SPV_GOOGLE_hlsl_functionality1 : ExtensionOperand<30, [EnvVulkan]>;
 defm SPV_NV_shader_subgroup_partitioned : ExtensionOperand<31, [EnvVulkan]>;
@@ -289,45 +289,45 @@ defm SPV_EXT_fragment_invocation_density : ExtensionOperand<44, [EnvVulkan]>;
 defm SPV_KHR_no_integer_wrap_decoration : ExtensionOperand<45, [EnvOpenCL]>;
 defm SPV_KHR_float_controls : ExtensionOperand<46, [EnvVulkan, EnvOpenCL]>;
 defm SPV_EXT_physical_storage_buffer : ExtensionOperand<47, [EnvVulkan]>;
-defm SPV_INTEL_fpga_memory_attributes : ExtensionOperand<48, []>;
+defm SPV_INTEL_fpga_memory_attributes : ExtensionOperand<48, [EnvOpenCL]>;
 defm SPV_NV_cooperative_matrix : ExtensionOperand<49, [EnvVulkan]>;
 defm SPV_INTEL_shader_integer_functions2 : ExtensionOperand<50, [EnvVulkan, EnvOpenCL]>;
-defm SPV_INTEL_fpga_loop_controls : ExtensionOperand<51, []>;
+defm SPV_INTEL_fpga_loop_controls : ExtensionOperand<51, [EnvOpenCL]>;
 defm SPV_EXT_fragment_shader_interlock : ExtensionOperand<52, [EnvVulkan]>;
 defm SPV_NV_shader_sm_builtins : ExtensionOperand<53, [EnvVulkan]>;
 defm SPV_KHR_shader_clock : ExtensionOperand<54, [EnvVulkan, EnvOpenCL]>;
-defm SPV_INTEL_unstructured_loop_controls : ExtensionOperand<55, []>;
+defm SPV_INTEL_unstructured_loop_controls : ExtensionOperand<55, [EnvOpenCL]>;
 defm SPV_EXT_demote_to_helper_invocation : ExtensionOperand<56, [EnvVulkan]>;
-defm SPV_INTEL_fpga_reg : ExtensionOperand<57, []>;
-defm SPV_INTEL_blocking_pipes : ExtensionOperand<58, []>;
+defm SPV_INTEL_fpga_reg : ExtensionOperand<57, [EnvOpenCL]>;
+defm SPV_INTEL_blocking_pipes : ExtensionOperand<58, [EnvOpenCL]>;
 defm SPV_GOOGLE_user_type : ExtensionOperand<59, [EnvVulkan]>;
 defm SPV_KHR_physical_storage_buffer : ExtensionOperand<60, [EnvVulkan]>;
-defm SPV_INTEL_kernel_attributes : ExtensionOperand<61, []>;
+defm SPV_INTEL_kernel_attributes : ExtensionOperand<61, [EnvOpenCL]>;
 defm SPV_KHR_non_semantic_info : ExtensionOperand<62, [EnvVulkan, EnvOpenCL]>;
-defm SPV_INTEL_io_pipes : ExtensionOperand<63, []>;
+defm SPV_INTEL_io_pipes : ExtensionOperand<63, [EnvOpenCL]>;
 defm SPV_KHR_ray_tracing : ExtensionOperand<64, [EnvVulkan]>;
 defm SPV_KHR_ray_query : ExtensionOperand<65, [EnvVulkan]>;
-defm SPV_INTEL_fpga_memory_accesses : ExtensionOperand<66, []>;
+defm SPV_INTEL_fpga_memory_accesses : ExtensionOperand<66, [EnvOpenCL]>;
 defm SPV_INTEL_arbitrary_precision_integers : ExtensionOperand<67, [EnvOpenCL]>;
 defm SPV_EXT_shader_atomic_float_add : ExtensionOperand<68, [EnvVulkan, EnvOpenCL]>;
 defm SPV_KHR_terminate_invocation : ExtensionOperand<69, [EnvVulkan]>;
 defm SPV_KHR_fragment_shading_rate : ExtensionOperand<70, [EnvVulkan]>;
 defm SPV_EXT_shader_image_int64 : ExtensionOperand<71, [EnvVulkan]>;
-defm SPV_INTEL_fp_fast_math_mode : ExtensionOperand<72, []>;
-defm SPV_INTEL_fpga_cluster_attributes : ExtensionOperand<73, []>;
-defm SPV_INTEL_loop_fuse : ExtensionOperand<74, []>;
+defm SPV_INTEL_fp_fast_math_mode : ExtensionOperand<72, [EnvOpenCL]>;
+defm SPV_INTEL_fpga_cluster_attributes : ExtensionOperand<73, [EnvOpenCL]>;
+defm SPV_INTEL_loop_fuse : ExtensionOperand<74, [EnvOpenCL]>;
 defm SPV_EXT_shader_atomic_float_min_max : ExtensionOperand<75, [EnvVulkan, EnvOpenCL]>;
 defm SPV_KHR_workgroup_memory_explicit_layout : ExtensionOperand<76, [EnvVulkan]>;
 defm SPV_KHR_linkonce_odr : ExtensionOperand<77, [EnvOpenCL]>;
 defm SPV_KHR_expect_assume : ExtensionOperand<78, [EnvVulkan, EnvOpenCL]>;
-defm SPV_INTEL_fpga_dsp_control : ExtensionOperand<79, []>;
-defm SPV_NV_bindless_texture : ExtensionOperand<80, []>;
-defm SPV_INTEL_fpga_invocation_pipelining_attributes : ExtensionOperand<81, []>;
+defm SPV_INTEL_fpga_dsp_control : ExtensionOperand<79, [EnvOpenCL]>;
+defm SPV_NV_bindless_texture : ExtensionOperand<80, [EnvVulkan]>;
+defm SPV_INTEL_fpga_invocation_pipelining_attributes : ExtensionOperand<81, [EnvOpenCL]>;
 defm SPV_KHR_subgroup_uniform_control_flow : ExtensionOperand<82, [EnvVulkan]>;
 defm SPV_HUAWEI_subpass_shading : ExtensionOperand<83, [EnvVulkan]>;
 defm SPV_KHR_integer_dot_product : ExtensionOperand<84, [EnvVulkan, EnvOpenCL]>;
 defm SPV_EXT_shader_atomic_float16_add : ExtensionOperand<85, [EnvVulkan, EnvOpenCL]>;
-defm SPV_INTEL_runtime_aligned : ExtensionOperand<86, []>;
+defm SPV_INTEL_runtime_aligned : ExtensionOperand<86, [EnvOpenCL]>;
 defm SPV_KHR_bit_instructions : ExtensionOperand<87, [EnvOpenCL]>;
 defm SPV_NV_ray_tracing_motion_blur : ExtensionOperand<88, [EnvVulkan]>;
 defm SPV_KHR_uniform_group_instructions : ExtensionOperand<89, [EnvOpenCL]>;
@@ -342,8 +342,8 @@ defm SPV_ARM_core_builtins : ExtensionOperand<97, [EnvVulkan]>;
 defm SPV_EXT_opacity_micromap : ExtensionOperand<98, [EnvVulkan]>;
 defm SPV_NV_shader_invocation_reorder : ExtensionOperand<99, [EnvVulkan]>;
 defm SPV_INTEL_usm_storage_classes : ExtensionOperand<100, [EnvOpenCL]>;
-defm SPV_INTEL_fpga_latency_control : ExtensionOperand<101, []>;
-defm SPV_INTEL_fpga_argument_interfaces : ExtensionOperand<102, []>;
+defm SPV_INTEL_fpga_latency_control : ExtensionOperand<101, [EnvOpenCL]>;
+defm SPV_INTEL_fpga_argument_interfaces : ExtensionOperand<102, [EnvOpenCL]>;
 defm SPV_INTEL_optnone : ExtensionOperand<103, [EnvOpenCL]>;
 defm SPV_INTEL_function_pointers : ExtensionOperand<104, [EnvOpenCL]>;
 defm SPV_INTEL_variable_length_array : ExtensionOperand<105, [EnvOpenCL]>;

>From bda296eca54f8b54443e2bf679afe17ca44f287c Mon Sep 17 00:00:00 2001
From: Steven Perron <stevenperron at google.com>
Date: Thu, 24 Jul 2025 16:02:01 -0400
Subject: [PATCH 8/8] Use table and format code

---
 .../SPIRV/MCTargetDesc/SPIRVBaseInfo.cpp      |  26 +++
 .../Target/SPIRV/MCTargetDesc/SPIRVBaseInfo.h |   8 +
 llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp    |  39 +++-
 .../lib/Target/SPIRV/SPIRVSymbolicOperands.td | 190 ++++++++++++------
 4 files changed, 197 insertions(+), 66 deletions(-)

diff --git a/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVBaseInfo.cpp b/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVBaseInfo.cpp
index 0ed97f5b41c51..d6b6079810471 100644
--- a/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVBaseInfo.cpp
+++ b/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVBaseInfo.cpp
@@ -38,8 +38,15 @@ struct CapabilityEntry {
   Capability::Capability ReqCapability;
 };
 
+struct EnvironmentEntry {
+  OperandCategory::OperandCategory Category;
+  uint32_t Value;
+  Environment::Environment AllowedEnvironment;
+};
+
 using namespace OperandCategory;
 using namespace Extension;
+using namespace Environment;
 using namespace Capability;
 using namespace InstructionSet;
 #define GET_SymbolicOperands_DECL
@@ -48,6 +55,8 @@ using namespace InstructionSet;
 #define GET_ExtensionEntries_IMPL
 #define GET_CapabilityEntries_DECL
 #define GET_CapabilityEntries_IMPL
+#define GET_EnvironmentEntries_DECL
+#define GET_EnvironmentEntries_IMPL
 #define GET_ExtendedBuiltins_DECL
 #define GET_ExtendedBuiltins_IMPL
 #include "SPIRVGenTables.inc"
@@ -133,6 +142,23 @@ getSymbolicOperandCapabilities(SPIRV::OperandCategory::OperandCategory Category,
   return Capabilities;
 }
 
+EnvironmentList getSymbolicOperandAllowedEnvironments(
+    SPIRV::OperandCategory::OperandCategory Category, uint32_t Value) {
+  EnvironmentList Environments;
+  const SPIRV::EnvironmentEntry *Environment =
+      SPIRV::lookupEnvironmentByCategoryAndValue(Category, Value);
+  auto TableEnd = ArrayRef(SPIRV::EnvironmentEntries).end();
+  while (Environment && Environment->Category == Category &&
+         Environment->Value == Value) {
+    Environments.push_back(static_cast<SPIRV::Environment::Environment>(
+        Environment->AllowedEnvironment));
+    if (++Environment == TableEnd)
+      break;
+  }
+
+  return Environments;
+}
+
 CapabilityList
 getCapabilitiesEnabledByExtension(SPIRV::Extension::Extension Extension) {
   const SPIRV::ExtensionEntry *Entry =
diff --git a/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVBaseInfo.h b/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVBaseInfo.h
index b8c467fef8e8e..c2c08f8831307 100644
--- a/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVBaseInfo.h
+++ b/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVBaseInfo.h
@@ -37,6 +37,11 @@ namespace Capability {
 #include "SPIRVGenTables.inc"
 } // namespace Capability
 
+namespace Environment {
+#define GET_Environment_DECL
+#include "SPIRVGenTables.inc"
+} // namespace Environment
+
 namespace SourceLanguage {
 #define GET_SourceLanguage_DECL
 #include "SPIRVGenTables.inc"
@@ -241,6 +246,7 @@ enum InstFlags {
 
 using CapabilityList = SmallVector<SPIRV::Capability::Capability, 8>;
 using ExtensionList = SmallVector<SPIRV::Extension::Extension, 8>;
+using EnvironmentList = SmallVector<SPIRV::Environment::Environment, 8>;
 
 std::string
 getSymbolicOperandMnemonic(SPIRV::OperandCategory::OperandCategory Category,
@@ -254,6 +260,8 @@ getSymbolicOperandMaxVersion(SPIRV::OperandCategory::OperandCategory Category,
 CapabilityList
 getSymbolicOperandCapabilities(SPIRV::OperandCategory::OperandCategory Category,
                                uint32_t Value);
+EnvironmentList getSymbolicOperandAllowedEnvironments(
+    SPIRV::OperandCategory::OperandCategory Category, uint32_t Value);
 CapabilityList
 getCapabilitiesEnabledByExtension(SPIRV::Extension::Extension Extension);
 ExtensionList
diff --git a/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp b/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp
index f74ab3b722c81..a67917a01eaee 100644
--- a/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp
@@ -12,6 +12,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "SPIRVCommandLine.h"
+#include "MCTargetDesc/SPIRVBaseInfo.h"
 #include "llvm/TargetParser/Triple.h"
 #include <algorithm>
 #include <map>
@@ -104,6 +105,26 @@ static const std::map<std::string, SPIRV::Extension::Extension, std::less<>>
         {"SPV_KHR_float_controls2",
          SPIRV::Extension::Extension::SPV_KHR_float_controls2}};
 
+/*
+
+TODO: std::set_union is not constexpr in c++17. I would still like a way to make
+sure the environment lists are added.
+
+// Check that every extension is in at least one of the two lists.
+constexpr bool AreAllExtensionsInAnEnvList() noexcept {
+      SPIRV::Extension::Extension ExtensionsInEnvList[100] = {};
+      constexpr auto* end = std::set_union(ValidVulkanExtensions.begin(),
+ValidVulkanExtensions.end(), ValidOpenCLExtensions.begin(),
+ValidOpenCLExtensions.end(), ExtensionsInEnvList); return
+(end-ExtensionsInEnvList) == SPIRVExtensionMap.size();
+}
+
+static_assert(
+    AreAllExtensionsInAnEnvList(),
+    "Not all extensions are in ValidVulkanExtensions or "
+    "ValidOpenCLExtensions");
+*/
+
 bool SPIRVExtensionsParser::parse(cl::Option &O, StringRef ArgName,
                                   StringRef ArgValue,
                                   std::set<SPIRV::Extension::Extension> &Vals) {
@@ -172,8 +193,20 @@ StringRef SPIRVExtensionsParser::checkExtensions(
 
 std::set<SPIRV::Extension::Extension>
 SPIRVExtensionsParser::getValidExtensions(const Triple &TT) {
-  // TODO: First build a set of all extensions in the SPIRVExtensionMap. Then if hte OS is Vulkan, then remove entries that are not allowed in the vulkan environment. Otherwise, remove the entries not allowed in the opencl environment.
+  std::set<SPIRV::Extension::Extension> R;
+  SPIRV::Environment::Environment CurrentEnvironment =
+      SPIRV::Environment::Environment::EnvOpenCL;
   if (TT.getOS() == Triple::Vulkan)
-    return ValidVulkanExtensions;
-  return ValidOpenCLExtensions;
+    CurrentEnvironment = SPIRV::Environment::Environment::EnvVulkan;
+
+  for (const auto &[ExtensionName, ExtensionEnum] : SPIRVExtensionMap) {
+    EnvironmentList AllowedEnv = getSymbolicOperandAllowedEnvironments(
+        SPIRV::OperandCategory::OperandCategory::ExtensionOperand,
+        ExtensionEnum);
+
+    if (std::count(AllowedEnv.begin(), AllowedEnv.end(), CurrentEnvironment))
+      R.insert(ExtensionEnum);
+  }
+
+  return R;
 }
diff --git a/llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td b/llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td
index 9291714f92fdb..08b78292ec900 100644
--- a/llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td
+++ b/llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td
@@ -118,7 +118,8 @@ def CapabilityEntries : GenericTable {
 // Forward-declare classes used in ExtensionEntry
 class Environment;
 
-class EnvironmentEntry<OperandCategory category, bits<32> value, Environment allowedEnvironment> {
+class EnvironmentEntry<OperandCategory category, bits<32> value,
+                       Environment allowedEnvironment> {
   OperandCategory Category = category;
   bits<32> Value = value;
   Environment AllowedEnvironment = allowedEnvironment;
@@ -140,22 +141,27 @@ def EnvironmentEntries : GenericTable {
 // required extension and capabilities.
 //===----------------------------------------------------------------------===//
 
-multiclass SymbolicOperandWithRequirements<OperandCategory category, bits<32> value, string mnemonic, bits<32> minVersion, bits<32> maxVersion, list<Extension> reqExtensions, list<Capability> reqCapabilities, list<Environment> allowedEnvironments> {
-    assert !ge(!size(mnemonic), 1), "No mnemonic/string representation provided for symbolic operand with value " # value;
-    def : SymbolicOperand<category, value, mnemonic, minVersion, maxVersion>;
+multiclass SymbolicOperandWithRequirements<
+    OperandCategory category, bits<32> value, string mnemonic,
+    bits<32> minVersion, bits<32> maxVersion, list<Extension> reqExtensions,
+    list<Capability> reqCapabilities, list<Environment> allowedEnvironments> {
+  assert !ge(!size(mnemonic), 1), "No mnemonic/string representation provided "
+                                  "for symbolic operand with value "#value;
+  def : SymbolicOperand<category, value, mnemonic, minVersion, maxVersion>;
 
-    assert !le(!size(reqExtensions), 1), "Too many required extensions for a symbolic/named operand: " # mnemonic;
-    if !eq(!size(reqExtensions), 1) then {
-        def : ExtensionEntry<category, value, reqExtensions[0]>;
-    }
+  assert !le(!size(reqExtensions), 1),
+      "Too many required extensions for a symbolic/named operand: "#mnemonic;
+  if !eq(!size(reqExtensions), 1) then {
+    def : ExtensionEntry<category, value, reqExtensions[0]>;
+  }
 
-    foreach capability = reqCapabilities in {
-        def : CapabilityEntry<category, value, capability>;
-    }
+  foreach capability = reqCapabilities in {
+    def : CapabilityEntry<category, value, capability>;
+  }
 
-    foreach environment = allowedEnvironments in {
-        def : EnvironmentEntry<category, value, environment>;
-    }
+  foreach environment = allowedEnvironments in {
+    def : EnvironmentEntry<category, value, environment>;
+  }
 }
 
 //===----------------------------------------------------------------------===//
@@ -214,9 +220,7 @@ def Environment : GenericEnum, Operand<i32> {
   let ValueField = "Value";
 }
 
-class Environment<bits<32> value> {
-  bits<32> Value = value;
-}
+class Environment<bits<32> value> { bits<32> Value = value; }
 
 def EnvOpenCL : Environment<0>;
 def EnvVulkan : Environment<1>;
@@ -238,12 +242,15 @@ class Extension<string name, bits<32> value> {
   bits<32> Value = value;
 }
 
-multiclass ExtensionOperand<bits<32> value, list<Environment> allowedEnvironments> {
+multiclass ExtensionOperand<bits<32> value,
+                            list<Environment> allowedEnvironments> {
   def NAME : Extension<NAME, value>;
-  defm : SymbolicOperandWithRequirements<ExtensionOperand, value, NAME, 0, 0, [], [], allowedEnvironments>;
+  defm : SymbolicOperandWithRequirements<ExtensionOperand, value, NAME, 0,
+                                         0, [], [], allowedEnvironments>;
 }
 
-defm SPV_AMD_shader_explicit_vertex_parameter : ExtensionOperand<1, [EnvVulkan]>;
+defm SPV_AMD_shader_explicit_vertex_parameter
+    : ExtensionOperand<1, [EnvVulkan]>;
 defm SPV_AMD_shader_trinary_minmax_extension : ExtensionOperand<2, [EnvVulkan]>;
 defm SPV_AMD_gcn_shader : ExtensionOperand<3, [EnvVulkan]>;
 defm SPV_KHR_shader_ballot : ExtensionOperand<4, [EnvVulkan]>;
@@ -291,7 +298,8 @@ defm SPV_KHR_float_controls : ExtensionOperand<46, [EnvVulkan, EnvOpenCL]>;
 defm SPV_EXT_physical_storage_buffer : ExtensionOperand<47, [EnvVulkan]>;
 defm SPV_INTEL_fpga_memory_attributes : ExtensionOperand<48, [EnvOpenCL]>;
 defm SPV_NV_cooperative_matrix : ExtensionOperand<49, [EnvVulkan]>;
-defm SPV_INTEL_shader_integer_functions2 : ExtensionOperand<50, [EnvVulkan, EnvOpenCL]>;
+defm SPV_INTEL_shader_integer_functions2
+    : ExtensionOperand<50, [EnvVulkan, EnvOpenCL]>;
 defm SPV_INTEL_fpga_loop_controls : ExtensionOperand<51, [EnvOpenCL]>;
 defm SPV_EXT_fragment_shader_interlock : ExtensionOperand<52, [EnvVulkan]>;
 defm SPV_NV_shader_sm_builtins : ExtensionOperand<53, [EnvVulkan]>;
@@ -309,24 +317,29 @@ defm SPV_KHR_ray_tracing : ExtensionOperand<64, [EnvVulkan]>;
 defm SPV_KHR_ray_query : ExtensionOperand<65, [EnvVulkan]>;
 defm SPV_INTEL_fpga_memory_accesses : ExtensionOperand<66, [EnvOpenCL]>;
 defm SPV_INTEL_arbitrary_precision_integers : ExtensionOperand<67, [EnvOpenCL]>;
-defm SPV_EXT_shader_atomic_float_add : ExtensionOperand<68, [EnvVulkan, EnvOpenCL]>;
+defm SPV_EXT_shader_atomic_float_add
+    : ExtensionOperand<68, [EnvVulkan, EnvOpenCL]>;
 defm SPV_KHR_terminate_invocation : ExtensionOperand<69, [EnvVulkan]>;
 defm SPV_KHR_fragment_shading_rate : ExtensionOperand<70, [EnvVulkan]>;
 defm SPV_EXT_shader_image_int64 : ExtensionOperand<71, [EnvVulkan]>;
 defm SPV_INTEL_fp_fast_math_mode : ExtensionOperand<72, [EnvOpenCL]>;
 defm SPV_INTEL_fpga_cluster_attributes : ExtensionOperand<73, [EnvOpenCL]>;
 defm SPV_INTEL_loop_fuse : ExtensionOperand<74, [EnvOpenCL]>;
-defm SPV_EXT_shader_atomic_float_min_max : ExtensionOperand<75, [EnvVulkan, EnvOpenCL]>;
-defm SPV_KHR_workgroup_memory_explicit_layout : ExtensionOperand<76, [EnvVulkan]>;
+defm SPV_EXT_shader_atomic_float_min_max
+    : ExtensionOperand<75, [EnvVulkan, EnvOpenCL]>;
+defm SPV_KHR_workgroup_memory_explicit_layout
+    : ExtensionOperand<76, [EnvVulkan]>;
 defm SPV_KHR_linkonce_odr : ExtensionOperand<77, [EnvOpenCL]>;
 defm SPV_KHR_expect_assume : ExtensionOperand<78, [EnvVulkan, EnvOpenCL]>;
 defm SPV_INTEL_fpga_dsp_control : ExtensionOperand<79, [EnvOpenCL]>;
 defm SPV_NV_bindless_texture : ExtensionOperand<80, [EnvVulkan]>;
-defm SPV_INTEL_fpga_invocation_pipelining_attributes : ExtensionOperand<81, [EnvOpenCL]>;
+defm SPV_INTEL_fpga_invocation_pipelining_attributes
+    : ExtensionOperand<81, [EnvOpenCL]>;
 defm SPV_KHR_subgroup_uniform_control_flow : ExtensionOperand<82, [EnvVulkan]>;
 defm SPV_HUAWEI_subpass_shading : ExtensionOperand<83, [EnvVulkan]>;
 defm SPV_KHR_integer_dot_product : ExtensionOperand<84, [EnvVulkan, EnvOpenCL]>;
-defm SPV_EXT_shader_atomic_float16_add : ExtensionOperand<85, [EnvVulkan, EnvOpenCL]>;
+defm SPV_EXT_shader_atomic_float16_add
+    : ExtensionOperand<85, [EnvVulkan, EnvOpenCL]>;
 defm SPV_INTEL_runtime_aligned : ExtensionOperand<86, [EnvOpenCL]>;
 defm SPV_KHR_bit_instructions : ExtensionOperand<87, [EnvOpenCL]>;
 defm SPV_NV_ray_tracing_motion_blur : ExtensionOperand<88, [EnvVulkan]>;
@@ -351,7 +364,8 @@ defm SPV_INTEL_bfloat16_conversion : ExtensionOperand<106, [EnvOpenCL]>;
 defm SPV_INTEL_inline_assembly : ExtensionOperand<107, [EnvOpenCL]>;
 defm SPV_INTEL_cache_controls : ExtensionOperand<108, [EnvOpenCL]>;
 defm SPV_INTEL_global_variable_host_access : ExtensionOperand<109, [EnvOpenCL]>;
-defm SPV_INTEL_global_variable_fpga_decorations : ExtensionOperand<110, [EnvOpenCL]>;
+defm SPV_INTEL_global_variable_fpga_decorations
+    : ExtensionOperand<110, [EnvOpenCL]>;
 defm SPV_KHR_cooperative_matrix : ExtensionOperand<111, [EnvVulkan, EnvOpenCL]>;
 defm SPV_EXT_arithmetic_fence : ExtensionOperand<112, [EnvOpenCL]>;
 defm SPV_EXT_optnone : ExtensionOperand<113, [EnvOpenCL]>;
@@ -362,7 +376,8 @@ defm SPV_INTEL_long_composites : ExtensionOperand<117, [EnvOpenCL]>;
 defm SPV_INTEL_memory_access_aliasing : ExtensionOperand<118, [EnvOpenCL]>;
 defm SPV_INTEL_fp_max_error : ExtensionOperand<119, [EnvOpenCL]>;
 defm SPV_INTEL_ternary_bitwise_function : ExtensionOperand<120, [EnvOpenCL]>;
-defm SPV_INTEL_subgroup_matrix_multiply_accumulate : ExtensionOperand<121, [EnvOpenCL]>;
+defm SPV_INTEL_subgroup_matrix_multiply_accumulate
+    : ExtensionOperand<121, [EnvOpenCL]>;
 defm SPV_INTEL_2d_block_io : ExtensionOperand<122, [EnvOpenCL]>;
 defm SPV_INTEL_int4 : ExtensionOperand<123, [EnvOpenCL]>;
 defm SPV_KHR_float_controls2 : ExtensionOperand<124, [EnvVulkan, EnvOpenCL]>;
@@ -387,7 +402,9 @@ class Capability<string name, bits<32> value> {
 
 multiclass CapabilityOperand<bits<32> value, bits<32> minVersion, bits<32> maxVersion, list<Extension> reqExtensions, list<Capability> reqCapabilities> {
   def NAME : Capability<NAME, value>;
-  defm : SymbolicOperandWithRequirements<CapabilityOperand, value, NAME, minVersion, maxVersion, reqExtensions, reqCapabilities, []>;
+  defm : SymbolicOperandWithRequirements<CapabilityOperand, value, NAME,
+                                         minVersion, maxVersion, reqExtensions,
+                                         reqCapabilities, []>;
 }
 
 defm Matrix : CapabilityOperand<0, 0, 0, [], []>;
@@ -595,7 +612,8 @@ class SourceLanguage<string name, bits<32> value> {
 
 multiclass SourceLanguageOperand<bits<32> value> {
   def : SourceLanguage<NAME, value>;
-  defm : SymbolicOperandWithRequirements<SourceLanguageOperand, value, NAME, 0, 0, [], [], []>;
+  defm : SymbolicOperandWithRequirements<SourceLanguageOperand, value, NAME, 0,
+                                         0, [], [], []>;
 }
 
 defm Unknown : SourceLanguageOperand<0>;
@@ -624,7 +642,8 @@ class AddressingModel<string name, bits<32> value> {
 
 multiclass AddressingModelOperand<bits<32> value, list<Capability> reqCapabilities> {
   def : AddressingModel<NAME, value>;
-  defm : SymbolicOperandWithRequirements<AddressingModelOperand, value, NAME, 0, 0, [], reqCapabilities, []>;
+  defm : SymbolicOperandWithRequirements<AddressingModelOperand, value, NAME, 0,
+                                         0, [], reqCapabilities, []>;
 }
 
 defm Logical : AddressingModelOperand<0, []>;
@@ -651,7 +670,8 @@ class ExecutionModel<string name, bits<32> value> {
 
 multiclass ExecutionModelOperand<bits<32> value, list<Capability> reqCapabilities> {
   def : ExecutionModel<NAME, value>;
-  defm : SymbolicOperandWithRequirements<ExecutionModelOperand, value, NAME, 0, 0, [], reqCapabilities, []>;
+  defm : SymbolicOperandWithRequirements<ExecutionModelOperand, value, NAME, 0,
+                                         0, [], reqCapabilities, []>;
 }
 
 defm Vertex : ExecutionModelOperand<0, [Shader]>;
@@ -689,7 +709,8 @@ class MemoryModel<string name, bits<32> value> {
 
 multiclass MemoryModelOperand<bits<32> value, list<Capability> reqCapabilities> {
   def : MemoryModel<NAME, value>;
-  defm : SymbolicOperandWithRequirements<MemoryModelOperand, value, NAME, 0, 0, [], reqCapabilities, []>;
+  defm : SymbolicOperandWithRequirements<MemoryModelOperand, value, NAME, 0,
+                                         0, [], reqCapabilities, []>;
 }
 
 defm Simple : MemoryModelOperand<0, [Shader]>;
@@ -716,7 +737,8 @@ class ExecutionMode<string name, bits<32> value> {
 
 multiclass ExecutionModeOperand<bits<32> value, list<Capability> reqCapabilities> {
   def : ExecutionMode<NAME, value>;
-  defm : SymbolicOperandWithRequirements<ExecutionModeOperand, value, NAME, 0, 0, [], reqCapabilities, []>;
+  defm : SymbolicOperandWithRequirements<ExecutionModeOperand, value, NAME, 0,
+                                         0, [], reqCapabilities, []>;
 }
 
 defm Invocations : ExecutionModeOperand<0, [Geometry]>;
@@ -792,7 +814,8 @@ class StorageClass<string name, bits<32> value> {
 
 multiclass StorageClassOperand<bits<32> value, list<Extension> reqExtensions, list<Capability> reqCapabilities> {
   def : StorageClass<NAME, value>;
-  defm : SymbolicOperandWithRequirements<StorageClassOperand, value, NAME, 0, 0, reqExtensions, reqCapabilities, []>;
+  defm : SymbolicOperandWithRequirements<StorageClassOperand, value, NAME, 0, 0,
+                                         reqExtensions, reqCapabilities, []>;
 }
 
 defm UniformConstant : StorageClassOperand<0, [], []>;
@@ -838,7 +861,8 @@ class Dim<string name, bits<32> value> {
 
 multiclass DimOperand<bits<32> value, string mnemonic, list<Capability> reqCapabilities> {
   def NAME : Dim<NAME, value>;
-  defm : SymbolicOperandWithRequirements<DimOperand, value, mnemonic, 0, 0, [], reqCapabilities, []>;
+  defm : SymbolicOperandWithRequirements<DimOperand, value, mnemonic, 0, 0, [],
+                                         reqCapabilities, []>;
 }
 
 defm DIM_1D : DimOperand<0, "1D", [Sampled1D, Image1D]>;
@@ -868,7 +892,8 @@ class SamplerAddressingMode<string name, bits<32> value> {
 
 multiclass SamplerAddressingModeOperand<bits<32> value, list<Capability> reqCapabilities> {
   def : SamplerAddressingMode<NAME, value>;
-  defm : SymbolicOperandWithRequirements<SamplerAddressingModeOperand, value, NAME, 0, 0, [], reqCapabilities, []>;
+  defm : SymbolicOperandWithRequirements<SamplerAddressingModeOperand, value,
+                                         NAME, 0, 0, [], reqCapabilities, []>;
 }
 
 defm None : SamplerAddressingModeOperand<0, [Kernel]>;
@@ -896,7 +921,8 @@ class SamplerFilterMode<string name, bits<32> value> {
 
 multiclass SamplerFilterModeOperand<bits<32> value, list<Capability> reqCapabilities> {
   def : SamplerFilterMode<NAME, value>;
-  defm : SymbolicOperandWithRequirements<SamplerFilterModeOperand, value, NAME, 0, 0, [], reqCapabilities, []>;
+  defm : SymbolicOperandWithRequirements<SamplerFilterModeOperand, value, NAME,
+                                         0, 0, [], reqCapabilities, []>;
 }
 
 defm Nearest : SamplerFilterModeOperand<0, [Kernel]>;
@@ -921,7 +947,8 @@ class ImageFormat<string name, bits<32> value> {
 
 multiclass ImageFormatOperand<bits<32> value, list<Capability> reqCapabilities> {
   def NAME : ImageFormat<NAME, value>;
-  defm : SymbolicOperandWithRequirements<ImageFormatOperand, value, NAME, 0, 0, [], reqCapabilities, []>;
+  defm : SymbolicOperandWithRequirements<ImageFormatOperand, value, NAME, 0,
+                                         0, [], reqCapabilities, []>;
 }
 
 defm Unknown : ImageFormatOperand<0, []>;
@@ -984,7 +1011,8 @@ class ImageChannelOrder<string name, bits<32> value> {
 
 multiclass ImageChannelOrderOperand<bits<32> value, list<Capability> reqCapabilities> {
   def : ImageChannelOrder<NAME, value>;
-  defm : SymbolicOperandWithRequirements<ImageChannelOrderOperand, value, NAME, 0, 0, [], reqCapabilities, []>;
+  defm : SymbolicOperandWithRequirements<ImageChannelOrderOperand, value, NAME,
+                                         0, 0, [], reqCapabilities, []>;
 }
 
 defm R : ImageChannelOrderOperand<0, [Kernel]>;
@@ -1027,7 +1055,8 @@ class ImageChannelDataType<string name, bits<32> value> {
 
 multiclass ImageChannelDataTypeOperand<bits<32> value, list<Capability> reqCapabilities> {
   def : ImageChannelDataType<NAME, value>;
-  defm : SymbolicOperandWithRequirements<ImageChannelDataTypeOperand, value, NAME, 0, 0, [], reqCapabilities, []>;
+  defm : SymbolicOperandWithRequirements<ImageChannelDataTypeOperand, value,
+                                         NAME, 0, 0, [], reqCapabilities, []>;
 }
 
 defm SnormInt8 : ImageChannelDataTypeOperand<0, []>;
@@ -1067,7 +1096,8 @@ class ImageOperand<string name, bits<32> value> {
 
 multiclass ImageOperandOperand<bits<32> value, list<Capability> reqCapabilities> {
   def : ImageOperand<NAME, value>;
-  defm : SymbolicOperandWithRequirements<ImageOperandOperand, value, NAME, 0, 0, [], reqCapabilities, []>;
+  defm : SymbolicOperandWithRequirements<ImageOperandOperand, value, NAME, 0,
+                                         0, [], reqCapabilities, []>;
 }
 
 defm None : ImageOperandOperand<0x0, []>;
@@ -1105,7 +1135,8 @@ class FPFastMathMode<string name, bits<32> value> {
 
 multiclass FPFastMathModeOperand<bits<32> value, list<Capability> reqCapabilities> {
   def : FPFastMathMode<NAME, value>;
-  defm : SymbolicOperandWithRequirements<FPFastMathModeOperand, value, NAME, 0, 0, [], reqCapabilities, []>;
+  defm : SymbolicOperandWithRequirements<FPFastMathModeOperand, value, NAME, 0,
+                                         0, [], reqCapabilities, []>;
 }
 
 defm None : FPFastMathModeOperand<0x0, []>;
@@ -1134,7 +1165,8 @@ class FPRoundingMode<string name, bits<32> value> {
 
 multiclass FPRoundingModeOperand<bits<32> value> {
   def NAME : FPRoundingMode<NAME, value>;
-  defm : SymbolicOperandWithRequirements<FPRoundingModeOperand, value, NAME, 0, 0, [], [], []>;
+  defm : SymbolicOperandWithRequirements<FPRoundingModeOperand, value, NAME, 0,
+                                         0, [], [], []>;
 }
 
 defm RTE : FPRoundingModeOperand<0>;
@@ -1161,7 +1193,8 @@ class LinkageType<string name, bits<32> value> {
 
 multiclass LinkageTypeOperand<bits<32> value, list<Capability> reqCapabilities> {
   def : LinkageType<NAME, value>;
-  defm : SymbolicOperandWithRequirements<LinkageTypeOperand, value, NAME, 0, 0, [], reqCapabilities, []>;
+  defm : SymbolicOperandWithRequirements<LinkageTypeOperand, value, NAME, 0,
+                                         0, [], reqCapabilities, []>;
 }
 
 defm Export : LinkageTypeOperand<0, [Linkage]>;
@@ -1187,7 +1220,8 @@ class AccessQualifier<string name, bits<32> value> {
 
 multiclass AccessQualifierOperand<bits<32> value, list<Capability> reqCapabilities> {
   def NAME : AccessQualifier<NAME, value>;
-  defm : SymbolicOperandWithRequirements<AccessQualifierOperand, value, NAME, 0, 0, [], reqCapabilities, []>;
+  defm : SymbolicOperandWithRequirements<AccessQualifierOperand, value, NAME, 0,
+                                         0, [], reqCapabilities, []>;
 }
 
 defm ReadOnly : AccessQualifierOperand<0, [Kernel]>;
@@ -1214,7 +1248,9 @@ class FunctionParameterAttribute<string name, bits<32> value> {
 
 multiclass FunctionParameterAttributeOperand<bits<32> value, list<Capability> reqCapabilities> {
   def : FunctionParameterAttribute<NAME, value>;
-  defm : SymbolicOperandWithRequirements<FunctionParameterAttributeOperand, value, NAME, 0, 0, [], reqCapabilities, []>;
+  defm : SymbolicOperandWithRequirements<FunctionParameterAttributeOperand,
+                                         value, NAME, 0, 0, [],
+                                         reqCapabilities, []>;
 }
 
 defm Zext : FunctionParameterAttributeOperand<0, [Kernel]>;
@@ -1246,7 +1282,9 @@ class Decoration<string name, bits<32> value> {
 
 multiclass DecorationOperand<bits<32> value, bits<32> minVersion, bits<32> maxVersion, list<Extension> reqExtensions, list<Capability> reqCapabilities> {
   def : Decoration<NAME, value>;
-  defm : SymbolicOperandWithRequirements<DecorationOperand, value, NAME, minVersion, maxVersion, reqExtensions, reqCapabilities, []>;
+  defm : SymbolicOperandWithRequirements<DecorationOperand, value, NAME,
+                                         minVersion, maxVersion, reqExtensions,
+                                         reqCapabilities, []>;
 }
 
 defm RelaxedPrecision : DecorationOperand<0, 0, 0, [], [Shader]>;
@@ -1347,7 +1385,9 @@ class BuiltIn<string name, bits<32> value> {
 
 multiclass BuiltInOperand<bits<32> value, bits<32> minVersion, bits<32> maxVersion, list<Extension> reqExtensions, list<Capability> reqCapabilities> {
   def NAME : BuiltIn<NAME, value>;
-  defm : SymbolicOperandWithRequirements<BuiltInOperand, value, NAME, minVersion, maxVersion, reqExtensions, reqCapabilities, []>;
+  defm : SymbolicOperandWithRequirements<BuiltInOperand, value, NAME,
+                                         minVersion, maxVersion, reqExtensions,
+                                         reqCapabilities, []>;
 }
 
 defm Position : BuiltInOperand<0, 0, 0, [], [Shader]>;
@@ -1461,7 +1501,8 @@ class SelectionControl<string name, bits<32> value> {
 
 multiclass SelectionControlOperand<bits<32> value> {
   def : SelectionControl<NAME, value>;
-  defm : SymbolicOperandWithRequirements<SelectionControlOperand, value, NAME, 0, 0, [], [], []>;
+  defm : SymbolicOperandWithRequirements<SelectionControlOperand, value, NAME,
+                                         0, 0, [], [], []>;
 }
 
 defm None : SelectionControlOperand<0x0>;
@@ -1487,7 +1528,8 @@ class LoopControl<string name, bits<32> value> {
 
 multiclass LoopControlOperand<bits<32> value> {
   def : LoopControl<NAME, value>;
-  defm : SymbolicOperandWithRequirements<LoopControlOperand, value, NAME, 0, 0, [], [], []>;
+  defm : SymbolicOperandWithRequirements<LoopControlOperand, value, NAME, 0,
+                                         0, [], [], []>;
 }
 
 defm None : LoopControlOperand<0x0>;
@@ -1520,7 +1562,8 @@ class FunctionControl<string name, bits<32> value> {
 
 multiclass FunctionControlOperand<bits<32> value> {
   def : FunctionControl<NAME, value>;
-  defm : SymbolicOperandWithRequirements<FunctionControlOperand, value, NAME, 0, 0, [], [], []>;
+  defm : SymbolicOperandWithRequirements<FunctionControlOperand, value, NAME, 0,
+                                         0, [], [], []>;
 }
 
 defm None : FunctionControlOperand<0x0>;
@@ -1550,7 +1593,9 @@ class MemorySemantics<string name, bits<32> value> {
 
 multiclass MemorySemanticsOperand<bits<32> value, bits<32> minVersion, bits<32> maxVersion, list<Extension> reqExtensions, list<Capability> reqCapabilities> {
   def : MemorySemantics<NAME, value>;
-  defm : SymbolicOperandWithRequirements<MemorySemanticsOperand, value, NAME, minVersion, maxVersion, reqExtensions, reqCapabilities, []>;
+  defm : SymbolicOperandWithRequirements<MemorySemanticsOperand, value, NAME,
+                                         minVersion, maxVersion, reqExtensions,
+                                         reqCapabilities, []>;
 }
 
 defm None : MemorySemanticsOperand<0x0, 0, 0, [], []>;
@@ -1588,7 +1633,9 @@ class MemoryOperand<string name, bits<32> value> {
 
 multiclass MemoryOperandOperand<bits<32> value, bits<32> minVersion, bits<32> maxVersion, list<Extension> reqExtensions, list<Capability> reqCapabilities> {
   def : MemoryOperand<NAME, value>;
-  defm : SymbolicOperandWithRequirements<MemoryOperandOperand, value, NAME, minVersion, maxVersion, reqExtensions, reqCapabilities, []>;
+  defm : SymbolicOperandWithRequirements<MemoryOperandOperand, value, NAME,
+                                         minVersion, maxVersion, reqExtensions,
+                                         reqCapabilities, []>;
 }
 
 defm None : MemoryOperandOperand<0x0, 0, 0, [], []>;
@@ -1621,7 +1668,9 @@ class Scope<string name, bits<32> value> {
 
 multiclass ScopeOperand<bits<32> value, bits<32> minVersion, bits<32> maxVersion, list<Extension> reqExtensions, list<Capability> reqCapabilities> {
   def : Scope<NAME, value>;
-  defm : SymbolicOperandWithRequirements<ScopeOperand, value, NAME, minVersion, maxVersion, reqExtensions, reqCapabilities, []>;
+  defm : SymbolicOperandWithRequirements<ScopeOperand, value, NAME, minVersion,
+                                         maxVersion, reqExtensions,
+                                         reqCapabilities, []>;
 }
 
 defm CrossDevice : ScopeOperand<0, 0, 0, [], []>;
@@ -1651,7 +1700,9 @@ class GroupOperation<string name, bits<32> value> {
 
 multiclass GroupOperationOperand<bits<32> value, bits<32> minVersion, bits<32> maxVersion, list<Extension> reqExtensions, list<Capability> reqCapabilities> {
   def NAME : GroupOperation<NAME, value>;
-  defm : SymbolicOperandWithRequirements<GroupOperationOperand, value, NAME, minVersion, maxVersion, reqExtensions, reqCapabilities, []>;
+  defm : SymbolicOperandWithRequirements<GroupOperationOperand, value, NAME,
+                                         minVersion, maxVersion, reqExtensions,
+                                         reqCapabilities, []>;
 }
 
 defm Reduce : GroupOperationOperand<0, 0, 0, [], [Kernel, GroupNonUniformArithmetic, GroupNonUniformBallot]>;
@@ -1682,7 +1733,9 @@ class KernelEnqueueFlags<string name, bits<32> value> {
 
 multiclass KernelEnqueueFlagsOperand<bits<32> value, bits<32> minVersion, bits<32> maxVersion, list<Extension> reqExtensions, list<Capability> reqCapabilities> {
   def : KernelEnqueueFlags<NAME, value>;
-  defm : SymbolicOperandWithRequirements<KernelEnqueueFlagsOperand, value, NAME, minVersion, maxVersion, reqExtensions, reqCapabilities, []>;
+  defm : SymbolicOperandWithRequirements<KernelEnqueueFlagsOperand, value, NAME,
+                                         minVersion, maxVersion, reqExtensions,
+                                         reqCapabilities, []>;
 }
 
 defm NoWait : KernelEnqueueFlagsOperand<0, 0, 0, [], [Kernel]>;
@@ -1709,7 +1762,9 @@ class KernelProfilingInfo<string name, bits<32> value> {
 
 multiclass KernelProfilingInfoOperand<bits<32> value, bits<32> minVersion, bits<32> maxVersion, list<Extension> reqExtensions, list<Capability> reqCapabilities> {
   def : KernelProfilingInfo<NAME, value>;
-  defm : SymbolicOperandWithRequirements<KernelProfilingInfoOperand, value, NAME, minVersion, maxVersion, reqExtensions, reqCapabilities, []>;
+  defm : SymbolicOperandWithRequirements<KernelProfilingInfoOperand, value,
+                                         NAME, minVersion, maxVersion,
+                                         reqExtensions, reqCapabilities, []>;
 }
 
 defm None : KernelProfilingInfoOperand<0x0, 0, 0, [], []>;
@@ -1734,7 +1789,8 @@ class Opcode<string name, bits<32> value> {
 
 multiclass OpcodeOperand<bits<32> value> {
   def : Opcode<NAME, value>;
-  defm : SymbolicOperandWithRequirements<OpcodeOperand, value, NAME, 0, 0, [], [], []>;
+  defm : SymbolicOperandWithRequirements<OpcodeOperand, value, NAME, 0,
+                                         0, [], [], []>;
 }
 // TODO: implement other mnemonics.
 defm InBoundsAccessChain : OpcodeOperand<66>;
@@ -1764,7 +1820,9 @@ class CooperativeMatrixLayout<string name, bits<32> value> {
 
 multiclass CooperativeMatrixLayoutOperand<bits<32> value, list<Extension> reqExtensions, list<Capability> reqCapabilities> {
   def : CooperativeMatrixLayout<NAME, value>;
-  defm : SymbolicOperandWithRequirements<CooperativeMatrixLayoutOperand, value, NAME, 0, 0, reqExtensions, reqCapabilities, []>;
+  defm : SymbolicOperandWithRequirements<CooperativeMatrixLayoutOperand, value,
+                                         NAME, 0, 0, reqExtensions,
+                                         reqCapabilities, []>;
 }
 
 defm RowMajorKHR : CooperativeMatrixLayoutOperand<0x0, [SPV_KHR_cooperative_matrix], [CooperativeMatrixKHR]>;
@@ -1791,7 +1849,9 @@ class CooperativeMatrixOperands<string name, bits<32> value> {
 
 multiclass CooperativeMatrixOperandsOperand<bits<32> value, list<Extension> reqExtensions, list<Capability> reqCapabilities> {
   def : CooperativeMatrixOperands<NAME, value>;
-  defm : SymbolicOperandWithRequirements<CooperativeMatrixOperandsOperand, value, NAME, 0, 0, reqExtensions, reqCapabilities, []>;
+  defm : SymbolicOperandWithRequirements<CooperativeMatrixOperandsOperand,
+                                         value, NAME, 0, 0, reqExtensions,
+                                         reqCapabilities, []>;
 }
 
 defm NoneKHR : CooperativeMatrixOperandsOperand<0x0, [SPV_KHR_cooperative_matrix], [CooperativeMatrixKHR]>;
@@ -1824,7 +1884,9 @@ class SpecConstantOpOperands<string name, bits<32> value> {
 
 multiclass SpecConstantOpOperandsOperand<bits<32> value, list<Extension> reqExtensions, list<Capability> reqCapabilities> {
   def : SpecConstantOpOperands<NAME, value>;
-  defm : SymbolicOperandWithRequirements<SpecConstantOpOperandsOperand, value, NAME, 0, 0, reqExtensions, reqCapabilities, []>;
+  defm : SymbolicOperandWithRequirements<SpecConstantOpOperandsOperand, value,
+                                         NAME, 0, 0, reqExtensions,
+                                         reqCapabilities, []>;
 }
 
 // Conversion
@@ -1912,7 +1974,9 @@ class MatrixMultiplyAccumulateOperands<string name, bits<32> value> {
 
 multiclass  MatrixMultiplyAccumulateOperandsOperand<bits<32> value, list<Extension> reqExtensions> {
   def : MatrixMultiplyAccumulateOperands<NAME, value>;
-  defm : SymbolicOperandWithRequirements<MatrixMultiplyAccumulateOperandsOperand, value, NAME, 0, 0, reqExtensions, [], []>;
+  defm : SymbolicOperandWithRequirements<
+             MatrixMultiplyAccumulateOperandsOperand, value, NAME, 0, 0,
+             reqExtensions, [], []>;
 }
 
 defm None :  MatrixMultiplyAccumulateOperandsOperand<0x0, [SPV_INTEL_subgroup_matrix_multiply_accumulate]>;



More information about the llvm-commits mailing list