In this patch, we try to support load/store/alloca for scalable structures. We have posted a RFC for the proposal in the mailing list. https://groups.google.com/g/llvm-dev/c/6ZK2eS4-8t0/m/PG6H1NNDBAAJ
In RISC-V vector intrinsics, we have defined types containing multiple scalable vectors. Due to the flexible configuration of vector types with LMUL, the struct is a good fit to represent these types containing multiple scalable vectors. We permit users to define auto variables using these types. That is why we need to support load, store, and alloca for the scalable structure.
To support load, store and alloca for the scalable structure, we have to achieve the following two points.
- In StructLayout, we use uint64_t for the StructSize. Currently, we have TypeSize to represent the size of data. We should modify the StructLayout using the TypeSize for data size regardless to support scalable struct or not.
- In order to handle load and store scalable struct correctly, we need to modify ComputeValueVTs() to return the correct information. The returned Offsets should be represented as TypeSize. In order to collect the correct information, we need to represent the StructSize in StructLayout using TypeSize. (refer to the first point.)
We have some limitation for the scalable structure.
- Due to the TypeSize could only represent either scalable size or fixed size, we could not mix the fixed objects and scalable objects in a struct. We only support struct with all scalable objects.
- We only need load/store/alloca scalable struct. We have no need to support GEP for scalable struct. It could alleviate the effort to expand the capabilities of IR.
clang-tidy: warning: function 'ComputeValueVTs' defined in a header file; function definitions in header files can lead to ODR violations [misc-definitions-in-headers]
not useful
clang-tidy: warning: invalid case style for function 'ComputeValueVTs' [readability-identifier-naming]
not useful