[mlir][spirv] NFC: Shuffle code around to better follow convention
authorLei Zhang <antiagainst@google.com>
Thu, 17 Dec 2020 15:55:45 +0000 (10:55 -0500)
committerLei Zhang <antiagainst@google.com>
Thu, 17 Dec 2020 16:03:26 +0000 (11:03 -0500)
This commit shuffles SPIR-V code around to better follow MLIR
convention. Specifically,

* Created IR/, Transforms/, Linking/, and Utils/ subdirectories and
  moved suitable code inside.
* Created SPIRVEnums.{h|cpp} for SPIR-V C/C++ enums generated from
  SPIR-V spec. Previously they are cluttered inside SPIRVTypes.{h|cpp}.
* Fixed include guards in various header files (both .h and .td).
* Moved serialization tests under test/Target/SPIRV.
* Renamed TableGen backend -gen-spirv-op-utils into -gen-spirv-attr-utils
  as it is only generating utility functions for attributes.

Reviewed By: mravishankar

Differential Revision: https://reviews.llvm.org/D93407

144 files changed:
mlir/docs/Dialects/SPIR-V.md
mlir/include/mlir/Dialect/SPIRV/CMakeLists.txt
mlir/include/mlir/Dialect/SPIRV/IR/CMakeLists.txt [new file with mode: 0644]
mlir/include/mlir/Dialect/SPIRV/IR/ParserUtils.h [moved from mlir/include/mlir/Dialect/SPIRV/ParserUtils.h with 87% similarity]
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVArithmeticOps.td [moved from mlir/include/mlir/Dialect/SPIRV/SPIRVArithmeticOps.td with 98% similarity]
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td [moved from mlir/include/mlir/Dialect/SPIRV/SPIRVAtomicOps.td with 99% similarity]
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAttributes.h [moved from mlir/include/mlir/Dialect/SPIRV/SPIRVAttributes.h with 91% similarity]
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAvailability.td [moved from mlir/include/mlir/Dialect/SPIRV/SPIRVAvailability.td with 96% similarity]
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td [moved from mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td with 99% similarity]
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBitOps.td [moved from mlir/include/mlir/Dialect/SPIRV/SPIRVBitOps.td with 99% similarity]
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCastOps.td [moved from mlir/include/mlir/Dialect/SPIRV/SPIRVCastOps.td with 98% similarity]
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCompositeOps.td [moved from mlir/include/mlir/Dialect/SPIRV/SPIRVCompositeOps.td with 97% similarity]
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVControlFlowOps.td [moved from mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td with 98% similarity]
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCooperativeMatrixOps.td [moved from mlir/include/mlir/Dialect/SPIRV/SPIRVCooperativeMatrixOps.td with 98% similarity]
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVDialect.h [moved from mlir/include/mlir/Dialect/SPIRV/SPIRVDialect.h with 77% similarity]
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVEnums.h [new file with mode: 0644]
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVGLSLOps.td [moved from mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td with 99% similarity]
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVGroupOps.td [moved from mlir/include/mlir/Dialect/SPIRV/SPIRVGroupOps.td with 98% similarity]
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVLogicalOps.td [moved from mlir/include/mlir/Dialect/SPIRV/SPIRVLogicalOps.td with 99% similarity]
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVMatrixOps.td [moved from mlir/include/mlir/Dialect/SPIRV/SPIRVMatrixOps.td with 97% similarity]
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVModule.h [moved from mlir/include/mlir/Dialect/SPIRV/SPIRVModule.h with 82% similarity]
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVNonUniformOps.td [moved from mlir/include/mlir/Dialect/SPIRV/SPIRVNonUniformOps.td with 99% similarity]
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVOCLOps.td [moved from mlir/include/mlir/Dialect/SPIRV/SPIRVOCLOps.td with 96% similarity]
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVOps.h [moved from mlir/include/mlir/Dialect/SPIRV/SPIRVOps.h with 78% similarity]
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVOps.td [moved from mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td with 94% similarity]
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td [moved from mlir/include/mlir/Dialect/SPIRV/SPIRVStructureOps.td with 99% similarity]
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVTypes.h [moved from mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h with 89% similarity]
mlir/include/mlir/Dialect/SPIRV/IR/TargetAndABI.h [moved from mlir/include/mlir/Dialect/SPIRV/TargetAndABI.h with 96% similarity]
mlir/include/mlir/Dialect/SPIRV/IR/TargetAndABI.td [moved from mlir/include/mlir/Dialect/SPIRV/TargetAndABI.td with 95% similarity]
mlir/include/mlir/Dialect/SPIRV/Linking/ModuleCombiner.h [moved from mlir/include/mlir/Dialect/SPIRV/ModuleCombiner.h with 93% similarity]
mlir/include/mlir/Dialect/SPIRV/Transforms/CMakeLists.txt [new file with mode: 0644]
mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.h [moved from mlir/include/mlir/Dialect/SPIRV/Passes.h with 87% similarity]
mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.td [moved from mlir/include/mlir/Dialect/SPIRV/Passes.td with 91% similarity]
mlir/include/mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h [moved from mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h with 92% similarity]
mlir/include/mlir/Dialect/SPIRV/Utils/LayoutUtils.h [moved from mlir/include/mlir/Dialect/SPIRV/LayoutUtils.h with 92% similarity]
mlir/include/mlir/InitAllDialects.h
mlir/include/mlir/InitAllPasses.h
mlir/include/mlir/Target/SPIRV/SPIRVBinaryUtils.h
mlir/lib/Conversion/GPUToSPIRV/CMakeLists.txt
mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp
mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.cpp
mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.td
mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp
mlir/lib/Conversion/LinalgToSPIRV/CMakeLists.txt
mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp
mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.cpp
mlir/lib/Conversion/SCFToSPIRV/CMakeLists.txt
mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp
mlir/lib/Conversion/SPIRVToLLVM/CMakeLists.txt
mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp
mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp
mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVMPass.cpp
mlir/lib/Conversion/StandardToSPIRV/CMakeLists.txt
mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp
mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp
mlir/lib/Conversion/VectorToSPIRV/CMakeLists.txt
mlir/lib/Conversion/VectorToSPIRV/VectorToSPIRV.cpp
mlir/lib/Dialect/SPIRV/CMakeLists.txt
mlir/lib/Dialect/SPIRV/IR/CMakeLists.txt [new file with mode: 0644]
mlir/lib/Dialect/SPIRV/IR/SPIRVAttributes.cpp [moved from mlir/lib/Dialect/SPIRV/SPIRVAttributes.cpp with 96% similarity]
mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.cpp [moved from mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.cpp with 99% similarity]
mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.td [moved from mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.td with 97% similarity]
mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp [moved from mlir/lib/Dialect/SPIRV/SPIRVDialect.cpp with 99% similarity]
mlir/lib/Dialect/SPIRV/IR/SPIRVEnums.cpp [new file with mode: 0644]
mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp [moved from mlir/lib/Dialect/SPIRV/SPIRVOps.cpp with 99% similarity]
mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp [moved from mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp with 91% similarity]
mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp [moved from mlir/lib/Dialect/SPIRV/TargetAndABI.cpp with 98% similarity]
mlir/lib/Dialect/SPIRV/Linking/ModuleCombiner/ModuleCombiner.cpp
mlir/lib/Dialect/SPIRV/Transforms/CMakeLists.txt
mlir/lib/Dialect/SPIRV/Transforms/DecorateCompositeTypeLayoutPass.cpp [moved from mlir/lib/Dialect/SPIRV/Transforms/DecorateSPIRVCompositeTypeLayoutPass.cpp with 93% similarity]
mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp
mlir/lib/Dialect/SPIRV/Transforms/PassDetail.h
mlir/lib/Dialect/SPIRV/Transforms/RewriteInsertsPass.cpp
mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp [moved from mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp with 99% similarity]
mlir/lib/Dialect/SPIRV/Transforms/UpdateVCEPass.cpp
mlir/lib/Dialect/SPIRV/Utils/CMakeLists.txt [new file with mode: 0644]
mlir/lib/Dialect/SPIRV/Utils/LayoutUtils.cpp [moved from mlir/lib/Dialect/SPIRV/LayoutUtils.cpp with 97% similarity]
mlir/lib/Target/SPIRV/Deserialization.cpp
mlir/lib/Target/SPIRV/SPIRVBinaryUtils.cpp
mlir/lib/Target/SPIRV/Serialization.cpp
mlir/lib/Target/SPIRV/TranslateRegistration.cpp
mlir/test/Dialect/SPIRV/IR/arithmetic-ops.mlir [moved from mlir/test/Dialect/SPIRV/arithmetic-ops.mlir with 100% similarity]
mlir/test/Dialect/SPIRV/IR/atomic-ops.mlir [moved from mlir/test/Dialect/SPIRV/atomic-ops.mlir with 100% similarity]
mlir/test/Dialect/SPIRV/IR/availability.mlir [moved from mlir/test/Dialect/SPIRV/availability.mlir with 100% similarity]
mlir/test/Dialect/SPIRV/IR/bit-ops.mlir [moved from mlir/test/Dialect/SPIRV/bit-ops.mlir with 100% similarity]
mlir/test/Dialect/SPIRV/IR/composite-ops.mlir [moved from mlir/test/Dialect/SPIRV/composite-ops.mlir with 100% similarity]
mlir/test/Dialect/SPIRV/IR/control-flow-ops.mlir [moved from mlir/test/Dialect/SPIRV/control-flow-ops.mlir with 100% similarity]
mlir/test/Dialect/SPIRV/IR/cooperative-matrix-ops.mlir [moved from mlir/test/Dialect/SPIRV/cooperative-matrix.mlir with 100% similarity]
mlir/test/Dialect/SPIRV/IR/glsl-ops.mlir [moved from mlir/test/Dialect/SPIRV/glslops.mlir with 100% similarity]
mlir/test/Dialect/SPIRV/IR/group-ops.mlir [moved from mlir/test/Dialect/SPIRV/group-ops.mlir with 100% similarity]
mlir/test/Dialect/SPIRV/IR/logical-ops.mlir [moved from mlir/test/Dialect/SPIRV/logical-ops.mlir with 100% similarity]
mlir/test/Dialect/SPIRV/IR/matrix-ops.mlir [moved from mlir/test/Dialect/SPIRV/matrix-ops.mlir with 100% similarity]
mlir/test/Dialect/SPIRV/IR/non-uniform-ops.mlir [moved from mlir/test/Dialect/SPIRV/non-uniform-ops.mlir with 100% similarity]
mlir/test/Dialect/SPIRV/IR/ocl-ops.mlir [moved from mlir/test/Dialect/SPIRV/ocl-ops.mlir with 100% similarity]
mlir/test/Dialect/SPIRV/IR/ops.mlir [moved from mlir/test/Dialect/SPIRV/ops.mlir with 100% similarity]
mlir/test/Dialect/SPIRV/IR/structure-ops.mlir [moved from mlir/test/Dialect/SPIRV/structure-ops.mlir with 100% similarity]
mlir/test/Dialect/SPIRV/IR/target-and-abi.mlir [moved from mlir/test/Dialect/SPIRV/target-and-abi.mlir with 100% similarity]
mlir/test/Dialect/SPIRV/IR/target-env.mlir [moved from mlir/test/Dialect/SPIRV/target-env.mlir with 100% similarity]
mlir/test/Dialect/SPIRV/IR/types.mlir [moved from mlir/test/Dialect/SPIRV/types.mlir with 100% similarity]
mlir/test/Dialect/SPIRV/Linking/ModuleCombiner/conflict-resolution.mlir [moved from mlir/test/Dialect/SPIRV/Linking/ModuleCombiner/conflict_resolution.mlir with 100% similarity]
mlir/test/Dialect/SPIRV/Linking/ModuleCombiner/deduplication.mlir [moved from mlir/test/Dialect/SPIRV/Linking/ModuleCombiner/deduplication_basic.mlir with 100% similarity]
mlir/test/Dialect/SPIRV/Transforms/canonicalize.mlir [moved from mlir/test/Dialect/SPIRV/canonicalize.mlir with 100% similarity]
mlir/test/Target/SPIRV/arithmetic-ops.mlir [moved from mlir/test/Dialect/SPIRV/Serialization/arithmetic-ops.mlir with 100% similarity]
mlir/test/Target/SPIRV/array.mlir [moved from mlir/test/Dialect/SPIRV/Serialization/array.mlir with 100% similarity]
mlir/test/Target/SPIRV/atomic-ops.mlir [moved from mlir/test/Dialect/SPIRV/Serialization/atomic-ops.mlir with 100% similarity]
mlir/test/Target/SPIRV/barrier.mlir [moved from mlir/test/Dialect/SPIRV/Serialization/barrier.mlir with 100% similarity]
mlir/test/Target/SPIRV/bit-ops.mlir [moved from mlir/test/Dialect/SPIRV/Serialization/bit-ops.mlir with 100% similarity]
mlir/test/Target/SPIRV/cast-ops.mlir [moved from mlir/test/Dialect/SPIRV/Serialization/cast-ops.mlir with 100% similarity]
mlir/test/Target/SPIRV/composite-op.mlir [moved from mlir/test/Dialect/SPIRV/Serialization/composite-op.mlir with 100% similarity]
mlir/test/Target/SPIRV/constant.mlir [moved from mlir/test/Dialect/SPIRV/Serialization/constant.mlir with 100% similarity]
mlir/test/Target/SPIRV/cooperative-matrix-ops.mlir [moved from mlir/test/Dialect/SPIRV/Serialization/cooperative-matrix.mlir with 100% similarity]
mlir/test/Target/SPIRV/debug.mlir [moved from mlir/test/Dialect/SPIRV/Serialization/debug.mlir with 100% similarity]
mlir/test/Target/SPIRV/decorations.mlir [moved from mlir/test/Dialect/SPIRV/Serialization/decorations.mlir with 100% similarity]
mlir/test/Target/SPIRV/entry-point.mlir [moved from mlir/test/Dialect/SPIRV/Serialization/entry-point.mlir with 100% similarity]
mlir/test/Target/SPIRV/execution-mode.mlir [moved from mlir/test/Dialect/SPIRV/Serialization/execution-mode.mlir with 100% similarity]
mlir/test/Target/SPIRV/function-call.mlir [moved from mlir/test/Dialect/SPIRV/Serialization/function-call.mlir with 100% similarity]
mlir/test/Target/SPIRV/global-variable.mlir [moved from mlir/test/Dialect/SPIRV/Serialization/global-variable.mlir with 100% similarity]
mlir/test/Target/SPIRV/glsl-ops.mlir [moved from mlir/test/Dialect/SPIRV/Serialization/glsl-ops.mlir with 100% similarity]
mlir/test/Target/SPIRV/group-ops.mlir [moved from mlir/test/Dialect/SPIRV/Serialization/group-ops.mlir with 100% similarity]
mlir/test/Target/SPIRV/logical-ops.mlir [moved from mlir/test/Dialect/SPIRV/Serialization/logical-ops.mlir with 100% similarity]
mlir/test/Target/SPIRV/loop.mlir [moved from mlir/test/Dialect/SPIRV/Serialization/loop.mlir with 100% similarity]
mlir/test/Target/SPIRV/matrix.mlir [moved from mlir/test/Dialect/SPIRV/Serialization/matrix.mlir with 100% similarity]
mlir/test/Target/SPIRV/memory-ops.mlir [moved from mlir/test/Dialect/SPIRV/Serialization/memory-ops.mlir with 100% similarity]
mlir/test/Target/SPIRV/module.mlir [moved from mlir/test/Dialect/SPIRV/Serialization/module.mlir with 100% similarity]
mlir/test/Target/SPIRV/non-uniform-ops.mlir [moved from mlir/test/Dialect/SPIRV/Serialization/non-uniform-ops.mlir with 100% similarity]
mlir/test/Target/SPIRV/ocl-ops.mlir [moved from mlir/test/Dialect/SPIRV/Serialization/ocl-ops.mlir with 100% similarity]
mlir/test/Target/SPIRV/phi.mlir [moved from mlir/test/Dialect/SPIRV/Serialization/phi.mlir with 100% similarity]
mlir/test/Target/SPIRV/selection.mlir [moved from mlir/test/Dialect/SPIRV/Serialization/selection.mlir with 100% similarity]
mlir/test/Target/SPIRV/spec-constant.mlir [moved from mlir/test/Dialect/SPIRV/Serialization/spec-constant.mlir with 100% similarity]
mlir/test/Target/SPIRV/struct.mlir [moved from mlir/test/Dialect/SPIRV/Serialization/struct.mlir with 100% similarity]
mlir/test/Target/SPIRV/terminator.mlir [moved from mlir/test/Dialect/SPIRV/Serialization/terminator.mlir with 100% similarity]
mlir/test/Target/SPIRV/undef.mlir [moved from mlir/test/Dialect/SPIRV/Serialization/undef.mlir with 100% similarity]
mlir/test/lib/Dialect/SPIRV/CMakeLists.txt
mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp
mlir/test/lib/Dialect/SPIRV/TestEntryPointAbi.cpp
mlir/test/lib/Dialect/SPIRV/TestModuleCombiner.cpp
mlir/test/lib/Transforms/TestGpuMemoryPromotion.cpp
mlir/tools/mlir-spirv-cpu-runner/CMakeLists.txt
mlir/tools/mlir-spirv-cpu-runner/mlir-spirv-cpu-runner.cpp
mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp
mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp
mlir/unittests/Dialect/SPIRV/SerializationTest.cpp

index 3432ddf..f30d82f 100644 (file)
@@ -1149,12 +1149,13 @@ These dialect to dialect conversions have their dedicated libraries,
 
 There are also common utilities when targeting SPIR-V from any dialect:
 
-*   [include/mlir/Dialect/SPIRV/Passes.h][MlirSpirvPasses] contains SPIR-V
-    specific analyses and transformations.
-*   [include/mlir/Dialect/SPIRV/SPIRVLowering.h][MlirSpirvLowering] contains
-    type converters and other utility functions.
+*   [include/mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h][MlirSpirvConversion]
+    contains type converters and other utility functions.
+*   [include/mlir/Dialect/SPIRV/Transforms/Passes.h][MlirSpirvPasses] contains
+    SPIR-V specific analyses and transformations.
 
-These common utilities are implemented in the `MLIRSPIRVTransforms` library.
+These common utilities are implemented in the `MLIRSPIRVConversion` and
+`MLIRSPIRVTransforms` library, respectively.
 
 ## Rationale
 
@@ -1406,15 +1407,15 @@ dialect.
 [MlirGpuToSpirvLibs]: https://github.com/llvm/llvm-project/tree/master/mlir/lib/Conversion/GPUToSPIRV
 [MlirStdToSpirvHeaders]: https://github.com/llvm/llvm-project/tree/master/mlir/include/mlir/Conversion/StandardToSPIRV
 [MlirStdToSpirvLibs]: https://github.com/llvm/llvm-project/tree/master/mlir/lib/Conversion/StandardToSPIRV
-[MlirSpirvDialect]: https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Dialect/SPIRV/SPIRVDialect.h
-[MlirSpirvTypes]: https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h
-[MlirSpirvOpsH]: https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.h
-[MlirSpirvSerialization]: https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Dialect/SPIRV/Serialization.h
-[MlirSpirvBase]: https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td
-[MlirSpirvPasses]: https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Dialect/SPIRV/Passes.h
-[MlirSpirvLowering]: https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h
-[MlirSpirvAbi]: https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Dialect/SPIRV/TargetAndABI.h
-[MlirSpirvOpsCpp]: https://github.com/llvm/llvm-project/blob/master/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
+[MlirSpirvDialect]: https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVDialect.h
+[MlirSpirvTypes]: https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVTypes.h
+[MlirSpirvOpsH]: https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVOps.h
+[MlirSpirvSerialization]: https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Target/SPIRV/Serialization.h
+[MlirSpirvBase]: https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td
+[MlirSpirvPasses]: https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.h
+[MlirSpirvConversion]: https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h
+[MlirSpirvAbi]: https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Dialect/SPIRV/IR/TargetAndABI.h
+[MlirSpirvOpsCpp]: https://github.com/llvm/llvm-project/blob/master/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
 [GitHubDialectTracking]: https://github.com/tensorflow/mlir/issues/302
 [GitHubLoweringTracking]: https://github.com/tensorflow/mlir/issues/303
 [GenSpirvUtilsPy]: https://github.com/llvm/llvm-project/blob/master/mlir/utils/spirv/gen_spirv_dialect.py
index ff078ef..9f57627 100644 (file)
@@ -1,45 +1,2 @@
-add_mlir_dialect(SPIRVOps spv)
-add_mlir_doc(SPIRVOps -gen-op-doc SPIRVOps Dialects/)
-
-set(LLVM_TARGET_DEFINITIONS SPIRVBase.td)
-mlir_tablegen(SPIRVEnums.h.inc -gen-enum-decls)
-mlir_tablegen(SPIRVEnums.cpp.inc -gen-enum-defs)
-add_public_tablegen_target(MLIRSPIRVEnumsIncGen)
-add_dependencies(mlir-headers MLIRSPIRVEnumsIncGen)
-
-set(LLVM_TARGET_DEFINITIONS SPIRVBase.td)
-mlir_tablegen(SPIRVEnumAvailability.h.inc -gen-spirv-enum-avail-decls)
-mlir_tablegen(SPIRVEnumAvailability.cpp.inc -gen-spirv-enum-avail-defs)
-mlir_tablegen(SPIRVCapabilityImplication.inc -gen-spirv-capability-implication)
-add_public_tablegen_target(MLIRSPIRVEnumAvailabilityIncGen)
-add_dependencies(mlir-headers MLIRSPIRVEnumAvailabilityIncGen)
-
-set(LLVM_TARGET_DEFINITIONS SPIRVOps.td)
-mlir_tablegen(SPIRVAvailability.h.inc -gen-avail-interface-decls)
-mlir_tablegen(SPIRVAvailability.cpp.inc -gen-avail-interface-defs)
-mlir_tablegen(SPIRVOpAvailabilityImpl.inc -gen-spirv-avail-impls)
-add_public_tablegen_target(MLIRSPIRVAvailabilityIncGen)
-add_dependencies(mlir-headers MLIRSPIRVAvailabilityIncGen)
-
-set(LLVM_TARGET_DEFINITIONS SPIRVOps.td)
-mlir_tablegen(SPIRVSerialization.inc -gen-spirv-serialization)
-add_public_tablegen_target(MLIRSPIRVSerializationGen)
-add_dependencies(mlir-headers MLIRSPIRVSerializationGen)
-
-set(LLVM_TARGET_DEFINITIONS SPIRVBase.td)
-mlir_tablegen(SPIRVOpUtils.inc -gen-spirv-op-utils)
-add_public_tablegen_target(MLIRSPIRVOpUtilsGen)
-add_dependencies(mlir-headers MLIRSPIRVOpUtilsGen)
-
-set(LLVM_TARGET_DEFINITIONS TargetAndABI.td)
-mlir_tablegen(TargetAndABI.h.inc -gen-struct-attr-decls)
-mlir_tablegen(TargetAndABI.cpp.inc -gen-struct-attr-defs)
-add_public_tablegen_target(MLIRSPIRVTargetAndABIIncGen)
-add_dependencies(mlir-headers MLIRSPIRVTargetAndABIIncGen)
-
-set(LLVM_TARGET_DEFINITIONS Passes.td)
-mlir_tablegen(Passes.h.inc -gen-pass-decls -name SPIRV)
-add_public_tablegen_target(MLIRSPIRVPassIncGen)
-add_dependencies(mlir-headers MLIRSPIRVPassIncGen)
-
-add_mlir_doc(Passes -gen-pass-doc SPIRVPasses ./)
+add_subdirectory(IR)
+add_subdirectory(Transforms)
diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/CMakeLists.txt b/mlir/include/mlir/Dialect/SPIRV/IR/CMakeLists.txt
new file mode 100644 (file)
index 0000000..9b0f7ba
--- /dev/null
@@ -0,0 +1,38 @@
+add_mlir_dialect(SPIRVOps spv)
+add_mlir_doc(SPIRVOps -gen-op-doc SPIRVOps Dialects/)
+
+set(LLVM_TARGET_DEFINITIONS SPIRVBase.td)
+mlir_tablegen(SPIRVEnums.h.inc -gen-enum-decls)
+mlir_tablegen(SPIRVEnums.cpp.inc -gen-enum-defs)
+add_public_tablegen_target(MLIRSPIRVEnumsIncGen)
+add_dependencies(mlir-headers MLIRSPIRVEnumsIncGen)
+
+set(LLVM_TARGET_DEFINITIONS SPIRVBase.td)
+mlir_tablegen(SPIRVEnumAvailability.h.inc -gen-spirv-enum-avail-decls)
+mlir_tablegen(SPIRVEnumAvailability.cpp.inc -gen-spirv-enum-avail-defs)
+mlir_tablegen(SPIRVCapabilityImplication.inc -gen-spirv-capability-implication)
+add_public_tablegen_target(MLIRSPIRVEnumAvailabilityIncGen)
+add_dependencies(mlir-headers MLIRSPIRVEnumAvailabilityIncGen)
+
+set(LLVM_TARGET_DEFINITIONS SPIRVOps.td)
+mlir_tablegen(SPIRVAvailability.h.inc -gen-avail-interface-decls)
+mlir_tablegen(SPIRVAvailability.cpp.inc -gen-avail-interface-defs)
+mlir_tablegen(SPIRVOpAvailabilityImpl.inc -gen-spirv-avail-impls)
+add_public_tablegen_target(MLIRSPIRVAvailabilityIncGen)
+add_dependencies(mlir-headers MLIRSPIRVAvailabilityIncGen)
+
+set(LLVM_TARGET_DEFINITIONS SPIRVOps.td)
+mlir_tablegen(SPIRVSerialization.inc -gen-spirv-serialization)
+add_public_tablegen_target(MLIRSPIRVSerializationGen)
+add_dependencies(mlir-headers MLIRSPIRVSerializationGen)
+
+set(LLVM_TARGET_DEFINITIONS SPIRVBase.td)
+mlir_tablegen(SPIRVAttrUtils.inc -gen-spirv-attr-utils)
+add_public_tablegen_target(MLIRSPIRVAttrUtilsGen)
+add_dependencies(mlir-headers MLIRSPIRVAttrUtilsGen)
+
+set(LLVM_TARGET_DEFINITIONS TargetAndABI.td)
+mlir_tablegen(TargetAndABI.h.inc -gen-struct-attr-decls)
+mlir_tablegen(TargetAndABI.cpp.inc -gen-struct-attr-defs)
+add_public_tablegen_target(MLIRSPIRVTargetAndABIIncGen)
+add_dependencies(mlir-headers MLIRSPIRVTargetAndABIIncGen)
 // dialect.
 //
 //===----------------------------------------------------------------------===//
-#ifndef MLIR_DIALECT_SPIRV_PARSERUTILS_H_
-#define MLIR_DIALECT_SPIRV_PARSERUTILS_H_
 
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
+#ifndef MLIR_DIALECT_SPIRV_IR_PARSERUTILS_H_
+#define MLIR_DIALECT_SPIRV_IR_PARSERUTILS_H_
+
+#include "mlir/Dialect/SPIRV/IR/SPIRVAttributes.h"
 #include "mlir/IR/OpDefinition.h"
 #include "mlir/IR/OpImplementation.h"
 
 namespace mlir {
+
 /// Parses the next keyword in `parser` as an enumerant of the given
 /// `EnumClass`.
 template <typename EnumClass, typename ParserType>
@@ -36,6 +38,7 @@ parseEnumKeywordAttr(EnumClass &value, ParserType &parser,
   return parser.emitError(loc, "invalid ")
          << attrName << " attribute specification: " << keyword;
 }
+
 } // namespace mlir
 
-#endif // MLIR_DIALECT_SPIRV_PARSERUTILS_H_
+#endif // MLIR_DIALECT_SPIRV_IR_PARSERUTILS_H_
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef SPIRV_ARITHMETIC_OPS
-#define SPIRV_ARITHMETIC_OPS
+#ifndef MLIR_DIALECT_SPIRV_IR_ARITHMETIC_OPS
+#define MLIR_DIALECT_SPIRV_IR_ARITHMETIC_OPS
 
-include "mlir/Dialect/SPIRV/SPIRVBase.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
 include "mlir/Interfaces/SideEffectInterfaces.td"
 
 class SPV_ArithmeticBinaryOp<string mnemonic, Type type,
@@ -576,4 +576,4 @@ def SPV_UModOp : SPV_ArithmeticBinaryOp<"UMod", SPV_Integer> {
   }];
 }
 
-#endif // SPIRV_ARITHMETIC_OPS
+#endif // MLIR_DIALECT_SPIRV_IR_ARITHMETIC_OPS
@@ -11,8 +11,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef SPIRV_ATOMIC_OPS
-#define SPIRV_ATOMIC_OPS
+#ifndef MLIR_DIALECT_SPIRV_IR_ATOMIC_OPS
+#define MLIR_DIALECT_SPIRV_IR_ATOMIC_OPS
 
 class SPV_AtomicUpdateOp<string mnemonic, list<OpTrait> traits = []> :
   SPV_Op<mnemonic, traits> {
@@ -564,4 +564,4 @@ def SPV_AtomicXorOp : SPV_AtomicUpdateWithValueOp<"AtomicXor", []> {
 
 // -----
 
-#endif // SPIRV_ATOMIC_OPS
+#endif // MLIR_DIALECT_SPIRV_IR_ATOMIC_OPS
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef MLIR_DIALECT_SPIRV_SPIRVATTRIBUTES_H
-#define MLIR_DIALECT_SPIRV_SPIRVATTRIBUTES_H
+#ifndef MLIR_DIALECT_SPIRV_IR_SPIRVATTRIBUTES_H
+#define MLIR_DIALECT_SPIRV_IR_SPIRVATTRIBUTES_H
 
-#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
 #include "mlir/IR/BuiltinAttributes.h"
 #include "mlir/Support/LLVM.h"
 
-// Pull in SPIR-V attribute definitions for target and ABI.
-#include "mlir/Dialect/SPIRV/TargetAndABI.h.inc"
+// Pull in TableGen'erated SPIR-V attribute definitions for target and ABI.
+#include "mlir/Dialect/SPIRV/IR/TargetAndABI.h.inc"
 
 namespace mlir {
 namespace spirv {
@@ -34,6 +34,14 @@ struct TargetEnvAttributeStorage;
 struct VerCapExtAttributeStorage;
 } // namespace detail
 
+// TableGen'erated helper functions.
+//
+// Get the name used in the Op to refer to an enum value of the given
+// `EnumClass`.
+// template <typename EnumClass> StringRef attributeName();
+//
+#include "mlir/Dialect/SPIRV/IR/SPIRVAttrUtils.inc"
+
 /// An attribute that specifies the information regarding the interface
 /// variable: descriptor set, binding, storage class.
 class InterfaceVarABIAttr
@@ -174,4 +182,4 @@ public:
 } // namespace spirv
 } // namespace mlir
 
-#endif // MLIR_DIALECT_SPIRV_SPIRVATTRIBUTES_H
+#endif // MLIR_DIALECT_SPIRV_IR_SPIRVATTRIBUTES_H
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef SPIRV_AVAILABILITY
-#define SPIRV_AVAILABILITY
+#ifndef MLIR_DIALECT_SPIRV_IR_AVAILABILITY
+#define MLIR_DIALECT_SPIRV_IR_AVAILABILITY
 
 include "mlir/IR/OpBase.td"
 
@@ -86,4 +86,4 @@ class MaxVersionBase<string name, I32EnumAttr scheme, I32EnumAttrCase max>
                  max.symbol;
 }
 
-#endif // SPIRV_AVAILABILITY
+#endif // MLIR_DIALECT_SPIRV_IR_AVAILABILITY
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef SPIRV_BASE
-#define SPIRV_BASE
+#ifndef MLIR_DIALECT_SPIRV_IR_BASE
+#define MLIR_DIALECT_SPIRV_IR_BASE
 
 include "mlir/IR/OpBase.td"
-include "mlir/Dialect/SPIRV/SPIRVAvailability.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVAvailability.td"
 
 //===----------------------------------------------------------------------===//
 // SPIR-V dialect definitions
@@ -3480,4 +3480,4 @@ class SPV_ExtInstOp<string mnemonic, string setPrefix, string setName,
   string extendedInstSetName = setName;
 }
 
-#endif // SPIRV_BASE
+#endif // MLIR_DIALECT_SPIRV_IR_BASE
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef SPIRV_BIT_OPS
-#define SPIRV_BIT_OPS
+#ifndef MLIR_DIALECT_SPIRV_IR_BIT_OPS
+#define MLIR_DIALECT_SPIRV_IR_BIT_OPS
 
-include "mlir/Dialect/SPIRV/SPIRVBase.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
 include "mlir/Interfaces/SideEffectInterfaces.td"
 
 class SPV_BitBinaryOp<string mnemonic, list<OpTrait> traits = []> :
@@ -608,4 +608,4 @@ def SPV_NotOp : SPV_BitUnaryOp<"Not", []> {
   }];
 }
 
-#endif // SPIRV_BIT_OPS
+#endif // MLIR_DIALECT_SPIRV_IR_BIT_OPS
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef SPIRV_CAST_OPS
-#define SPIRV_CAST_OPS
+#ifndef MLIR_DIALECT_SPIRV_IR_CAST_OPS
+#define MLIR_DIALECT_SPIRV_IR_CAST_OPS
 
-include "mlir/Dialect/SPIRV/SPIRVBase.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
 include "mlir/Interfaces/SideEffectInterfaces.td"
 
 class SPV_CastOp<string mnemonic, Type resultType, Type operandType,
@@ -331,4 +331,4 @@ def SPV_UConvertOp : SPV_CastOp<"UConvert", SPV_Integer, SPV_Integer, []> {
   let verifier = [{ return verifyCastOp(this->getOperation(), false); }];
 }
 
-#endif // SPIRV_CAST_OPS
+#endif // MLIR_DIALECT_SPIRV_IR_CAST_OPS
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef SPIRV_COMPOSITE_OPS
-#define SPIRV_COMPOSITE_OPS
+#ifndef MLIR_DIALECT_SPIRV_IR_COMPOSITE_OPS
+#define MLIR_DIALECT_SPIRV_IR_COMPOSITE_OPS
 
-include "mlir/Dialect/SPIRV/SPIRVBase.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
 include "mlir/Interfaces/SideEffectInterfaces.td"
 
 // -----
@@ -289,4 +289,4 @@ def SPV_VectorInsertDynamicOp : SPV_Op<"VectorInsertDynamic",
 
 // -----
 
-#endif // SPIRV_COMPOSITE_OPS
+#endif // MLIR_DIALECT_SPIRV_IR_COMPOSITE_OPS
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef SPIRV_CONTROLFLOW_OPS
-#define SPIRV_CONTROLFLOW_OPS
+#ifndef MLIR_DIALECT_SPIRV_IR_CONTROLFLOW_OPS
+#define MLIR_DIALECT_SPIRV_IR_CONTROLFLOW_OPS
 
-include "mlir/Dialect/SPIRV/SPIRVBase.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
 include "mlir/Interfaces/CallInterfaces.td"
 include "mlir/Interfaces/ControlFlowInterfaces.td"
 include "mlir/Interfaces/SideEffectInterfaces.td"
@@ -472,4 +472,4 @@ def SPV_SelectionOp : SPV_Op<"selection", [InFunctionScope]> {
   let hasCanonicalizer = 1;
 }
 
-#endif // SPIRV_CONTROLFLOW_OPS
+#endif // MLIR_DIALECT_SPIRV_IR_CONTROLFLOW_OPS
@@ -10,8 +10,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef SPIRV_COOPERATIVE_MATRIX_OPS
-#define SPIRV_COOPERATIVE_MATRIX_OPS
+#ifndef MLIR_DIALECT_SPIRV_IR_COOPERATIVE_MATRIX_OPS
+#define MLIR_DIALECT_SPIRV_IR_COOPERATIVE_MATRIX_OPS
 
 // -----
 
@@ -283,4 +283,4 @@ def SPV_CooperativeMatrixStoreNVOp : SPV_Op<"CooperativeMatrixStoreNV", []> {
 
 // -----
 
-#endif // SPIRV_COOPERATIVE_MATRIX_OPS
+#endif // MLIR_DIALECT_SPIRV_IR_COOPERATIVE_MATRIX_OPS
@@ -10,8 +10,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef MLIR_DIALECT_SPIRV_SPIRVDIALECT_H_
-#define MLIR_DIALECT_SPIRV_SPIRVDIALECT_H_
+#ifndef MLIR_DIALECT_SPIRV_IR_SPIRVDIALECT_H_
+#define MLIR_DIALECT_SPIRV_IR_SPIRVDIALECT_H_
 
 #include "mlir/IR/Dialect.h"
 
@@ -23,6 +23,6 @@ enum class Decoration : uint32_t;
 } // end namespace spirv
 } // end namespace mlir
 
-#include "mlir/Dialect/SPIRV/SPIRVOpsDialect.h.inc"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOpsDialect.h.inc"
 
-#endif // MLIR_DIALECT_SPIRV_SPIRVDIALECT_H_
+#endif // MLIR_DIALECT_SPIRV_IR_SPIRVDIALECT_H_
diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVEnums.h b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVEnums.h
new file mode 100644 (file)
index 0000000..e5838ef
--- /dev/null
@@ -0,0 +1,57 @@
+//===- SPIRVEnums.h - MLIR SPIR-V Enums -------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file declares the C/C++ enums from SPIR-V spec.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef MLIR_DIALECT_SPIRV_IR_SPIRVENUMS_H_
+#define MLIR_DIALECT_SPIRV_IR_SPIRVENUMS_H_
+
+#include "mlir/Support/LLVM.h"
+#include "llvm/ADT/DenseMapInfo.h"
+#include "llvm/ADT/StringRef.h"
+
+// Forward declare enum classes related to op availability. Their definitions
+// are in the TableGen'erated SPIRVEnums.h.inc and can be referenced by other
+// declarations in SPIRVEnums.h.inc.
+namespace mlir {
+namespace spirv {
+enum class Version : uint32_t;
+enum class Extension;
+enum class Capability : uint32_t;
+} // namespace spirv
+} // namespace mlir
+
+// Pull in all enum type definitions and utility function declarations
+#include "mlir/Dialect/SPIRV/IR/SPIRVEnums.h.inc"
+
+// Pull in all enum type availability query function declarations
+#include "mlir/Dialect/SPIRV/IR/SPIRVEnumAvailability.h.inc"
+
+namespace mlir {
+namespace spirv {
+/// Returns the implied extensions for the given version. These extensions are
+/// incorporated into the current version so they are implicitly declared when
+/// targeting the given version.
+ArrayRef<Extension> getImpliedExtensions(Version version);
+
+/// Returns the directly implied capabilities for the given capability. These
+/// capabilities are implicitly declared by the given capability.
+ArrayRef<Capability> getDirectImpliedCapabilities(Capability cap);
+/// Returns the recursively implied capabilities for the given capability. These
+/// capabilities are implicitly declared by the given capability. Compared to
+/// the above function, this function collects implied capabilities recursively:
+/// if an implicitly declared capability implicitly declares a third one, the
+/// third one will also be returned.
+SmallVector<Capability, 0> getRecursiveImpliedCapabilities(Capability cap);
+
+} // end namespace spirv
+} // end namespace mlir
+
+#endif // MLIR_DIALECT_SPIRV_IR_SPIRVENUMS_H_
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef SPIRV_GLSL_OPS
-#define SPIRV_GLSL_OPS
+#ifndef MLIR_DIALECT_SPIRV_IR_GLSL_OPS
+#define MLIR_DIALECT_SPIRV_IR_GLSL_OPS
 
-include "mlir/Dialect/SPIRV/SPIRVBase.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
 include "mlir/Interfaces/SideEffectInterfaces.td"
 
 //===----------------------------------------------------------------------===//
@@ -972,4 +972,4 @@ def SPV_GLSLSClampOp : SPV_GLSLTernaryArithmeticOp<"SClamp", 45, SPV_SignedInt>
   }];
 }
 
-#endif // SPIRV_GLSL_OPS
+#endif // MLIR_DIALECT_SPIRV_IR_GLSL_OPS
@@ -12,8 +12,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef SPIRV_GROUP_OPS
-#define SPIRV_GROUP_OPS
+#ifndef MLIR_DIALECT_SPIRV_IR_GROUP_OPS
+#define MLIR_DIALECT_SPIRV_IR_GROUP_OPS
 
 // -----
 
@@ -246,4 +246,4 @@ def SPV_SubgroupBlockWriteINTELOp : SPV_Op<"SubgroupBlockWriteINTEL", []> {
 
 // -----
 
-#endif // SPIRV_GROUP_OPS
+#endif // MLIR_DIALECT_SPIRV_IR_GROUP_OPS
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef SPIRV_LOGICAL_OPS
-#define SPIRV_LOGICAL_OPS
+#ifndef MLIR_DIALECT_SPIRV_IR_LOGICAL_OPS
+#define MLIR_DIALECT_SPIRV_IR_LOGICAL_OPS
 
-include "mlir/Dialect/SPIRV/SPIRVBase.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
 include "mlir/Interfaces/SideEffectInterfaces.td"
 
 class SPV_LogicalBinaryOp<string mnemonic, Type operandsType,
@@ -1002,4 +1002,4 @@ def SPV_ULessThanEqualOp :
   }];
 }
 
-#endif // SPIRV_LOGICAL_OPS
+#endif // MLIR_DIALECT_SPIRV_IR_LOGICAL_OPS
@@ -10,8 +10,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef SPIRV_MATRIX_OPS
-#define SPIRV_MATRIX_OPS
+#ifndef MLIR_DIALECT_SPIRV_IR_MATRIX_OPS
+#define MLIR_DIALECT_SPIRV_IR_MATRIX_OPS
 include "mlir/Interfaces/SideEffectInterfaces.td"
 
 // -----
@@ -188,4 +188,4 @@ def SPV_TransposeOp : SPV_Op<"Transpose", [NoSideEffect]> {
 
 // -----
 
-#endif // SPIRV_MATRIX_OPS
+#endif // MLIR_DIALECT_SPIRV_IR_MATRIX_OPS
@@ -6,10 +6,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef MLIR_DIALECT_SPIRV_SPIRVMODULE_H
-#define MLIR_DIALECT_SPIRV_SPIRVMODULE_H
+#ifndef MLIR_DIALECT_SPIRV_IR_SPIRVMODULE_H
+#define MLIR_DIALECT_SPIRV_IR_SPIRVMODULE_H
 
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
 #include "mlir/IR/OwningOpRef.h"
 
 namespace mlir {
@@ -27,4 +27,4 @@ public:
 } // end namespace spirv
 } // end namespace mlir
 
-#endif // MLIR_DIALECT_SPIRV_SPIRVMODULE_H
+#endif // MLIR_DIALECT_SPIRV_IR_SPIRVMODULE_H
@@ -11,8 +11,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef SPIRV_NON_UNIFORM_OPS
-#define SPIRV_NON_UNIFORM_OPS
+#ifndef MLIR_DIALECT_SPIRV_IR_NON_UNIFORM_OPS
+#define MLIR_DIALECT_SPIRV_IR_NON_UNIFORM_OPS
 
 class SPV_GroupNonUniformArithmeticOp<string mnemonic, Type type,
       list<OpTrait> traits = []> : SPV_Op<mnemonic, traits> {
@@ -730,4 +730,4 @@ def SPV_GroupNonUniformUMinOp :
 
 // -----
 
-#endif // SPIRV_NON_UNIFORM_OPS
+#endif // MLIR_DIALECT_SPIRV_IR_NON_UNIFORM_OPS
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef SPIRV_OCL_OPS
-#define SPIRV_OCL_OPS
+#ifndef MLIR_DIALECT_SPIRV_IR_OCL_OPS
+#define MLIR_DIALECT_SPIRV_IR_OCL_OPS
 
-include "mlir/Dialect/SPIRV/SPIRVBase.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
 
 //===----------------------------------------------------------------------===//
 // SPIR-V OpenCL opcode specification.
@@ -166,4 +166,4 @@ def SPV_OCLSAbsOp : SPV_OCLUnaryArithmeticOp<"s_abs", 141, SPV_Integer> {
   }];
 }
 
-#endif // SPIRV_OCL_OPS
+#endif // MLIR_DIALECT_SPIRV_IR_OCL_OPS
similarity index 78%
rename from mlir/include/mlir/Dialect/SPIRV/SPIRVOps.h
rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVOps.h
index ae576d9..5e9a46d 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef MLIR_DIALECT_SPIRV_SPIRVOPS_H_
-#define MLIR_DIALECT_SPIRV_SPIRVOPS_H_
+#ifndef MLIR_DIALECT_SPIRV_IR_SPIRVOPS_H_
+#define MLIR_DIALECT_SPIRV_IR_SPIRVOPS_H_
 
-#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
 #include "mlir/IR/BuiltinOps.h"
 #include "mlir/Interfaces/ControlFlowInterfaces.h"
 #include "mlir/Interfaces/SideEffectInterfaces.h"
@@ -27,26 +27,13 @@ class VerCapExtAttr;
 
 // TableGen'erated operation interfaces for querying versions, extensions, and
 // capabilities.
-#include "mlir/Dialect/SPIRV/SPIRVAvailability.h.inc"
+#include "mlir/Dialect/SPIRV/IR/SPIRVAvailability.h.inc"
 } // namespace spirv
 } // namespace mlir
 
 // TablenGen'erated operation declarations.
 #define GET_OP_CLASSES
-#include "mlir/Dialect/SPIRV/SPIRVOps.h.inc"
-
-namespace mlir {
-namespace spirv {
-// TableGen'erated helper functions.
-//
-// Get the name used in the Op to refer to an enum value of the given
-// `EnumClass`.
-// template <typename EnumClass> StringRef attributeName();
-//
-#include "mlir/Dialect/SPIRV/SPIRVOpUtils.inc"
-
-} // end namespace spirv
-} // end namespace mlir
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h.inc"
 
 namespace llvm {
 
@@ -84,4 +71,4 @@ public:
 
 } // namespace llvm
 
-#endif // MLIR_DIALECT_SPIRV_SPIRVOPS_H_
+#endif // MLIR_DIALECT_SPIRV_IR_SPIRVOPS_H_
similarity index 94%
rename from mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td
rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVOps.td
index 3fc60d0..3621ff7 100644 (file)
 // results, and sections after the results are retained. Besides, ops must be
 // separated via the '// -----' marker.
 
-#ifndef SPIRV_OPS
-#define SPIRV_OPS
-
-include "mlir/Dialect/SPIRV/SPIRVBase.td"
-include "mlir/Dialect/SPIRV/SPIRVArithmeticOps.td"
-include "mlir/Dialect/SPIRV/SPIRVAtomicOps.td"
-include "mlir/Dialect/SPIRV/SPIRVBitOps.td"
-include "mlir/Dialect/SPIRV/SPIRVCastOps.td"
-include "mlir/Dialect/SPIRV/SPIRVCompositeOps.td"
-include "mlir/Dialect/SPIRV/SPIRVControlFlowOps.td"
-include "mlir/Dialect/SPIRV/SPIRVCooperativeMatrixOps.td"
-include "mlir/Dialect/SPIRV/SPIRVGLSLOps.td"
-include "mlir/Dialect/SPIRV/SPIRVGroupOps.td"
-include "mlir/Dialect/SPIRV/SPIRVLogicalOps.td"
-include "mlir/Dialect/SPIRV/SPIRVMatrixOps.td"
-include "mlir/Dialect/SPIRV/SPIRVNonUniformOps.td"
-include "mlir/Dialect/SPIRV/SPIRVOCLOps.td"
-include "mlir/Dialect/SPIRV/SPIRVStructureOps.td"
+#ifndef MLIR_DIALECT_SPIRV_IR_OPS
+#define MLIR_DIALECT_SPIRV_IR_OPS
+
+include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVArithmeticOps.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVBitOps.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVCastOps.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVCompositeOps.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVControlFlowOps.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVCooperativeMatrixOps.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVGLSLOps.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVGroupOps.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVLogicalOps.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVMatrixOps.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVNonUniformOps.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVOCLOps.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td"
 include "mlir/Interfaces/SideEffectInterfaces.td"
 
 // -----
@@ -529,4 +529,4 @@ def SPV_VariableOp : SPV_Op<"Variable", []> {
 
 // -----
 
-#endif // SPIRV_OPS
+#endif // MLIR_DIALECT_SPIRV_IR_OPS
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef SPIRV_STRUCTURE_OPS
-#define SPIRV_STRUCTURE_OPS
+#ifndef MLIR_DIALECT_SPIRV_IR_STRUCTURE_OPS
+#define MLIR_DIALECT_SPIRV_IR_STRUCTURE_OPS
 
-include "mlir/Dialect/SPIRV/SPIRVBase.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
 include "mlir/IR/SymbolInterfaces.td"
 include "mlir/Interfaces/CallInterfaces.td"
 include "mlir/Interfaces/SideEffectInterfaces.td"
@@ -734,4 +734,4 @@ def SPV_SpecConstantOperationOp : SPV_Op<"SpecConstantOperation", [
 
 // -----
 
-#endif // SPIRV_STRUCTURE_OPS
+#endif // MLIR_DIALECT_SPIRV_IR_STRUCTURE_OPS
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef MLIR_DIALECT_SPIRV_SPIRVTYPES_H_
-#define MLIR_DIALECT_SPIRV_SPIRVTYPES_H_
+#ifndef MLIR_DIALECT_SPIRV_IR_SPIRVTYPES_H_
+#define MLIR_DIALECT_SPIRV_IR_SPIRVTYPES_H_
 
+#include "mlir/Dialect/SPIRV/IR/SPIRVEnums.h"
 #include "mlir/IR/BuiltinTypes.h"
 #include "mlir/IR/Diagnostics.h"
 #include "mlir/IR/Location.h"
 
 #include <tuple>
 
-// Forward declare enum classes related to op availability. Their definitions
-// are in the TableGen'erated SPIRVEnums.h.inc and can be referenced by other
-// declarations in SPIRVEnums.h.inc.
 namespace mlir {
 namespace spirv {
-enum class Version : uint32_t;
-enum class Extension;
-enum class Capability : uint32_t;
-} // namespace spirv
-} // namespace mlir
-
-// Pull in all enum type definitions and utility function declarations
-#include "mlir/Dialect/SPIRV/SPIRVEnums.h.inc"
-// Pull in all enum type availability query function declarations
-#include "mlir/Dialect/SPIRV/SPIRVEnumAvailability.h.inc"
-
-namespace mlir {
-namespace spirv {
-/// Returns the implied extensions for the given version. These extensions are
-/// incorporated into the current version so they are implicitly declared when
-/// targeting the given version.
-ArrayRef<Extension> getImpliedExtensions(Version version);
-
-/// Returns the directly implied capabilities for the given capability. These
-/// capabilities are implicitly declared by the given capability.
-ArrayRef<Capability> getDirectImpliedCapabilities(Capability cap);
-/// Returns the recursively implied capabilities for the given capability. These
-/// capabilities are implicitly declared by the given capability. Compared to
-/// the above function, this function collects implied capabilities recursively:
-/// if an implicitly declared capability implicitly declares a third one, the
-/// third one will also be returned.
-SmallVector<Capability, 0> getRecursiveImpliedCapabilities(Capability cap);
 
 namespace detail {
 struct ArrayTypeStorage;
@@ -380,9 +351,9 @@ public:
 
   // Returns in `decorationsInfo` all the Decorations (apart from Offset)
   // associated with the `i`-th member of the StructType.
-  void getMemberDecorations(unsigned i,
-                            SmallVectorImpl<StructType::MemberDecorationInfo>
-                                &decorationsInfo) const;
+  void getMemberDecorations(
+      unsigned i,
+      SmallVectorImpl<StructType::MemberDecorationInfo> &decorationsInfo) const;
 
   /// Sets the contents of an incomplete identified StructType. This method must
   /// be called only for identified StructTypes and it must be called only once
@@ -465,4 +436,4 @@ public:
 } // end namespace spirv
 } // end namespace mlir
 
-#endif // MLIR_DIALECT_SPIRV_SPIRVTYPES_H_
+#endif // MLIR_DIALECT_SPIRV_IR_SPIRVTYPES_H_
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef MLIR_DIALECT_SPIRV_TARGETANDABI_H
-#define MLIR_DIALECT_SPIRV_TARGETANDABI_H
+#ifndef MLIR_DIALECT_SPIRV_IR_TARGETANDABI_H
+#define MLIR_DIALECT_SPIRV_IR_TARGETANDABI_H
 
-#include "mlir/Dialect/SPIRV/SPIRVAttributes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVAttributes.h"
 #include "mlir/Support/LLVM.h"
 #include "llvm/ADT/SmallSet.h"
 
@@ -132,4 +132,4 @@ FailureOr<MemoryModel> getMemoryModel(TargetEnvAttr targetAttr);
 } // namespace spirv
 } // namespace mlir
 
-#endif // MLIR_DIALECT_SPIRV_TARGETANDABI_H
+#endif // MLIR_DIALECT_SPIRV_IR_TARGETANDABI_H
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef SPIRV_TARGET_AND_ABI
-#define SPIRV_TARGET_AND_ABI
+#ifndef MLIR_DIALECT_SPIRV_IR_TARGET_AND_ABI
+#define MLIR_DIALECT_SPIRV_IR_TARGET_AND_ABI
 
-include "mlir/Dialect/SPIRV/SPIRVBase.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
 
 // For entry functions, this attribute specifies information related to entry
 // points in the generated SPIR-V module:
@@ -88,4 +88,4 @@ def SPV_ResourceLimitsAttr : StructAttr<"ResourceLimitsAttr", SPIRV_Dialect, [
         DefaultValuedAttr<SPV_CooperativeMatrixPropertiesNVArrayAttr, "{}">>
 ]>;
 
-#endif // SPIRV_TARGET_AND_ABI
+#endif // MLIR_DIALECT_SPIRV_IR_TARGET_AND_ABI
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef MLIR_DIALECT_SPIRV_MODULECOMBINER_H_
-#define MLIR_DIALECT_SPIRV_MODULECOMBINER_H_
+#ifndef MLIR_DIALECT_SPIRV_LINKING_MODULECOMBINER_H_
+#define MLIR_DIALECT_SPIRV_LINKING_MODULECOMBINER_H_
 
-#include "mlir/Dialect/SPIRV/SPIRVModule.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVModule.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallVector.h"
 
@@ -75,4 +75,4 @@ combine(llvm::MutableArrayRef<ModuleOp> modules,
 } // namespace spirv
 } // namespace mlir
 
-#endif // MLIR_DIALECT_SPIRV_MODULECOMBINER_H_
+#endif // MLIR_DIALECT_SPIRV_LINKING_MODULECOMBINER_H_
diff --git a/mlir/include/mlir/Dialect/SPIRV/Transforms/CMakeLists.txt b/mlir/include/mlir/Dialect/SPIRV/Transforms/CMakeLists.txt
new file mode 100644 (file)
index 0000000..f5342e1
--- /dev/null
@@ -0,0 +1,7 @@
+set(LLVM_TARGET_DEFINITIONS Passes.td)
+mlir_tablegen(Passes.h.inc -gen-pass-decls -name SPIRV)
+add_public_tablegen_target(MLIRSPIRVPassIncGen)
+add_dependencies(mlir-headers MLIRSPIRVPassIncGen)
+
+add_mlir_doc(Passes -gen-pass-doc SPIRVPasses ./)
+
@@ -10,8 +10,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef MLIR_DIALECT_SPIRV_PASSES_H_
-#define MLIR_DIALECT_SPIRV_PASSES_H_
+#ifndef MLIR_DIALECT_SPIRV_TRANSFORMS_PASSES_H_
+#define MLIR_DIALECT_SPIRV_TRANSFORMS_PASSES_H_
 
 #include "mlir/Pass/Pass.h"
 
@@ -19,6 +19,11 @@ namespace mlir {
 namespace spirv {
 
 class ModuleOp;
+
+//===----------------------------------------------------------------------===//
+// Passes
+//===----------------------------------------------------------------------===//
+
 /// Creates a module pass that converts composite types used by objects in the
 /// StorageBuffer, PhysicalStorageBuffer, Uniform, and PushConstant storage
 /// classes with layout information.
@@ -56,9 +61,9 @@ std::unique_ptr<OperationPass<spirv::ModuleOp>> createRewriteInsertsPass();
 
 /// Generate the code for registering passes.
 #define GEN_PASS_REGISTRATION
-#include "mlir/Dialect/SPIRV/Passes.h.inc"
+#include "mlir/Dialect/SPIRV/Transforms/Passes.h.inc"
 
 } // namespace spirv
 } // namespace mlir
 
-#endif // MLIR_DIALECT_SPIRV_PASSES_H_
+#endif // MLIR_DIALECT_SPIRV_TRANSFORMS_PASSES_H_
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef MLIR_DIALECT_SPIRV_PASSES
-#define MLIR_DIALECT_SPIRV_PASSES
+#ifndef MLIR_DIALECT_SPIRV_TRANSFORMS_PASSES
+#define MLIR_DIALECT_SPIRV_TRANSFORMS_PASSES
 
 include "mlir/Pass/PassBase.td"
 
@@ -34,4 +34,4 @@ def SPIRVUpdateVCE : Pass<"spirv-update-vce", "spirv::ModuleOp"> {
   let constructor = "mlir::spirv::createUpdateVersionCapabilityExtensionPass()";
 }
 
-#endif // MLIR_DIALECT_SPIRV_PASSES
+#endif // MLIR_DIALECT_SPIRV_TRANSFORMS_PASSES
@@ -1,4 +1,4 @@
-//===- SPIRVLowering.h - SPIR-V lowering utilities  -------------*- C++ -*-===//
+//===- SPIRVConversion.h - SPIR-V Conversion Utilities ----------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,16 +6,16 @@
 //
 //===----------------------------------------------------------------------===//
 //
-// Defines utilities to use while targeting SPIR-V dialect.
+// Defines utilities to use while converting to the SPIR-V dialect.
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef MLIR_DIALECT_SPIRV_SPIRVLOWERING_H
-#define MLIR_DIALECT_SPIRV_SPIRVLOWERING_H
+#ifndef MLIR_DIALECT_SPIRV_SPIRVCONVERSION_H
+#define MLIR_DIALECT_SPIRV_SPIRVCONVERSION_H
 
-#include "mlir/Dialect/SPIRV/SPIRVAttributes.h"
-#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
-#include "mlir/Dialect/SPIRV/TargetAndABI.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVAttributes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
+#include "mlir/Dialect/SPIRV/IR/TargetAndABI.h"
 #include "mlir/Transforms/DialectConversion.h"
 #include "llvm/ADT/SmallSet.h"
 
@@ -135,4 +135,4 @@ LogicalResult setABIAttrs(spirv::FuncOp funcOp,
 } // namespace spirv
 } // namespace mlir
 
-#endif // MLIR_DIALECT_SPIRV_SPIRVLOWERING_H
+#endif // MLIR_DIALECT_SPIRV_SPIRVCONVERSION_H
@@ -1,4 +1,4 @@
-//===-- LayoutUtils.h - Decorate composite type with layout information ---===//
+//===-- LayoutUtils.h - Vulkan Layout Util functions ------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -10,8 +10,9 @@
 // types in SPIR-V dialect.
 //
 //===----------------------------------------------------------------------===//
-#ifndef MLIR_DIALECT_SPIRV_LAYOUTUTILS_H_
-#define MLIR_DIALECT_SPIRV_LAYOUTUTILS_H_
+
+#ifndef MLIR_DIALECT_SPIRV_UTILS_LAYOUTUTILS_H_
+#define MLIR_DIALECT_SPIRV_UTILS_LAYOUTUTILS_H_
 
 #include <cstdint>
 
@@ -76,4 +77,4 @@ private:
 
 } // namespace mlir
 
-#endif // MLIR_DIALECT_SPIRV_LAYOUTUTILS_H_
+#endif // MLIR_DIALECT_SPIRV_UTILS_LAYOUTUTILS_H_
index a541fa4..0367f9d 100644 (file)
@@ -34,7 +34,7 @@
 #include "mlir/Dialect/Quant/QuantOps.h"
 #include "mlir/Dialect/SCF/SCF.h"
 #include "mlir/Dialect/SDBM/SDBMDialect.h"
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
 #include "mlir/Dialect/Shape/IR/Shape.h"
 #include "mlir/Dialect/StandardOps/IR/Ops.h"
 #include "mlir/Dialect/Tensor/IR/Tensor.h"
index 12b6399..a3de7e3 100644 (file)
@@ -22,7 +22,7 @@
 #include "mlir/Dialect/Linalg/Passes.h"
 #include "mlir/Dialect/Quant/Passes.h"
 #include "mlir/Dialect/SCF/Passes.h"
-#include "mlir/Dialect/SPIRV/Passes.h"
+#include "mlir/Dialect/SPIRV/Transforms/Passes.h"
 #include "mlir/Dialect/Shape/Transforms/Passes.h"
 #include "mlir/Dialect/StandardOps/Transforms/Passes.h"
 #include "mlir/Dialect/Tensor/Transforms/Passes.h"
index cdfadb0..f12ca45 100644 (file)
@@ -13,7 +13,7 @@
 #ifndef MLIR_TARGET_SPIRV_BINARY_UTILS_H_
 #define MLIR_TARGET_SPIRV_BINARY_UTILS_H_
 
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
 #include "mlir/Support/LogicalResult.h"
 
 #include <cstdint>
index 2da9c70..fba29cf 100644 (file)
@@ -16,6 +16,7 @@ add_mlir_conversion_library(MLIRGPUToSPIRVTransforms
   MLIRPass
   MLIRSCFToSPIRV
   MLIRSPIRV
+  MLIRSPIRVConversion
   MLIRStandard
   MLIRStandardToSPIRVTransforms
   MLIRSupport
index 1b25ffd..259acd7 100644 (file)
 //===----------------------------------------------------------------------===//
 #include "mlir/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.h"
 #include "mlir/Dialect/GPU/GPUDialect.h"
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
-#include "mlir/Dialect/SPIRV/SPIRVLowering.h"
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
-#include "mlir/Dialect/SPIRV/TargetAndABI.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/TargetAndABI.h"
+#include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"
 #include "mlir/IR/BuiltinOps.h"
 
 using namespace mlir;
index 083f992..973aa3d 100644 (file)
@@ -18,9 +18,9 @@
 #include "mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.h"
 #include "mlir/Dialect/GPU/GPUDialect.h"
 #include "mlir/Dialect/SCF/SCF.h"
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
-#include "mlir/Dialect/SPIRV/SPIRVLowering.h"
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"
 
 using namespace mlir;
 
index 0285d1c..9615582 100644 (file)
 //===----------------------------------------------------------------------===//
 
 
-#ifndef CONVERT_GPU_TO_SPIRV
-#define CONVERT_GPU_TO_SPIRV
+#ifndef MLIR_CONVERSION_GPU_TO_SPIRV
+#define MLIR_CONVERSION_GPU_TO_SPIRV
 
 include "mlir/Dialect/GPU/GPUOps.td"
-include "mlir/Dialect/SPIRV/SPIRVStructureOps.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td"
 
 def : Pat<(GPU_ModuleEndOp), (SPV_ModuleEndOp)>;
 
-#endif // CONVERT_GPU_TO_SPIRV
+#endif // MLIR_CONVERSION_GPU_TO_SPIRV
index 3808e3d..9582756 100644 (file)
@@ -16,8 +16,8 @@
 #include "../PassDetail.h"
 #include "mlir/Conversion/GPUToVulkan/ConvertGPUToVulkanPass.h"
 #include "mlir/Dialect/GPU/GPUDialect.h"
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
 #include "mlir/Dialect/StandardOps/IR/Ops.h"
 #include "mlir/IR/Attributes.h"
 #include "mlir/IR/Builders.h"
index e76e9b7..a40abba 100644 (file)
@@ -15,5 +15,6 @@ add_mlir_conversion_library(MLIRLinalgToSPIRVTransforms
   MLIRLinalgUtils
   MLIRPass
   MLIRSPIRV
+  MLIRSPIRVConversion
   MLIRSupport
   )
index 18e2693..0e09d95 100644 (file)
@@ -9,9 +9,9 @@
 #include "mlir/Conversion/LinalgToSPIRV/LinalgToSPIRV.h"
 #include "mlir/Dialect/Linalg/IR/LinalgOps.h"
 #include "mlir/Dialect/Linalg/Utils/Utils.h"
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
-#include "mlir/Dialect/SPIRV/SPIRVLowering.h"
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"
 #include "mlir/Dialect/StandardOps/IR/Ops.h"
 #include "mlir/Dialect/Utils/StructuredOpsUtils.h"
 #include "mlir/IR/AffineExpr.h"
index d0b724b..1ce2f41 100644 (file)
@@ -9,8 +9,8 @@
 #include "mlir/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.h"
 #include "../PassDetail.h"
 #include "mlir/Conversion/LinalgToSPIRV/LinalgToSPIRV.h"
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
-#include "mlir/Dialect/SPIRV/SPIRVLowering.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"
 
 using namespace mlir;
 
index 1a38676..d77a759 100644 (file)
@@ -11,6 +11,7 @@ add_mlir_conversion_library(MLIRSCFToSPIRV
   MLIRAffine
   MLIRAffineToStandard
   MLIRSPIRV
+  MLIRSPIRVConversion
   MLIRIR
   MLIRLinalg
   MLIRPass
index 754e193..576f38f 100644 (file)
@@ -11,9 +11,9 @@
 //===----------------------------------------------------------------------===//
 #include "mlir/Conversion/SCFToSPIRV/SCFToSPIRV.h"
 #include "mlir/Dialect/SCF/SCF.h"
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
-#include "mlir/Dialect/SPIRV/SPIRVLowering.h"
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"
 #include "mlir/IR/BuiltinOps.h"
 
 using namespace mlir;
index 5c18928..8d3cbc6 100644 (file)
@@ -13,6 +13,7 @@ add_mlir_conversion_library(MLIRSPIRVToLLVM
   LINK_LIBS PUBLIC
   MLIRGPU
   MLIRSPIRV
+  MLIRSPIRVUtils
   MLIRLLVMIR
   MLIRStandardToLLVM
   MLIRIR
index b01c443..1724c70 100644 (file)
@@ -17,7 +17,7 @@
 #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h"
 #include "mlir/Dialect/GPU/GPUDialect.h"
 #include "mlir/Dialect/LLVMIR/LLVMDialect.h"
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
 #include "mlir/Dialect/StandardOps/IR/Ops.h"
 #include "mlir/IR/BuiltinOps.h"
 #include "mlir/IR/SymbolTable.h"
index 935433c..22a4310 100644 (file)
@@ -14,9 +14,9 @@
 #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h"
 #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h"
 #include "mlir/Dialect/LLVMIR/LLVMDialect.h"
-#include "mlir/Dialect/SPIRV/LayoutUtils.h"
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/Utils/LayoutUtils.h"
 #include "mlir/Dialect/StandardOps/IR/Ops.h"
 #include "mlir/IR/BuiltinOps.h"
 #include "mlir/IR/PatternMatch.h"
index cea0e76..b93ce48 100644 (file)
@@ -16,7 +16,7 @@
 #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h"
 #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h"
 #include "mlir/Dialect/LLVMIR/LLVMDialect.h"
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
 
 using namespace mlir;
 
index 5ccbcc6..4af5d7d 100644 (file)
@@ -14,8 +14,8 @@ add_mlir_conversion_library(MLIRStandardToSPIRVTransforms
   MLIRIR
   MLIRPass
   MLIRSPIRV
+  MLIRSPIRVConversion
   MLIRSupport
   MLIRTransformUtils
-  MLIRSPIRV
   MLIRStandard
   )
index cd5079f..d156235 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
-#include "mlir/Dialect/SPIRV/LayoutUtils.h"
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
-#include "mlir/Dialect/SPIRV/SPIRVLowering.h"
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"
+#include "mlir/Dialect/SPIRV/Utils/LayoutUtils.h"
 #include "mlir/Dialect/StandardOps/IR/Ops.h"
 #include "mlir/IR/AffineMap.h"
 #include "mlir/Support/LogicalResult.h"
index aea7852..c2477e8 100644 (file)
@@ -14,8 +14,8 @@
 #include "mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.h"
 #include "../PassDetail.h"
 #include "mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.h"
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
-#include "mlir/Dialect/SPIRV/SPIRVLowering.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"
 
 using namespace mlir;
 
index eb237cf..ea483aa 100644 (file)
@@ -14,7 +14,7 @@
 #include "../PassDetail.h"
 #include "mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.h"
 #include "mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.h"
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
 #include "mlir/Dialect/StandardOps/IR/Ops.h"
 #include "mlir/Dialect/Vector/VectorOps.h"
 #include "mlir/IR/BuiltinTypes.h"
index a6e7300..060afdf 100644 (file)
@@ -10,6 +10,7 @@ add_mlir_conversion_library(MLIRVectorToSPIRV
 
   LINK_LIBS PUBLIC
   MLIRSPIRV
+  MLIRSPIRVConversion
   MLIRVector
   MLIRTransforms
   )
index 220fa62..7f73391 100644 (file)
 #include "../PassDetail.h"
 #include "mlir/Conversion/VectorToSPIRV/ConvertVectorToSPIRV.h"
 #include "mlir/Conversion/VectorToSPIRV/ConvertVectorToSPIRVPass.h"
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
-#include "mlir/Dialect/SPIRV/SPIRVLowering.h"
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
-#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
+#include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"
 #include "mlir/Dialect/Vector/VectorOps.h"
 #include "mlir/Pass/Pass.h"
 #include "mlir/Transforms/DialectConversion.h"
index 8362a98..4d73d45 100644 (file)
@@ -1,38 +1,4 @@
-
-set(LLVM_TARGET_DEFINITIONS SPIRVCanonicalization.td)
-mlir_tablegen(SPIRVCanonicalization.inc -gen-rewriters)
-add_public_tablegen_target(MLIRSPIRVCanonicalizationIncGen)
-
-add_mlir_dialect_library(MLIRSPIRV
-  LayoutUtils.cpp
-  SPIRVAttributes.cpp
-  SPIRVCanonicalization.cpp
-  SPIRVDialect.cpp
-  SPIRVOps.cpp
-  SPIRVLowering.cpp
-  SPIRVTypes.cpp
-  TargetAndABI.cpp
-
-  ADDITIONAL_HEADER_DIRS
-  ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/SPIRV
-
-  DEPENDS
-  MLIRSPIRVAvailabilityIncGen
-  MLIRSPIRVCanonicalizationIncGen
-  MLIRSPIRVEnumAvailabilityIncGen
-  MLIRSPIRVEnumsIncGen
-  MLIRSPIRVOpsIncGen
-  MLIRSPIRVOpUtilsGen
-  MLIRSPIRVTargetAndABIIncGen
-
-  LINK_LIBS PUBLIC
-  MLIRControlFlowInterfaces
-  MLIRIR
-  MLIRParser
-  MLIRSideEffectInterfaces
-  MLIRSupport
-  MLIRTransforms
-  )
-
+add_subdirectory(IR)
 add_subdirectory(Linking)
 add_subdirectory(Transforms)
+add_subdirectory(Utils)
diff --git a/mlir/lib/Dialect/SPIRV/IR/CMakeLists.txt b/mlir/lib/Dialect/SPIRV/IR/CMakeLists.txt
new file mode 100644 (file)
index 0000000..dbf6242
--- /dev/null
@@ -0,0 +1,33 @@
+set(LLVM_TARGET_DEFINITIONS SPIRVCanonicalization.td)
+mlir_tablegen(SPIRVCanonicalization.inc -gen-rewriters)
+add_public_tablegen_target(MLIRSPIRVCanonicalizationIncGen)
+
+add_mlir_dialect_library(MLIRSPIRV
+  SPIRVAttributes.cpp
+  SPIRVCanonicalization.cpp
+  SPIRVDialect.cpp
+  SPIRVEnums.cpp
+  SPIRVOps.cpp
+  SPIRVTypes.cpp
+  TargetAndABI.cpp
+
+  ADDITIONAL_HEADER_DIRS
+  ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/SPIRV
+
+  DEPENDS
+  MLIRSPIRVAttrUtilsGen
+  MLIRSPIRVAvailabilityIncGen
+  MLIRSPIRVCanonicalizationIncGen
+  MLIRSPIRVEnumAvailabilityIncGen
+  MLIRSPIRVEnumsIncGen
+  MLIRSPIRVOpsIncGen
+  MLIRSPIRVTargetAndABIIncGen
+
+  LINK_LIBS PUBLIC
+  MLIRControlFlowInterfaces
+  MLIRIR
+  MLIRParser
+  MLIRSideEffectInterfaces
+  MLIRSupport
+  MLIRTransforms
+)
similarity index 96%
rename from mlir/lib/Dialect/SPIRV/SPIRVAttributes.cpp
rename to mlir/lib/Dialect/SPIRV/IR/SPIRVAttributes.cpp
index 2f90951..98e0b94 100644 (file)
@@ -6,17 +6,27 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "mlir/Dialect/SPIRV/SPIRVAttributes.h"
-#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVAttributes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
 #include "mlir/IR/Builders.h"
 
 using namespace mlir;
 
 //===----------------------------------------------------------------------===//
+// TableGen'erated attribute utility functions
+//===----------------------------------------------------------------------===//
+
+namespace mlir {
+namespace spirv {
+#include "mlir/Dialect/SPIRV/IR/SPIRVAttrUtils.inc"
+} // namespace spirv
+} // namespace mlir
+
+//===----------------------------------------------------------------------===//
 // DictionaryDict derived attributes
 //===----------------------------------------------------------------------===//
 
-#include "mlir/Dialect/SPIRV/TargetAndABI.cpp.inc"
+#include "mlir/Dialect/SPIRV/IR/TargetAndABI.cpp.inc"
 
 namespace mlir {
 
 //
 //===----------------------------------------------------------------------===//
 
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
 
 #include "mlir/Dialect/CommonFolders.h"
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
-#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
 #include "mlir/IR/Matchers.h"
 #include "mlir/IR/PatternMatch.h"
 
@@ -356,7 +356,6 @@ private:
     return lhs->getAttrDictionary() == rhs->getAttrDictionary();
   }
 
-
   // Returns a source value for the given block.
   Value getSrcValue(Block *block) const {
     auto storeOp = cast<spirv::StoreOp>(block->front());
@@ -10,7 +10,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-include "mlir/Dialect/SPIRV/SPIRVOps.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVOps.td"
 
 //===----------------------------------------------------------------------===//
 // spv.Bitcast
similarity index 99%
rename from mlir/lib/Dialect/SPIRV/SPIRVDialect.cpp
rename to mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp
index 26d7067..c53048c 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
-#include "mlir/Dialect/SPIRV/ParserUtils.h"
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
-#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
-#include "mlir/Dialect/SPIRV/TargetAndABI.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/ParserUtils.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
+#include "mlir/Dialect/SPIRV/IR/TargetAndABI.h"
 #include "mlir/IR/Builders.h"
 #include "mlir/IR/BuiltinTypes.h"
 #include "mlir/IR/DialectImplementation.h"
 #include "llvm/ADT/TypeSwitch.h"
 #include "llvm/Support/raw_ostream.h"
 
-namespace mlir {
-namespace spirv {
-#include "mlir/Dialect/SPIRV/SPIRVOpUtils.inc"
-} // namespace spirv
-} // namespace mlir
-
 using namespace mlir;
 using namespace mlir::spirv;
 
@@ -129,7 +123,7 @@ void SPIRVDialect::initialize() {
   // Add SPIR-V ops.
   addOperations<
 #define GET_OP_LIST
-#include "mlir/Dialect/SPIRV/SPIRVOps.cpp.inc"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.cpp.inc"
       >();
 
   addInterfaces<SPIRVInlinerInterface>();
diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVEnums.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVEnums.cpp
new file mode 100644 (file)
index 0000000..a289d9d
--- /dev/null
@@ -0,0 +1,94 @@
+//===- SPIRVEnums.cpp - MLIR SPIR-V Enums ---------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the C/C++ enums from SPIR-V spec.
+//
+//===----------------------------------------------------------------------===//
+
+#include "mlir/Dialect/SPIRV/IR/SPIRVEnums.h"
+
+#include "llvm/ADT/SetVector.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSwitch.h"
+
+using namespace mlir;
+
+// Pull in all enum utility function definitions
+#include "mlir/Dialect/SPIRV/IR/SPIRVEnums.cpp.inc"
+
+// Pull in all enum type availability query function definitions
+#include "mlir/Dialect/SPIRV/IR/SPIRVEnumAvailability.cpp.inc"
+
+//===----------------------------------------------------------------------===//
+// Availability relationship
+//===----------------------------------------------------------------------===//
+
+ArrayRef<spirv::Extension> spirv::getImpliedExtensions(spirv::Version version) {
+  // Note: the following lists are from "Appendix A: Changes" of the spec.
+
+#define V_1_3_IMPLIED_EXTS                                                     \
+  Extension::SPV_KHR_shader_draw_parameters, Extension::SPV_KHR_16bit_storage, \
+      Extension::SPV_KHR_device_group, Extension::SPV_KHR_multiview,           \
+      Extension::SPV_KHR_storage_buffer_storage_class,                         \
+      Extension::SPV_KHR_variable_pointers
+
+#define V_1_4_IMPLIED_EXTS                                                     \
+  Extension::SPV_KHR_no_integer_wrap_decoration,                               \
+      Extension::SPV_GOOGLE_decorate_string,                                   \
+      Extension::SPV_GOOGLE_hlsl_functionality1,                               \
+      Extension::SPV_KHR_float_controls
+
+#define V_1_5_IMPLIED_EXTS                                                     \
+  Extension::SPV_KHR_8bit_storage, Extension::SPV_EXT_descriptor_indexing,     \
+      Extension::SPV_EXT_shader_viewport_index_layer,                          \
+      Extension::SPV_EXT_physical_storage_buffer,                              \
+      Extension::SPV_KHR_physical_storage_buffer,                              \
+      Extension::SPV_KHR_vulkan_memory_model
+
+  switch (version) {
+  default:
+    return {};
+  case Version::V_1_3: {
+    // The following manual ArrayRef constructor call is to satisfy GCC 5.
+    static const Extension exts[] = {V_1_3_IMPLIED_EXTS};
+    return ArrayRef<spirv::Extension>(exts, llvm::array_lengthof(exts));
+  }
+  case Version::V_1_4: {
+    static const Extension exts[] = {V_1_3_IMPLIED_EXTS, V_1_4_IMPLIED_EXTS};
+    return ArrayRef<spirv::Extension>(exts, llvm::array_lengthof(exts));
+  }
+  case Version::V_1_5: {
+    static const Extension exts[] = {V_1_3_IMPLIED_EXTS, V_1_4_IMPLIED_EXTS,
+                                     V_1_5_IMPLIED_EXTS};
+    return ArrayRef<spirv::Extension>(exts, llvm::array_lengthof(exts));
+  }
+  }
+
+#undef V_1_5_IMPLIED_EXTS
+#undef V_1_4_IMPLIED_EXTS
+#undef V_1_3_IMPLIED_EXTS
+}
+
+// Pull in utility function definition for implied capabilities
+#include "mlir/Dialect/SPIRV/IR/SPIRVCapabilityImplication.inc"
+
+SmallVector<spirv::Capability, 0>
+spirv::getRecursiveImpliedCapabilities(spirv::Capability cap) {
+  ArrayRef<spirv::Capability> directCaps = getDirectImpliedCapabilities(cap);
+  llvm::SetVector<spirv::Capability, SmallVector<spirv::Capability, 0>> allCaps(
+      directCaps.begin(), directCaps.end());
+
+  // TODO: This is insufficient; find a better way to handle this
+  // (e.g., using static lists) if this turns out to be a bottleneck.
+  for (unsigned i = 0; i < allCaps.size(); ++i)
+    for (Capability c : getDirectImpliedCapabilities(allCaps[i]))
+      allCaps.insert(c);
+
+  return allCaps.takeVector();
+}
similarity index 99%
rename from mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
rename to mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
index 43b3c51..6cada4a 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
 
-#include "mlir/Dialect/SPIRV/ParserUtils.h"
-#include "mlir/Dialect/SPIRV/SPIRVAttributes.h"
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
-#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
-#include "mlir/Dialect/SPIRV/TargetAndABI.h"
+#include "mlir/Dialect/SPIRV/IR/ParserUtils.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVAttributes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
+#include "mlir/Dialect/SPIRV/IR/TargetAndABI.h"
 #include "mlir/IR/Builders.h"
 #include "mlir/IR/BuiltinOps.h"
 #include "mlir/IR/BuiltinTypes.h"
@@ -3471,18 +3471,18 @@ namespace spirv {
 
 // TableGen'erated operation interfaces for querying versions, extensions, and
 // capabilities.
-#include "mlir/Dialect/SPIRV/SPIRVAvailability.cpp.inc"
+#include "mlir/Dialect/SPIRV/IR/SPIRVAvailability.cpp.inc"
 } // namespace spirv
 } // namespace mlir
 
 // TablenGen'erated operation definitions.
 #define GET_OP_CLASSES
-#include "mlir/Dialect/SPIRV/SPIRVOps.cpp.inc"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.cpp.inc"
 
 namespace mlir {
 namespace spirv {
 // TableGen'erated operation availability interface implementations.
-#include "mlir/Dialect/SPIRV/SPIRVOpAvailabilityImpl.inc"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOpAvailabilityImpl.inc"
 
 } // namespace spirv
 } // namespace mlir
similarity index 91%
rename from mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp
rename to mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp
index 15fafdd..fa8576a 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
-#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
 #include "mlir/IR/Attributes.h"
 #include "mlir/IR/BuiltinTypes.h"
 #include "mlir/IR/Identifier.h"
 #include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/SetVector.h"
-#include "llvm/ADT/StringExtras.h"
-#include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/TypeSwitch.h"
 
 using namespace mlir;
 using namespace mlir::spirv;
 
-// Pull in all enum utility function definitions
-#include "mlir/Dialect/SPIRV/SPIRVEnums.cpp.inc"
-// Pull in all enum type availability query function definitions
-#include "mlir/Dialect/SPIRV/SPIRVEnumAvailability.cpp.inc"
-
-//===----------------------------------------------------------------------===//
-// Availability relationship
-//===----------------------------------------------------------------------===//
-
-ArrayRef<Extension> spirv::getImpliedExtensions(Version version) {
-  // Note: the following lists are from "Appendix A: Changes" of the spec.
-
-#define V_1_3_IMPLIED_EXTS                                                     \
-  Extension::SPV_KHR_shader_draw_parameters, Extension::SPV_KHR_16bit_storage, \
-      Extension::SPV_KHR_device_group, Extension::SPV_KHR_multiview,           \
-      Extension::SPV_KHR_storage_buffer_storage_class,                         \
-      Extension::SPV_KHR_variable_pointers
-
-#define V_1_4_IMPLIED_EXTS                                                     \
-  Extension::SPV_KHR_no_integer_wrap_decoration,                               \
-      Extension::SPV_GOOGLE_decorate_string,                                   \
-      Extension::SPV_GOOGLE_hlsl_functionality1,                               \
-      Extension::SPV_KHR_float_controls
-
-#define V_1_5_IMPLIED_EXTS                                                     \
-  Extension::SPV_KHR_8bit_storage, Extension::SPV_EXT_descriptor_indexing,     \
-      Extension::SPV_EXT_shader_viewport_index_layer,                          \
-      Extension::SPV_EXT_physical_storage_buffer,                              \
-      Extension::SPV_KHR_physical_storage_buffer,                              \
-      Extension::SPV_KHR_vulkan_memory_model
-
-  switch (version) {
-  default:
-    return {};
-  case Version::V_1_3: {
-    // The following manual ArrayRef constructor call is to satisfy GCC 5.
-    static const Extension exts[] = {V_1_3_IMPLIED_EXTS};
-    return ArrayRef<Extension>(exts, llvm::array_lengthof(exts));
-  }
-  case Version::V_1_4: {
-    static const Extension exts[] = {V_1_3_IMPLIED_EXTS, V_1_4_IMPLIED_EXTS};
-    return ArrayRef<Extension>(exts, llvm::array_lengthof(exts));
-  }
-  case Version::V_1_5: {
-    static const Extension exts[] = {V_1_3_IMPLIED_EXTS, V_1_4_IMPLIED_EXTS,
-                                     V_1_5_IMPLIED_EXTS};
-    return ArrayRef<Extension>(exts, llvm::array_lengthof(exts));
-  }
-  }
-
-#undef V_1_5_IMPLIED_EXTS
-#undef V_1_4_IMPLIED_EXTS
-#undef V_1_3_IMPLIED_EXTS
-}
-
-// Pull in utility function definition for implied capabilities
-#include "mlir/Dialect/SPIRV/SPIRVCapabilityImplication.inc"
-
-SmallVector<Capability, 0>
-spirv::getRecursiveImpliedCapabilities(Capability cap) {
-  ArrayRef<Capability> directCaps = getDirectImpliedCapabilities(cap);
-  llvm::SetVector<Capability, SmallVector<Capability, 0>> allCaps(
-      directCaps.begin(), directCaps.end());
-
-  // TODO: This is insufficient; find a better way to handle this
-  // (e.g., using static lists) if this turns out to be a bottleneck.
-  for (unsigned i = 0; i < allCaps.size(); ++i)
-    for (Capability c : getDirectImpliedCapabilities(allCaps[i]))
-      allCaps.insert(c);
-
-  return allCaps.takeVector();
-}
-
 //===----------------------------------------------------------------------===//
 // ArrayType
 //===----------------------------------------------------------------------===//
@@ -336,33 +260,42 @@ void CooperativeMatrixNVType::getCapabilities(
 // ImageType
 //===----------------------------------------------------------------------===//
 
-template <typename T> static constexpr unsigned getNumBits() { return 0; }
-template <> constexpr unsigned getNumBits<Dim>() {
+template <typename T>
+static constexpr unsigned getNumBits() {
+  return 0;
+}
+template <>
+constexpr unsigned getNumBits<Dim>() {
   static_assert((1 << 3) > getMaxEnumValForDim(),
                 "Not enough bits to encode Dim value");
   return 3;
 }
-template <> constexpr unsigned getNumBits<ImageDepthInfo>() {
+template <>
+constexpr unsigned getNumBits<ImageDepthInfo>() {
   static_assert((1 << 2) > getMaxEnumValForImageDepthInfo(),
                 "Not enough bits to encode ImageDepthInfo value");
   return 2;
 }
-template <> constexpr unsigned getNumBits<ImageArrayedInfo>() {
+template <>
+constexpr unsigned getNumBits<ImageArrayedInfo>() {
   static_assert((1 << 1) > getMaxEnumValForImageArrayedInfo(),
                 "Not enough bits to encode ImageArrayedInfo value");
   return 1;
 }
-template <> constexpr unsigned getNumBits<ImageSamplingInfo>() {
+template <>
+constexpr unsigned getNumBits<ImageSamplingInfo>() {
   static_assert((1 << 1) > getMaxEnumValForImageSamplingInfo(),
                 "Not enough bits to encode ImageSamplingInfo value");
   return 1;
 }
-template <> constexpr unsigned getNumBits<ImageSamplerUseInfo>() {
+template <>
+constexpr unsigned getNumBits<ImageSamplerUseInfo>() {
   static_assert((1 << 2) > getMaxEnumValForImageSamplerUseInfo(),
                 "Not enough bits to encode ImageSamplerUseInfo value");
   return 2;
 }
-template <> constexpr unsigned getNumBits<ImageFormat>() {
+template <>
+constexpr unsigned getNumBits<ImageFormat>() {
   static_assert((1 << 6) > getMaxEnumValForImageFormat(),
                 "Not enough bits to encode ImageFormat value");
   return 6;
similarity index 98%
rename from mlir/lib/Dialect/SPIRV/TargetAndABI.cpp
rename to mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp
index f409f1d..b6c5f82 100644 (file)
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "mlir/Dialect/SPIRV/TargetAndABI.h"
-#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
+#include "mlir/Dialect/SPIRV/IR/TargetAndABI.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
 #include "mlir/IR/Builders.h"
 #include "mlir/IR/FunctionSupport.h"
 #include "mlir/IR/Operation.h"
index c9ba8a3..1f4bfd3 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
-#include "mlir/Dialect/SPIRV/ModuleCombiner.h"
+#include "mlir/Dialect/SPIRV/Linking/ModuleCombiner.h"
 
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
 #include "mlir/IR/Builders.h"
 #include "mlir/IR/SymbolTable.h"
 #include "llvm/ADT/ArrayRef.h"
index 228d848..db27408 100644 (file)
@@ -1,5 +1,24 @@
+set(LLVM_OPTIONAL_SOURCES
+  DecorateCompositeTypeLayoutPass.cpp
+  LowerABIAttributesPass.cpp
+  RewriteInsertsPass.cpp
+  SPIRVConversion.cpp
+  UpdateVCEPass.cpp
+)
+
+add_mlir_dialect_library(MLIRSPIRVConversion
+  SPIRVConversion.cpp
+
+  ADDITIONAL_HEADER_DIRS
+  ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/SPIRV
+
+  LINK_LIBS PUBLIC
+  MLIRSPIRV
+  MLIRTransformUtils
+)
+
 add_mlir_dialect_library(MLIRSPIRVTransforms
-  DecorateSPIRVCompositeTypeLayoutPass.cpp
+  DecorateCompositeTypeLayoutPass.cpp
   LowerABIAttributesPass.cpp
   RewriteInsertsPass.cpp
   UpdateVCEPass.cpp
@@ -12,5 +31,6 @@ add_mlir_dialect_library(MLIRSPIRVTransforms
 
   LINK_LIBS PUBLIC
   MLIRPass
-  MLIRSPIRV
-  )
+  MLIRSPIRVConversion
+  MLIRSPIRVUtils
+)
@@ -1,4 +1,4 @@
-//===- DecorateSPIRVCompositeTypeLayoutPass.cpp - Decorate composite type -===//
+//===- DecorateCompositeTypeLayoutPass.cpp - Decorate composite type ------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
 //===----------------------------------------------------------------------===//
 
 #include "PassDetail.h"
-#include "mlir/Dialect/SPIRV/LayoutUtils.h"
-#include "mlir/Dialect/SPIRV/Passes.h"
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/Transforms/Passes.h"
+#include "mlir/Dialect/SPIRV/Utils/LayoutUtils.h"
 #include "mlir/Transforms/DialectConversion.h"
 
 using namespace mlir;
index 12f0152..aeff47a 100644 (file)
 //===----------------------------------------------------------------------===//
 
 #include "PassDetail.h"
-#include "mlir/Dialect/SPIRV/LayoutUtils.h"
-#include "mlir/Dialect/SPIRV/Passes.h"
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
-#include "mlir/Dialect/SPIRV/SPIRVLowering.h"
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/Transforms/Passes.h"
+#include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"
+#include "mlir/Dialect/SPIRV/Utils/LayoutUtils.h"
 #include "mlir/Transforms/DialectConversion.h"
 #include "llvm/ADT/SetVector.h"
 
index 3c56f21..cb4f01f 100644 (file)
@@ -18,7 +18,7 @@ class ModuleOp;
 } // end namespace spirv
 
 #define GEN_PASS_CLASSES
-#include "mlir/Dialect/SPIRV/Passes.h.inc"
+#include "mlir/Dialect/SPIRV/Transforms/Passes.h.inc"
 
 } // end namespace mlir
 
index 8700831..b89312f 100644 (file)
@@ -13,8 +13,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "PassDetail.h"
-#include "mlir/Dialect/SPIRV/Passes.h"
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/Transforms/Passes.h"
 #include "mlir/IR/Builders.h"
 #include "mlir/IR/BuiltinOps.h"
 
@@ -1,4 +1,4 @@
-//===- SPIRVLowering.cpp - SPIR-V lowering utilities ----------------------===//
+//===- SPIRVConversion.cpp - SPIR-V Conversion Utilities ------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
 //
 //===----------------------------------------------------------------------===//
 
-#include "mlir/Dialect/SPIRV/SPIRVLowering.h"
-#include "mlir/Dialect/SPIRV/LayoutUtils.h"
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
 #include "llvm/ADT/Sequence.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Debug.h"
 
 #include <functional>
 
-#define DEBUG_TYPE "mlir-spirv-lowering"
+#define DEBUG_TYPE "mlir-spirv-conversion"
 
 using namespace mlir;
 
index 00e9ffa..c5a8804 100644 (file)
 //===----------------------------------------------------------------------===//
 
 #include "PassDetail.h"
-#include "mlir/Dialect/SPIRV/Passes.h"
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
-#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
-#include "mlir/Dialect/SPIRV/TargetAndABI.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
+#include "mlir/Dialect/SPIRV/IR/TargetAndABI.h"
+#include "mlir/Dialect/SPIRV/Transforms/Passes.h"
 #include "mlir/IR/Builders.h"
 #include "mlir/IR/Visitors.h"
 #include "llvm/ADT/SetVector.h"
diff --git a/mlir/lib/Dialect/SPIRV/Utils/CMakeLists.txt b/mlir/lib/Dialect/SPIRV/Utils/CMakeLists.txt
new file mode 100644 (file)
index 0000000..fa0f932
--- /dev/null
@@ -0,0 +1,10 @@
+add_mlir_dialect_library(MLIRSPIRVUtils
+  LayoutUtils.cpp
+
+  ADDITIONAL_HEADER_DIRS
+  ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/SPIRV
+
+  LINK_LIBS PUBLIC
+  MLIRSPIRV
+)
+
similarity index 97%
rename from mlir/lib/Dialect/SPIRV/LayoutUtils.cpp
rename to mlir/lib/Dialect/SPIRV/Utils/LayoutUtils.cpp
index 9094d2e..b5a38c3 100644 (file)
 // for types in SPIR-V dialect.
 //
 //===----------------------------------------------------------------------===//
-#include "mlir/Dialect/SPIRV/LayoutUtils.h"
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
-#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
+
+#include "mlir/Dialect/SPIRV/Utils/LayoutUtils.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
 
 using namespace mlir;
 
index 6512b1a..bf2c143 100644 (file)
 
 #include "mlir/Target/SPIRV/Deserialization.h"
 
-#include "mlir/Dialect/SPIRV/SPIRVAttributes.h"
-#include "mlir/Dialect/SPIRV/SPIRVModule.h"
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
-#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVAttributes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVModule.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
 #include "mlir/IR/BlockAndValueMapping.h"
 #include "mlir/IR/Builders.h"
 #include "mlir/IR/Location.h"
@@ -2778,7 +2778,7 @@ Deserializer::processOp<spirv::CopyMemoryOp>(ArrayRef<uint32_t> words) {
 // Pull in auto-generated Deserializer::dispatchToAutogenDeserialization() and
 // various Deserializer::processOp<...>() specializations.
 #define GET_DESERIALIZATION_FNS
-#include "mlir/Dialect/SPIRV/SPIRVSerialization.inc"
+#include "mlir/Dialect/SPIRV/IR/SPIRVSerialization.inc"
 } // namespace
 
 namespace mlir {
index e179502..769718b 100644 (file)
@@ -11,7 +11,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "mlir/Target/SPIRV/SPIRVBinaryUtils.h"
-#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
 
 using namespace mlir;
 
index 5d05197..cb41c7b 100644 (file)
 
 #include "mlir/Target/SPIRV/Serialization.h"
 
-#include "mlir/Dialect/SPIRV/SPIRVAttributes.h"
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
-#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVAttributes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
 #include "mlir/IR/Builders.h"
 #include "mlir/IR/RegionGraphTraits.h"
 #include "mlir/Support/LogicalResult.h"
@@ -2107,7 +2107,7 @@ Serializer::processOp<spirv::CopyMemoryOp>(spirv::CopyMemoryOp op) {
 // Pull in auto-generated Serializer::dispatchToAutogenSerialization() and
 // various Serializer::processOp<...>() specializations.
 #define GET_SERIALIZATION_FNS
-#include "mlir/Dialect/SPIRV/SPIRVSerialization.inc"
+#include "mlir/Dialect/SPIRV/IR/SPIRVSerialization.inc"
 } // namespace
 
 LogicalResult Serializer::emitDecoration(uint32_t target,
index f4cf45a..70af479 100644 (file)
@@ -11,9 +11,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
-#include "mlir/Dialect/SPIRV/SPIRVModule.h"
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVModule.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
 #include "mlir/IR/Builders.h"
 #include "mlir/IR/BuiltinOps.h"
 #include "mlir/IR/Dialect.h"
index 6c74d2f..edcbf4e 100644 (file)
@@ -15,6 +15,7 @@ add_mlir_library(MLIRSPIRVTestPasses
   MLIRIR
   MLIRPass
   MLIRSPIRV
+  MLIRSPIRVConversion
   MLIRSPIRVModuleCombiner
   MLIRSupport
   )
index 791b354..99a6022 100644 (file)
@@ -6,9 +6,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "mlir/Dialect/SPIRV/SPIRVLowering.h"
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
-#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
+#include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"
 #include "mlir/IR/BuiltinOps.h"
 #include "mlir/Pass/Pass.h"
 
index b8b544a..ed1b923 100644 (file)
@@ -12,8 +12,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "mlir/Dialect/GPU/GPUDialect.h"
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
-#include "mlir/Dialect/SPIRV/TargetAndABI.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/TargetAndABI.h"
 #include "mlir/Pass/Pass.h"
 
 using namespace mlir;
index 0c39702..29a0570 100644 (file)
@@ -6,10 +6,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "mlir/Dialect/SPIRV/ModuleCombiner.h"
-
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
-#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
+#include "mlir/Dialect/SPIRV/Linking/ModuleCombiner.h"
 #include "mlir/IR/Builders.h"
 #include "mlir/IR/BuiltinOps.h"
 #include "mlir/Pass/Pass.h"
index 3c2b933..c8c9590 100644 (file)
@@ -14,7 +14,7 @@
 #include "mlir/Dialect/GPU/GPUDialect.h"
 #include "mlir/Dialect/GPU/MemoryPromotion.h"
 #include "mlir/Dialect/SCF/SCF.h"
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
 #include "mlir/Dialect/StandardOps/IR/Ops.h"
 #include "mlir/IR/Attributes.h"
 #include "mlir/Pass/Pass.h"
index 69080ae..5860b07 100644 (file)
@@ -1,9 +1,9 @@
-set(LLVM_OPTIONAL_SOURCES
-  mlir-spirv-cpu-runner.cpp
-  )
+set(LLVM_LINK_COMPONENTS
+  Linker
+)
 
 if (MLIR_SPIRV_CPU_RUNNER_ENABLED)
-  message(STATUS "Building SPIR-V cpu runner")
+  message(STATUS "Building SPIR-V CPU runner")
 
   add_llvm_tool(mlir-spirv-cpu-runner
     mlir-spirv-cpu-runner.cpp
index 5deb52c..31dbae3 100644 (file)
@@ -16,8 +16,8 @@
 #include "mlir/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVMPass.h"
 #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h"
 #include "mlir/Dialect/GPU/Passes.h"
-#include "mlir/Dialect/SPIRV/Passes.h"
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/Transforms/Passes.h"
 #include "mlir/ExecutionEngine/JitRunner.h"
 #include "mlir/ExecutionEngine/OptUtils.h"
 #include "mlir/InitAllDialects.h"
index f5a40e2..cd8be8a 100644 (file)
@@ -1155,18 +1155,18 @@ static void emitEnumGetAttrNameFnDefn(const EnumAttr &enumAttr,
   os << "}\n";
 }
 
-static bool emitOpUtils(const RecordKeeper &recordKeeper, raw_ostream &os) {
-  llvm::emitSourceFileHeader("SPIR-V Op Utilities", os);
+static bool emitAttrUtils(const RecordKeeper &recordKeeper, raw_ostream &os) {
+  llvm::emitSourceFileHeader("SPIR-V Attribute Utilities", os);
 
   auto defs = recordKeeper.getAllDerivedDefinitions("EnumAttrInfo");
-  os << "#ifndef SPIRV_OP_UTILS_H_\n";
-  os << "#define SPIRV_OP_UTILS_H_\n";
+  os << "#ifndef MLIR_DIALECT_SPIRV_IR_ATTR_UTILS_H_\n";
+  os << "#define MLIR_DIALECT_SPIRV_IR_ATTR_UTILS_H_\n";
   emitEnumGetAttrNameFnDecl(os);
   for (const auto *def : defs) {
     EnumAttr enumAttr(*def);
     emitEnumGetAttrNameFnDefn(enumAttr, os);
   }
-  os << "#endif // SPIRV_OP_UTILS_H\n";
+  os << "#endif // MLIR_DIALECT_SPIRV_IR_ATTR_UTILS_H\n";
   return false;
 }
 
@@ -1175,10 +1175,10 @@ static bool emitOpUtils(const RecordKeeper &recordKeeper, raw_ostream &os) {
 //===----------------------------------------------------------------------===//
 
 static mlir::GenRegistration
-    genOpUtils("gen-spirv-op-utils",
-               "Generate SPIR-V operation utility definitions",
+    genOpUtils("gen-spirv-attr-utils",
+               "Generate SPIR-V attribute utility definitions",
                [](const RecordKeeper &records, raw_ostream &os) {
-                 return emitOpUtils(records, os);
+                 return emitAttrUtils(records, os);
                });
 
 //===----------------------------------------------------------------------===//
@@ -1330,8 +1330,8 @@ static bool emitCapabilityImplication(const RecordKeeper &recordKeeper,
 
   EnumAttr enumAttr(recordKeeper.getDef("SPV_CapabilityAttr"));
 
-  os << "ArrayRef<Capability> "
-        "spirv::getDirectImpliedCapabilities(Capability cap) {\n"
+  os << "ArrayRef<spirv::Capability> "
+        "spirv::getDirectImpliedCapabilities(spirv::Capability cap) {\n"
      << "  switch (cap) {\n"
      << "  default: return {};\n";
   for (const EnumAttrCase &enumerant : enumAttr.getAllCases()) {
@@ -1340,14 +1340,14 @@ static bool emitCapabilityImplication(const RecordKeeper &recordKeeper,
       continue;
 
     std::vector<Record *> impliedCapsDefs = def.getValueAsListOfDefs("implies");
-    os << "  case Capability::" << enumerant.getSymbol()
-       << ": {static const Capability implies[" << impliedCapsDefs.size()
+    os << "  case spirv::Capability::" << enumerant.getSymbol()
+       << ": {static const spirv::Capability implies[" << impliedCapsDefs.size()
        << "] = {";
     llvm::interleaveComma(impliedCapsDefs, os, [&](const Record *capDef) {
-      os << "Capability::" << EnumAttrCase(capDef).getSymbol();
+      os << "spirv::Capability::" << EnumAttrCase(capDef).getSymbol();
     });
-    os << "}; return ArrayRef<Capability>(implies, " << impliedCapsDefs.size()
-       << "); }\n";
+    os << "}; return ArrayRef<spirv::Capability>(implies, "
+       << impliedCapsDefs.size() << "); }\n";
   }
   os << "  }\n";
   os << "}\n";
index 8b00bae..98d3bcf 100644 (file)
@@ -17,8 +17,8 @@
 #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h"
 #include "mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.h"
 #include "mlir/Dialect/GPU/Passes.h"
-#include "mlir/Dialect/SPIRV/Passes.h"
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/Transforms/Passes.h"
 #include "mlir/ExecutionEngine/JitRunner.h"
 #include "mlir/ExecutionEngine/OptUtils.h"
 #include "mlir/InitAllDialects.h"
index 3823c7b..76fa661 100644 (file)
@@ -13,9 +13,9 @@
 //===----------------------------------------------------------------------===//
 
 #include "mlir/Target/SPIRV/Deserialization.h"
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
-#include "mlir/Dialect/SPIRV/SPIRVModule.h"
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVModule.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
 #include "mlir/IR/Diagnostics.h"
 #include "mlir/IR/MLIRContext.h"
 #include "mlir/Target/SPIRV/SPIRVBinaryUtils.h"
index bfeffa3..2a05edb 100644 (file)
 //===----------------------------------------------------------------------===//
 
 #include "mlir/Target/SPIRV/Serialization.h"
-#include "mlir/Dialect/SPIRV/SPIRVAttributes.h"
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
-#include "mlir/Dialect/SPIRV/SPIRVModule.h"
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
-#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVAttributes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVModule.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
 #include "mlir/IR/Builders.h"
 #include "mlir/IR/Location.h"
 #include "mlir/IR/MLIRContext.h"