Introduce affine terminator
authorAlex Zinenko <zinenko@google.com>
Wed, 27 Mar 2019 12:11:58 +0000 (05:11 -0700)
committerjpienaar <jpienaar@google.com>
Sat, 30 Mar 2019 00:44:24 +0000 (17:44 -0700)
commit5a5bba0279a5754c8e7aa2a9bf415aee2a0f1774
treeaa7553c11c35ffb030135528adb3bf47c54705cc
parentaf45236c70ed457fd093c88154a520db2d99f021
Introduce affine terminator

Due to legacy reasons (ML/CFG function separation), regions in affine control
flow operations require contained blocks not to have terminators.  This is
inconsistent with the notion of the block and may complicate code motion
between regions of affine control operations and other regions.

Introduce `affine.terminator`, a special terminator operation that must be used
to terminate blocks inside affine operations and transfers the control back to
he region enclosing the affine operation.  For brevity and readability reasons,
allow `affine.for` and `affine.if` to omit the `affine.terminator` in their
regions when using custom printing and parsing format.  The custom parser
injects the `affine.terminator` if it is missing so as to always have it
present in constructed operations.

Update transformations to account for the presence of terminator.  In
particular, most code motion transformation between loops should leave the
terminator in place, and code motion between loops and non-affine blocks should
drop the terminator.

PiperOrigin-RevId: 240536998
20 files changed:
mlir/g3doc/Dialects/Affine.md
mlir/include/mlir/AffineOps/AffineOps.h
mlir/include/mlir/EDSC/Builders.h
mlir/include/mlir/IR/OpImplementation.h
mlir/include/mlir/IR/Operation.h
mlir/lib/AffineOps/AffineOps.cpp
mlir/lib/Analysis/Verifier.cpp
mlir/lib/EDSC/Builders.cpp
mlir/lib/EDSC/MLIREmitter.cpp
mlir/lib/IR/AsmPrinter.cpp
mlir/lib/IR/Builders.cpp
mlir/lib/IR/Operation.cpp
mlir/lib/Transforms/LoopFusion.cpp
mlir/lib/Transforms/LoopTiling.cpp
mlir/lib/Transforms/LoopUnrollAndJam.cpp
mlir/lib/Transforms/LowerAffine.cpp
mlir/lib/Transforms/Utils/LoopUtils.cpp
mlir/test/AffineOps/ops.mlir
mlir/test/IR/invalid.mlir
mlir/test/IR/parser.mlir