[all-commits] [llvm/llvm-project] cb395f: [mlir][spirv] Change the return type for {Min|Max}...

Lei Zhang via All-commits all-commits at lists.llvm.org
Wed Nov 24 14:33:25 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: cb395f66ac3ce60427ca2b99580e716ac6dd551a
      https://github.com/llvm/llvm-project/commit/cb395f66ac3ce60427ca2b99580e716ac6dd551a
  Author: Lei Zhang <antiagainst at google.com>
  Date:   2021-11-24 (Wed, 24 Nov 2021)

  Changed paths:
    M mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAvailability.td
    M mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td
    M mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
    M mlir/lib/Dialect/SPIRV/Transforms/UpdateVCEPass.cpp
    M mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp
    M mlir/tools/mlir-opt/mlir-opt.cpp

  Log Message:
  -----------
  [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




More information about the All-commits mailing list