MLIR 22.0.0git
MemRefToSPIRV.h
Go to the documentation of this file.
1//===- MemRefToSPIRV.h - MemRef to SPIR-V Patterns --------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Provides patterns to convert MemRef dialect to SPIR-V dialect.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef MLIR_CONVERSION_MEMREFTOSPIRV_MEMREFTOSPIRV_H
14#define MLIR_CONVERSION_MEMREFTOSPIRV_MEMREFTOSPIRV_H
15
18#include <memory>
19
20namespace mlir {
22
23namespace spirv {
24/// Mapping from numeric MemRef memory spaces into SPIR-V symbolic ones.
26 std::function<std::optional<spirv::StorageClass>(Attribute)>;
27
28/// Maps MemRef memory spaces to storage classes for Vulkan-flavored SPIR-V
29/// using the default rule. Returns std::nullopt if the memory space is unknown.
30std::optional<spirv::StorageClass>
32/// Maps storage classes for Vulkan-flavored SPIR-V to MemRef memory spaces
33/// using the default rule. Returns std::nullopt if the storage class is
34/// unsupported.
35std::optional<unsigned> mapVulkanStorageClassToMemorySpace(spirv::StorageClass);
36
37/// Maps MemRef memory spaces to storage classes for OpenCL-flavored SPIR-V
38/// using the default rule. Returns std::nullopt if the memory space is unknown.
39std::optional<spirv::StorageClass>
41/// Maps storage classes for OpenCL-flavored SPIR-V to MemRef memory spaces
42/// using the default rule. Returns std::nullopt if the storage class is
43/// unsupported.
44std::optional<unsigned> mapOpenCLStorageClassToMemorySpace(spirv::StorageClass);
45
46/// Type converter for converting numeric MemRef memory spaces into SPIR-V
47/// symbolic ones.
49public:
51 const MemorySpaceToStorageClassMap &memorySpaceMap);
52
53private:
54 MemorySpaceToStorageClassMap memorySpaceMap;
55};
56
57/// Creates the target that populates legality of ops with MemRef types.
58std::unique_ptr<ConversionTarget>
60
61/// Converts all MemRef types and attributes in the op, as decided by the
62/// `typeConverter`.
65
66} // namespace spirv
67
68/// Appends to a pattern list additional patterns for translating MemRef ops
69/// to SPIR-V ops.
72
73} // namespace mlir
74
75#endif // MLIR_CONVERSION_MEMREFTOSPIRV_MEMREFTOSPIRV_H
Attributes are known-constant values of operations.
Definition Attributes.h:25
MLIRContext is the top-level object for a collection of MLIR operations.
Definition MLIRContext.h:63
Operation is the basic unit of execution within MLIR.
Definition Operation.h:88
Type conversion from builtin types to SPIR-V types for shader interface.
Type converter for converting numeric MemRef memory spaces into SPIR-V symbolic ones.
MemorySpaceToStorageClassConverter(const MemorySpaceToStorageClassMap &memorySpaceMap)
std::unique_ptr< ConversionTarget > getMemorySpaceToStorageClassTarget(MLIRContext &)
Creates the target that populates legality of ops with MemRef types.
void convertMemRefTypesAndAttrs(Operation *op, MemorySpaceToStorageClassConverter &typeConverter)
Converts all MemRef types and attributes in the op, as decided by the typeConverter.
std::optional< spirv::StorageClass > mapMemorySpaceToOpenCLStorageClass(Attribute)
Maps MemRef memory spaces to storage classes for OpenCL-flavored SPIR-V using the default rule.
std::optional< unsigned > mapVulkanStorageClassToMemorySpace(spirv::StorageClass)
Maps storage classes for Vulkan-flavored SPIR-V to MemRef memory spaces using the default rule.
std::function< std::optional< spirv::StorageClass >(Attribute)> MemorySpaceToStorageClassMap
Mapping from numeric MemRef memory spaces into SPIR-V symbolic ones.
std::optional< unsigned > mapOpenCLStorageClassToMemorySpace(spirv::StorageClass)
Maps storage classes for OpenCL-flavored SPIR-V to MemRef memory spaces using the default rule.
std::optional< spirv::StorageClass > mapMemorySpaceToVulkanStorageClass(Attribute)
Maps MemRef memory spaces to storage classes for Vulkan-flavored SPIR-V using the default rule.
Include the generated interface declarations.
const FrozenRewritePatternSet & patterns
void populateMemRefToSPIRVPatterns(const SPIRVTypeConverter &typeConverter, RewritePatternSet &patterns)
Appends to a pattern list additional patterns for translating MemRef ops to SPIR-V ops.