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
[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
-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)
--- /dev/null
+add_mlir_dialect(SPIRVOps spv)
+add_mlir_doc(SPIRVOps -gen-op-doc SPIRVOps Dialects/)
+
+set(LLVM_TARGET_DEFINITIONS SPIRVBase.td)
+mlir_tablegen(SPIRVEnums.h.inc -gen-enum-decls)
+mlir_tablegen(SPIRVEnums.cpp.inc -gen-enum-defs)
+add_public_tablegen_target(MLIRSPIRVEnumsIncGen)
+add_dependencies(mlir-headers MLIRSPIRVEnumsIncGen)
+
+set(LLVM_TARGET_DEFINITIONS SPIRVBase.td)
+mlir_tablegen(SPIRVEnumAvailability.h.inc -gen-spirv-enum-avail-decls)
+mlir_tablegen(SPIRVEnumAvailability.cpp.inc -gen-spirv-enum-avail-defs)
+mlir_tablegen(SPIRVCapabilityImplication.inc -gen-spirv-capability-implication)
+add_public_tablegen_target(MLIRSPIRVEnumAvailabilityIncGen)
+add_dependencies(mlir-headers MLIRSPIRVEnumAvailabilityIncGen)
+
+set(LLVM_TARGET_DEFINITIONS SPIRVOps.td)
+mlir_tablegen(SPIRVAvailability.h.inc -gen-avail-interface-decls)
+mlir_tablegen(SPIRVAvailability.cpp.inc -gen-avail-interface-defs)
+mlir_tablegen(SPIRVOpAvailabilityImpl.inc -gen-spirv-avail-impls)
+add_public_tablegen_target(MLIRSPIRVAvailabilityIncGen)
+add_dependencies(mlir-headers MLIRSPIRVAvailabilityIncGen)
+
+set(LLVM_TARGET_DEFINITIONS SPIRVOps.td)
+mlir_tablegen(SPIRVSerialization.inc -gen-spirv-serialization)
+add_public_tablegen_target(MLIRSPIRVSerializationGen)
+add_dependencies(mlir-headers MLIRSPIRVSerializationGen)
+
+set(LLVM_TARGET_DEFINITIONS SPIRVBase.td)
+mlir_tablegen(SPIRVAttrUtils.inc -gen-spirv-attr-utils)
+add_public_tablegen_target(MLIRSPIRVAttrUtilsGen)
+add_dependencies(mlir-headers MLIRSPIRVAttrUtilsGen)
+
+set(LLVM_TARGET_DEFINITIONS TargetAndABI.td)
+mlir_tablegen(TargetAndABI.h.inc -gen-struct-attr-decls)
+mlir_tablegen(TargetAndABI.cpp.inc -gen-struct-attr-defs)
+add_public_tablegen_target(MLIRSPIRVTargetAndABIIncGen)
+add_dependencies(mlir-headers MLIRSPIRVTargetAndABIIncGen)
// dialect.
//
//===----------------------------------------------------------------------===//
-#ifndef MLIR_DIALECT_SPIRV_PARSERUTILS_H_
-#define MLIR_DIALECT_SPIRV_PARSERUTILS_H_
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
+#ifndef MLIR_DIALECT_SPIRV_IR_PARSERUTILS_H_
+#define MLIR_DIALECT_SPIRV_IR_PARSERUTILS_H_
+
+#include "mlir/Dialect/SPIRV/IR/SPIRVAttributes.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/IR/OpImplementation.h"
namespace mlir {
+
/// Parses the next keyword in `parser` as an enumerant of the given
/// `EnumClass`.
template <typename EnumClass, typename ParserType>
return parser.emitError(loc, "invalid ")
<< attrName << " attribute specification: " << keyword;
}
+
} // namespace mlir
-#endif // MLIR_DIALECT_SPIRV_PARSERUTILS_H_
+#endif // MLIR_DIALECT_SPIRV_IR_PARSERUTILS_H_
//
//===----------------------------------------------------------------------===//
-#ifndef SPIRV_ARITHMETIC_OPS
-#define SPIRV_ARITHMETIC_OPS
+#ifndef MLIR_DIALECT_SPIRV_IR_ARITHMETIC_OPS
+#define MLIR_DIALECT_SPIRV_IR_ARITHMETIC_OPS
-include "mlir/Dialect/SPIRV/SPIRVBase.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
class SPV_ArithmeticBinaryOp<string mnemonic, Type type,
}];
}
-#endif // SPIRV_ARITHMETIC_OPS
+#endif // MLIR_DIALECT_SPIRV_IR_ARITHMETIC_OPS
//
//===----------------------------------------------------------------------===//
-#ifndef SPIRV_ATOMIC_OPS
-#define SPIRV_ATOMIC_OPS
+#ifndef MLIR_DIALECT_SPIRV_IR_ATOMIC_OPS
+#define MLIR_DIALECT_SPIRV_IR_ATOMIC_OPS
class SPV_AtomicUpdateOp<string mnemonic, list<OpTrait> traits = []> :
SPV_Op<mnemonic, traits> {
// -----
-#endif // SPIRV_ATOMIC_OPS
+#endif // MLIR_DIALECT_SPIRV_IR_ATOMIC_OPS
//
//===----------------------------------------------------------------------===//
-#ifndef MLIR_DIALECT_SPIRV_SPIRVATTRIBUTES_H
-#define MLIR_DIALECT_SPIRV_SPIRVATTRIBUTES_H
+#ifndef MLIR_DIALECT_SPIRV_IR_SPIRVATTRIBUTES_H
+#define MLIR_DIALECT_SPIRV_IR_SPIRVATTRIBUTES_H
-#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
#include "mlir/IR/BuiltinAttributes.h"
#include "mlir/Support/LLVM.h"
-// Pull in SPIR-V attribute definitions for target and ABI.
-#include "mlir/Dialect/SPIRV/TargetAndABI.h.inc"
+// Pull in TableGen'erated SPIR-V attribute definitions for target and ABI.
+#include "mlir/Dialect/SPIRV/IR/TargetAndABI.h.inc"
namespace mlir {
namespace spirv {
struct VerCapExtAttributeStorage;
} // namespace detail
+// TableGen'erated helper functions.
+//
+// Get the name used in the Op to refer to an enum value of the given
+// `EnumClass`.
+// template <typename EnumClass> StringRef attributeName();
+//
+#include "mlir/Dialect/SPIRV/IR/SPIRVAttrUtils.inc"
+
/// An attribute that specifies the information regarding the interface
/// variable: descriptor set, binding, storage class.
class InterfaceVarABIAttr
} // namespace spirv
} // namespace mlir
-#endif // MLIR_DIALECT_SPIRV_SPIRVATTRIBUTES_H
+#endif // MLIR_DIALECT_SPIRV_IR_SPIRVATTRIBUTES_H
//
//===----------------------------------------------------------------------===//
-#ifndef SPIRV_AVAILABILITY
-#define SPIRV_AVAILABILITY
+#ifndef MLIR_DIALECT_SPIRV_IR_AVAILABILITY
+#define MLIR_DIALECT_SPIRV_IR_AVAILABILITY
include "mlir/IR/OpBase.td"
max.symbol;
}
-#endif // SPIRV_AVAILABILITY
+#endif // MLIR_DIALECT_SPIRV_IR_AVAILABILITY
//
//===----------------------------------------------------------------------===//
-#ifndef SPIRV_BASE
-#define SPIRV_BASE
+#ifndef MLIR_DIALECT_SPIRV_IR_BASE
+#define MLIR_DIALECT_SPIRV_IR_BASE
include "mlir/IR/OpBase.td"
-include "mlir/Dialect/SPIRV/SPIRVAvailability.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVAvailability.td"
//===----------------------------------------------------------------------===//
// SPIR-V dialect definitions
string extendedInstSetName = setName;
}
-#endif // SPIRV_BASE
+#endif // MLIR_DIALECT_SPIRV_IR_BASE
//
//===----------------------------------------------------------------------===//
-#ifndef SPIRV_BIT_OPS
-#define SPIRV_BIT_OPS
+#ifndef MLIR_DIALECT_SPIRV_IR_BIT_OPS
+#define MLIR_DIALECT_SPIRV_IR_BIT_OPS
-include "mlir/Dialect/SPIRV/SPIRVBase.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
class SPV_BitBinaryOp<string mnemonic, list<OpTrait> traits = []> :
}];
}
-#endif // SPIRV_BIT_OPS
+#endif // MLIR_DIALECT_SPIRV_IR_BIT_OPS
//
//===----------------------------------------------------------------------===//
-#ifndef SPIRV_CAST_OPS
-#define SPIRV_CAST_OPS
+#ifndef MLIR_DIALECT_SPIRV_IR_CAST_OPS
+#define MLIR_DIALECT_SPIRV_IR_CAST_OPS
-include "mlir/Dialect/SPIRV/SPIRVBase.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
class SPV_CastOp<string mnemonic, Type resultType, Type operandType,
let verifier = [{ return verifyCastOp(this->getOperation(), false); }];
}
-#endif // SPIRV_CAST_OPS
+#endif // MLIR_DIALECT_SPIRV_IR_CAST_OPS
//
//===----------------------------------------------------------------------===//
-#ifndef SPIRV_COMPOSITE_OPS
-#define SPIRV_COMPOSITE_OPS
+#ifndef MLIR_DIALECT_SPIRV_IR_COMPOSITE_OPS
+#define MLIR_DIALECT_SPIRV_IR_COMPOSITE_OPS
-include "mlir/Dialect/SPIRV/SPIRVBase.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
// -----
// -----
-#endif // SPIRV_COMPOSITE_OPS
+#endif // MLIR_DIALECT_SPIRV_IR_COMPOSITE_OPS
//
//===----------------------------------------------------------------------===//
-#ifndef SPIRV_CONTROLFLOW_OPS
-#define SPIRV_CONTROLFLOW_OPS
+#ifndef MLIR_DIALECT_SPIRV_IR_CONTROLFLOW_OPS
+#define MLIR_DIALECT_SPIRV_IR_CONTROLFLOW_OPS
-include "mlir/Dialect/SPIRV/SPIRVBase.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
include "mlir/Interfaces/CallInterfaces.td"
include "mlir/Interfaces/ControlFlowInterfaces.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
let hasCanonicalizer = 1;
}
-#endif // SPIRV_CONTROLFLOW_OPS
+#endif // MLIR_DIALECT_SPIRV_IR_CONTROLFLOW_OPS
//
//===----------------------------------------------------------------------===//
-#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
// -----
// -----
-#endif // SPIRV_COOPERATIVE_MATRIX_OPS
+#endif // MLIR_DIALECT_SPIRV_IR_COOPERATIVE_MATRIX_OPS
//
//===----------------------------------------------------------------------===//
-#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"
} // 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_
--- /dev/null
+//===- SPIRVEnums.h - MLIR SPIR-V Enums -------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file declares the C/C++ enums from SPIR-V spec.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef MLIR_DIALECT_SPIRV_IR_SPIRVENUMS_H_
+#define MLIR_DIALECT_SPIRV_IR_SPIRVENUMS_H_
+
+#include "mlir/Support/LLVM.h"
+#include "llvm/ADT/DenseMapInfo.h"
+#include "llvm/ADT/StringRef.h"
+
+// Forward declare enum classes related to op availability. Their definitions
+// are in the TableGen'erated SPIRVEnums.h.inc and can be referenced by other
+// declarations in SPIRVEnums.h.inc.
+namespace mlir {
+namespace spirv {
+enum class Version : uint32_t;
+enum class Extension;
+enum class Capability : uint32_t;
+} // namespace spirv
+} // namespace mlir
+
+// Pull in all enum type definitions and utility function declarations
+#include "mlir/Dialect/SPIRV/IR/SPIRVEnums.h.inc"
+
+// Pull in all enum type availability query function declarations
+#include "mlir/Dialect/SPIRV/IR/SPIRVEnumAvailability.h.inc"
+
+namespace mlir {
+namespace spirv {
+/// Returns the implied extensions for the given version. These extensions are
+/// incorporated into the current version so they are implicitly declared when
+/// targeting the given version.
+ArrayRef<Extension> getImpliedExtensions(Version version);
+
+/// Returns the directly implied capabilities for the given capability. These
+/// capabilities are implicitly declared by the given capability.
+ArrayRef<Capability> getDirectImpliedCapabilities(Capability cap);
+/// Returns the recursively implied capabilities for the given capability. These
+/// capabilities are implicitly declared by the given capability. Compared to
+/// the above function, this function collects implied capabilities recursively:
+/// if an implicitly declared capability implicitly declares a third one, the
+/// third one will also be returned.
+SmallVector<Capability, 0> getRecursiveImpliedCapabilities(Capability cap);
+
+} // end namespace spirv
+} // end namespace mlir
+
+#endif // MLIR_DIALECT_SPIRV_IR_SPIRVENUMS_H_
//
//===----------------------------------------------------------------------===//
-#ifndef SPIRV_GLSL_OPS
-#define SPIRV_GLSL_OPS
+#ifndef MLIR_DIALECT_SPIRV_IR_GLSL_OPS
+#define MLIR_DIALECT_SPIRV_IR_GLSL_OPS
-include "mlir/Dialect/SPIRV/SPIRVBase.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
//===----------------------------------------------------------------------===//
}];
}
-#endif // SPIRV_GLSL_OPS
+#endif // MLIR_DIALECT_SPIRV_IR_GLSL_OPS
//
//===----------------------------------------------------------------------===//
-#ifndef SPIRV_GROUP_OPS
-#define SPIRV_GROUP_OPS
+#ifndef MLIR_DIALECT_SPIRV_IR_GROUP_OPS
+#define MLIR_DIALECT_SPIRV_IR_GROUP_OPS
// -----
// -----
-#endif // SPIRV_GROUP_OPS
+#endif // MLIR_DIALECT_SPIRV_IR_GROUP_OPS
//
//===----------------------------------------------------------------------===//
-#ifndef SPIRV_LOGICAL_OPS
-#define SPIRV_LOGICAL_OPS
+#ifndef MLIR_DIALECT_SPIRV_IR_LOGICAL_OPS
+#define MLIR_DIALECT_SPIRV_IR_LOGICAL_OPS
-include "mlir/Dialect/SPIRV/SPIRVBase.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
class SPV_LogicalBinaryOp<string mnemonic, Type operandsType,
}];
}
-#endif // SPIRV_LOGICAL_OPS
+#endif // MLIR_DIALECT_SPIRV_IR_LOGICAL_OPS
//
//===----------------------------------------------------------------------===//
-#ifndef SPIRV_MATRIX_OPS
-#define SPIRV_MATRIX_OPS
+#ifndef MLIR_DIALECT_SPIRV_IR_MATRIX_OPS
+#define MLIR_DIALECT_SPIRV_IR_MATRIX_OPS
include "mlir/Interfaces/SideEffectInterfaces.td"
// -----
// -----
-#endif // SPIRV_MATRIX_OPS
+#endif // MLIR_DIALECT_SPIRV_IR_MATRIX_OPS
//
//===----------------------------------------------------------------------===//
-#ifndef MLIR_DIALECT_SPIRV_SPIRVMODULE_H
-#define MLIR_DIALECT_SPIRV_SPIRVMODULE_H
+#ifndef MLIR_DIALECT_SPIRV_IR_SPIRVMODULE_H
+#define MLIR_DIALECT_SPIRV_IR_SPIRVMODULE_H
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
#include "mlir/IR/OwningOpRef.h"
namespace mlir {
} // end namespace spirv
} // end namespace mlir
-#endif // MLIR_DIALECT_SPIRV_SPIRVMODULE_H
+#endif // MLIR_DIALECT_SPIRV_IR_SPIRVMODULE_H
//
//===----------------------------------------------------------------------===//
-#ifndef SPIRV_NON_UNIFORM_OPS
-#define SPIRV_NON_UNIFORM_OPS
+#ifndef MLIR_DIALECT_SPIRV_IR_NON_UNIFORM_OPS
+#define MLIR_DIALECT_SPIRV_IR_NON_UNIFORM_OPS
class SPV_GroupNonUniformArithmeticOp<string mnemonic, Type type,
list<OpTrait> traits = []> : SPV_Op<mnemonic, traits> {
// -----
-#endif // SPIRV_NON_UNIFORM_OPS
+#endif // MLIR_DIALECT_SPIRV_IR_NON_UNIFORM_OPS
//
//===----------------------------------------------------------------------===//
-#ifndef SPIRV_OCL_OPS
-#define SPIRV_OCL_OPS
+#ifndef MLIR_DIALECT_SPIRV_IR_OCL_OPS
+#define MLIR_DIALECT_SPIRV_IR_OCL_OPS
-include "mlir/Dialect/SPIRV/SPIRVBase.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
//===----------------------------------------------------------------------===//
// SPIR-V OpenCL opcode specification.
}];
}
-#endif // SPIRV_OCL_OPS
+#endif // MLIR_DIALECT_SPIRV_IR_OCL_OPS
//
//===----------------------------------------------------------------------===//
-#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"
// TableGen'erated operation interfaces for querying versions, extensions, and
// capabilities.
-#include "mlir/Dialect/SPIRV/SPIRVAvailability.h.inc"
+#include "mlir/Dialect/SPIRV/IR/SPIRVAvailability.h.inc"
} // namespace spirv
} // namespace mlir
// TablenGen'erated operation declarations.
#define GET_OP_CLASSES
-#include "mlir/Dialect/SPIRV/SPIRVOps.h.inc"
-
-namespace mlir {
-namespace spirv {
-// TableGen'erated helper functions.
-//
-// Get the name used in the Op to refer to an enum value of the given
-// `EnumClass`.
-// template <typename EnumClass> StringRef attributeName();
-//
-#include "mlir/Dialect/SPIRV/SPIRVOpUtils.inc"
-
-} // end namespace spirv
-} // end namespace mlir
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h.inc"
namespace llvm {
} // namespace llvm
-#endif // MLIR_DIALECT_SPIRV_SPIRVOPS_H_
+#endif // MLIR_DIALECT_SPIRV_IR_SPIRVOPS_H_
// 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"
// -----
// -----
-#endif // SPIRV_OPS
+#endif // MLIR_DIALECT_SPIRV_IR_OPS
//
//===----------------------------------------------------------------------===//
-#ifndef SPIRV_STRUCTURE_OPS
-#define SPIRV_STRUCTURE_OPS
+#ifndef MLIR_DIALECT_SPIRV_IR_STRUCTURE_OPS
+#define MLIR_DIALECT_SPIRV_IR_STRUCTURE_OPS
-include "mlir/Dialect/SPIRV/SPIRVBase.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
include "mlir/IR/SymbolInterfaces.td"
include "mlir/Interfaces/CallInterfaces.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
// -----
-#endif // SPIRV_STRUCTURE_OPS
+#endif // MLIR_DIALECT_SPIRV_IR_STRUCTURE_OPS
//
//===----------------------------------------------------------------------===//
-#ifndef MLIR_DIALECT_SPIRV_SPIRVTYPES_H_
-#define MLIR_DIALECT_SPIRV_SPIRVTYPES_H_
+#ifndef MLIR_DIALECT_SPIRV_IR_SPIRVTYPES_H_
+#define MLIR_DIALECT_SPIRV_IR_SPIRVTYPES_H_
+#include "mlir/Dialect/SPIRV/IR/SPIRVEnums.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Diagnostics.h"
#include "mlir/IR/Location.h"
#include <tuple>
-// Forward declare enum classes related to op availability. Their definitions
-// are in the TableGen'erated SPIRVEnums.h.inc and can be referenced by other
-// declarations in SPIRVEnums.h.inc.
namespace mlir {
namespace spirv {
-enum class Version : uint32_t;
-enum class Extension;
-enum class Capability : uint32_t;
-} // namespace spirv
-} // namespace mlir
-
-// Pull in all enum type definitions and utility function declarations
-#include "mlir/Dialect/SPIRV/SPIRVEnums.h.inc"
-// Pull in all enum type availability query function declarations
-#include "mlir/Dialect/SPIRV/SPIRVEnumAvailability.h.inc"
-
-namespace mlir {
-namespace spirv {
-/// Returns the implied extensions for the given version. These extensions are
-/// incorporated into the current version so they are implicitly declared when
-/// targeting the given version.
-ArrayRef<Extension> getImpliedExtensions(Version version);
-
-/// Returns the directly implied capabilities for the given capability. These
-/// capabilities are implicitly declared by the given capability.
-ArrayRef<Capability> getDirectImpliedCapabilities(Capability cap);
-/// Returns the recursively implied capabilities for the given capability. These
-/// capabilities are implicitly declared by the given capability. Compared to
-/// the above function, this function collects implied capabilities recursively:
-/// if an implicitly declared capability implicitly declares a third one, the
-/// third one will also be returned.
-SmallVector<Capability, 0> getRecursiveImpliedCapabilities(Capability cap);
namespace detail {
struct ArrayTypeStorage;
// Returns in `decorationsInfo` all the Decorations (apart from Offset)
// associated with the `i`-th member of the StructType.
- void getMemberDecorations(unsigned i,
- SmallVectorImpl<StructType::MemberDecorationInfo>
- &decorationsInfo) const;
+ void getMemberDecorations(
+ unsigned i,
+ SmallVectorImpl<StructType::MemberDecorationInfo> &decorationsInfo) const;
/// Sets the contents of an incomplete identified StructType. This method must
/// be called only for identified StructTypes and it must be called only once
} // end namespace spirv
} // end namespace mlir
-#endif // MLIR_DIALECT_SPIRV_SPIRVTYPES_H_
+#endif // MLIR_DIALECT_SPIRV_IR_SPIRVTYPES_H_
//
//===----------------------------------------------------------------------===//
-#ifndef MLIR_DIALECT_SPIRV_TARGETANDABI_H
-#define MLIR_DIALECT_SPIRV_TARGETANDABI_H
+#ifndef MLIR_DIALECT_SPIRV_IR_TARGETANDABI_H
+#define MLIR_DIALECT_SPIRV_IR_TARGETANDABI_H
-#include "mlir/Dialect/SPIRV/SPIRVAttributes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVAttributes.h"
#include "mlir/Support/LLVM.h"
#include "llvm/ADT/SmallSet.h"
} // namespace spirv
} // namespace mlir
-#endif // MLIR_DIALECT_SPIRV_TARGETANDABI_H
+#endif // MLIR_DIALECT_SPIRV_IR_TARGETANDABI_H
//
//===----------------------------------------------------------------------===//
-#ifndef SPIRV_TARGET_AND_ABI
-#define SPIRV_TARGET_AND_ABI
+#ifndef MLIR_DIALECT_SPIRV_IR_TARGET_AND_ABI
+#define MLIR_DIALECT_SPIRV_IR_TARGET_AND_ABI
-include "mlir/Dialect/SPIRV/SPIRVBase.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
// For entry functions, this attribute specifies information related to entry
// points in the generated SPIR-V module:
DefaultValuedAttr<SPV_CooperativeMatrixPropertiesNVArrayAttr, "{}">>
]>;
-#endif // SPIRV_TARGET_AND_ABI
+#endif // MLIR_DIALECT_SPIRV_IR_TARGET_AND_ABI
//
//===----------------------------------------------------------------------===//
-#ifndef MLIR_DIALECT_SPIRV_MODULECOMBINER_H_
-#define MLIR_DIALECT_SPIRV_MODULECOMBINER_H_
+#ifndef MLIR_DIALECT_SPIRV_LINKING_MODULECOMBINER_H_
+#define MLIR_DIALECT_SPIRV_LINKING_MODULECOMBINER_H_
-#include "mlir/Dialect/SPIRV/SPIRVModule.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVModule.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
} // namespace spirv
} // namespace mlir
-#endif // MLIR_DIALECT_SPIRV_MODULECOMBINER_H_
+#endif // MLIR_DIALECT_SPIRV_LINKING_MODULECOMBINER_H_
--- /dev/null
+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 ./)
+
//
//===----------------------------------------------------------------------===//
-#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"
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.
/// 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_
//
//===----------------------------------------------------------------------===//
-#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"
let constructor = "mlir::spirv::createUpdateVersionCapabilityExtensionPass()";
}
-#endif // MLIR_DIALECT_SPIRV_PASSES
+#endif // MLIR_DIALECT_SPIRV_TRANSFORMS_PASSES
-//===- 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.
//
//===----------------------------------------------------------------------===//
//
-// 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"
} // namespace spirv
} // namespace mlir
-#endif // MLIR_DIALECT_SPIRV_SPIRVLOWERING_H
+#endif // MLIR_DIALECT_SPIRV_SPIRVCONVERSION_H
-//===-- 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.
// types in SPIR-V dialect.
//
//===----------------------------------------------------------------------===//
-#ifndef MLIR_DIALECT_SPIRV_LAYOUTUTILS_H_
-#define MLIR_DIALECT_SPIRV_LAYOUTUTILS_H_
+
+#ifndef MLIR_DIALECT_SPIRV_UTILS_LAYOUTUTILS_H_
+#define MLIR_DIALECT_SPIRV_UTILS_LAYOUTUTILS_H_
#include <cstdint>
} // namespace mlir
-#endif // MLIR_DIALECT_SPIRV_LAYOUTUTILS_H_
+#endif // MLIR_DIALECT_SPIRV_UTILS_LAYOUTUTILS_H_
#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"
#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"
#ifndef MLIR_TARGET_SPIRV_BINARY_UTILS_H_
#define MLIR_TARGET_SPIRV_BINARY_UTILS_H_
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
#include "mlir/Support/LogicalResult.h"
#include <cstdint>
MLIRPass
MLIRSCFToSPIRV
MLIRSPIRV
+ MLIRSPIRVConversion
MLIRStandard
MLIRStandardToSPIRVTransforms
MLIRSupport
//===----------------------------------------------------------------------===//
#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;
#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;
//===----------------------------------------------------------------------===//
-#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
#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"
MLIRLinalgUtils
MLIRPass
MLIRSPIRV
+ MLIRSPIRVConversion
MLIRSupport
)
#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"
#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;
MLIRAffine
MLIRAffineToStandard
MLIRSPIRV
+ MLIRSPIRVConversion
MLIRIR
MLIRLinalg
MLIRPass
//===----------------------------------------------------------------------===//
#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;
LINK_LIBS PUBLIC
MLIRGPU
MLIRSPIRV
+ MLIRSPIRVUtils
MLIRLLVMIR
MLIRStandardToLLVM
MLIRIR
#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"
#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"
#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;
MLIRIR
MLIRPass
MLIRSPIRV
+ MLIRSPIRVConversion
MLIRSupport
MLIRTransformUtils
- MLIRSPIRV
MLIRStandard
)
//
//===----------------------------------------------------------------------===//
-#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"
#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;
#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"
LINK_LIBS PUBLIC
MLIRSPIRV
+ MLIRSPIRVConversion
MLIRVector
MLIRTransforms
)
#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"
-
-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)
--- /dev/null
+set(LLVM_TARGET_DEFINITIONS SPIRVCanonicalization.td)
+mlir_tablegen(SPIRVCanonicalization.inc -gen-rewriters)
+add_public_tablegen_target(MLIRSPIRVCanonicalizationIncGen)
+
+add_mlir_dialect_library(MLIRSPIRV
+ SPIRVAttributes.cpp
+ SPIRVCanonicalization.cpp
+ SPIRVDialect.cpp
+ SPIRVEnums.cpp
+ SPIRVOps.cpp
+ SPIRVTypes.cpp
+ TargetAndABI.cpp
+
+ ADDITIONAL_HEADER_DIRS
+ ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/SPIRV
+
+ DEPENDS
+ MLIRSPIRVAttrUtilsGen
+ MLIRSPIRVAvailabilityIncGen
+ MLIRSPIRVCanonicalizationIncGen
+ MLIRSPIRVEnumAvailabilityIncGen
+ MLIRSPIRVEnumsIncGen
+ MLIRSPIRVOpsIncGen
+ MLIRSPIRVTargetAndABIIncGen
+
+ LINK_LIBS PUBLIC
+ MLIRControlFlowInterfaces
+ MLIRIR
+ MLIRParser
+ MLIRSideEffectInterfaces
+ MLIRSupport
+ MLIRTransforms
+)
//
//===----------------------------------------------------------------------===//
-#include "mlir/Dialect/SPIRV/SPIRVAttributes.h"
-#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVAttributes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
#include "mlir/IR/Builders.h"
using namespace mlir;
//===----------------------------------------------------------------------===//
+// TableGen'erated attribute utility functions
+//===----------------------------------------------------------------------===//
+
+namespace mlir {
+namespace spirv {
+#include "mlir/Dialect/SPIRV/IR/SPIRVAttrUtils.inc"
+} // namespace spirv
+} // namespace mlir
+
+//===----------------------------------------------------------------------===//
// DictionaryDict derived attributes
//===----------------------------------------------------------------------===//
-#include "mlir/Dialect/SPIRV/TargetAndABI.cpp.inc"
+#include "mlir/Dialect/SPIRV/IR/TargetAndABI.cpp.inc"
namespace mlir {
//
//===----------------------------------------------------------------------===//
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
#include "mlir/Dialect/CommonFolders.h"
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
-#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/PatternMatch.h"
return lhs->getAttrDictionary() == rhs->getAttrDictionary();
}
-
// Returns a source value for the given block.
Value getSrcValue(Block *block) const {
auto storeOp = cast<spirv::StoreOp>(block->front());
//
//===----------------------------------------------------------------------===//
-include "mlir/Dialect/SPIRV/SPIRVOps.td"
+include "mlir/Dialect/SPIRV/IR/SPIRVOps.td"
//===----------------------------------------------------------------------===//
// spv.Bitcast
//
//===----------------------------------------------------------------------===//
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
-#include "mlir/Dialect/SPIRV/ParserUtils.h"
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
-#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
-#include "mlir/Dialect/SPIRV/TargetAndABI.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/ParserUtils.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
+#include "mlir/Dialect/SPIRV/IR/TargetAndABI.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/DialectImplementation.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/raw_ostream.h"
-namespace mlir {
-namespace spirv {
-#include "mlir/Dialect/SPIRV/SPIRVOpUtils.inc"
-} // namespace spirv
-} // namespace mlir
-
using namespace mlir;
using namespace mlir::spirv;
// Add SPIR-V ops.
addOperations<
#define GET_OP_LIST
-#include "mlir/Dialect/SPIRV/SPIRVOps.cpp.inc"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.cpp.inc"
>();
addInterfaces<SPIRVInlinerInterface>();
--- /dev/null
+//===- SPIRVEnums.cpp - MLIR SPIR-V Enums ---------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the C/C++ enums from SPIR-V spec.
+//
+//===----------------------------------------------------------------------===//
+
+#include "mlir/Dialect/SPIRV/IR/SPIRVEnums.h"
+
+#include "llvm/ADT/SetVector.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSwitch.h"
+
+using namespace mlir;
+
+// Pull in all enum utility function definitions
+#include "mlir/Dialect/SPIRV/IR/SPIRVEnums.cpp.inc"
+
+// Pull in all enum type availability query function definitions
+#include "mlir/Dialect/SPIRV/IR/SPIRVEnumAvailability.cpp.inc"
+
+//===----------------------------------------------------------------------===//
+// Availability relationship
+//===----------------------------------------------------------------------===//
+
+ArrayRef<spirv::Extension> spirv::getImpliedExtensions(spirv::Version version) {
+ // Note: the following lists are from "Appendix A: Changes" of the spec.
+
+#define V_1_3_IMPLIED_EXTS \
+ Extension::SPV_KHR_shader_draw_parameters, Extension::SPV_KHR_16bit_storage, \
+ Extension::SPV_KHR_device_group, Extension::SPV_KHR_multiview, \
+ Extension::SPV_KHR_storage_buffer_storage_class, \
+ Extension::SPV_KHR_variable_pointers
+
+#define V_1_4_IMPLIED_EXTS \
+ Extension::SPV_KHR_no_integer_wrap_decoration, \
+ Extension::SPV_GOOGLE_decorate_string, \
+ Extension::SPV_GOOGLE_hlsl_functionality1, \
+ Extension::SPV_KHR_float_controls
+
+#define V_1_5_IMPLIED_EXTS \
+ Extension::SPV_KHR_8bit_storage, Extension::SPV_EXT_descriptor_indexing, \
+ Extension::SPV_EXT_shader_viewport_index_layer, \
+ Extension::SPV_EXT_physical_storage_buffer, \
+ Extension::SPV_KHR_physical_storage_buffer, \
+ Extension::SPV_KHR_vulkan_memory_model
+
+ switch (version) {
+ default:
+ return {};
+ case Version::V_1_3: {
+ // The following manual ArrayRef constructor call is to satisfy GCC 5.
+ static const Extension exts[] = {V_1_3_IMPLIED_EXTS};
+ return ArrayRef<spirv::Extension>(exts, llvm::array_lengthof(exts));
+ }
+ case Version::V_1_4: {
+ static const Extension exts[] = {V_1_3_IMPLIED_EXTS, V_1_4_IMPLIED_EXTS};
+ return ArrayRef<spirv::Extension>(exts, llvm::array_lengthof(exts));
+ }
+ case Version::V_1_5: {
+ static const Extension exts[] = {V_1_3_IMPLIED_EXTS, V_1_4_IMPLIED_EXTS,
+ V_1_5_IMPLIED_EXTS};
+ return ArrayRef<spirv::Extension>(exts, llvm::array_lengthof(exts));
+ }
+ }
+
+#undef V_1_5_IMPLIED_EXTS
+#undef V_1_4_IMPLIED_EXTS
+#undef V_1_3_IMPLIED_EXTS
+}
+
+// Pull in utility function definition for implied capabilities
+#include "mlir/Dialect/SPIRV/IR/SPIRVCapabilityImplication.inc"
+
+SmallVector<spirv::Capability, 0>
+spirv::getRecursiveImpliedCapabilities(spirv::Capability cap) {
+ ArrayRef<spirv::Capability> directCaps = getDirectImpliedCapabilities(cap);
+ llvm::SetVector<spirv::Capability, SmallVector<spirv::Capability, 0>> allCaps(
+ directCaps.begin(), directCaps.end());
+
+ // TODO: This is insufficient; find a better way to handle this
+ // (e.g., using static lists) if this turns out to be a bottleneck.
+ for (unsigned i = 0; i < allCaps.size(); ++i)
+ for (Capability c : getDirectImpliedCapabilities(allCaps[i]))
+ allCaps.insert(c);
+
+ return allCaps.takeVector();
+}
//
//===----------------------------------------------------------------------===//
-#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"
// 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
//
//===----------------------------------------------------------------------===//
-#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
#include "mlir/IR/Attributes.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Identifier.h"
#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/SetVector.h"
-#include "llvm/ADT/StringExtras.h"
-#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/TypeSwitch.h"
using namespace mlir;
using namespace mlir::spirv;
-// Pull in all enum utility function definitions
-#include "mlir/Dialect/SPIRV/SPIRVEnums.cpp.inc"
-// Pull in all enum type availability query function definitions
-#include "mlir/Dialect/SPIRV/SPIRVEnumAvailability.cpp.inc"
-
-//===----------------------------------------------------------------------===//
-// Availability relationship
-//===----------------------------------------------------------------------===//
-
-ArrayRef<Extension> spirv::getImpliedExtensions(Version version) {
- // Note: the following lists are from "Appendix A: Changes" of the spec.
-
-#define V_1_3_IMPLIED_EXTS \
- Extension::SPV_KHR_shader_draw_parameters, Extension::SPV_KHR_16bit_storage, \
- Extension::SPV_KHR_device_group, Extension::SPV_KHR_multiview, \
- Extension::SPV_KHR_storage_buffer_storage_class, \
- Extension::SPV_KHR_variable_pointers
-
-#define V_1_4_IMPLIED_EXTS \
- Extension::SPV_KHR_no_integer_wrap_decoration, \
- Extension::SPV_GOOGLE_decorate_string, \
- Extension::SPV_GOOGLE_hlsl_functionality1, \
- Extension::SPV_KHR_float_controls
-
-#define V_1_5_IMPLIED_EXTS \
- Extension::SPV_KHR_8bit_storage, Extension::SPV_EXT_descriptor_indexing, \
- Extension::SPV_EXT_shader_viewport_index_layer, \
- Extension::SPV_EXT_physical_storage_buffer, \
- Extension::SPV_KHR_physical_storage_buffer, \
- Extension::SPV_KHR_vulkan_memory_model
-
- switch (version) {
- default:
- return {};
- case Version::V_1_3: {
- // The following manual ArrayRef constructor call is to satisfy GCC 5.
- static const Extension exts[] = {V_1_3_IMPLIED_EXTS};
- return ArrayRef<Extension>(exts, llvm::array_lengthof(exts));
- }
- case Version::V_1_4: {
- static const Extension exts[] = {V_1_3_IMPLIED_EXTS, V_1_4_IMPLIED_EXTS};
- return ArrayRef<Extension>(exts, llvm::array_lengthof(exts));
- }
- case Version::V_1_5: {
- static const Extension exts[] = {V_1_3_IMPLIED_EXTS, V_1_4_IMPLIED_EXTS,
- V_1_5_IMPLIED_EXTS};
- return ArrayRef<Extension>(exts, llvm::array_lengthof(exts));
- }
- }
-
-#undef V_1_5_IMPLIED_EXTS
-#undef V_1_4_IMPLIED_EXTS
-#undef V_1_3_IMPLIED_EXTS
-}
-
-// Pull in utility function definition for implied capabilities
-#include "mlir/Dialect/SPIRV/SPIRVCapabilityImplication.inc"
-
-SmallVector<Capability, 0>
-spirv::getRecursiveImpliedCapabilities(Capability cap) {
- ArrayRef<Capability> directCaps = getDirectImpliedCapabilities(cap);
- llvm::SetVector<Capability, SmallVector<Capability, 0>> allCaps(
- directCaps.begin(), directCaps.end());
-
- // TODO: This is insufficient; find a better way to handle this
- // (e.g., using static lists) if this turns out to be a bottleneck.
- for (unsigned i = 0; i < allCaps.size(); ++i)
- for (Capability c : getDirectImpliedCapabilities(allCaps[i]))
- allCaps.insert(c);
-
- return allCaps.takeVector();
-}
-
//===----------------------------------------------------------------------===//
// ArrayType
//===----------------------------------------------------------------------===//
// ImageType
//===----------------------------------------------------------------------===//
-template <typename T> static constexpr unsigned getNumBits() { return 0; }
-template <> constexpr unsigned getNumBits<Dim>() {
+template <typename T>
+static constexpr unsigned getNumBits() {
+ return 0;
+}
+template <>
+constexpr unsigned getNumBits<Dim>() {
static_assert((1 << 3) > getMaxEnumValForDim(),
"Not enough bits to encode Dim value");
return 3;
}
-template <> constexpr unsigned getNumBits<ImageDepthInfo>() {
+template <>
+constexpr unsigned getNumBits<ImageDepthInfo>() {
static_assert((1 << 2) > getMaxEnumValForImageDepthInfo(),
"Not enough bits to encode ImageDepthInfo value");
return 2;
}
-template <> constexpr unsigned getNumBits<ImageArrayedInfo>() {
+template <>
+constexpr unsigned getNumBits<ImageArrayedInfo>() {
static_assert((1 << 1) > getMaxEnumValForImageArrayedInfo(),
"Not enough bits to encode ImageArrayedInfo value");
return 1;
}
-template <> constexpr unsigned getNumBits<ImageSamplingInfo>() {
+template <>
+constexpr unsigned getNumBits<ImageSamplingInfo>() {
static_assert((1 << 1) > getMaxEnumValForImageSamplingInfo(),
"Not enough bits to encode ImageSamplingInfo value");
return 1;
}
-template <> constexpr unsigned getNumBits<ImageSamplerUseInfo>() {
+template <>
+constexpr unsigned getNumBits<ImageSamplerUseInfo>() {
static_assert((1 << 2) > getMaxEnumValForImageSamplerUseInfo(),
"Not enough bits to encode ImageSamplerUseInfo value");
return 2;
}
-template <> constexpr unsigned getNumBits<ImageFormat>() {
+template <>
+constexpr unsigned getNumBits<ImageFormat>() {
static_assert((1 << 6) > getMaxEnumValForImageFormat(),
"Not enough bits to encode ImageFormat value");
return 6;
//
//===----------------------------------------------------------------------===//
-#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"
//
//===----------------------------------------------------------------------===//
-#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"
+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
LINK_LIBS PUBLIC
MLIRPass
- MLIRSPIRV
- )
+ MLIRSPIRVConversion
+ MLIRSPIRVUtils
+)
-//===- DecorateSPIRVCompositeTypeLayoutPass.cpp - Decorate composite type -===//
+//===- DecorateCompositeTypeLayoutPass.cpp - Decorate composite type ------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
//===----------------------------------------------------------------------===//
#include "PassDetail.h"
-#include "mlir/Dialect/SPIRV/LayoutUtils.h"
-#include "mlir/Dialect/SPIRV/Passes.h"
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/Transforms/Passes.h"
+#include "mlir/Dialect/SPIRV/Utils/LayoutUtils.h"
#include "mlir/Transforms/DialectConversion.h"
using namespace mlir;
//===----------------------------------------------------------------------===//
#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"
} // 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
//===----------------------------------------------------------------------===//
#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"
-//===- SPIRVLowering.cpp - SPIR-V lowering utilities ----------------------===//
+//===- SPIRVConversion.cpp - SPIR-V Conversion Utilities ------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
//
//===----------------------------------------------------------------------===//
-#include "mlir/Dialect/SPIRV/SPIRVLowering.h"
-#include "mlir/Dialect/SPIRV/LayoutUtils.h"
-#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
+#include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
#include "llvm/ADT/Sequence.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Debug.h"
#include <functional>
-#define DEBUG_TYPE "mlir-spirv-lowering"
+#define DEBUG_TYPE "mlir-spirv-conversion"
using namespace mlir;
//===----------------------------------------------------------------------===//
#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"
--- /dev/null
+add_mlir_dialect_library(MLIRSPIRVUtils
+ LayoutUtils.cpp
+
+ ADDITIONAL_HEADER_DIRS
+ ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/SPIRV
+
+ LINK_LIBS PUBLIC
+ MLIRSPIRV
+)
+
// 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;
#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"
// 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 {
//===----------------------------------------------------------------------===//
#include "mlir/Target/SPIRV/SPIRVBinaryUtils.h"
-#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
using namespace mlir;
#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"
// 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,
//
//===----------------------------------------------------------------------===//
-#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"
MLIRIR
MLIRPass
MLIRSPIRV
+ MLIRSPIRVConversion
MLIRSPIRVModuleCombiner
MLIRSupport
)
//
//===----------------------------------------------------------------------===//
-#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"
//===----------------------------------------------------------------------===//
#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;
//
//===----------------------------------------------------------------------===//
-#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"
#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"
-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
#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"
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;
}
//===----------------------------------------------------------------------===//
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);
});
//===----------------------------------------------------------------------===//
EnumAttr enumAttr(recordKeeper.getDef("SPV_CapabilityAttr"));
- os << "ArrayRef<Capability> "
- "spirv::getDirectImpliedCapabilities(Capability cap) {\n"
+ os << "ArrayRef<spirv::Capability> "
+ "spirv::getDirectImpliedCapabilities(spirv::Capability cap) {\n"
<< " switch (cap) {\n"
<< " default: return {};\n";
for (const EnumAttrCase &enumerant : enumAttr.getAllCases()) {
continue;
std::vector<Record *> impliedCapsDefs = def.getValueAsListOfDefs("implies");
- os << " case Capability::" << enumerant.getSymbol()
- << ": {static const Capability implies[" << impliedCapsDefs.size()
+ os << " case spirv::Capability::" << enumerant.getSymbol()
+ << ": {static const spirv::Capability implies[" << impliedCapsDefs.size()
<< "] = {";
llvm::interleaveComma(impliedCapsDefs, os, [&](const Record *capDef) {
- os << "Capability::" << EnumAttrCase(capDef).getSymbol();
+ os << "spirv::Capability::" << EnumAttrCase(capDef).getSymbol();
});
- os << "}; return ArrayRef<Capability>(implies, " << impliedCapsDefs.size()
- << "); }\n";
+ os << "}; return ArrayRef<spirv::Capability>(implies, "
+ << impliedCapsDefs.size() << "); }\n";
}
os << " }\n";
os << "}\n";
#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"
//===----------------------------------------------------------------------===//
#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"
//===----------------------------------------------------------------------===//
#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"