LLVM  13.0.0git
PPCMachineFunctionInfo.cpp
Go to the documentation of this file.
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 
10 #include "llvm/ADT/Twine.h"
12 #include "llvm/IR/DataLayout.h"
13 #include "llvm/MC/MCContext.h"
15 
16 using namespace llvm;
18  "ppc-disable-non-volatile-cr",
19  cl::desc("Disable the use of non-volatile CR register fields"),
20  cl::init(false), cl::Hidden);
21 
22 void PPCFunctionInfo::anchor() {}
24  : DisableNonVolatileCR(PPCDisableNonVolatileCR) {}
25 
27  const DataLayout &DL = MF.getDataLayout();
28  return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
29  Twine(MF.getFunctionNumber()) +
30  "$poff");
31 }
32 
34  const DataLayout &DL = MF.getDataLayout();
35  return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
36  "func_gep" +
37  Twine(MF.getFunctionNumber()));
38 }
39 
41  const DataLayout &DL = MF.getDataLayout();
42  return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
43  "func_lep" +
44  Twine(MF.getFunctionNumber()));
45 }
46 
48  const DataLayout &DL = MF.getDataLayout();
49  return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
50  "func_toc" +
51  Twine(MF.getFunctionNumber()));
52 }
53 
55  for (const std::pair<Register, ISD::ArgFlagsTy> &LiveIn : LiveInAttrs)
56  if (LiveIn.first == VReg)
57  return LiveIn.second.isSExt();
58  return false;
59 }
60 
62  for (const std::pair<Register, ISD::ArgFlagsTy> &LiveIn : LiveInAttrs)
63  if (LiveIn.first == VReg)
64  return LiveIn.second.isZExt();
65  return false;
66 }
67 
69  uint32_t CopyParamType = ParameterType;
70  int Bits = 0;
71 
72  // If it is fixed type, we only need to increase the FixedParamNum, for
73  // the bit encode of fixed type is bit of zero, we do not need to change the
74  // ParamType.
75  if (Type == FixedType) {
76  ++FixedParamNum;
77  return;
78  }
79 
80  ++FloatingPointParamNum;
81 
82  for (int I = 0;
83  I < static_cast<int>(FloatingPointParamNum + FixedParamNum - 1); ++I) {
85  // '10'b => floating point short parameter.
86  // '11'b => floating point long parameter.
87  CopyParamType <<= 2;
88  Bits += 2;
89  } else {
90  // '0'b => fixed parameter.
91  CopyParamType <<= 1;
92  ++Bits;
93  }
94  }
95 
96  assert(Type != FixedType && "FixedType should already be handled.");
97  if (Bits < 31)
98  ParameterType |= Type << (30 - Bits);
99 }
llvm
Definition: AllocatorList.h:23
llvm::PPCFunctionInfo::appendParameterType
void appendParameterType(ParamType Type)
Definition: PPCMachineFunctionInfo.cpp:68
llvm::MCSymbol
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:112
llvm::MachineFunction::getContext
MCContext & getContext() const
Definition: MachineFunction.h:510
llvm::MachineFunction::getFunctionNumber
unsigned getFunctionNumber() const
getFunctionNumber - Return a unique ID for the current function.
Definition: MachineFunction.h:533
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:143
llvm::XCOFF::TracebackTable::ParmTypeIsFloatingBit
static constexpr uint32_t ParmTypeIsFloatingBit
Definition: XCOFF.h:371
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:46
llvm::PPCFunctionInfo::getLocalEPSymbol
MCSymbol * getLocalEPSymbol(MachineFunction &MF) const
Definition: PPCMachineFunctionInfo.cpp:40
llvm::tgtok::Bits
@ Bits
Definition: TGLexer.h:50
llvm::PPCFunctionInfo::getPICOffsetSymbol
MCSymbol * getPICOffsetSymbol(MachineFunction &MF) const
Definition: PPCMachineFunctionInfo.cpp:26
XCOFF.h
CommandLine.h
llvm::MCContext::getOrCreateSymbol
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Definition: MCContext.cpp:187
Twine.h
MCContext.h
llvm::PPCFunctionInfo::ParamType
ParamType
Definition: PPCMachineFunctionInfo.h:28
llvm::cl::opt< bool >
llvm::PPCFunctionInfo::getTOCOffsetSymbol
MCSymbol * getTOCOffsetSymbol(MachineFunction &MF) const
Definition: PPCMachineFunctionInfo.cpp:47
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:443
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::PPCFunctionInfo::getGlobalEPSymbol
MCSymbol * getGlobalEPSymbol(MachineFunction &MF) const
Definition: PPCMachineFunctionInfo.cpp:33
PPCDisableNonVolatileCR
static cl::opt< bool > PPCDisableNonVolatileCR("ppc-disable-non-volatile-cr", cl::desc("Disable the use of non-volatile CR register fields"), cl::init(false), cl::Hidden)
llvm::MachineFunction
Definition: MachineFunction.h:230
DataLayout.h
uint32_t
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::Register
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
llvm::PPCFunctionInfo::PPCFunctionInfo
PPCFunctionInfo(const MachineFunction &MF)
Definition: PPCMachineFunctionInfo.cpp:23
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:80
llvm::PPCFunctionInfo::FixedType
@ FixedType
Definition: PPCMachineFunctionInfo.h:29
llvm::PPCFunctionInfo::isLiveInSExt
bool isLiveInSExt(Register VReg) const
This function returns true if the specified vreg is a live-in register and sign-extended.
Definition: PPCMachineFunctionInfo.cpp:54
llvm::PPCFunctionInfo::isLiveInZExt
bool isLiveInZExt(Register VReg) const
This function returns true if the specified vreg is a live-in register and zero-extended.
Definition: PPCMachineFunctionInfo.cpp:61
PPCMachineFunctionInfo.h
llvm::MachineFunction::getDataLayout
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
Definition: MachineFunction.cpp:260
llvm::cl::desc
Definition: CommandLine.h:414