This patch proposes how to deal with RISC-V vector frame objects. The layout of RISC-V vector frame will look like
|---------------------------------| | RVV incoming arguments | |---------------------------------| previous frame | scalar incoming arguments | |---------------------------------| <- start of frame (fp) | scalar callee-saved registers | |---------------------------------| | scalar local variables | |---------------------------------| | addresses of RVV objects (*) | current frame |---------------------------------| | RVV local variables | |---------------------------------| | RVV outgoing arguments | |---------------------------------| | scalar outgoing arguments | |---------------------------------| <- end of frame (sp)
We will reserve stack space for RISC-V vector frame objects and store their base addresses in “addresses of RVV objects” area. The benefits of this way is we have no need to calculate the addresses of RVV objects repeatedly. There is no easy way to get the addresses of the RISC-V vector objects in V instructions. We need to read out VLENB and multiple VLENB with LMUL to know the size of vector objects. Then we need to subtract or add the size from the stack pointer. If there are multiple vector objects in the frame, we need to subtract or add the accumulated size from the stack pointer. If we store the base addresses in the frame first, we only need to load the base address from the stack frame and access the vector object directly.
Spilling for RISC-V V extension will be another patch.
Authored-by: Roger Ferrer Ibanez <rofirrim@gmail.com>
Co-Authored-by: Hsiangkai Wang <kai.wang@sifive.com>
clang-format: please reformat the code