Movatterモバイル変換


[0]ホーム

URL:


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
9#include "PPCMachineFunctionInfo.h"
10#include "llvm/ADT/Twine.h"
11#include "llvm/BinaryFormat/XCOFF.h"
12#include "llvm/IR/DataLayout.h"
13#include "llvm/MC/MCContext.h"
14#include "llvm/Support/CommandLine.h"
15
16using namespacellvm;
17staticcl::opt<bool>PPCDisableNonVolatileCR(
18"ppc-disable-non-volatile-cr",
19cl::desc("Disable the use of non-volatile CR register fields"),
20cl::init(false),cl::Hidden);
21
22void PPCFunctionInfo::anchor() {}
23PPCFunctionInfo::PPCFunctionInfo(constFunction &F,
24constTargetSubtargetInfo *STI)
25 : DisableNonVolatileCR(PPCDisableNonVolatileCR) {}
26
27MachineFunctionInfo *
28PPCFunctionInfo::clone(BumpPtrAllocator &Allocator,MachineFunction &DestMF,
29constDenseMap<MachineBasicBlock *, MachineBasicBlock *>
30 &Src2DstMBB) const{
31return DestMF.cloneInfo<PPCFunctionInfo>(*this);
32}
33
34MCSymbol *PPCFunctionInfo::getPICOffsetSymbol(MachineFunction &MF) const{
35constDataLayout &DL = MF.getDataLayout();
36return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
37Twine(MF.getFunctionNumber()) +
38"$poff");
39}
40
41MCSymbol *PPCFunctionInfo::getGlobalEPSymbol(MachineFunction &MF) const{
42constDataLayout &DL = MF.getDataLayout();
43return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
44"func_gep" +
45Twine(MF.getFunctionNumber()));
46}
47
48MCSymbol *PPCFunctionInfo::getLocalEPSymbol(MachineFunction &MF) const{
49constDataLayout &DL = MF.getDataLayout();
50return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
51"func_lep" +
52Twine(MF.getFunctionNumber()));
53}
54
55MCSymbol *PPCFunctionInfo::getTOCOffsetSymbol(MachineFunction &MF) const{
56constDataLayout &DL = MF.getDataLayout();
57return MF.getContext().getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
58"func_toc" +
59Twine(MF.getFunctionNumber()));
60}
61
62boolPPCFunctionInfo::isLiveInSExt(Register VReg) const{
63for (const std::pair<Register, ISD::ArgFlagsTy> &LiveIn : LiveInAttrs)
64if (LiveIn.first == VReg)
65return LiveIn.second.isSExt();
66returnfalse;
67}
68
69boolPPCFunctionInfo::isLiveInZExt(Register VReg) const{
70for (const std::pair<Register, ISD::ArgFlagsTy> &LiveIn : LiveInAttrs)
71if (LiveIn.first == VReg)
72return LiveIn.second.isZExt();
73returnfalse;
74}
75
76voidPPCFunctionInfo::appendParameterType(ParamTypeType) {
77
78 ParamtersType.push_back(Type);
79switch (Type) {
80caseFixedType:
81 ++FixedParmsNum;
82return;
83caseShortFloatingPoint:
84caseLongFloatingPoint:
85 ++FloatingParmsNum;
86return;
87caseVectorChar:
88caseVectorShort:
89caseVectorInt:
90caseVectorFloat:
91 ++VectorParmsNum;
92return;
93 }
94llvm_unreachable("Error ParamType type.");
95}
96
97uint32_tPPCFunctionInfo::getVecExtParmsType() const{
98
99uint32_t VectExtParamInfo = 0;
100unsigned ShiftBits = 32 -XCOFF::TracebackTable::WidthOfParamType;
101int Bits = 0;
102
103if (!hasVectorParms())
104return 0;
105
106for (constauto &Elt : ParamtersType) {
107switch (Elt) {
108caseVectorChar:
109 VectExtParamInfo <<=XCOFF::TracebackTable::WidthOfParamType;
110 VectExtParamInfo |=
111XCOFF::TracebackTable::ParmTypeIsVectorCharBit >> ShiftBits;
112 Bits +=XCOFF::TracebackTable::WidthOfParamType;
113break;
114caseVectorShort:
115 VectExtParamInfo <<=XCOFF::TracebackTable::WidthOfParamType;
116 VectExtParamInfo |=
117XCOFF::TracebackTable::ParmTypeIsVectorShortBit >> ShiftBits;
118 Bits +=XCOFF::TracebackTable::WidthOfParamType;
119break;
120caseVectorInt:
121 VectExtParamInfo <<=XCOFF::TracebackTable::WidthOfParamType;
122 VectExtParamInfo |=
123XCOFF::TracebackTable::ParmTypeIsVectorIntBit >> ShiftBits;
124 Bits +=XCOFF::TracebackTable::WidthOfParamType;
125break;
126caseVectorFloat:
127 VectExtParamInfo <<=XCOFF::TracebackTable::WidthOfParamType;
128 VectExtParamInfo |=
129XCOFF::TracebackTable::ParmTypeIsVectorFloatBit >> ShiftBits;
130 Bits +=XCOFF::TracebackTable::WidthOfParamType;
131break;
132default:
133break;
134 }
135
136// There are only 32bits in the VectExtParamInfo.
137if (Bits >= 32)
138break;
139 }
140return Bits < 32 ? VectExtParamInfo << (32 - Bits) : VectExtParamInfo;
141}
142
143uint32_tPPCFunctionInfo::getParmsType() const{
144uint32_t ParamsTypeInfo = 0;
145unsigned ShiftBits = 32 -XCOFF::TracebackTable::WidthOfParamType;
146
147int Bits = 0;
148for (constauto &Elt : ParamtersType) {
149
150if (Bits > 31 || (Bits > 30 && (Elt !=FixedType ||hasVectorParms())))
151break;
152
153switch (Elt) {
154caseFixedType:
155if (hasVectorParms()) {
156//'00' ==> fixed parameter if HasVectorParms is true.
157 ParamsTypeInfo <<=XCOFF::TracebackTable::WidthOfParamType;
158 ParamsTypeInfo |=
159XCOFF::TracebackTable::ParmTypeIsFixedBits >> ShiftBits;
160 Bits +=XCOFF::TracebackTable::WidthOfParamType;
161 }else {
162//'0' ==> fixed parameter if HasVectorParms is false.
163 ParamsTypeInfo <<= 1;
164 ++Bits;
165 }
166break;
167caseShortFloatingPoint:
168// '10'b => floating point short parameter.
169 ParamsTypeInfo <<=XCOFF::TracebackTable::WidthOfParamType;
170 ParamsTypeInfo |=
171XCOFF::TracebackTable::ParmTypeIsFloatingBits >> ShiftBits;
172 Bits +=XCOFF::TracebackTable::WidthOfParamType;
173break;
174caseLongFloatingPoint:
175// '11'b => floating point long parameter.
176 ParamsTypeInfo <<=XCOFF::TracebackTable::WidthOfParamType;
177 ParamsTypeInfo |=
178XCOFF::TracebackTable::ParmTypeIsDoubleBits >> ShiftBits;
179 Bits +=XCOFF::TracebackTable::WidthOfParamType;
180break;
181caseVectorChar:
182caseVectorShort:
183caseVectorInt:
184caseVectorFloat:
185// '01' ==> vector parameter
186 ParamsTypeInfo <<=XCOFF::TracebackTable::WidthOfParamType;
187 ParamsTypeInfo |=
188XCOFF::TracebackTable::ParmTypeIsVectorBits >> ShiftBits;
189 Bits +=XCOFF::TracebackTable::WidthOfParamType;
190break;
191 }
192 }
193
194return Bits < 32 ? ParamsTypeInfo << (32 - Bits) : ParamsTypeInfo;
195}
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition:ARMSLSHardening.cpp:73
CommandLine.h
DataLayout.h
MCContext.h
F
#define F(x, y, z)
Definition:MD5.cpp:55
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)
PPCMachineFunctionInfo.h
Twine.h
XCOFF.h
llvm::BumpPtrAllocatorImpl
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition:Allocator.h:66
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition:DataLayout.h:63
llvm::DenseMap
Definition:DenseMap.h:727
llvm::Function
Definition:Function.h:63
llvm::MCContext::getOrCreateSymbol
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Definition:MCContext.cpp:212
llvm::MCSymbol
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition:MCSymbol.h:41
llvm::MachineFunction
Definition:MachineFunction.h:267
llvm::MachineFunction::getFunctionNumber
unsigned getFunctionNumber() const
getFunctionNumber - Return a unique ID for the current function.
Definition:MachineFunction.h:713
llvm::MachineFunction::getContext
MCContext & getContext() const
Definition:MachineFunction.h:690
llvm::MachineFunction::getDataLayout
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
Definition:MachineFunction.cpp:309
llvm::MachineFunction::cloneInfo
Ty * cloneInfo(const Ty &Old)
Definition:MachineFunction.h:840
llvm::PPCFunctionInfo
PPCFunctionInfo - This class is derived from MachineFunction private PowerPC target-specific informat...
Definition:PPCMachineFunctionInfo.h:24
llvm::PPCFunctionInfo::getParmsType
uint32_t getParmsType() const
Definition:PPCMachineFunctionInfo.cpp:143
llvm::PPCFunctionInfo::getPICOffsetSymbol
MCSymbol * getPICOffsetSymbol(MachineFunction &MF) const
Definition:PPCMachineFunctionInfo.cpp:34
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:62
llvm::PPCFunctionInfo::getGlobalEPSymbol
MCSymbol * getGlobalEPSymbol(MachineFunction &MF) const
Definition:PPCMachineFunctionInfo.cpp:41
llvm::PPCFunctionInfo::getLocalEPSymbol
MCSymbol * getLocalEPSymbol(MachineFunction &MF) const
Definition:PPCMachineFunctionInfo.cpp:48
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:69
llvm::PPCFunctionInfo::PPCFunctionInfo
PPCFunctionInfo(const Function &F, const TargetSubtargetInfo *STI)
Definition:PPCMachineFunctionInfo.cpp:23
llvm::PPCFunctionInfo::appendParameterType
void appendParameterType(ParamType Type)
Definition:PPCMachineFunctionInfo.cpp:76
llvm::PPCFunctionInfo::hasVectorParms
bool hasVectorParms() const
Definition:PPCMachineFunctionInfo.h:248
llvm::PPCFunctionInfo::getVecExtParmsType
uint32_t getVecExtParmsType() const
Definition:PPCMachineFunctionInfo.cpp:97
llvm::PPCFunctionInfo::getTOCOffsetSymbol
MCSymbol * getTOCOffsetSymbol(MachineFunction &MF) const
Definition:PPCMachineFunctionInfo.cpp:55
llvm::PPCFunctionInfo::ParamType
ParamType
Definition:PPCMachineFunctionInfo.h:26
llvm::PPCFunctionInfo::LongFloatingPoint
@ LongFloatingPoint
Definition:PPCMachineFunctionInfo.h:29
llvm::PPCFunctionInfo::VectorShort
@ VectorShort
Definition:PPCMachineFunctionInfo.h:31
llvm::PPCFunctionInfo::VectorChar
@ VectorChar
Definition:PPCMachineFunctionInfo.h:30
llvm::PPCFunctionInfo::ShortFloatingPoint
@ ShortFloatingPoint
Definition:PPCMachineFunctionInfo.h:28
llvm::PPCFunctionInfo::VectorFloat
@ VectorFloat
Definition:PPCMachineFunctionInfo.h:33
llvm::PPCFunctionInfo::FixedType
@ FixedType
Definition:PPCMachineFunctionInfo.h:27
llvm::PPCFunctionInfo::VectorInt
@ VectorInt
Definition:PPCMachineFunctionInfo.h:32
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:28
llvm::Register
Wrapper class representing virtual and physical registers.
Definition:Register.h:19
llvm::SmallVectorTemplateBase::push_back
void push_back(const T &Elt)
Definition:SmallVector.h:413
llvm::TargetSubtargetInfo
TargetSubtargetInfo - Generic base class for all target subtargets.
Definition:TargetSubtargetInfo.h:63
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition:Twine.h:81
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition:Type.h:45
llvm::cl::opt
Definition:CommandLine.h:1423
uint32_t
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition:ErrorHandling.h:143
llvm::cl::Hidden
@ Hidden
Definition:CommandLine.h:137
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition:CommandLine.h:443
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
llvm::MachineFunctionInfo
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...
Definition:MachineFunction.h:104
llvm::XCOFF::TracebackTable::WidthOfParamType
static constexpr uint8_t WidthOfParamType
Definition:XCOFF.h:480
llvm::XCOFF::TracebackTable::ParmTypeIsVectorShortBit
static constexpr uint32_t ParmTypeIsVectorShortBit
Definition:XCOFF.h:476
llvm::XCOFF::TracebackTable::ParmTypeIsDoubleBits
static constexpr uint32_t ParmTypeIsDoubleBits
Definition:XCOFF.h:462
llvm::XCOFF::TracebackTable::ParmTypeIsVectorIntBit
static constexpr uint32_t ParmTypeIsVectorIntBit
Definition:XCOFF.h:477
llvm::XCOFF::TracebackTable::ParmTypeIsFixedBits
static constexpr uint32_t ParmTypeIsFixedBits
Definition:XCOFF.h:459
llvm::XCOFF::TracebackTable::ParmTypeIsVectorBits
static constexpr uint32_t ParmTypeIsVectorBits
Definition:XCOFF.h:460
llvm::XCOFF::TracebackTable::ParmTypeIsVectorCharBit
static constexpr uint32_t ParmTypeIsVectorCharBit
Definition:XCOFF.h:475
llvm::XCOFF::TracebackTable::ParmTypeIsVectorFloatBit
static constexpr uint32_t ParmTypeIsVectorFloatBit
Definition:XCOFF.h:478
llvm::XCOFF::TracebackTable::ParmTypeIsFloatingBits
static constexpr uint32_t ParmTypeIsFloatingBits
Definition:XCOFF.h:461
llvm::cl::desc
Definition:CommandLine.h:409

Generated on Fri Jul 18 2025 14:19:14 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp