- In thumb mode, if size of MachineFunction is >= 2048, force LR to be
[oota-llvm.git] / lib / Target / ARM / ARMMachineFunctionInfo.h
1 //====- ARMMachineFuctionInfo.h - ARM machine function info -----*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
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.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares ARM-specific per-machine-function information.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef ARMMACHINEFUNCTIONINFO_H
15 #define ARMMACHINEFUNCTIONINFO_H
16
17 #include "ARMSubtarget.h"
18 #include "llvm/CodeGen/MachineFunction.h"
19 #include "llvm/Target/TargetMachine.h"
20
21 namespace llvm {
22
23 /// ARMFunctionInfo - This class is derived from MachineFunction private
24 /// ARM target-specific information for each MachineFunction.
25 class ARMFunctionInfo : public MachineFunctionInfo {
26
27   /// isThumb - True if this function is compiled under Thumb mode.
28   ///
29   bool isThumb;
30
31   /// VarArgsRegSaveSize - Size of the register save area for vararg functions.
32   ///
33   unsigned VarArgsRegSaveSize;
34
35   /// HasStackFrame - True if this function has a stack frame. Set by
36   /// processFunctionBeforeCalleeSavedScan().
37   bool HasStackFrame;
38
39   /// LRSForceSpilled - True if the LR register has been for spilled to enable
40   /// far jump.
41   bool LRForceSpilled;
42
43   /// FramePtrSpillOffset - If HasStackFrame, this records the frame pointer
44   /// spill stack offset.
45   unsigned FramePtrSpillOffset;
46
47   /// GPRCS1Offset, GPRCS2Offset, DPRCSOffset - Starting offset of callee saved
48   /// register spills areas. For Mac OS X:
49   ///
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;
57   unsigned DPRCSOffset;
58
59   /// GPRCS1Size, GPRCS2Size, DPRCSSize - Sizes of callee saved register spills
60   /// areas.
61   unsigned GPRCS1Size;
62   unsigned GPRCS2Size;
63   unsigned DPRCSSize;
64
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;
70
71   /// JumpTableUId - Unique id for jumptables.
72   ///
73   unsigned JumpTableUId;
74
75 public:
76   ARMFunctionInfo() :
77     isThumb(false),
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) {}
81
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) {}
87
88   bool isThumbFunction() const { return isThumb; }
89
90   unsigned getVarArgsRegSaveSize() const { return VarArgsRegSaveSize; }
91   void setVarArgsRegSaveSize(unsigned s) { VarArgsRegSaveSize = s; }
92
93   bool hasStackFrame() const { return HasStackFrame; }
94   void setHasStackFrame(bool s) { HasStackFrame = s; }
95
96   bool isLRForceSpilled() const { return LRForceSpilled; }
97   void setLRIsForceSpilled(bool s) { LRForceSpilled = s; }
98
99   unsigned getFramePtrSpillOffset() const { return FramePtrSpillOffset; }
100   void setFramePtrSpillOffset(unsigned o) { FramePtrSpillOffset = o; }
101   
102   unsigned getGPRCalleeSavedArea1Offset() const { return GPRCS1Offset; }
103   unsigned getGPRCalleeSavedArea2Offset() const { return GPRCS2Offset; }
104   unsigned getDPRCalleeSavedAreaOffset()  const { return DPRCSOffset; }
105
106   void setGPRCalleeSavedArea1Offset(unsigned o) { GPRCS1Offset = o; }
107   void setGPRCalleeSavedArea2Offset(unsigned o) { GPRCS2Offset = o; }
108   void setDPRCalleeSavedAreaOffset(unsigned o)  { DPRCSOffset = o; }
109
110   unsigned getGPRCalleeSavedArea1Size() const { return GPRCS1Size; }
111   unsigned getGPRCalleeSavedArea2Size() const { return GPRCS2Size; }
112   unsigned getDPRCalleeSavedAreaSize()  const { return DPRCSSize; }
113
114   void setGPRCalleeSavedArea1Size(unsigned s) { GPRCS1Size = s; }
115   void setGPRCalleeSavedArea2Size(unsigned s) { GPRCS2Size = s; }
116   void setDPRCalleeSavedAreaSize(unsigned s)  { DPRCSSize = s; }
117
118   bool isGPRCalleeSavedArea1Frame(int fi) const {
119     if (fi < 0 || fi >= (int)GPRCS1Frames.size())
120       return false;
121     return GPRCS1Frames[fi];
122   }
123   bool isGPRCalleeSavedArea2Frame(int fi) const {
124     if (fi < 0 || fi >= (int)GPRCS2Frames.size())
125       return false;
126     return GPRCS2Frames[fi];
127   }
128   bool isDPRCalleeSavedAreaFrame(int fi) const {
129     if (fi < 0 || fi >= (int)DPRCSFrames.size())
130       return false;
131     return DPRCSFrames[fi];
132   }
133
134   void addGPRCalleeSavedArea1Frame(int fi) {
135     if (fi >= 0) {
136       if (fi >= (int)GPRCS1Frames.size())
137         GPRCS1Frames.resize(fi+1);
138       GPRCS1Frames[fi] = true;
139     }
140   }
141   void addGPRCalleeSavedArea2Frame(int fi) {
142     if (fi >= 0) {
143       if (fi >= (int)GPRCS2Frames.size())
144         GPRCS2Frames.resize(fi+1);
145       GPRCS2Frames[fi] = true;
146     }
147   }
148   void addDPRCalleeSavedAreaFrame(int fi) {
149     if (fi >= 0) {
150       if (fi >= (int)DPRCSFrames.size())
151         DPRCSFrames.resize(fi+1);
152       DPRCSFrames[fi] = true;
153     }
154   }
155
156   unsigned createJumpTableUId() {
157     return JumpTableUId++;
158   }
159 };
160 } // End llvm namespace
161
162 #endif // ARMMACHINEFUNCTIONINFO_H