LLVM  16.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 
29  &Src2DstMBB) const {
30  return DestMF.cloneInfo<PPCFunctionInfo>(*this);
31 }
32 
34  const DataLayout &DL = MF.getDataLayout();
35  return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
36  Twine(MF.getFunctionNumber()) +
37  "$poff");
38 }
39 
41  const DataLayout &DL = MF.getDataLayout();
42  return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
43  "func_gep" +
44  Twine(MF.getFunctionNumber()));
45 }
46 
48  const DataLayout &DL = MF.getDataLayout();
49  return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
50  "func_lep" +
51  Twine(MF.getFunctionNumber()));
52 }
53 
55  const DataLayout &DL = MF.getDataLayout();
56  return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
57  "func_toc" +
58  Twine(MF.getFunctionNumber()));
59 }
60 
62  for (const std::pair<Register, ISD::ArgFlagsTy> &LiveIn : LiveInAttrs)
63  if (LiveIn.first == VReg)
64  return LiveIn.second.isSExt();
65  return false;
66 }
67 
69  for (const std::pair<Register, ISD::ArgFlagsTy> &LiveIn : LiveInAttrs)
70  if (LiveIn.first == VReg)
71  return LiveIn.second.isZExt();
72  return false;
73 }
74 
76 
77  ParamtersType.push_back(Type);
78  switch (Type) {
79  case FixedType:
80  ++FixedParmsNum;
81  return;
82  case ShortFloatingPoint:
83  case LongFloatingPoint:
84  ++FloatingParmsNum;
85  return;
86  case VectorChar:
87  case VectorShort:
88  case VectorInt:
89  case VectorFloat:
90  ++VectorParmsNum;
91  return;
92  }
93  llvm_unreachable("Error ParamType type.");
94 }
95 
97 
98  uint32_t VectExtParamInfo = 0;
99  unsigned ShiftBits = 32 - XCOFF::TracebackTable::WidthOfParamType;
100  int Bits = 0;
101 
102  if (!hasVectorParms())
103  return 0;
104 
105  for (const auto &Elt : ParamtersType) {
106  switch (Elt) {
107  case VectorChar:
108  VectExtParamInfo <<= XCOFF::TracebackTable::WidthOfParamType;
109  VectExtParamInfo |=
112  break;
113  case VectorShort:
114  VectExtParamInfo <<= XCOFF::TracebackTable::WidthOfParamType;
115  VectExtParamInfo |=
118  break;
119  case VectorInt:
120  VectExtParamInfo <<= XCOFF::TracebackTable::WidthOfParamType;
121  VectExtParamInfo |=
124  break;
125  case VectorFloat:
126  VectExtParamInfo <<= XCOFF::TracebackTable::WidthOfParamType;
127  VectExtParamInfo |=
130  break;
131  default:
132  break;
133  }
134 
135  // There are only 32bits in the VectExtParamInfo.
136  if (Bits >= 32)
137  break;
138  }
139  return Bits < 32 ? VectExtParamInfo << (32 - Bits) : VectExtParamInfo;
140 }
141 
143  uint32_t ParamsTypeInfo = 0;
144  unsigned ShiftBits = 32 - XCOFF::TracebackTable::WidthOfParamType;
145 
146  int Bits = 0;
147  for (const auto &Elt : ParamtersType) {
148 
149  if (Bits > 31 || (Bits > 30 && (Elt != FixedType || hasVectorParms())))
150  break;
151 
152  switch (Elt) {
153  case FixedType:
154  if (hasVectorParms()) {
155  //'00' ==> fixed parameter if HasVectorParms is true.
156  ParamsTypeInfo <<= XCOFF::TracebackTable::WidthOfParamType;
157  ParamsTypeInfo |=
160  } else {
161  //'0' ==> fixed parameter if HasVectorParms is false.
162  ParamsTypeInfo <<= 1;
163  ++Bits;
164  }
165  break;
166  case ShortFloatingPoint:
167  // '10'b => floating point short parameter.
168  ParamsTypeInfo <<= XCOFF::TracebackTable::WidthOfParamType;
169  ParamsTypeInfo |=
172  break;
173  case LongFloatingPoint:
174  // '11'b => floating point long parameter.
175  ParamsTypeInfo <<= XCOFF::TracebackTable::WidthOfParamType;
176  ParamsTypeInfo |=
179  break;
180  case VectorChar:
181  case VectorShort:
182  case VectorInt:
183  case VectorFloat:
184  // '01' ==> vector parameter
185  ParamsTypeInfo <<= XCOFF::TracebackTable::WidthOfParamType;
186  ParamsTypeInfo |=
189  break;
190  }
191  }
192 
193  return Bits < 32 ? ParamsTypeInfo << (32 - Bits) : ParamsTypeInfo;
194 }
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::PPCFunctionInfo::appendParameterType
void appendParameterType(ParamType Type)
Definition: PPCMachineFunctionInfo.cpp:75
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:442
llvm::MachineFunction::getContext
MCContext & getContext() const
Definition: MachineFunction.h:609
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:632
llvm::PPCFunctionInfo::clone
MachineFunctionInfo * clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF, const DenseMap< MachineBasicBlock *, MachineBasicBlock * > &Src2DstMBB) const override
Make a functionally equivalent copy of this MachineFunctionInfo in MF.
Definition: PPCMachineFunctionInfo.cpp:27
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:139
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:47
llvm::tgtok::Bits
@ Bits
Definition: TGLexer.h:50
llvm::PPCFunctionInfo
PPCFunctionInfo - This class is derived from MachineFunction private PowerPC target-specific informat...
Definition: PPCMachineFunctionInfo.h:24
llvm::PPCFunctionInfo::VectorInt
@ VectorInt
Definition: PPCMachineFunctionInfo.h:32
llvm::PPCFunctionInfo::getPICOffsetSymbol
MCSymbol * getPICOffsetSymbol(MachineFunction &MF) const
Definition: PPCMachineFunctionInfo.cpp:33
XCOFF.h
CommandLine.h
llvm::MCContext::getOrCreateSymbol
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Definition: MCContext.cpp:201
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:54
llvm::PPCFunctionInfo::hasVectorParms
bool hasVectorParms() const
Definition: PPCMachineFunctionInfo.h:236
llvm::BumpPtrAllocatorImpl
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:63
llvm::DenseMap
Definition: DenseMap.h:714
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:446
llvm::PPCFunctionInfo::getParmsType
uint32_t getParmsType() const
Definition: PPCMachineFunctionInfo.cpp:142
llvm::PPCFunctionInfo::getGlobalEPSymbol
MCSymbol * getGlobalEPSymbol(MachineFunction &MF) const
Definition: PPCMachineFunctionInfo.cpp:40
llvm::XCOFF::TracebackTable::ParmTypeIsVectorBits
static constexpr uint32_t ParmTypeIsVectorBits
Definition: XCOFF.h:422
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:440
llvm::XCOFF::TracebackTable::ParmTypeIsFloatingBits
static constexpr uint32_t ParmTypeIsFloatingBits
Definition: XCOFF.h:423
llvm::MachineFunction
Definition: MachineFunction.h:257
llvm::XCOFF::TracebackTable::ParmTypeIsVectorIntBit
static constexpr uint32_t ParmTypeIsVectorIntBit
Definition: XCOFF.h:439
DataLayout.h
llvm::XCOFF::TracebackTable::ParmTypeIsVectorCharBit
static constexpr uint32_t ParmTypeIsVectorCharBit
Definition: XCOFF.h:437
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:143
llvm::XCOFF::TracebackTable::ParmTypeIsDoubleBits
static constexpr uint32_t ParmTypeIsDoubleBits
Definition: XCOFF.h:424
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::MachineFunction::cloneInfo
Ty * cloneInfo(const Ty &Old)
Definition: MachineFunction.h:766
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:81
llvm::PPCFunctionInfo::FixedType
@ FixedType
Definition: PPCMachineFunctionInfo.h:27
llvm::XCOFF::TracebackTable::ParmTypeIsFixedBits
static constexpr uint32_t ParmTypeIsFixedBits
Definition: XCOFF.h:421
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:61
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:68
llvm::PPCFunctionInfo::LongFloatingPoint
@ LongFloatingPoint
Definition: PPCMachineFunctionInfo.h:29
llvm::PPCFunctionInfo::VectorShort
@ VectorShort
Definition: PPCMachineFunctionInfo.h:31
Allocator
Basic Register Allocator
Definition: RegAllocBasic.cpp:143
PPCMachineFunctionInfo.h
llvm::MachineFunction::getDataLayout
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
Definition: MachineFunction.cpp:285
llvm::PPCFunctionInfo::ShortFloatingPoint
@ ShortFloatingPoint
Definition: PPCMachineFunctionInfo.h:28
llvm::PPCFunctionInfo::getVecExtParmsType
uint32_t getVecExtParmsType() const
Definition: PPCMachineFunctionInfo.cpp:96
llvm::XCOFF::TracebackTable::ParmTypeIsVectorShortBit
static constexpr uint32_t ParmTypeIsVectorShortBit
Definition: XCOFF.h:438
llvm::cl::desc
Definition: CommandLine.h:412
llvm::MachineFunctionInfo
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...
Definition: MachineFunction.h:95