LLVM  10.0.0svn
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 
14 #include "llvm/ADT/STLExtras.h"
17 #include "llvm/IR/DerivedTypes.h"
18 #include "llvm/IR/LLVMContext.h"
21 using namespace llvm;
22 
23 static const char *const PSVNames[] = {
24  "Stack", "GOT", "JumpTable", "ConstantPool", "FixedStack",
25  "GlobalValueCallEntry", "ExternalSymbolCallEntry"};
26 
28  : Kind(Kind) {
30 }
31 
32 
34 
35 void PseudoSourceValue::printCustom(raw_ostream &O) const {
36  if (Kind < TargetCustom)
37  O << PSVNames[Kind];
38  else
39  O << "TargetCustom" << Kind;
40 }
41 
43  if (isStack())
44  return false;
45  if (isGOT() || isConstantPool() || isJumpTable())
46  return true;
47  llvm_unreachable("Unknown PseudoSourceValue!");
48 }
49 
51  if (isStack() || isGOT() || isConstantPool() || isJumpTable())
52  return false;
53  llvm_unreachable("Unknown PseudoSourceValue!");
54 }
55 
57  return !(isGOT() || isConstantPool() || isJumpTable());
58 }
59 
61  const MachineFrameInfo *MFI) const {
62  return MFI && MFI->isImmutableObjectIndex(FI);
63 }
64 
66  if (!MFI)
67  return true;
68  return MFI->isAliasedObjectIndex(FI);
69 }
70 
72  if (!MFI)
73  return true;
74  // Spill slots will not alias any LLVM IR value.
75  return !MFI->isSpillSlotObjectIndex(FI);
76 }
77 
79  OS << "FixedStack" << FI;
80 }
81 
83  unsigned Kind, const TargetInstrInfo &TII)
84  : PseudoSourceValue(Kind, TII) {}
85 
87  return false;
88 }
89 
91  return false;
92 }
93 
95  return false;
96 }
97 
99  const GlobalValue *GV,
100  const TargetInstrInfo &TII)
103  const char *ES, const TargetInstrInfo &TII)
105 
107  const TargetInstrInfo &TIInfo)
108  : TII(TIInfo),
109  StackPSV(PseudoSourceValue::Stack, TII),
110  GOTPSV(PseudoSourceValue::GOT, TII),
111  JumpTablePSV(PseudoSourceValue::JumpTable, TII),
112  ConstantPoolPSV(PseudoSourceValue::ConstantPool, TII) {}
113 
115  return &StackPSV;
116 }
117 
119 
121  return &ConstantPoolPSV;
122 }
123 
125  return &JumpTablePSV;
126 }
127 
128 const PseudoSourceValue *
130  std::unique_ptr<FixedStackPseudoSourceValue> &V = FSValues[FI];
131  if (!V)
132  V = std::make_unique<FixedStackPseudoSourceValue>(FI, TII);
133  return V.get();
134 }
135 
136 const PseudoSourceValue *
138  std::unique_ptr<const GlobalValuePseudoSourceValue> &E =
139  GlobalCallEntries[GV];
140  if (!E)
141  E = std::make_unique<GlobalValuePseudoSourceValue>(GV, TII);
142  return E.get();
143 }
144 
145 const PseudoSourceValue *
147  std::unique_ptr<const ExternalSymbolPseudoSourceValue> &E =
148  ExternalCallEntries[ES];
149  if (!E)
150  E = std::make_unique<ExternalSymbolPseudoSourceValue>(ES, TII);
151  return E.get();
152 }
This class represents lattice values for constants.
Definition: AllocatorList.h:23
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:21
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 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:45
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.