[PATCH] D94465: [RISCV] Frame handling for RISC-V V extension. (2nd. version)

Hsiangkai Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 11 21:05:44 PST 2021


HsiangKai created this revision.
HsiangKai added reviewers: craig.topper, evandro, rogfer01, frasercrmck, luismarques, asb, jrtc27.
Herald added subscribers: NickHung, kerbowa, apazos, sameer.abuasal, pzheng, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, edward-jones, zzheng, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya, nhaehnle, jvesely, arsenm.
HsiangKai requested review of this revision.
Herald added a subscriber: MaskRay.
Herald added a project: LLVM.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94465

Files:
  llvm/include/llvm/CodeGen/MIRYamlMapping.h
  llvm/include/llvm/CodeGen/TargetFrameLowering.h
  llvm/lib/Target/AMDGPU/SIFrameLowering.cpp
  llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
  llvm/lib/Target/RISCV/RISCVFrameLowering.h
  llvm/lib/Target/RISCV/RISCVMachineFunctionInfo.h
  llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
  llvm/lib/Target/RISCV/RISCVRegisterInfo.h
  llvm/test/CodeGen/RISCV/rvv/allocate-lmul-2-4-8.ll
  llvm/test/CodeGen/RISCV/rvv/localvar.ll
  llvm/test/CodeGen/RISCV/rvv/memory-args.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94465.315988.patch
Type: text/x-patch
Size: 48246 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210112/ae29aff6/attachment.bin>


More information about the llvm-commits mailing list