[PATCH] D129106: [RISCV] Add support for static chain

Funan Zeng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 4 23:43:00 PDT 2022


melonedo created this revision.
melonedo added reviewers: liaolucy, craig.topper.
Herald added subscribers: sunshaoce, VincentWu, luke957, StephenFan, vkmr, frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya, arichardson.
Herald added a project: All.
melonedo requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead, eopXD, MaskRay.
Herald added a project: LLVM.

The static chain parameter is a special parameter that is not passed in the usual argument registers or stack space. For example, in x64 System V ABI it is always passed in R10 <https://reviews.llvm.org/source/svn-test-suite/>. Although the ABI of RISCV does not assign a register for this purpose, GCC had support for it on RISC-V a long time ago, and it is exposed via `__builtin_call_with_static_chain` intrinsic, and assign t2 for static chain parameters. This patch also chose t2 for compatibility.

In LLVM, static chain parameters are handled by the `nest` attribute of an argument to a function (D6332 <https://reviews.llvm.org/D6332>), so tests are added to ensure `nest` arguments are handled correctly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129106

Files:
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/test/CodeGen/RISCV/nest-register.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129106.442182.patch
Type: text/x-patch
Size: 3647 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220705/7d0792d2/attachment.bin>


More information about the llvm-commits mailing list