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/ADT/SmallVector.h"
18 #include "llvm/IR/DebugLoc.h"
19 #include "llvm/Support/DataTypes.h"
27 /// SDDbgValue - Holds the information from a dbg_value node through SDISel.
28 /// 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
51 enum DbgValueKind kind;
56 // Constructor for non-constants.
57 SDDbgValue(MDNode *Var, MDNode *Expr, SDNode *N, unsigned R, bool indir,
58 uint64_t off, DebugLoc dl, unsigned O)
59 : Var(Var), Expr(Expr), Offset(off), DL(dl), Order(O), IsIndirect(indir) {
65 // Constructor for constants.
66 SDDbgValue(MDNode *Var, MDNode *Expr, const Value *C, uint64_t off,
67 DebugLoc dl, unsigned O)
68 : Var(Var), Expr(Expr), Offset(off), DL(dl), Order(O), IsIndirect(false) {
73 // Constructor for frame indices.
74 SDDbgValue(MDNode *Var, MDNode *Expr, unsigned FI, uint64_t off, DebugLoc dl,
76 : Var(Var), Expr(Expr), Offset(off), DL(dl), Order(O), IsIndirect(false) {
82 DbgValueKind getKind() const { return kind; }
84 // Returns the MDNode pointer for the variable.
85 MDNode *getVariable() const { return Var; }
87 // Returns the MDNode pointer for the expression.
88 MDNode *getExpression() const { return Expr; }
90 // Returns the SDNode* for a register ref
91 SDNode *getSDNode() const { assert (kind==SDNODE); return u.s.Node; }
93 // Returns the ResNo for a register ref
94 unsigned getResNo() const { assert (kind==SDNODE); return u.s.ResNo; }
96 // Returns the Value* for a constant
97 const Value *getConst() const { assert (kind==CONST); return u.Const; }
99 // Returns the FrameIx for a stack object
100 unsigned getFrameIx() const { assert (kind==FRAMEIX); return u.FrameIx; }
102 // Returns whether this is an indirect value.
103 bool isIndirect() const { return IsIndirect; }
105 // Returns the offset.
106 uint64_t getOffset() const { return Offset; }
108 // Returns the DebugLoc.
109 DebugLoc getDebugLoc() const { return DL; }
111 // Returns the SDNodeOrder. This is the order of the preceding node in the
113 unsigned getOrder() const { return Order; }
115 // setIsInvalidated / isInvalidated - Setter / getter of the "Invalidated"
116 // property. A SDDbgValue is invalid if the SDNode that produces the value is
118 void setIsInvalidated() { Invalid = true; }
119 bool isInvalidated() const { return Invalid; }
122 } // end llvm namespace