/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h
Line | Count | Source |
1 | | //===-- llvm/CodeGen/SDNodeDbgValue.h - SelectionDAG dbg_value --*- 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 | | // This file declares the SDDbgValue class. |
11 | | // |
12 | | //===----------------------------------------------------------------------===// |
13 | | |
14 | | #ifndef LLVM_LIB_CODEGEN_SELECTIONDAG_SDNODEDBGVALUE_H |
15 | | #define LLVM_LIB_CODEGEN_SELECTIONDAG_SDNODEDBGVALUE_H |
16 | | |
17 | | #include "llvm/IR/DebugLoc.h" |
18 | | #include "llvm/Support/DataTypes.h" |
19 | | #include <utility> |
20 | | |
21 | | namespace llvm { |
22 | | |
23 | | class DIVariable; |
24 | | class DIExpression; |
25 | | class SDNode; |
26 | | class Value; |
27 | | |
28 | | /// SDDbgValue - Holds the information from a dbg_value node through SDISel. |
29 | | /// We do not use SDValue here to avoid including its header. |
30 | | |
31 | | class SDDbgValue { |
32 | | public: |
33 | | enum DbgValueKind { |
34 | | SDNODE = 0, // value is the result of an expression |
35 | | CONST = 1, // value is a constant |
36 | | FRAMEIX = 2 // value is contents of a stack location |
37 | | }; |
38 | | private: |
39 | | union { |
40 | | struct { |
41 | | SDNode *Node; // valid for expressions |
42 | | unsigned ResNo; // valid for expressions |
43 | | } s; |
44 | | const Value *Const; // valid for constants |
45 | | unsigned FrameIx; // valid for stack objects |
46 | | } u; |
47 | | DIVariable *Var; |
48 | | DIExpression *Expr; |
49 | | DebugLoc DL; |
50 | | unsigned Order; |
51 | | enum DbgValueKind kind; |
52 | | bool IsIndirect; |
53 | | bool Invalid = false; |
54 | | |
55 | | public: |
56 | | // Constructor for non-constants. |
57 | | SDDbgValue(DIVariable *Var, DIExpression *Expr, SDNode *N, unsigned R, |
58 | | bool indir, DebugLoc dl, unsigned O) |
59 | 304 | : Var(Var), Expr(Expr), DL(std::move(dl)), Order(O), IsIndirect(indir) { |
60 | 304 | kind = SDNODE; |
61 | 304 | u.s.Node = N; |
62 | 304 | u.s.ResNo = R; |
63 | 304 | } |
64 | | |
65 | | // Constructor for constants. |
66 | | SDDbgValue(DIVariable *Var, DIExpression *Expr, const Value *C, DebugLoc dl, |
67 | | unsigned O) |
68 | 95 | : Var(Var), Expr(Expr), DL(std::move(dl)), Order(O), IsIndirect(false) { |
69 | 95 | kind = CONST; |
70 | 95 | u.Const = C; |
71 | 95 | } |
72 | | |
73 | | // Constructor for frame indices. |
74 | | SDDbgValue(DIVariable *Var, DIExpression *Expr, unsigned FI, DebugLoc dl, |
75 | | unsigned O) |
76 | 46 | : Var(Var), Expr(Expr), DL(std::move(dl)), Order(O), IsIndirect(false) { |
77 | 46 | kind = FRAMEIX; |
78 | 46 | u.FrameIx = FI; |
79 | 46 | } |
80 | | |
81 | | // Returns the kind. |
82 | 882 | DbgValueKind getKind() const { return kind; } |
83 | | |
84 | | // Returns the DIVariable pointer for the variable. |
85 | 436 | DIVariable *getVariable() const { return Var; } |
86 | | |
87 | | // Returns the DIExpression pointer for the expression. |
88 | 436 | DIExpression *getExpression() const { return Expr; } |
89 | | |
90 | | // Returns the SDNode* for a register ref |
91 | 303 | SDNode *getSDNode() const { assert (kind==SDNODE); return u.s.Node; } |
92 | | |
93 | | // Returns the ResNo for a register ref |
94 | 303 | unsigned getResNo() const { assert (kind==SDNODE); return u.s.ResNo; } |
95 | | |
96 | | // Returns the Value* for a constant |
97 | 95 | const Value *getConst() const { assert (kind==CONST); return u.Const; } |
98 | | |
99 | | // Returns the FrameIx for a stack object |
100 | 43 | unsigned getFrameIx() const { assert (kind==FRAMEIX); return u.FrameIx; } |
101 | | |
102 | | // Returns whether this is an indirect value. |
103 | 393 | bool isIndirect() const { return IsIndirect; } |
104 | | |
105 | | // Returns the DebugLoc. |
106 | 436 | DebugLoc getDebugLoc() const { return DL; } |
107 | | |
108 | | // Returns the SDNodeOrder. This is the order of the preceding node in the |
109 | | // input. |
110 | 3.15k | unsigned getOrder() const { return Order; } |
111 | | |
112 | | // setIsInvalidated / isInvalidated - Setter / getter of the "Invalidated" |
113 | | // property. A SDDbgValue is invalid if the SDNode that produces the value is |
114 | | // deleted. |
115 | 663 | void setIsInvalidated() { Invalid = true; } |
116 | 741 | bool isInvalidated() const { return Invalid; } |
117 | | }; |
118 | | |
119 | | } // end llvm namespace |
120 | | |
121 | | #endif |