PPC: Implement base pointer and stack realignment
authorHal Finkel <hfinkel@anl.gov>
Wed, 17 Jul 2013 00:45:52 +0000 (00:45 +0000)
committerHal Finkel <hfinkel@anl.gov>
Wed, 17 Jul 2013 00:45:52 +0000 (00:45 +0000)
commitfe47bf8fa07e12b70ff8b234fa1f6b97c8d2753d
treee2aea580e6331c70d20f3d01ec127e6f696d68c7
parent63e22afdceda8e8eae59ba5ec122097e2755a522
PPC: Implement base pointer and stack realignment

This builds on some frame-lowering code that has existed since 2005 (r24224)
but was disabled in 2008 (r48188) because it needed base pointer support to
function correctly. This implementation follows the strategy suggested by Dale
Johannesen in r48188 where the following comment was added:

  This does not currently work, because the delta between old and new stack
  pointers is added to offsets that reference incoming parameters after the
  prolog is generated, and the code that does that doesn't handle a variable
  delta.  You don't want to do that anyway; a better approach is to reserve
  another register that retains to the incoming stack pointer, and reference
  parameters relative to that.

And now we do exactly that. If we don't need a frame pointer, then we use r31
as a base pointer. If we do need a frame pointer, then we use r30 as a base
pointer. The base pointer retains the value of the stack pointer before it was
decremented in the prologue. We then use the base pointer to resolve all
negative frame indicies. The basic scheme follows that for base pointers in the
X86 backend.

We use a base pointer when we need to dynamically realign the incoming stack
pointer. This currently applies only to static objects (dynamic allocas with
large alignments, and base-pointer support in SjLj lowering will come in future
commits).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186478 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/PowerPC/PPCFrameLowering.cpp
lib/Target/PowerPC/PPCFrameLowering.h
lib/Target/PowerPC/PPCMachineFunctionInfo.h
lib/Target/PowerPC/PPCRegisterInfo.cpp
lib/Target/PowerPC/PPCRegisterInfo.h
test/CodeGen/PowerPC/stack-realign.ll [new file with mode: 0644]