[mlir][Interfaces] Add `promoteIfSingleIteration` to `LoopLikeOpInterface`
authorMatthias Springer <me@m-sp.org>
Mon, 3 Jul 2023 15:57:02 +0000 (17:57 +0200)
committerMatthias Springer <me@m-sp.org>
Mon, 3 Jul 2023 16:03:35 +0000 (18:03 +0200)
commitde9caf2f3244849cf0fe29bbf7cc67bae9035329
tree18f396995530dbe92b7a89b9e452b51f0920509e
parentaa82b562b7b4b36f4a3d04e80e5743028bddd577
[mlir][Interfaces] Add `promoteIfSingleIteration` to `LoopLikeOpInterface`

There are existing implementations for `scf.for`, `scf.forall` and `affine.for`. This revision adds an interface method to the `LoopLikeOpInterface`.

* `scf.forall` now implements the `LoopLikeOpInterface`.
* The implementations of `scf.for` and `scf.forall` become interface method implementations. `affine.for` remains as is for the moment. (The implementation of `promoteIfSingleIteration` depepends on helper functions from `MLIRAffineAnalysis`, which cannot be used from `MLIRAffineDialect`, where the interface is currently implemented.)
* More efficient implementations of `promoteIfSingleIteration`. In particular, the `scf.forall` operation now inlines operations instead of cloning them. This also preserves handles when used from the transform dialect.

Differential Revision: https://reviews.llvm.org/D154343
mlir/include/mlir/Dialect/SCF/IR/SCF.h
mlir/include/mlir/Dialect/SCF/IR/SCFOps.td
mlir/include/mlir/Dialect/SCF/Utils/Utils.h
mlir/include/mlir/Interfaces/LoopLikeInterface.h
mlir/include/mlir/Interfaces/LoopLikeInterface.td
mlir/lib/Dialect/SCF/IR/SCF.cpp
mlir/lib/Dialect/SCF/Utils/Utils.cpp
mlir/test/Dialect/SCF/one-shot-bufferize.mlir