diff options
author | Chris Lattner <sabre@nondot.org> | 2003-01-15 22:52:34 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-01-15 22:52:34 +0000 |
commit | 4ac7d7302b36a5d20f71b5c290c63a7f6c345289 (patch) | |
tree | fa9478b4e6c764819c4e1d459bc3c39ae1efc18b /lib/CodeGen/PrologEpilogInserter.cpp | |
parent | 795ba6cabdbba32cdf9912fbd9091e6b3cfbd3c6 (diff) | |
download | external_llvm-4ac7d7302b36a5d20f71b5c290c63a7f6c345289.zip external_llvm-4ac7d7302b36a5d20f71b5c290c63a7f6c345289.tar.gz external_llvm-4ac7d7302b36a5d20f71b5c290c63a7f6c345289.tar.bz2 |
* Insert prolog/epilog code before rewriting indexes
* Fix calculation of frame offsets when there is an offset.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5318 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/PrologEpilogInserter.cpp')
-rw-r--r-- | lib/CodeGen/PrologEpilogInserter.cpp | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/lib/CodeGen/PrologEpilogInserter.cpp b/lib/CodeGen/PrologEpilogInserter.cpp index 21107a2..1f3c9e2 100644 --- a/lib/CodeGen/PrologEpilogInserter.cpp +++ b/lib/CodeGen/PrologEpilogInserter.cpp @@ -41,13 +41,13 @@ namespace { // Calculate actual frame offsets for all of the abstract stack objects... calculateFrameObjectOffsets(Fn); + // Add prolog and epilog code to the function. + insertPrologEpilogCode(Fn); + // Replace all MO_FrameIndex operands with physical register references // and actual offsets. // replaceFrameIndices(Fn); - - // Add prolog and epilog code to the function. - insertPrologEpilogCode(Fn); return true; } @@ -187,7 +187,7 @@ void PEI::calculateFrameObjectOffsets(MachineFunction &Fn) { MachineFrameInfo *FFI = Fn.getFrameInfo(); // Start at the beginning of the local area... - int Offset = -TFI.getOffsetOfLocalArea(); + int Offset = TFI.getOffsetOfLocalArea(); for (unsigned i = 0, e = FFI->getObjectIndexEnd(); i != e; ++i) { Offset += FFI->getObjectSize(i); // Allocate Size bytes... @@ -202,7 +202,25 @@ void PEI::calculateFrameObjectOffsets(MachineFunction &Fn) { Offset = (Offset+StackAlign-1)/StackAlign*StackAlign; // Set the final value of the stack pointer... - FFI->setStackSize(Offset); + FFI->setStackSize(Offset-TFI.getOffsetOfLocalArea()); +} + + +/// insertPrologEpilogCode - Scan the function for modified caller saved +/// registers, insert spill code for these caller saved registers, then add +/// prolog and epilog code to the function. +/// +void PEI::insertPrologEpilogCode(MachineFunction &Fn) { + // Add prologue to the function... + Fn.getTarget().getRegisterInfo()->emitPrologue(Fn); + + // Add epilogue to restore the callee-save registers in each exiting block + const TargetInstrInfo &TII = Fn.getTarget().getInstrInfo(); + for (MachineFunction::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I) { + // If last instruction is a return instruction, add an epilogue + if (TII.isReturn(I->back()->getOpcode())) + Fn.getTarget().getRegisterInfo()->emitEpilogue(Fn, *I); + } } @@ -226,21 +244,3 @@ void PEI::replaceFrameIndices(MachineFunction &Fn) { break; } } - - -/// insertPrologEpilogCode - Scan the function for modified caller saved -/// registers, insert spill code for these caller saved registers, then add -/// prolog and epilog code to the function. -/// -void PEI::insertPrologEpilogCode(MachineFunction &Fn) { - // Add prologue to the function... - Fn.getTarget().getRegisterInfo()->emitPrologue(Fn); - - // Add epilogue to restore the callee-save registers in each exiting block - const TargetInstrInfo &TII = Fn.getTarget().getInstrInfo(); - for (MachineFunction::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I) { - // If last instruction is a return instruction, add an epilogue - if (TII.isReturn(I->back()->getOpcode())) - Fn.getTarget().getRegisterInfo()->emitEpilogue(Fn, *I); - } -} |