This is a frequently requested feature. I’d like to extend memref to support arbitrary element types, and we now have sufficient infrastructure support to do so.
The extension can be implemented as follows. In addition to the types that are currently supported, memref can support element types that implement the newly added
MemRefElementTypeInterface, which provides functionality necessary for memref to reason about the type. Given the current use, this functionality provides the size and alignment requirements of the element type. The default implementation of the interface queries the
DataLayout interfaces to obtain size and alignment information. An interface separate from
DataLayoutTypeInterface allows types to explicitly opt into being supported as memref element types and enables independent evolution of the two interfaces.