LLVM  8.0.1
PseudoSourceValue.cpp
Go to the documentation of this file.
1 //===-- llvm/CodeGen/PseudoSourceValue.cpp ----------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the PseudoSourceValue class.
11 //
12 //===----------------------------------------------------------------------===//
13 
15 #include "llvm/ADT/STLExtras.h"
18 #include "llvm/IR/DerivedTypes.h"
19 #include "llvm/IR/LLVMContext.h"
22 using namespace llvm;
23 
24 static const char *const PSVNames[] = {
25  "Stack", "GOT", "JumpTable", "ConstantPool", "FixedStack",
26  "GlobalValueCallEntry", "ExternalSymbolCallEntry"};
27 
29  : Kind(Kind) {
31 }
32 
33 
35 
36 void PseudoSourceValue::printCustom(raw_ostream &O) const {
37  if (Kind < TargetCustom)
38  O << PSVNames[Kind];
39  else
40  O << "TargetCustom" << Kind;
41 }
42 
44  if (isStack())
45  return false;
46  if (isGOT() || isConstantPool() || isJumpTable())
47  return true;
48  llvm_unreachable("Unknown PseudoSourceValue!");
49 }
50 
52  if (isStack() || isGOT() || isConstantPool() || isJumpTable())
53  return false;
54  llvm_unreachable("Unknown PseudoSourceValue!");
55 }
56 
58  return !(isGOT() || isConstantPool() || isJumpTable());
59 }
60 
62  const MachineFrameInfo *MFI) const {
63  return MFI && MFI->isImmutableObjectIndex(FI);
64 }
65 
67  if (!MFI)
68  return true;
69  return MFI->isAliasedObjectIndex(FI);
70 }
71 
73  if (!MFI)
74  return true;
75  // Spill slots will not alias any LLVM IR value.
76  return !MFI->isSpillSlotObjectIndex(FI);
77 }
78 
80  OS << "FixedStack" << FI;
81 }
82 
84  unsigned Kind, const TargetInstrInfo &TII)
85  : PseudoSourceValue(Kind, TII) {}
86 
88  return false;
89 }
90 
92  return false;
93 }
94 
96  return false;
97 }
98 
100  const GlobalValue *GV,
101  const TargetInstrInfo &TII)
104  const char *ES, const TargetInstrInfo &TII)
106 
108  const TargetInstrInfo &TIInfo)
109  : TII(TIInfo),
110  StackPSV(PseudoSourceValue::Stack, TII),
111  GOTPSV(PseudoSourceValue::GOT, TII),
112  JumpTablePSV(PseudoSourceValue::JumpTable, TII),
113  ConstantPoolPSV(PseudoSourceValue::ConstantPool, TII) {}
114 
116  return &StackPSV;
117 }
118 
120 
122  return &ConstantPoolPSV;
123 }
124 
126  return &JumpTablePSV;
127 }
128 
129 const PseudoSourceValue *
131  std::unique_ptr<FixedStackPseudoSourceValue> &V = FSValues[FI];
132  if (!V)
133  V = llvm::make_unique<FixedStackPseudoSourceValue>(FI, TII);
134  return V.get();
135 }
136 
137 const PseudoSourceValue *
139  std::unique_ptr<const GlobalValuePseudoSourceValue> &E =
140  GlobalCallEntries[GV];
141  if (!E)
142  E = llvm::make_unique<GlobalValuePseudoSourceValue>(GV, TII);
143  return E.get();
144 }
145 
146 const PseudoSourceValue *
148  std::unique_ptr<const ExternalSymbolPseudoSourceValue> &E =
149  ExternalCallEntries[ES];
150  if (!E)
151  E = llvm::make_unique<ExternalSymbolPseudoSourceValue>(ES, TII);
152  return E.get();
153 }
This class represents lattice values for constants.
Definition: AllocatorList.h:24
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...
virtual bool isConstant(const MachineFrameInfo *) const
Test whether the memory pointed to by this PseudoSourceValue has a constant value.
const HexagonInstrInfo * TII
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 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 isConstant(const MachineFrameInfo *MFI) const override
Test whether the memory pointed to by this PseudoSourceValue has a constant value.
bool mayAlias(const MachineFrameInfo *) const override
Return true if the memory pointed to by this PseudoSourceValue can ever alias an LLVM IR Value...
const PseudoSourceValue * getFixedStack(int FI)
Return a pseudo source value referencing a fixed stack frame entry, e.g., a spill slot...
TargetInstrInfo - Interface to description of machine instruction set.
ExternalSymbolPseudoSourceValue(const char *ES, const TargetInstrInfo &TII)
const PseudoSourceValue * getExternalSymbolCallEntry(const char *ES)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
virtual unsigned getAddressSpaceForPseudoSourceKind(unsigned Kind) const
getAddressSpaceForPseudoSourceKind - Given the kind of memory (e.g.
CallEntryPseudoSourceValue(unsigned Kind, const TargetInstrInfo &TII)
AddressSpace
Definition: NVPTXBaseInfo.h:22
GlobalValuePseudoSourceValue(const GlobalValue *GV, const TargetInstrInfo &TII)
Special value supplied for machine level alias analysis.
const PseudoSourceValue * getJumpTable()
Return a pseudo source value referencing a jump table.
const PseudoSourceValue * getGlobalValueCallEntry(const GlobalValue *GV)
const PseudoSourceValue * getGOT()
Return a pseudo source value referencing the global offset table (or something the like)...
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...
PseudoSourceValue(unsigned Kind, const TargetInstrInfo &TII)
static const char *const PSVNames[]
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...
const unsigned Kind
const PseudoSourceValue * getStack()
Return a pseudo source value referencing the area below the stack frame of a function, e.g., the argument space.
bool isConstant(const MachineFrameInfo *) const override
Test whether the memory pointed to by this PseudoSourceValue has a constant value.
PseudoSourceValueManager(const TargetInstrInfo &TII)
void printCustom(raw_ostream &OS) const override
Implement printing for PseudoSourceValue.
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:46
bool mayAlias(const MachineFrameInfo *) const override
Return true if the memory pointed to by this PseudoSourceValue can ever alias an LLVM IR Value...
const PseudoSourceValue * getConstantPool()
Return a pseudo source value referencing the constant pool.
bool isSpillSlotObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a spill slot.