blob: aaa1e0e184411239f691dc4411b7f101cbb9f3e5 [file] [log] [blame]
Eugene Zelenkodde94e42017-01-30 23:21:32 +00001//===- MipsMachineFunctionInfo.h - Private data used for Mips ---*- C++ -*-===//
Bruno Cardoso Lopes753e3702007-07-11 22:44:21 +00002//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Bruno Cardoso Lopes753e3702007-07-11 22:44:21 +00006//
Akira Hatanakae2489122011-04-15 21:51:11 +00007//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes753e3702007-07-11 22:44:21 +00008//
9// This file declares the Mips specific subclass of MachineFunctionInfo.
10//
Akira Hatanakae2489122011-04-15 21:51:11 +000011//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes753e3702007-07-11 22:44:21 +000012
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000013#ifndef LLVM_LIB_TARGET_MIPS_MIPSMACHINEFUNCTION_H
14#define LLVM_LIB_TARGET_MIPS_MIPSMACHINEFUNCTION_H
Bruno Cardoso Lopes753e3702007-07-11 22:44:21 +000015
Reed Kotler4cdaa7d2014-02-14 19:16:39 +000016#include "Mips16HardFloatInfo.h"
Chandler Carruth802d7552012-12-04 07:12:27 +000017#include "llvm/CodeGen/MachineFunction.h"
Akira Hatanakae0657b22013-09-27 22:30:36 +000018#include "llvm/CodeGen/MachineMemOperand.h"
Reed Kotler4cdaa7d2014-02-14 19:16:39 +000019#include <map>
Bruno Cardoso Lopes753e3702007-07-11 22:44:21 +000020
21namespace llvm {
22
23/// MipsFunctionInfo - This class is derived from MachineFunction private
24/// Mips target-specific information for each MachineFunction.
25class MipsFunctionInfo : public MachineFunctionInfo {
Bruno Cardoso Lopes753e3702007-07-11 22:44:21 +000026public:
Eugene Zelenkodde94e42017-01-30 23:21:32 +000027 MipsFunctionInfo(MachineFunction &MF) : MF(MF) {}
Bruno Cardoso Lopes753e3702007-07-11 22:44:21 +000028
Eugene Zelenkodde94e42017-01-30 23:21:32 +000029 ~MipsFunctionInfo() override;
Akira Hatanakae0657b22013-09-27 22:30:36 +000030
Bruno Cardoso Lopesc9c3f492008-07-05 19:05:21 +000031 unsigned getSRetReturnReg() const { return SRetReturnReg; }
32 void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
Dan Gohmand5ca70642009-06-03 20:30:14 +000033
Akira Hatanakab049aef2012-02-24 22:34:47 +000034 bool globalBaseRegSet() const;
Matt Arsenaultfaeaedf2019-06-24 16:16:12 +000035 Register getGlobalBaseReg();
36 Register getGlobalBaseRegForGlobalISel();
Dan Gohman31ae5862010-04-17 14:41:14 +000037
Petar Avramovic9058b502019-05-31 08:15:28 +000038 // Insert instructions to initialize the global base register in the
39 // first MBB of the function.
40 void initGlobalBaseReg();
41
Dan Gohman31ae5862010-04-17 14:41:14 +000042 int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
43 void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
Akira Hatanakad738c0f2011-05-20 01:17:58 +000044
Akira Hatanaka4866fe12012-10-30 19:37:25 +000045 bool hasByvalArg() const { return HasByvalArg; }
Akira Hatanaka40f2d302012-11-07 19:04:26 +000046 void setFormalArgInfo(unsigned Size, bool HasByval) {
47 IncomingArgSize = Size;
Akira Hatanaka4866fe12012-10-30 19:37:25 +000048 HasByvalArg = HasByval;
49 }
Akira Hatanaka719df282012-11-02 21:03:58 +000050
51 unsigned getIncomingArgSize() const { return IncomingArgSize; }
Akira Hatanakac0b02062013-01-30 00:26:49 +000052
53 bool callsEhReturn() const { return CallsEhReturn; }
54 void setCallsEhReturn() { CallsEhReturn = true; }
55
56 void createEhDataRegsFI();
57 int getEhDataRegFI(unsigned Reg) const { return EhDataRegFI[Reg]; }
58 bool isEhDataRegFI(int FI) const;
59
Alex Lorenz5659a2f2015-08-11 23:23:17 +000060 /// Create a MachinePointerInfo that has an ExternalSymbolPseudoSourceValue
61 /// object representing a GOT entry for an external function.
62 MachinePointerInfo callPtrInfo(const char *ES);
Akira Hatanakae0657b22013-09-27 22:30:36 +000063
Vasileios Kalintiris43dff0c2015-10-26 12:38:43 +000064 // Functions with the "interrupt" attribute require special prologues,
65 // epilogues and additional spill slots.
66 bool isISR() const { return IsISR; }
67 void setISR() { IsISR = true; }
68 void createISRRegFI();
69 int getISRRegFI(unsigned Reg) const { return ISRDataRegFI[Reg]; }
70 bool isISRRegFI(int FI) const;
71
Alex Lorenz5659a2f2015-08-11 23:23:17 +000072 /// Create a MachinePointerInfo that has a GlobalValuePseudoSourceValue object
Akira Hatanakae0657b22013-09-27 22:30:36 +000073 /// representing a GOT entry for a global function.
Alex Lorenz5659a2f2015-08-11 23:23:17 +000074 MachinePointerInfo callPtrInfo(const GlobalValue *GV);
Akira Hatanakae0657b22013-09-27 22:30:36 +000075
Reed Kotler4cdaa7d2014-02-14 19:16:39 +000076 void setSaveS2() { SaveS2 = true; }
77 bool hasSaveS2() const { return SaveS2; }
78
Daniel Sanders7ddb0ab2014-07-14 13:08:14 +000079 int getMoveF64ViaSpillFI(const TargetRegisterClass *RC);
Sasa Stankovicb976fee2014-07-14 09:40:29 +000080
Eugene Zelenkodde94e42017-01-30 23:21:32 +000081 std::map<const char *, const Mips16HardFloatInfo::FuncSignature *>
Reed Kotler4cdaa7d2014-02-14 19:16:39 +000082 StubsNeeded;
83
Akira Hatanakaf215e072013-09-25 00:34:42 +000084private:
85 virtual void anchor();
86
87 MachineFunction& MF;
Eugene Zelenkodde94e42017-01-30 23:21:32 +000088
Akira Hatanakaf215e072013-09-25 00:34:42 +000089 /// 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.
Eugene Zelenkodde94e42017-01-30 23:21:32 +000092 unsigned SRetReturnReg = 0;
Akira Hatanakaf215e072013-09-25 00:34:42 +000093
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.
Eugene Zelenkodde94e42017-01-30 23:21:32 +000097 unsigned GlobalBaseReg = 0;
Akira Hatanakaf215e072013-09-25 00:34:42 +000098
Akira Hatanakaf215e072013-09-25 00:34:42 +000099 /// VarArgsFrameIndex - FrameIndex for start of varargs area.
Eugene Zelenkodde94e42017-01-30 23:21:32 +0000100 int VarArgsFrameIndex = 0;
Akira Hatanakaf215e072013-09-25 00:34:42 +0000101
102 /// True if function has a byval argument.
103 bool HasByvalArg;
104
105 /// Size of incoming argument area.
106 unsigned IncomingArgSize;
107
108 /// CallsEhReturn - Whether the function calls llvm.eh.return.
Eugene Zelenkodde94e42017-01-30 23:21:32 +0000109 bool CallsEhReturn = false;
Akira Hatanakaf215e072013-09-25 00:34:42 +0000110
111 /// Frame objects for spilling eh data registers.
112 int EhDataRegFI[4];
Akira Hatanakae0657b22013-09-27 22:30:36 +0000113
Vasileios Kalintiris43dff0c2015-10-26 12:38:43 +0000114 /// ISR - Whether the function is an Interrupt Service Routine.
Eugene Zelenkodde94e42017-01-30 23:21:32 +0000115 bool IsISR = false;
Vasileios Kalintiris43dff0c2015-10-26 12:38:43 +0000116
117 /// Frame objects for spilling C0_STATUS, C0_EPC
118 int ISRDataRegFI[2];
119
Reed Kotler4cdaa7d2014-02-14 19:16:39 +0000120 // saveS2
Eugene Zelenkodde94e42017-01-30 23:21:32 +0000121 bool SaveS2 = false;
Reed Kotler4cdaa7d2014-02-14 19:16:39 +0000122
Sasa Stankovicb976fee2014-07-14 09:40:29 +0000123 /// FrameIndex for expanding BuildPairF64 nodes to spill and reload when the
124 /// O32 FPXX ABI is enabled. -1 is used to denote invalid index.
Eugene Zelenkodde94e42017-01-30 23:21:32 +0000125 int MoveF64ViaSpillFI = -1;
Bruno Cardoso Lopes753e3702007-07-11 22:44:21 +0000126};
127
Eugene Zelenkodde94e42017-01-30 23:21:32 +0000128} // end namespace llvm
Bruno Cardoso Lopes753e3702007-07-11 22:44:21 +0000129
Eugene Zelenkodde94e42017-01-30 23:21:32 +0000130#endif // LLVM_LIB_TARGET_MIPS_MIPSMACHINEFUNCTION_H