xref: /freebsd/contrib/llvm-project/llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.cpp (revision 0b57cec536236d46e3dba9bd041533462f33dbb7)
1*0b57cec5SDimitry Andric //===-- PPCMachineFunctionInfo.cpp - Private data used for PowerPC --------===//
2*0b57cec5SDimitry Andric //
3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*0b57cec5SDimitry Andric //
7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
8*0b57cec5SDimitry Andric 
9*0b57cec5SDimitry Andric #include "PPCMachineFunctionInfo.h"
10*0b57cec5SDimitry Andric #include "llvm/ADT/Twine.h"
11*0b57cec5SDimitry Andric #include "llvm/IR/DataLayout.h"
12*0b57cec5SDimitry Andric #include "llvm/MC/MCContext.h"
13*0b57cec5SDimitry Andric 
14*0b57cec5SDimitry Andric using namespace llvm;
15*0b57cec5SDimitry Andric 
16*0b57cec5SDimitry Andric void PPCFunctionInfo::anchor() {}
17*0b57cec5SDimitry Andric 
18*0b57cec5SDimitry Andric MCSymbol *PPCFunctionInfo::getPICOffsetSymbol() const {
19*0b57cec5SDimitry Andric   const DataLayout &DL = MF.getDataLayout();
20*0b57cec5SDimitry Andric   return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
21*0b57cec5SDimitry Andric                                            Twine(MF.getFunctionNumber()) +
22*0b57cec5SDimitry Andric                                            "$poff");
23*0b57cec5SDimitry Andric }
24*0b57cec5SDimitry Andric 
25*0b57cec5SDimitry Andric MCSymbol *PPCFunctionInfo::getGlobalEPSymbol() const {
26*0b57cec5SDimitry Andric   const DataLayout &DL = MF.getDataLayout();
27*0b57cec5SDimitry Andric   return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
28*0b57cec5SDimitry Andric                                            "func_gep" +
29*0b57cec5SDimitry Andric                                            Twine(MF.getFunctionNumber()));
30*0b57cec5SDimitry Andric }
31*0b57cec5SDimitry Andric 
32*0b57cec5SDimitry Andric MCSymbol *PPCFunctionInfo::getLocalEPSymbol() const {
33*0b57cec5SDimitry Andric   const DataLayout &DL = MF.getDataLayout();
34*0b57cec5SDimitry Andric   return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
35*0b57cec5SDimitry Andric                                            "func_lep" +
36*0b57cec5SDimitry Andric                                            Twine(MF.getFunctionNumber()));
37*0b57cec5SDimitry Andric }
38*0b57cec5SDimitry Andric 
39*0b57cec5SDimitry Andric MCSymbol *PPCFunctionInfo::getTOCOffsetSymbol() const {
40*0b57cec5SDimitry Andric   const DataLayout &DL = MF.getDataLayout();
41*0b57cec5SDimitry Andric   return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
42*0b57cec5SDimitry Andric                                            "func_toc" +
43*0b57cec5SDimitry Andric                                            Twine(MF.getFunctionNumber()));
44*0b57cec5SDimitry Andric }
45*0b57cec5SDimitry Andric 
46*0b57cec5SDimitry Andric bool PPCFunctionInfo::isLiveInSExt(unsigned VReg) const {
47*0b57cec5SDimitry Andric   for (const std::pair<unsigned, ISD::ArgFlagsTy> &LiveIn : LiveInAttrs)
48*0b57cec5SDimitry Andric     if (LiveIn.first == VReg)
49*0b57cec5SDimitry Andric       return LiveIn.second.isSExt();
50*0b57cec5SDimitry Andric   return false;
51*0b57cec5SDimitry Andric }
52*0b57cec5SDimitry Andric 
53*0b57cec5SDimitry Andric bool PPCFunctionInfo::isLiveInZExt(unsigned VReg) const {
54*0b57cec5SDimitry Andric   for (const std::pair<unsigned, ISD::ArgFlagsTy> &LiveIn : LiveInAttrs)
55*0b57cec5SDimitry Andric     if (LiveIn.first == VReg)
56*0b57cec5SDimitry Andric       return LiveIn.second.isZExt();
57*0b57cec5SDimitry Andric   return false;
58*0b57cec5SDimitry Andric }
59