LLVM  15.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 
18 using namespace llvm;
19 
20 static const char *const PSVNames[] = {
21  "Stack", "GOT", "JumpTable", "ConstantPool", "FixedStack",
22  "GlobalValueCallEntry", "ExternalSymbolCallEntry"};
23 
25  : Kind(Kind) {
26  AddressSpace = TII.getAddressSpaceForPseudoSourceKind(Kind);
27 }
28 
30 
31 void PseudoSourceValue::printCustom(raw_ostream &O) const {
32  if (Kind < TargetCustom)
33  O << PSVNames[Kind];
34  else
35  O << "TargetCustom" << Kind;
36 }
37 
39  if (isStack())
40  return false;
41  if (isGOT() || isConstantPool() || isJumpTable())
42  return true;
43  llvm_unreachable("Unknown PseudoSourceValue!");
44 }
45 
47  if (isStack() || isGOT() || isConstantPool() || isJumpTable())
48  return false;
49  llvm_unreachable("Unknown PseudoSourceValue!");
50 }
51 
53  return !(isGOT() || isConstantPool() || isJumpTable());
54 }
55 
57  const MachineFrameInfo *MFI) const {
58  return MFI && MFI->isImmutableObjectIndex(FI);
59 }
60 
62  if (!MFI)
63  return true;
64  return MFI->isAliasedObjectIndex(FI);
65 }
66 
68  if (!MFI)
69  return true;
70  // Spill slots will not alias any LLVM IR value.
71  return !MFI->isSpillSlotObjectIndex(FI);
72 }
73 
75  OS << "FixedStack" << FI;
76 }
77 
79  unsigned Kind, const TargetInstrInfo &TII)
81 
83  return false;
84 }
85 
87  return false;
88 }
89 
91  return false;
92 }
93 
95  const GlobalValue *GV,
96  const TargetInstrInfo &TII)
97  : CallEntryPseudoSourceValue(GlobalValueCallEntry, TII), GV(GV) {}
99  const char *ES, const TargetInstrInfo &TII)
100  : CallEntryPseudoSourceValue(ExternalSymbolCallEntry, TII), ES(ES) {}
101 
103  const TargetInstrInfo &TIInfo)
104  : TII(TIInfo),
105  StackPSV(PseudoSourceValue::Stack, TII),
106  GOTPSV(PseudoSourceValue::GOT, TII),
107  JumpTablePSV(PseudoSourceValue::JumpTable, TII),
108  ConstantPoolPSV(PseudoSourceValue::ConstantPool, TII) {}
109 
111  return &StackPSV;
112 }
113 
115 
117  return &ConstantPoolPSV;
118 }
119 
121  return &JumpTablePSV;
122 }
123 
124 const PseudoSourceValue *
126  std::unique_ptr<FixedStackPseudoSourceValue> &V = FSValues[FI];
127  if (!V)
128  V = std::make_unique<FixedStackPseudoSourceValue>(FI, TII);
129  return V.get();
130 }
131 
132 const PseudoSourceValue *
134  std::unique_ptr<const GlobalValuePseudoSourceValue> &E =
135  GlobalCallEntries[GV];
136  if (!E)
137  E = std::make_unique<GlobalValuePseudoSourceValue>(GV, TII);
138  return E.get();
139 }
140 
141 const PseudoSourceValue *
143  std::unique_ptr<const ExternalSymbolPseudoSourceValue> &E =
144  ExternalCallEntries[ES];
145  if (!E)
146  E = std::make_unique<ExternalSymbolPseudoSourceValue>(ES, TII);
147  return E.get();
148 }
llvm::PseudoSourceValueManager::getGOT
const PseudoSourceValue * getGOT()
Return a pseudo source value referencing the global offset table (or something the like).
Definition: PseudoSourceValue.cpp:114
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::PseudoSourceValue::isAliased
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...
Definition: PseudoSourceValue.cpp:46
ErrorHandling.h
llvm::ConstantPool
Definition: ConstantPools.h:43
llvm::PseudoSourceValue::mayAlias
virtual bool mayAlias(const MachineFrameInfo *) const
Return true if the memory pointed to by this PseudoSourceValue can ever alias an LLVM IR Value.
Definition: PseudoSourceValue.cpp:52
TargetInstrInfo.h
llvm::FixedStackPseudoSourceValue::mayAlias
bool mayAlias(const MachineFrameInfo *) const override
Return true if the memory pointed to by this PseudoSourceValue can ever alias an LLVM IR Value.
Definition: PseudoSourceValue.cpp:67
llvm::PseudoSourceValueManager::getStack
const PseudoSourceValue * getStack()
Return a pseudo source value referencing the area below the stack frame of a function,...
Definition: PseudoSourceValue.cpp:110
llvm::TargetInstrInfo
TargetInstrInfo - Interface to description of machine instruction set.
Definition: TargetInstrInfo.h:97
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::PseudoSourceValue::isStack
bool isStack() const
Definition: PseudoSourceValue.h:68
PseudoSourceValue.h
TII
const HexagonInstrInfo * TII
Definition: HexagonCopyToCombine.cpp:127
llvm::PseudoSourceValueManager::PseudoSourceValueManager
PseudoSourceValueManager(const TargetInstrInfo &TII)
Definition: PseudoSourceValue.cpp:102
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:54
llvm::MachineFrameInfo::isAliasedObjectIndex
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...
Definition: MachineFrameInfo.h:686
llvm::PseudoSourceValue
Special value supplied for machine level alias analysis.
Definition: PseudoSourceValue.h:35
llvm::AddressSpace
AddressSpace
Definition: NVPTXBaseInfo.h:21
llvm::PseudoSourceValue::TargetCustom
@ TargetCustom
Definition: PseudoSourceValue.h:45
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
llvm::PseudoSourceValue::isGOT
bool isGOT() const
Definition: PseudoSourceValue.h:69
llvm::FixedStackPseudoSourceValue::isConstant
bool isConstant(const MachineFrameInfo *MFI) const override
Test whether the memory pointed to by this PseudoSourceValue has a constant value.
Definition: PseudoSourceValue.cpp:56
llvm::RISCVFenceField::O
@ O
Definition: RISCVBaseInfo.h:239
llvm::GlobalValue
Definition: GlobalValue.h:44
llvm::CallEntryPseudoSourceValue::isAliased
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...
Definition: PseudoSourceValue.cpp:86
llvm::FixedStackPseudoSourceValue::isAliased
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...
Definition: PseudoSourceValue.cpp:61
llvm::CallEntryPseudoSourceValue::isConstant
bool isConstant(const MachineFrameInfo *) const override
Test whether the memory pointed to by this PseudoSourceValue has a constant value.
Definition: PseudoSourceValue.cpp:82
llvm::PseudoSourceValue::PseudoSourceValue
PseudoSourceValue(unsigned Kind, const TargetInstrInfo &TII)
Definition: PseudoSourceValue.cpp:24
llvm::PseudoSourceValue::~PseudoSourceValue
virtual ~PseudoSourceValue()
llvm::GlobalValuePseudoSourceValue::GlobalValuePseudoSourceValue
GlobalValuePseudoSourceValue(const GlobalValue *GV, const TargetInstrInfo &TII)
Definition: PseudoSourceValue.cpp:94
llvm::CallEntryPseudoSourceValue
Definition: PseudoSourceValue.h:116
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:143
llvm::CallEntryPseudoSourceValue::CallEntryPseudoSourceValue
CallEntryPseudoSourceValue(unsigned Kind, const TargetInstrInfo &TII)
Definition: PseudoSourceValue.cpp:78
llvm::PseudoSourceValueManager::getJumpTable
const PseudoSourceValue * getJumpTable()
Return a pseudo source value referencing a jump table.
Definition: PseudoSourceValue.cpp:120
llvm::PseudoSourceValueManager::getGlobalValueCallEntry
const PseudoSourceValue * getGlobalValueCallEntry(const GlobalValue *GV)
Definition: PseudoSourceValue.cpp:133
llvm::PseudoSourceValueManager::getFixedStack
const PseudoSourceValue * getFixedStack(int FI)
Return a pseudo source value referencing a fixed stack frame entry, e.g., a spill slot.
Definition: PseudoSourceValue.cpp:125
MachineFrameInfo.h
JumpTable
MIPS Relocation Principles In there are several elements of the llvm::ISD::NodeType enum that deal with addresses and or relocations These are defined in include llvm Target TargetSelectionDAG td JumpTable
Definition: Relocation.txt:6
llvm::CallEntryPseudoSourceValue::mayAlias
bool mayAlias(const MachineFrameInfo *) const override
Return true if the memory pointed to by this PseudoSourceValue can ever alias an LLVM IR Value.
Definition: PseudoSourceValue.cpp:90
llvm::MachineFrameInfo::isSpillSlotObjectIndex
bool isSpillSlotObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a spill slot.
Definition: MachineFrameInfo.h:710
llvm::FixedStackPseudoSourceValue::printCustom
void printCustom(raw_ostream &OS) const override
Implement printing for PseudoSourceValue.
Definition: PseudoSourceValue.cpp:74
llvm::PseudoSourceValue::isConstantPool
bool isConstantPool() const
Definition: PseudoSourceValue.h:70
llvm::MachineFrameInfo::isImmutableObjectIndex
bool isImmutableObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to an immutable object.
Definition: MachineFrameInfo.h:693
llvm::MachineFrameInfo
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
Definition: MachineFrameInfo.h:105
llvm::PseudoSourceValue::isJumpTable
bool isJumpTable() const
Definition: PseudoSourceValue.h:71
PSVNames
static const char *const PSVNames[]
Definition: PseudoSourceValue.cpp:20
raw_ostream.h
llvm::PseudoSourceValueManager::getExternalSymbolCallEntry
const PseudoSourceValue * getExternalSymbolCallEntry(const char *ES)
Definition: PseudoSourceValue.cpp:142
llvm::PseudoSourceValue::isConstant
virtual bool isConstant(const MachineFrameInfo *) const
Test whether the memory pointed to by this PseudoSourceValue has a constant value.
Definition: PseudoSourceValue.cpp:38
llvm::PseudoSourceValueManager::getConstantPool
const PseudoSourceValue * getConstantPool()
Return a pseudo source value referencing the constant pool.
Definition: PseudoSourceValue.cpp:116
llvm::ExternalSymbolPseudoSourceValue::ExternalSymbolPseudoSourceValue
ExternalSymbolPseudoSourceValue(const char *ES, const TargetInstrInfo &TII)
Definition: PseudoSourceValue.cpp:98