LLVM 20.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
16using 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
22void PPCFunctionInfo::anchor() {}
24 const TargetSubtargetInfo *STI)
25 : DisableNonVolatileCR(PPCDisableNonVolatileCR) {}
26
30 &Src2DstMBB) const {
31 return DestMF.cloneInfo<PPCFunctionInfo>(*this);
32}
33
35 const DataLayout &DL = MF.getDataLayout();
36 return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
38 "$poff");
39}
40
42 const DataLayout &DL = MF.getDataLayout();
43 return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
44 "func_gep" +
46}
47
49 const DataLayout &DL = MF.getDataLayout();
50 return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
51 "func_lep" +
53}
54
56 const DataLayout &DL = MF.getDataLayout();
57 return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
58 "func_toc" +
60}
61
63 for (const std::pair<Register, ISD::ArgFlagsTy> &LiveIn : LiveInAttrs)
64 if (LiveIn.first == VReg)
65 return LiveIn.second.isSExt();
66 return false;
67}
68
70 for (const std::pair<Register, ISD::ArgFlagsTy> &LiveIn : LiveInAttrs)
71 if (LiveIn.first == VReg)
72 return LiveIn.second.isZExt();
73 return false;
74}
75
77
78 ParamtersType.push_back(Type);
79 switch (Type) {
80 case FixedType:
81 ++FixedParmsNum;
82 return;
85 ++FloatingParmsNum;
86 return;
87 case VectorChar:
88 case VectorShort:
89 case VectorInt:
90 case VectorFloat:
91 ++VectorParmsNum;
92 return;
93 }
94 llvm_unreachable("Error ParamType type.");
95}
96
98
99 uint32_t VectExtParamInfo = 0;
100 unsigned ShiftBits = 32 - XCOFF::TracebackTable::WidthOfParamType;
101 int Bits = 0;
102
103 if (!hasVectorParms())
104 return 0;
105
106 for (const auto &Elt : ParamtersType) {
107 switch (Elt) {
108 case VectorChar:
109 VectExtParamInfo <<= XCOFF::TracebackTable::WidthOfParamType;
110 VectExtParamInfo |=
113 break;
114 case VectorShort:
115 VectExtParamInfo <<= XCOFF::TracebackTable::WidthOfParamType;
116 VectExtParamInfo |=
119 break;
120 case VectorInt:
121 VectExtParamInfo <<= XCOFF::TracebackTable::WidthOfParamType;
122 VectExtParamInfo |=
125 break;
126 case VectorFloat:
127 VectExtParamInfo <<= XCOFF::TracebackTable::WidthOfParamType;
128 VectExtParamInfo |=
131 break;
132 default:
133 break;
134 }
135
136 // There are only 32bits in the VectExtParamInfo.
137 if (Bits >= 32)
138 break;
139 }
140 return Bits < 32 ? VectExtParamInfo << (32 - Bits) : VectExtParamInfo;
141}
142
144 uint32_t ParamsTypeInfo = 0;
145 unsigned ShiftBits = 32 - XCOFF::TracebackTable::WidthOfParamType;
146
147 int Bits = 0;
148 for (const auto &Elt : ParamtersType) {
149
150 if (Bits > 31 || (Bits > 30 && (Elt != FixedType || hasVectorParms())))
151 break;
152
153 switch (Elt) {
154 case FixedType:
155 if (hasVectorParms()) {
156 //'00' ==> fixed parameter if HasVectorParms is true.
158 ParamsTypeInfo |=
161 } else {
162 //'0' ==> fixed parameter if HasVectorParms is false.
163 ParamsTypeInfo <<= 1;
164 ++Bits;
165 }
166 break;
168 // '10'b => floating point short parameter.
170 ParamsTypeInfo |=
173 break;
175 // '11'b => floating point long parameter.
177 ParamsTypeInfo |=
180 break;
181 case VectorChar:
182 case VectorShort:
183 case VectorInt:
184 case VectorFloat:
185 // '01' ==> vector parameter
187 ParamsTypeInfo |=
190 break;
191 }
192 }
193
194 return Bits < 32 ? ParamsTypeInfo << (32 - Bits) : ParamsTypeInfo;
195}
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
#define F(x, y, z)
Definition: MD5.cpp:55
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)
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:66
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:63
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Definition: MCContext.cpp:212
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
unsigned getFunctionNumber() const
getFunctionNumber - Return a unique ID for the current function.
MCContext & getContext() const
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
Ty * cloneInfo(const Ty &Old)
PPCFunctionInfo - This class is derived from MachineFunction private PowerPC target-specific informat...
MCSymbol * getPICOffsetSymbol(MachineFunction &MF) const
bool isLiveInSExt(Register VReg) const
This function returns true if the specified vreg is a live-in register and sign-extended.
MCSymbol * getGlobalEPSymbol(MachineFunction &MF) const
MCSymbol * getLocalEPSymbol(MachineFunction &MF) const
bool isLiveInZExt(Register VReg) const
This function returns true if the specified vreg is a live-in register and zero-extended.
PPCFunctionInfo(const Function &F, const TargetSubtargetInfo *STI)
void appendParameterType(ParamType Type)
uint32_t getVecExtParmsType() const
MCSymbol * getTOCOffsetSymbol(MachineFunction &MF) const
MachineFunctionInfo * clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF, const DenseMap< MachineBasicBlock *, MachineBasicBlock * > &Src2DstMBB) const override
Make a functionally equivalent copy of this MachineFunctionInfo in MF.
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
void push_back(const T &Elt)
Definition: SmallVector.h:413
TargetSubtargetInfo - Generic base class for all target subtargets.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:443
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...
static constexpr uint8_t WidthOfParamType
Definition: XCOFF.h:480
static constexpr uint32_t ParmTypeIsVectorShortBit
Definition: XCOFF.h:476
static constexpr uint32_t ParmTypeIsDoubleBits
Definition: XCOFF.h:462
static constexpr uint32_t ParmTypeIsVectorIntBit
Definition: XCOFF.h:477
static constexpr uint32_t ParmTypeIsFixedBits
Definition: XCOFF.h:459
static constexpr uint32_t ParmTypeIsVectorBits
Definition: XCOFF.h:460
static constexpr uint32_t ParmTypeIsVectorCharBit
Definition: XCOFF.h:475
static constexpr uint32_t ParmTypeIsVectorFloatBit
Definition: XCOFF.h:478
static constexpr uint32_t ParmTypeIsFloatingBits
Definition: XCOFF.h:461