1 //===-- llvm/CodeGen/SDNodeDbgValue.h - SelectionDAG dbg_value --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the SDDbgValue class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_CODEGEN_SELECTIONDAG_SDNODEDBGVALUE_H
15 #define LLVM_LIB_CODEGEN_SELECTIONDAG_SDNODEDBGVALUE_H
17 #include "llvm/IR/DebugLoc.h"
18 #include "llvm/Support/DataTypes.h"
29 /// Holds the information from a dbg_value node through SDISel.
30 /// We do not use SDValue here to avoid including its header.
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 VREG = 3 ///< Value is a virtual register.
42 SDNode *Node; ///< Valid for expressions.
43 unsigned ResNo; ///< Valid for expressions.
45 const Value *Const; ///< Valid for constants.
46 unsigned FrameIx; ///< Valid for stack objects.
47 unsigned VReg; ///< Valid for registers.
53 enum DbgValueKind kind;
59 /// Constructor for non-constants.
60 SDDbgValue(DIVariable *Var, DIExpression *Expr, SDNode *N, unsigned R,
61 bool indir, DebugLoc dl, unsigned O)
62 : Var(Var), Expr(Expr), DL(std::move(dl)), Order(O), IsIndirect(indir) {
68 /// Constructor for constants.
69 SDDbgValue(DIVariable *Var, DIExpression *Expr, const Value *C, DebugLoc dl,
71 : Var(Var), Expr(Expr), DL(std::move(dl)), Order(O), IsIndirect(false) {
76 /// Constructor for virtual registers and frame indices.
77 SDDbgValue(DIVariable *Var, DIExpression *Expr, unsigned VRegOrFrameIdx,
78 bool IsIndirect, DebugLoc DL, unsigned Order,
79 enum DbgValueKind Kind)
80 : Var(Var), Expr(Expr), DL(DL), Order(Order), IsIndirect(IsIndirect) {
81 assert((Kind == VREG || Kind == FRAMEIX) &&
82 "Invalid SDDbgValue constructor");
85 u.VReg = VRegOrFrameIdx;
87 u.FrameIx = VRegOrFrameIdx;
91 DbgValueKind getKind() const { return kind; }
93 /// Returns the DIVariable pointer for the variable.
94 DIVariable *getVariable() const { return Var; }
96 /// Returns the DIExpression pointer for the expression.
97 DIExpression *getExpression() const { return Expr; }
99 /// Returns the SDNode* for a register ref
100 SDNode *getSDNode() const { assert (kind==SDNODE); return u.s.Node; }
102 /// Returns the ResNo for a register ref
103 unsigned getResNo() const { assert (kind==SDNODE); return u.s.ResNo; }
105 /// Returns the Value* for a constant
106 const Value *getConst() const { assert (kind==CONST); return u.Const; }
108 /// Returns the FrameIx for a stack object
109 unsigned getFrameIx() const { assert (kind==FRAMEIX); return u.FrameIx; }
111 /// Returns the Virtual Register for a VReg
112 unsigned getVReg() const { assert (kind==VREG); return u.VReg; }
114 /// Returns whether this is an indirect value.
115 bool isIndirect() const { return IsIndirect; }
117 /// Returns the DebugLoc.
118 DebugLoc getDebugLoc() const { return DL; }
120 /// Returns the SDNodeOrder. This is the order of the preceding node in the
122 unsigned getOrder() const { return Order; }
124 /// setIsInvalidated / isInvalidated - Setter / getter of the "Invalidated"
125 /// property. A SDDbgValue is invalid if the SDNode that produces the value is
127 void setIsInvalidated() { Invalid = true; }
128 bool isInvalidated() const { return Invalid; }
130 /// setIsEmitted / isEmitted - Getter/Setter for flag indicating that this
131 /// SDDbgValue has been emitted to an MBB.
132 void setIsEmitted() { Emitted = true; }
133 bool isEmitted() const { return Emitted; }
135 /// clearIsEmitted - Reset Emitted flag, for certain special cases where
136 /// dbg.addr is emitted twice.
137 void clearIsEmitted() { Emitted = false; }
139 LLVM_DUMP_METHOD void dump(raw_ostream &OS) const;
142 /// Holds the information from a dbg_label node through SDISel.
143 /// We do not use SDValue here to avoid including its header.
150 SDDbgLabel(MDNode *Label, DebugLoc dl, unsigned O)
151 : Label(Label), DL(std::move(dl)), Order(O) {}
153 /// Returns the MDNode pointer for the label.
154 MDNode *getLabel() const { return Label; }
156 /// Returns the DebugLoc.
157 DebugLoc getDebugLoc() const { return DL; }
159 /// Returns the SDNodeOrder. This is the order of the preceding node in the
161 unsigned getOrder() const { return Order; }
164 } // end llvm namespace