blob: a1b2e8173714827fbd3338d5cf915468da7b389a [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),
Sasa Stankovicb976fee2014-07-14 09:40:29 +000037 VarArgsFrameIndex(0), CallsEhReturn(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
Alex Lorenz5659a2f2015-08-11 23:23:17 +000073 /// Create a MachinePointerInfo that has a GlobalValuePseudoSourceValue object
Akira Hatanakae0657b22013-09-27 22:30:36 +000074 /// representing a GOT entry for a global function.
Alex Lorenz5659a2f2015-08-11 23:23:17 +000075 MachinePointerInfo callPtrInfo(const GlobalValue *GV);
Akira Hatanakae0657b22013-09-27 22:30:36 +000076
Reed Kotler4cdaa7d2014-02-14 19:16:39 +000077 void setSaveS2() { SaveS2 = true; }
78 bool hasSaveS2() const { return SaveS2; }
79
Daniel Sanders7ddb0ab2014-07-14 13:08:14 +000080 int getMoveF64ViaSpillFI(const TargetRegisterClass *RC);
Sasa Stankovicb976fee2014-07-14 09:40:29 +000081
Reed Kotler4cdaa7d2014-02-14 19:16:39 +000082 std::map<const char *, const llvm::Mips16HardFloatInfo::FuncSignature *>
83 StubsNeeded;
84
Akira Hatanakaf215e072013-09-25 00:34:42 +000085private:
86 virtual void anchor();
87
88 MachineFunction& MF;
89 /// SRetReturnReg - Some subtargets require that sret lowering includes
90 /// returning the value of the returned struct in a register. This field
91 /// holds the virtual register into which the sret argument is passed.
92 unsigned SRetReturnReg;
93
94 /// GlobalBaseReg - keeps track of the virtual register initialized for
95 /// use as the global base register. This is used for PIC in some PIC
96 /// relocation models.
97 unsigned GlobalBaseReg;
98
99 /// Mips16SPAliasReg - keeps track of the virtual register initialized for
100 /// use as an alias for SP for use in load/store of halfword/byte from/to
101 /// the stack
102 unsigned Mips16SPAliasReg;
103
104 /// VarArgsFrameIndex - FrameIndex for start of varargs area.
105 int VarArgsFrameIndex;
106
107 /// True if function has a byval argument.
108 bool HasByvalArg;
109
110 /// Size of incoming argument area.
111 unsigned IncomingArgSize;
112
113 /// CallsEhReturn - Whether the function calls llvm.eh.return.
114 bool CallsEhReturn;
115
116 /// Frame objects for spilling eh data registers.
117 int EhDataRegFI[4];
Akira Hatanakae0657b22013-09-27 22:30:36 +0000118
Reed Kotler4cdaa7d2014-02-14 19:16:39 +0000119 // saveS2
120 bool SaveS2;
121
Sasa Stankovicb976fee2014-07-14 09:40:29 +0000122 /// FrameIndex for expanding BuildPairF64 nodes to spill and reload when the
123 /// O32 FPXX ABI is enabled. -1 is used to denote invalid index.
Daniel Sanders7ddb0ab2014-07-14 13:08:14 +0000124 int MoveF64ViaSpillFI;
Bruno Cardoso Lopes753e3702007-07-11 22:44:21 +0000125};
126
127} // end of namespace llvm
128
Benjamin Kramera7c40ef2014-08-13 16:26:38 +0000129#endif