diff --git a/mlir/docs/Dialects/SPIR-V.md b/mlir/docs/Dialects/SPIR-V.md --- a/mlir/docs/Dialects/SPIR-V.md +++ b/mlir/docs/Dialects/SPIR-V.md @@ -1149,12 +1149,13 @@ 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 @@ [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 --- 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/CMakeLists.txt b/mlir/include/mlir/Dialect/SPIRV/IR/CMakeLists.txt copy from mlir/include/mlir/Dialect/SPIRV/CMakeLists.txt copy to mlir/include/mlir/Dialect/SPIRV/IR/CMakeLists.txt --- a/mlir/include/mlir/Dialect/SPIRV/CMakeLists.txt +++ b/mlir/include/mlir/Dialect/SPIRV/IR/CMakeLists.txt @@ -27,19 +27,12 @@ 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) +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) - -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/ParserUtils.h b/mlir/include/mlir/Dialect/SPIRV/IR/ParserUtils.h rename from mlir/include/mlir/Dialect/SPIRV/ParserUtils.h rename to mlir/include/mlir/Dialect/SPIRV/IR/ParserUtils.h --- 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 @@ -36,6 +38,7 @@ 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 rename from mlir/include/mlir/Dialect/SPIRV/SPIRVArithmeticOps.td rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVArithmeticOps.td --- 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 traits = []> : SPV_Op { @@ -564,4 +564,4 @@ // ----- -#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 rename from mlir/include/mlir/Dialect/SPIRV/SPIRVAttributes.h rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAttributes.h --- 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 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 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 @@ } // 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 rename from mlir/include/mlir/Dialect/SPIRV/SPIRVAvailability.td rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAvailability.td --- 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 @@ 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 rename from mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td --- 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 @@ 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 rename from mlir/include/mlir/Dialect/SPIRV/SPIRVBitOps.td rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBitOps.td --- 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 traits = []> : @@ -608,4 +608,4 @@ }]; } -#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 rename from mlir/include/mlir/Dialect/SPIRV/SPIRVCastOps.td rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCastOps.td --- 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_CastOpgetOperation(), 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 rename from mlir/include/mlir/Dialect/SPIRV/SPIRVCompositeOps.td rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCompositeOps.td --- 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 @@ // ----- -#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 rename from mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVControlFlowOps.td --- 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 @@ 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 rename from mlir/include/mlir/Dialect/SPIRV/SPIRVCooperativeMatrixOps.td rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCooperativeMatrixOps.td --- 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 @@ // ----- -#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 rename from mlir/include/mlir/Dialect/SPIRV/SPIRVDialect.h rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVDialect.h --- 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 @@ } // 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 --- /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 getImpliedExtensions(Version version); + +/// Returns the directly implied capabilities for the given capability. These +/// capabilities are implicitly declared by the given capability. +ArrayRef 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 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 rename from mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVGLSLOps.td --- 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 @@ }]; } -#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 rename from mlir/include/mlir/Dialect/SPIRV/SPIRVGroupOps.td rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVGroupOps.td --- 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 @@ // ----- -#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 rename from mlir/include/mlir/Dialect/SPIRV/SPIRVLogicalOps.td rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVLogicalOps.td --- 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 traits = []> : SPV_Op { @@ -730,4 +730,4 @@ // ----- -#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 rename from mlir/include/mlir/Dialect/SPIRV/SPIRVOCLOps.td rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVOCLOps.td --- 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 @@ }]; } -#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 rename from mlir/include/mlir/Dialect/SPIRV/SPIRVOps.h rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVOps.h --- 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 @@ // 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 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 @@ } // 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 rename from mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVOps.td --- 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 @@ // ----- -#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 rename from mlir/include/mlir/Dialect/SPIRV/SPIRVStructureOps.td rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td --- 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 @@ // ----- -#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 rename from mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h rename to mlir/include/mlir/Dialect/SPIRV/IR/SPIRVTypes.h --- 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 -// 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 getImpliedExtensions(Version version); - -/// Returns the directly implied capabilities for the given capability. These -/// capabilities are implicitly declared by the given capability. -ArrayRef 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 getRecursiveImpliedCapabilities(Capability cap); namespace detail { struct ArrayTypeStorage; @@ -380,9 +351,9 @@ // Returns in `decorationsInfo` all the Decorations (apart from Offset) // associated with the `i`-th member of the StructType. - void getMemberDecorations(unsigned i, - SmallVectorImpl - &decorationsInfo) const; + void getMemberDecorations( + unsigned i, + SmallVectorImpl &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 @@ } // 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 rename from mlir/include/mlir/Dialect/SPIRV/TargetAndABI.h rename to mlir/include/mlir/Dialect/SPIRV/IR/TargetAndABI.h --- 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 @@ } // 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 rename from mlir/include/mlir/Dialect/SPIRV/TargetAndABI.td rename to mlir/include/mlir/Dialect/SPIRV/IR/TargetAndABI.td --- 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 @@ DefaultValuedAttr> ]>; -#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 rename from mlir/include/mlir/Dialect/SPIRV/ModuleCombiner.h rename to mlir/include/mlir/Dialect/SPIRV/Linking/ModuleCombiner.h --- 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 @@ } // 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 --- /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 rename from mlir/include/mlir/Dialect/SPIRV/Passes.h rename to mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.h --- 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 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 @@ /// 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 rename from mlir/include/mlir/Dialect/SPIRV/Passes.td rename to mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.td --- 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 @@ 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 rename from mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h rename to mlir/include/mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h --- 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 @@ } // 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 rename from mlir/include/mlir/Dialect/SPIRV/LayoutUtils.h rename to mlir/include/mlir/Dialect/SPIRV/Utils/LayoutUtils.h --- 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 @@ -76,4 +77,4 @@ } // 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 --- 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 --- 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 --- 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 diff --git a/mlir/lib/Conversion/GPUToSPIRV/CMakeLists.txt b/mlir/lib/Conversion/GPUToSPIRV/CMakeLists.txt --- a/mlir/lib/Conversion/GPUToSPIRV/CMakeLists.txt +++ b/mlir/lib/Conversion/GPUToSPIRV/CMakeLists.txt @@ -16,6 +16,7 @@ MLIRPass MLIRSCFToSPIRV MLIRSPIRV + MLIRSPIRVConversion MLIRStandard MLIRStandardToSPIRVTransforms MLIRSupport diff --git a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp --- 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 --- 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 --- 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 --- 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 --- a/mlir/lib/Conversion/LinalgToSPIRV/CMakeLists.txt +++ b/mlir/lib/Conversion/LinalgToSPIRV/CMakeLists.txt @@ -15,5 +15,6 @@ MLIRLinalgUtils MLIRPass MLIRSPIRV + MLIRSPIRVConversion MLIRSupport ) diff --git a/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp b/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp --- 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 --- 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 --- a/mlir/lib/Conversion/SCFToSPIRV/CMakeLists.txt +++ b/mlir/lib/Conversion/SCFToSPIRV/CMakeLists.txt @@ -11,6 +11,7 @@ MLIRAffine MLIRAffineToStandard MLIRSPIRV + MLIRSPIRVConversion MLIRIR MLIRLinalg MLIRPass diff --git a/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp b/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp --- 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 --- a/mlir/lib/Conversion/SPIRVToLLVM/CMakeLists.txt +++ b/mlir/lib/Conversion/SPIRVToLLVM/CMakeLists.txt @@ -13,6 +13,7 @@ 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 --- 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 --- 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 --- 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 --- a/mlir/lib/Conversion/StandardToSPIRV/CMakeLists.txt +++ b/mlir/lib/Conversion/StandardToSPIRV/CMakeLists.txt @@ -14,8 +14,8 @@ MLIRIR MLIRPass MLIRSPIRV + MLIRSPIRVConversion MLIRSupport MLIRTransformUtils - MLIRSPIRV MLIRStandard ) diff --git a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp --- 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 --- 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 --- 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 --- a/mlir/lib/Conversion/VectorToSPIRV/CMakeLists.txt +++ b/mlir/lib/Conversion/VectorToSPIRV/CMakeLists.txt @@ -10,6 +10,7 @@ LINK_LIBS PUBLIC MLIRSPIRV + MLIRSPIRVConversion MLIRVector MLIRTransforms ) diff --git a/mlir/lib/Conversion/VectorToSPIRV/VectorToSPIRV.cpp b/mlir/lib/Conversion/VectorToSPIRV/VectorToSPIRV.cpp --- 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 --- 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/CMakeLists.txt b/mlir/lib/Dialect/SPIRV/IR/CMakeLists.txt copy from mlir/lib/Dialect/SPIRV/CMakeLists.txt copy to mlir/lib/Dialect/SPIRV/IR/CMakeLists.txt --- a/mlir/lib/Dialect/SPIRV/CMakeLists.txt +++ b/mlir/lib/Dialect/SPIRV/IR/CMakeLists.txt @@ -1,15 +1,13 @@ - 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 + SPIRVEnums.cpp SPIRVOps.cpp - SPIRVLowering.cpp SPIRVTypes.cpp TargetAndABI.cpp @@ -17,12 +15,12 @@ ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/SPIRV DEPENDS + MLIRSPIRVAttrUtilsGen MLIRSPIRVAvailabilityIncGen MLIRSPIRVCanonicalizationIncGen MLIRSPIRVEnumAvailabilityIncGen MLIRSPIRVEnumsIncGen MLIRSPIRVOpsIncGen - MLIRSPIRVOpUtilsGen MLIRSPIRVTargetAndABIIncGen LINK_LIBS PUBLIC @@ -32,7 +30,4 @@ MLIRSideEffectInterfaces MLIRSupport MLIRTransforms - ) - -add_subdirectory(Linking) -add_subdirectory(Transforms) +) diff --git a/mlir/lib/Dialect/SPIRV/SPIRVAttributes.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVAttributes.cpp rename from mlir/lib/Dialect/SPIRV/SPIRVAttributes.cpp rename to mlir/lib/Dialect/SPIRV/IR/SPIRVAttributes.cpp --- 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 rename from mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.cpp rename to mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.cpp --- 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 @@ return lhs->getAttrDictionary() == rhs->getAttrDictionary(); } - // Returns a source value for the given block. Value getSrcValue(Block *block) const { auto storeOp = cast(block->front()); diff --git a/mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.td b/mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.td rename from mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.td rename to mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.td --- 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 rename from mlir/lib/Dialect/SPIRV/SPIRVDialect.cpp rename to mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp --- 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 @@ // 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(); diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVEnums.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVEnums.cpp new file mode 100644 --- /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::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(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(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(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::getRecursiveImpliedCapabilities(spirv::Capability cap) { + ArrayRef directCaps = getDirectImpliedCapabilities(cap); + llvm::SetVector> 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 rename from mlir/lib/Dialect/SPIRV/SPIRVOps.cpp rename to mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp --- 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 @@ // 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 rename from mlir/lib/Dialect/SPIRV/SPIRVTypes.cpp rename to mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp --- 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 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(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(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(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 -spirv::getRecursiveImpliedCapabilities(Capability cap) { - ArrayRef directCaps = getDirectImpliedCapabilities(cap); - llvm::SetVector> 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 @@ // ImageType //===----------------------------------------------------------------------===// -template static constexpr unsigned getNumBits() { return 0; } -template <> constexpr unsigned getNumBits() { +template +static constexpr unsigned getNumBits() { + return 0; +} +template <> +constexpr unsigned getNumBits() { static_assert((1 << 3) > getMaxEnumValForDim(), "Not enough bits to encode Dim value"); return 3; } -template <> constexpr unsigned getNumBits() { +template <> +constexpr unsigned getNumBits() { static_assert((1 << 2) > getMaxEnumValForImageDepthInfo(), "Not enough bits to encode ImageDepthInfo value"); return 2; } -template <> constexpr unsigned getNumBits() { +template <> +constexpr unsigned getNumBits() { static_assert((1 << 1) > getMaxEnumValForImageArrayedInfo(), "Not enough bits to encode ImageArrayedInfo value"); return 1; } -template <> constexpr unsigned getNumBits() { +template <> +constexpr unsigned getNumBits() { static_assert((1 << 1) > getMaxEnumValForImageSamplingInfo(), "Not enough bits to encode ImageSamplingInfo value"); return 1; } -template <> constexpr unsigned getNumBits() { +template <> +constexpr unsigned getNumBits() { static_assert((1 << 2) > getMaxEnumValForImageSamplerUseInfo(), "Not enough bits to encode ImageSamplerUseInfo value"); return 2; } -template <> constexpr unsigned getNumBits() { +template <> +constexpr unsigned getNumBits() { 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 rename from mlir/lib/Dialect/SPIRV/TargetAndABI.cpp rename to mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp --- 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 --- 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 --- 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 @@ 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 rename from mlir/lib/Dialect/SPIRV/Transforms/DecorateSPIRVCompositeTypeLayoutPass.cpp rename to mlir/lib/Dialect/SPIRV/Transforms/DecorateCompositeTypeLayoutPass.cpp --- 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 --- 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 --- a/mlir/lib/Dialect/SPIRV/Transforms/PassDetail.h +++ b/mlir/lib/Dialect/SPIRV/Transforms/PassDetail.h @@ -18,7 +18,7 @@ } // 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 --- 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 rename from mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp rename to mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp --- 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 -#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 --- 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 --- /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 rename from mlir/lib/Dialect/SPIRV/LayoutUtils.cpp rename to mlir/lib/Dialect/SPIRV/Utils/LayoutUtils.cpp --- 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 --- 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 @@ // 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 --- 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 --- 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 @@ // 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 --- 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 --- a/mlir/test/lib/Dialect/SPIRV/CMakeLists.txt +++ b/mlir/test/lib/Dialect/SPIRV/CMakeLists.txt @@ -15,6 +15,7 @@ MLIRIR MLIRPass MLIRSPIRV + MLIRSPIRVConversion MLIRSPIRVModuleCombiner MLIRSupport ) diff --git a/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp b/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp --- 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 --- 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 --- 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 --- 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 --- 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 --- 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 --- a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp +++ b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp @@ -1155,18 +1155,18 @@ 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 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 @@ EnumAttr enumAttr(recordKeeper.getDef("SPV_CapabilityAttr")); - os << "ArrayRef " - "spirv::getDirectImpliedCapabilities(Capability cap) {\n" + os << "ArrayRef " + "spirv::getDirectImpliedCapabilities(spirv::Capability cap) {\n" << " switch (cap) {\n" << " default: return {};\n"; for (const EnumAttrCase &enumerant : enumAttr.getAllCases()) { @@ -1340,14 +1340,14 @@ continue; std::vector 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(implies, " << impliedCapsDefs.size() - << "); }\n"; + os << "}; return ArrayRef(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 --- 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 --- 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 --- 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"