Changeset View
Changeset View
Standalone View
Standalone View
mlir/include/mlir/Dialect/SPIRV/SPIRVAttributes.h
- This file was copied from mlir/include/mlir/Dialect/SPIRV/TargetAndABI.h.
//===- TargetAndABI.h - SPIR-V target and ABI utilities --------*- C++ -*-===// | //===- SPIRVAttributes.h - SPIR-V attribute declarations -------*- C++ -*-===// | ||||
// | // | ||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||||
// See https://llvm.org/LICENSE.txt for license information. | // See https://llvm.org/LICENSE.txt for license information. | ||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||||
// | // | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
// | // | ||||
// This file declares utilities for SPIR-V target and shader interface ABI. | // This file declares SPIR-V dialect specific attributes. | ||||
// | // | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
#ifndef MLIR_DIALECT_SPIRV_TARGETANDABI_H | #ifndef MLIR_DIALECT_SPIRV_SPIRVATTRIBUTES_H | ||||
#define MLIR_DIALECT_SPIRV_TARGETANDABI_H | #define MLIR_DIALECT_SPIRV_SPIRVATTRIBUTES_H | ||||
#include "mlir/IR/Attributes.h" | #include "mlir/IR/Attributes.h" | ||||
#include "mlir/Support/LLVM.h" | #include "mlir/Support/LLVM.h" | ||||
namespace mlir { | namespace mlir { | ||||
class OpBuilder; | // Pull in SPIR-V attribute definitions for target and ABI. | ||||
class Operation; | |||||
class Value; | |||||
// Pull in SPIR-V attribute definitions. | |||||
#include "mlir/Dialect/SPIRV/TargetAndABI.h.inc" | #include "mlir/Dialect/SPIRV/TargetAndABI.h.inc" | ||||
namespace spirv { | namespace spirv { | ||||
enum class Capability : uint32_t; | enum class Capability : uint32_t; | ||||
enum class Extension; | enum class Extension; | ||||
enum class StorageClass : uint32_t; | |||||
enum class Version : uint32_t; | enum class Version : uint32_t; | ||||
namespace detail { | namespace detail { | ||||
struct TargetEnvAttributeStorage; | struct TargetEnvAttributeStorage; | ||||
struct VerCapExtAttributeStorage; | struct VerCapExtAttributeStorage; | ||||
} // namespace detail | } // namespace detail | ||||
/// SPIR-V dialect-specific attribute kinds. | /// SPIR-V dialect-specific attribute kinds. | ||||
// TODO(antiagainst): move to a more suitable place if we have more attributes. | |||||
namespace AttrKind { | namespace AttrKind { | ||||
enum Kind { | enum Kind { | ||||
TargetEnv = Attribute::FIRST_SPIRV_ATTR, /// Target environment | TargetEnv = Attribute::FIRST_SPIRV_ATTR, /// Target environment | ||||
VerCapExt, /// (version, extension, capability) triple | VerCapExt, /// (version, extension, capability) triple | ||||
}; | }; | ||||
} // namespace AttrKind | } // namespace AttrKind | ||||
/// An attribute that specifies the SPIR-V (version, capabilities, extensions) | /// An attribute that specifies the SPIR-V (version, capabilities, extensions) | ||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | public: | ||||
ResourceLimitsAttr getResourceLimits(); | ResourceLimitsAttr getResourceLimits(); | ||||
static bool kindof(unsigned kind) { return kind == AttrKind::TargetEnv; } | static bool kindof(unsigned kind) { return kind == AttrKind::TargetEnv; } | ||||
static LogicalResult verifyConstructionInvariants(Location loc, | static LogicalResult verifyConstructionInvariants(Location loc, | ||||
VerCapExtAttr triple, | VerCapExtAttr triple, | ||||
DictionaryAttr limits); | DictionaryAttr limits); | ||||
}; | }; | ||||
/// Returns the attribute name for specifying argument ABI information. | |||||
StringRef getInterfaceVarABIAttrName(); | |||||
/// Gets the InterfaceVarABIAttr given its fields. | |||||
InterfaceVarABIAttr getInterfaceVarABIAttr(unsigned descriptorSet, | |||||
unsigned binding, | |||||
StorageClass storageClass, | |||||
MLIRContext *context); | |||||
/// Returns the attribute name for specifying entry point information. | |||||
StringRef getEntryPointABIAttrName(); | |||||
/// Gets the EntryPointABIAttr given its fields. | |||||
EntryPointABIAttr getEntryPointABIAttr(ArrayRef<int32_t> localSize, | |||||
MLIRContext *context); | |||||
/// Queries the entry point ABI on the nearest function-like op containing the | |||||
/// given `op`. Returns null attribute if not found. | |||||
EntryPointABIAttr lookupEntryPointABI(Operation *op); | |||||
/// Queries the local workgroup size from entry point ABI on the nearest | |||||
/// function-like op containing the given `op`. Returns null attribute if not | |||||
/// found. | |||||
DenseIntElementsAttr lookupLocalWorkGroupSize(Operation *op); | |||||
/// Returns a default resource limits attribute that uses numbers from | |||||
/// "Table 46. Required Limits" of the Vulkan spec. | |||||
ResourceLimitsAttr getDefaultResourceLimits(MLIRContext *context); | |||||
/// Returns the attribute name for specifying SPIR-V target environment. | |||||
StringRef getTargetEnvAttrName(); | |||||
/// Returns the default target environment: SPIR-V 1.0 with Shader capability | |||||
/// and no extra extensions. | |||||
TargetEnvAttr getDefaultTargetEnv(MLIRContext *context); | |||||
/// Queries the target environment recursively from enclosing symbol table ops | |||||
/// containing the given `op`. | |||||
TargetEnvAttr lookupTargetEnv(Operation *op); | |||||
/// Queries the target environment recursively from enclosing symbol table ops | |||||
/// containing the given `op` or returns the default target environment as | |||||
/// returned by getDefaultTargetEnv() if not provided. | |||||
TargetEnvAttr lookupTargetEnvOrDefault(Operation *op); | |||||
} // namespace spirv | } // namespace spirv | ||||
} // namespace mlir | } // namespace mlir | ||||
#endif // MLIR_DIALECT_SPIRV_TARGETANDABI_H | #endif // MLIR_DIALECT_SPIRV_SPIRVATTRIBUTES_H |