blob: 43bf6827eefb3a8f6b7246e9d3c1577d0415257d [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"
Akira Hatanaka479a7782013-09-27 22:30:36 +000018#include "llvm/ADT/StringMap.h"
19#include "llvm/ADT/ValueMap.h"
Bruno Cardoso Lopes2d4575e2007-08-28 05:04:41 +000020#include "llvm/CodeGen/MachineFrameInfo.h"
Chandler Carrutha1514e22012-12-04 07:12:27 +000021#include "llvm/CodeGen/MachineFunction.h"
Akira Hatanaka479a7782013-09-27 22:30:36 +000022#include "llvm/CodeGen/MachineMemOperand.h"
23#include "llvm/CodeGen/PseudoSourceValue.h"
24#include "llvm/IR/GlobalValue.h"
Akira Hatanakaa76220a2012-06-14 01:15:36 +000025#include "llvm/Target/TargetFrameLowering.h"
26#include "llvm/Target/TargetMachine.h"
Craig Topper79aa3412012-03-17 18:46:09 +000027#include <utility>
Bruno Cardoso Lopes4215a592007-07-11 22:44:21 +000028
29namespace llvm {
30
Akira Hatanaka479a7782013-09-27 22:30:36 +000031/// \brief A class derived from PseudoSourceValue that represents a GOT entry
32/// resolved by lazy-binding.
33class MipsCallEntry : public PseudoSourceValue {
34public:
35 explicit MipsCallEntry(const StringRef &N);
36 explicit MipsCallEntry(const GlobalValue *V);
37 virtual bool isConstant(const MachineFrameInfo *) const;
38 virtual bool isAliased(const MachineFrameInfo *) const;
39 virtual bool mayAlias(const MachineFrameInfo *) const;
40
41private:
42 virtual void printCustom(raw_ostream &O) const;
43#ifndef NDEBUG
44 std::string Name;
45 const GlobalValue *Val;
46#endif
47};
48
Bruno Cardoso Lopes4215a592007-07-11 22:44:21 +000049/// MipsFunctionInfo - This class is derived from MachineFunction private
50/// Mips target-specific information for each MachineFunction.
51class MipsFunctionInfo : public MachineFunctionInfo {
Bruno Cardoso Lopes4215a592007-07-11 22:44:21 +000052public:
Che-Liang Chiouacf1d482010-09-28 10:06:53 +000053 MipsFunctionInfo(MachineFunction& MF)
Reed Kotlerf99998a2012-10-28 06:02:37 +000054 : MF(MF), SRetReturnReg(0), GlobalBaseReg(0), Mips16SPAliasReg(0),
Akira Hatanaka544cc212013-01-30 00:26:49 +000055 VarArgsFrameIndex(0), CallsEhReturn(false)
Bruno Cardoso Lopes4215a592007-07-11 22:44:21 +000056 {}
57
Akira Hatanaka479a7782013-09-27 22:30:36 +000058 ~MipsFunctionInfo();
59
Bruno Cardoso Lopes225ca9c2008-07-05 19:05:21 +000060 unsigned getSRetReturnReg() const { return SRetReturnReg; }
61 void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
Dan Gohman99114052009-06-03 20:30:14 +000062
Akira Hatanaka648f00c2012-02-24 22:34:47 +000063 bool globalBaseRegSet() const;
64 unsigned getGlobalBaseReg();
Dan Gohman1e93df62010-04-17 14:41:14 +000065
Reed Kotlerf99998a2012-10-28 06:02:37 +000066 bool mips16SPAliasRegSet() const;
67 unsigned getMips16SPAliasReg();
68
Dan Gohman1e93df62010-04-17 14:41:14 +000069 int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
70 void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
Akira Hatanakada0a3572011-05-20 01:17:58 +000071
Akira Hatanakab33b34a2012-10-30 19:37:25 +000072 bool hasByvalArg() const { return HasByvalArg; }
Akira Hatanaka70852212012-11-07 19:04:26 +000073 void setFormalArgInfo(unsigned Size, bool HasByval) {
74 IncomingArgSize = Size;
Akira Hatanakab33b34a2012-10-30 19:37:25 +000075 HasByvalArg = HasByval;
76 }
Akira Hatanaka294166d2012-11-02 21:03:58 +000077
78 unsigned getIncomingArgSize() const { return IncomingArgSize; }
Akira Hatanaka544cc212013-01-30 00:26:49 +000079
80 bool callsEhReturn() const { return CallsEhReturn; }
81 void setCallsEhReturn() { CallsEhReturn = true; }
82
83 void createEhDataRegsFI();
84 int getEhDataRegFI(unsigned Reg) const { return EhDataRegFI[Reg]; }
85 bool isEhDataRegFI(int FI) const;
86
Akira Hatanaka479a7782013-09-27 22:30:36 +000087 /// \brief Create a MachinePointerInfo that has a MipsCallEntr object
88 /// representing a GOT entry for an external function.
89 MachinePointerInfo callPtrInfo(const StringRef &Name);
90
91 /// \brief Create a MachinePointerInfo that has a MipsCallEntr object
92 /// representing a GOT entry for a global function.
93 MachinePointerInfo callPtrInfo(const GlobalValue *Val);
94
Akira Hatanakad47aa3a2013-09-25 00:34:42 +000095private:
96 virtual void anchor();
97
98 MachineFunction& MF;
99 /// SRetReturnReg - Some subtargets require that sret lowering includes
100 /// returning the value of the returned struct in a register. This field
101 /// holds the virtual register into which the sret argument is passed.
102 unsigned SRetReturnReg;
103
104 /// GlobalBaseReg - keeps track of the virtual register initialized for
105 /// use as the global base register. This is used for PIC in some PIC
106 /// relocation models.
107 unsigned GlobalBaseReg;
108
109 /// Mips16SPAliasReg - keeps track of the virtual register initialized for
110 /// use as an alias for SP for use in load/store of halfword/byte from/to
111 /// the stack
112 unsigned Mips16SPAliasReg;
113
114 /// VarArgsFrameIndex - FrameIndex for start of varargs area.
115 int VarArgsFrameIndex;
116
117 /// True if function has a byval argument.
118 bool HasByvalArg;
119
120 /// Size of incoming argument area.
121 unsigned IncomingArgSize;
122
123 /// CallsEhReturn - Whether the function calls llvm.eh.return.
124 bool CallsEhReturn;
125
126 /// Frame objects for spilling eh data registers.
127 int EhDataRegFI[4];
Akira Hatanaka479a7782013-09-27 22:30:36 +0000128
129 /// MipsCallEntry maps.
130 StringMap<const MipsCallEntry *> ExternalCallEntries;
131 ValueMap<const GlobalValue *, const MipsCallEntry *> GlobalCallEntries;
Bruno Cardoso Lopes4215a592007-07-11 22:44:21 +0000132};
133
134} // end of namespace llvm
135
Bruno Cardoso Lopes2d4575e2007-08-28 05:04:41 +0000136#endif // MIPS_MACHINE_FUNCTION_INFO_H