1 //===-- PPCMachineFunctionInfo.cpp - Private data used for PowerPC --------===//
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
7 //===----------------------------------------------------------------------===//
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"
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);
21 void PPCFunctionInfo::anchor() {}
22 PPCFunctionInfo::PPCFunctionInfo(const MachineFunction &MF)
23 : DisableNonVolatileCR(PPCDisableNonVolatileCR) {}
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()) +
32 MCSymbol *PPCFunctionInfo::getGlobalEPSymbol(MachineFunction &MF) const {
33 const DataLayout &DL = MF.getDataLayout();
34 return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
36 Twine(MF.getFunctionNumber()));
39 MCSymbol *PPCFunctionInfo::getLocalEPSymbol(MachineFunction &MF) const {
40 const DataLayout &DL = MF.getDataLayout();
41 return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
43 Twine(MF.getFunctionNumber()));
46 MCSymbol *PPCFunctionInfo::getTOCOffsetSymbol(MachineFunction &MF) const {
47 const DataLayout &DL = MF.getDataLayout();
48 return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
50 Twine(MF.getFunctionNumber()));
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();
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();