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 | |
| 14 | #ifndef MIPS_MACHINE_FUNCTION_INFO_H |
| 15 | #define MIPS_MACHINE_FUNCTION_INFO_H |
| 16 | |
Reed Kotler | 4cdaa7d | 2014-02-14 19:16:39 +0000 | [diff] [blame] | 17 | #include "Mips16HardFloatInfo.h" |
Akira Hatanaka | 51c70c6 | 2012-06-14 01:15:36 +0000 | [diff] [blame] | 18 | #include "MipsSubtarget.h" |
Akira Hatanaka | e0657b2 | 2013-09-27 22:30:36 +0000 | [diff] [blame] | 19 | #include "llvm/ADT/StringMap.h" |
Bruno Cardoso Lopes | f55a785 | 2007-08-28 05:04:41 +0000 | [diff] [blame] | 20 | #include "llvm/CodeGen/MachineFrameInfo.h" |
Chandler Carruth | 802d755 | 2012-12-04 07:12:27 +0000 | [diff] [blame] | 21 | #include "llvm/CodeGen/MachineFunction.h" |
Akira Hatanaka | e0657b2 | 2013-09-27 22:30:36 +0000 | [diff] [blame] | 22 | #include "llvm/CodeGen/MachineMemOperand.h" |
| 23 | #include "llvm/CodeGen/PseudoSourceValue.h" |
| 24 | #include "llvm/IR/GlobalValue.h" |
Chandler Carruth | a4ea269 | 2014-03-04 11:26:31 +0000 | [diff] [blame^] | 25 | #include "llvm/IR/ValueMap.h" |
Akira Hatanaka | 51c70c6 | 2012-06-14 01:15:36 +0000 | [diff] [blame] | 26 | #include "llvm/Target/TargetFrameLowering.h" |
| 27 | #include "llvm/Target/TargetMachine.h" |
Reed Kotler | 4cdaa7d | 2014-02-14 19:16:39 +0000 | [diff] [blame] | 28 | #include <map> |
| 29 | #include <string> |
Craig Topper | b25fda9 | 2012-03-17 18:46:09 +0000 | [diff] [blame] | 30 | #include <utility> |
Bruno Cardoso Lopes | 753e370 | 2007-07-11 22:44:21 +0000 | [diff] [blame] | 31 | |
| 32 | namespace llvm { |
| 33 | |
Akira Hatanaka | e0657b2 | 2013-09-27 22:30:36 +0000 | [diff] [blame] | 34 | /// \brief A class derived from PseudoSourceValue that represents a GOT entry |
| 35 | /// resolved by lazy-binding. |
| 36 | class MipsCallEntry : public PseudoSourceValue { |
| 37 | public: |
| 38 | explicit MipsCallEntry(const StringRef &N); |
| 39 | explicit MipsCallEntry(const GlobalValue *V); |
| 40 | virtual bool isConstant(const MachineFrameInfo *) const; |
| 41 | virtual bool isAliased(const MachineFrameInfo *) const; |
| 42 | virtual bool mayAlias(const MachineFrameInfo *) const; |
| 43 | |
| 44 | private: |
| 45 | virtual void printCustom(raw_ostream &O) const; |
| 46 | #ifndef NDEBUG |
| 47 | std::string Name; |
| 48 | const GlobalValue *Val; |
| 49 | #endif |
| 50 | }; |
| 51 | |
Bruno Cardoso Lopes | 753e370 | 2007-07-11 22:44:21 +0000 | [diff] [blame] | 52 | /// MipsFunctionInfo - This class is derived from MachineFunction private |
| 53 | /// Mips target-specific information for each MachineFunction. |
| 54 | class MipsFunctionInfo : public MachineFunctionInfo { |
Bruno Cardoso Lopes | 753e370 | 2007-07-11 22:44:21 +0000 | [diff] [blame] | 55 | public: |
Reed Kotler | 4cdaa7d | 2014-02-14 19:16:39 +0000 | [diff] [blame] | 56 | MipsFunctionInfo(MachineFunction &MF) |
| 57 | : MF(MF), SRetReturnReg(0), GlobalBaseReg(0), Mips16SPAliasReg(0), |
| 58 | VarArgsFrameIndex(0), CallsEhReturn(false), SaveS2(false) {} |
Bruno Cardoso Lopes | 753e370 | 2007-07-11 22:44:21 +0000 | [diff] [blame] | 59 | |
Akira Hatanaka | e0657b2 | 2013-09-27 22:30:36 +0000 | [diff] [blame] | 60 | ~MipsFunctionInfo(); |
| 61 | |
Bruno Cardoso Lopes | c9c3f49 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 62 | unsigned getSRetReturnReg() const { return SRetReturnReg; } |
| 63 | void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; } |
Dan Gohman | d5ca7064 | 2009-06-03 20:30:14 +0000 | [diff] [blame] | 64 | |
Akira Hatanaka | b049aef | 2012-02-24 22:34:47 +0000 | [diff] [blame] | 65 | bool globalBaseRegSet() const; |
| 66 | unsigned getGlobalBaseReg(); |
Dan Gohman | 31ae586 | 2010-04-17 14:41:14 +0000 | [diff] [blame] | 67 | |
Reed Kotler | 3589dd7 | 2012-10-28 06:02:37 +0000 | [diff] [blame] | 68 | bool mips16SPAliasRegSet() const; |
| 69 | unsigned getMips16SPAliasReg(); |
| 70 | |
Dan Gohman | 31ae586 | 2010-04-17 14:41:14 +0000 | [diff] [blame] | 71 | int getVarArgsFrameIndex() const { return VarArgsFrameIndex; } |
| 72 | void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; } |
Akira Hatanaka | d738c0f | 2011-05-20 01:17:58 +0000 | [diff] [blame] | 73 | |
Akira Hatanaka | 4866fe1 | 2012-10-30 19:37:25 +0000 | [diff] [blame] | 74 | bool hasByvalArg() const { return HasByvalArg; } |
Akira Hatanaka | 40f2d30 | 2012-11-07 19:04:26 +0000 | [diff] [blame] | 75 | void setFormalArgInfo(unsigned Size, bool HasByval) { |
| 76 | IncomingArgSize = Size; |
Akira Hatanaka | 4866fe1 | 2012-10-30 19:37:25 +0000 | [diff] [blame] | 77 | HasByvalArg = HasByval; |
| 78 | } |
Akira Hatanaka | 719df28 | 2012-11-02 21:03:58 +0000 | [diff] [blame] | 79 | |
| 80 | unsigned getIncomingArgSize() const { return IncomingArgSize; } |
Akira Hatanaka | c0b0206 | 2013-01-30 00:26:49 +0000 | [diff] [blame] | 81 | |
| 82 | bool callsEhReturn() const { return CallsEhReturn; } |
| 83 | void setCallsEhReturn() { CallsEhReturn = true; } |
| 84 | |
| 85 | void createEhDataRegsFI(); |
| 86 | int getEhDataRegFI(unsigned Reg) const { return EhDataRegFI[Reg]; } |
| 87 | bool isEhDataRegFI(int FI) const; |
| 88 | |
Akira Hatanaka | e0657b2 | 2013-09-27 22:30:36 +0000 | [diff] [blame] | 89 | /// \brief Create a MachinePointerInfo that has a MipsCallEntr object |
| 90 | /// representing a GOT entry for an external function. |
| 91 | MachinePointerInfo callPtrInfo(const StringRef &Name); |
| 92 | |
| 93 | /// \brief Create a MachinePointerInfo that has a MipsCallEntr object |
| 94 | /// representing a GOT entry for a global function. |
| 95 | MachinePointerInfo callPtrInfo(const GlobalValue *Val); |
| 96 | |
Reed Kotler | 4cdaa7d | 2014-02-14 19:16:39 +0000 | [diff] [blame] | 97 | void setSaveS2() { SaveS2 = true; } |
| 98 | bool hasSaveS2() const { return SaveS2; } |
| 99 | |
| 100 | std::map<const char *, const llvm::Mips16HardFloatInfo::FuncSignature *> |
| 101 | StubsNeeded; |
| 102 | |
Akira Hatanaka | f215e07 | 2013-09-25 00:34:42 +0000 | [diff] [blame] | 103 | private: |
| 104 | virtual void anchor(); |
| 105 | |
| 106 | MachineFunction& MF; |
| 107 | /// SRetReturnReg - Some subtargets require that sret lowering includes |
| 108 | /// returning the value of the returned struct in a register. This field |
| 109 | /// holds the virtual register into which the sret argument is passed. |
| 110 | unsigned SRetReturnReg; |
| 111 | |
| 112 | /// GlobalBaseReg - keeps track of the virtual register initialized for |
| 113 | /// use as the global base register. This is used for PIC in some PIC |
| 114 | /// relocation models. |
| 115 | unsigned GlobalBaseReg; |
| 116 | |
| 117 | /// Mips16SPAliasReg - keeps track of the virtual register initialized for |
| 118 | /// use as an alias for SP for use in load/store of halfword/byte from/to |
| 119 | /// the stack |
| 120 | unsigned Mips16SPAliasReg; |
| 121 | |
| 122 | /// VarArgsFrameIndex - FrameIndex for start of varargs area. |
| 123 | int VarArgsFrameIndex; |
| 124 | |
| 125 | /// True if function has a byval argument. |
| 126 | bool HasByvalArg; |
| 127 | |
| 128 | /// Size of incoming argument area. |
| 129 | unsigned IncomingArgSize; |
| 130 | |
| 131 | /// CallsEhReturn - Whether the function calls llvm.eh.return. |
| 132 | bool CallsEhReturn; |
| 133 | |
| 134 | /// Frame objects for spilling eh data registers. |
| 135 | int EhDataRegFI[4]; |
Akira Hatanaka | e0657b2 | 2013-09-27 22:30:36 +0000 | [diff] [blame] | 136 | |
Reed Kotler | 4cdaa7d | 2014-02-14 19:16:39 +0000 | [diff] [blame] | 137 | // saveS2 |
| 138 | bool SaveS2; |
| 139 | |
Akira Hatanaka | e0657b2 | 2013-09-27 22:30:36 +0000 | [diff] [blame] | 140 | /// MipsCallEntry maps. |
| 141 | StringMap<const MipsCallEntry *> ExternalCallEntries; |
| 142 | ValueMap<const GlobalValue *, const MipsCallEntry *> GlobalCallEntries; |
Bruno Cardoso Lopes | 753e370 | 2007-07-11 22:44:21 +0000 | [diff] [blame] | 143 | }; |
| 144 | |
| 145 | } // end of namespace llvm |
| 146 | |
Bruno Cardoso Lopes | f55a785 | 2007-08-28 05:04:41 +0000 | [diff] [blame] | 147 | #endif // MIPS_MACHINE_FUNCTION_INFO_H |