LLVM  7.0.0svn
SDNodeDbgValue.h
Go to the documentation of this file.
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 /// 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 
56 public:
57  /// Constructor for non-constants.
58  SDDbgValue(DIVariable *Var, DIExpression *Expr, SDNode *N, unsigned R,
59  bool indir, DebugLoc dl, unsigned O)
60  : Var(Var), Expr(Expr), DL(std::move(dl)), Order(O), IsIndirect(indir) {
61  kind = SDNODE;
62  u.s.Node = N;
63  u.s.ResNo = R;
64  }
65 
66  /// Constructor for constants.
67  SDDbgValue(DIVariable *Var, DIExpression *Expr, const Value *C, DebugLoc dl,
68  unsigned O)
69  : Var(Var), Expr(Expr), DL(std::move(dl)), Order(O), IsIndirect(false) {
70  kind = CONST;
71  u.Const = C;
72  }
73 
74  /// Constructor for frame indices.
75  SDDbgValue(DIVariable *Var, DIExpression *Expr, unsigned FI, DebugLoc dl,
76  unsigned O)
77  : Var(Var), Expr(Expr), DL(std::move(dl)), Order(O), IsIndirect(false) {
78  kind = FRAMEIX;
79  u.FrameIx = FI;
80  }
81 
82  /// Constructor for virtual registers.
83  SDDbgValue(DIVariable *Var, DIExpression *Expr, unsigned VReg, bool indir,
84  DebugLoc dl, unsigned O)
85  : Var(Var), Expr(Expr), DL(std::move(dl)), Order(O), IsIndirect(indir) {
86  kind = VREG;
87  u.VReg = VReg;
88  }
89 
90  /// Returns the kind.
91  DbgValueKind getKind() const { return kind; }
92 
93  /// Returns the DIVariable pointer for the variable.
94  DIVariable *getVariable() const { return Var; }
95 
96  /// Returns the DIExpression pointer for the expression.
97  DIExpression *getExpression() const { return Expr; }
98 
99  /// Returns the SDNode* for a register ref
100  SDNode *getSDNode() const { assert (kind==SDNODE); return u.s.Node; }
101 
102  /// Returns the ResNo for a register ref
103  unsigned getResNo() const { assert (kind==SDNODE); return u.s.ResNo; }
104 
105  /// Returns the Value* for a constant
106  const Value *getConst() const { assert (kind==CONST); return u.Const; }
107 
108  /// Returns the FrameIx for a stack object
109  unsigned getFrameIx() const { assert (kind==FRAMEIX); return u.FrameIx; }
110 
111  /// Returns the Virtual Register for a VReg
112  unsigned getVReg() const { assert (kind==VREG); return u.VReg; }
113 
114  /// Returns whether this is an indirect value.
115  bool isIndirect() const { return IsIndirect; }
116 
117  /// Returns the DebugLoc.
118  DebugLoc getDebugLoc() const { return DL; }
119 
120  /// Returns the SDNodeOrder. This is the order of the preceding node in the
121  /// input.
122  unsigned getOrder() const { return Order; }
123 
124  /// setIsInvalidated / isInvalidated - Setter / getter of the "Invalidated"
125  /// property. A SDDbgValue is invalid if the SDNode that produces the value is
126  /// deleted.
127  void setIsInvalidated() { Invalid = true; }
128  bool isInvalidated() const { return Invalid; }
129 };
130 
131 /// Holds the information from a dbg_label node through SDISel.
132 /// We do not use SDValue here to avoid including its header.
133 class SDDbgLabel {
134  MDNode *Label;
135  DebugLoc DL;
136  unsigned Order;
137 
138 public:
139  SDDbgLabel(MDNode *Label, DebugLoc dl, unsigned O)
140  : Label(Label), DL(std::move(dl)), Order(O) {}
141 
142  /// Returns the MDNode pointer for the label.
143  MDNode *getLabel() const { return Label; }
144 
145  /// Returns the DebugLoc.
146  DebugLoc getDebugLoc() const { return DL; }
147 
148  /// Returns the SDNodeOrder. This is the order of the preceding node in the
149  /// input.
150  unsigned getOrder() const { return Order; }
151 };
152 
153 } // end llvm namespace
154 
155 #endif
unsigned VReg
Valid for registers.
uint64_t CallInst * C
struct llvm::SDDbgValue::@328::@329 s
SDDbgValue(DIVariable *Var, DIExpression *Expr, unsigned FI, DebugLoc dl, unsigned O)
Constructor for frame indices.
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
SDNode * getSDNode() const
Returns the SDNode* for a register ref.
bool isInvalidated() const
const Value * getConst() const
Returns the Value* for a constant.
unsigned ResNo
Valid for expressions.
A debug info location.
Definition: DebugLoc.h:34
Metadata node.
Definition: Metadata.h:862
unsigned FrameIx
Valid for stack objects.
Value is a virtual register.
unsigned getResNo() const
Returns the ResNo for a register ref.
unsigned getVReg() const
Returns the Virtual Register for a VReg.
Definition: BitVector.h:921
unsigned getFrameIx() const
Returns the FrameIx for a stack object.
const Value * Const
Valid for constants.
Value is contents of a stack location.
DIVariable * getVariable() const
Returns the DIVariable pointer for the variable.
DbgValueKind getKind() const
Returns the kind.
Base class for variables.
SDDbgValue(DIVariable *Var, DIExpression *Expr, SDNode *N, unsigned R, bool indir, DebugLoc dl, unsigned O)
Constructor for non-constants.
DebugLoc getDebugLoc() const
Returns the DebugLoc.
SDDbgValue(DIVariable *Var, DIExpression *Expr, const Value *C, DebugLoc dl, unsigned O)
Constructor for constants.
DIExpression * getExpression() const
Returns the DIExpression pointer for the expression.
SDDbgValue(DIVariable *Var, DIExpression *Expr, unsigned VReg, bool indir, DebugLoc dl, unsigned O)
Constructor for virtual registers.
DebugLoc getDebugLoc() const
Returns the DebugLoc.
Value is a constant.
void setIsInvalidated()
setIsInvalidated / isInvalidated - Setter / getter of the "Invalidated" property. ...
Represents one node in the SelectionDAG.
DWARF expression.
SDNode * Node
Valid for expressions.
Value is the result of an expression.
Holds the information from a dbg_label node through SDISel.
#define N
MDNode * getLabel() const
Returns the MDNode pointer for the label.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
Definition: Value.h:73
unsigned getOrder() const
Returns the SDNodeOrder.
SDDbgLabel(MDNode *Label, DebugLoc dl, unsigned O)
bool isIndirect() const
Returns whether this is an indirect value.
Holds the information from a dbg_value node through SDISel.
unsigned getOrder() const
Returns the SDNodeOrder.