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 "MipsSubtarget.h"
18 #include "llvm/ADT/StringMap.h"
19 #include "llvm/ADT/ValueMap.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/Target/TargetFrameLowering.h"
26 #include "llvm/Target/TargetMachine.h"
31 /// \brief A class derived from PseudoSourceValue that represents a GOT entry
32 /// resolved by lazy-binding.
33 class MipsCallEntry : public PseudoSourceValue {
35 explicit MipsCallEntry(const StringRef &N);
36 explicit MipsCallEntry(const GlobalValue *V);
37 virtual bool isConstant(const MachineFrameInfo *) const;
38 virtual bool isAliased(const MachineFrameInfo *) const;
39 virtual bool mayAlias(const MachineFrameInfo *) const;
42 virtual void printCustom(raw_ostream &O) const;
45 const GlobalValue *Val;
49 /// MipsFunctionInfo - This class is derived from MachineFunction private
50 /// Mips target-specific information for each MachineFunction.
51 class MipsFunctionInfo : public MachineFunctionInfo {
53 MipsFunctionInfo(MachineFunction& MF)
54 : MF(MF), SRetReturnReg(0), GlobalBaseReg(0), Mips16SPAliasReg(0),
55 VarArgsFrameIndex(0), CallsEhReturn(false)
60 unsigned getSRetReturnReg() const { return SRetReturnReg; }
61 void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
63 bool globalBaseRegSet() const;
64 unsigned getGlobalBaseReg();
66 bool mips16SPAliasRegSet() const;
67 unsigned getMips16SPAliasReg();
69 int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
70 void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }
72 bool hasByvalArg() const { return HasByvalArg; }
73 void setFormalArgInfo(unsigned Size, bool HasByval) {
74 IncomingArgSize = Size;
75 HasByvalArg = HasByval;
78 unsigned getIncomingArgSize() const { return IncomingArgSize; }
80 bool callsEhReturn() const { return CallsEhReturn; }
81 void setCallsEhReturn() { CallsEhReturn = true; }
83 void createEhDataRegsFI();
84 int getEhDataRegFI(unsigned Reg) const { return EhDataRegFI[Reg]; }
85 bool isEhDataRegFI(int FI) const;
87 /// \brief Create a MachinePointerInfo that has a MipsCallEntr object
88 /// representing a GOT entry for an external function.
89 MachinePointerInfo callPtrInfo(const StringRef &Name);
91 /// \brief Create a MachinePointerInfo that has a MipsCallEntr object
92 /// representing a GOT entry for a global function.
93 MachinePointerInfo callPtrInfo(const GlobalValue *Val);
96 virtual void anchor();
99 /// SRetReturnReg - Some subtargets require that sret lowering includes
100 /// returning the value of the returned struct in a register. This field
101 /// holds the virtual register into which the sret argument is passed.
102 unsigned SRetReturnReg;
104 /// GlobalBaseReg - keeps track of the virtual register initialized for
105 /// use as the global base register. This is used for PIC in some PIC
106 /// relocation models.
107 unsigned GlobalBaseReg;
109 /// Mips16SPAliasReg - keeps track of the virtual register initialized for
110 /// use as an alias for SP for use in load/store of halfword/byte from/to
112 unsigned Mips16SPAliasReg;
114 /// VarArgsFrameIndex - FrameIndex for start of varargs area.
115 int VarArgsFrameIndex;
117 /// True if function has a byval argument.
120 /// Size of incoming argument area.
121 unsigned IncomingArgSize;
123 /// CallsEhReturn - Whether the function calls llvm.eh.return.
126 /// Frame objects for spilling eh data registers.
129 /// MipsCallEntry maps.
130 StringMap<const MipsCallEntry *> ExternalCallEntries;
131 ValueMap<const GlobalValue *, const MipsCallEntry *> GlobalCallEntries;
134 } // end of namespace llvm
136 #endif // MIPS_MACHINE_FUNCTION_INFO_H