LLVM  14.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 
70  ParamtersType.push_back(Type);
71  switch (Type) {
72  case FixedType:
73  ++FixedParmsNum;
74  return;
75  case ShortFloatingPoint:
76  case LongFloatingPoint:
77  ++FloatingParmsNum;
78  return;
79  case VectorChar:
80  case VectorShort:
81  case VectorInt:
82  case VectorFloat:
83  ++VectorParmsNum;
84  return;
85  }
86  llvm_unreachable("Error ParamType type.");
87 }
88 
90 
91  uint32_t VectExtParamInfo = 0;
92  unsigned ShiftBits = 32 - XCOFF::TracebackTable::WidthOfParamType;
93  int Bits = 0;
94 
95  if (!hasVectorParms())
96  return 0;
97 
98  for (const auto &Elt : ParamtersType) {
99  switch (Elt) {
100  case VectorChar:
101  VectExtParamInfo <<= XCOFF::TracebackTable::WidthOfParamType;
102  VectExtParamInfo |=
105  break;
106  case VectorShort:
107  VectExtParamInfo <<= XCOFF::TracebackTable::WidthOfParamType;
108  VectExtParamInfo |=
111  break;
112  case VectorInt:
113  VectExtParamInfo <<= XCOFF::TracebackTable::WidthOfParamType;
114  VectExtParamInfo |=
117  break;
118  case VectorFloat:
119  VectExtParamInfo <<= XCOFF::TracebackTable::WidthOfParamType;
120  VectExtParamInfo |=
123  break;
124  default:
125  break;
126  }
127 
128  // There are only 32bits in the VectExtParamInfo.
129  if (Bits >= 32)
130  break;
131  }
132  return Bits < 32 ? VectExtParamInfo << (32 - Bits) : VectExtParamInfo;
133 }
134 
136  uint32_t ParamsTypeInfo = 0;
137  unsigned ShiftBits = 32 - XCOFF::TracebackTable::WidthOfParamType;
138 
139  int Bits = 0;
140  for (const auto &Elt : ParamtersType) {
141 
142  if (Bits > 31 || (Bits > 30 && (Elt != FixedType || hasVectorParms())))
143  break;
144 
145  switch (Elt) {
146  case FixedType:
147  if (hasVectorParms()) {
148  //'00' ==> fixed parameter if HasVectorParms is true.
149  ParamsTypeInfo <<= XCOFF::TracebackTable::WidthOfParamType;
150  ParamsTypeInfo |=
153  } else {
154  //'0' ==> fixed parameter if HasVectorParms is false.
155  ParamsTypeInfo <<= 1;
156  ++Bits;
157  }
158  break;
159  case ShortFloatingPoint:
160  // '10'b => floating point short parameter.
161  ParamsTypeInfo <<= XCOFF::TracebackTable::WidthOfParamType;
162  ParamsTypeInfo |=
165  break;
166  case LongFloatingPoint:
167  // '11'b => floating point long parameter.
168  ParamsTypeInfo <<= XCOFF::TracebackTable::WidthOfParamType;
169  ParamsTypeInfo |=
172  break;
173  case VectorChar:
174  case VectorShort:
175  case VectorInt:
176  case VectorFloat:
177  // '01' ==> vector parameter
178  ParamsTypeInfo <<= XCOFF::TracebackTable::WidthOfParamType;
179  ParamsTypeInfo |=
182  break;
183  }
184  }
185 
186  return Bits < 32 ? ParamsTypeInfo << (32 - Bits) : ParamsTypeInfo;
187 }
llvm
This is an optimization pass for GlobalISel generic memory operations.
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:113
llvm::XCOFF::TracebackTable::WidthOfParamType
static constexpr uint8_t WidthOfParamType
Definition: XCOFF.h:409
llvm::MachineFunction::getContext
MCContext & getContext() const
Definition: MachineFunction.h:586
llvm::PPCFunctionInfo::VectorChar
@ VectorChar
Definition: PPCMachineFunctionInfo.h:30
llvm::MachineFunction::getFunctionNumber
unsigned getFunctionNumber() const
getFunctionNumber - Return a unique ID for the current function.
Definition: MachineFunction.h:609
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:143
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::PPCFunctionInfo::getLocalEPSymbol
MCSymbol * getLocalEPSymbol(MachineFunction &MF) const
Definition: PPCMachineFunctionInfo.cpp:40
llvm::tgtok::Bits
@ Bits
Definition: TGLexer.h:50
llvm::PPCFunctionInfo::VectorInt
@ VectorInt
Definition: PPCMachineFunctionInfo.h:32
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:191
Twine.h
MCContext.h
llvm::PPCFunctionInfo::ParamType
ParamType
Definition: PPCMachineFunctionInfo.h:26
llvm::cl::opt< bool >
llvm::PPCFunctionInfo::getTOCOffsetSymbol
MCSymbol * getTOCOffsetSymbol(MachineFunction &MF) const
Definition: PPCMachineFunctionInfo.cpp:47
llvm::PPCFunctionInfo::hasVectorParms
bool hasVectorParms() const
Definition: PPCMachineFunctionInfo.h:231
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:441
llvm::PPCFunctionInfo::getParmsType
uint32_t getParmsType() const
Definition: PPCMachineFunctionInfo.cpp:135
llvm::PPCFunctionInfo::getGlobalEPSymbol
MCSymbol * getGlobalEPSymbol(MachineFunction &MF) const
Definition: PPCMachineFunctionInfo.cpp:33
llvm::XCOFF::TracebackTable::ParmTypeIsVectorBits
static constexpr uint32_t ParmTypeIsVectorBits
Definition: XCOFF.h:389
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::XCOFF::TracebackTable::ParmTypeIsVectorFloatBit
static constexpr uint32_t ParmTypeIsVectorFloatBit
Definition: XCOFF.h:407
llvm::XCOFF::TracebackTable::ParmTypeIsFloatingBits
static constexpr uint32_t ParmTypeIsFloatingBits
Definition: XCOFF.h:390
llvm::MachineFunction
Definition: MachineFunction.h:234
llvm::XCOFF::TracebackTable::ParmTypeIsVectorIntBit
static constexpr uint32_t ParmTypeIsVectorIntBit
Definition: XCOFF.h:406
DataLayout.h
llvm::XCOFF::TracebackTable::ParmTypeIsVectorCharBit
static constexpr uint32_t ParmTypeIsVectorCharBit
Definition: XCOFF.h:404
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:134
llvm::XCOFF::TracebackTable::ParmTypeIsDoubleBits
static constexpr uint32_t ParmTypeIsDoubleBits
Definition: XCOFF.h:391
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:83
llvm::PPCFunctionInfo::FixedType
@ FixedType
Definition: PPCMachineFunctionInfo.h:27
llvm::XCOFF::TracebackTable::ParmTypeIsFixedBits
static constexpr uint32_t ParmTypeIsFixedBits
Definition: XCOFF.h:388
llvm::PPCFunctionInfo::VectorFloat
@ VectorFloat
Definition: PPCMachineFunctionInfo.h:33
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
llvm::PPCFunctionInfo::LongFloatingPoint
@ LongFloatingPoint
Definition: PPCMachineFunctionInfo.h:29
llvm::PPCFunctionInfo::VectorShort
@ VectorShort
Definition: PPCMachineFunctionInfo.h:31
PPCMachineFunctionInfo.h
llvm::MachineFunction::getDataLayout
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
Definition: MachineFunction.cpp:261
llvm::PPCFunctionInfo::ShortFloatingPoint
@ ShortFloatingPoint
Definition: PPCMachineFunctionInfo.h:28
llvm::PPCFunctionInfo::getVecExtParmsType
uint32_t getVecExtParmsType() const
Definition: PPCMachineFunctionInfo.cpp:89
llvm::XCOFF::TracebackTable::ParmTypeIsVectorShortBit
static constexpr uint32_t ParmTypeIsVectorShortBit
Definition: XCOFF.h:405
llvm::cl::desc
Definition: CommandLine.h:412