/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/include/llvm/CodeGen/SelectionDAGAddressAnalysis.h
Line | Count | Source (jump to first uncovered line) |
1 | | //===- SelectionDAGAddressAnalysis.h - DAG Address Analysis -----*- C++ -*-===// |
2 | | // |
3 | | // The LLVM Compiler Infrastructure |
4 | | // |
5 | | // This file is distributed under the University of Illinois Open Source |
6 | | // License. See LICENSE.TXT for details. |
7 | | // |
8 | | //===----------------------------------------------------------------------===// |
9 | | |
10 | | #ifndef LLVM_CODEGEN_SELECTIONDAGADDRESSANALYSIS_H |
11 | | #define LLVM_CODEGEN_SELECTIONDAGADDRESSANALYSIS_H |
12 | | |
13 | | #include "llvm/CodeGen/SelectionDAGNodes.h" |
14 | | #include <cstdint> |
15 | | |
16 | | namespace llvm { |
17 | | |
18 | | class SelectionDAG; |
19 | | |
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))))) |
33 | | class BaseIndexOffset { |
34 | | private: |
35 | | SDValue Base; |
36 | | SDValue Index; |
37 | | int64_t Offset = 0; |
38 | | bool IsIndexSignExt = false; |
39 | | |
40 | | public: |
41 | 36.2M | BaseIndexOffset() = default; |
42 | | BaseIndexOffset(SDValue Base, SDValue Index, int64_t Offset, |
43 | | bool IsIndexSignExt) |
44 | | : Base(Base), Index(Index), Offset(Offset), |
45 | 116M | IsIndexSignExt(IsIndexSignExt) {} |
46 | | |
47 | 30.1M | SDValue getBase() { return Base; } |
48 | 0 | SDValue getIndex() { return Index; } |
49 | | |
50 | 12.7M | bool equalBaseIndex(BaseIndexOffset &Other, const SelectionDAG &DAG) { |
51 | 12.7M | int64_t Off; |
52 | 12.7M | return equalBaseIndex(Other, DAG, Off); |
53 | 12.7M | } |
54 | | |
55 | | bool equalBaseIndex(BaseIndexOffset &Other, const SelectionDAG &DAG, |
56 | | int64_t &Off); |
57 | | |
58 | | /// Parses tree in Ptr for base, index, offset addresses. |
59 | | static BaseIndexOffset match(SDValue Ptr, const SelectionDAG &DAG); |
60 | | }; |
61 | | |
62 | | } // end namespace llvm |
63 | | |
64 | | #endif // LLVM_CODEGEN_SELECTIONDAGADDRESSANALYSIS_H |