1 //===-- PPCMachineFunctionInfo.cpp - Private data used for PowerPC --------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "PPCMachineFunctionInfo.h" 10 #include "llvm/ADT/Twine.h" 11 #include "llvm/IR/DataLayout.h" 12 #include "llvm/MC/MCContext.h" 13 #include "llvm/Support/CommandLine.h" 14 15 using namespace llvm; 16 static cl::opt<bool> PPCDisableNonVolatileCR( 17 "ppc-disable-non-volatile-cr", 18 cl::desc("Disable the use of non-volatile CR register fields"), 19 cl::init(false), cl::Hidden); 20 21 void PPCFunctionInfo::anchor() {} 22 PPCFunctionInfo::PPCFunctionInfo(const MachineFunction &MF) 23 : DisableNonVolatileCR(PPCDisableNonVolatileCR) {} 24 25 MCSymbol *PPCFunctionInfo::getPICOffsetSymbol(MachineFunction &MF) const { 26 const DataLayout &DL = MF.getDataLayout(); 27 return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) + 28 Twine(MF.getFunctionNumber()) + 29 "$poff"); 30 } 31 32 MCSymbol *PPCFunctionInfo::getGlobalEPSymbol(MachineFunction &MF) const { 33 const DataLayout &DL = MF.getDataLayout(); 34 return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) + 35 "func_gep" + 36 Twine(MF.getFunctionNumber())); 37 } 38 39 MCSymbol *PPCFunctionInfo::getLocalEPSymbol(MachineFunction &MF) const { 40 const DataLayout &DL = MF.getDataLayout(); 41 return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) + 42 "func_lep" + 43 Twine(MF.getFunctionNumber())); 44 } 45 46 MCSymbol *PPCFunctionInfo::getTOCOffsetSymbol(MachineFunction &MF) const { 47 const DataLayout &DL = MF.getDataLayout(); 48 return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) + 49 "func_toc" + 50 Twine(MF.getFunctionNumber())); 51 } 52 53 bool PPCFunctionInfo::isLiveInSExt(Register VReg) const { 54 for (const std::pair<Register, ISD::ArgFlagsTy> &LiveIn : LiveInAttrs) 55 if (LiveIn.first == VReg) 56 return LiveIn.second.isSExt(); 57 return false; 58 } 59 60 bool PPCFunctionInfo::isLiveInZExt(Register VReg) const { 61 for (const std::pair<Register, ISD::ArgFlagsTy> &LiveIn : LiveInAttrs) 62 if (LiveIn.first == VReg) 63 return LiveIn.second.isZExt(); 64 return false; 65 } 66