1 //===-- MipsMachineFunctionInfo.cpp - Private data used for Mips ----------===//
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 #include "MipsMachineFunction.h"
11 #include "MipsInstrInfo.h"
12 #include "MipsSubtarget.h"
13 #include "MCTargetDesc/MipsBaseInfo.h"
14 #include "llvm/Function.h"
15 #include "llvm/CodeGen/MachineInstrBuilder.h"
16 #include "llvm/CodeGen/MachineRegisterInfo.h"
17 #include "llvm/Support/CommandLine.h"
22 FixGlobalBaseReg("mips-fix-global-base-reg", cl::Hidden, cl::init(true),
23 cl::desc("Always use $gp as the global base register."));
25 bool MipsFunctionInfo::globalBaseRegFixed() const {
26 return FixGlobalBaseReg;
29 bool MipsFunctionInfo::globalBaseRegSet() const {
33 unsigned MipsFunctionInfo::getGlobalBaseReg() {
34 // Return if it has already been initialized.
38 const MipsSubtarget &ST = MF.getTarget().getSubtarget<MipsSubtarget>();
40 if (FixGlobalBaseReg) // $gp is the global base register.
41 return GlobalBaseReg = ST.isABI_N64() ? Mips::GP_64 : Mips::GP;
43 const TargetRegisterClass *RC;
45 Mips::CPU64RegsRegisterClass : Mips::CPURegsRegisterClass;
47 return GlobalBaseReg = MF.getRegInfo().createVirtualRegister(RC);
50 void MipsFunctionInfo::anchor() { }