1dff0c46cSDimitry Andric //===-- PPCMachineFunctionInfo.cpp - Private data used for PowerPC --------===//
2dff0c46cSDimitry Andric //
3dff0c46cSDimitry Andric //                     The LLVM Compiler Infrastructure
4dff0c46cSDimitry Andric //
5dff0c46cSDimitry Andric // This file is distributed under the University of Illinois Open Source
6dff0c46cSDimitry Andric // License. See LICENSE.TXT for details.
7dff0c46cSDimitry Andric //
8dff0c46cSDimitry Andric //===----------------------------------------------------------------------===//
9dff0c46cSDimitry Andric 
10dff0c46cSDimitry Andric #include "PPCMachineFunctionInfo.h"
11*26e25074SRoman Divacky #include "llvm/ADT/Twine.h"
12*26e25074SRoman Divacky #include "llvm/IR/DataLayout.h"
13*26e25074SRoman Divacky #include "llvm/MC/MCContext.h"
14dff0c46cSDimitry Andric 
15dff0c46cSDimitry Andric using namespace llvm;
16dff0c46cSDimitry Andric 
anchor()17dff0c46cSDimitry Andric void PPCFunctionInfo::anchor() {}
18dff0c46cSDimitry Andric 
getPICOffsetSymbol() const19*26e25074SRoman Divacky MCSymbol *PPCFunctionInfo::getPICOffsetSymbol() const {
20*26e25074SRoman Divacky   const DataLayout &DL = MF.getDataLayout();
21*26e25074SRoman Divacky   return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
22*26e25074SRoman Divacky                                            Twine(MF.getFunctionNumber()) +
23*26e25074SRoman Divacky                                            "$poff");
24 }
25 
getGlobalEPSymbol() const26 MCSymbol *PPCFunctionInfo::getGlobalEPSymbol() const {
27   const DataLayout &DL = MF.getDataLayout();
28   return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
29                                            "func_gep" +
30                                            Twine(MF.getFunctionNumber()));
31 }
32 
getLocalEPSymbol() const33 MCSymbol *PPCFunctionInfo::getLocalEPSymbol() const {
34   const DataLayout &DL = MF.getDataLayout();
35   return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
36                                            "func_lep" +
37                                            Twine(MF.getFunctionNumber()));
38 }
39 
getTOCOffsetSymbol() const40 MCSymbol *PPCFunctionInfo::getTOCOffsetSymbol() const {
41   const DataLayout &DL = MF.getDataLayout();
42   return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
43                                            "func_toc" +
44                                            Twine(MF.getFunctionNumber()));
45 }
46 
isLiveInSExt(unsigned VReg) const47 bool PPCFunctionInfo::isLiveInSExt(unsigned VReg) const {
48   for (const std::pair<unsigned, ISD::ArgFlagsTy> &LiveIn : LiveInAttrs)
49     if (LiveIn.first == VReg)
50       return LiveIn.second.isSExt();
51   return false;
52 }
53 
isLiveInZExt(unsigned VReg) const54 bool PPCFunctionInfo::isLiveInZExt(unsigned VReg) const {
55   for (const std::pair<unsigned, ISD::ArgFlagsTy> &LiveIn : LiveInAttrs)
56     if (LiveIn.first == VReg)
57       return LiveIn.second.isZExt();
58   return false;
59 }
60