1 //===- SelectionDAGAddressAnalysis.h - DAG Address Analysis -----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_CODEGEN_SELECTIONDAGADDRESSANALYSIS_H
11 #define LLVM_CODEGEN_SELECTIONDAGADDRESSANALYSIS_H
13 #include "llvm/CodeGen/SelectionDAGNodes.h"
20 /// Helper struct to parse and store a memory address as base + index + offset.
21 /// We ignore sign extensions when it is safe to do so.
22 /// The following two expressions are not equivalent. To differentiate we need
23 /// to store whether there was a sign extension involved in the index
25 /// (load (i64 add (i64 copyfromreg %c)
26 /// (i64 signextend (add (i8 load %index)
30 /// (load (i64 add (i64 copyfromreg %c)
31 /// (i64 signextend (i32 add (i32 signextend (i8 load %index))
33 class BaseIndexOffset {
38 bool IsIndexSignExt = false;
41 BaseIndexOffset() = default;
42 BaseIndexOffset(SDValue Base, SDValue Index, int64_t Offset,
44 : Base(Base), Index(Index), Offset(Offset),
45 IsIndexSignExt(IsIndexSignExt) {}
47 SDValue getBase() { return Base; }
48 SDValue getBase() const { return Base; }
49 SDValue getIndex() { return Index; }
50 SDValue getIndex() const { return Index; }
52 bool equalBaseIndex(const BaseIndexOffset &Other,
53 const SelectionDAG &DAG) const {
55 return equalBaseIndex(Other, DAG, Off);
58 bool equalBaseIndex(const BaseIndexOffset &Other, const SelectionDAG &DAG,
61 /// Parses tree in Ptr for base, index, offset addresses.
62 static BaseIndexOffset match(const LSBaseSDNode *N, const SelectionDAG &DAG);
65 } // end namespace llvm
67 #endif // LLVM_CODEGEN_SELECTIONDAGADDRESSANALYSIS_H