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 "llvm/ADT/StringMap.h"
19 #include "llvm/CodeGen/MachineFrameInfo.h"
20 #include "llvm/CodeGen/MachineFunction.h"
21 #include "llvm/CodeGen/MachineMemOperand.h"
22 #include "llvm/CodeGen/PseudoSourceValue.h"
23 #include "llvm/IR/GlobalValue.h"
24 #include "llvm/IR/ValueMap.h"
25 #include "llvm/Target/TargetFrameLowering.h"
26 #include "llvm/Target/TargetMachine.h"
33 /// \brief A class derived from PseudoSourceValue that represents a GOT entry
34 /// resolved by lazy-binding.
35 class MipsCallEntry : public PseudoSourceValue {
37 explicit MipsCallEntry(const StringRef &N);
38 explicit MipsCallEntry(const GlobalValue *V);
39 bool isConstant(const MachineFrameInfo *) const override;
40 bool isAliased(const MachineFrameInfo *) const override;
41 bool mayAlias(const MachineFrameInfo *) const override;
44 void printCustom(raw_ostream &O) const override;
47 const GlobalValue *Val;
51 /// MipsFunctionInfo - This class is derived from MachineFunction private
52 /// Mips target-specific information for each MachineFunction.
53 class MipsFunctionInfo : public MachineFunctionInfo {
55 MipsFunctionInfo(MachineFunction &MF)
56 : MF(MF), SRetReturnReg(0), GlobalBaseReg(0), Mips16SPAliasReg(0),
57 VarArgsFrameIndex(0), CallsEhReturn(false), SaveS2(false) {}
61 unsigned getSRetReturnReg() const { return SRetReturnReg; }
62 void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
64 bool globalBaseRegSet() const;
65 unsigned getGlobalBaseReg();
67 bool mips16SPAliasRegSet() const;
68 unsigned getMips16SPAliasReg();
70 int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
71 void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
73 bool hasByvalArg() const { return HasByvalArg; }
74 void setFormalArgInfo(unsigned Size, bool HasByval) {
75 IncomingArgSize = Size;
76 HasByvalArg = HasByval;
79 unsigned getIncomingArgSize() const { return IncomingArgSize; }
81 bool callsEhReturn() const { return CallsEhReturn; }
82 void setCallsEhReturn() { CallsEhReturn = true; }
84 void createEhDataRegsFI();
85 int getEhDataRegFI(unsigned Reg) const { return EhDataRegFI[Reg]; }
86 bool isEhDataRegFI(int FI) const;
88 /// \brief Create a MachinePointerInfo that has a MipsCallEntr object
89 /// representing a GOT entry for an external function.
90 MachinePointerInfo callPtrInfo(const StringRef &Name);
92 /// \brief Create a MachinePointerInfo that has a MipsCallEntr object
93 /// representing a GOT entry for a global function.
94 MachinePointerInfo callPtrInfo(const GlobalValue *Val);
96 void setSaveS2() { SaveS2 = true; }
97 bool hasSaveS2() const { return SaveS2; }
99 std::map<const char *, const llvm::Mips16HardFloatInfo::FuncSignature *>
103 virtual void anchor();
106 /// SRetReturnReg - Some subtargets require that sret lowering includes
107 /// returning the value of the returned struct in a register. This field
108 /// holds the virtual register into which the sret argument is passed.
109 unsigned SRetReturnReg;
111 /// GlobalBaseReg - keeps track of the virtual register initialized for
112 /// use as the global base register. This is used for PIC in some PIC
113 /// relocation models.
114 unsigned GlobalBaseReg;
116 /// Mips16SPAliasReg - keeps track of the virtual register initialized for
117 /// use as an alias for SP for use in load/store of halfword/byte from/to
119 unsigned Mips16SPAliasReg;
121 /// VarArgsFrameIndex - FrameIndex for start of varargs area.
122 int VarArgsFrameIndex;
124 /// True if function has a byval argument.
127 /// Size of incoming argument area.
128 unsigned IncomingArgSize;
130 /// CallsEhReturn - Whether the function calls llvm.eh.return.
133 /// Frame objects for spilling eh data registers.
139 /// MipsCallEntry maps.
140 StringMap<const MipsCallEntry *> ExternalCallEntries;
141 ValueMap<const GlobalValue *, const MipsCallEntry *> GlobalCallEntries;
144 } // end of namespace llvm
146 #endif // MIPS_MACHINE_FUNCTION_INFO_H