blob: a2f6ee03604fc0fa24d8aaa5c5f62d7c001cb20d [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
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000014#ifndef LLVM_LIB_TARGET_MIPS_MIPSMACHINEFUNCTION_H
15#define LLVM_LIB_TARGET_MIPS_MIPSMACHINEFUNCTION_H
Bruno Cardoso Lopes753e3702007-07-11 22:44:21 +000016
Reed Kotler4cdaa7d2014-02-14 19:16:39 +000017#include "Mips16HardFloatInfo.h"
Bruno Cardoso Lopesf55a7852007-08-28 05:04:41 +000018#include "llvm/CodeGen/MachineFrameInfo.h"
Chandler Carruth802d7552012-12-04 07:12:27 +000019#include "llvm/CodeGen/MachineFunction.h"
Akira Hatanakae0657b22013-09-27 22:30:36 +000020#include "llvm/CodeGen/MachineMemOperand.h"
21#include "llvm/CodeGen/PseudoSourceValue.h"
Chandler Carrutha4ea2692014-03-04 11:26:31 +000022#include "llvm/IR/ValueMap.h"
Akira Hatanaka51c70c62012-06-14 01:15:36 +000023#include "llvm/Target/TargetFrameLowering.h"
24#include "llvm/Target/TargetMachine.h"
Reed Kotler4cdaa7d2014-02-14 19:16:39 +000025#include <map>
26#include <string>
Craig Topperb25fda92012-03-17 18:46:09 +000027#include <utility>
Bruno Cardoso Lopes753e3702007-07-11 22:44:21 +000028
29namespace llvm {
30
31/// MipsFunctionInfo - This class is derived from MachineFunction private
32/// Mips target-specific information for each MachineFunction.
33class MipsFunctionInfo : public MachineFunctionInfo {
Bruno Cardoso Lopes753e3702007-07-11 22:44:21 +000034public:
Reed Kotler4cdaa7d2014-02-14 19:16:39 +000035 MipsFunctionInfo(MachineFunction &MF)
36 : MF(MF), SRetReturnReg(0), GlobalBaseReg(0), Mips16SPAliasReg(0),
Vasileios Kalintiris43dff0c2015-10-26 12:38:43 +000037 VarArgsFrameIndex(0), CallsEhReturn(false), IsISR(false), SaveS2(false),
Daniel Sanders7ddb0ab2014-07-14 13:08:14 +000038 MoveF64ViaSpillFI(-1) {}
Bruno Cardoso Lopes753e3702007-07-11 22:44:21 +000039
Akira Hatanakae0657b22013-09-27 22:30:36 +000040 ~MipsFunctionInfo();
41
Bruno Cardoso Lopesc9c3f492008-07-05 19:05:21 +000042 unsigned getSRetReturnReg() const { return SRetReturnReg; }
43 void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
Dan Gohmand5ca70642009-06-03 20:30:14 +000044
Akira Hatanakab049aef2012-02-24 22:34:47 +000045 bool globalBaseRegSet() const;
46 unsigned getGlobalBaseReg();
Dan Gohman31ae5862010-04-17 14:41:14 +000047
Reed Kotler3589dd72012-10-28 06:02:37 +000048 bool mips16SPAliasRegSet() const;
49 unsigned getMips16SPAliasReg();
50
Dan Gohman31ae5862010-04-17 14:41:14 +000051 int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
52 void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
Akira Hatanakad738c0f2011-05-20 01:17:58 +000053
Akira Hatanaka4866fe12012-10-30 19:37:25 +000054 bool hasByvalArg() const { return HasByvalArg; }
Akira Hatanaka40f2d302012-11-07 19:04:26 +000055 void setFormalArgInfo(unsigned Size, bool HasByval) {
56 IncomingArgSize = Size;
Akira Hatanaka4866fe12012-10-30 19:37:25 +000057 HasByvalArg = HasByval;
58 }
Akira Hatanaka719df282012-11-02 21:03:58 +000059
60 unsigned getIncomingArgSize() const { return IncomingArgSize; }
Akira Hatanakac0b02062013-01-30 00:26:49 +000061
62 bool callsEhReturn() const { return CallsEhReturn; }
63 void setCallsEhReturn() { CallsEhReturn = true; }
64
65 void createEhDataRegsFI();
66 int getEhDataRegFI(unsigned Reg) const { return EhDataRegFI[Reg]; }
67 bool isEhDataRegFI(int FI) const;
68
Alex Lorenz5659a2f2015-08-11 23:23:17 +000069 /// Create a MachinePointerInfo that has an ExternalSymbolPseudoSourceValue
70 /// object representing a GOT entry for an external function.
71 MachinePointerInfo callPtrInfo(const char *ES);
Akira Hatanakae0657b22013-09-27 22:30:36 +000072
Vasileios Kalintiris43dff0c2015-10-26 12:38:43 +000073 // Functions with the "interrupt" attribute require special prologues,
74 // epilogues and additional spill slots.
75 bool isISR() const { return IsISR; }
76 void setISR() { IsISR = true; }
77 void createISRRegFI();
78 int getISRRegFI(unsigned Reg) const { return ISRDataRegFI[Reg]; }
79 bool isISRRegFI(int FI) const;
80
Alex Lorenz5659a2f2015-08-11 23:23:17 +000081 /// Create a MachinePointerInfo that has a GlobalValuePseudoSourceValue object
Akira Hatanakae0657b22013-09-27 22:30:36 +000082 /// representing a GOT entry for a global function.
Alex Lorenz5659a2f2015-08-11 23:23:17 +000083 MachinePointerInfo callPtrInfo(const GlobalValue *GV);
Akira Hatanakae0657b22013-09-27 22:30:36 +000084
Reed Kotler4cdaa7d2014-02-14 19:16:39 +000085 void setSaveS2() { SaveS2 = true; }
86 bool hasSaveS2() const { return SaveS2; }
87
Daniel Sanders7ddb0ab2014-07-14 13:08:14 +000088 int getMoveF64ViaSpillFI(const TargetRegisterClass *RC);
Sasa Stankovicb976fee2014-07-14 09:40:29 +000089
Reed Kotler4cdaa7d2014-02-14 19:16:39 +000090 std::map<const char *, const llvm::Mips16HardFloatInfo::FuncSignature *>
91 StubsNeeded;
92
Akira Hatanakaf215e072013-09-25 00:34:42 +000093private:
94 virtual void anchor();
95
96 MachineFunction& MF;
97 /// SRetReturnReg - Some subtargets require that sret lowering includes
98 /// returning the value of the returned struct in a register. This field
99 /// holds the virtual register into which the sret argument is passed.
100 unsigned SRetReturnReg;
101
102 /// GlobalBaseReg - keeps track of the virtual register initialized for
103 /// use as the global base register. This is used for PIC in some PIC
104 /// relocation models.
105 unsigned GlobalBaseReg;
106
107 /// Mips16SPAliasReg - keeps track of the virtual register initialized for
108 /// use as an alias for SP for use in load/store of halfword/byte from/to
109 /// the stack
110 unsigned Mips16SPAliasReg;
111
112 /// VarArgsFrameIndex - FrameIndex for start of varargs area.
113 int VarArgsFrameIndex;
114
115 /// True if function has a byval argument.
116 bool HasByvalArg;
117
118 /// Size of incoming argument area.
119 unsigned IncomingArgSize;
120
121 /// CallsEhReturn - Whether the function calls llvm.eh.return.
122 bool CallsEhReturn;
123
124 /// Frame objects for spilling eh data registers.
125 int EhDataRegFI[4];
Akira Hatanakae0657b22013-09-27 22:30:36 +0000126
Vasileios Kalintiris43dff0c2015-10-26 12:38:43 +0000127 /// ISR - Whether the function is an Interrupt Service Routine.
128 bool IsISR;
129
130 /// Frame objects for spilling C0_STATUS, C0_EPC
131 int ISRDataRegFI[2];
132
Reed Kotler4cdaa7d2014-02-14 19:16:39 +0000133 // saveS2
134 bool SaveS2;
135
Sasa Stankovicb976fee2014-07-14 09:40:29 +0000136 /// FrameIndex for expanding BuildPairF64 nodes to spill and reload when the
137 /// O32 FPXX ABI is enabled. -1 is used to denote invalid index.
Daniel Sanders7ddb0ab2014-07-14 13:08:14 +0000138 int MoveF64ViaSpillFI;
Bruno Cardoso Lopes753e3702007-07-11 22:44:21 +0000139};
140
141} // end of namespace llvm
142
Benjamin Kramera7c40ef2014-08-13 16:26:38 +0000143#endif