[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32RegisterInfo.cpp README.txt

Nate Begeman natebegeman at mac.com
Tue Jul 26 23:06:41 PDT 2005



Changes in directory llvm/lib/Target/PowerPC:

PPC32RegisterInfo.cpp updated: 1.12 -> 1.13
README.txt updated: 1.24 -> 1.25
---
Log message:

Implement the optimization for the Red Zone on Darwin.  This removes the
unnecessary SP manipulation in leaf routines that don't need it.


---
Diffs of the changes:  (+8 -4)

 PPC32RegisterInfo.cpp |   11 ++++++++---
 README.txt            |    1 -
 2 files changed, 8 insertions(+), 4 deletions(-)


Index: llvm/lib/Target/PowerPC/PPC32RegisterInfo.cpp
diff -u llvm/lib/Target/PowerPC/PPC32RegisterInfo.cpp:1.12 llvm/lib/Target/PowerPC/PPC32RegisterInfo.cpp:1.13
--- llvm/lib/Target/PowerPC/PPC32RegisterInfo.cpp:1.12	Fri Apr 22 12:54:30 2005
+++ llvm/lib/Target/PowerPC/PPC32RegisterInfo.cpp	Wed Jul 27 01:06:29 2005
@@ -245,8 +245,13 @@
     NumBytes += MFI->getMaxCallFrameSize();
   }
 
-  // Do we need to allocate space on the stack?
-  if (NumBytes == 0) return;
+  // If we are a leaf function, and use up to 224 bytes of stack space, 
+  // and don't have a frame pointer, then we do not need to adjust the stack
+  // pointer (we fit in the Red Zone).
+  if ((NumBytes == 0) || (NumBytes <= 224 && !hasFP(MF) && !MFI->hasCalls())) {
+    MFI->setStackSize(0);
+    return;
+  }
 
   // Add the size of R1 to  NumBytes size for the store of R1 to the bottom
   // of the stack and round the size to a multiple of the alignment.
@@ -258,7 +263,7 @@
   // Update frame info to pretend that this is part of the stack...
   MFI->setStackSize(NumBytes);
 
-  // adjust stack pointer: r1 -= numbytes
+  // If , adjust stack pointer: r1 -= numbytes.
   if (NumBytes <= 32768) {
     MI=BuildMI(PPC::STWU,3).addReg(PPC::R1).addSImm(-NumBytes).addReg(PPC::R1);
     MBB.insert(MBBI, MI);


Index: llvm/lib/Target/PowerPC/README.txt
diff -u llvm/lib/Target/PowerPC/README.txt:1.24 llvm/lib/Target/PowerPC/README.txt:1.25
--- llvm/lib/Target/PowerPC/README.txt:1.24	Tue Jul 26 14:07:51 2005
+++ llvm/lib/Target/PowerPC/README.txt	Wed Jul 27 01:06:29 2005
@@ -3,7 +3,6 @@
 * implement do-loop -> bdnz transform
 * implement powerpc-64 for darwin
 * use stfiwx in float->int
-* take advantage of the darwin red zone in PPC32RegisterInfo.cpp
 * be able to combine sequences like the following into 2 instructions:
 	lis r2, ha16(l2__ZTV4Cell)
 	la r2, lo16(l2__ZTV4Cell)(r2)






More information about the llvm-commits mailing list