LLVM: lib/CodeGen/SelectionDAG/SelectionDAGAddressAnalysis.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
20#include
21
22using namespace llvm;
23
26 int64_t &Off) const {
27
28 if (!Base.getNode() || .Base.getNode())
29 return false;
31 return false;
32
33 Off = *Other.Offset - *Offset;
34
35 if ((Other.Index == Index) && (Other.IsIndexSignExt == IsIndexSignExt)) {
36
37 if (Other.Base == Base)
38 return true;
39
40
43 if (A->getGlobal() == B->getGlobal()) {
44 Off += B->getOffset() - A->getOffset();
45 return true;
46 }
47
48 return false;
49 }
50
51
54 bool IsMatch =
55 A->isMachineConstantPoolEntry() == B->isMachineConstantPoolEntry();
56 if (IsMatch) {
57 if (A->isMachineConstantPoolEntry())
58 IsMatch = A->getMachineCPVal() == B->getMachineCPVal();
59 else
60 IsMatch = A->getConstVal() == B->getConstVal();
61 }
62 if (IsMatch) {
63 Off += B->getOffset() - A->getOffset();
64 return true;
65 }
66 }
67
68 return false;
69 }
70
71
74
75 if (A->getIndex() == B->getIndex())
76 return true;
77
78
79
85 return true;
86 }
87 }
88 }
89
90 return false;
91}
92
99 if (!BasePtr0.getBase().getNode())
100 return false;
101
103 if (!BasePtr1.getBase().getNode())
104 return false;
105
106 int64_t PtrDiff;
107 if (BasePtr0.equalBaseIndex(BasePtr1, DAG, PtrDiff)) {
108
109
110
111 if (PtrDiff >= 0 && NumBytes0.hasValue() && !NumBytes0.isScalable()) {
112
113
114
115 IsAlias = !(static_cast<int64_t>(NumBytes0.getValue().getFixedValue()) <=
116 PtrDiff);
117 return true;
118 }
119 if (PtrDiff < 0 && NumBytes1.hasValue() && !NumBytes1.isScalable()) {
120
121
122
123 IsAlias = !((PtrDiff + static_cast<int64_t>(
124 NumBytes1.getValue().getFixedValue())) <= 0);
125 return true;
126 }
127 return false;
128 }
129
130
131
132
136
137
140 IsAlias = false;
141 return true;
142 }
143 }
144
151
152 if ((IsFI0 || IsGV0 || IsCV0) && (IsFI1 || IsGV1 || IsCV1)) {
153
154 if (IsFI0 != IsFI1 || IsGV0 != IsGV1 || IsCV0 != IsCV1) {
155 IsAlias = false;
156 return true;
157 }
158 if (IsGV0 && IsGV1) {
161
162
163
164
165
166
167
169 IsAlias = false;
170 return true;
171 }
172 }
173 }
174 return false;
175}
176
179 int64_t OtherBitSize, int64_t &BitOffset) const {
180 int64_t Offset;
182 return false;
183 if (Offset >= 0) {
184
185
186
187
188 BitOffset = 8 * Offset;
189 return BitOffset + OtherBitSize <= BitSize;
190 }
191
192
193
194 return false;
195}
196
197
200 SDValue Ptr = N->getBasePtr();
201
202
206 bool IsIndexSignExt = false;
207
208
211 Offset += C->getSExtValue();
212 else
214 } else if (N->getAddressingMode() == ISD::PRE_DEC) {
216 Offset -= C->getSExtValue();
217 else
219 }
220
221
222 while (true) {
223 switch (Base->getOpcode()) {
225
228 Offset += C->getSExtValue();
230 continue;
231 }
232 break;
234 case ISD::PTRADD:
236 Offset += C->getSExtValue();
238 continue;
239 }
240 break;
241 case ISD::LOAD:
242 case ISD::STORE: {
244 unsigned int IndexResNo = (Base->getOpcode() == ISD::LOAD) ? 1 : 0;
245 if (LSBase->isIndexed() && Base.getResNo() == IndexResNo)
247 auto Off = C->getSExtValue();
248 if (LSBase->getAddressingMode() == ISD::PRE_DEC ||
251 else
254 continue;
255 }
256 break;
257 }
258 }
259
260 break;
261 }
262
263 if (Base->isAnyAdd()) {
264
265
266
267
268
269
270
271
272 if (Base->getOperand(1)->getOpcode() == ISD::MUL)
274
275
276 Index = Base->getOperand(1);
277 SDValue PotentialBase = Base->getOperand(0);
278
279
281 Index = Index->getOperand(0);
282 IsIndexSignExt = true;
283 }
284
285
288
290 Index = Index->getOperand(0);
292 Index = Index->getOperand(0);
293 IsIndexSignExt = true;
294 } else
295 IsIndexSignExt = false;
296 Base = PotentialBase;
297 }
299}
300
310
311#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
312
316
318 OS << "BaseIndexOffset base=[";
319 Base->print(OS);
320 OS << "] index=[";
321 if (Index)
322 Index->print(OS);
323 OS << "] offset=" << Offset;
324}
325
326#endif
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
This file provides utility analysis objects describing memory locations.
static BaseIndexOffset matchLSNode(const LSBaseSDNode *N, const SelectionDAG &DAG)
Parses tree in Ptr for base, index, offset addresses.
Definition SelectionDAGAddressAnalysis.cpp:198
This file describes how to lower LLVM code to machine code.
LLVM_ABI bool contains(const SelectionDAG &DAG, int64_t BitSize, const BaseIndexOffset &Other, int64_t OtherBitSize, int64_t &BitOffset) const
Definition SelectionDAGAddressAnalysis.cpp:177
LLVM_ABI void print(raw_ostream &OS) const
Definition SelectionDAGAddressAnalysis.cpp:317
BaseIndexOffset()=default
static LLVM_ABI BaseIndexOffset match(const SDNode *N, const SelectionDAG &DAG)
Parses tree in N for base, index, offset addresses.
Definition SelectionDAGAddressAnalysis.cpp:301
static LLVM_ABI bool computeAliasing(const SDNode *Op0, const LocationSize NumBytes0, const SDNode *Op1, const LocationSize NumBytes1, const SelectionDAG &DAG, bool &IsAlias)
Definition SelectionDAGAddressAnalysis.cpp:93
LLVM_ABI void dump() const
Definition SelectionDAGAddressAnalysis.cpp:313
LLVM_ABI bool equalBaseIndex(const BaseIndexOffset &Other, const SelectionDAG &DAG, int64_t &Off) const
Definition SelectionDAGAddressAnalysis.cpp:24
Helper struct to store a base, index and offset that forms an address.
BaseIndexOffset()=default
bool hasValidOffset() const
Base class for LoadSDNode and StoreSDNode.
TypeSize getValue() const
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
bool isFixedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a fixed stack object.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
Represents one node in the SelectionDAG.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
const TargetLowering & getTargetLoweringInfo() const
MachineFunction & getMachineFunction() const
LLVM_ABI bool MaskedValueIsZero(SDValue Op, const APInt &Mask, unsigned Depth=0) const
Return true if 'Op & Mask' is known to be zero.
virtual SDValue unwrapAddress(SDValue N) const
This class implements an extremely fast bulk output stream that can only output to a stream.
@ C
The default llvm calling convention, compatible with C.
@ ADD
Simple integer binary arithmetic operators.
@ SIGN_EXTEND
Conversion operators.
bool match(Val *V, const Pattern &P)
This is an optimization pass for GlobalISel generic memory operations.
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr, unsigned DynamicVGPRBlockSize=0)
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool isa(const From &Val)
isa - Return true if the parameter to the template is an instance of one of the template type argu...
decltype(auto) cast(const From &Val)
cast - Return the argument parameter cast to the specified type.