Lines Matching +full:isa +full:- +full:base

1 //==- llvm/CodeGen/SelectionDAGAddressAnalysis.cpp - DAG Address Analysis --==//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
28 if (!Base.getNode() || !Other.Base.getNode())
33 Off = *Other.Offset - *Offset;
37 if (Other.Base == Base)
41 if (auto *A = dyn_cast<GlobalAddressSDNode>(Base)) {
42 if (auto *B = dyn_cast<GlobalAddressSDNode>(Other.Base))
43 if (A->getGlobal() == B->getGlobal()) {
44 Off += B->getOffset() - A->getOffset();
52 if (auto *A = dyn_cast<ConstantPoolSDNode>(Base)) {
53 if (auto *B = dyn_cast<ConstantPoolSDNode>(Other.Base)) {
55 A->isMachineConstantPoolEntry() == B->isMachineConstantPoolEntry();
57 if (A->isMachineConstantPoolEntry())
58 IsMatch = A->getMachineCPVal() == B->getMachineCPVal();
60 IsMatch = A->getConstVal() == B->getConstVal();
63 Off += B->getOffset() - A->getOffset();
72 if (auto *A = dyn_cast<FrameIndexSDNode>(Base))
73 if (auto *B = dyn_cast<FrameIndexSDNode>(Other.Base)) {
74 // Equal FrameIndexes - offsets are directly comparable.
75 if (A->getIndex() == B->getIndex())
77 // Non-equal FrameIndexes - If both frame indices are fixed
81 if (MFI.isFixedObjectIndex(A->getIndex()) &&
82 MFI.isFixedObjectIndex(B->getIndex())) {
83 Off += MFI.getObjectOffset(B->getIndex()) -
84 MFI.getObjectOffset(A->getIndex());
112 // [----BasePtr0----]
113 // [---BasePtr1--]
120 // [----BasePtr0----]
121 // [---BasePtr1--]
122 // =====(-PtrDiff)====>
136 // If the base are the same frame index but the we couldn't find a
138 if (A->getIndex() != B->getIndex() && (!MFI.isFixedObjectIndex(A->getIndex()) ||
139 !MFI.isFixedObjectIndex(B->getIndex()))) {
145 bool IsFI0 = isa<FrameIndexSDNode>(BasePtr0.getBase());
146 bool IsFI1 = isa<FrameIndexSDNode>(BasePtr1.getBase());
147 bool IsGV0 = isa<GlobalAddressSDNode>(BasePtr0.getBase());
148 bool IsGV1 = isa<GlobalAddressSDNode>(BasePtr1.getBase());
149 bool IsCV0 = isa<ConstantPoolSDNode>(BasePtr0.getBase());
150 bool IsCV1 = isa<ConstantPoolSDNode>(BasePtr1.getBase());
153 // We can derive NoAlias In case of mismatched base types.
159 auto *GV0 = cast<GlobalAddressSDNode>(BasePtr0.getBase())->getGlobal();
160 auto *GV1 = cast<GlobalAddressSDNode>(BasePtr1.getBase())->getGlobal();
168 if (GV0 != GV1 && !isa<GlobalAlias>(GV0) && !isa<GlobalAlias>(GV1)) {
185 // [-------*this---------]
186 // [---Other--]
192 // [-------*this---------]
193 // [--Other--]
197 /// Parses tree in Ptr for base, index, offset addresses.
200 SDValue Ptr = N->getBasePtr();
203 SDValue Base = DAG.getTargetLoweringInfo().unwrapAddress(Ptr);
208 // pre-inc/pre-dec ops are components of EA.
209 if (N->getAddressingMode() == ISD::PRE_INC) {
210 if (auto *C = dyn_cast<ConstantSDNode>(N->getOffset()))
211 Offset += C->getSExtValue();
214 } else if (N->getAddressingMode() == ISD::PRE_DEC) {
215 if (auto *C = dyn_cast<ConstantSDNode>(N->getOffset()))
216 Offset -= C->getSExtValue();
223 switch (Base->getOpcode()) {
226 if (auto *C = dyn_cast<ConstantSDNode>(Base->getOperand(1)))
227 if (DAG.MaskedValueIsZero(Base->getOperand(0), C->getAPIntValue())) {
228 Offset += C->getSExtValue();
229 Base = DAG.getTargetLoweringInfo().unwrapAddress(Base->getOperand(0));
234 if (auto *C = dyn_cast<ConstantSDNode>(Base->getOperand(1))) {
235 Offset += C->getSExtValue();
236 Base = DAG.getTargetLoweringInfo().unwrapAddress(Base->getOperand(0));
242 auto *LSBase = cast<LSBaseSDNode>(Base.getNode());
243 unsigned int IndexResNo = (Base->getOpcode() == ISD::LOAD) ? 1 : 0;
244 if (LSBase->isIndexed() && Base.getResNo() == IndexResNo)
245 if (auto *C = dyn_cast<ConstantSDNode>(LSBase->getOffset())) {
246 auto Off = C->getSExtValue();
247 if (LSBase->getAddressingMode() == ISD::PRE_DEC ||
248 LSBase->getAddressingMode() == ISD::POST_DEC)
249 Offset -= Off;
252 Base = DAG.getTargetLoweringInfo().unwrapAddress(LSBase->getBasePtr());
262 if (Base->getOpcode() == ISD::ADD) {
266 // Inside a loop the current BASE pointer is calculated using an ADD and a
267 // MUL instruction. In this case Base is the actual BASE pointer.
271 if (Base->getOperand(1)->getOpcode() == ISD::MUL)
272 return BaseIndexOffset(Base, Index, Offset, IsIndexSignExt);
274 // Look at Base + Index + Offset cases.
275 Index = Base->getOperand(1);
276 SDValue PotentialBase = Base->getOperand(0);
279 if (Index->getOpcode() == ISD::SIGN_EXTEND) {
280 Index = Index->getOperand(0);
285 if (Index->getOpcode() != ISD::ADD ||
286 !isa<ConstantSDNode>(Index->getOperand(1)))
289 Offset += cast<ConstantSDNode>(Index->getOperand(1))->getSExtValue();
290 Index = Index->getOperand(0);
291 if (Index->getOpcode() == ISD::SIGN_EXTEND) {
292 Index = Index->getOperand(0);
296 Base = PotentialBase;
298 return BaseIndexOffset(Base, Index, Offset, IsIndexSignExt);
306 if (LN->hasOffset())
307 return BaseIndexOffset(LN->getOperand(1), SDValue(), LN->getOffset(),
309 return BaseIndexOffset(LN->getOperand(1), SDValue(), false);
321 OS << "BaseIndexOffset base=[";
322 Base->print(OS);
325 Index->print(OS);