LLVM  3.7.0
MipsMachineFunction.cpp
Go to the documentation of this file.
1 //===-- MipsMachineFunctionInfo.cpp - Private data used for Mips ----------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
11 #include "MipsInstrInfo.h"
12 #include "MipsMachineFunction.h"
13 #include "MipsSubtarget.h"
14 #include "MipsTargetMachine.h"
17 #include "llvm/IR/Function.h"
20 
21 using namespace llvm;
22 
23 static cl::opt<bool>
24 FixGlobalBaseReg("mips-fix-global-base-reg", cl::Hidden, cl::init(true),
25  cl::desc("Always use $gp as the global base register."));
26 
27 // class MipsCallEntry.
29 #ifndef NDEBUG
30  Name = N;
31  Val = nullptr;
32 #endif
33 }
34 
36 #ifndef NDEBUG
37  Val = V;
38 #endif
39 }
40 
42  return false;
43 }
44 
46  return false;
47 }
48 
50  return false;
51 }
52 
53 void MipsCallEntry::printCustom(raw_ostream &O) const {
54  O << "MipsCallEntry: ";
55 #ifndef NDEBUG
56  if (Val)
57  O << Val->getName();
58  else
59  O << Name;
60 #endif
61 }
62 
64 
66  return GlobalBaseReg;
67 }
68 
70  // Return if it has already been initialized.
71  if (GlobalBaseReg)
72  return GlobalBaseReg;
73 
74  MipsSubtarget const &STI =
75  static_cast<const MipsSubtarget &>(MF.getSubtarget());
76 
77  const TargetRegisterClass *RC =
78  STI.inMips16Mode()
79  ? &Mips::CPU16RegsRegClass
80  : STI.inMicroMipsMode()
81  ? &Mips::GPRMM16RegClass
82  : static_cast<const MipsTargetMachine &>(MF.getTarget())
83  .getABI()
84  .IsN64()
85  ? &Mips::GPR64RegClass
86  : &Mips::GPR32RegClass;
87  return GlobalBaseReg = MF.getRegInfo().createVirtualRegister(RC);
88 }
89 
91  return Mips16SPAliasReg;
92 }
94  // Return if it has already been initialized.
95  if (Mips16SPAliasReg)
96  return Mips16SPAliasReg;
97 
98  const TargetRegisterClass *RC = &Mips::CPU16RegsRegClass;
99  return Mips16SPAliasReg = MF.getRegInfo().createVirtualRegister(RC);
100 }
101 
103  for (int I = 0; I < 4; ++I) {
104  const TargetRegisterClass *RC =
105  static_cast<const MipsTargetMachine &>(MF.getTarget()).getABI().IsN64()
106  ? &Mips::GPR64RegClass
107  : &Mips::GPR32RegClass;
108 
109  EhDataRegFI[I] = MF.getFrameInfo()->CreateStackObject(RC->getSize(),
110  RC->getAlignment(), false);
111  }
112 }
113 
115  return CallsEhReturn && (FI == EhDataRegFI[0] || FI == EhDataRegFI[1]
116  || FI == EhDataRegFI[2] || FI == EhDataRegFI[3]);
117 }
118 
120  std::unique_ptr<const MipsCallEntry> &E = ExternalCallEntries[Name];
121 
122  if (!E)
123  E = llvm::make_unique<MipsCallEntry>(Name);
124 
125  return MachinePointerInfo(E.get());
126 }
127 
129  std::unique_ptr<const MipsCallEntry> &E = GlobalCallEntries[Val];
130 
131  if (!E)
132  E = llvm::make_unique<MipsCallEntry>(Val);
133 
134  return MachinePointerInfo(E.get());
135 }
136 
138  if (MoveF64ViaSpillFI == -1) {
139  MoveF64ViaSpillFI = MF.getFrameInfo()->CreateStackObject(
140  RC->getSize(), RC->getAlignment(), false);
141  }
142  return MoveF64ViaSpillFI;
143 }
144 
145 void MipsFunctionInfo::anchor() { }
bool mayAlias(const MachineFrameInfo *) const override
mayAlias - Return true if the memory pointed to by this PseudoSourceValue can ever alias an LLVM IR V...
unsigned createVirtualRegister(const TargetRegisterClass *RegClass)
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:188
unsigned getSize() const
getSize - Return the size of the register in bytes, which is also the size of a stack slot allocated ...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:325
unsigned getAlignment() const
getAlignment - Return the minimum required alignment for a register of this class.
bool inMicroMipsMode() const
bool inMips16Mode() const
MachinePointerInfo - This class contains a discriminated union of information about pointers in memor...
bool isEhDataRegFI(int FI) const
MachineFrameInfo * getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
bool isAliased(const MachineFrameInfo *) const override
isAliased - Test whether the memory pointed to by this PseudoSourceValue may also be pointed to by an...
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
MachinePointerInfo callPtrInfo(StringRef Name)
Create a MachinePointerInfo that has a MipsCallEntr object representing a GOT entry for an external f...
#define I(x, y, z)
Definition: MD5.cpp:54
#define N
bool isConstant(const MachineFrameInfo *) const override
isConstant - Test whether the memory pointed to by this PseudoSourceValue has a constant value...
int getMoveF64ViaSpillFI(const TargetRegisterClass *RC)
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS, const AllocaInst *Alloca=nullptr)
Create a new statically sized stack object, returning a nonnegative identifier to represent it...
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:38
static cl::opt< bool > FixGlobalBaseReg("mips-fix-global-base-reg", cl::Hidden, cl::init(true), cl::desc("Always use $gp as the global base register."))
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:40