/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h
Line | Count | Source |
1 | | //===-- llvm/CodeGen/SDNodeDbgValue.h - SelectionDAG dbg_value --*- C++ -*-===// |
2 | | // |
3 | | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | | // See https://llvm.org/LICENSE.txt for license information. |
5 | | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | | // |
7 | | //===----------------------------------------------------------------------===// |
8 | | // |
9 | | // This file declares the SDDbgValue class. |
10 | | // |
11 | | //===----------------------------------------------------------------------===// |
12 | | |
13 | | #ifndef LLVM_LIB_CODEGEN_SELECTIONDAG_SDNODEDBGVALUE_H |
14 | | #define LLVM_LIB_CODEGEN_SELECTIONDAG_SDNODEDBGVALUE_H |
15 | | |
16 | | #include "llvm/IR/DebugLoc.h" |
17 | | #include "llvm/Support/DataTypes.h" |
18 | | #include <utility> |
19 | | |
20 | | namespace llvm { |
21 | | |
22 | | class DIVariable; |
23 | | class DIExpression; |
24 | | class SDNode; |
25 | | class Value; |
26 | | class raw_ostream; |
27 | | |
28 | | /// Holds the information from a dbg_value node through SDISel. |
29 | | /// We do not use SDValue here to avoid including its header. |
30 | | class SDDbgValue { |
31 | | public: |
32 | | enum DbgValueKind { |
33 | | SDNODE = 0, ///< Value is the result of an expression. |
34 | | CONST = 1, ///< Value is a constant. |
35 | | FRAMEIX = 2, ///< Value is contents of a stack location. |
36 | | VREG = 3 ///< Value is a virtual register. |
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 | | unsigned VReg; ///< Valid for registers. |
47 | | } u; |
48 | | DIVariable *Var; |
49 | | DIExpression *Expr; |
50 | | DebugLoc DL; |
51 | | unsigned Order; |
52 | | enum DbgValueKind kind; |
53 | | bool IsIndirect; |
54 | | bool Invalid = false; |
55 | | bool Emitted = false; |
56 | | |
57 | | public: |
58 | | /// Constructor for non-constants. |
59 | | SDDbgValue(DIVariable *Var, DIExpression *Expr, SDNode *N, unsigned R, |
60 | | bool indir, DebugLoc dl, unsigned O) |
61 | 538 | : Var(Var), Expr(Expr), DL(std::move(dl)), Order(O), IsIndirect(indir) { |
62 | 538 | kind = SDNODE; |
63 | 538 | u.s.Node = N; |
64 | 538 | u.s.ResNo = R; |
65 | 538 | } |
66 | | |
67 | | /// Constructor for constants. |
68 | | SDDbgValue(DIVariable *Var, DIExpression *Expr, const Value *C, DebugLoc dl, |
69 | | unsigned O) |
70 | 4.18k | : Var(Var), Expr(Expr), DL(std::move(dl)), Order(O), IsIndirect(false) { |
71 | 4.18k | kind = CONST; |
72 | 4.18k | u.Const = C; |
73 | 4.18k | } |
74 | | |
75 | | /// Constructor for virtual registers and frame indices. |
76 | | SDDbgValue(DIVariable *Var, DIExpression *Expr, unsigned VRegOrFrameIdx, |
77 | | bool IsIndirect, DebugLoc DL, unsigned Order, |
78 | | enum DbgValueKind Kind) |
79 | 111 | : Var(Var), Expr(Expr), DL(DL), Order(Order), IsIndirect(IsIndirect) { |
80 | 111 | assert((Kind == VREG || Kind == FRAMEIX) && |
81 | 111 | "Invalid SDDbgValue constructor"); |
82 | 111 | kind = Kind; |
83 | 111 | if (kind == VREG) |
84 | 52 | u.VReg = VRegOrFrameIdx; |
85 | 59 | else |
86 | 59 | u.FrameIx = VRegOrFrameIdx; |
87 | 111 | } |
88 | | |
89 | | /// Returns the kind. |
90 | 17.9k | DbgValueKind getKind() const { return kind; } |
91 | | |
92 | | /// Returns the DIVariable pointer for the variable. |
93 | 4.85k | DIVariable *getVariable() const { return Var; } |
94 | | |
95 | | /// Returns the DIExpression pointer for the expression. |
96 | 4.85k | DIExpression *getExpression() const { return Expr; } |
97 | | |
98 | | /// Returns the SDNode* for a register ref |
99 | 347 | SDNode *getSDNode() const { assert (kind==SDNODE); return u.s.Node; } |
100 | | |
101 | | /// Returns the ResNo for a register ref |
102 | 550 | unsigned getResNo() const { assert (kind==SDNODE); return u.s.ResNo; } |
103 | | |
104 | | /// Returns the Value* for a constant |
105 | 4.18k | const Value *getConst() const { assert (kind==CONST); return u.Const; } |
106 | | |
107 | | /// Returns the FrameIx for a stack object |
108 | 61 | unsigned getFrameIx() const { assert (kind==FRAMEIX); return u.FrameIx; } |
109 | | |
110 | | /// Returns the Virtual Register for a VReg |
111 | 52 | unsigned getVReg() const { assert (kind==VREG); return u.VReg; } |
112 | | |
113 | | /// Returns whether this is an indirect value. |
114 | 4.81k | bool isIndirect() const { return IsIndirect; } |
115 | | |
116 | | /// Returns the DebugLoc. |
117 | 4.85k | DebugLoc getDebugLoc() const { return DL; } |
118 | | |
119 | | /// Returns the SDNodeOrder. This is the order of the preceding node in the |
120 | | /// input. |
121 | 45.1k | unsigned getOrder() const { return Order; } |
122 | | |
123 | | /// setIsInvalidated / isInvalidated - Setter / getter of the "Invalidated" |
124 | | /// property. A SDDbgValue is invalid if the SDNode that produces the value is |
125 | | /// deleted. |
126 | 695 | void setIsInvalidated() { Invalid = true; } |
127 | 4.94k | bool isInvalidated() const { return Invalid; } |
128 | | |
129 | | /// setIsEmitted / isEmitted - Getter/Setter for flag indicating that this |
130 | | /// SDDbgValue has been emitted to an MBB. |
131 | 4.83k | void setIsEmitted() { Emitted = true; } |
132 | 5.17k | bool isEmitted() const { return Emitted; } |
133 | | |
134 | | /// clearIsEmitted - Reset Emitted flag, for certain special cases where |
135 | | /// dbg.addr is emitted twice. |
136 | 3 | void clearIsEmitted() { Emitted = false; } |
137 | | |
138 | | LLVM_DUMP_METHOD void dump() const; |
139 | | LLVM_DUMP_METHOD void print(raw_ostream &OS) const; |
140 | | }; |
141 | | |
142 | | /// Holds the information from a dbg_label node through SDISel. |
143 | | /// We do not use SDValue here to avoid including its header. |
144 | | class SDDbgLabel { |
145 | | MDNode *Label; |
146 | | DebugLoc DL; |
147 | | unsigned Order; |
148 | | |
149 | | public: |
150 | | SDDbgLabel(MDNode *Label, DebugLoc dl, unsigned O) |
151 | 4 | : Label(Label), DL(std::move(dl)), Order(O) {} |
152 | | |
153 | | /// Returns the MDNode pointer for the label. |
154 | 4 | MDNode *getLabel() const { return Label; } |
155 | | |
156 | | /// Returns the DebugLoc. |
157 | 4 | DebugLoc getDebugLoc() const { return DL; } |
158 | | |
159 | | /// Returns the SDNodeOrder. This is the order of the preceding node in the |
160 | | /// input. |
161 | 12 | unsigned getOrder() const { return Order; } |
162 | | }; |
163 | | |
164 | | } // end llvm namespace |
165 | | |
166 | | #endif |