[spirv] Add spv.loop
authorLei Zhang <antiagainst@google.com>
Thu, 5 Sep 2019 19:45:08 +0000 (12:45 -0700)
committerA. Unique TensorFlower <gardener@tensorflow.org>
Thu, 5 Sep 2019 19:45:53 +0000 (12:45 -0700)
commit916eb980b09a3c5303aa2e700eb6fc234c043ce6
treea68a4a0e5655218dae46161391f23d8f5ebf5d6a
parent0ba00878876316a43c7e7c38a30439adca9d5774
[spirv] Add spv.loop

SPIR-V can explicitly declare structured control-flow constructs using merge
instructions. These explicitly declare a header block before the control
flow diverges and a merge block where control flow subsequently converges.
These blocks delimit constructs that must nest, and can only be entered
and exited in structured ways.

Instead of having a `spv.LoopMerge` op to directly model loop merge
instruction for indicating the merge and continue target, we use regions
to delimit the boundary of the loop: the merge target is the next op
following the `spv.loop` op and the continue target is the block that
has a back-edge pointing to the entry block inside the `spv.loop`'s region.
This way it's easier to discover all blocks belonging to a construct and
it plays nicer with the MLIR system.

Updated the SPIR-V.md doc.

PiperOrigin-RevId: 267431010
mlir/g3doc/Dialects/SPIR-V.md
mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td
mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td
mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
mlir/test/Dialect/SPIRV/control-flow-ops.mlir