HomePhabricator

[RISCV] Frame handling for RISC-V V extension.

Authored by HsiangKai on Jan 7 2021, 6:18 PM.

Description

[RISCV] Frame handling for RISC-V V extension.

This patch proposes how to deal with RISC-V vector frame objects. The
layout of RISC-V vector frame will look like

scalar callee-saved registers
scalar local variables
scalar outgoing arguments
RVV local variables &&
RVV outgoing arguments
---------------------------------<- end of frame (sp)

If there is realignment or variable length array in the stack, we will use
frame pointer to access fixed objects and stack pointer to access
non-fixed objects.

---------------------------------<- frame pointer (fp)
scalar callee-saved registers
scalar local variables
/ realignment /
scalar outgoing arguments
RVV local variables &&
RVV outgoing arguments
---------------------------------<- end of frame (sp)

If there are both realignment and variable length array in the stack, we
will use frame pointer to access fixed objects and base pointer to access
non-fixed objects.

---------------------------------<- frame pointer (fp)
scalar callee-saved registers
scalar local variables
/ realignment /
---------------------------------<- base pointer (bp)
RVV local variables &&
RVV outgoing arguments
///////
variable length array
///////
---------------------------------<- end of frame (sp)
scalar outgoing arguments

In this version, we do not save the addresses of RVV objects in the
stack. We access them directly through the polynomial expression
(a x VLENB + b). We do not reserve frame pointer when there is any RVV
object in the stack. So, we also access the scalar frame objects through the
polynomial expression (a x VLENB + b) if the access across RVV stack
area.

Differential Revision: https://reviews.llvm.org/D94465