llvm.org GIT mirror llvm / 2d4575e
Added methods to record SPOffsets from LowerFORMAL_ARGUMENTS git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41525 91177308-0d34-0410-b5e6-96231b3b80d8 Bruno Cardoso Lopes 13 years ago
1 changed file(s) with 53 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
1313 #ifndef MIPS_MACHINE_FUNCTION_INFO_H
1414 #define MIPS_MACHINE_FUNCTION_INFO_H
1515
16 #include "llvm/ADT/VectorExtras.h"
1617 #include "llvm/CodeGen/MachineFunction.h"
18 #include "llvm/CodeGen/MachineFrameInfo.h"
1719
1820 namespace llvm {
1921
3032 /// the Return Address must be saved
3133 int RAStackOffset;
3234
35 /// MipsFIHolder - Holds a FrameIndex and it's Stack Pointer Offset
36 struct MipsFIHolder {
37
38 int FI;
39 int SPOffset;
40
41 MipsFIHolder(int FrameIndex, int StackPointerOffset)
42 : FI(FrameIndex), SPOffset(StackPointerOffset) {}
43 };
44
45 // On LowerFORMAL_ARGUMENTS the stack size is unknown,
46 // so the Stack Pointer Offset calculation of "not in
47 // register arguments" must be postponed to emitPrologue.
48 SmallVector FnLoadArgs;
49 bool HasLoadArgs;
50
51 // When VarArgs, we must write registers back to caller
52 // stack, preserving on register arguments. Since the
53 // stack size is unknown on LowerFORMAL_ARGUMENTS,
54 // the Stack Pointer Offset calculation must be
55 // postponed to emitPrologue.
56 SmallVector FnStoreVarArgs;
57 bool HasStoreVarArgs;
58
3359 public:
3460 MipsFunctionInfo(MachineFunction& MF)
35 : FPStackOffset(0), RAStackOffset(0)
61 : FPStackOffset(0), RAStackOffset(0),
62 HasLoadArgs(false), HasStoreVarArgs(false)
3663 {}
3764
3865 int getFPStackOffset() const { return FPStackOffset; }
4572 return (RAStackOffset > FPStackOffset) ?
4673 (RAStackOffset) : (FPStackOffset);
4774 }
75
76 bool hasLoadArgs() const { return HasLoadArgs; }
77 bool hasStoreVarArgs() const { return HasStoreVarArgs; }
78
79 void recordLoadArgsFI(int FI, int SPOffset) {
80 if (!HasLoadArgs) HasLoadArgs=true;
81 FnLoadArgs.push_back(MipsFIHolder(FI, SPOffset));
82 }
83 void recordStoreVarArgsFI(int FI, int SPOffset) {
84 if (!HasStoreVarArgs) HasStoreVarArgs=true;
85 FnStoreVarArgs.push_back(MipsFIHolder(FI, SPOffset));
86 }
87
88 void adjustLoadArgsFI(MachineFrameInfo *MFI) const {
89 if (!hasLoadArgs()) return;
90 for (unsigned i = 0, e = FnLoadArgs.size(); i != e; ++i)
91 MFI->setObjectOffset( FnLoadArgs[i].FI, FnLoadArgs[i].SPOffset );
92 }
93 void adjustStoreVarArgsFI(MachineFrameInfo *MFI) const {
94 if (!hasStoreVarArgs()) return;
95 for (unsigned i = 0, e = FnStoreVarArgs.size(); i != e; ++i)
96 MFI->setObjectOffset( FnStoreVarArgs[i].FI, FnStoreVarArgs[i].SPOffset );
97 }
98
4899 };
49100
50101 } // end of namespace llvm
51102
52
53 #endif
103 #endif // MIPS_MACHINE_FUNCTION_INFO_H