[mlir][spirv] Add support for lowering scf.for scf/if with return value
authorThomas Raoux <thomasraoux@google.com>
Thu, 2 Jul 2020 00:08:08 +0000 (17:08 -0700)
committerThomas Raoux <thomasraoux@google.com>
Thu, 2 Jul 2020 00:08:08 +0000 (17:08 -0700)
commit0670f855a7d8f48a86d67d83e6be45fab016f080
treefe1a2e9e317e2187de095299b2281c2a152ea8a9
parentfbce9855e9d5483f724d231dd4ecc2b79807d217
[mlir][spirv] Add support for lowering scf.for scf/if with return value

This allow lowering to support scf.for and scf.if with results. As right now
spv region operations don't have return value the results are demoted to
Function memory. We create one allocation per result right before the region
and store the yield values in it. Then we can load back the value from
allocation to be able to use the results.

Differential Revision: https://reviews.llvm.org/D82246
mlir/include/mlir/Conversion/SCFToSPIRV/SCFToSPIRV.h
mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.cpp
mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp
mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp
mlir/test/Conversion/GPUToSPIRV/if.mlir
mlir/test/Conversion/GPUToSPIRV/loop.mlir