Add a pass to legalize operations before lowering to SPIR-V.
authorMahesh Ravishankar <ravishankarm@google.com>
Wed, 4 Dec 2019 00:05:46 +0000 (16:05 -0800)
committerA. Unique TensorFlower <gardener@tensorflow.org>
Wed, 4 Dec 2019 00:06:17 +0000 (16:06 -0800)
commitc5ba37b6ae00f07a37e22072fb9af84768dd1437
tree3b8faf07e317f83ef58390a9e9806f8d63d65521
parent82f9f9d112ca35f12dec9fbd83d9584b46fc9d1f
Add a pass to legalize operations before lowering to SPIR-V.

Not all StandardOps can be lowered to SPIR-V. For example, subview op
implementation requires use of pointer bitcasts which is not valid
according to SPIR-V spec (or at least is ambiguous about it). Such ops
need to be removed/transformed before lowering to SPIR-V. The
SPIRVLegalizationPass is added a place where such legalizations can be
added. Current implementation folds the subview ops with load/stores
so that the lowering itself does not have to convert a subview op.

PiperOrigin-RevId: 283642981
mlir/include/mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.h
mlir/include/mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.h
mlir/include/mlir/Dialect/StandardOps/Ops.td
mlir/lib/Conversion/StandardToSPIRV/CMakeLists.txt
mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp [new file with mode: 0644]
mlir/lib/Dialect/StandardOps/Ops.cpp
mlir/test/Conversion/StandardToSPIRV/legalization.mlir [new file with mode: 0644]
mlir/test/Conversion/StandardToSPIRV/subview-to-spirv.mlir [new file with mode: 0644]