1 //====- ARMMachineFuctionInfo.h - ARM machine function info -----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the Evan Cheng and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares ARM-specific per-machine-function information.
12 //===----------------------------------------------------------------------===//
14 #ifndef ARMMACHINEFUNCTIONINFO_H
15 #define ARMMACHINEFUNCTIONINFO_H
17 #include "ARMSubtarget.h"
18 #include "llvm/CodeGen/MachineFunction.h"
19 #include "llvm/Target/TargetMachine.h"
23 /// ARMFunctionInfo - This class is derived from MachineFunction private
24 /// ARM target-specific information for each MachineFunction.
25 class ARMFunctionInfo : public MachineFunctionInfo {
27 /// isThumb - True if this function is compiled under Thumb mode.
31 /// VarArgsRegSaveSize - Size of the register save area for vararg functions.
33 unsigned VarArgsRegSaveSize;
35 /// HasStackFrame - True if this function has a stack frame. Set by
36 /// processFunctionBeforeCalleeSavedScan().
39 /// LRSForceSpilled - True if the LR register has been for spilled to enable
43 /// FramePtrSpillOffset - If HasStackFrame, this records the frame pointer
44 /// spill stack offset.
45 unsigned FramePtrSpillOffset;
47 /// GPRCS1Offset, GPRCS2Offset, DPRCSOffset - Starting offset of callee saved
48 /// register spills areas. For Mac OS X:
50 /// GPR callee-saved (1) : r4, r5, r6, r7, lr
51 /// --------------------------------------------
52 /// GPR callee-saved (2) : r8, r10, r11
53 /// --------------------------------------------
54 /// DPR callee-saved : d8 - d15
55 unsigned GPRCS1Offset;
56 unsigned GPRCS2Offset;
59 /// GPRCS1Size, GPRCS2Size, DPRCSSize - Sizes of callee saved register spills
65 /// GPRCS1Frames, GPRCS2Frames, DPRCSFrames - Keeps track of frame indices
66 /// which belong to these spill areas.
67 std::vector<bool> GPRCS1Frames;
68 std::vector<bool> GPRCS2Frames;
69 std::vector<bool> DPRCSFrames;
71 /// JumpTableUId - Unique id for jumptables.
73 unsigned JumpTableUId;
78 VarArgsRegSaveSize(0), HasStackFrame(false), LRForceSpilled(false),
79 FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0),
80 GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0), JumpTableUId(0) {}
82 ARMFunctionInfo(MachineFunction &MF) :
83 isThumb(MF.getTarget().getSubtarget<ARMSubtarget>().isThumb()),
84 VarArgsRegSaveSize(0), HasStackFrame(false), LRForceSpilled(false),
85 FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0),
86 GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0), JumpTableUId(0) {}
88 bool isThumbFunction() const { return isThumb; }
90 unsigned getVarArgsRegSaveSize() const { return VarArgsRegSaveSize; }
91 void setVarArgsRegSaveSize(unsigned s) { VarArgsRegSaveSize = s; }
93 bool hasStackFrame() const { return HasStackFrame; }
94 void setHasStackFrame(bool s) { HasStackFrame = s; }
96 bool isLRForceSpilled() const { return LRForceSpilled; }
97 void setLRIsForceSpilled(bool s) { LRForceSpilled = s; }
99 unsigned getFramePtrSpillOffset() const { return FramePtrSpillOffset; }
100 void setFramePtrSpillOffset(unsigned o) { FramePtrSpillOffset = o; }
102 unsigned getGPRCalleeSavedArea1Offset() const { return GPRCS1Offset; }
103 unsigned getGPRCalleeSavedArea2Offset() const { return GPRCS2Offset; }
104 unsigned getDPRCalleeSavedAreaOffset() const { return DPRCSOffset; }
106 void setGPRCalleeSavedArea1Offset(unsigned o) { GPRCS1Offset = o; }
107 void setGPRCalleeSavedArea2Offset(unsigned o) { GPRCS2Offset = o; }
108 void setDPRCalleeSavedAreaOffset(unsigned o) { DPRCSOffset = o; }
110 unsigned getGPRCalleeSavedArea1Size() const { return GPRCS1Size; }
111 unsigned getGPRCalleeSavedArea2Size() const { return GPRCS2Size; }
112 unsigned getDPRCalleeSavedAreaSize() const { return DPRCSSize; }
114 void setGPRCalleeSavedArea1Size(unsigned s) { GPRCS1Size = s; }
115 void setGPRCalleeSavedArea2Size(unsigned s) { GPRCS2Size = s; }
116 void setDPRCalleeSavedAreaSize(unsigned s) { DPRCSSize = s; }
118 bool isGPRCalleeSavedArea1Frame(int fi) const {
119 if (fi < 0 || fi >= (int)GPRCS1Frames.size())
121 return GPRCS1Frames[fi];
123 bool isGPRCalleeSavedArea2Frame(int fi) const {
124 if (fi < 0 || fi >= (int)GPRCS2Frames.size())
126 return GPRCS2Frames[fi];
128 bool isDPRCalleeSavedAreaFrame(int fi) const {
129 if (fi < 0 || fi >= (int)DPRCSFrames.size())
131 return DPRCSFrames[fi];
134 void addGPRCalleeSavedArea1Frame(int fi) {
136 if (fi >= (int)GPRCS1Frames.size())
137 GPRCS1Frames.resize(fi+1);
138 GPRCS1Frames[fi] = true;
141 void addGPRCalleeSavedArea2Frame(int fi) {
143 if (fi >= (int)GPRCS2Frames.size())
144 GPRCS2Frames.resize(fi+1);
145 GPRCS2Frames[fi] = true;
148 void addDPRCalleeSavedAreaFrame(int fi) {
150 if (fi >= (int)DPRCSFrames.size())
151 DPRCSFrames.resize(fi+1);
152 DPRCSFrames[fi] = true;
156 unsigned createJumpTableUId() {
157 return JumpTableUId++;
160 } // End llvm namespace
162 #endif // ARMMACHINEFUNCTIONINFO_H