blob: 36c2e5948584bbdc89c797e29c8dd1f8280789c2 [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 Hatanakaa76220a2012-06-14 01:15:36 +000017#include "MipsSubtarget.h"
Bruno Cardoso Lopes2d4575e2007-08-28 05:04:41 +000018#include "llvm/CodeGen/MachineFrameInfo.h"
Chandler Carrutha1514e22012-12-04 07:12:27 +000019#include "llvm/CodeGen/MachineFunction.h"
Akira Hatanakaa76220a2012-06-14 01:15:36 +000020#include "llvm/Target/TargetFrameLowering.h"
21#include "llvm/Target/TargetMachine.h"
Craig Topper79aa3412012-03-17 18:46:09 +000022#include <utility>
Bruno Cardoso Lopes4215a592007-07-11 22:44:21 +000023
24namespace llvm {
25
26/// MipsFunctionInfo - This class is derived from MachineFunction private
27/// Mips target-specific information for each MachineFunction.
28class MipsFunctionInfo : public MachineFunctionInfo {
Bruno Cardoso Lopes4215a592007-07-11 22:44:21 +000029public:
Che-Liang Chiouacf1d482010-09-28 10:06:53 +000030 MipsFunctionInfo(MachineFunction& MF)
Reed Kotlerf99998a2012-10-28 06:02:37 +000031 : MF(MF), SRetReturnReg(0), GlobalBaseReg(0), Mips16SPAliasReg(0),
Akira Hatanaka544cc212013-01-30 00:26:49 +000032 VarArgsFrameIndex(0), CallsEhReturn(false)
Bruno Cardoso Lopes4215a592007-07-11 22:44:21 +000033 {}
34
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000035 unsigned getSRetReturnReg() const { return SRetReturnReg; }
36 void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
Dan Gohman99114052009-06-03 20:30:14 +000037
Akira Hatanaka648f00c2012-02-24 22:34:47 +000038 bool globalBaseRegSet() const;
39 unsigned getGlobalBaseReg();
Dan Gohman1e93df62010-04-17 14:41:14 +000040
Reed Kotlerf99998a2012-10-28 06:02:37 +000041 bool mips16SPAliasRegSet() const;
42 unsigned getMips16SPAliasReg();
43
Dan Gohman1e93df62010-04-17 14:41:14 +000044 int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
45 void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
Akira Hatanakada0a3572011-05-20 01:17:58 +000046
Akira Hatanakab33b34a2012-10-30 19:37:25 +000047 bool hasByvalArg() const { return HasByvalArg; }
Akira Hatanaka70852212012-11-07 19:04:26 +000048 void setFormalArgInfo(unsigned Size, bool HasByval) {
49 IncomingArgSize = Size;
Akira Hatanakab33b34a2012-10-30 19:37:25 +000050 HasByvalArg = HasByval;
51 }
Akira Hatanaka294166d2012-11-02 21:03:58 +000052
53 unsigned getIncomingArgSize() const { return IncomingArgSize; }
Akira Hatanaka544cc212013-01-30 00:26:49 +000054
55 bool callsEhReturn() const { return CallsEhReturn; }
56 void setCallsEhReturn() { CallsEhReturn = true; }
57
58 void createEhDataRegsFI();
59 int getEhDataRegFI(unsigned Reg) const { return EhDataRegFI[Reg]; }
60 bool isEhDataRegFI(int FI) const;
61
Akira Hatanakad47aa3a2013-09-25 00:34:42 +000062private:
63 virtual void anchor();
64
65 MachineFunction& MF;
66 /// SRetReturnReg - Some subtargets require that sret lowering includes
67 /// returning the value of the returned struct in a register. This field
68 /// holds the virtual register into which the sret argument is passed.
69 unsigned SRetReturnReg;
70
71 /// GlobalBaseReg - keeps track of the virtual register initialized for
72 /// use as the global base register. This is used for PIC in some PIC
73 /// relocation models.
74 unsigned GlobalBaseReg;
75
76 /// Mips16SPAliasReg - keeps track of the virtual register initialized for
77 /// use as an alias for SP for use in load/store of halfword/byte from/to
78 /// the stack
79 unsigned Mips16SPAliasReg;
80
81 /// VarArgsFrameIndex - FrameIndex for start of varargs area.
82 int VarArgsFrameIndex;
83
84 /// True if function has a byval argument.
85 bool HasByvalArg;
86
87 /// Size of incoming argument area.
88 unsigned IncomingArgSize;
89
90 /// CallsEhReturn - Whether the function calls llvm.eh.return.
91 bool CallsEhReturn;
92
93 /// Frame objects for spilling eh data registers.
94 int EhDataRegFI[4];
Bruno Cardoso Lopes4215a592007-07-11 22:44:21 +000095};
96
97} // end of namespace llvm
98
Bruno Cardoso Lopes2d4575e2007-08-28 05:04:41 +000099#endif // MIPS_MACHINE_FUNCTION_INFO_H