blob: 9cc0faf0469a0038d421b8f9b4eca45fcab491e2 [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
Akira Hatanakada0a3572011-05-20 01:17:58 +000017#include <utility>
Dan Gohmand68a0762009-01-05 17:59:02 +000018#include "llvm/ADT/SmallVector.h"
Bruno Cardoso Lopes2d4575e2007-08-28 05:04:41 +000019#include "llvm/ADT/VectorExtras.h"
Bruno Cardoso Lopes4215a592007-07-11 22:44:21 +000020#include "llvm/CodeGen/MachineFunction.h"
Bruno Cardoso Lopes2d4575e2007-08-28 05:04:41 +000021#include "llvm/CodeGen/MachineFrameInfo.h"
Bruno Cardoso Lopes4215a592007-07-11 22:44:21 +000022
23namespace llvm {
24
25/// MipsFunctionInfo - This class is derived from MachineFunction private
26/// Mips target-specific information for each MachineFunction.
27class MipsFunctionInfo : public MachineFunctionInfo {
28
29private:
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000030 /// SRetReturnReg - Some subtargets require that sret lowering includes
31 /// returning the value of the returned struct in a register. This field
32 /// holds the virtual register into which the sret argument is passed.
33 unsigned SRetReturnReg;
34
Dan Gohman99114052009-06-03 20:30:14 +000035 /// GlobalBaseReg - keeps track of the virtual register initialized for
36 /// use as the global base register. This is used for PIC in some PIC
37 /// relocation models.
38 unsigned GlobalBaseReg;
39
Dan Gohman1e93df62010-04-17 14:41:14 +000040 /// VarArgsFrameIndex - FrameIndex for start of varargs area.
41 int VarArgsFrameIndex;
42
Akira Hatanakada0a3572011-05-20 01:17:58 +000043 // Range of frame object indices.
44 // InArgFIRange: Range of indices of all frame objects created during call to
45 // LowerFormalArguments.
46 // OutArgFIRange: Range of indices of all frame objects created during call to
47 // LowerCall except for the frame object for restoring $gp.
48 std::pair<int, int> InArgFIRange, OutArgFIRange;
49 int GPFI; // Index of the frame object for restoring $gp
50 bool HasCall; // True if function has a function call.
Akira Hatanakaf15f4982011-05-25 17:52:48 +000051 unsigned MaxCallFrameSize;
Bruno Cardoso Lopes4215a592007-07-11 22:44:21 +000052public:
Che-Liang Chiouacf1d482010-09-28 10:06:53 +000053 MipsFunctionInfo(MachineFunction& MF)
Akira Hatanakaf8928c02011-05-23 20:34:30 +000054 : SRetReturnReg(0), GlobalBaseReg(0),
Akira Hatanakada0a3572011-05-20 01:17:58 +000055 VarArgsFrameIndex(0), InArgFIRange(std::make_pair(-1, 0)),
Akira Hatanaka6ffbf822011-05-20 20:11:17 +000056 OutArgFIRange(std::make_pair(-1, 0)), GPFI(0), HasCall(false),
Akira Hatanakaf15f4982011-05-25 17:52:48 +000057 MaxCallFrameSize(0)
Bruno Cardoso Lopes4215a592007-07-11 22:44:21 +000058 {}
59
Akira Hatanakada0a3572011-05-20 01:17:58 +000060 bool isInArgFI(int FI) const {
61 return FI <= InArgFIRange.first && FI >= InArgFIRange.second;
62 }
63 void setLastInArgFI(int FI) { InArgFIRange.second = FI; }
64
65 bool isOutArgFI(int FI) const {
66 return FI <= OutArgFIRange.first && FI >= OutArgFIRange.second;
67 }
68 void extendOutArgFIRange(int FirstFI, int LastFI) {
69 if (!OutArgFIRange.second)
70 // this must be the first time this function was called.
71 OutArgFIRange.first = FirstFI;
72 OutArgFIRange.second = LastFI;
73 }
74
Akira Hatanaka69c19f72011-05-23 20:16:59 +000075 int getGPFI() const { return GPFI; }
76 void setGPFI(int FI) { GPFI = FI; }
77 bool needGPSaveRestore() const { return getGPFI(); }
Akira Hatanakada0a3572011-05-20 01:17:58 +000078 bool isGPFI(int FI) const { return GPFI && GPFI == FI; }
Bruno Cardoso Lopes0a604002007-10-09 03:01:19 +000079
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000080 unsigned getSRetReturnReg() const { return SRetReturnReg; }
81 void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
Dan Gohman99114052009-06-03 20:30:14 +000082
83 unsigned getGlobalBaseReg() const { return GlobalBaseReg; }
84 void setGlobalBaseReg(unsigned Reg) { GlobalBaseReg = Reg; }
Dan Gohman1e93df62010-04-17 14:41:14 +000085
86 int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
87 void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
Akira Hatanakada0a3572011-05-20 01:17:58 +000088
Benjamin Kramer6e35e4c2011-05-20 09:20:25 +000089 bool hasCall() const { return HasCall; }
Akira Hatanakada0a3572011-05-20 01:17:58 +000090 void setHasCall() { HasCall = true; }
Akira Hatanaka6ffbf822011-05-20 20:11:17 +000091
Akira Hatanakaf15f4982011-05-25 17:52:48 +000092 unsigned getMaxCallFrameSize() const { return MaxCallFrameSize; }
93 void setMaxCallFrameSize(unsigned S) { MaxCallFrameSize = S; }
Bruno Cardoso Lopes4215a592007-07-11 22:44:21 +000094};
95
96} // end of namespace llvm
97
Bruno Cardoso Lopes2d4575e2007-08-28 05:04:41 +000098#endif // MIPS_MACHINE_FUNCTION_INFO_H