LLVM  7.0.0
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 virtual registers and frame indices.
75  SDDbgValue(DIVariable *Var, DIExpression *Expr, unsigned VRegOrFrameIdx,
76  bool IsIndirect, DebugLoc DL, unsigned Order,
77  enum DbgValueKind Kind)
78  : Var(Var), Expr(Expr), DL(DL), Order(Order), IsIndirect(IsIndirect) {
79  assert((Kind == VREG || Kind == FRAMEIX) &&
80  "Invalid SDDbgValue constructor");
81  kind = Kind;
82  if (kind == VREG)
83  u.VReg = VRegOrFrameIdx;
84  else
85  u.FrameIx = VRegOrFrameIdx;
86  }
87 
88  /// Returns the kind.
89  DbgValueKind getKind() const { return kind; }
90 
91  /// Returns the DIVariable pointer for the variable.
92  DIVariable *getVariable() const { return Var; }
93 
94  /// Returns the DIExpression pointer for the expression.
95  DIExpression *getExpression() const { return Expr; }
96 
97  /// Returns the SDNode* for a register ref
98  SDNode *getSDNode() const { assert (kind==SDNODE); return u.s.Node; }
99 
100  /// Returns the ResNo for a register ref
101  unsigned getResNo() const { assert (kind==SDNODE); return u.s.ResNo; }
102 
103  /// Returns the Value* for a constant
104  const Value *getConst() const { assert (kind==CONST); return u.Const; }
105 
106  /// Returns the FrameIx for a stack object
107  unsigned getFrameIx() const { assert (kind==FRAMEIX); return u.FrameIx; }
108 
109  /// Returns the Virtual Register for a VReg
110  unsigned getVReg() const { assert (kind==VREG); return u.VReg; }
111 
112  /// Returns whether this is an indirect value.
113  bool isIndirect() const { return IsIndirect; }
114 
115  /// Returns the DebugLoc.
116  DebugLoc getDebugLoc() const { return DL; }
117 
118  /// Returns the SDNodeOrder. This is the order of the preceding node in the
119  /// input.
120  unsigned getOrder() const { return Order; }
121 
122  /// setIsInvalidated / isInvalidated - Setter / getter of the "Invalidated"
123  /// property. A SDDbgValue is invalid if the SDNode that produces the value is
124  /// deleted.
125  void setIsInvalidated() { Invalid = true; }
126  bool isInvalidated() const { return Invalid; }
127 };
128 
129 /// Holds the information from a dbg_label node through SDISel.
130 /// We do not use SDValue here to avoid including its header.
131 class SDDbgLabel {
132  MDNode *Label;
133  DebugLoc DL;
134  unsigned Order;
135 
136 public:
137  SDDbgLabel(MDNode *Label, DebugLoc dl, unsigned O)
138  : Label(Label), DL(std::move(dl)), Order(O) {}
139 
140  /// Returns the MDNode pointer for the label.
141  MDNode *getLabel() const { return Label; }
142 
143  /// Returns the DebugLoc.
144  DebugLoc getDebugLoc() const { return DL; }
145 
146  /// Returns the SDNodeOrder. This is the order of the preceding node in the
147  /// input.
148  unsigned getOrder() const { return Order; }
149 };
150 
151 } // end llvm namespace
152 
153 #endif
unsigned VReg
Valid for registers.
uint64_t CallInst * C
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.
struct llvm::SDDbgValue::@331::@332 s
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.
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.
const unsigned Kind
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.
SDDbgValue(DIVariable *Var, DIExpression *Expr, unsigned VRegOrFrameIdx, bool IsIndirect, DebugLoc DL, unsigned Order, enum DbgValueKind Kind)
Constructor for virtual registers and frame indices.
unsigned getOrder() const
Returns the SDNodeOrder.