X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTarget%2FMips%2FMipsMachineFunction.h;h=217f30734b29972eb95e60e15435db95e0319c60;hb=211ed6d0017280fe27176338e88a9fee998dc909;hp=be27606ed8e664f761d47871a82c399f86eb52a8;hpb=213b2a218840ce81196ac5914de47647c927b287;p=oota-llvm.git diff --git a/lib/Target/Mips/MipsMachineFunction.h b/lib/Target/Mips/MipsMachineFunction.h index be27606ed8e..217f30734b2 100644 --- a/lib/Target/Mips/MipsMachineFunction.h +++ b/lib/Target/Mips/MipsMachineFunction.h @@ -11,22 +11,100 @@ // //===----------------------------------------------------------------------===// -#ifndef MIPS_MACHINE_FUNCTION_INFO_H -#define MIPS_MACHINE_FUNCTION_INFO_H +#ifndef LLVM_LIB_TARGET_MIPS_MIPSMACHINEFUNCTION_H +#define LLVM_LIB_TARGET_MIPS_MIPSMACHINEFUNCTION_H -#include -#include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/VectorExtras.h" -#include "llvm/CodeGen/MachineFunction.h" +#include "Mips16HardFloatInfo.h" +#include "llvm/ADT/StringMap.h" #include "llvm/CodeGen/MachineFrameInfo.h" +#include "llvm/CodeGen/MachineFunction.h" +#include "llvm/CodeGen/MachineMemOperand.h" +#include "llvm/CodeGen/PseudoSourceValue.h" +#include "llvm/IR/GlobalValue.h" +#include "llvm/IR/ValueMap.h" +#include "llvm/Target/TargetFrameLowering.h" +#include "llvm/Target/TargetMachine.h" +#include +#include +#include namespace llvm { +/// \brief A class derived from PseudoSourceValue that represents a GOT entry +/// resolved by lazy-binding. +class MipsCallEntry : public PseudoSourceValue { +public: + explicit MipsCallEntry(StringRef N); + explicit MipsCallEntry(const GlobalValue *V); + bool isConstant(const MachineFrameInfo *) const override; + bool isAliased(const MachineFrameInfo *) const override; + bool mayAlias(const MachineFrameInfo *) const override; + +private: + void printCustom(raw_ostream &O) const override; +#ifndef NDEBUG + std::string Name; + const GlobalValue *Val; +#endif +}; + /// MipsFunctionInfo - This class is derived from MachineFunction private /// Mips target-specific information for each MachineFunction. class MipsFunctionInfo : public MachineFunctionInfo { +public: + MipsFunctionInfo(MachineFunction &MF) + : MF(MF), SRetReturnReg(0), GlobalBaseReg(0), Mips16SPAliasReg(0), + VarArgsFrameIndex(0), CallsEhReturn(false), SaveS2(false), + MoveF64ViaSpillFI(-1) {} + + ~MipsFunctionInfo(); + + unsigned getSRetReturnReg() const { return SRetReturnReg; } + void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; } + + bool globalBaseRegSet() const; + unsigned getGlobalBaseReg(); + + bool mips16SPAliasRegSet() const; + unsigned getMips16SPAliasReg(); + + int getVarArgsFrameIndex() const { return VarArgsFrameIndex; } + void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; } + + bool hasByvalArg() const { return HasByvalArg; } + void setFormalArgInfo(unsigned Size, bool HasByval) { + IncomingArgSize = Size; + HasByvalArg = HasByval; + } + + unsigned getIncomingArgSize() const { return IncomingArgSize; } + + bool callsEhReturn() const { return CallsEhReturn; } + void setCallsEhReturn() { CallsEhReturn = true; } + + void createEhDataRegsFI(); + int getEhDataRegFI(unsigned Reg) const { return EhDataRegFI[Reg]; } + bool isEhDataRegFI(int FI) const; + + /// \brief Create a MachinePointerInfo that has a MipsCallEntr object + /// representing a GOT entry for an external function. + MachinePointerInfo callPtrInfo(StringRef Name); + + /// \brief Create a MachinePointerInfo that has a MipsCallEntr object + /// representing a GOT entry for a global function. + MachinePointerInfo callPtrInfo(const GlobalValue *Val); + + void setSaveS2() { SaveS2 = true; } + bool hasSaveS2() const { return SaveS2; } + + int getMoveF64ViaSpillFI(const TargetRegisterClass *RC); + + std::map + StubsNeeded; private: + virtual void anchor(); + MachineFunction& MF; /// SRetReturnReg - Some subtargets require that sret lowering includes /// returning the value of the returned struct in a register. This field @@ -38,79 +116,38 @@ private: /// relocation models. unsigned GlobalBaseReg; + /// Mips16SPAliasReg - keeps track of the virtual register initialized for + /// use as an alias for SP for use in load/store of halfword/byte from/to + /// the stack + unsigned Mips16SPAliasReg; + /// VarArgsFrameIndex - FrameIndex for start of varargs area. int VarArgsFrameIndex; - // Range of frame object indices. - // InArgFIRange: Range of indices of all frame objects created during call to - // LowerFormalArguments. - // OutArgFIRange: Range of indices of all frame objects created during call to - // LowerCall except for the frame object for restoring $gp. - std::pair InArgFIRange, OutArgFIRange; - int GPFI; // Index of the frame object for restoring $gp - mutable int DynAllocFI; // Frame index of dynamically allocated stack area. - unsigned MaxCallFrameSize; + /// True if function has a byval argument. + bool HasByvalArg; - // Size of area on callee's stack frame which is used to save va_arg or - // byval arguments passed in registers. - unsigned RegSaveAreaSize; + /// Size of incoming argument area. + unsigned IncomingArgSize; -public: - MipsFunctionInfo(MachineFunction& MF) - : MF(MF), SRetReturnReg(0), GlobalBaseReg(0), - VarArgsFrameIndex(0), InArgFIRange(std::make_pair(-1, 0)), - OutArgFIRange(std::make_pair(-1, 0)), GPFI(0), DynAllocFI(0), - MaxCallFrameSize(0), RegSaveAreaSize(0) - {} - - bool isInArgFI(int FI) const { - return FI <= InArgFIRange.first && FI >= InArgFIRange.second; - } - void setLastInArgFI(int FI) { InArgFIRange.second = FI; } + /// CallsEhReturn - Whether the function calls llvm.eh.return. + bool CallsEhReturn; - bool isOutArgFI(int FI) const { - return FI <= OutArgFIRange.first && FI >= OutArgFIRange.second; - } - void extendOutArgFIRange(int FirstFI, int LastFI) { - if (!OutArgFIRange.second) - // this must be the first time this function was called. - OutArgFIRange.first = FirstFI; - OutArgFIRange.second = LastFI; - } + /// Frame objects for spilling eh data registers. + int EhDataRegFI[4]; - int getGPFI() const { return GPFI; } - void setGPFI(int FI) { GPFI = FI; } - bool needGPSaveRestore() const { return getGPFI(); } - bool isGPFI(int FI) const { return GPFI && GPFI == FI; } + // saveS2 + bool SaveS2; - // The first call to this function creates a frame object for dynamically - // allocated stack area. - int getDynAllocFI() const { - if (!DynAllocFI) - DynAllocFI = MF.getFrameInfo()->CreateFixedObject(4, 0, true); + /// FrameIndex for expanding BuildPairF64 nodes to spill and reload when the + /// O32 FPXX ABI is enabled. -1 is used to denote invalid index. + int MoveF64ViaSpillFI; - return DynAllocFI; - } - bool isDynAllocFI(int FI) const { return DynAllocFI && DynAllocFI == FI; } - - unsigned getSRetReturnReg() const { return SRetReturnReg; } - void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; } - - unsigned getGlobalBaseReg() const { return GlobalBaseReg; } - void setGlobalBaseReg(unsigned Reg) { GlobalBaseReg = Reg; } - - int getVarArgsFrameIndex() const { return VarArgsFrameIndex; } - void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; } - - unsigned getMaxCallFrameSize() const { return MaxCallFrameSize; } - void setMaxCallFrameSize(unsigned S) { MaxCallFrameSize = S; } - - unsigned getRegSaveAreaSize() const { return RegSaveAreaSize; } - void setRegSaveAreaSize(unsigned S) { - if (RegSaveAreaSize < S) RegSaveAreaSize = S; - } + /// MipsCallEntry maps. + StringMap ExternalCallEntries; + ValueMap GlobalCallEntries; }; } // end of namespace llvm -#endif // MIPS_MACHINE_FUNCTION_INFO_H +#endif