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

This commit shuffles SPIR-V code around to better follow MLIR
convention. Specifically,

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

Reviewed By: mravishankar

Differential Revision: https://reviews.llvm.org/D93407
This commit is contained in:
Lei Zhang 2020-12-17 10:55:45 -05:00
parent d20e0c3444
commit 0117865412
144 changed files with 619 additions and 520 deletions

View File

@ -1149,12 +1149,13 @@ These dialect to dialect conversions have their dedicated libraries,
There are also common utilities when targeting SPIR-V from any dialect:
* [include/mlir/Dialect/SPIRV/Passes.h][MlirSpirvPasses] contains SPIR-V
specific analyses and transformations.
* [include/mlir/Dialect/SPIRV/SPIRVLowering.h][MlirSpirvLowering] contains
type converters and other utility functions.
* [include/mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h][MlirSpirvConversion]
contains type converters and other utility functions.
* [include/mlir/Dialect/SPIRV/Transforms/Passes.h][MlirSpirvPasses] contains
SPIR-V specific analyses and transformations.
These common utilities are implemented in the `MLIRSPIRVTransforms` library.
These common utilities are implemented in the `MLIRSPIRVConversion` and
`MLIRSPIRVTransforms` library, respectively.
## Rationale
@ -1406,15 +1407,15 @@ dialect.
[MlirGpuToSpirvLibs]: https://github.com/llvm/llvm-project/tree/master/mlir/lib/Conversion/GPUToSPIRV
[MlirStdToSpirvHeaders]: https://github.com/llvm/llvm-project/tree/master/mlir/include/mlir/Conversion/StandardToSPIRV
[MlirStdToSpirvLibs]: https://github.com/llvm/llvm-project/tree/master/mlir/lib/Conversion/StandardToSPIRV
[MlirSpirvDialect]: https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Dialect/SPIRV/SPIRVDialect.h
[MlirSpirvTypes]: https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Dialect/SPIRV/SPIRVTypes.h
[MlirSpirvOpsH]: https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.h
[MlirSpirvSerialization]: https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Dialect/SPIRV/Serialization.h
[MlirSpirvBase]: https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td
[MlirSpirvPasses]: https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Dialect/SPIRV/Passes.h
[MlirSpirvLowering]: https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h
[MlirSpirvAbi]: https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Dialect/SPIRV/TargetAndABI.h
[MlirSpirvOpsCpp]: https://github.com/llvm/llvm-project/blob/master/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
[MlirSpirvDialect]: https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVDialect.h
[MlirSpirvTypes]: https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVTypes.h
[MlirSpirvOpsH]: https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVOps.h
[MlirSpirvSerialization]: https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Target/SPIRV/Serialization.h
[MlirSpirvBase]: https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td
[MlirSpirvPasses]: https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Dialect/SPIRV/Transforms/Passes.h
[MlirSpirvConversion]: https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h
[MlirSpirvAbi]: https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Dialect/SPIRV/IR/TargetAndABI.h
[MlirSpirvOpsCpp]: https://github.com/llvm/llvm-project/blob/master/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
[GitHubDialectTracking]: https://github.com/tensorflow/mlir/issues/302
[GitHubLoweringTracking]: https://github.com/tensorflow/mlir/issues/303
[GenSpirvUtilsPy]: https://github.com/llvm/llvm-project/blob/master/mlir/utils/spirv/gen_spirv_dialect.py

View File

@ -1,45 +1,2 @@
add_mlir_dialect(SPIRVOps spv)
add_mlir_doc(SPIRVOps -gen-op-doc SPIRVOps Dialects/)
set(LLVM_TARGET_DEFINITIONS SPIRVBase.td)
mlir_tablegen(SPIRVEnums.h.inc -gen-enum-decls)
mlir_tablegen(SPIRVEnums.cpp.inc -gen-enum-defs)
add_public_tablegen_target(MLIRSPIRVEnumsIncGen)
add_dependencies(mlir-headers MLIRSPIRVEnumsIncGen)
set(LLVM_TARGET_DEFINITIONS SPIRVBase.td)
mlir_tablegen(SPIRVEnumAvailability.h.inc -gen-spirv-enum-avail-decls)
mlir_tablegen(SPIRVEnumAvailability.cpp.inc -gen-spirv-enum-avail-defs)
mlir_tablegen(SPIRVCapabilityImplication.inc -gen-spirv-capability-implication)
add_public_tablegen_target(MLIRSPIRVEnumAvailabilityIncGen)
add_dependencies(mlir-headers MLIRSPIRVEnumAvailabilityIncGen)
set(LLVM_TARGET_DEFINITIONS SPIRVOps.td)
mlir_tablegen(SPIRVAvailability.h.inc -gen-avail-interface-decls)
mlir_tablegen(SPIRVAvailability.cpp.inc -gen-avail-interface-defs)
mlir_tablegen(SPIRVOpAvailabilityImpl.inc -gen-spirv-avail-impls)
add_public_tablegen_target(MLIRSPIRVAvailabilityIncGen)
add_dependencies(mlir-headers MLIRSPIRVAvailabilityIncGen)
set(LLVM_TARGET_DEFINITIONS SPIRVOps.td)
mlir_tablegen(SPIRVSerialization.inc -gen-spirv-serialization)
add_public_tablegen_target(MLIRSPIRVSerializationGen)
add_dependencies(mlir-headers MLIRSPIRVSerializationGen)
set(LLVM_TARGET_DEFINITIONS SPIRVBase.td)
mlir_tablegen(SPIRVOpUtils.inc -gen-spirv-op-utils)
add_public_tablegen_target(MLIRSPIRVOpUtilsGen)
add_dependencies(mlir-headers MLIRSPIRVOpUtilsGen)
set(LLVM_TARGET_DEFINITIONS TargetAndABI.td)
mlir_tablegen(TargetAndABI.h.inc -gen-struct-attr-decls)
mlir_tablegen(TargetAndABI.cpp.inc -gen-struct-attr-defs)
add_public_tablegen_target(MLIRSPIRVTargetAndABIIncGen)
add_dependencies(mlir-headers MLIRSPIRVTargetAndABIIncGen)
set(LLVM_TARGET_DEFINITIONS Passes.td)
mlir_tablegen(Passes.h.inc -gen-pass-decls -name SPIRV)
add_public_tablegen_target(MLIRSPIRVPassIncGen)
add_dependencies(mlir-headers MLIRSPIRVPassIncGen)
add_mlir_doc(Passes -gen-pass-doc SPIRVPasses ./)
add_subdirectory(IR)
add_subdirectory(Transforms)

View File

@ -0,0 +1,38 @@
add_mlir_dialect(SPIRVOps spv)
add_mlir_doc(SPIRVOps -gen-op-doc SPIRVOps Dialects/)
set(LLVM_TARGET_DEFINITIONS SPIRVBase.td)
mlir_tablegen(SPIRVEnums.h.inc -gen-enum-decls)
mlir_tablegen(SPIRVEnums.cpp.inc -gen-enum-defs)
add_public_tablegen_target(MLIRSPIRVEnumsIncGen)
add_dependencies(mlir-headers MLIRSPIRVEnumsIncGen)
set(LLVM_TARGET_DEFINITIONS SPIRVBase.td)
mlir_tablegen(SPIRVEnumAvailability.h.inc -gen-spirv-enum-avail-decls)
mlir_tablegen(SPIRVEnumAvailability.cpp.inc -gen-spirv-enum-avail-defs)
mlir_tablegen(SPIRVCapabilityImplication.inc -gen-spirv-capability-implication)
add_public_tablegen_target(MLIRSPIRVEnumAvailabilityIncGen)
add_dependencies(mlir-headers MLIRSPIRVEnumAvailabilityIncGen)
set(LLVM_TARGET_DEFINITIONS SPIRVOps.td)
mlir_tablegen(SPIRVAvailability.h.inc -gen-avail-interface-decls)
mlir_tablegen(SPIRVAvailability.cpp.inc -gen-avail-interface-defs)
mlir_tablegen(SPIRVOpAvailabilityImpl.inc -gen-spirv-avail-impls)
add_public_tablegen_target(MLIRSPIRVAvailabilityIncGen)
add_dependencies(mlir-headers MLIRSPIRVAvailabilityIncGen)
set(LLVM_TARGET_DEFINITIONS SPIRVOps.td)
mlir_tablegen(SPIRVSerialization.inc -gen-spirv-serialization)
add_public_tablegen_target(MLIRSPIRVSerializationGen)
add_dependencies(mlir-headers MLIRSPIRVSerializationGen)
set(LLVM_TARGET_DEFINITIONS SPIRVBase.td)
mlir_tablegen(SPIRVAttrUtils.inc -gen-spirv-attr-utils)
add_public_tablegen_target(MLIRSPIRVAttrUtilsGen)
add_dependencies(mlir-headers MLIRSPIRVAttrUtilsGen)
set(LLVM_TARGET_DEFINITIONS TargetAndABI.td)
mlir_tablegen(TargetAndABI.h.inc -gen-struct-attr-decls)
mlir_tablegen(TargetAndABI.cpp.inc -gen-struct-attr-defs)
add_public_tablegen_target(MLIRSPIRVTargetAndABIIncGen)
add_dependencies(mlir-headers MLIRSPIRVTargetAndABIIncGen)

View File

@ -10,14 +10,16 @@
// dialect.
//
//===----------------------------------------------------------------------===//
#ifndef MLIR_DIALECT_SPIRV_PARSERUTILS_H_
#define MLIR_DIALECT_SPIRV_PARSERUTILS_H_
#include "mlir/Dialect/SPIRV/SPIRVOps.h"
#ifndef MLIR_DIALECT_SPIRV_IR_PARSERUTILS_H_
#define MLIR_DIALECT_SPIRV_IR_PARSERUTILS_H_
#include "mlir/Dialect/SPIRV/IR/SPIRVAttributes.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/IR/OpImplementation.h"
namespace mlir {
/// Parses the next keyword in `parser` as an enumerant of the given
/// `EnumClass`.
template <typename EnumClass, typename ParserType>
@ -36,6 +38,7 @@ parseEnumKeywordAttr(EnumClass &value, ParserType &parser,
return parser.emitError(loc, "invalid ")
<< attrName << " attribute specification: " << keyword;
}
} // namespace mlir
#endif // MLIR_DIALECT_SPIRV_PARSERUTILS_H_
#endif // MLIR_DIALECT_SPIRV_IR_PARSERUTILS_H_

View File

@ -11,10 +11,10 @@
//
//===----------------------------------------------------------------------===//
#ifndef SPIRV_ARITHMETIC_OPS
#define SPIRV_ARITHMETIC_OPS
#ifndef MLIR_DIALECT_SPIRV_IR_ARITHMETIC_OPS
#define MLIR_DIALECT_SPIRV_IR_ARITHMETIC_OPS
include "mlir/Dialect/SPIRV/SPIRVBase.td"
include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
class SPV_ArithmeticBinaryOp<string mnemonic, Type type,
@ -576,4 +576,4 @@ def SPV_UModOp : SPV_ArithmeticBinaryOp<"UMod", SPV_Integer> {
}];
}
#endif // SPIRV_ARITHMETIC_OPS
#endif // MLIR_DIALECT_SPIRV_IR_ARITHMETIC_OPS

View File

@ -11,8 +11,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef SPIRV_ATOMIC_OPS
#define SPIRV_ATOMIC_OPS
#ifndef MLIR_DIALECT_SPIRV_IR_ATOMIC_OPS
#define MLIR_DIALECT_SPIRV_IR_ATOMIC_OPS
class SPV_AtomicUpdateOp<string mnemonic, list<OpTrait> traits = []> :
SPV_Op<mnemonic, traits> {
@ -564,4 +564,4 @@ def SPV_AtomicXorOp : SPV_AtomicUpdateWithValueOp<"AtomicXor", []> {
// -----
#endif // SPIRV_ATOMIC_OPS
#endif // MLIR_DIALECT_SPIRV_IR_ATOMIC_OPS

View File

@ -10,15 +10,15 @@
//
//===----------------------------------------------------------------------===//
#ifndef MLIR_DIALECT_SPIRV_SPIRVATTRIBUTES_H
#define MLIR_DIALECT_SPIRV_SPIRVATTRIBUTES_H
#ifndef MLIR_DIALECT_SPIRV_IR_SPIRVATTRIBUTES_H
#define MLIR_DIALECT_SPIRV_IR_SPIRVATTRIBUTES_H
#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
#include "mlir/IR/BuiltinAttributes.h"
#include "mlir/Support/LLVM.h"
// Pull in SPIR-V attribute definitions for target and ABI.
#include "mlir/Dialect/SPIRV/TargetAndABI.h.inc"
// Pull in TableGen'erated SPIR-V attribute definitions for target and ABI.
#include "mlir/Dialect/SPIRV/IR/TargetAndABI.h.inc"
namespace mlir {
namespace spirv {
@ -34,6 +34,14 @@ struct TargetEnvAttributeStorage;
struct VerCapExtAttributeStorage;
} // namespace detail
// TableGen'erated helper functions.
//
// Get the name used in the Op to refer to an enum value of the given
// `EnumClass`.
// template <typename EnumClass> StringRef attributeName();
//
#include "mlir/Dialect/SPIRV/IR/SPIRVAttrUtils.inc"
/// An attribute that specifies the information regarding the interface
/// variable: descriptor set, binding, storage class.
class InterfaceVarABIAttr
@ -174,4 +182,4 @@ public:
} // namespace spirv
} // namespace mlir
#endif // MLIR_DIALECT_SPIRV_SPIRVATTRIBUTES_H
#endif // MLIR_DIALECT_SPIRV_IR_SPIRVATTRIBUTES_H

View File

@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef SPIRV_AVAILABILITY
#define SPIRV_AVAILABILITY
#ifndef MLIR_DIALECT_SPIRV_IR_AVAILABILITY
#define MLIR_DIALECT_SPIRV_IR_AVAILABILITY
include "mlir/IR/OpBase.td"
@ -86,4 +86,4 @@ class MaxVersionBase<string name, I32EnumAttr scheme, I32EnumAttrCase max>
max.symbol;
}
#endif // SPIRV_AVAILABILITY
#endif // MLIR_DIALECT_SPIRV_IR_AVAILABILITY

View File

@ -12,11 +12,11 @@
//
//===----------------------------------------------------------------------===//
#ifndef SPIRV_BASE
#define SPIRV_BASE
#ifndef MLIR_DIALECT_SPIRV_IR_BASE
#define MLIR_DIALECT_SPIRV_IR_BASE
include "mlir/IR/OpBase.td"
include "mlir/Dialect/SPIRV/SPIRVAvailability.td"
include "mlir/Dialect/SPIRV/IR/SPIRVAvailability.td"
//===----------------------------------------------------------------------===//
// SPIR-V dialect definitions
@ -3480,4 +3480,4 @@ class SPV_ExtInstOp<string mnemonic, string setPrefix, string setName,
string extendedInstSetName = setName;
}
#endif // SPIRV_BASE
#endif // MLIR_DIALECT_SPIRV_IR_BASE

View File

@ -11,10 +11,10 @@
//
//===----------------------------------------------------------------------===//
#ifndef SPIRV_BIT_OPS
#define SPIRV_BIT_OPS
#ifndef MLIR_DIALECT_SPIRV_IR_BIT_OPS
#define MLIR_DIALECT_SPIRV_IR_BIT_OPS
include "mlir/Dialect/SPIRV/SPIRVBase.td"
include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
class SPV_BitBinaryOp<string mnemonic, list<OpTrait> traits = []> :
@ -608,4 +608,4 @@ def SPV_NotOp : SPV_BitUnaryOp<"Not", []> {
}];
}
#endif // SPIRV_BIT_OPS
#endif // MLIR_DIALECT_SPIRV_IR_BIT_OPS

View File

@ -11,10 +11,10 @@
//
//===----------------------------------------------------------------------===//
#ifndef SPIRV_CAST_OPS
#define SPIRV_CAST_OPS
#ifndef MLIR_DIALECT_SPIRV_IR_CAST_OPS
#define MLIR_DIALECT_SPIRV_IR_CAST_OPS
include "mlir/Dialect/SPIRV/SPIRVBase.td"
include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
class SPV_CastOp<string mnemonic, Type resultType, Type operandType,
@ -331,4 +331,4 @@ def SPV_UConvertOp : SPV_CastOp<"UConvert", SPV_Integer, SPV_Integer, []> {
let verifier = [{ return verifyCastOp(this->getOperation(), false); }];
}
#endif // SPIRV_CAST_OPS
#endif // MLIR_DIALECT_SPIRV_IR_CAST_OPS

View File

@ -11,10 +11,10 @@
//
//===----------------------------------------------------------------------===//
#ifndef SPIRV_COMPOSITE_OPS
#define SPIRV_COMPOSITE_OPS
#ifndef MLIR_DIALECT_SPIRV_IR_COMPOSITE_OPS
#define MLIR_DIALECT_SPIRV_IR_COMPOSITE_OPS
include "mlir/Dialect/SPIRV/SPIRVBase.td"
include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
// -----
@ -289,4 +289,4 @@ def SPV_VectorInsertDynamicOp : SPV_Op<"VectorInsertDynamic",
// -----
#endif // SPIRV_COMPOSITE_OPS
#endif // MLIR_DIALECT_SPIRV_IR_COMPOSITE_OPS

View File

@ -11,10 +11,10 @@
//
//===----------------------------------------------------------------------===//
#ifndef SPIRV_CONTROLFLOW_OPS
#define SPIRV_CONTROLFLOW_OPS
#ifndef MLIR_DIALECT_SPIRV_IR_CONTROLFLOW_OPS
#define MLIR_DIALECT_SPIRV_IR_CONTROLFLOW_OPS
include "mlir/Dialect/SPIRV/SPIRVBase.td"
include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
include "mlir/Interfaces/CallInterfaces.td"
include "mlir/Interfaces/ControlFlowInterfaces.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
@ -472,4 +472,4 @@ def SPV_SelectionOp : SPV_Op<"selection", [InFunctionScope]> {
let hasCanonicalizer = 1;
}
#endif // SPIRV_CONTROLFLOW_OPS
#endif // MLIR_DIALECT_SPIRV_IR_CONTROLFLOW_OPS

View File

@ -10,8 +10,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef SPIRV_COOPERATIVE_MATRIX_OPS
#define SPIRV_COOPERATIVE_MATRIX_OPS
#ifndef MLIR_DIALECT_SPIRV_IR_COOPERATIVE_MATRIX_OPS
#define MLIR_DIALECT_SPIRV_IR_COOPERATIVE_MATRIX_OPS
// -----
@ -283,4 +283,4 @@ def SPV_CooperativeMatrixStoreNVOp : SPV_Op<"CooperativeMatrixStoreNV", []> {
// -----
#endif // SPIRV_COOPERATIVE_MATRIX_OPS
#endif // MLIR_DIALECT_SPIRV_IR_COOPERATIVE_MATRIX_OPS

View File

@ -10,8 +10,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef MLIR_DIALECT_SPIRV_SPIRVDIALECT_H_
#define MLIR_DIALECT_SPIRV_SPIRVDIALECT_H_
#ifndef MLIR_DIALECT_SPIRV_IR_SPIRVDIALECT_H_
#define MLIR_DIALECT_SPIRV_IR_SPIRVDIALECT_H_
#include "mlir/IR/Dialect.h"
@ -23,6 +23,6 @@ enum class Decoration : uint32_t;
} // end namespace spirv
} // end namespace mlir
#include "mlir/Dialect/SPIRV/SPIRVOpsDialect.h.inc"
#include "mlir/Dialect/SPIRV/IR/SPIRVOpsDialect.h.inc"
#endif // MLIR_DIALECT_SPIRV_SPIRVDIALECT_H_
#endif // MLIR_DIALECT_SPIRV_IR_SPIRVDIALECT_H_

View File

@ -0,0 +1,57 @@
//===- SPIRVEnums.h - MLIR SPIR-V Enums -------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file declares the C/C++ enums from SPIR-V spec.
//
//===----------------------------------------------------------------------===//
#ifndef MLIR_DIALECT_SPIRV_IR_SPIRVENUMS_H_
#define MLIR_DIALECT_SPIRV_IR_SPIRVENUMS_H_
#include "mlir/Support/LLVM.h"
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/ADT/StringRef.h"
// Forward declare enum classes related to op availability. Their definitions
// are in the TableGen'erated SPIRVEnums.h.inc and can be referenced by other
// declarations in SPIRVEnums.h.inc.
namespace mlir {
namespace spirv {
enum class Version : uint32_t;
enum class Extension;
enum class Capability : uint32_t;
} // namespace spirv
} // namespace mlir
// Pull in all enum type definitions and utility function declarations
#include "mlir/Dialect/SPIRV/IR/SPIRVEnums.h.inc"
// Pull in all enum type availability query function declarations
#include "mlir/Dialect/SPIRV/IR/SPIRVEnumAvailability.h.inc"
namespace mlir {
namespace spirv {
/// Returns the implied extensions for the given version. These extensions are
/// incorporated into the current version so they are implicitly declared when
/// targeting the given version.
ArrayRef<Extension> getImpliedExtensions(Version version);
/// Returns the directly implied capabilities for the given capability. These
/// capabilities are implicitly declared by the given capability.
ArrayRef<Capability> getDirectImpliedCapabilities(Capability cap);
/// Returns the recursively implied capabilities for the given capability. These
/// capabilities are implicitly declared by the given capability. Compared to
/// the above function, this function collects implied capabilities recursively:
/// if an implicitly declared capability implicitly declares a third one, the
/// third one will also be returned.
SmallVector<Capability, 0> getRecursiveImpliedCapabilities(Capability cap);
} // end namespace spirv
} // end namespace mlir
#endif // MLIR_DIALECT_SPIRV_IR_SPIRVENUMS_H_

View File

@ -10,10 +10,10 @@
//
//===----------------------------------------------------------------------===//
#ifndef SPIRV_GLSL_OPS
#define SPIRV_GLSL_OPS
#ifndef MLIR_DIALECT_SPIRV_IR_GLSL_OPS
#define MLIR_DIALECT_SPIRV_IR_GLSL_OPS
include "mlir/Dialect/SPIRV/SPIRVBase.td"
include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
//===----------------------------------------------------------------------===//
@ -972,4 +972,4 @@ def SPV_GLSLSClampOp : SPV_GLSLTernaryArithmeticOp<"SClamp", 45, SPV_SignedInt>
}];
}
#endif // SPIRV_GLSL_OPS
#endif // MLIR_DIALECT_SPIRV_IR_GLSL_OPS

View File

@ -12,8 +12,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef SPIRV_GROUP_OPS
#define SPIRV_GROUP_OPS
#ifndef MLIR_DIALECT_SPIRV_IR_GROUP_OPS
#define MLIR_DIALECT_SPIRV_IR_GROUP_OPS
// -----
@ -246,4 +246,4 @@ def SPV_SubgroupBlockWriteINTELOp : SPV_Op<"SubgroupBlockWriteINTEL", []> {
// -----
#endif // SPIRV_GROUP_OPS
#endif // MLIR_DIALECT_SPIRV_IR_GROUP_OPS

View File

@ -11,10 +11,10 @@
//
//===----------------------------------------------------------------------===//
#ifndef SPIRV_LOGICAL_OPS
#define SPIRV_LOGICAL_OPS
#ifndef MLIR_DIALECT_SPIRV_IR_LOGICAL_OPS
#define MLIR_DIALECT_SPIRV_IR_LOGICAL_OPS
include "mlir/Dialect/SPIRV/SPIRVBase.td"
include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
class SPV_LogicalBinaryOp<string mnemonic, Type operandsType,
@ -1002,4 +1002,4 @@ def SPV_ULessThanEqualOp :
}];
}
#endif // SPIRV_LOGICAL_OPS
#endif // MLIR_DIALECT_SPIRV_IR_LOGICAL_OPS

View File

@ -10,8 +10,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef SPIRV_MATRIX_OPS
#define SPIRV_MATRIX_OPS
#ifndef MLIR_DIALECT_SPIRV_IR_MATRIX_OPS
#define MLIR_DIALECT_SPIRV_IR_MATRIX_OPS
include "mlir/Interfaces/SideEffectInterfaces.td"
// -----
@ -188,4 +188,4 @@ def SPV_TransposeOp : SPV_Op<"Transpose", [NoSideEffect]> {
// -----
#endif // SPIRV_MATRIX_OPS
#endif // MLIR_DIALECT_SPIRV_IR_MATRIX_OPS

View File

@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
#ifndef MLIR_DIALECT_SPIRV_SPIRVMODULE_H
#define MLIR_DIALECT_SPIRV_SPIRVMODULE_H
#ifndef MLIR_DIALECT_SPIRV_IR_SPIRVMODULE_H
#define MLIR_DIALECT_SPIRV_IR_SPIRVMODULE_H
#include "mlir/Dialect/SPIRV/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
#include "mlir/IR/OwningOpRef.h"
namespace mlir {
@ -27,4 +27,4 @@ public:
} // end namespace spirv
} // end namespace mlir
#endif // MLIR_DIALECT_SPIRV_SPIRVMODULE_H
#endif // MLIR_DIALECT_SPIRV_IR_SPIRVMODULE_H

View File

@ -11,8 +11,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef SPIRV_NON_UNIFORM_OPS
#define SPIRV_NON_UNIFORM_OPS
#ifndef MLIR_DIALECT_SPIRV_IR_NON_UNIFORM_OPS
#define MLIR_DIALECT_SPIRV_IR_NON_UNIFORM_OPS
class SPV_GroupNonUniformArithmeticOp<string mnemonic, Type type,
list<OpTrait> traits = []> : SPV_Op<mnemonic, traits> {
@ -730,4 +730,4 @@ def SPV_GroupNonUniformUMinOp :
// -----
#endif // SPIRV_NON_UNIFORM_OPS
#endif // MLIR_DIALECT_SPIRV_IR_NON_UNIFORM_OPS

View File

@ -10,10 +10,10 @@
//
//===----------------------------------------------------------------------===//
#ifndef SPIRV_OCL_OPS
#define SPIRV_OCL_OPS
#ifndef MLIR_DIALECT_SPIRV_IR_OCL_OPS
#define MLIR_DIALECT_SPIRV_IR_OCL_OPS
include "mlir/Dialect/SPIRV/SPIRVBase.td"
include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
//===----------------------------------------------------------------------===//
// SPIR-V OpenCL opcode specification.
@ -166,4 +166,4 @@ def SPV_OCLSAbsOp : SPV_OCLUnaryArithmeticOp<"s_abs", 141, SPV_Integer> {
}];
}
#endif // SPIRV_OCL_OPS
#endif // MLIR_DIALECT_SPIRV_IR_OCL_OPS

View File

@ -10,10 +10,10 @@
//
//===----------------------------------------------------------------------===//
#ifndef MLIR_DIALECT_SPIRV_SPIRVOPS_H_
#define MLIR_DIALECT_SPIRV_SPIRVOPS_H_
#ifndef MLIR_DIALECT_SPIRV_IR_SPIRVOPS_H_
#define MLIR_DIALECT_SPIRV_IR_SPIRVOPS_H_
#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/Interfaces/ControlFlowInterfaces.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
@ -27,26 +27,13 @@ class VerCapExtAttr;
// TableGen'erated operation interfaces for querying versions, extensions, and
// capabilities.
#include "mlir/Dialect/SPIRV/SPIRVAvailability.h.inc"
#include "mlir/Dialect/SPIRV/IR/SPIRVAvailability.h.inc"
} // namespace spirv
} // namespace mlir
// TablenGen'erated operation declarations.
#define GET_OP_CLASSES
#include "mlir/Dialect/SPIRV/SPIRVOps.h.inc"
namespace mlir {
namespace spirv {
// TableGen'erated helper functions.
//
// Get the name used in the Op to refer to an enum value of the given
// `EnumClass`.
// template <typename EnumClass> StringRef attributeName();
//
#include "mlir/Dialect/SPIRV/SPIRVOpUtils.inc"
} // end namespace spirv
} // end namespace mlir
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h.inc"
namespace llvm {
@ -84,4 +71,4 @@ public:
} // namespace llvm
#endif // MLIR_DIALECT_SPIRV_SPIRVOPS_H_
#endif // MLIR_DIALECT_SPIRV_IR_SPIRVOPS_H_

View File

@ -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
#ifndef MLIR_DIALECT_SPIRV_IR_OPS
#define MLIR_DIALECT_SPIRV_IR_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"
include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
include "mlir/Dialect/SPIRV/IR/SPIRVArithmeticOps.td"
include "mlir/Dialect/SPIRV/IR/SPIRVAtomicOps.td"
include "mlir/Dialect/SPIRV/IR/SPIRVBitOps.td"
include "mlir/Dialect/SPIRV/IR/SPIRVCastOps.td"
include "mlir/Dialect/SPIRV/IR/SPIRVCompositeOps.td"
include "mlir/Dialect/SPIRV/IR/SPIRVControlFlowOps.td"
include "mlir/Dialect/SPIRV/IR/SPIRVCooperativeMatrixOps.td"
include "mlir/Dialect/SPIRV/IR/SPIRVGLSLOps.td"
include "mlir/Dialect/SPIRV/IR/SPIRVGroupOps.td"
include "mlir/Dialect/SPIRV/IR/SPIRVLogicalOps.td"
include "mlir/Dialect/SPIRV/IR/SPIRVMatrixOps.td"
include "mlir/Dialect/SPIRV/IR/SPIRVNonUniformOps.td"
include "mlir/Dialect/SPIRV/IR/SPIRVOCLOps.td"
include "mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
// -----
@ -529,4 +529,4 @@ def SPV_VariableOp : SPV_Op<"Variable", []> {
// -----
#endif // SPIRV_OPS
#endif // MLIR_DIALECT_SPIRV_IR_OPS

View File

@ -12,10 +12,10 @@
//
//===----------------------------------------------------------------------===//
#ifndef SPIRV_STRUCTURE_OPS
#define SPIRV_STRUCTURE_OPS
#ifndef MLIR_DIALECT_SPIRV_IR_STRUCTURE_OPS
#define MLIR_DIALECT_SPIRV_IR_STRUCTURE_OPS
include "mlir/Dialect/SPIRV/SPIRVBase.td"
include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
include "mlir/IR/SymbolInterfaces.td"
include "mlir/Interfaces/CallInterfaces.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
@ -734,4 +734,4 @@ def SPV_SpecConstantOperationOp : SPV_Op<"SpecConstantOperation", [
// -----
#endif // SPIRV_STRUCTURE_OPS
#endif // MLIR_DIALECT_SPIRV_IR_STRUCTURE_OPS

View File

@ -10,9 +10,10 @@
//
//===----------------------------------------------------------------------===//
#ifndef MLIR_DIALECT_SPIRV_SPIRVTYPES_H_
#define MLIR_DIALECT_SPIRV_SPIRVTYPES_H_
#ifndef MLIR_DIALECT_SPIRV_IR_SPIRVTYPES_H_
#define MLIR_DIALECT_SPIRV_IR_SPIRVTYPES_H_
#include "mlir/Dialect/SPIRV/IR/SPIRVEnums.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Diagnostics.h"
#include "mlir/IR/Location.h"
@ -21,38 +22,8 @@
#include <tuple>
// Forward declare enum classes related to op availability. Their definitions
// are in the TableGen'erated SPIRVEnums.h.inc and can be referenced by other
// declarations in SPIRVEnums.h.inc.
namespace mlir {
namespace spirv {
enum class Version : uint32_t;
enum class Extension;
enum class Capability : uint32_t;
} // namespace spirv
} // namespace mlir
// Pull in all enum type definitions and utility function declarations
#include "mlir/Dialect/SPIRV/SPIRVEnums.h.inc"
// Pull in all enum type availability query function declarations
#include "mlir/Dialect/SPIRV/SPIRVEnumAvailability.h.inc"
namespace mlir {
namespace spirv {
/// Returns the implied extensions for the given version. These extensions are
/// incorporated into the current version so they are implicitly declared when
/// targeting the given version.
ArrayRef<Extension> getImpliedExtensions(Version version);
/// Returns the directly implied capabilities for the given capability. These
/// capabilities are implicitly declared by the given capability.
ArrayRef<Capability> getDirectImpliedCapabilities(Capability cap);
/// Returns the recursively implied capabilities for the given capability. These
/// capabilities are implicitly declared by the given capability. Compared to
/// the above function, this function collects implied capabilities recursively:
/// if an implicitly declared capability implicitly declares a third one, the
/// third one will also be returned.
SmallVector<Capability, 0> getRecursiveImpliedCapabilities(Capability cap);
namespace detail {
struct ArrayTypeStorage;
@ -380,9 +351,9 @@ public:
// Returns in `decorationsInfo` all the Decorations (apart from Offset)
// associated with the `i`-th member of the StructType.
void getMemberDecorations(unsigned i,
SmallVectorImpl<StructType::MemberDecorationInfo>
&decorationsInfo) const;
void getMemberDecorations(
unsigned i,
SmallVectorImpl<StructType::MemberDecorationInfo> &decorationsInfo) const;
/// Sets the contents of an incomplete identified StructType. This method must
/// be called only for identified StructTypes and it must be called only once
@ -465,4 +436,4 @@ public:
} // end namespace spirv
} // end namespace mlir
#endif // MLIR_DIALECT_SPIRV_SPIRVTYPES_H_
#endif // MLIR_DIALECT_SPIRV_IR_SPIRVTYPES_H_

View File

@ -10,10 +10,10 @@
//
//===----------------------------------------------------------------------===//
#ifndef MLIR_DIALECT_SPIRV_TARGETANDABI_H
#define MLIR_DIALECT_SPIRV_TARGETANDABI_H
#ifndef MLIR_DIALECT_SPIRV_IR_TARGETANDABI_H
#define MLIR_DIALECT_SPIRV_IR_TARGETANDABI_H
#include "mlir/Dialect/SPIRV/SPIRVAttributes.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVAttributes.h"
#include "mlir/Support/LLVM.h"
#include "llvm/ADT/SmallSet.h"
@ -132,4 +132,4 @@ FailureOr<MemoryModel> getMemoryModel(TargetEnvAttr targetAttr);
} // namespace spirv
} // namespace mlir
#endif // MLIR_DIALECT_SPIRV_TARGETANDABI_H
#endif // MLIR_DIALECT_SPIRV_IR_TARGETANDABI_H

View File

@ -18,10 +18,10 @@
//
//===----------------------------------------------------------------------===//
#ifndef SPIRV_TARGET_AND_ABI
#define SPIRV_TARGET_AND_ABI
#ifndef MLIR_DIALECT_SPIRV_IR_TARGET_AND_ABI
#define MLIR_DIALECT_SPIRV_IR_TARGET_AND_ABI
include "mlir/Dialect/SPIRV/SPIRVBase.td"
include "mlir/Dialect/SPIRV/IR/SPIRVBase.td"
// For entry functions, this attribute specifies information related to entry
// points in the generated SPIR-V module:
@ -88,4 +88,4 @@ def SPV_ResourceLimitsAttr : StructAttr<"ResourceLimitsAttr", SPIRV_Dialect, [
DefaultValuedAttr<SPV_CooperativeMatrixPropertiesNVArrayAttr, "{}">>
]>;
#endif // SPIRV_TARGET_AND_ABI
#endif // MLIR_DIALECT_SPIRV_IR_TARGET_AND_ABI

View File

@ -10,10 +10,10 @@
//
//===----------------------------------------------------------------------===//
#ifndef MLIR_DIALECT_SPIRV_MODULECOMBINER_H_
#define MLIR_DIALECT_SPIRV_MODULECOMBINER_H_
#ifndef MLIR_DIALECT_SPIRV_LINKING_MODULECOMBINER_H_
#define MLIR_DIALECT_SPIRV_LINKING_MODULECOMBINER_H_
#include "mlir/Dialect/SPIRV/SPIRVModule.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVModule.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
@ -75,4 +75,4 @@ combine(llvm::MutableArrayRef<ModuleOp> modules,
} // namespace spirv
} // namespace mlir
#endif // MLIR_DIALECT_SPIRV_MODULECOMBINER_H_
#endif // MLIR_DIALECT_SPIRV_LINKING_MODULECOMBINER_H_

View File

@ -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 ./)

View File

@ -10,8 +10,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef MLIR_DIALECT_SPIRV_PASSES_H_
#define MLIR_DIALECT_SPIRV_PASSES_H_
#ifndef MLIR_DIALECT_SPIRV_TRANSFORMS_PASSES_H_
#define MLIR_DIALECT_SPIRV_TRANSFORMS_PASSES_H_
#include "mlir/Pass/Pass.h"
@ -19,6 +19,11 @@ namespace mlir {
namespace spirv {
class ModuleOp;
//===----------------------------------------------------------------------===//
// Passes
//===----------------------------------------------------------------------===//
/// Creates a module pass that converts composite types used by objects in the
/// StorageBuffer, PhysicalStorageBuffer, Uniform, and PushConstant storage
/// classes with layout information.
@ -56,9 +61,9 @@ std::unique_ptr<OperationPass<spirv::ModuleOp>> createRewriteInsertsPass();
/// Generate the code for registering passes.
#define GEN_PASS_REGISTRATION
#include "mlir/Dialect/SPIRV/Passes.h.inc"
#include "mlir/Dialect/SPIRV/Transforms/Passes.h.inc"
} // namespace spirv
} // namespace mlir
#endif // MLIR_DIALECT_SPIRV_PASSES_H_
#endif // MLIR_DIALECT_SPIRV_TRANSFORMS_PASSES_H_

View File

@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef MLIR_DIALECT_SPIRV_PASSES
#define MLIR_DIALECT_SPIRV_PASSES
#ifndef MLIR_DIALECT_SPIRV_TRANSFORMS_PASSES
#define MLIR_DIALECT_SPIRV_TRANSFORMS_PASSES
include "mlir/Pass/PassBase.td"
@ -34,4 +34,4 @@ def SPIRVUpdateVCE : Pass<"spirv-update-vce", "spirv::ModuleOp"> {
let constructor = "mlir::spirv::createUpdateVersionCapabilityExtensionPass()";
}
#endif // MLIR_DIALECT_SPIRV_PASSES
#endif // MLIR_DIALECT_SPIRV_TRANSFORMS_PASSES

View File

@ -1,4 +1,4 @@
//===- SPIRVLowering.h - SPIR-V lowering utilities -------------*- C++ -*-===//
//===- SPIRVConversion.h - SPIR-V Conversion Utilities ----------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@ -6,16 +6,16 @@
//
//===----------------------------------------------------------------------===//
//
// Defines utilities to use while targeting SPIR-V dialect.
// Defines utilities to use while converting to the SPIR-V dialect.
//
//===----------------------------------------------------------------------===//
#ifndef MLIR_DIALECT_SPIRV_SPIRVLOWERING_H
#define MLIR_DIALECT_SPIRV_SPIRVLOWERING_H
#ifndef MLIR_DIALECT_SPIRV_SPIRVCONVERSION_H
#define MLIR_DIALECT_SPIRV_SPIRVCONVERSION_H
#include "mlir/Dialect/SPIRV/SPIRVAttributes.h"
#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
#include "mlir/Dialect/SPIRV/TargetAndABI.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVAttributes.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
#include "mlir/Dialect/SPIRV/IR/TargetAndABI.h"
#include "mlir/Transforms/DialectConversion.h"
#include "llvm/ADT/SmallSet.h"
@ -135,4 +135,4 @@ LogicalResult setABIAttrs(spirv::FuncOp funcOp,
} // namespace spirv
} // namespace mlir
#endif // MLIR_DIALECT_SPIRV_SPIRVLOWERING_H
#endif // MLIR_DIALECT_SPIRV_SPIRVCONVERSION_H

View File

@ -1,4 +1,4 @@
//===-- LayoutUtils.h - Decorate composite type with layout information ---===//
//===-- LayoutUtils.h - Vulkan Layout Util functions ------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@ -10,8 +10,9 @@
// types in SPIR-V dialect.
//
//===----------------------------------------------------------------------===//
#ifndef MLIR_DIALECT_SPIRV_LAYOUTUTILS_H_
#define MLIR_DIALECT_SPIRV_LAYOUTUTILS_H_
#ifndef MLIR_DIALECT_SPIRV_UTILS_LAYOUTUTILS_H_
#define MLIR_DIALECT_SPIRV_UTILS_LAYOUTUTILS_H_
#include <cstdint>
@ -76,4 +77,4 @@ private:
} // namespace mlir
#endif // MLIR_DIALECT_SPIRV_LAYOUTUTILS_H_
#endif // MLIR_DIALECT_SPIRV_UTILS_LAYOUTUTILS_H_

View File

@ -34,7 +34,7 @@
#include "mlir/Dialect/Quant/QuantOps.h"
#include "mlir/Dialect/SCF/SCF.h"
#include "mlir/Dialect/SDBM/SDBMDialect.h"
#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
#include "mlir/Dialect/Shape/IR/Shape.h"
#include "mlir/Dialect/StandardOps/IR/Ops.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"

View File

@ -22,7 +22,7 @@
#include "mlir/Dialect/Linalg/Passes.h"
#include "mlir/Dialect/Quant/Passes.h"
#include "mlir/Dialect/SCF/Passes.h"
#include "mlir/Dialect/SPIRV/Passes.h"
#include "mlir/Dialect/SPIRV/Transforms/Passes.h"
#include "mlir/Dialect/Shape/Transforms/Passes.h"
#include "mlir/Dialect/StandardOps/Transforms/Passes.h"
#include "mlir/Dialect/Tensor/Transforms/Passes.h"

View File

@ -13,7 +13,7 @@
#ifndef MLIR_TARGET_SPIRV_BINARY_UTILS_H_
#define MLIR_TARGET_SPIRV_BINARY_UTILS_H_
#include "mlir/Dialect/SPIRV/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
#include "mlir/Support/LogicalResult.h"
#include <cstdint>

View File

@ -16,6 +16,7 @@ add_mlir_conversion_library(MLIRGPUToSPIRVTransforms
MLIRPass
MLIRSCFToSPIRV
MLIRSPIRV
MLIRSPIRVConversion
MLIRStandard
MLIRStandardToSPIRVTransforms
MLIRSupport

View File

@ -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;

View File

@ -18,9 +18,9 @@
#include "mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.h"
#include "mlir/Dialect/GPU/GPUDialect.h"
#include "mlir/Dialect/SCF/SCF.h"
#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/SPIRVLowering.h"
#include "mlir/Dialect/SPIRV/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"
using namespace mlir;

View File

@ -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

View File

@ -16,8 +16,8 @@
#include "../PassDetail.h"
#include "mlir/Conversion/GPUToVulkan/ConvertGPUToVulkanPass.h"
#include "mlir/Dialect/GPU/GPUDialect.h"
#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
#include "mlir/Dialect/StandardOps/IR/Ops.h"
#include "mlir/IR/Attributes.h"
#include "mlir/IR/Builders.h"

View File

@ -15,5 +15,6 @@ add_mlir_conversion_library(MLIRLinalgToSPIRVTransforms
MLIRLinalgUtils
MLIRPass
MLIRSPIRV
MLIRSPIRVConversion
MLIRSupport
)

View File

@ -9,9 +9,9 @@
#include "mlir/Conversion/LinalgToSPIRV/LinalgToSPIRV.h"
#include "mlir/Dialect/Linalg/IR/LinalgOps.h"
#include "mlir/Dialect/Linalg/Utils/Utils.h"
#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/SPIRVLowering.h"
#include "mlir/Dialect/SPIRV/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"
#include "mlir/Dialect/StandardOps/IR/Ops.h"
#include "mlir/Dialect/Utils/StructuredOpsUtils.h"
#include "mlir/IR/AffineExpr.h"

View File

@ -9,8 +9,8 @@
#include "mlir/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.h"
#include "../PassDetail.h"
#include "mlir/Conversion/LinalgToSPIRV/LinalgToSPIRV.h"
#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/SPIRVLowering.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"
using namespace mlir;

View File

@ -11,6 +11,7 @@ add_mlir_conversion_library(MLIRSCFToSPIRV
MLIRAffine
MLIRAffineToStandard
MLIRSPIRV
MLIRSPIRVConversion
MLIRIR
MLIRLinalg
MLIRPass

View File

@ -11,9 +11,9 @@
//===----------------------------------------------------------------------===//
#include "mlir/Conversion/SCFToSPIRV/SCFToSPIRV.h"
#include "mlir/Dialect/SCF/SCF.h"
#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/SPIRVLowering.h"
#include "mlir/Dialect/SPIRV/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"
#include "mlir/IR/BuiltinOps.h"
using namespace mlir;

View File

@ -13,6 +13,7 @@ add_mlir_conversion_library(MLIRSPIRVToLLVM
LINK_LIBS PUBLIC
MLIRGPU
MLIRSPIRV
MLIRSPIRVUtils
MLIRLLVMIR
MLIRStandardToLLVM
MLIRIR

View File

@ -17,7 +17,7 @@
#include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h"
#include "mlir/Dialect/GPU/GPUDialect.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/Dialect/SPIRV/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
#include "mlir/Dialect/StandardOps/IR/Ops.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/SymbolTable.h"

View File

@ -14,9 +14,9 @@
#include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h"
#include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/Dialect/SPIRV/LayoutUtils.h"
#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/Utils/LayoutUtils.h"
#include "mlir/Dialect/StandardOps/IR/Ops.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/PatternMatch.h"

View File

@ -16,7 +16,7 @@
#include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h"
#include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
using namespace mlir;

View File

@ -14,8 +14,8 @@ add_mlir_conversion_library(MLIRStandardToSPIRVTransforms
MLIRIR
MLIRPass
MLIRSPIRV
MLIRSPIRVConversion
MLIRSupport
MLIRTransformUtils
MLIRSPIRV
MLIRStandard
)

View File

@ -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"

View File

@ -14,8 +14,8 @@
#include "mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.h"
#include "../PassDetail.h"
#include "mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.h"
#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/SPIRVLowering.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"
using namespace mlir;

View File

@ -14,7 +14,7 @@
#include "../PassDetail.h"
#include "mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.h"
#include "mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.h"
#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
#include "mlir/Dialect/StandardOps/IR/Ops.h"
#include "mlir/Dialect/Vector/VectorOps.h"
#include "mlir/IR/BuiltinTypes.h"

View File

@ -10,6 +10,7 @@ add_mlir_conversion_library(MLIRVectorToSPIRV
LINK_LIBS PUBLIC
MLIRSPIRV
MLIRSPIRVConversion
MLIRVector
MLIRTransforms
)

View File

@ -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"

View File

@ -1,38 +1,4 @@
set(LLVM_TARGET_DEFINITIONS SPIRVCanonicalization.td)
mlir_tablegen(SPIRVCanonicalization.inc -gen-rewriters)
add_public_tablegen_target(MLIRSPIRVCanonicalizationIncGen)
add_mlir_dialect_library(MLIRSPIRV
LayoutUtils.cpp
SPIRVAttributes.cpp
SPIRVCanonicalization.cpp
SPIRVDialect.cpp
SPIRVOps.cpp
SPIRVLowering.cpp
SPIRVTypes.cpp
TargetAndABI.cpp
ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/SPIRV
DEPENDS
MLIRSPIRVAvailabilityIncGen
MLIRSPIRVCanonicalizationIncGen
MLIRSPIRVEnumAvailabilityIncGen
MLIRSPIRVEnumsIncGen
MLIRSPIRVOpsIncGen
MLIRSPIRVOpUtilsGen
MLIRSPIRVTargetAndABIIncGen
LINK_LIBS PUBLIC
MLIRControlFlowInterfaces
MLIRIR
MLIRParser
MLIRSideEffectInterfaces
MLIRSupport
MLIRTransforms
)
add_subdirectory(IR)
add_subdirectory(Linking)
add_subdirectory(Transforms)
add_subdirectory(Utils)

View File

@ -0,0 +1,33 @@
set(LLVM_TARGET_DEFINITIONS SPIRVCanonicalization.td)
mlir_tablegen(SPIRVCanonicalization.inc -gen-rewriters)
add_public_tablegen_target(MLIRSPIRVCanonicalizationIncGen)
add_mlir_dialect_library(MLIRSPIRV
SPIRVAttributes.cpp
SPIRVCanonicalization.cpp
SPIRVDialect.cpp
SPIRVEnums.cpp
SPIRVOps.cpp
SPIRVTypes.cpp
TargetAndABI.cpp
ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/SPIRV
DEPENDS
MLIRSPIRVAttrUtilsGen
MLIRSPIRVAvailabilityIncGen
MLIRSPIRVCanonicalizationIncGen
MLIRSPIRVEnumAvailabilityIncGen
MLIRSPIRVEnumsIncGen
MLIRSPIRVOpsIncGen
MLIRSPIRVTargetAndABIIncGen
LINK_LIBS PUBLIC
MLIRControlFlowInterfaces
MLIRIR
MLIRParser
MLIRSideEffectInterfaces
MLIRSupport
MLIRTransforms
)

View File

@ -6,17 +6,27 @@
//
//===----------------------------------------------------------------------===//
#include "mlir/Dialect/SPIRV/SPIRVAttributes.h"
#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVAttributes.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
#include "mlir/IR/Builders.h"
using namespace mlir;
//===----------------------------------------------------------------------===//
// TableGen'erated attribute utility functions
//===----------------------------------------------------------------------===//
namespace mlir {
namespace spirv {
#include "mlir/Dialect/SPIRV/IR/SPIRVAttrUtils.inc"
} // namespace spirv
} // namespace mlir
//===----------------------------------------------------------------------===//
// DictionaryDict derived attributes
//===----------------------------------------------------------------------===//
#include "mlir/Dialect/SPIRV/TargetAndABI.cpp.inc"
#include "mlir/Dialect/SPIRV/IR/TargetAndABI.cpp.inc"
namespace mlir {

View File

@ -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 @@ private:
return lhs->getAttrDictionary() == rhs->getAttrDictionary();
}
// Returns a source value for the given block.
Value getSrcValue(Block *block) const {
auto storeOp = cast<spirv::StoreOp>(block->front());

View File

@ -10,7 +10,7 @@
//
//===----------------------------------------------------------------------===//
include "mlir/Dialect/SPIRV/SPIRVOps.td"
include "mlir/Dialect/SPIRV/IR/SPIRVOps.td"
//===----------------------------------------------------------------------===//
// spv.Bitcast

View File

@ -10,11 +10,11 @@
//
//===----------------------------------------------------------------------===//
#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/ParserUtils.h"
#include "mlir/Dialect/SPIRV/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
#include "mlir/Dialect/SPIRV/TargetAndABI.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/IR/ParserUtils.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
#include "mlir/Dialect/SPIRV/IR/TargetAndABI.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/DialectImplementation.h"
@ -30,12 +30,6 @@
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/raw_ostream.h"
namespace mlir {
namespace spirv {
#include "mlir/Dialect/SPIRV/SPIRVOpUtils.inc"
} // namespace spirv
} // namespace mlir
using namespace mlir;
using namespace mlir::spirv;
@ -129,7 +123,7 @@ void SPIRVDialect::initialize() {
// Add SPIR-V ops.
addOperations<
#define GET_OP_LIST
#include "mlir/Dialect/SPIRV/SPIRVOps.cpp.inc"
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.cpp.inc"
>();
addInterfaces<SPIRVInlinerInterface>();

View File

@ -0,0 +1,94 @@
//===- SPIRVEnums.cpp - MLIR SPIR-V Enums ---------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file defines the C/C++ enums from SPIR-V spec.
//
//===----------------------------------------------------------------------===//
#include "mlir/Dialect/SPIRV/IR/SPIRVEnums.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
using namespace mlir;
// Pull in all enum utility function definitions
#include "mlir/Dialect/SPIRV/IR/SPIRVEnums.cpp.inc"
// Pull in all enum type availability query function definitions
#include "mlir/Dialect/SPIRV/IR/SPIRVEnumAvailability.cpp.inc"
//===----------------------------------------------------------------------===//
// Availability relationship
//===----------------------------------------------------------------------===//
ArrayRef<spirv::Extension> spirv::getImpliedExtensions(spirv::Version version) {
// Note: the following lists are from "Appendix A: Changes" of the spec.
#define V_1_3_IMPLIED_EXTS \
Extension::SPV_KHR_shader_draw_parameters, Extension::SPV_KHR_16bit_storage, \
Extension::SPV_KHR_device_group, Extension::SPV_KHR_multiview, \
Extension::SPV_KHR_storage_buffer_storage_class, \
Extension::SPV_KHR_variable_pointers
#define V_1_4_IMPLIED_EXTS \
Extension::SPV_KHR_no_integer_wrap_decoration, \
Extension::SPV_GOOGLE_decorate_string, \
Extension::SPV_GOOGLE_hlsl_functionality1, \
Extension::SPV_KHR_float_controls
#define V_1_5_IMPLIED_EXTS \
Extension::SPV_KHR_8bit_storage, Extension::SPV_EXT_descriptor_indexing, \
Extension::SPV_EXT_shader_viewport_index_layer, \
Extension::SPV_EXT_physical_storage_buffer, \
Extension::SPV_KHR_physical_storage_buffer, \
Extension::SPV_KHR_vulkan_memory_model
switch (version) {
default:
return {};
case Version::V_1_3: {
// The following manual ArrayRef constructor call is to satisfy GCC 5.
static const Extension exts[] = {V_1_3_IMPLIED_EXTS};
return ArrayRef<spirv::Extension>(exts, llvm::array_lengthof(exts));
}
case Version::V_1_4: {
static const Extension exts[] = {V_1_3_IMPLIED_EXTS, V_1_4_IMPLIED_EXTS};
return ArrayRef<spirv::Extension>(exts, llvm::array_lengthof(exts));
}
case Version::V_1_5: {
static const Extension exts[] = {V_1_3_IMPLIED_EXTS, V_1_4_IMPLIED_EXTS,
V_1_5_IMPLIED_EXTS};
return ArrayRef<spirv::Extension>(exts, llvm::array_lengthof(exts));
}
}
#undef V_1_5_IMPLIED_EXTS
#undef V_1_4_IMPLIED_EXTS
#undef V_1_3_IMPLIED_EXTS
}
// Pull in utility function definition for implied capabilities
#include "mlir/Dialect/SPIRV/IR/SPIRVCapabilityImplication.inc"
SmallVector<spirv::Capability, 0>
spirv::getRecursiveImpliedCapabilities(spirv::Capability cap) {
ArrayRef<spirv::Capability> directCaps = getDirectImpliedCapabilities(cap);
llvm::SetVector<spirv::Capability, SmallVector<spirv::Capability, 0>> allCaps(
directCaps.begin(), directCaps.end());
// TODO: This is insufficient; find a better way to handle this
// (e.g., using static lists) if this turns out to be a bottleneck.
for (unsigned i = 0; i < allCaps.size(); ++i)
for (Capability c : getDirectImpliedCapabilities(allCaps[i]))
allCaps.insert(c);
return allCaps.takeVector();
}

View File

@ -10,13 +10,13 @@
//
//===----------------------------------------------------------------------===//
#include "mlir/Dialect/SPIRV/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/ParserUtils.h"
#include "mlir/Dialect/SPIRV/SPIRVAttributes.h"
#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
#include "mlir/Dialect/SPIRV/TargetAndABI.h"
#include "mlir/Dialect/SPIRV/IR/ParserUtils.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVAttributes.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
#include "mlir/Dialect/SPIRV/IR/TargetAndABI.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/BuiltinTypes.h"
@ -3471,18 +3471,18 @@ namespace spirv {
// TableGen'erated operation interfaces for querying versions, extensions, and
// capabilities.
#include "mlir/Dialect/SPIRV/SPIRVAvailability.cpp.inc"
#include "mlir/Dialect/SPIRV/IR/SPIRVAvailability.cpp.inc"
} // namespace spirv
} // namespace mlir
// TablenGen'erated operation definitions.
#define GET_OP_CLASSES
#include "mlir/Dialect/SPIRV/SPIRVOps.cpp.inc"
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.cpp.inc"
namespace mlir {
namespace spirv {
// TableGen'erated operation availability interface implementations.
#include "mlir/Dialect/SPIRV/SPIRVOpAvailabilityImpl.inc"
#include "mlir/Dialect/SPIRV/IR/SPIRVOpAvailabilityImpl.inc"
} // namespace spirv
} // namespace mlir

View File

@ -10,93 +10,17 @@
//
//===----------------------------------------------------------------------===//
#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
#include "mlir/IR/Attributes.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Identifier.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/TypeSwitch.h"
using namespace mlir;
using namespace mlir::spirv;
// Pull in all enum utility function definitions
#include "mlir/Dialect/SPIRV/SPIRVEnums.cpp.inc"
// Pull in all enum type availability query function definitions
#include "mlir/Dialect/SPIRV/SPIRVEnumAvailability.cpp.inc"
//===----------------------------------------------------------------------===//
// Availability relationship
//===----------------------------------------------------------------------===//
ArrayRef<Extension> spirv::getImpliedExtensions(Version version) {
// Note: the following lists are from "Appendix A: Changes" of the spec.
#define V_1_3_IMPLIED_EXTS \
Extension::SPV_KHR_shader_draw_parameters, Extension::SPV_KHR_16bit_storage, \
Extension::SPV_KHR_device_group, Extension::SPV_KHR_multiview, \
Extension::SPV_KHR_storage_buffer_storage_class, \
Extension::SPV_KHR_variable_pointers
#define V_1_4_IMPLIED_EXTS \
Extension::SPV_KHR_no_integer_wrap_decoration, \
Extension::SPV_GOOGLE_decorate_string, \
Extension::SPV_GOOGLE_hlsl_functionality1, \
Extension::SPV_KHR_float_controls
#define V_1_5_IMPLIED_EXTS \
Extension::SPV_KHR_8bit_storage, Extension::SPV_EXT_descriptor_indexing, \
Extension::SPV_EXT_shader_viewport_index_layer, \
Extension::SPV_EXT_physical_storage_buffer, \
Extension::SPV_KHR_physical_storage_buffer, \
Extension::SPV_KHR_vulkan_memory_model
switch (version) {
default:
return {};
case Version::V_1_3: {
// The following manual ArrayRef constructor call is to satisfy GCC 5.
static const Extension exts[] = {V_1_3_IMPLIED_EXTS};
return ArrayRef<Extension>(exts, llvm::array_lengthof(exts));
}
case Version::V_1_4: {
static const Extension exts[] = {V_1_3_IMPLIED_EXTS, V_1_4_IMPLIED_EXTS};
return ArrayRef<Extension>(exts, llvm::array_lengthof(exts));
}
case Version::V_1_5: {
static const Extension exts[] = {V_1_3_IMPLIED_EXTS, V_1_4_IMPLIED_EXTS,
V_1_5_IMPLIED_EXTS};
return ArrayRef<Extension>(exts, llvm::array_lengthof(exts));
}
}
#undef V_1_5_IMPLIED_EXTS
#undef V_1_4_IMPLIED_EXTS
#undef V_1_3_IMPLIED_EXTS
}
// Pull in utility function definition for implied capabilities
#include "mlir/Dialect/SPIRV/SPIRVCapabilityImplication.inc"
SmallVector<Capability, 0>
spirv::getRecursiveImpliedCapabilities(Capability cap) {
ArrayRef<Capability> directCaps = getDirectImpliedCapabilities(cap);
llvm::SetVector<Capability, SmallVector<Capability, 0>> allCaps(
directCaps.begin(), directCaps.end());
// TODO: This is insufficient; find a better way to handle this
// (e.g., using static lists) if this turns out to be a bottleneck.
for (unsigned i = 0; i < allCaps.size(); ++i)
for (Capability c : getDirectImpliedCapabilities(allCaps[i]))
allCaps.insert(c);
return allCaps.takeVector();
}
//===----------------------------------------------------------------------===//
// ArrayType
//===----------------------------------------------------------------------===//
@ -336,33 +260,42 @@ void CooperativeMatrixNVType::getCapabilities(
// ImageType
//===----------------------------------------------------------------------===//
template <typename T> static constexpr unsigned getNumBits() { return 0; }
template <> constexpr unsigned getNumBits<Dim>() {
template <typename T>
static constexpr unsigned getNumBits() {
return 0;
}
template <>
constexpr unsigned getNumBits<Dim>() {
static_assert((1 << 3) > getMaxEnumValForDim(),
"Not enough bits to encode Dim value");
return 3;
}
template <> constexpr unsigned getNumBits<ImageDepthInfo>() {
template <>
constexpr unsigned getNumBits<ImageDepthInfo>() {
static_assert((1 << 2) > getMaxEnumValForImageDepthInfo(),
"Not enough bits to encode ImageDepthInfo value");
return 2;
}
template <> constexpr unsigned getNumBits<ImageArrayedInfo>() {
template <>
constexpr unsigned getNumBits<ImageArrayedInfo>() {
static_assert((1 << 1) > getMaxEnumValForImageArrayedInfo(),
"Not enough bits to encode ImageArrayedInfo value");
return 1;
}
template <> constexpr unsigned getNumBits<ImageSamplingInfo>() {
template <>
constexpr unsigned getNumBits<ImageSamplingInfo>() {
static_assert((1 << 1) > getMaxEnumValForImageSamplingInfo(),
"Not enough bits to encode ImageSamplingInfo value");
return 1;
}
template <> constexpr unsigned getNumBits<ImageSamplerUseInfo>() {
template <>
constexpr unsigned getNumBits<ImageSamplerUseInfo>() {
static_assert((1 << 2) > getMaxEnumValForImageSamplerUseInfo(),
"Not enough bits to encode ImageSamplerUseInfo value");
return 2;
}
template <> constexpr unsigned getNumBits<ImageFormat>() {
template <>
constexpr unsigned getNumBits<ImageFormat>() {
static_assert((1 << 6) > getMaxEnumValForImageFormat(),
"Not enough bits to encode ImageFormat value");
return 6;

View File

@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
#include "mlir/Dialect/SPIRV/TargetAndABI.h"
#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
#include "mlir/Dialect/SPIRV/IR/TargetAndABI.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/FunctionSupport.h"
#include "mlir/IR/Operation.h"

View File

@ -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"

View File

@ -1,5 +1,24 @@
set(LLVM_OPTIONAL_SOURCES
DecorateCompositeTypeLayoutPass.cpp
LowerABIAttributesPass.cpp
RewriteInsertsPass.cpp
SPIRVConversion.cpp
UpdateVCEPass.cpp
)
add_mlir_dialect_library(MLIRSPIRVConversion
SPIRVConversion.cpp
ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/SPIRV
LINK_LIBS PUBLIC
MLIRSPIRV
MLIRTransformUtils
)
add_mlir_dialect_library(MLIRSPIRVTransforms
DecorateSPIRVCompositeTypeLayoutPass.cpp
DecorateCompositeTypeLayoutPass.cpp
LowerABIAttributesPass.cpp
RewriteInsertsPass.cpp
UpdateVCEPass.cpp
@ -12,5 +31,6 @@ add_mlir_dialect_library(MLIRSPIRVTransforms
LINK_LIBS PUBLIC
MLIRPass
MLIRSPIRV
MLIRSPIRVConversion
MLIRSPIRVUtils
)

View File

@ -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;

View File

@ -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"

View File

@ -18,7 +18,7 @@ class ModuleOp;
} // end namespace spirv
#define GEN_PASS_CLASSES
#include "mlir/Dialect/SPIRV/Passes.h.inc"
#include "mlir/Dialect/SPIRV/Transforms/Passes.h.inc"
} // end namespace mlir

View File

@ -13,8 +13,8 @@
//===----------------------------------------------------------------------===//
#include "PassDetail.h"
#include "mlir/Dialect/SPIRV/Passes.h"
#include "mlir/Dialect/SPIRV/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/Transforms/Passes.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"

View File

@ -1,4 +1,4 @@
//===- SPIRVLowering.cpp - SPIR-V lowering utilities ----------------------===//
//===- SPIRVConversion.cpp - SPIR-V Conversion Utilities ------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@ -10,17 +10,16 @@
//
//===----------------------------------------------------------------------===//
#include "mlir/Dialect/SPIRV/SPIRVLowering.h"
#include "mlir/Dialect/SPIRV/LayoutUtils.h"
#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
#include "llvm/ADT/Sequence.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Debug.h"
#include <functional>
#define DEBUG_TYPE "mlir-spirv-lowering"
#define DEBUG_TYPE "mlir-spirv-conversion"
using namespace mlir;

View File

@ -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"

View File

@ -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
)

View File

@ -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;

View File

@ -12,10 +12,10 @@
#include "mlir/Target/SPIRV/Deserialization.h"
#include "mlir/Dialect/SPIRV/SPIRVAttributes.h"
#include "mlir/Dialect/SPIRV/SPIRVModule.h"
#include "mlir/Dialect/SPIRV/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVAttributes.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVModule.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
#include "mlir/IR/BlockAndValueMapping.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/Location.h"
@ -2778,7 +2778,7 @@ Deserializer::processOp<spirv::CopyMemoryOp>(ArrayRef<uint32_t> words) {
// Pull in auto-generated Deserializer::dispatchToAutogenDeserialization() and
// various Deserializer::processOp<...>() specializations.
#define GET_DESERIALIZATION_FNS
#include "mlir/Dialect/SPIRV/SPIRVSerialization.inc"
#include "mlir/Dialect/SPIRV/IR/SPIRVSerialization.inc"
} // namespace
namespace mlir {

View File

@ -11,7 +11,7 @@
//===----------------------------------------------------------------------===//
#include "mlir/Target/SPIRV/SPIRVBinaryUtils.h"
#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
using namespace mlir;

View File

@ -12,10 +12,10 @@
#include "mlir/Target/SPIRV/Serialization.h"
#include "mlir/Dialect/SPIRV/SPIRVAttributes.h"
#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVAttributes.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/RegionGraphTraits.h"
#include "mlir/Support/LogicalResult.h"
@ -2107,7 +2107,7 @@ Serializer::processOp<spirv::CopyMemoryOp>(spirv::CopyMemoryOp op) {
// Pull in auto-generated Serializer::dispatchToAutogenSerialization() and
// various Serializer::processOp<...>() specializations.
#define GET_SERIALIZATION_FNS
#include "mlir/Dialect/SPIRV/SPIRVSerialization.inc"
#include "mlir/Dialect/SPIRV/IR/SPIRVSerialization.inc"
} // namespace
LogicalResult Serializer::emitDecoration(uint32_t target,

View File

@ -11,9 +11,9 @@
//
//===----------------------------------------------------------------------===//
#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/SPIRVModule.h"
#include "mlir/Dialect/SPIRV/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVModule.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/Dialect.h"

Some files were not shown because too many files have changed in this diff Show More