llvm.org GIT mirror llvm / bb07ef9
The prologue/epilogue related method calls have no reason to return a value, make them return void. This allows us to avoid some costly MBB.size() calls git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11448 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 16 years ago
2 changed file(s) with 34 addition(s) and 44 deletion(s). Raw diff Collapse all Expand all
2424 #include "llvm/Target/TargetFrameInfo.h"
2525 #include "Support/CommandLine.h"
2626 #include "Support/STLExtras.h"
27
2827 using namespace llvm;
2928
3029 namespace {
9190 return NoFPElim || MF.getFrameInfo()->hasVarSizedObjects();
9291 }
9392
94 int X86RegisterInfo::eliminateCallFramePseudoInstr(MachineFunction &MF,
95 MachineBasicBlock &MBB,
96 MachineBasicBlock::iterator I) const {
97 MachineInstr *New = 0, *Old = I;
93 void X86RegisterInfo::
94 eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
95 MachineBasicBlock::iterator I) const {
9896 if (hasFP(MF)) {
9997 // If we have a frame pointer, turn the adjcallstackup instruction into a
10098 // 'sub ESP, ' and the adjcallstackdown instruction into 'add ESP,
10199 // '
100 MachineInstr *Old = I;
102101 unsigned Amount = Old->getOperand(0).getImmedValue();
103102 if (Amount != 0) {
104103 // We need to keep the stack aligned properly. To do this, we round the
107106 unsigned Align = MF.getTarget().getFrameInfo().getStackAlignment();
108107 Amount = (Amount+Align-1)/Align*Align;
109108
109 MachineInstr *New;
110110 if (Old->getOpcode() == X86::ADJCALLSTACKDOWN) {
111111 New=BuildMI(X86::SUBri32, 1, X86::ESP, MOTy::UseAndDef).addZImm(Amount);
112112 } else {
113113 assert(Old->getOpcode() == X86::ADJCALLSTACKUP);
114114 New=BuildMI(X86::ADDri32, 1, X86::ESP, MOTy::UseAndDef).addZImm(Amount);
115115 }
116 }
117 }
118
119 if (New) {
120 // Replace the pseudo instruction with a new instruction...
121 MBB.insert(MBB.erase(I), New);
122 return 0;
123 } else {
124 MBB.erase(I);
125 return -1;
126 }
127 }
128
129 int X86RegisterInfo::eliminateFrameIndex(MachineFunction &MF,
116
117 // Replace the pseudo instruction with a new instruction...
118 MBB.insert(I, New);
119 }
120 }
121
122 MBB.erase(I);
123 }
124
125 void X86RegisterInfo::eliminateFrameIndex(MachineFunction &MF,
130126 MachineBasicBlock::iterator II) const {
131127 unsigned i = 0;
132128 MachineInstr &MI = *II;
149145 Offset += MF.getFrameInfo()->getStackSize();
150146
151147 MI.SetMachineOperandConst(i+3, MachineOperand::MO_SignExtendedImmed, Offset);
152 return 0;
153 }
154
155 int X86RegisterInfo::processFunctionBeforeFrameFinalized(MachineFunction &MF)
156 const {
148 }
149
150 void
151 X86RegisterInfo::processFunctionBeforeFrameFinalized(MachineFunction &MF) const{
157152 if (hasFP(MF)) {
158153 // Create a frame entry for the EBP register that must be saved.
159154 int FrameIdx = MF.getFrameInfo()->CreateStackObject(4, 4);
160155 assert(FrameIdx == MF.getFrameInfo()->getObjectIndexEnd()-1 &&
161156 "Slot for EBP register must be last in order to be found!");
162157 }
163 return 0;
164 }
165
166 int X86RegisterInfo::emitPrologue(MachineFunction &MF) const {
158 }
159
160 void X86RegisterInfo::emitPrologue(MachineFunction &MF) const {
167161 MachineBasicBlock &MBB = MF.front(); // Prolog goes in entry BB
168162 MachineBasicBlock::iterator MBBI = MBB.begin();
169163 MachineFrameInfo *MFI = MF.getFrameInfo();
170164 MachineInstr *MI;
171165
172 unsigned oldSize = MBB.size();
173166 // Get the number of bytes to allocate from the FrameInfo
174167 unsigned NumBytes = MFI->getStackSize();
175168 if (hasFP(MF)) {
216209 MBB.insert(MBBI, MI);
217210 }
218211 }
219 return MBB.size() - oldSize;
220 }
221
222 int X86RegisterInfo::emitEpilogue(MachineFunction &MF,
223 MachineBasicBlock &MBB) const {
224 unsigned oldSize = MBB.size();
212 }
213
214 void X86RegisterInfo::emitEpilogue(MachineFunction &MF,
215 MachineBasicBlock &MBB) const {
225216 const MachineFrameInfo *MFI = MF.getFrameInfo();
226217 MachineBasicBlock::iterator MBBI = prior(MBB.end());
227218 MachineInstr *MI;
249240 MBB.insert(MBBI, MI);
250241 }
251242 }
252 return MBB.size() - oldSize;
253243 }
254244
255245 #include "X86GenRegisterInfo.inc"
4141 unsigned DestReg, unsigned SrcReg,
4242 const TargetRegisterClass *RC) const;
4343
44 int eliminateCallFramePseudoInstr(MachineFunction &MF,
45 MachineBasicBlock &MBB,
46 MachineBasicBlock::iterator MI) const;
44 void eliminateCallFramePseudoInstr(MachineFunction &MF,
45 MachineBasicBlock &MBB,
46 MachineBasicBlock::iterator MI) const;
4747
48 int eliminateFrameIndex(MachineFunction &MF,
49 MachineBasicBlock::iterator MI) const;
48 void eliminateFrameIndex(MachineFunction &MF,
49 MachineBasicBlock::iterator MI) const;
5050
51 int processFunctionBeforeFrameFinalized(MachineFunction &MF) const;
51 void processFunctionBeforeFrameFinalized(MachineFunction &MF) const;
5252
53 int emitPrologue(MachineFunction &MF) const;
54 int emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
53 void emitPrologue(MachineFunction &MF) const;
54 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
5555 };
5656
5757 } // End llvm namespace