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"
28 /// Holds the information from a dbg_value node through SDISel.
29 /// We do not use SDValue here to avoid including its header.
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.
40 SDNode *Node; ///< Valid for expressions.
41 unsigned ResNo; ///< Valid for expressions.
43 const Value *Const; ///< Valid for constants.
44 unsigned FrameIx; ///< Valid for stack objects.
50 enum DbgValueKind kind;
55 /// Constructor for non-constants.
56 SDDbgValue(DIVariable *Var, DIExpression *Expr, SDNode *N, unsigned R,
57 bool indir, DebugLoc dl, unsigned O)
58 : Var(Var), Expr(Expr), DL(std::move(dl)), Order(O), IsIndirect(indir) {
64 /// Constructor for constants.
65 SDDbgValue(DIVariable *Var, DIExpression *Expr, const Value *C, DebugLoc dl,
67 : Var(Var), Expr(Expr), DL(std::move(dl)), Order(O), IsIndirect(false) {
72 /// Constructor for frame indices.
73 SDDbgValue(DIVariable *Var, DIExpression *Expr, unsigned FI, DebugLoc dl,
75 : Var(Var), Expr(Expr), DL(std::move(dl)), Order(O), IsIndirect(false) {
81 DbgValueKind getKind() const { return kind; }
83 /// Returns the DIVariable pointer for the variable.
84 DIVariable *getVariable() const { return Var; }
86 /// Returns the DIExpression pointer for the expression.
87 DIExpression *getExpression() const { return Expr; }
89 /// Returns the SDNode* for a register ref
90 SDNode *getSDNode() const { assert (kind==SDNODE); return u.s.Node; }
92 /// Returns the ResNo for a register ref
93 unsigned getResNo() const { assert (kind==SDNODE); return u.s.ResNo; }
95 /// Returns the Value* for a constant
96 const Value *getConst() const { assert (kind==CONST); return u.Const; }
98 /// Returns the FrameIx for a stack object
99 unsigned getFrameIx() const { assert (kind==FRAMEIX); return u.FrameIx; }
101 /// Returns whether this is an indirect value.
102 bool isIndirect() const { return IsIndirect; }
104 /// Returns the DebugLoc.
105 DebugLoc getDebugLoc() const { return DL; }
107 /// Returns the SDNodeOrder. This is the order of the preceding node in the
109 unsigned getOrder() const { return Order; }
111 /// setIsInvalidated / isInvalidated - Setter / getter of the "Invalidated"
112 /// property. A SDDbgValue is invalid if the SDNode that produces the value is
114 void setIsInvalidated() { Invalid = true; }
115 bool isInvalidated() const { return Invalid; }
118 } // end llvm namespace