LLVM  5.0.0
SelectionDAGAddressAnalysis.h
Go to the documentation of this file.
1 //===-- llvm/CodeGen/SelectionDAGAddressAnalysis.h ------- DAG Address Analysis
2 //---*- C++ -*-===//
3 //
4 // The LLVM Compiler Infrastructure
5 //
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
8 //
9 //===----------------------------------------------------------------------===//
10 //
11 
12 #ifndef LLVM_CODEGEN_SELECTIONDAGADDRESSANALYSIS_H
13 #define LLVM_CODEGEN_SELECTIONDAGADDRESSANALYSIS_H
14 
18 
19 namespace llvm {
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
24 /// computation.
25 /// (load (i64 add (i64 copyfromreg %c)
26 /// (i64 signextend (add (i8 load %index)
27 /// (i8 1))))
28 /// vs
29 ///
30 /// (load (i64 add (i64 copyfromreg %c)
31 /// (i64 signextend (i32 add (i32 signextend (i8 load %index))
32 /// (i32 1)))))
34 private:
35  SDValue Base;
36  SDValue Index;
37  int64_t Offset;
38  bool IsIndexSignExt;
39 
40 public:
41  BaseIndexOffset() : Offset(0), IsIndexSignExt(false) {}
42 
43  BaseIndexOffset(SDValue Base, SDValue Index, int64_t Offset,
44  bool IsIndexSignExt)
45  : Base(Base), Index(Index), Offset(Offset),
46  IsIndexSignExt(IsIndexSignExt) {}
47 
48  SDValue getBase() { return Base; }
49  SDValue getIndex() { return Index; }
50 
51  bool equalBaseIndex(BaseIndexOffset &Other, const SelectionDAG &DAG) {
52  int64_t Off;
53  return equalBaseIndex(Other, DAG, Off);
54  }
55 
56  bool equalBaseIndex(BaseIndexOffset &Other, const SelectionDAG &DAG,
57  int64_t &Off);
58 
59  /// Parses tree in Ptr for base, index, offset addresses.
60  static BaseIndexOffset match(SDValue Ptr, const SelectionDAG &DAG);
61 };
62 } // namespace llvm
63 
64 #endif
bool equalBaseIndex(BaseIndexOffset &Other, const SelectionDAG &DAG)
Function Alias Analysis false
BaseIndexOffset(SDValue Base, SDValue Index, int64_t Offset, bool IsIndexSignExt)
Helper struct to parse and store a memory address as base + index + offset.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
Definition: SelectionDAG.h:209
static BaseIndexOffset match(SDValue Ptr, const SelectionDAG &DAG)
Parses tree in Ptr for base, index, offset addresses.
int * Ptr
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...