LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
10 #include "MipsMachineFunction.h"
12 #include "MipsInstrInfo.h"
13 #include "MipsSubtarget.h"
16 #include "llvm/IR/Function.h"
19 
20 using namespace llvm;
21 
22 static cl::opt<bool>
23 FixGlobalBaseReg("mips-fix-global-base-reg", cl::Hidden, cl::init(true),
24  cl::desc("Always use $gp as the global base register."));
25 
26 // class MipsCallEntry.
28 #ifndef NDEBUG
29  Name = N;
30  Val = 0;
31 #endif
32 }
33 
35 #ifndef NDEBUG
36  Val = V;
37 #endif
38 }
39 
41  return false;
42 }
43 
45  return false;
46 }
47 
49  return false;
50 }
51 
52 void MipsCallEntry::printCustom(raw_ostream &O) const {
53  O << "MipsCallEntry: ";
54 #ifndef NDEBUG
55  if (Val)
56  O << Val->getName();
57  else
58  O << Name;
59 #endif
60 }
61 
64  I = ExternalCallEntries.begin(), E = ExternalCallEntries.end(); I != E;
65  ++I)
66  delete I->getValue();
67 
69  I = GlobalCallEntries.begin(), E = GlobalCallEntries.end(); I != E; ++I)
70  delete I->second;
71 }
72 
74  return GlobalBaseReg;
75 }
76 
78  // Return if it has already been initialized.
79  if (GlobalBaseReg)
80  return GlobalBaseReg;
81 
83 
84  const TargetRegisterClass *RC;
85  if (ST.inMips16Mode())
86  RC=(const TargetRegisterClass*)&Mips::CPU16RegsRegClass;
87  else
88  RC = ST.isABI_N64() ?
89  (const TargetRegisterClass*)&Mips::GPR64RegClass :
90  (const TargetRegisterClass*)&Mips::GPR32RegClass;
91  return GlobalBaseReg = MF.getRegInfo().createVirtualRegister(RC);
92 }
93 
95  return Mips16SPAliasReg;
96 }
98  // Return if it has already been initialized.
99  if (Mips16SPAliasReg)
100  return Mips16SPAliasReg;
101 
102  const TargetRegisterClass *RC;
103  RC=(const TargetRegisterClass*)&Mips::CPU16RegsRegClass;
104  return Mips16SPAliasReg = MF.getRegInfo().createVirtualRegister(RC);
105 }
106 
108  for (int I = 0; I < 4; ++I) {
110  const TargetRegisterClass *RC = ST.isABI_N64() ?
111  &Mips::GPR64RegClass : &Mips::GPR32RegClass;
112 
113  EhDataRegFI[I] = MF.getFrameInfo()->CreateStackObject(RC->getSize(),
114  RC->getAlignment(), false);
115  }
116 }
117 
119  return CallsEhReturn && (FI == EhDataRegFI[0] || FI == EhDataRegFI[1]
120  || FI == EhDataRegFI[2] || FI == EhDataRegFI[3]);
121 }
122 
124  const MipsCallEntry *&E = ExternalCallEntries[Name];
125 
126  if (!E)
127  E = new MipsCallEntry(Name);
128 
129  return MachinePointerInfo(E);
130 }
131 
133  const MipsCallEntry *&E = GlobalCallEntries[Val];
134 
135  if (!E)
136  E = new MipsCallEntry(Val);
137 
138  return MachinePointerInfo(E);
139 }
140 
141 void MipsFunctionInfo::anchor() { }
virtual bool mayAlias(const MachineFrameInfo *) const
unsigned createVirtualRegister(const TargetRegisterClass *RegClass)
StringRef getName() const
Definition: Value.cpp:167
virtual bool isConstant(const MachineFrameInfo *) const
Abstract Stack Frame Information.
bool isABI_N64() const
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:314
A class derived from PseudoSourceValue that represents a GOT entry resolved by lazy-binding.
virtual bool isAliased(const MachineFrameInfo *) const
bool inMips16Mode() const
bool isEhDataRegFI(int FI) const
const STC & getSubtarget() const
MachineFrameInfo * getFrameInfo()
MipsCallEntry(const StringRef &N)
int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS, bool MayNeedSP=false, const AllocaInst *Alloca=0)
MachineRegisterInfo & getRegInfo()
#define I(x, y, z)
Definition: MD5.cpp:54
#define N
const TargetMachine & getTarget() const
MachinePointerInfo callPtrInfo(const StringRef &Name)
Create a MachinePointerInfo that has a MipsCallEntr object representing a GOT entry for an external f...
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."))