MLIR 22.0.0git
MapMemRefStorageClassPass.cpp File Reference
#include "mlir/Conversion/MemRefToSPIRV/MemRefToSPIRVPass.h"
#include "mlir/Conversion/MemRefToSPIRV/MemRefToSPIRV.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVAttributes.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVEnums.h"
#include "mlir/Dialect/SPIRV/IR/TargetAndABI.h"
#include "mlir/IR/Attributes.h"
#include "mlir/IR/BuiltinAttributes.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Operation.h"
#include "mlir/IR/Visitors.h"
#include "mlir/Interfaces/FunctionInterfaces.h"
#include "llvm/ADT/SmallVectorExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Debug.h"
#include <optional>
#include "mlir/Conversion/Passes.h.inc"

Go to the source code of this file.

Classes

class  mlir::impl::MapMemRefStorageClassBase< DerivedT >

Namespaces

namespace  mlir
 Include the generated interface declarations.
namespace  mlir::impl
 Attribute collections provide a dictionary-like interface.

Macros

#define GEN_PASS_DEF_MAPMEMREFSTORAGECLASS
#define DEBUG_TYPE   "mlir-map-memref-storage-class"
#define VULKAN_STORAGE_SPACE_MAP_LIST(MAP_FN)
 Mapping between SPIR-V storage classes to memref memory spaces.
#define STORAGE_SPACE_MAP_FN(storage, space)
#define STORAGE_SPACE_MAP_FN(storage, space)
#define OPENCL_STORAGE_SPACE_MAP_LIST(MAP_FN)
#define STORAGE_SPACE_MAP_FN(storage, space)
#define STORAGE_SPACE_MAP_FN(storage, space)

Functions

static bool isLegalType (Type type)
 Returns true if the given type is considered as legal for SPIR-V conversion.
static bool isLegalAttr (Attribute attr)
 Returns true if the given attr is considered as legal for SPIR-V conversion.
static bool isLegalOp (Operation *op)
 Returns true if the given op is considered as legal for SPIR-V conversion.

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "mlir-map-memref-storage-class"

Definition at line 37 of file MapMemRefStorageClassPass.cpp.

◆ GEN_PASS_DEF_MAPMEMREFSTORAGECLASS

#define GEN_PASS_DEF_MAPMEMREFSTORAGECLASS

Definition at line 33 of file MapMemRefStorageClassPass.cpp.

◆ OPENCL_STORAGE_SPACE_MAP_LIST

#define OPENCL_STORAGE_SPACE_MAP_LIST ( MAP_FN)
Value:
MAP_FN(spirv::StorageClass::CrossWorkgroup, 0) \
MAP_FN(spirv::StorageClass::Generic, 1) \
MAP_FN(spirv::StorageClass::Workgroup, 3) \
MAP_FN(spirv::StorageClass::UniformConstant, 4) \
MAP_FN(spirv::StorageClass::Private, 5) \
MAP_FN(spirv::StorageClass::Function, 6) \
MAP_FN(spirv::StorageClass::Image, 7)

Definition at line 110 of file MapMemRefStorageClassPass.cpp.

Referenced by mlir::spirv::mapMemorySpaceToOpenCLStorageClass(), and mlir::spirv::mapOpenCLStorageClassToMemorySpace().

◆ STORAGE_SPACE_MAP_FN [1/4]

◆ STORAGE_SPACE_MAP_FN [2/4]

#define STORAGE_SPACE_MAP_FN ( storage,
space )
Value:
case storage: \
return space;

◆ STORAGE_SPACE_MAP_FN [3/4]

#define STORAGE_SPACE_MAP_FN ( storage,
space )
Value:
case space: \
return storage;

◆ STORAGE_SPACE_MAP_FN [4/4]

#define STORAGE_SPACE_MAP_FN ( storage,
space )
Value:
case storage: \
return space;

◆ VULKAN_STORAGE_SPACE_MAP_LIST

#define VULKAN_STORAGE_SPACE_MAP_LIST ( MAP_FN)
Value:
MAP_FN(spirv::StorageClass::StorageBuffer, 0) \
MAP_FN(spirv::StorageClass::Generic, 1) \
MAP_FN(spirv::StorageClass::Workgroup, 3) \
MAP_FN(spirv::StorageClass::Uniform, 4) \
MAP_FN(spirv::StorageClass::Private, 5) \
MAP_FN(spirv::StorageClass::Function, 6) \
MAP_FN(spirv::StorageClass::PushConstant, 7) \
MAP_FN(spirv::StorageClass::UniformConstant, 8) \
MAP_FN(spirv::StorageClass::Input, 9) \
MAP_FN(spirv::StorageClass::Output, 10) \
MAP_FN(spirv::StorageClass::PhysicalStorageBuffer, 11) \
MAP_FN(spirv::StorageClass::Image, 12)

Mapping between SPIR-V storage classes to memref memory spaces.

Note: memref does not have a defined semantics for each memory space; it depends on the context where it is used. There are no particular reasons behind the number assignments; we try to follow NVVM conventions and largely give common storage classes a smaller number.

Definition at line 51 of file MapMemRefStorageClassPass.cpp.

Referenced by mlir::spirv::mapMemorySpaceToVulkanStorageClass(), and mlir::spirv::mapVulkanStorageClassToMemorySpace().

Function Documentation

◆ isLegalAttr()

bool isLegalAttr ( Attribute attr)
static

Returns true if the given attr is considered as legal for SPIR-V conversion.

Definition at line 218 of file MapMemRefStorageClassPass.cpp.

References isLegalType().

Referenced by isLegalOp().

◆ isLegalOp()

bool isLegalOp ( Operation * op)
static

Returns true if the given op is considered as legal for SPIR-V conversion.

Definition at line 225 of file MapMemRefStorageClassPass.cpp.

References mlir::Operation::getAttrs(), mlir::Operation::getOperandTypes(), mlir::Operation::getResultTypes(), isLegalAttr(), and isLegalType().

Referenced by mlir::spirv::getMemorySpaceToStorageClassTarget().

◆ isLegalType()

bool isLegalType ( Type type)
static

Returns true if the given type is considered as legal for SPIR-V conversion.

Definition at line 208 of file MapMemRefStorageClassPass.cpp.

Referenced by isLegalAttr(), and isLegalOp().