[PATCH] D149575: [CodeGen] Support allocating of arguments by decreasing offsets

Sergei Barannikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 1 04:07:02 PDT 2023


barannikov88 created this revision.
Herald added subscribers: jrtc27, fedor.sergeev, kbarton, hiraditya, nemanjai, jyknight.
Herald added a project: All.
barannikov88 retitled this revision from "[CodeGen] Support allocating of arguments by decreasing addresses" to "[CodeGen] Support allocating of arguments by decreasing offsets".
barannikov88 edited the summary of this revision.
Herald added subscribers: kosarev, tpr.
barannikov88 edited the summary of this revision.
barannikov88 edited the summary of this revision.
barannikov88 added reviewers: arsenm, yusra.syeda.
barannikov88 published this revision for review.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

Previously, `CCState::AllocateStack` always allocated stack space by increasing
offsets. For targets with stack growing down (towards zero) it is more
convenient to allocate arguments by decreasing offsets, so that the first
argument is at the top of the stack. This is important when calling a function
with variable number of arguments: the callee does not know the size of the
stack, but must be able to access "fixed" arguments. For that to work, the
"fixed" arguments should have fixed offsets relative to the stack top, i.e. the
variadic arguments area should be at the stack bottom (at lowest addresses).

The in-tree target with stack growing down is AMDGPU, but it allocates
arguments by increasing addresses. It does not support variadic arguments.

A drive-by change is to promote stack size/offset to 64-bit integer.
This is what MachineFrameInfo expects.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149575

Files:
  llvm/include/llvm/CodeGen/CallingConvLower.h
  llvm/lib/CodeGen/CallingConvLower.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/Sparc/SparcISelLowering.cpp
  llvm/unittests/CodeGen/CCStateTest.cpp
  llvm/unittests/CodeGen/CMakeLists.txt
  llvm/utils/TableGen/CallingConvEmitter.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149575.518412.patch
Type: text/x-patch
Size: 11310 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230501/e14501b5/attachment.bin>


More information about the llvm-commits mailing list