[MLIR] Allow Loop dialect IfOp and ForOp to define values
authorNagy Mostafa <nagy.h.mostafa@intel.com>
Fri, 21 Feb 2020 17:58:00 +0000 (09:58 -0800)
committerDiego Caballero <diego.caballero@intel.com>
Fri, 21 Feb 2020 18:05:32 +0000 (10:05 -0800)
commitbc7b26c333f51b4b534abb81d597c0b86123718c
tree4cf07723592bfa3f799e08cb3eca660f4b249622
parent31ec721516b5ed36f7dbed180a903e269f29716d
[MLIR] Allow Loop dialect IfOp and ForOp to define values

This patch implements the RFCs proposed here:
https://llvm.discourse.group/t/rfc-modify-ifop-in-loop-dialect-to-yield-values/463
https://llvm.discourse.group/t/rfc-adding-operands-and-results-to-loop-for/459/19.

It introduces the following changes:
- All Loop Ops region, except for ReduceOp, terminate with a YieldOp.
- YieldOp can have variadice operands that is used to return values out of IfOp and ForOp regions.
- Change IfOp and ForOp syntax and representation to define values.
- Add unit-tests and update .td documentation.
- YieldOp is a terminator to loop.for/if/parallel
- YieldOp custom parser and printer

Lowering is not supported at the moment, and will be in a follow-up PR.

Thanks.

Reviewed By: bondhugula, nicolasvasilache, rriddle

Differential Revision: https://reviews.llvm.org/D74174
13 files changed:
mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp
mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp
mlir/include/mlir/Dialect/LoopOps/LoopOps.td
mlir/include/mlir/IR/OpImplementation.h
mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp
mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp
mlir/lib/Dialect/LoopOps/LoopOps.cpp
mlir/lib/Parser/Parser.cpp
mlir/test/Conversion/LoopsToGPU/parallel_loop.mlir
mlir/test/Dialect/Linalg/parallel_loops.mlir
mlir/test/Dialect/Loops/invalid.mlir
mlir/test/Dialect/Loops/ops.mlir
mlir/test/Dialect/Loops/parallel-loop-fusion.mlir