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" 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" 18 19 using namespace llvm; 20 21 static cl::opt<bool> 22 FixGlobalBaseReg("mips-fix-global-base-reg", cl::Hidden, cl::init(true), 23 cl::desc("Always use $gp as the global base register.")); 24 globalBaseRegSet() const25bool MipsFunctionInfo::globalBaseRegSet() const { 26 return GlobalBaseReg; 27 } 28 getGlobalBaseReg()29unsigned MipsFunctionInfo::getGlobalBaseReg() { 30 // Return if it has already been initialized. 31 if (GlobalBaseReg) 32 return GlobalBaseReg; 33 34 const MipsSubtarget &ST = MF.getTarget().getSubtarget<MipsSubtarget>(); 35 36 const TargetRegisterClass *RC; 37 if (ST.inMips16Mode()) 38 RC=(const TargetRegisterClass*)&Mips::CPU16RegsRegClass; 39 else 40 RC = ST.isABI_N64() ? 41 (const TargetRegisterClass*)&Mips::CPU64RegsRegClass : 42 (const TargetRegisterClass*)&Mips::CPURegsRegClass; 43 return GlobalBaseReg = MF.getRegInfo().createVirtualRegister(RC); 44 } 45 anchor()46void MipsFunctionInfo::anchor() { } 47