[llvm-branch-commits] [mlir] 0117865 - [mlir][spirv] NFC: Shuffle code around to better follow convention

Lei Zhang via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Dec 17 08:08:24 PST 2020


Author: Lei Zhang
Date: 2020-12-17T11:03:26-05:00
New Revision: 01178654121b1caadadd448d65d7fb4f806670d6

URL: https://github.com/llvm/llvm-project/commit/01178654121b1caadadd448d65d7fb4f806670d6
DIFF: https://github.com/llvm/llvm-project/commit/01178654121b1caadadd448d65d7fb4f806670d6.diff

LOG: [mlir][spirv] NFC: Shuffle code around to better follow convention

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

Added: 
    mlir/include/mlir/Dialect/SPIRV/IR/CMakeLists.txt
    mlir/include/mlir/Dialect/SPIRV/IR/ParserUtils.h
    mlir/include/mlir/Dialect/SPIRV/IR/SPIRVArithmeticOps.td
    mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td
    mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAttributes.h
    mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAvailability.td
    mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td
    mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBitOps.td
    mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCastOps.td
    mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCompositeOps.td
    mlir/include/mlir/Dialect/SPIRV/IR/SPIRVControlFlowOps.td
    mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCooperativeMatrixOps.td
    mlir/include/mlir/Dialect/SPIRV/IR/SPIRVDialect.h
    mlir/include/mlir/Dialect/SPIRV/IR/SPIRVEnums.h
    mlir/include/mlir/Dialect/SPIRV/IR/SPIRVGLSLOps.td
    mlir/include/mlir/Dialect/SPIRV/IR/SPIRVGroupOps.td
    mlir/include/mlir/Dialect/SPIRV/IR/SPIRVLogicalOps.td
    mlir/include/mlir/Dialect/SPIRV/IR/SPIRVMatrixOps.td
    mlir/include/mlir/Dialect/SPIRV/IR/SPIRVModule.h
    mlir/include/mlir/Dialect/SPIRV/IR/SPIRVNonUniformOps.td
    mlir/include/mlir/Dialect/SPIRV/IR/SPIRVOCLOps.td
    mlir/include/mlir/Dialect/SPIRV/IR/SPIRVOps.h
    mlir/include/mlir/Dialect/SPIRV/IR/SPIRVOps.td
    mlir/include/mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td
    mlir/include/mlir/Dialect/SPIRV/IR/SPIRVTypes.h
    mlir/include/mlir/Dialect/SPIRV/IR/TargetAndABI.h
    mlir/include/mlir/Dialect/SPIRV/IR/TargetAndABI.td
    mlir/include/mlir/Dialect/SPIRV/Linking/ModuleCombiner.h
    mlir/include/mlir/Dialect/SPIRV/Transforms/CMakeLists.txt
    mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.h
    mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.td
    mlir/include/mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h
    mlir/include/mlir/Dialect/SPIRV/Utils/LayoutUtils.h
    mlir/lib/Dialect/SPIRV/IR/CMakeLists.txt
    mlir/lib/Dialect/SPIRV/IR/SPIRVAttributes.cpp
    mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.cpp
    mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.td
    mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp
    mlir/lib/Dialect/SPIRV/IR/SPIRVEnums.cpp
    mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
    mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp
    mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp
    mlir/lib/Dialect/SPIRV/Transforms/DecorateCompositeTypeLayoutPass.cpp
    mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
    mlir/lib/Dialect/SPIRV/Utils/CMakeLists.txt
    mlir/lib/Dialect/SPIRV/Utils/LayoutUtils.cpp
    mlir/test/Dialect/SPIRV/IR/arithmetic-ops.mlir
    mlir/test/Dialect/SPIRV/IR/atomic-ops.mlir
    mlir/test/Dialect/SPIRV/IR/availability.mlir
    mlir/test/Dialect/SPIRV/IR/bit-ops.mlir
    mlir/test/Dialect/SPIRV/IR/composite-ops.mlir
    mlir/test/Dialect/SPIRV/IR/control-flow-ops.mlir
    mlir/test/Dialect/SPIRV/IR/cooperative-matrix-ops.mlir
    mlir/test/Dialect/SPIRV/IR/glsl-ops.mlir
    mlir/test/Dialect/SPIRV/IR/group-ops.mlir
    mlir/test/Dialect/SPIRV/IR/logical-ops.mlir
    mlir/test/Dialect/SPIRV/IR/matrix-ops.mlir
    mlir/test/Dialect/SPIRV/IR/non-uniform-ops.mlir
    mlir/test/Dialect/SPIRV/IR/ocl-ops.mlir
    mlir/test/Dialect/SPIRV/IR/ops.mlir
    mlir/test/Dialect/SPIRV/IR/structure-ops.mlir
    mlir/test/Dialect/SPIRV/IR/target-and-abi.mlir
    mlir/test/Dialect/SPIRV/IR/target-env.mlir
    mlir/test/Dialect/SPIRV/IR/types.mlir
    mlir/test/Dialect/SPIRV/Linking/ModuleCombiner/conflict-resolution.mlir
    mlir/test/Dialect/SPIRV/Linking/ModuleCombiner/deduplication.mlir
    mlir/test/Dialect/SPIRV/Transforms/canonicalize.mlir
    mlir/test/Target/SPIRV/arithmetic-ops.mlir
    mlir/test/Target/SPIRV/array.mlir
    mlir/test/Target/SPIRV/atomic-ops.mlir
    mlir/test/Target/SPIRV/barrier.mlir
    mlir/test/Target/SPIRV/bit-ops.mlir
    mlir/test/Target/SPIRV/cast-ops.mlir
    mlir/test/Target/SPIRV/composite-op.mlir
    mlir/test/Target/SPIRV/constant.mlir
    mlir/test/Target/SPIRV/cooperative-matrix-ops.mlir
    mlir/test/Target/SPIRV/debug.mlir
    mlir/test/Target/SPIRV/decorations.mlir
    mlir/test/Target/SPIRV/entry-point.mlir
    mlir/test/Target/SPIRV/execution-mode.mlir
    mlir/test/Target/SPIRV/function-call.mlir
    mlir/test/Target/SPIRV/global-variable.mlir
    mlir/test/Target/SPIRV/glsl-ops.mlir
    mlir/test/Target/SPIRV/group-ops.mlir
    mlir/test/Target/SPIRV/logical-ops.mlir
    mlir/test/Target/SPIRV/loop.mlir
    mlir/test/Target/SPIRV/matrix.mlir
    mlir/test/Target/SPIRV/memory-ops.mlir
    mlir/test/Target/SPIRV/module.mlir
    mlir/test/Target/SPIRV/non-uniform-ops.mlir
    mlir/test/Target/SPIRV/ocl-ops.mlir
    mlir/test/Target/SPIRV/phi.mlir
    mlir/test/Target/SPIRV/selection.mlir
    mlir/test/Target/SPIRV/spec-constant.mlir
    mlir/test/Target/SPIRV/struct.mlir
    mlir/test/Target/SPIRV/terminator.mlir
    mlir/test/Target/SPIRV/undef.mlir

Modified: 
    mlir/docs/Dialects/SPIR-V.md
    mlir/include/mlir/Dialect/SPIRV/CMakeLists.txt
    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/Linking/ModuleCombiner/ModuleCombiner.cpp
    mlir/lib/Dialect/SPIRV/Transforms/CMakeLists.txt
    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/UpdateVCEPass.cpp
    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/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

Removed: 
    mlir/include/mlir/Dialect/SPIRV/LayoutUtils.h
    mlir/include/mlir/Dialect/SPIRV/ModuleCombiner.h
    mlir/include/mlir/Dialect/SPIRV/ParserUtils.h
    mlir/include/mlir/Dialect/SPIRV/Passes.h
    mlir/include/mlir/Dialect/SPIRV/Passes.td
    mlir/include/mlir/Dialect/SPIRV/SPIRVArithmeticOps.td
    mlir/include/mlir/Dialect/SPIRV/SPIRVAtomicOps.td
    mlir/include/mlir/Dialect/SPIRV/SPIRVAttributes.h
    mlir/include/mlir/Dialect/SPIRV/SPIRVAvailability.td
    mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td
    mlir/include/mlir/Dialect/SPIRV/SPIRVBitOps.td
    mlir/include/mlir/Dialect/SPIRV/SPIRVCastOps.td
    mlir/include/mlir/Dialect/SPIRV/SPIRVCompositeOps.td
    mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td
    mlir/include/mlir/Dialect/SPIRV/SPIRVCooperativeMatrixOps.td
    mlir/include/mlir/Dialect/SPIRV/SPIRVDialect.h
    mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td
    mlir/include/mlir/Dialect/SPIRV/SPIRVGroupOps.td
    mlir/include/mlir/Dialect/SPIRV/SPIRVLogicalOps.td
    mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h
    mlir/include/mlir/Dialect/SPIRV/SPIRVMatrixOps.td
    mlir/include/mlir/Dialect/SPIRV/SPIRVModule.h
    mlir/include/mlir/Dialect/SPIRV/SPIRVNonUniformOps.td
    mlir/include/mlir/Dialect/SPIRV/SPIRVOCLOps.td
    mlir/include/mlir/Dialect/SPIRV/SPIRVOps.h
    mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td
    mlir/include/mlir/Dialect/SPIRV/SPIRVStructureOps.td
    mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h
    mlir/include/mlir/Dialect/SPIRV/TargetAndABI.h
    mlir/include/mlir/Dialect/SPIRV/TargetAndABI.td
    mlir/lib/Dialect/SPIRV/LayoutUtils.cpp
    mlir/lib/Dialect/SPIRV/SPIRVAttributes.cpp
    mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.cpp
    mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.td
    mlir/lib/Dialect/SPIRV/SPIRVDialect.cpp
    mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp
    mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
    mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp
    mlir/lib/Dialect/SPIRV/TargetAndABI.cpp
    mlir/lib/Dialect/SPIRV/Transforms/DecorateSPIRVCompositeTypeLayoutPass.cpp
    mlir/test/Dialect/SPIRV/Linking/ModuleCombiner/conflict_resolution.mlir
    mlir/test/Dialect/SPIRV/Linking/ModuleCombiner/deduplication_basic.mlir
    mlir/test/Dialect/SPIRV/Serialization/arithmetic-ops.mlir
    mlir/test/Dialect/SPIRV/Serialization/array.mlir
    mlir/test/Dialect/SPIRV/Serialization/atomic-ops.mlir
    mlir/test/Dialect/SPIRV/Serialization/barrier.mlir
    mlir/test/Dialect/SPIRV/Serialization/bit-ops.mlir
    mlir/test/Dialect/SPIRV/Serialization/cast-ops.mlir
    mlir/test/Dialect/SPIRV/Serialization/composite-op.mlir
    mlir/test/Dialect/SPIRV/Serialization/constant.mlir
    mlir/test/Dialect/SPIRV/Serialization/cooperative-matrix.mlir
    mlir/test/Dialect/SPIRV/Serialization/debug.mlir
    mlir/test/Dialect/SPIRV/Serialization/decorations.mlir
    mlir/test/Dialect/SPIRV/Serialization/entry-point.mlir
    mlir/test/Dialect/SPIRV/Serialization/execution-mode.mlir
    mlir/test/Dialect/SPIRV/Serialization/function-call.mlir
    mlir/test/Dialect/SPIRV/Serialization/global-variable.mlir
    mlir/test/Dialect/SPIRV/Serialization/glsl-ops.mlir
    mlir/test/Dialect/SPIRV/Serialization/group-ops.mlir
    mlir/test/Dialect/SPIRV/Serialization/logical-ops.mlir
    mlir/test/Dialect/SPIRV/Serialization/loop.mlir
    mlir/test/Dialect/SPIRV/Serialization/matrix.mlir
    mlir/test/Dialect/SPIRV/Serialization/memory-ops.mlir
    mlir/test/Dialect/SPIRV/Serialization/module.mlir
    mlir/test/Dialect/SPIRV/Serialization/non-uniform-ops.mlir
    mlir/test/Dialect/SPIRV/Serialization/ocl-ops.mlir
    mlir/test/Dialect/SPIRV/Serialization/phi.mlir
    mlir/test/Dialect/SPIRV/Serialization/selection.mlir
    mlir/test/Dialect/SPIRV/Serialization/spec-constant.mlir
    mlir/test/Dialect/SPIRV/Serialization/struct.mlir
    mlir/test/Dialect/SPIRV/Serialization/terminator.mlir
    mlir/test/Dialect/SPIRV/Serialization/undef.mlir
    mlir/test/Dialect/SPIRV/arithmetic-ops.mlir
    mlir/test/Dialect/SPIRV/atomic-ops.mlir
    mlir/test/Dialect/SPIRV/availability.mlir
    mlir/test/Dialect/SPIRV/bit-ops.mlir
    mlir/test/Dialect/SPIRV/canonicalize.mlir
    mlir/test/Dialect/SPIRV/composite-ops.mlir
    mlir/test/Dialect/SPIRV/control-flow-ops.mlir
    mlir/test/Dialect/SPIRV/cooperative-matrix.mlir
    mlir/test/Dialect/SPIRV/glslops.mlir
    mlir/test/Dialect/SPIRV/group-ops.mlir
    mlir/test/Dialect/SPIRV/logical-ops.mlir
    mlir/test/Dialect/SPIRV/matrix-ops.mlir
    mlir/test/Dialect/SPIRV/non-uniform-ops.mlir
    mlir/test/Dialect/SPIRV/ocl-ops.mlir
    mlir/test/Dialect/SPIRV/ops.mlir
    mlir/test/Dialect/SPIRV/structure-ops.mlir
    mlir/test/Dialect/SPIRV/target-and-abi.mlir
    mlir/test/Dialect/SPIRV/target-env.mlir
    mlir/test/Dialect/SPIRV/types.mlir


################################################################################
diff  --git a/mlir/docs/Dialects/SPIR-V.md b/mlir/docs/Dialects/SPIR-V.md
index 3432ddfdbd14..f30d82fd2810 100644
--- a/mlir/docs/Dialects/SPIR-V.md
+++ b/mlir/docs/Dialects/SPIR-V.md
@@ -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

diff  --git a/mlir/include/mlir/Dialect/SPIRV/CMakeLists.txt b/mlir/include/mlir/Dialect/SPIRV/CMakeLists.txt
index ff078ef9d946..9f57627c321f 100644
--- a/mlir/include/mlir/Dialect/SPIRV/CMakeLists.txt
+++ b/mlir/include/mlir/Dialect/SPIRV/CMakeLists.txt
@@ -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
index 000000000000..9b0f7baa3d81
--- /dev/null
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/CMakeLists.txt
@@ -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)

diff  --git a/mlir/include/mlir/Dialect/SPIRV/ParserUtils.h b/mlir/include/mlir/Dialect/SPIRV/IR/ParserUtils.h
similarity index 87%
rename from mlir/include/mlir/Dialect/SPIRV/ParserUtils.h
rename to mlir/include/mlir/Dialect/SPIRV/IR/ParserUtils.h
index f368aec45efb..36d66f123ea5 100644
--- a/mlir/include/mlir/Dialect/SPIRV/ParserUtils.h
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/ParserUtils.h
@@ -10,14 +10,16 @@
 // 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_

diff  --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVArithmeticOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVArithmeticOps.td
similarity index 98%
rename from mlir/include/mlir/Dialect/SPIRV/SPIRVArithmeticOps.td
rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVArithmeticOps.td
index 5a12e6f36ec4..0d6dd015b7e3 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVArithmeticOps.td
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVArithmeticOps.td
@@ -11,10 +11,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#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

diff  --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVAtomicOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td
similarity index 99%
rename from mlir/include/mlir/Dialect/SPIRV/SPIRVAtomicOps.td
rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td
index 69d57ad0125d..1c9dbd758857 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVAtomicOps.td
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td
@@ -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

diff  --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVAttributes.h b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAttributes.h
similarity index 91%
rename from mlir/include/mlir/Dialect/SPIRV/SPIRVAttributes.h
rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAttributes.h
index b948df39b3fc..1c253f9f5984 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVAttributes.h
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAttributes.h
@@ -10,15 +10,15 @@
 //
 //===----------------------------------------------------------------------===//
 
-#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 @@ class TargetEnvAttr
 } // namespace spirv
 } // namespace mlir
 
-#endif // MLIR_DIALECT_SPIRV_SPIRVATTRIBUTES_H
+#endif // MLIR_DIALECT_SPIRV_IR_SPIRVATTRIBUTES_H

diff  --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVAvailability.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAvailability.td
similarity index 96%
rename from mlir/include/mlir/Dialect/SPIRV/SPIRVAvailability.td
rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAvailability.td
index 712237c895dd..4e2e943bc3d9 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVAvailability.td
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAvailability.td
@@ -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

diff  --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td
similarity index 99%
rename from mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td
rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td
index 0d80ecc8ddda..9e32af59f397 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td
@@ -12,11 +12,11 @@
 //
 //===----------------------------------------------------------------------===//
 
-#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

diff  --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVBitOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBitOps.td
similarity index 99%
rename from mlir/include/mlir/Dialect/SPIRV/SPIRVBitOps.td
rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBitOps.td
index ddc9ab559375..3df9798c4d81 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVBitOps.td
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBitOps.td
@@ -11,10 +11,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#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

diff  --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVCastOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCastOps.td
similarity index 98%
rename from mlir/include/mlir/Dialect/SPIRV/SPIRVCastOps.td
rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCastOps.td
index 0e595984dde4..726f79f94fa1 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVCastOps.td
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCastOps.td
@@ -11,10 +11,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#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

diff  --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVCompositeOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCompositeOps.td
similarity index 97%
rename from mlir/include/mlir/Dialect/SPIRV/SPIRVCompositeOps.td
rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCompositeOps.td
index 8c9eac195878..035d73f1c842 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVCompositeOps.td
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCompositeOps.td
@@ -11,10 +11,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#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

diff  --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVControlFlowOps.td
similarity index 98%
rename from mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td
rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVControlFlowOps.td
index 76fdc64e59da..1605672bb864 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVControlFlowOps.td
@@ -11,10 +11,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#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

diff  --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVCooperativeMatrixOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCooperativeMatrixOps.td
similarity index 98%
rename from mlir/include/mlir/Dialect/SPIRV/SPIRVCooperativeMatrixOps.td
rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCooperativeMatrixOps.td
index 720cfd697c24..c64e8d4e9221 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVCooperativeMatrixOps.td
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCooperativeMatrixOps.td
@@ -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

diff  --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVDialect.h b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVDialect.h
similarity index 77%
rename from mlir/include/mlir/Dialect/SPIRV/SPIRVDialect.h
rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVDialect.h
index 1b37abb93764..f08e9db4dc4e 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVDialect.h
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVDialect.h
@@ -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
index 000000000000..e5838eff0600
--- /dev/null
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVEnums.h
@@ -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_

diff  --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVGLSLOps.td
similarity index 99%
rename from mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td
rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVGLSLOps.td
index 73745fe4694e..ea3e98e963a4 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVGLSLOps.td
@@ -10,10 +10,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#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

diff  --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVGroupOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVGroupOps.td
similarity index 98%
rename from mlir/include/mlir/Dialect/SPIRV/SPIRVGroupOps.td
rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVGroupOps.td
index 7eab3b44601e..8cad962de5d3 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVGroupOps.td
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVGroupOps.td
@@ -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

diff  --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVLogicalOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVLogicalOps.td
similarity index 99%
rename from mlir/include/mlir/Dialect/SPIRV/SPIRVLogicalOps.td
rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVLogicalOps.td
index 1cb9cfe812df..71254c17fbc3 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVLogicalOps.td
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVLogicalOps.td
@@ -11,10 +11,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#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

diff  --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVMatrixOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVMatrixOps.td
similarity index 97%
rename from mlir/include/mlir/Dialect/SPIRV/SPIRVMatrixOps.td
rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVMatrixOps.td
index 70479e743b0d..0f009edd5830 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVMatrixOps.td
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVMatrixOps.td
@@ -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

diff  --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVModule.h b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVModule.h
similarity index 82%
rename from mlir/include/mlir/Dialect/SPIRV/SPIRVModule.h
rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVModule.h
index 9f2692f8e903..f64a5029bbf2 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVModule.h
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVModule.h
@@ -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 @@ class OwningSPIRVModuleRef : public OwningOpRef<spirv::ModuleOp> {
 } // end namespace spirv
 } // end namespace mlir
 
-#endif // MLIR_DIALECT_SPIRV_SPIRVMODULE_H
+#endif // MLIR_DIALECT_SPIRV_IR_SPIRVMODULE_H

diff  --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVNonUniformOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVNonUniformOps.td
similarity index 99%
rename from mlir/include/mlir/Dialect/SPIRV/SPIRVNonUniformOps.td
rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVNonUniformOps.td
index 7d75f7b87452..9a22a930b62d 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVNonUniformOps.td
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVNonUniformOps.td
@@ -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

diff  --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVOCLOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVOCLOps.td
similarity index 96%
rename from mlir/include/mlir/Dialect/SPIRV/SPIRVOCLOps.td
rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVOCLOps.td
index 78151bafb654..fda4a0ce3c6e 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVOCLOps.td
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVOCLOps.td
@@ -10,10 +10,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#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

diff  --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.h b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVOps.h
similarity index 78%
rename from mlir/include/mlir/Dialect/SPIRV/SPIRVOps.h
rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVOps.h
index ae576d9cd46b..5e9a46d039d7 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.h
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVOps.h
@@ -10,10 +10,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#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 @@ struct PointerLikeTypeTraits<mlir::spirv::FuncOp> {
 
 } // namespace llvm
 
-#endif // MLIR_DIALECT_SPIRV_SPIRVOPS_H_
+#endif // MLIR_DIALECT_SPIRV_IR_SPIRVOPS_H_

diff  --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVOps.td
similarity index 94%
rename from mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td
rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVOps.td
index 3fc60d018cce..3621ff71f9c7 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVOps.td
@@ -18,24 +18,24 @@
 // 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

diff  --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVStructureOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td
similarity index 99%
rename from mlir/include/mlir/Dialect/SPIRV/SPIRVStructureOps.td
rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td
index 1ae7d285cd93..88183f98c6d1 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVStructureOps.td
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td
@@ -12,10 +12,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#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

diff  --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVTypes.h
similarity index 89%
rename from mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h
rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVTypes.h
index 9f621cd6526b..3065c772b55b 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVTypes.h
@@ -10,9 +10,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#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"
@@ -21,38 +22,8 @@
 
 #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 @@ class StructType : public Type::TypeBase<StructType, CompositeType,
 
   // 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 @@ class MatrixType : public Type::TypeBase<MatrixType, CompositeType,
 } // end namespace spirv
 } // end namespace mlir
 
-#endif // MLIR_DIALECT_SPIRV_SPIRVTYPES_H_
+#endif // MLIR_DIALECT_SPIRV_IR_SPIRVTYPES_H_

diff  --git a/mlir/include/mlir/Dialect/SPIRV/TargetAndABI.h b/mlir/include/mlir/Dialect/SPIRV/IR/TargetAndABI.h
similarity index 96%
rename from mlir/include/mlir/Dialect/SPIRV/TargetAndABI.h
rename to mlir/include/mlir/Dialect/SPIRV/IR/TargetAndABI.h
index 4d7b96fae009..146ca7d38046 100644
--- a/mlir/include/mlir/Dialect/SPIRV/TargetAndABI.h
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/TargetAndABI.h
@@ -10,10 +10,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#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

diff  --git a/mlir/include/mlir/Dialect/SPIRV/TargetAndABI.td b/mlir/include/mlir/Dialect/SPIRV/IR/TargetAndABI.td
similarity index 95%
rename from mlir/include/mlir/Dialect/SPIRV/TargetAndABI.td
rename to mlir/include/mlir/Dialect/SPIRV/IR/TargetAndABI.td
index 13bffabaef17..f9a6600df2ac 100644
--- a/mlir/include/mlir/Dialect/SPIRV/TargetAndABI.td
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/TargetAndABI.td
@@ -18,10 +18,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#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

diff  --git a/mlir/include/mlir/Dialect/SPIRV/ModuleCombiner.h b/mlir/include/mlir/Dialect/SPIRV/Linking/ModuleCombiner.h
similarity index 93%
rename from mlir/include/mlir/Dialect/SPIRV/ModuleCombiner.h
rename to mlir/include/mlir/Dialect/SPIRV/Linking/ModuleCombiner.h
index 36071f00b94d..6d40e29333b4 100644
--- a/mlir/include/mlir/Dialect/SPIRV/ModuleCombiner.h
+++ b/mlir/include/mlir/Dialect/SPIRV/Linking/ModuleCombiner.h
@@ -10,10 +10,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#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
index 000000000000..f5342e1f29d0
--- /dev/null
+++ b/mlir/include/mlir/Dialect/SPIRV/Transforms/CMakeLists.txt
@@ -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 ./)
+

diff  --git a/mlir/include/mlir/Dialect/SPIRV/Passes.h b/mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.h
similarity index 87%
rename from mlir/include/mlir/Dialect/SPIRV/Passes.h
rename to mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.h
index dbd2c93a53a5..38548fee3268 100644
--- a/mlir/include/mlir/Dialect/SPIRV/Passes.h
+++ b/mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.h
@@ -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_

diff  --git a/mlir/include/mlir/Dialect/SPIRV/Passes.td b/mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.td
similarity index 91%
rename from mlir/include/mlir/Dialect/SPIRV/Passes.td
rename to mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.td
index 93a3516fc2b3..575bb0898faa 100644
--- a/mlir/include/mlir/Dialect/SPIRV/Passes.td
+++ b/mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.td
@@ -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

diff  --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h b/mlir/include/mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h
similarity index 92%
rename from mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h
rename to mlir/include/mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h
index 1ebf702ff8a2..fddf84859bc2 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h
+++ b/mlir/include/mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h
@@ -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

diff  --git a/mlir/include/mlir/Dialect/SPIRV/LayoutUtils.h b/mlir/include/mlir/Dialect/SPIRV/Utils/LayoutUtils.h
similarity index 92%
rename from mlir/include/mlir/Dialect/SPIRV/LayoutUtils.h
rename to mlir/include/mlir/Dialect/SPIRV/Utils/LayoutUtils.h
index fdae7be1eaed..1f1fa79153d3 100644
--- a/mlir/include/mlir/Dialect/SPIRV/LayoutUtils.h
+++ b/mlir/include/mlir/Dialect/SPIRV/Utils/LayoutUtils.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 @@ class VulkanLayoutUtils {
 
 } // namespace mlir
 
-#endif // MLIR_DIALECT_SPIRV_LAYOUTUTILS_H_
+#endif // MLIR_DIALECT_SPIRV_UTILS_LAYOUTUTILS_H_

diff  --git a/mlir/include/mlir/InitAllDialects.h b/mlir/include/mlir/InitAllDialects.h
index a541fa4742ba..0367f9de2d18 100644
--- a/mlir/include/mlir/InitAllDialects.h
+++ b/mlir/include/mlir/InitAllDialects.h
@@ -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"

diff  --git a/mlir/include/mlir/InitAllPasses.h b/mlir/include/mlir/InitAllPasses.h
index 12b63991a901..a3de7e345c70 100644
--- a/mlir/include/mlir/InitAllPasses.h
+++ b/mlir/include/mlir/InitAllPasses.h
@@ -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"

diff  --git a/mlir/include/mlir/Target/SPIRV/SPIRVBinaryUtils.h b/mlir/include/mlir/Target/SPIRV/SPIRVBinaryUtils.h
index cdfadb02fe5c..f12ca452236d 100644
--- a/mlir/include/mlir/Target/SPIRV/SPIRVBinaryUtils.h
+++ b/mlir/include/mlir/Target/SPIRV/SPIRVBinaryUtils.h
@@ -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>

diff  --git a/mlir/lib/Conversion/GPUToSPIRV/CMakeLists.txt b/mlir/lib/Conversion/GPUToSPIRV/CMakeLists.txt
index 2da9c709079f..fba29cf5f342 100644
--- a/mlir/lib/Conversion/GPUToSPIRV/CMakeLists.txt
+++ b/mlir/lib/Conversion/GPUToSPIRV/CMakeLists.txt
@@ -16,6 +16,7 @@ add_mlir_conversion_library(MLIRGPUToSPIRVTransforms
   MLIRPass
   MLIRSCFToSPIRV
   MLIRSPIRV
+  MLIRSPIRVConversion
   MLIRStandard
   MLIRStandardToSPIRVTransforms
   MLIRSupport

diff  --git a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp
index 1b25ffd0943f..259acd7a9ce7 100644
--- a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp
+++ b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp
@@ -11,10 +11,10 @@
 //===----------------------------------------------------------------------===//
 #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;

diff  --git a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.cpp b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.cpp
index 083f992bda95..973aa3d79bd8 100644
--- a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.cpp
+++ b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRVPass.cpp
@@ -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;
 

diff  --git a/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.td b/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.td
index 0285d1c769c7..961558255748 100644
--- a/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.td
+++ b/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.td
@@ -11,12 +11,12 @@
 //===----------------------------------------------------------------------===//
 
 
-#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

diff  --git a/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp b/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp
index 3808e3df024c..958275603532 100644
--- a/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp
+++ b/mlir/lib/Conversion/GPUToVulkan/ConvertGPULaunchFuncToVulkanLaunchFunc.cpp
@@ -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"

diff  --git a/mlir/lib/Conversion/LinalgToSPIRV/CMakeLists.txt b/mlir/lib/Conversion/LinalgToSPIRV/CMakeLists.txt
index e76e9b7f5012..a40abba0351f 100644
--- a/mlir/lib/Conversion/LinalgToSPIRV/CMakeLists.txt
+++ b/mlir/lib/Conversion/LinalgToSPIRV/CMakeLists.txt
@@ -15,5 +15,6 @@ add_mlir_conversion_library(MLIRLinalgToSPIRVTransforms
   MLIRLinalgUtils
   MLIRPass
   MLIRSPIRV
+  MLIRSPIRVConversion
   MLIRSupport
   )

diff  --git a/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp b/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp
index 18e269330ea8..0e09d9596a62 100644
--- a/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp
+++ b/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp
@@ -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"

diff  --git a/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.cpp b/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.cpp
index d0b724b0484c..1ce2f41f46b8 100644
--- a/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.cpp
+++ b/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.cpp
@@ -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;
 

diff  --git a/mlir/lib/Conversion/SCFToSPIRV/CMakeLists.txt b/mlir/lib/Conversion/SCFToSPIRV/CMakeLists.txt
index 1a3867627720..d77a759d5f38 100644
--- a/mlir/lib/Conversion/SCFToSPIRV/CMakeLists.txt
+++ b/mlir/lib/Conversion/SCFToSPIRV/CMakeLists.txt
@@ -11,6 +11,7 @@ add_mlir_conversion_library(MLIRSCFToSPIRV
   MLIRAffine
   MLIRAffineToStandard
   MLIRSPIRV
+  MLIRSPIRVConversion
   MLIRIR
   MLIRLinalg
   MLIRPass

diff  --git a/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp b/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp
index 754e1937a783..576f38fba819 100644
--- a/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp
+++ b/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp
@@ -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;

diff  --git a/mlir/lib/Conversion/SPIRVToLLVM/CMakeLists.txt b/mlir/lib/Conversion/SPIRVToLLVM/CMakeLists.txt
index 5c18928ad37a..8d3cbc6c7c33 100644
--- a/mlir/lib/Conversion/SPIRVToLLVM/CMakeLists.txt
+++ b/mlir/lib/Conversion/SPIRVToLLVM/CMakeLists.txt
@@ -13,6 +13,7 @@ add_mlir_conversion_library(MLIRSPIRVToLLVM
   LINK_LIBS PUBLIC
   MLIRGPU
   MLIRSPIRV
+  MLIRSPIRVUtils
   MLIRLLVMIR
   MLIRStandardToLLVM
   MLIRIR

diff  --git a/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp b/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp
index b01c443ddc77..1724c7044339 100644
--- a/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp
+++ b/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp
@@ -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"

diff  --git a/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp b/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp
index 935433cf11a8..22a43100cb0e 100644
--- a/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp
+++ b/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp
@@ -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"

diff  --git a/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVMPass.cpp b/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVMPass.cpp
index cea0e76221e5..b93ce48cb804 100644
--- a/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVMPass.cpp
+++ b/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVMPass.cpp
@@ -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;
 

diff  --git a/mlir/lib/Conversion/StandardToSPIRV/CMakeLists.txt b/mlir/lib/Conversion/StandardToSPIRV/CMakeLists.txt
index 5ccbcc6b3947..4af5d7d4f83a 100644
--- a/mlir/lib/Conversion/StandardToSPIRV/CMakeLists.txt
+++ b/mlir/lib/Conversion/StandardToSPIRV/CMakeLists.txt
@@ -14,8 +14,8 @@ add_mlir_conversion_library(MLIRStandardToSPIRVTransforms
   MLIRIR
   MLIRPass
   MLIRSPIRV
+  MLIRSPIRVConversion
   MLIRSupport
   MLIRTransformUtils
-  MLIRSPIRV
   MLIRStandard
   )

diff  --git a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
index cd5079f50425..d15623568212 100644
--- a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
+++ b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
@@ -10,10 +10,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#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"

diff  --git a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp
index aea78523ca01..c2477e852307 100644
--- a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp
+++ b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.cpp
@@ -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;
 

diff  --git a/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp b/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp
index eb237cf35154..ea483aa6abae 100644
--- a/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp
+++ b/mlir/lib/Conversion/StandardToSPIRV/LegalizeStandardForSPIRV.cpp
@@ -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"

diff  --git a/mlir/lib/Conversion/VectorToSPIRV/CMakeLists.txt b/mlir/lib/Conversion/VectorToSPIRV/CMakeLists.txt
index a6e73002de25..060afdfbbddb 100644
--- a/mlir/lib/Conversion/VectorToSPIRV/CMakeLists.txt
+++ b/mlir/lib/Conversion/VectorToSPIRV/CMakeLists.txt
@@ -10,6 +10,7 @@ add_mlir_conversion_library(MLIRVectorToSPIRV
 
   LINK_LIBS PUBLIC
   MLIRSPIRV
+  MLIRSPIRVConversion
   MLIRVector
   MLIRTransforms
   )

diff  --git a/mlir/lib/Conversion/VectorToSPIRV/VectorToSPIRV.cpp b/mlir/lib/Conversion/VectorToSPIRV/VectorToSPIRV.cpp
index 220fa62f9e9a..7f7339190115 100644
--- a/mlir/lib/Conversion/VectorToSPIRV/VectorToSPIRV.cpp
+++ b/mlir/lib/Conversion/VectorToSPIRV/VectorToSPIRV.cpp
@@ -14,10 +14,10 @@
 #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"

diff  --git a/mlir/lib/Dialect/SPIRV/CMakeLists.txt b/mlir/lib/Dialect/SPIRV/CMakeLists.txt
index 8362a980cc5e..4d73d45f39ec 100644
--- a/mlir/lib/Dialect/SPIRV/CMakeLists.txt
+++ b/mlir/lib/Dialect/SPIRV/CMakeLists.txt
@@ -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
index 000000000000..dbf62425878b
--- /dev/null
+++ b/mlir/lib/Dialect/SPIRV/IR/CMakeLists.txt
@@ -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
+)

diff  --git a/mlir/lib/Dialect/SPIRV/SPIRVAttributes.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVAttributes.cpp
similarity index 96%
rename from mlir/lib/Dialect/SPIRV/SPIRVAttributes.cpp
rename to mlir/lib/Dialect/SPIRV/IR/SPIRVAttributes.cpp
index 2f90951fadd4..98e0b94c8bc7 100644
--- a/mlir/lib/Dialect/SPIRV/SPIRVAttributes.cpp
+++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVAttributes.cpp
@@ -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 {
 

diff  --git a/mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.cpp
similarity index 99%
rename from mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.cpp
rename to mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.cpp
index bc965d1db6aa..7f268ca92964 100644
--- a/mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.cpp
+++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.cpp
@@ -10,11 +10,11 @@
 //
 //===----------------------------------------------------------------------===//
 
-#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 @@ struct ConvertSelectionOpToSelect
     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());

diff  --git a/mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.td b/mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.td
similarity index 97%
rename from mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.td
rename to mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.td
index baa9027e448b..125e97360865 100644
--- a/mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.td
+++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.td
@@ -10,7 +10,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-include "mlir/Dialect/SPIRV/SPIRVOps.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVOps.td"
 
 //===----------------------------------------------------------------------===//
 // spv.Bitcast

diff  --git a/mlir/lib/Dialect/SPIRV/SPIRVDialect.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp
similarity index 99%
rename from mlir/lib/Dialect/SPIRV/SPIRVDialect.cpp
rename to mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp
index 26d7067ad91f..c53048c7a5ff 100644
--- a/mlir/lib/Dialect/SPIRV/SPIRVDialect.cpp
+++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp
@@ -10,11 +10,11 @@
 //
 //===----------------------------------------------------------------------===//
 
-#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"
@@ -30,12 +30,6 @@
 #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
index 000000000000..a289d9d2801b
--- /dev/null
+++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVEnums.cpp
@@ -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();
+}

diff  --git a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
similarity index 99%
rename from mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
rename to mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
index 43b3c517a4c6..6cada4a7b01d 100644
--- a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
+++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
@@ -10,13 +10,13 @@
 //
 //===----------------------------------------------------------------------===//
 
-#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

diff  --git a/mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp
similarity index 91%
rename from mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp
rename to mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp
index 15fafddf9f24..fa8576a6753a 100644
--- a/mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp
+++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp
@@ -10,93 +10,17 @@
 //
 //===----------------------------------------------------------------------===//
 
-#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;

diff  --git a/mlir/lib/Dialect/SPIRV/TargetAndABI.cpp b/mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp
similarity index 98%
rename from mlir/lib/Dialect/SPIRV/TargetAndABI.cpp
rename to mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp
index f409f1d14a98..b6c5f82c6c7d 100644
--- a/mlir/lib/Dialect/SPIRV/TargetAndABI.cpp
+++ b/mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp
@@ -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"

diff  --git a/mlir/lib/Dialect/SPIRV/Linking/ModuleCombiner/ModuleCombiner.cpp b/mlir/lib/Dialect/SPIRV/Linking/ModuleCombiner/ModuleCombiner.cpp
index c9ba8a353990..1f4bfd37bddc 100644
--- a/mlir/lib/Dialect/SPIRV/Linking/ModuleCombiner/ModuleCombiner.cpp
+++ b/mlir/lib/Dialect/SPIRV/Linking/ModuleCombiner/ModuleCombiner.cpp
@@ -10,10 +10,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#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"

diff  --git a/mlir/lib/Dialect/SPIRV/Transforms/CMakeLists.txt b/mlir/lib/Dialect/SPIRV/Transforms/CMakeLists.txt
index 228d8482e6be..db274088bdf2 100644
--- a/mlir/lib/Dialect/SPIRV/Transforms/CMakeLists.txt
+++ b/mlir/lib/Dialect/SPIRV/Transforms/CMakeLists.txt
@@ -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
+)

diff  --git a/mlir/lib/Dialect/SPIRV/Transforms/DecorateSPIRVCompositeTypeLayoutPass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/DecorateCompositeTypeLayoutPass.cpp
similarity index 93%
rename from mlir/lib/Dialect/SPIRV/Transforms/DecorateSPIRVCompositeTypeLayoutPass.cpp
rename to mlir/lib/Dialect/SPIRV/Transforms/DecorateCompositeTypeLayoutPass.cpp
index 282c6bbfb651..aaa5b46b80d5 100644
--- a/mlir/lib/Dialect/SPIRV/Transforms/DecorateSPIRVCompositeTypeLayoutPass.cpp
+++ b/mlir/lib/Dialect/SPIRV/Transforms/DecorateCompositeTypeLayoutPass.cpp
@@ -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.
@@ -14,10 +14,10 @@
 //===----------------------------------------------------------------------===//
 
 #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;

diff  --git a/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp
index 12f0152079cc..aeff47a831ef 100644
--- a/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp
+++ b/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp
@@ -12,11 +12,11 @@
 //===----------------------------------------------------------------------===//
 
 #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"
 

diff  --git a/mlir/lib/Dialect/SPIRV/Transforms/PassDetail.h b/mlir/lib/Dialect/SPIRV/Transforms/PassDetail.h
index 3c56f21e9360..cb4f01f1e908 100644
--- a/mlir/lib/Dialect/SPIRV/Transforms/PassDetail.h
+++ b/mlir/lib/Dialect/SPIRV/Transforms/PassDetail.h
@@ -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
 

diff  --git a/mlir/lib/Dialect/SPIRV/Transforms/RewriteInsertsPass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/RewriteInsertsPass.cpp
index 87008315f69f..b89312fb8ae7 100644
--- a/mlir/lib/Dialect/SPIRV/Transforms/RewriteInsertsPass.cpp
+++ b/mlir/lib/Dialect/SPIRV/Transforms/RewriteInsertsPass.cpp
@@ -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"
 

diff  --git a/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp b/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
similarity index 99%
rename from mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp
rename to mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
index d629e2229ce6..bf3a509c73be 100644
--- a/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp
+++ b/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp
@@ -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.
@@ -10,17 +10,16 @@
 //
 //===----------------------------------------------------------------------===//
 
-#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;
 

diff  --git a/mlir/lib/Dialect/SPIRV/Transforms/UpdateVCEPass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/UpdateVCEPass.cpp
index 00e9ffa813a9..c5a880400efe 100644
--- a/mlir/lib/Dialect/SPIRV/Transforms/UpdateVCEPass.cpp
+++ b/mlir/lib/Dialect/SPIRV/Transforms/UpdateVCEPass.cpp
@@ -12,11 +12,11 @@
 //===----------------------------------------------------------------------===//
 
 #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
index 000000000000..fa0f9322b838
--- /dev/null
+++ b/mlir/lib/Dialect/SPIRV/Utils/CMakeLists.txt
@@ -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
+)
+

diff  --git a/mlir/lib/Dialect/SPIRV/LayoutUtils.cpp b/mlir/lib/Dialect/SPIRV/Utils/LayoutUtils.cpp
similarity index 97%
rename from mlir/lib/Dialect/SPIRV/LayoutUtils.cpp
rename to mlir/lib/Dialect/SPIRV/Utils/LayoutUtils.cpp
index 9094d2e96b8f..b5a38c34799b 100644
--- a/mlir/lib/Dialect/SPIRV/LayoutUtils.cpp
+++ b/mlir/lib/Dialect/SPIRV/Utils/LayoutUtils.cpp
@@ -10,9 +10,10 @@
 // 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;
 

diff  --git a/mlir/lib/Target/SPIRV/Deserialization.cpp b/mlir/lib/Target/SPIRV/Deserialization.cpp
index 6512b1a0f111..bf2c14318d37 100644
--- a/mlir/lib/Target/SPIRV/Deserialization.cpp
+++ b/mlir/lib/Target/SPIRV/Deserialization.cpp
@@ -12,10 +12,10 @@
 
 #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 {

diff  --git a/mlir/lib/Target/SPIRV/SPIRVBinaryUtils.cpp b/mlir/lib/Target/SPIRV/SPIRVBinaryUtils.cpp
index e1795021b335..769718bacffc 100644
--- a/mlir/lib/Target/SPIRV/SPIRVBinaryUtils.cpp
+++ b/mlir/lib/Target/SPIRV/SPIRVBinaryUtils.cpp
@@ -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;
 

diff  --git a/mlir/lib/Target/SPIRV/Serialization.cpp b/mlir/lib/Target/SPIRV/Serialization.cpp
index 5d05197e2659..cb41c7be93cb 100644
--- a/mlir/lib/Target/SPIRV/Serialization.cpp
+++ b/mlir/lib/Target/SPIRV/Serialization.cpp
@@ -12,10 +12,10 @@
 
 #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,

diff  --git a/mlir/lib/Target/SPIRV/TranslateRegistration.cpp b/mlir/lib/Target/SPIRV/TranslateRegistration.cpp
index f4cf45ae1956..70af479f414b 100644
--- a/mlir/lib/Target/SPIRV/TranslateRegistration.cpp
+++ b/mlir/lib/Target/SPIRV/TranslateRegistration.cpp
@@ -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"

diff  --git a/mlir/test/Dialect/SPIRV/arithmetic-ops.mlir b/mlir/test/Dialect/SPIRV/IR/arithmetic-ops.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/arithmetic-ops.mlir
rename to mlir/test/Dialect/SPIRV/IR/arithmetic-ops.mlir

diff  --git a/mlir/test/Dialect/SPIRV/atomic-ops.mlir b/mlir/test/Dialect/SPIRV/IR/atomic-ops.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/atomic-ops.mlir
rename to mlir/test/Dialect/SPIRV/IR/atomic-ops.mlir

diff  --git a/mlir/test/Dialect/SPIRV/availability.mlir b/mlir/test/Dialect/SPIRV/IR/availability.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/availability.mlir
rename to mlir/test/Dialect/SPIRV/IR/availability.mlir

diff  --git a/mlir/test/Dialect/SPIRV/bit-ops.mlir b/mlir/test/Dialect/SPIRV/IR/bit-ops.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/bit-ops.mlir
rename to mlir/test/Dialect/SPIRV/IR/bit-ops.mlir

diff  --git a/mlir/test/Dialect/SPIRV/composite-ops.mlir b/mlir/test/Dialect/SPIRV/IR/composite-ops.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/composite-ops.mlir
rename to mlir/test/Dialect/SPIRV/IR/composite-ops.mlir

diff  --git a/mlir/test/Dialect/SPIRV/control-flow-ops.mlir b/mlir/test/Dialect/SPIRV/IR/control-flow-ops.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/control-flow-ops.mlir
rename to mlir/test/Dialect/SPIRV/IR/control-flow-ops.mlir

diff  --git a/mlir/test/Dialect/SPIRV/cooperative-matrix.mlir b/mlir/test/Dialect/SPIRV/IR/cooperative-matrix-ops.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/cooperative-matrix.mlir
rename to mlir/test/Dialect/SPIRV/IR/cooperative-matrix-ops.mlir

diff  --git a/mlir/test/Dialect/SPIRV/glslops.mlir b/mlir/test/Dialect/SPIRV/IR/glsl-ops.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/glslops.mlir
rename to mlir/test/Dialect/SPIRV/IR/glsl-ops.mlir

diff  --git a/mlir/test/Dialect/SPIRV/group-ops.mlir b/mlir/test/Dialect/SPIRV/IR/group-ops.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/group-ops.mlir
rename to mlir/test/Dialect/SPIRV/IR/group-ops.mlir

diff  --git a/mlir/test/Dialect/SPIRV/logical-ops.mlir b/mlir/test/Dialect/SPIRV/IR/logical-ops.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/logical-ops.mlir
rename to mlir/test/Dialect/SPIRV/IR/logical-ops.mlir

diff  --git a/mlir/test/Dialect/SPIRV/matrix-ops.mlir b/mlir/test/Dialect/SPIRV/IR/matrix-ops.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/matrix-ops.mlir
rename to mlir/test/Dialect/SPIRV/IR/matrix-ops.mlir

diff  --git a/mlir/test/Dialect/SPIRV/non-uniform-ops.mlir b/mlir/test/Dialect/SPIRV/IR/non-uniform-ops.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/non-uniform-ops.mlir
rename to mlir/test/Dialect/SPIRV/IR/non-uniform-ops.mlir

diff  --git a/mlir/test/Dialect/SPIRV/ocl-ops.mlir b/mlir/test/Dialect/SPIRV/IR/ocl-ops.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/ocl-ops.mlir
rename to mlir/test/Dialect/SPIRV/IR/ocl-ops.mlir

diff  --git a/mlir/test/Dialect/SPIRV/ops.mlir b/mlir/test/Dialect/SPIRV/IR/ops.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/ops.mlir
rename to mlir/test/Dialect/SPIRV/IR/ops.mlir

diff  --git a/mlir/test/Dialect/SPIRV/structure-ops.mlir b/mlir/test/Dialect/SPIRV/IR/structure-ops.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/structure-ops.mlir
rename to mlir/test/Dialect/SPIRV/IR/structure-ops.mlir

diff  --git a/mlir/test/Dialect/SPIRV/target-and-abi.mlir b/mlir/test/Dialect/SPIRV/IR/target-and-abi.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/target-and-abi.mlir
rename to mlir/test/Dialect/SPIRV/IR/target-and-abi.mlir

diff  --git a/mlir/test/Dialect/SPIRV/target-env.mlir b/mlir/test/Dialect/SPIRV/IR/target-env.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/target-env.mlir
rename to mlir/test/Dialect/SPIRV/IR/target-env.mlir

diff  --git a/mlir/test/Dialect/SPIRV/types.mlir b/mlir/test/Dialect/SPIRV/IR/types.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/types.mlir
rename to mlir/test/Dialect/SPIRV/IR/types.mlir

diff  --git a/mlir/test/Dialect/SPIRV/Linking/ModuleCombiner/conflict_resolution.mlir b/mlir/test/Dialect/SPIRV/Linking/ModuleCombiner/conflict-resolution.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/Linking/ModuleCombiner/conflict_resolution.mlir
rename to mlir/test/Dialect/SPIRV/Linking/ModuleCombiner/conflict-resolution.mlir

diff  --git a/mlir/test/Dialect/SPIRV/Linking/ModuleCombiner/deduplication_basic.mlir b/mlir/test/Dialect/SPIRV/Linking/ModuleCombiner/deduplication.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/Linking/ModuleCombiner/deduplication_basic.mlir
rename to mlir/test/Dialect/SPIRV/Linking/ModuleCombiner/deduplication.mlir

diff  --git a/mlir/test/Dialect/SPIRV/canonicalize.mlir b/mlir/test/Dialect/SPIRV/Transforms/canonicalize.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/canonicalize.mlir
rename to mlir/test/Dialect/SPIRV/Transforms/canonicalize.mlir

diff  --git a/mlir/test/Dialect/SPIRV/Serialization/arithmetic-ops.mlir b/mlir/test/Target/SPIRV/arithmetic-ops.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/Serialization/arithmetic-ops.mlir
rename to mlir/test/Target/SPIRV/arithmetic-ops.mlir

diff  --git a/mlir/test/Dialect/SPIRV/Serialization/array.mlir b/mlir/test/Target/SPIRV/array.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/Serialization/array.mlir
rename to mlir/test/Target/SPIRV/array.mlir

diff  --git a/mlir/test/Dialect/SPIRV/Serialization/atomic-ops.mlir b/mlir/test/Target/SPIRV/atomic-ops.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/Serialization/atomic-ops.mlir
rename to mlir/test/Target/SPIRV/atomic-ops.mlir

diff  --git a/mlir/test/Dialect/SPIRV/Serialization/barrier.mlir b/mlir/test/Target/SPIRV/barrier.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/Serialization/barrier.mlir
rename to mlir/test/Target/SPIRV/barrier.mlir

diff  --git a/mlir/test/Dialect/SPIRV/Serialization/bit-ops.mlir b/mlir/test/Target/SPIRV/bit-ops.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/Serialization/bit-ops.mlir
rename to mlir/test/Target/SPIRV/bit-ops.mlir

diff  --git a/mlir/test/Dialect/SPIRV/Serialization/cast-ops.mlir b/mlir/test/Target/SPIRV/cast-ops.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/Serialization/cast-ops.mlir
rename to mlir/test/Target/SPIRV/cast-ops.mlir

diff  --git a/mlir/test/Dialect/SPIRV/Serialization/composite-op.mlir b/mlir/test/Target/SPIRV/composite-op.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/Serialization/composite-op.mlir
rename to mlir/test/Target/SPIRV/composite-op.mlir

diff  --git a/mlir/test/Dialect/SPIRV/Serialization/constant.mlir b/mlir/test/Target/SPIRV/constant.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/Serialization/constant.mlir
rename to mlir/test/Target/SPIRV/constant.mlir

diff  --git a/mlir/test/Dialect/SPIRV/Serialization/cooperative-matrix.mlir b/mlir/test/Target/SPIRV/cooperative-matrix-ops.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/Serialization/cooperative-matrix.mlir
rename to mlir/test/Target/SPIRV/cooperative-matrix-ops.mlir

diff  --git a/mlir/test/Dialect/SPIRV/Serialization/debug.mlir b/mlir/test/Target/SPIRV/debug.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/Serialization/debug.mlir
rename to mlir/test/Target/SPIRV/debug.mlir

diff  --git a/mlir/test/Dialect/SPIRV/Serialization/decorations.mlir b/mlir/test/Target/SPIRV/decorations.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/Serialization/decorations.mlir
rename to mlir/test/Target/SPIRV/decorations.mlir

diff  --git a/mlir/test/Dialect/SPIRV/Serialization/entry-point.mlir b/mlir/test/Target/SPIRV/entry-point.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/Serialization/entry-point.mlir
rename to mlir/test/Target/SPIRV/entry-point.mlir

diff  --git a/mlir/test/Dialect/SPIRV/Serialization/execution-mode.mlir b/mlir/test/Target/SPIRV/execution-mode.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/Serialization/execution-mode.mlir
rename to mlir/test/Target/SPIRV/execution-mode.mlir

diff  --git a/mlir/test/Dialect/SPIRV/Serialization/function-call.mlir b/mlir/test/Target/SPIRV/function-call.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/Serialization/function-call.mlir
rename to mlir/test/Target/SPIRV/function-call.mlir

diff  --git a/mlir/test/Dialect/SPIRV/Serialization/global-variable.mlir b/mlir/test/Target/SPIRV/global-variable.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/Serialization/global-variable.mlir
rename to mlir/test/Target/SPIRV/global-variable.mlir

diff  --git a/mlir/test/Dialect/SPIRV/Serialization/glsl-ops.mlir b/mlir/test/Target/SPIRV/glsl-ops.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/Serialization/glsl-ops.mlir
rename to mlir/test/Target/SPIRV/glsl-ops.mlir

diff  --git a/mlir/test/Dialect/SPIRV/Serialization/group-ops.mlir b/mlir/test/Target/SPIRV/group-ops.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/Serialization/group-ops.mlir
rename to mlir/test/Target/SPIRV/group-ops.mlir

diff  --git a/mlir/test/Dialect/SPIRV/Serialization/logical-ops.mlir b/mlir/test/Target/SPIRV/logical-ops.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/Serialization/logical-ops.mlir
rename to mlir/test/Target/SPIRV/logical-ops.mlir

diff  --git a/mlir/test/Dialect/SPIRV/Serialization/loop.mlir b/mlir/test/Target/SPIRV/loop.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/Serialization/loop.mlir
rename to mlir/test/Target/SPIRV/loop.mlir

diff  --git a/mlir/test/Dialect/SPIRV/Serialization/matrix.mlir b/mlir/test/Target/SPIRV/matrix.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/Serialization/matrix.mlir
rename to mlir/test/Target/SPIRV/matrix.mlir

diff  --git a/mlir/test/Dialect/SPIRV/Serialization/memory-ops.mlir b/mlir/test/Target/SPIRV/memory-ops.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/Serialization/memory-ops.mlir
rename to mlir/test/Target/SPIRV/memory-ops.mlir

diff  --git a/mlir/test/Dialect/SPIRV/Serialization/module.mlir b/mlir/test/Target/SPIRV/module.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/Serialization/module.mlir
rename to mlir/test/Target/SPIRV/module.mlir

diff  --git a/mlir/test/Dialect/SPIRV/Serialization/non-uniform-ops.mlir b/mlir/test/Target/SPIRV/non-uniform-ops.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/Serialization/non-uniform-ops.mlir
rename to mlir/test/Target/SPIRV/non-uniform-ops.mlir

diff  --git a/mlir/test/Dialect/SPIRV/Serialization/ocl-ops.mlir b/mlir/test/Target/SPIRV/ocl-ops.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/Serialization/ocl-ops.mlir
rename to mlir/test/Target/SPIRV/ocl-ops.mlir

diff  --git a/mlir/test/Dialect/SPIRV/Serialization/phi.mlir b/mlir/test/Target/SPIRV/phi.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/Serialization/phi.mlir
rename to mlir/test/Target/SPIRV/phi.mlir

diff  --git a/mlir/test/Dialect/SPIRV/Serialization/selection.mlir b/mlir/test/Target/SPIRV/selection.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/Serialization/selection.mlir
rename to mlir/test/Target/SPIRV/selection.mlir

diff  --git a/mlir/test/Dialect/SPIRV/Serialization/spec-constant.mlir b/mlir/test/Target/SPIRV/spec-constant.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/Serialization/spec-constant.mlir
rename to mlir/test/Target/SPIRV/spec-constant.mlir

diff  --git a/mlir/test/Dialect/SPIRV/Serialization/struct.mlir b/mlir/test/Target/SPIRV/struct.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/Serialization/struct.mlir
rename to mlir/test/Target/SPIRV/struct.mlir

diff  --git a/mlir/test/Dialect/SPIRV/Serialization/terminator.mlir b/mlir/test/Target/SPIRV/terminator.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/Serialization/terminator.mlir
rename to mlir/test/Target/SPIRV/terminator.mlir

diff  --git a/mlir/test/Dialect/SPIRV/Serialization/undef.mlir b/mlir/test/Target/SPIRV/undef.mlir
similarity index 100%
rename from mlir/test/Dialect/SPIRV/Serialization/undef.mlir
rename to mlir/test/Target/SPIRV/undef.mlir

diff  --git a/mlir/test/lib/Dialect/SPIRV/CMakeLists.txt b/mlir/test/lib/Dialect/SPIRV/CMakeLists.txt
index 6c74d2f26357..edcbf4ebf1de 100644
--- a/mlir/test/lib/Dialect/SPIRV/CMakeLists.txt
+++ b/mlir/test/lib/Dialect/SPIRV/CMakeLists.txt
@@ -15,6 +15,7 @@ add_mlir_library(MLIRSPIRVTestPasses
   MLIRIR
   MLIRPass
   MLIRSPIRV
+  MLIRSPIRVConversion
   MLIRSPIRVModuleCombiner
   MLIRSupport
   )

diff  --git a/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp b/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp
index 791b354d3711..99a6022a3f45 100644
--- a/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp
+++ b/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp
@@ -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"
 

diff  --git a/mlir/test/lib/Dialect/SPIRV/TestEntryPointAbi.cpp b/mlir/test/lib/Dialect/SPIRV/TestEntryPointAbi.cpp
index b8b544a8f228..ed1b9236efca 100644
--- a/mlir/test/lib/Dialect/SPIRV/TestEntryPointAbi.cpp
+++ b/mlir/test/lib/Dialect/SPIRV/TestEntryPointAbi.cpp
@@ -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;

diff  --git a/mlir/test/lib/Dialect/SPIRV/TestModuleCombiner.cpp b/mlir/test/lib/Dialect/SPIRV/TestModuleCombiner.cpp
index 0c3970245bfc..29a057041b55 100644
--- a/mlir/test/lib/Dialect/SPIRV/TestModuleCombiner.cpp
+++ b/mlir/test/lib/Dialect/SPIRV/TestModuleCombiner.cpp
@@ -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"

diff  --git a/mlir/test/lib/Transforms/TestGpuMemoryPromotion.cpp b/mlir/test/lib/Transforms/TestGpuMemoryPromotion.cpp
index 3c2b933e99f6..c8c959047250 100644
--- a/mlir/test/lib/Transforms/TestGpuMemoryPromotion.cpp
+++ b/mlir/test/lib/Transforms/TestGpuMemoryPromotion.cpp
@@ -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"

diff  --git a/mlir/tools/mlir-spirv-cpu-runner/CMakeLists.txt b/mlir/tools/mlir-spirv-cpu-runner/CMakeLists.txt
index 69080ae66dce..5860b07cbf5c 100644
--- a/mlir/tools/mlir-spirv-cpu-runner/CMakeLists.txt
+++ b/mlir/tools/mlir-spirv-cpu-runner/CMakeLists.txt
@@ -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

diff  --git a/mlir/tools/mlir-spirv-cpu-runner/mlir-spirv-cpu-runner.cpp b/mlir/tools/mlir-spirv-cpu-runner/mlir-spirv-cpu-runner.cpp
index 5deb52c763a6..31dbae336218 100644
--- a/mlir/tools/mlir-spirv-cpu-runner/mlir-spirv-cpu-runner.cpp
+++ b/mlir/tools/mlir-spirv-cpu-runner/mlir-spirv-cpu-runner.cpp
@@ -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"

diff  --git a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
index f5a40e290889..cd8be8a984f5 100644
--- a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
+++ b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
@@ -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";

diff  --git a/mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp b/mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp
index 8b00bae2c8a5..98d3bcff02cf 100644
--- a/mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp
+++ b/mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp
@@ -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"

diff  --git a/mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp b/mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp
index 3823c7b8b544..76fa66145e7e 100644
--- a/mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp
+++ b/mlir/unittests/Dialect/SPIRV/DeserializationTest.cpp
@@ -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"

diff  --git a/mlir/unittests/Dialect/SPIRV/SerializationTest.cpp b/mlir/unittests/Dialect/SPIRV/SerializationTest.cpp
index bfeffa3fb055..2a05edb8d42a 100644
--- a/mlir/unittests/Dialect/SPIRV/SerializationTest.cpp
+++ b/mlir/unittests/Dialect/SPIRV/SerializationTest.cpp
@@ -12,11 +12,11 @@
 //===----------------------------------------------------------------------===//
 
 #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"


        


More information about the llvm-branch-commits mailing list