[mlir][spirv] Properly support SPIR-V conversion target
authorLei Zhang <antiagainst@google.com>
Tue, 14 Jan 2020 23:23:25 +0000 (18:23 -0500)
committerLei Zhang <antiagainst@google.com>
Wed, 15 Jan 2020 00:18:42 +0000 (19:18 -0500)
commit47c6ab2b97773ee5fb360fc093a5824be64b8c68
tree7d9562e97714b1ac42d4579b9cbfae4a3ed130ef
parent60d39479221d6bc09060f7816bcd7c54eb286603
[mlir][spirv] Properly support SPIR-V conversion target

This commit defines a new SPIR-V dialect attribute for specifying
a SPIR-V target environment. It is a dictionary attribute containing
the SPIR-V version, supported extension list, and allowed capability
list. A SPIRVConversionTarget subclass is created to take in the
target environment and sets proper dynmaically legal ops by querying
the op availability interface of SPIR-V ops to make sure they are
available in the specified target environment. All existing conversions
targeting SPIR-V is changed to use this SPIRVConversionTarget. It
probes whether the input IR has a `spv.target_env` attribute,
otherwise, it uses the default target environment: SPIR-V 1.0 with
Shader capability and no extra extensions.

Differential Revision: https://reviews.llvm.org/D72256
13 files changed:
mlir/docs/Dialects/SPIR-V.md
mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h
mlir/include/mlir/Dialect/SPIRV/TargetAndABI.h
mlir/include/mlir/Dialect/SPIRV/TargetAndABI.td
mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.cpp
mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp
mlir/lib/Dialect/SPIRV/SPIRVDialect.cpp
mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp
mlir/lib/Dialect/SPIRV/TargetAndABI.cpp
mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp
mlir/test/Dialect/SPIRV/TestAvailability.cpp
mlir/test/Dialect/SPIRV/target-and-abi.mlir
mlir/test/Dialect/SPIRV/target-env.mlir [new file with mode: 0644]