1 //===-- MipsMachineFunctionInfo.h - Private data used for Mips ----*- C++ -*-=//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the Mips specific subclass of MachineFunctionInfo.
12 //===----------------------------------------------------------------------===//
14 #ifndef MIPS_MACHINE_FUNCTION_INFO_H
15 #define MIPS_MACHINE_FUNCTION_INFO_H
17 #include "Mips16HardFloatInfo.h"
18 #include "MipsSubtarget.h"
19 #include "llvm/ADT/StringMap.h"
20 #include "llvm/CodeGen/MachineFrameInfo.h"
21 #include "llvm/CodeGen/MachineFunction.h"
22 #include "llvm/CodeGen/MachineMemOperand.h"
23 #include "llvm/CodeGen/PseudoSourceValue.h"
24 #include "llvm/IR/GlobalValue.h"
25 #include "llvm/IR/ValueMap.h"
26 #include "llvm/Target/TargetFrameLowering.h"
27 #include "llvm/Target/TargetMachine.h"
34 /// \brief A class derived from PseudoSourceValue that represents a GOT entry
35 /// resolved by lazy-binding.
36 class MipsCallEntry : public PseudoSourceValue {
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;
45 virtual void printCustom(raw_ostream &O) const;
48 const GlobalValue *Val;
52 /// MipsFunctionInfo - This class is derived from MachineFunction private
53 /// Mips target-specific information for each MachineFunction.
54 class MipsFunctionInfo : public MachineFunctionInfo {
56 MipsFunctionInfo(MachineFunction &MF)
57 : MF(MF), SRetReturnReg(0), GlobalBaseReg(0), Mips16SPAliasReg(0),
58 VarArgsFrameIndex(0), CallsEhReturn(false), SaveS2(false) {}
62 unsigned getSRetReturnReg() const { return SRetReturnReg; }
63 void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
65 bool globalBaseRegSet() const;
66 unsigned getGlobalBaseReg();
68 bool mips16SPAliasRegSet() const;
69 unsigned getMips16SPAliasReg();
71 int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
72 void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
74 bool hasByvalArg() const { return HasByvalArg; }
75 void setFormalArgInfo(unsigned Size, bool HasByval) {
76 IncomingArgSize = Size;
77 HasByvalArg = HasByval;
80 unsigned getIncomingArgSize() const { return IncomingArgSize; }
82 bool callsEhReturn() const { return CallsEhReturn; }
83 void setCallsEhReturn() { CallsEhReturn = true; }
85 void createEhDataRegsFI();
86 int getEhDataRegFI(unsigned Reg) const { return EhDataRegFI[Reg]; }
87 bool isEhDataRegFI(int FI) const;
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);
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);
97 void setSaveS2() { SaveS2 = true; }
98 bool hasSaveS2() const { return SaveS2; }
100 std::map<const char *, const llvm::Mips16HardFloatInfo::FuncSignature *>
104 virtual void anchor();
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;
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;
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
120 unsigned Mips16SPAliasReg;
122 /// VarArgsFrameIndex - FrameIndex for start of varargs area.
123 int VarArgsFrameIndex;
125 /// True if function has a byval argument.
128 /// Size of incoming argument area.
129 unsigned IncomingArgSize;
131 /// CallsEhReturn - Whether the function calls llvm.eh.return.
134 /// Frame objects for spilling eh data registers.
140 /// MipsCallEntry maps.
141 StringMap<const MipsCallEntry *> ExternalCallEntries;
142 ValueMap<const GlobalValue *, const MipsCallEntry *> GlobalCallEntries;
145 } // end of namespace llvm
147 #endif // MIPS_MACHINE_FUNCTION_INFO_H