blob: 57ff06948afd5952ea93a6b12d8d04360b4d95a9 [file] [log] [blame]
Akira Hatanakae2489122011-04-15 21:51:11 +00001//===-- MipsMachineFunctionInfo.h - Private data used for Mips ----*- C++ -*-=//
Bruno Cardoso Lopes753e3702007-07-11 22:44:21 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-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 Lopes753e3702007-07-11 22:44:21 +00007//
Akira Hatanakae2489122011-04-15 21:51:11 +00008//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes753e3702007-07-11 22:44:21 +00009//
10// This file declares the Mips specific subclass of MachineFunctionInfo.
11//
Akira Hatanakae2489122011-04-15 21:51:11 +000012//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes753e3702007-07-11 22:44:21 +000013
14#ifndef MIPS_MACHINE_FUNCTION_INFO_H
15#define MIPS_MACHINE_FUNCTION_INFO_H
16
Akira Hatanakad738c0f2011-05-20 01:17:58 +000017#include <utility>
Dan Gohman906152a2009-01-05 17:59:02 +000018#include "llvm/ADT/SmallVector.h"
Bruno Cardoso Lopes753e3702007-07-11 22:44:21 +000019#include "llvm/CodeGen/MachineFunction.h"
Bruno Cardoso Lopesf55a7852007-08-28 05:04:41 +000020#include "llvm/CodeGen/MachineFrameInfo.h"
Bruno Cardoso Lopes753e3702007-07-11 22:44:21 +000021
22namespace llvm {
23
24/// MipsFunctionInfo - This class is derived from MachineFunction private
25/// Mips target-specific information for each MachineFunction.
26class MipsFunctionInfo : public MachineFunctionInfo {
David Blaikiea379b1812011-12-20 02:50:00 +000027 virtual void anchor();
Bruno Cardoso Lopes753e3702007-07-11 22:44:21 +000028
Akira Hatanaka4c406e72011-06-21 00:40:49 +000029 MachineFunction& MF;
Bruno Cardoso Lopesc9c3f492008-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 Gohmand5ca70642009-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 Gohman31ae5862010-04-17 14:41:14 +000040 /// VarArgsFrameIndex - FrameIndex for start of varargs area.
41 int VarArgsFrameIndex;
42
Akira Hatanakad738c0f2011-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
Jia Liuf54f60f2012-02-28 07:46:26 +000047 // LowerCall except for the frame object for restoring $gp.
Akira Hatanakad738c0f2011-05-20 01:17:58 +000048 std::pair<int, int> InArgFIRange, OutArgFIRange;
Jia Liuf54f60f2012-02-28 07:46:26 +000049 int GPFI; // Index of the frame object for restoring $gp
50 mutable int DynAllocFI; // Frame index of dynamically allocated stack area.
Akira Hatanaka92a26d42011-05-25 17:52:48 +000051 unsigned MaxCallFrameSize;
Bruno Cardoso Lopes98fc4c82011-05-31 02:54:07 +000052
Bruno Cardoso Lopes753e3702007-07-11 22:44:21 +000053public:
Che-Liang Chioue084cff2010-09-28 10:06:53 +000054 MipsFunctionInfo(MachineFunction& MF)
Akira Hatanaka4c406e72011-06-21 00:40:49 +000055 : MF(MF), SRetReturnReg(0), GlobalBaseReg(0),
Akira Hatanakad738c0f2011-05-20 01:17:58 +000056 VarArgsFrameIndex(0), InArgFIRange(std::make_pair(-1, 0)),
Akira Hatanaka4c406e72011-06-21 00:40:49 +000057 OutArgFIRange(std::make_pair(-1, 0)), GPFI(0), DynAllocFI(0),
Akira Hatanakad673cfe2011-11-14 18:56:20 +000058 MaxCallFrameSize(0)
Bruno Cardoso Lopes753e3702007-07-11 22:44:21 +000059 {}
60
Akira Hatanakad738c0f2011-05-20 01:17:58 +000061 bool isInArgFI(int FI) const {
62 return FI <= InArgFIRange.first && FI >= InArgFIRange.second;
63 }
64 void setLastInArgFI(int FI) { InArgFIRange.second = FI; }
65
Jia Liuf54f60f2012-02-28 07:46:26 +000066 bool isOutArgFI(int FI) const {
Akira Hatanakad738c0f2011-05-20 01:17:58 +000067 return FI <= OutArgFIRange.first && FI >= OutArgFIRange.second;
68 }
69 void extendOutArgFIRange(int FirstFI, int LastFI) {
70 if (!OutArgFIRange.second)
71 // this must be the first time this function was called.
72 OutArgFIRange.first = FirstFI;
73 OutArgFIRange.second = LastFI;
74 }
75
Akira Hatanakaf9e57502011-05-23 20:16:59 +000076 int getGPFI() const { return GPFI; }
77 void setGPFI(int FI) { GPFI = FI; }
78 bool needGPSaveRestore() const { return getGPFI(); }
Akira Hatanakad738c0f2011-05-20 01:17:58 +000079 bool isGPFI(int FI) const { return GPFI && GPFI == FI; }
Bruno Cardoso Lopes35d86e62007-10-09 03:01:19 +000080
Akira Hatanaka4c406e72011-06-21 00:40:49 +000081 // The first call to this function creates a frame object for dynamically
82 // allocated stack area.
83 int getDynAllocFI() const {
84 if (!DynAllocFI)
85 DynAllocFI = MF.getFrameInfo()->CreateFixedObject(4, 0, true);
86
87 return DynAllocFI;
88 }
89 bool isDynAllocFI(int FI) const { return DynAllocFI && DynAllocFI == FI; }
90
Bruno Cardoso Lopesc9c3f492008-07-05 19:05:21 +000091 unsigned getSRetReturnReg() const { return SRetReturnReg; }
92 void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
Dan Gohmand5ca70642009-06-03 20:30:14 +000093
Akira Hatanakab049aef2012-02-24 22:34:47 +000094 bool globalBaseRegFixed() const;
95 bool globalBaseRegSet() const;
96 unsigned getGlobalBaseReg();
Dan Gohman31ae5862010-04-17 14:41:14 +000097
98 int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
99 void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
Akira Hatanakad738c0f2011-05-20 01:17:58 +0000100
Akira Hatanaka92a26d42011-05-25 17:52:48 +0000101 unsigned getMaxCallFrameSize() const { return MaxCallFrameSize; }
102 void setMaxCallFrameSize(unsigned S) { MaxCallFrameSize = S; }
Bruno Cardoso Lopes753e3702007-07-11 22:44:21 +0000103};
104
105} // end of namespace llvm
106
Bruno Cardoso Lopesf55a7852007-08-28 05:04:41 +0000107#endif // MIPS_MACHINE_FUNCTION_INFO_H