MLIR  20.0.0git
Namespaces | Macros | Functions
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.

Namespaces

 mlir
 Include the generated interface declarations.
 

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. More...
 
#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. More...
 
static bool isLegalAttr (Attribute attr)
 Returns true if the given attr is considered as legal for SPIR-V conversion. More...
 
static bool isLegalOp (Operation *op)
 Returns true if the given op is considered as legal for SPIR-V conversion. More...
 

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 109 of file MapMemRefStorageClassPass.cpp.

◆ STORAGE_SPACE_MAP_FN [1/4]

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

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

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.

Function Documentation

◆ isLegalAttr()

static bool isLegalAttr ( Attribute  attr)
static

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

Definition at line 217 of file MapMemRefStorageClassPass.cpp.

References isLegalType().

Referenced by isLegalOp().

◆ isLegalOp()

static bool isLegalOp ( Operation op)
static

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

Definition at line 224 of file MapMemRefStorageClassPass.cpp.

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

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

◆ isLegalType()

static bool isLegalType ( Type  type)
static

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

Definition at line 207 of file MapMemRefStorageClassPass.cpp.

Referenced by isLegalAttr(), and isLegalOp().