[mlir][spirv] Add a pass to map memref memory space
MemRef types now can carry an attribute to represent the memory space. Still, upper layers in the compilation stack mostly use nuemric values. They don't mean much (other than differentiating separate memory domains) in MLIR's multi-level settings. Those numeric memory space inside MemRef types need to be translated into concrete SPIR-V storage classes during lowering to pin down to concrete memory types. Thus far we have been hardcoding an arbitrary mapping from memory space to storage class for converting MemRef types. This works fine for only targeting Vulkan; it falls apart if we want to target other SPIR-V consumers like OpenCL, as different consumers might want different storage classes for the buffer/variable of the same lifetime. For example, StorageClass in Vulkan vs. CrossWorkgroup in OpenCL. So putting up a new pass to let the user to control how to map MemRef memory spaces into SPIR-V storage classes. This provides more flexibility and can address the awkwardness in the current SPIR-V type converter. This pass should be the prelimiary step towards lowering MemRef related types/ops into SPIR-V. Reviewed By: mravishankar Differential Revision: https://reviews.llvm.org/D130317
Loading
Please sign in to comment