blob: 2f65d6a2855be5b54ab095c1823249e2518b144c [file] [log] [blame]
Jia Liub22310f2012-02-18 12:03:15 +00001//===-- PPCMachineFunctionInfo.cpp - Private data used for PowerPC --------===//
David Blaikiea379b1812011-12-20 02:50:00 +00002//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
David Blaikiea379b1812011-12-20 02:50:00 +00006//
7//===----------------------------------------------------------------------===//
8
9#include "PPCMachineFunctionInfo.h"
Eugene Zelenko8187c192017-01-13 00:58:58 +000010#include "llvm/ADT/Twine.h"
Hal Finkel3ee2af72014-07-18 23:29:49 +000011#include "llvm/IR/DataLayout.h"
12#include "llvm/MC/MCContext.h"
David Blaikiea379b1812011-12-20 02:50:00 +000013
14using namespace llvm;
15
Eugene Zelenko8187c192017-01-13 00:58:58 +000016void PPCFunctionInfo::anchor() {}
David Blaikiea379b1812011-12-20 02:50:00 +000017
Hal Finkel3ee2af72014-07-18 23:29:49 +000018MCSymbol *PPCFunctionInfo::getPICOffsetSymbol() const {
Mehdi Aminibd7287e2015-07-16 06:11:10 +000019 const DataLayout &DL = MF.getDataLayout();
20 return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
Eric Christopher8b770652015-01-26 19:03:15 +000021 Twine(MF.getFunctionNumber()) +
22 "$poff");
Hal Finkel3ee2af72014-07-18 23:29:49 +000023}
Ulrich Weigand46ff7ec2016-01-13 13:12:23 +000024
25MCSymbol *PPCFunctionInfo::getGlobalEPSymbol() const {
26 const DataLayout &DL = MF.getDataLayout();
27 return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
28 "func_gep" +
29 Twine(MF.getFunctionNumber()));
30}
31
32MCSymbol *PPCFunctionInfo::getLocalEPSymbol() const {
33 const DataLayout &DL = MF.getDataLayout();
34 return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
35 "func_lep" +
36 Twine(MF.getFunctionNumber()));
37}
38
39MCSymbol *PPCFunctionInfo::getTOCOffsetSymbol() const {
40 const DataLayout &DL = MF.getDataLayout();
41 return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
42 "func_toc" +
43 Twine(MF.getFunctionNumber()));
44}
Hiroshi Inouee3a3e3c2017-10-16 04:12:57 +000045
46bool PPCFunctionInfo::isLiveInSExt(unsigned VReg) const {
47 for (const std::pair<unsigned, ISD::ArgFlagsTy> &LiveIn : LiveInAttrs)
48 if (LiveIn.first == VReg)
49 return LiveIn.second.isSExt();
50 return false;
51}
52
53bool PPCFunctionInfo::isLiveInZExt(unsigned VReg) const {
54 for (const std::pair<unsigned, ISD::ArgFlagsTy> &LiveIn : LiveInAttrs)
55 if (LiveIn.first == VReg)
56 return LiveIn.second.isZExt();
57 return false;
58}