Akira Hatanaka | e248912 | 2011-04-15 21:51:11 +0000 | [diff] [blame] | 1 | //===-- MipsMachineFunctionInfo.h - Private data used for Mips ----*- C++ -*-=// |
Bruno Cardoso Lopes | 753e370 | 2007-07-11 22:44:21 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | f3ebc3f | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Bruno Cardoso Lopes | 753e370 | 2007-07-11 22:44:21 +0000 | [diff] [blame] | 7 | // |
Akira Hatanaka | e248912 | 2011-04-15 21:51:11 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
Bruno Cardoso Lopes | 753e370 | 2007-07-11 22:44:21 +0000 | [diff] [blame] | 9 | // |
| 10 | // This file declares the Mips specific subclass of MachineFunctionInfo. |
| 11 | // |
Akira Hatanaka | e248912 | 2011-04-15 21:51:11 +0000 | [diff] [blame] | 12 | //===----------------------------------------------------------------------===// |
Bruno Cardoso Lopes | 753e370 | 2007-07-11 22:44:21 +0000 | [diff] [blame] | 13 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 14 | #ifndef LLVM_LIB_TARGET_MIPS_MIPSMACHINEFUNCTION_H |
| 15 | #define LLVM_LIB_TARGET_MIPS_MIPSMACHINEFUNCTION_H |
Bruno Cardoso Lopes | 753e370 | 2007-07-11 22:44:21 +0000 | [diff] [blame] | 16 | |
Reed Kotler | 4cdaa7d | 2014-02-14 19:16:39 +0000 | [diff] [blame] | 17 | #include "Mips16HardFloatInfo.h" |
Bruno Cardoso Lopes | f55a785 | 2007-08-28 05:04:41 +0000 | [diff] [blame] | 18 | #include "llvm/CodeGen/MachineFrameInfo.h" |
Chandler Carruth | 802d755 | 2012-12-04 07:12:27 +0000 | [diff] [blame] | 19 | #include "llvm/CodeGen/MachineFunction.h" |
Akira Hatanaka | e0657b2 | 2013-09-27 22:30:36 +0000 | [diff] [blame] | 20 | #include "llvm/CodeGen/MachineMemOperand.h" |
| 21 | #include "llvm/CodeGen/PseudoSourceValue.h" |
Chandler Carruth | a4ea269 | 2014-03-04 11:26:31 +0000 | [diff] [blame] | 22 | #include "llvm/IR/ValueMap.h" |
Akira Hatanaka | 51c70c6 | 2012-06-14 01:15:36 +0000 | [diff] [blame] | 23 | #include "llvm/Target/TargetFrameLowering.h" |
| 24 | #include "llvm/Target/TargetMachine.h" |
Reed Kotler | 4cdaa7d | 2014-02-14 19:16:39 +0000 | [diff] [blame] | 25 | #include <map> |
| 26 | #include <string> |
Craig Topper | b25fda9 | 2012-03-17 18:46:09 +0000 | [diff] [blame] | 27 | #include <utility> |
Bruno Cardoso Lopes | 753e370 | 2007-07-11 22:44:21 +0000 | [diff] [blame] | 28 | |
| 29 | namespace llvm { |
| 30 | |
| 31 | /// MipsFunctionInfo - This class is derived from MachineFunction private |
| 32 | /// Mips target-specific information for each MachineFunction. |
| 33 | class MipsFunctionInfo : public MachineFunctionInfo { |
Bruno Cardoso Lopes | 753e370 | 2007-07-11 22:44:21 +0000 | [diff] [blame] | 34 | public: |
Reed Kotler | 4cdaa7d | 2014-02-14 19:16:39 +0000 | [diff] [blame] | 35 | MipsFunctionInfo(MachineFunction &MF) |
| 36 | : MF(MF), SRetReturnReg(0), GlobalBaseReg(0), Mips16SPAliasReg(0), |
Sasa Stankovic | b976fee | 2014-07-14 09:40:29 +0000 | [diff] [blame] | 37 | VarArgsFrameIndex(0), CallsEhReturn(false), SaveS2(false), |
Daniel Sanders | 7ddb0ab | 2014-07-14 13:08:14 +0000 | [diff] [blame] | 38 | MoveF64ViaSpillFI(-1) {} |
Bruno Cardoso Lopes | 753e370 | 2007-07-11 22:44:21 +0000 | [diff] [blame] | 39 | |
Akira Hatanaka | e0657b2 | 2013-09-27 22:30:36 +0000 | [diff] [blame] | 40 | ~MipsFunctionInfo(); |
| 41 | |
Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 42 | unsigned getSRetReturnReg() const { return SRetReturnReg; } |
| 43 | void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; } |
Dan Gohman | d5ca7064 | 2009-06-03 20:30:14 +0000 | [diff] [blame] | 44 | |
Akira Hatanaka | b049aef | 2012-02-24 22:34:47 +0000 | [diff] [blame] | 45 | bool globalBaseRegSet() const; |
| 46 | unsigned getGlobalBaseReg(); |
Dan Gohman | 31ae586 | 2010-04-17 14:41:14 +0000 | [diff] [blame] | 47 | |
Reed Kotler | 3589dd7 | 2012-10-28 06:02:37 +0000 | [diff] [blame] | 48 | bool mips16SPAliasRegSet() const; |
| 49 | unsigned getMips16SPAliasReg(); |
| 50 | |
Dan Gohman | 31ae586 | 2010-04-17 14:41:14 +0000 | [diff] [blame] | 51 | int getVarArgsFrameIndex() const { return VarArgsFrameIndex; } |
| 52 | void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; } |
Akira Hatanaka | d738c0f | 2011-05-20 01:17:58 +0000 | [diff] [blame] | 53 | |
Akira Hatanaka | 4866fe1 | 2012-10-30 19:37:25 +0000 | [diff] [blame] | 54 | bool hasByvalArg() const { return HasByvalArg; } |
Akira Hatanaka | 40f2d30 | 2012-11-07 19:04:26 +0000 | [diff] [blame] | 55 | void setFormalArgInfo(unsigned Size, bool HasByval) { |
| 56 | IncomingArgSize = Size; |
Akira Hatanaka | 4866fe1 | 2012-10-30 19:37:25 +0000 | [diff] [blame] | 57 | HasByvalArg = HasByval; |
| 58 | } |
Akira Hatanaka | 719df28 | 2012-11-02 21:03:58 +0000 | [diff] [blame] | 59 | |
| 60 | unsigned getIncomingArgSize() const { return IncomingArgSize; } |
Akira Hatanaka | c0b0206 | 2013-01-30 00:26:49 +0000 | [diff] [blame] | 61 | |
| 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 Lorenz | 5659a2f | 2015-08-11 23:23:17 +0000 | [diff] [blame] | 69 | /// Create a MachinePointerInfo that has an ExternalSymbolPseudoSourceValue |
| 70 | /// object representing a GOT entry for an external function. |
| 71 | MachinePointerInfo callPtrInfo(const char *ES); |
Akira Hatanaka | e0657b2 | 2013-09-27 22:30:36 +0000 | [diff] [blame] | 72 | |
Alex Lorenz | 5659a2f | 2015-08-11 23:23:17 +0000 | [diff] [blame] | 73 | /// Create a MachinePointerInfo that has a GlobalValuePseudoSourceValue object |
Akira Hatanaka | e0657b2 | 2013-09-27 22:30:36 +0000 | [diff] [blame] | 74 | /// representing a GOT entry for a global function. |
Alex Lorenz | 5659a2f | 2015-08-11 23:23:17 +0000 | [diff] [blame] | 75 | MachinePointerInfo callPtrInfo(const GlobalValue *GV); |
Akira Hatanaka | e0657b2 | 2013-09-27 22:30:36 +0000 | [diff] [blame] | 76 | |
Reed Kotler | 4cdaa7d | 2014-02-14 19:16:39 +0000 | [diff] [blame] | 77 | void setSaveS2() { SaveS2 = true; } |
| 78 | bool hasSaveS2() const { return SaveS2; } |
| 79 | |
Daniel Sanders | 7ddb0ab | 2014-07-14 13:08:14 +0000 | [diff] [blame] | 80 | int getMoveF64ViaSpillFI(const TargetRegisterClass *RC); |
Sasa Stankovic | b976fee | 2014-07-14 09:40:29 +0000 | [diff] [blame] | 81 | |
Reed Kotler | 4cdaa7d | 2014-02-14 19:16:39 +0000 | [diff] [blame] | 82 | std::map<const char *, const llvm::Mips16HardFloatInfo::FuncSignature *> |
| 83 | StubsNeeded; |
| 84 | |
Akira Hatanaka | f215e07 | 2013-09-25 00:34:42 +0000 | [diff] [blame] | 85 | private: |
| 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 Hatanaka | e0657b2 | 2013-09-27 22:30:36 +0000 | [diff] [blame] | 118 | |
Reed Kotler | 4cdaa7d | 2014-02-14 19:16:39 +0000 | [diff] [blame] | 119 | // saveS2 |
| 120 | bool SaveS2; |
| 121 | |
Sasa Stankovic | b976fee | 2014-07-14 09:40:29 +0000 | [diff] [blame] | 122 | /// 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 Sanders | 7ddb0ab | 2014-07-14 13:08:14 +0000 | [diff] [blame] | 124 | int MoveF64ViaSpillFI; |
Bruno Cardoso Lopes | 753e370 | 2007-07-11 22:44:21 +0000 | [diff] [blame] | 125 | }; |
| 126 | |
| 127 | } // end of namespace llvm |
| 128 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 129 | #endif |