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

    <tr>
        <th>Summary</th>
        <td>
            [spirv] Pick extension symbols when importing from grammar
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            mlir:spirv
      </td>
    </tr>

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

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

<pre>
    When there are duplicated symbols mapping to the same numeric value, e.g., `DotProduct` and `DotProductKHR`, right now the `gen_spirv_dialect.py` script [chooses the non-suffix one](https://github.com/llvm/llvm-project/blob/339c87a/mlir/utils/spirv/gen_spirv_dialect.py#L148-L149). This results nicer symbols but it looks recently the upstream grammar files are updated to [maintain different lists](https://github.com/KhronosGroup/SPIRV-Headers/blob/c214f6f/include/spirv/unified1/spirv.core.grammar.json#L14745-L14755) of required versions/extensions/capabilities for suffixed symbols vs non-sufffixed ones. This results in that the imported symbols [missing extensions](https://github.com/llvm/llvm-project/blob/339c87a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td#L813-L817). We should fix the script to favor suffixed ones (KHR > vendor specific though) so that we have the correct availability.  
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytVEtvnDAQ_jVwsRaBWXbhwKFp-lJ6iNKqOVbGNjCJsakfm-y_7xh2k21VqapUaWEYG8bzPWY7I47t_Sg18aO0kjC8RJgVcOalIO44dUY5MrF5Bj0Qb-J7xLFJEh0maYGTA1NBJvQtkdmQxZjs8mvjb60RgXtMCNPi18Wbj3eYx3ctDKMn2jwtdXFxkPq7m8EevgtgSnKfzcdYw3ELsydJdcVHY5x0ywfa6I0LfQ_PxGiZVNcJrUfvZ5eUbxL6Hn8D-DF0GTcTJkodzmEzW_OA5THtlOkwlGXD6z3Dp0mBxRA8KIdxaSeW-lNrtPxcbOsN3pqENhn5OoIjVrqgvCMauLQvJHbBE_BEGfMYX-FSe3VcYITZeSvZRAbLpolZ0oNChFGMMItFCWQesU8MtMeLCOh71EtjOXDe_RX5zWiNNu6DNWHG9Mvtp7tvm4-SCWndKwWcFtt-1-MTaK6CkBfog4YepCjOS1jYouJrw9mDM3rlYr-tIhv7qkI-iOkR6Y8AFiEc8CwwOp4nn73U54SzmXWgwANi7g0Stih6Yb-De1F63UCx3W9cQ7Qw8wufMM3GXvo3UgfORQtfHP1_7fJK2WnhenXJmW6Mn-7OyRVzMvMiUlYX5QZv-8U-9zhcowlKkOjpZdZW46P-PTtckhM5IAgAh4kk5TukV4u4P0uOSnH82IRhjCI4s1LzJMnIDnIpi-qhBT1hBwZqpf-YEZLKttjtmnpb7LY0FW0pmrJhqQevZIssrm6orskt8MdXLl-Ifop_JSv9kezemhdTp8Gq9p_ZRtWCjC6pGrrP07HNGfa0a_K62VLGaMe6HeV9h9ZtukrU-xTRSOViswmlixTlm5OJKXaeQktzSouizGleldUuK-um7-h-39WcFXlVJNtc4qCpLLaSGTuktl266sLgcHOZuNdNhr4atJSnEx_DyOzpKBZQBNsy7YENOLbOpwuedgHzE1lU2HQ">