diff options
| author | Lei Zhang <antiagainst@google.com> | 2019-11-12 11:59:34 -0800 |
|---|---|---|
| committer | A. Unique TensorFlower <gardener@tensorflow.org> | 2019-11-12 12:00:28 -0800 |
| commit | b259c26eb0717b6962c2f75ac23a44491b27810d (patch) | |
| tree | f5b93beb71a399ff72b73170c544b5b2065523f1 /mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp | |
| parent | 626e1fd95e626c47154c5fe5d546f3d36b39e319 (diff) | |
| download | bcm5719-llvm-b259c26eb0717b6962c2f75ac23a44491b27810d.tar.gz bcm5719-llvm-b259c26eb0717b6962c2f75ac23a44491b27810d.zip | |
Add support for OpPhi in loop header block
During deserialization, the loop header block will be moved into the
spv.loop's region. If the loop header block has block arguments,
we need to make sure it is correctly carried over to the block where
the new spv.loop resides.
During serialization, we need to make sure block arguments from the
spv.loop's entry block are not silently dropped.
PiperOrigin-RevId: 280021777
Diffstat (limited to 'mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp')
| -rw-r--r-- | mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp index 805a3393b0c..02134200a93 100644 --- a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp +++ b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp @@ -1515,6 +1515,17 @@ LogicalResult Serializer::processLoopOp(spirv::LoopOp loopOp) { // afterwards. encodeInstructionInto(functions, spirv::Opcode::OpBranch, {headerID}); + // We omit the LoopOp's entry block and start serialization from the loop + // header block. The entry block should not contain any additional ops other + // than a single spv.Branch that jumps to the loop header block. However, + // the spv.Branch can contain additional block arguments. Those block + // arguments must come from out of the loop using implicit capture. We will + // need to query the <id> for the value sent and the <id> for the incoming + // parent block. For the latter, we need to make sure this block is + // registered. The value sent should come from the block this loop resides in. + blockIDMap[loopOp.getEntryBlock()] = + getBlockID(loopOp.getOperation()->getBlock()); + // Emit the loop header block, which dominates all other blocks, first. We // need to emit an OpLoopMerge instruction before the loop header block's // terminator. |

