<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/154425>154425</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [SPIRV] Implicit extension declarations should be unified
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          winocm
      </td>
    </tr>
</table>

<pre>
    While looking at MLIR, I noticed that `spirv::getImpliedExtensions` has a set of implicit extensions that are enabled per SPIR-V version:

```c
#define V_1_3_IMPLIED_EXTS \
 Extension::SPV_KHR_shader_draw_parameters, Extension::SPV_KHR_16bit_storage, \
      Extension::SPV_KHR_device_group, Extension::SPV_KHR_multiview, \
      Extension::SPV_KHR_storage_buffer_storage_class, \
      Extension::SPV_KHR_variable_pointers

#define V_1_4_IMPLIED_EXTS                                                     \
 Extension::SPV_KHR_no_integer_wrap_decoration, \
      Extension::SPV_GOOGLE_decorate_string, \
      Extension::SPV_GOOGLE_hlsl_functionality1, \
      Extension::SPV_KHR_float_controls

#define V_1_5_IMPLIED_EXTS                                                     \
 Extension::SPV_KHR_8bit_storage, Extension::SPV_EXT_descriptor_indexing, \
      Extension::SPV_EXT_shader_viewport_index_layer, \
      Extension::SPV_EXT_physical_storage_buffer, \
      Extension::SPV_KHR_physical_storage_buffer, \
      Extension::SPV_KHR_vulkan_memory_model

#define V_1_6_IMPLIED_EXTS                                                     \
 Extension::SPV_KHR_non_semantic_info, \
      Extension::SPV_KHR_integer_dot_product, \
      Extension::SPV_KHR_terminate_invocation, \
 Extension::SPV_EXT_demote_to_helper_invocation
```

There doesn't seem to be any equivalent in the LLVM SPIR-V backend, with many checks using the `STI.canUseExtension(...) || STI.isAtLeastSPIRVVer(VersionTuple(...))` idiom instead, which can lead to unintentional bugs.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy0VVFv2zYQ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