[mlir][spirv] Change the return type for {Min|Max}VersionBase

For synthesizing an op's implementation of the generated interface
from {Min|Max}Version, we need to define an `initializer` and
`mergeAction`. The `initializer` specifies the initial version,
and `mergeAction` specifies how version specifications from
different parts of the op should be merged to generate a final
version requirements.

Previously we use the specified version enum as the type for both
the initializer and thus the final return type. This means we need
to perform `static_cast` over some hopefully not used number (`~0u`)
as the initializer. This is quite opaque and sort of not guaranteed
to work. Also, there are ops that have an enum attribute where some
values declare version requirements (e.g., enumerant `B` requires
v1.1+) but some not (e.g., enumerant `A` requires nothing). Then a
concrete op instance with `A` will still declare it implements the
version interface (because interface implementation is static for
an op) but actually theirs no requirements for version.

So this commit changes to use an more explicit `llvm::Optional`
to wrap around the returned version enum.  This should make it
more clear.

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D108312

GitOrigin-RevId: cb395f66ac3ce60427ca2b99580e716ac6dd551a
6 files changed
tree: 221089bac2627a6847c4ea4ad1173a8763e953a6
  1. cmake/
  2. docs/
  3. examples/
  4. include/
  5. lib/
  6. python/
  7. test/
  8. tools/
  9. unittests/
  10. utils/
  11. .clang-format
  12. .clang-tidy
  13. CMakeLists.txt
  14. LICENSE.TXT
  15. README.md
README.md

Multi-Level Intermediate Representation

See https://mlir.llvm.org/ for more information.