blob: 0fde55cb62e86e2c3de39e31ab57f2bea67dfecd [file] [log] [blame]
Akira Hatanaka4552c9a2011-04-15 21:51:11 +00001//===-- MipsMachineFunctionInfo.h - Private data used for Mips ----*- C++ -*-=//
Bruno Cardoso Lopes4215a592007-07-11 22:44:21 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Bruno Cardoso Lopes4215a592007-07-11 22:44:21 +00007//
Akira Hatanaka4552c9a2011-04-15 21:51:11 +00008//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes4215a592007-07-11 22:44:21 +00009//
10// This file declares the Mips specific subclass of MachineFunctionInfo.
11//
Akira Hatanaka4552c9a2011-04-15 21:51:11 +000012//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes4215a592007-07-11 22:44:21 +000013
14#ifndef MIPS_MACHINE_FUNCTION_INFO_H
15#define MIPS_MACHINE_FUNCTION_INFO_H
16
17#include "llvm/CodeGen/MachineFunction.h"
Bruno Cardoso Lopes2d4575e2007-08-28 05:04:41 +000018#include "llvm/CodeGen/MachineFrameInfo.h"
Craig Topper79aa3412012-03-17 18:46:09 +000019#include <utility>
Bruno Cardoso Lopes4215a592007-07-11 22:44:21 +000020
21namespace llvm {
22
23/// MipsFunctionInfo - This class is derived from MachineFunction private
24/// Mips target-specific information for each MachineFunction.
25class MipsFunctionInfo : public MachineFunctionInfo {
David Blaikie2d24e2a2011-12-20 02:50:00 +000026 virtual void anchor();
Bruno Cardoso Lopes4215a592007-07-11 22:44:21 +000027
Akira Hatanaka21afc632011-06-21 00:40:49 +000028 MachineFunction& MF;
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000029 /// SRetReturnReg - Some subtargets require that sret lowering includes
30 /// returning the value of the returned struct in a register. This field
31 /// holds the virtual register into which the sret argument is passed.
32 unsigned SRetReturnReg;
33
Dan Gohman99114052009-06-03 20:30:14 +000034 /// GlobalBaseReg - keeps track of the virtual register initialized for
35 /// use as the global base register. This is used for PIC in some PIC
36 /// relocation models.
37 unsigned GlobalBaseReg;
38
Dan Gohman1e93df62010-04-17 14:41:14 +000039 /// VarArgsFrameIndex - FrameIndex for start of varargs area.
40 int VarArgsFrameIndex;
41
Akira Hatanakada0a3572011-05-20 01:17:58 +000042 // Range of frame object indices.
43 // InArgFIRange: Range of indices of all frame objects created during call to
44 // LowerFormalArguments.
45 // OutArgFIRange: Range of indices of all frame objects created during call to
Jia Liubb481f82012-02-28 07:46:26 +000046 // LowerCall except for the frame object for restoring $gp.
Akira Hatanakada0a3572011-05-20 01:17:58 +000047 std::pair<int, int> InArgFIRange, OutArgFIRange;
Jia Liubb481f82012-02-28 07:46:26 +000048 int GPFI; // Index of the frame object for restoring $gp
49 mutable int DynAllocFI; // Frame index of dynamically allocated stack area.
Akira Hatanakaf15f4982011-05-25 17:52:48 +000050 unsigned MaxCallFrameSize;
Bruno Cardoso Lopes4e694c92011-05-31 02:54:07 +000051
Akira Hatanaka95f95a72012-03-27 19:08:42 +000052 bool EmitNOAT;
53
Bruno Cardoso Lopes4215a592007-07-11 22:44:21 +000054public:
Che-Liang Chiouacf1d482010-09-28 10:06:53 +000055 MipsFunctionInfo(MachineFunction& MF)
Akira Hatanaka21afc632011-06-21 00:40:49 +000056 : MF(MF), SRetReturnReg(0), GlobalBaseReg(0),
Akira Hatanakada0a3572011-05-20 01:17:58 +000057 VarArgsFrameIndex(0), InArgFIRange(std::make_pair(-1, 0)),
Akira Hatanaka21afc632011-06-21 00:40:49 +000058 OutArgFIRange(std::make_pair(-1, 0)), GPFI(0), DynAllocFI(0),
Akira Hatanaka95f95a72012-03-27 19:08:42 +000059 MaxCallFrameSize(0), EmitNOAT(false)
Bruno Cardoso Lopes4215a592007-07-11 22:44:21 +000060 {}
61
Akira Hatanakada0a3572011-05-20 01:17:58 +000062 bool isInArgFI(int FI) const {
63 return FI <= InArgFIRange.first && FI >= InArgFIRange.second;
64 }
65 void setLastInArgFI(int FI) { InArgFIRange.second = FI; }
66
Jia Liubb481f82012-02-28 07:46:26 +000067 bool isOutArgFI(int FI) const {
Akira Hatanakada0a3572011-05-20 01:17:58 +000068 return FI <= OutArgFIRange.first && FI >= OutArgFIRange.second;
69 }
70 void extendOutArgFIRange(int FirstFI, int LastFI) {
71 if (!OutArgFIRange.second)
72 // this must be the first time this function was called.
73 OutArgFIRange.first = FirstFI;
74 OutArgFIRange.second = LastFI;
75 }
76
Akira Hatanaka69c19f72011-05-23 20:16:59 +000077 int getGPFI() const { return GPFI; }
78 void setGPFI(int FI) { GPFI = FI; }
79 bool needGPSaveRestore() const { return getGPFI(); }
Akira Hatanakada0a3572011-05-20 01:17:58 +000080 bool isGPFI(int FI) const { return GPFI && GPFI == FI; }
Bruno Cardoso Lopes0a604002007-10-09 03:01:19 +000081
Akira Hatanaka21afc632011-06-21 00:40:49 +000082 // The first call to this function creates a frame object for dynamically
83 // allocated stack area.
84 int getDynAllocFI() const {
85 if (!DynAllocFI)
86 DynAllocFI = MF.getFrameInfo()->CreateFixedObject(4, 0, true);
87
88 return DynAllocFI;
89 }
90 bool isDynAllocFI(int FI) const { return DynAllocFI && DynAllocFI == FI; }
91
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000092 unsigned getSRetReturnReg() const { return SRetReturnReg; }
93 void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
Dan Gohman99114052009-06-03 20:30:14 +000094
Akira Hatanaka648f00c2012-02-24 22:34:47 +000095 bool globalBaseRegFixed() const;
96 bool globalBaseRegSet() const;
97 unsigned getGlobalBaseReg();
Dan Gohman1e93df62010-04-17 14:41:14 +000098
99 int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
100 void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
Akira Hatanakada0a3572011-05-20 01:17:58 +0000101
Akira Hatanakaf15f4982011-05-25 17:52:48 +0000102 unsigned getMaxCallFrameSize() const { return MaxCallFrameSize; }
103 void setMaxCallFrameSize(unsigned S) { MaxCallFrameSize = S; }
Akira Hatanaka95f95a72012-03-27 19:08:42 +0000104
105 bool getEmitNOAT() const { return EmitNOAT; }
106 void setEmitNOAT() { EmitNOAT = true; }
Bruno Cardoso Lopes4215a592007-07-11 22:44:21 +0000107};
108
109} // end of namespace llvm
110
Bruno Cardoso Lopes2d4575e2007-08-28 05:04:41 +0000111#endif // MIPS_MACHINE_FUNCTION_INFO_H