llvm.org GIT mirror llvm / aa09b75
Rename FunctionFrameInfo to MachineFrameInfo git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5201 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 17 years ago
5 changed file(s) with 33 addition(s) and 33 deletion(s). Raw diff Collapse all Expand all
None //===-- CodeGen/FunctionFrameInfo.h - Abstract Stack Frame Rep --*- C++ -*-===//
0 //===-- CodeGen/MachineFrameInfo.h - Abstract Stack Frame Rep. --*- C++ -*-===//
11 //
2 // The FunctionFrameInfo class represents an abstract stack frame until
2 // The MachineFrameInfo class represents an abstract stack frame until
33 // prolog/epilog code is inserted. This class is key to allowing stack frame
44 // representation optimizations, such as frame pointer elimination. It also
55 // allows more mundane (but still important) optimizations, such as reordering
3030 #ifndef LLVM_CODEGEN_FUNCTIONFRAMEINFO_H
3131 #define LLVM_CODEGEN_FUNCTIONFRAMEINFO_H
3232
33 class FunctionFrameInfo {
33 class MachineFrameInfo {
3434
3535 // StackObject - Represent a single object allocated on the stack.
3636 struct StackObject {
8282 ///
8383 unsigned MaxCallFrameSize;
8484 public:
85 FunctionFrameInfo() {
85 MachineFrameInfo() {
8686 NumFixedObjects = StackSize = 0;
8787 HasVarSizedObjects = false;
8888 HasCalls = false;
180180 return Objects.size()-NumFixedObjects-1;
181181 }
182182
183 /// CreateVariableSizedObject - Notify the FunctionFrameInfo object that a
183 /// CreateVariableSizedObject - Notify the MachineFrameInfo object that a
184184 /// variable sized object has been created. This must be created whenever a
185185 /// variable sized object is created, whether or not the index returned is
186186 /// actually used.
1919 class Pass;
2020 class SSARegMap;
2121 class MachineFunctionInfo;
22 class FunctionFrameInfo;
22 class MachineFrameInfo;
2323
2424 Pass *createMachineCodeConstructionPass(TargetMachine &Target);
2525 Pass *createMachineCodeDestructionPass();
3939 MachineFunctionInfo *MFInfo;
4040
4141 // Keep track of objects allocated on the stack.
42 FunctionFrameInfo *FrameInfo;
42 MachineFrameInfo *FrameInfo;
4343
4444 public:
4545 MachineFunction(const Function *Fn, const TargetMachine& target);
6363 /// This object contains information about objects allocated on the stack
6464 /// frame of the current function in an abstract way.
6565 ///
66 FunctionFrameInfo *getFrameInfo() const { return FrameInfo; }
66 MachineFrameInfo *getFrameInfo() const { return FrameInfo; }
6767
6868 /// MachineFunctionInfo - Keep track of various per-function pieces of
6969 /// information for the sparc backend.
1919 #include "llvm/CodeGen/MachineFunction.h"
2020 #include "llvm/CodeGen/MachineInstrBuilder.h"
2121 #include "llvm/CodeGen/SSARegMap.h"
22 #include "llvm/CodeGen/FunctionFrameInfo.h"
22 #include "llvm/CodeGen/MachineFrameInfo.h"
2323 #include "llvm/Target/TargetMachine.h"
2424 #include "llvm/Support/InstVisitor.h"
2525 #include "llvm/Target/MRegisterInfo.h"
344344 // ...
345345 //
346346 unsigned ArgOffset = 0;
347 FunctionFrameInfo *FFI = F->getFrameInfo();
347 MachineFrameInfo *MFI = F->getFrameInfo();
348348
349349 for (Function::aiterator I = Fn.abegin(), E = Fn.aend(); I != E; ++I) {
350350 unsigned Reg = getReg(*I);
354354
355355 switch (getClassB(I->getType())) {
356356 case cByte:
357 FI = FFI->CreateFixedObject(1, ArgOffset);
357 FI = MFI->CreateFixedObject(1, ArgOffset);
358358 addFrameReference(BuildMI(BB, X86::MOVmr8, 4, Reg), FI);
359359 break;
360360 case cShort:
361 FI = FFI->CreateFixedObject(2, ArgOffset);
361 FI = MFI->CreateFixedObject(2, ArgOffset);
362362 addFrameReference(BuildMI(BB, X86::MOVmr16, 4, Reg), FI);
363363 break;
364364 case cInt:
365 FI = FFI->CreateFixedObject(4, ArgOffset);
365 FI = MFI->CreateFixedObject(4, ArgOffset);
366366 addFrameReference(BuildMI(BB, X86::MOVmr32, 4, Reg), FI);
367367 break;
368368 case cFP:
369369 unsigned Opcode;
370370 if (I->getType() == Type::FloatTy) {
371371 Opcode = X86::FLDr32;
372 FI = FFI->CreateFixedObject(4, ArgOffset);
372 FI = MFI->CreateFixedObject(4, ArgOffset);
373373 } else {
374374 Opcode = X86::FLDr64;
375375 ArgOffset += 4; // doubles require 4 additional bytes
376 FI = FFI->CreateFixedObject(8, ArgOffset);
376 FI = MFI->CreateFixedObject(8, ArgOffset);
377377 }
378378 addFrameReference(BuildMI(BB, Opcode, 4, Reg), FI);
379379 break;
1919 #include "llvm/CodeGen/MachineFunction.h"
2020 #include "llvm/CodeGen/MachineInstrBuilder.h"
2121 #include "llvm/CodeGen/SSARegMap.h"
22 #include "llvm/CodeGen/FunctionFrameInfo.h"
22 #include "llvm/CodeGen/MachineFrameInfo.h"
2323 #include "llvm/Target/TargetMachine.h"
2424 #include "llvm/Support/InstVisitor.h"
2525 #include "llvm/Target/MRegisterInfo.h"
344344 // ...
345345 //
346346 unsigned ArgOffset = 0;
347 FunctionFrameInfo *FFI = F->getFrameInfo();
347 MachineFrameInfo *MFI = F->getFrameInfo();
348348
349349 for (Function::aiterator I = Fn.abegin(), E = Fn.aend(); I != E; ++I) {
350350 unsigned Reg = getReg(*I);
354354
355355 switch (getClassB(I->getType())) {
356356 case cByte:
357 FI = FFI->CreateFixedObject(1, ArgOffset);
357 FI = MFI->CreateFixedObject(1, ArgOffset);
358358 addFrameReference(BuildMI(BB, X86::MOVmr8, 4, Reg), FI);
359359 break;
360360 case cShort:
361 FI = FFI->CreateFixedObject(2, ArgOffset);
361 FI = MFI->CreateFixedObject(2, ArgOffset);
362362 addFrameReference(BuildMI(BB, X86::MOVmr16, 4, Reg), FI);
363363 break;
364364 case cInt:
365 FI = FFI->CreateFixedObject(4, ArgOffset);
365 FI = MFI->CreateFixedObject(4, ArgOffset);
366366 addFrameReference(BuildMI(BB, X86::MOVmr32, 4, Reg), FI);
367367 break;
368368 case cFP:
369369 unsigned Opcode;
370370 if (I->getType() == Type::FloatTy) {
371371 Opcode = X86::FLDr32;
372 FI = FFI->CreateFixedObject(4, ArgOffset);
372 FI = MFI->CreateFixedObject(4, ArgOffset);
373373 } else {
374374 Opcode = X86::FLDr64;
375375 ArgOffset += 4; // doubles require 4 additional bytes
376 FI = FFI->CreateFixedObject(8, ArgOffset);
376 FI = MFI->CreateFixedObject(8, ArgOffset);
377377 }
378378 addFrameReference(BuildMI(BB, Opcode, 4, Reg), FI);
379379 break;
1111 #include "llvm/Type.h"
1212 #include "llvm/CodeGen/MachineInstrBuilder.h"
1313 #include "llvm/CodeGen/MachineFunction.h"
14 #include "llvm/CodeGen/FunctionFrameInfo.h"
14 #include "llvm/CodeGen/MachineFrameInfo.h"
1515 #include "Support/CommandLine.h"
1616
1717 namespace {
138138 int Offset = MF.getFrameInfo()->getObjectOffset(FrameIndex);
139139
140140 if (!hasFP(MF) && hasSPAdjust(MF)) {
141 const FunctionFrameInfo *FFI = MF.getFrameInfo();
142 Offset += FFI->getStackSize() + FFI->getMaxCallFrameSize();
141 const MachineFrameInfo *MFI = MF.getFrameInfo();
142 Offset += MFI->getStackSize() + MFI->getMaxCallFrameSize();
143143 }
144144
145145 MI.SetMachineOperandConst(i, MachineOperand::MO_SignExtendedImmed, Offset);
158158 void X86RegisterInfo::emitPrologue(MachineFunction &MF) const {
159159 MachineBasicBlock &MBB = MF.front(); // Prolog goes in entry BB
160160 MachineBasicBlock::iterator MBBI = MBB.begin();
161 const FunctionFrameInfo *FFI = MF.getFrameInfo();
161 const MachineFrameInfo *MFI = MF.getFrameInfo();
162162 MachineInstr *MI;
163163
164164 // Get the number of bytes to allocate from the FrameInfo
165 unsigned NumBytes = FFI->getStackSize();
165 unsigned NumBytes = MFI->getStackSize();
166166 if (hasFP(MF)) {
167167 // Get the offset of the stack slot for the EBP register... which is
168168 // guaranteed to be the last slot by processFunctionBeforeFrameFinalized.
169 int EBPOffset = FFI->getObjectOffset(FFI->getObjectIndexEnd()-1);
169 int EBPOffset = MFI->getObjectOffset(MFI->getObjectIndexEnd()-1);
170170
171171 MI = addRegOffset(BuildMI(X86::MOVrm32, 5), // mov [ESP-], EBP
172172 X86::ESP, EBPOffset).addReg(X86::EBP);
186186 // in the function immediately on entry to the current function. This
187187 // eliminates the need for add/sub ESP brackets around call sites.
188188 //
189 NumBytes += FFI->getMaxCallFrameSize();
189 NumBytes += MFI->getMaxCallFrameSize();
190190 }
191191
192192 if (NumBytes) {
198198
199199 void X86RegisterInfo::emitEpilogue(MachineFunction &MF,
200200 MachineBasicBlock &MBB) const {
201 const FunctionFrameInfo *FFI = MF.getFrameInfo();
201 const MachineFrameInfo *MFI = MF.getFrameInfo();
202202 MachineBasicBlock::iterator MBBI = MBB.end()-1;
203203 MachineInstr *MI;
204204 assert((*MBBI)->getOpcode() == X86::RET &&
207207 if (hasFP(MF)) {
208208 // Get the offset of the stack slot for the EBP register... which is
209209 // guaranteed to be the last slot by processFunctionBeforeFrameFinalized.
210 int EBPOffset = FFI->getObjectOffset(FFI->getObjectIndexEnd()-1);
210 int EBPOffset = MFI->getObjectOffset(MFI->getObjectIndexEnd()-1);
211211
212212 // mov ESP, EBP
213213 MI = BuildMI(X86::MOVrr32, 1,X86::ESP).addReg(X86::EBP);
220220 if (!hasSPAdjust(MF)) return;
221221
222222 // Get the number of bytes allocated from the FrameInfo...
223 unsigned NumBytes = FFI->getStackSize();
224 NumBytes += FFI->getMaxCallFrameSize();
223 unsigned NumBytes = MFI->getStackSize();
224 NumBytes += MFI->getMaxCallFrameSize();
225225
226226 if (NumBytes) { // adjust stack pointer back: ESP += numbytes
227227 MI =BuildMI(X86::ADDri32, 2, X86::ESP).addReg(X86::ESP).addZImm(NumBytes);