1 //===-- llvm/CodeGen/SelectionDAGAddressAnalysis.h ------- DAG Address Analysis
4 // The LLVM Compiler Infrastructure
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
12 #ifndef LLVM_CODEGEN_SELECTIONDAGADDRESSANALYSIS_H
13 #define LLVM_CODEGEN_SELECTIONDAGADDRESSANALYSIS_H
15 #include "llvm/CodeGen/ISDOpcodes.h"
16 #include "llvm/CodeGen/SelectionDAG.h"
17 #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 {
41 BaseIndexOffset() : Offset(0), IsIndexSignExt(false) {}
43 BaseIndexOffset(SDValue Base, SDValue Index, int64_t Offset,
45 : Base(Base), Index(Index), Offset(Offset),
46 IsIndexSignExt(IsIndexSignExt) {}
48 SDValue getBase() { return Base; }
49 SDValue getIndex() { return Index; }
51 bool equalBaseIndex(BaseIndexOffset &Other, const SelectionDAG &DAG) {
53 return equalBaseIndex(Other, DAG, Off);
56 bool equalBaseIndex(BaseIndexOffset &Other, const SelectionDAG &DAG,
59 /// Parses tree in Ptr for base, index, offset addresses.
60 static BaseIndexOffset match(SDValue Ptr, const SelectionDAG &DAG);