[PATCH] D93750: [RISCV] Frame handling for RISC-V V extension.

Hsiangkai Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 23 01:46:10 PST 2020


HsiangKai created this revision.
HsiangKai added reviewers: craig.topper, evandro, rogfer01, frasercrmck, luismarques.
Herald added subscribers: NickHung, kerbowa, apazos, sameer.abuasal, pzheng, s.egerton, lenary, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 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

  |---------------------------------|
  | 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 at gmail.com>
Co-Authored-by: Hsiangkai Wang <kai.wang at sifive.com>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93750

Files:
  llvm/include/llvm/CodeGen/MIRYamlMapping.h
  llvm/include/llvm/CodeGen/MachineFrameInfo.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/RISCVInstrInfoVPseudos.td
  llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
  llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
  llvm/lib/Target/RISCV/Utils/RISCVBaseInfo.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-with-scalar.ll
  llvm/test/CodeGen/RISCV/rvv/memory-args.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93750.313507.patch
Type: text/x-patch
Size: 58618 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201223/9c9ac21f/attachment.bin>


More information about the llvm-commits mailing list