LLVM 19.0.0git
PseudoSourceValue.cpp
Go to the documentation of this file.
1//===-- llvm/CodeGen/PseudoSourceValue.cpp ----------------------*- C++ -*-===//
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// This file implements the PseudoSourceValue class.
10//
11//===----------------------------------------------------------------------===//
12
19
20using namespace llvm;
21
22static const char *const PSVNames[] = {
23 "Stack", "GOT", "JumpTable", "ConstantPool", "FixedStack",
24 "GlobalValueCallEntry", "ExternalSymbolCallEntry"};
25
27 : Kind(Kind) {
28 AddressSpace = TM.getAddressSpaceForPseudoSourceKind(Kind);
29}
30
32
33void PseudoSourceValue::printCustom(raw_ostream &O) const {
34 if (Kind < TargetCustom)
35 O << PSVNames[Kind];
36 else
37 O << "TargetCustom" << Kind;
38}
39
41 if (isStack())
42 return false;
43 if (isGOT() || isConstantPool() || isJumpTable())
44 return true;
45 llvm_unreachable("Unknown PseudoSourceValue!");
46}
47
49 if (isStack() || isGOT() || isConstantPool() || isJumpTable())
50 return false;
51 llvm_unreachable("Unknown PseudoSourceValue!");
52}
53
55 return !(isGOT() || isConstantPool() || isJumpTable());
56}
57
59 const MachineFrameInfo *MFI) const {
60 return MFI && MFI->isImmutableObjectIndex(FI);
61}
62
64 if (!MFI)
65 return true;
66 return MFI->isAliasedObjectIndex(FI);
67}
68
70 if (!MFI)
71 return true;
72 // Spill slots will not alias any LLVM IR value.
73 return !MFI->isSpillSlotObjectIndex(FI);
74}
75
77 OS << "FixedStack" << FI;
78}
79
81 const TargetMachine &TM)
82 : PseudoSourceValue(Kind, TM) {}
83
85 return false;
86}
87
89 return false;
90}
91
93 return false;
94}
95
97 const GlobalValue *GV, const TargetMachine &TM)
98 : CallEntryPseudoSourceValue(GlobalValueCallEntry, TM), GV(GV) {}
100 const char *ES, const TargetMachine &TM)
101 : CallEntryPseudoSourceValue(ExternalSymbolCallEntry, TM), ES(ES) {}
102
104 : TM(TMInfo), StackPSV(PseudoSourceValue::Stack, TM),
105 GOTPSV(PseudoSourceValue::GOT, TM),
106 JumpTablePSV(PseudoSourceValue::JumpTable, TM),
107 ConstantPoolPSV(PseudoSourceValue::ConstantPool, TM) {}
108
110 return &StackPSV;
111}
112
114
116 return &ConstantPoolPSV;
117}
118
120 return &JumpTablePSV;
121}
122
123const PseudoSourceValue *
125 std::unique_ptr<FixedStackPseudoSourceValue> &V = FSValues[FI];
126 if (!V)
127 V = std::make_unique<FixedStackPseudoSourceValue>(FI, TM);
128 return V.get();
129}
130
131const PseudoSourceValue *
133 std::unique_ptr<const GlobalValuePseudoSourceValue> &E =
134 GlobalCallEntries[GV];
135 if (!E)
136 E = std::make_unique<GlobalValuePseudoSourceValue>(GV, TM);
137 return E.get();
138}
139
140const PseudoSourceValue *
142 std::unique_ptr<const ExternalSymbolPseudoSourceValue> &E =
143 ExternalCallEntries[ES];
144 if (!E)
145 E = std::make_unique<ExternalSymbolPseudoSourceValue>(ES, TM);
146 return E.get();
147}
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
const char LLVMTargetMachineRef TM
static const char *const PSVNames[]
raw_pwrite_stream & OS
CallEntryPseudoSourceValue(unsigned Kind, const TargetMachine &TM)
bool isAliased(const MachineFrameInfo *) const override
Test whether the memory pointed to by this PseudoSourceValue may also be pointed to by an LLVM IR Val...
bool mayAlias(const MachineFrameInfo *) const override
Return true if the memory pointed to by this PseudoSourceValue can ever alias an LLVM IR Value.
bool isConstant(const MachineFrameInfo *) const override
Test whether the memory pointed to by this PseudoSourceValue has a constant value.
ExternalSymbolPseudoSourceValue(const char *ES, const TargetMachine &TM)
void printCustom(raw_ostream &OS) const override
Implement printing for PseudoSourceValue.
bool isAliased(const MachineFrameInfo *MFI) const override
Test whether the memory pointed to by this PseudoSourceValue may also be pointed to by an LLVM IR Val...
bool mayAlias(const MachineFrameInfo *) const override
Return true if the memory pointed to by this PseudoSourceValue can ever alias an LLVM IR Value.
bool isConstant(const MachineFrameInfo *MFI) const override
Test whether the memory pointed to by this PseudoSourceValue has a constant value.
GlobalValuePseudoSourceValue(const GlobalValue *GV, const TargetMachine &TM)
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
bool isImmutableObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to an immutable object.
bool isSpillSlotObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a spill slot.
bool isAliasedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to an object that might be pointed to by an LLVM IR v...
const PseudoSourceValue * getJumpTable()
Return a pseudo source value referencing a jump table.
const PseudoSourceValue * getExternalSymbolCallEntry(const char *ES)
const PseudoSourceValue * getFixedStack(int FI)
Return a pseudo source value referencing a fixed stack frame entry, e.g., a spill slot.
const PseudoSourceValue * getGOT()
Return a pseudo source value referencing the global offset table (or something the like).
const PseudoSourceValue * getGlobalValueCallEntry(const GlobalValue *GV)
const PseudoSourceValue * getStack()
Return a pseudo source value referencing the area below the stack frame of a function,...
const PseudoSourceValue * getConstantPool()
Return a pseudo source value referencing the constant pool.
PseudoSourceValueManager(const TargetMachine &TM)
Special value supplied for machine level alias analysis.
virtual bool mayAlias(const MachineFrameInfo *) const
Return true if the memory pointed to by this PseudoSourceValue can ever alias an LLVM IR Value.
virtual bool isAliased(const MachineFrameInfo *) const
Test whether the memory pointed to by this PseudoSourceValue may also be pointed to by an LLVM IR Val...
PseudoSourceValue(unsigned Kind, const TargetMachine &TM)
virtual bool isConstant(const MachineFrameInfo *) const
Test whether the memory pointed to by this PseudoSourceValue has a constant value.
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:76
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
AddressSpace
Definition: NVPTXBaseInfo.h:21