LLVM  8.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 class raw_ostream;
28 
29 /// Holds the information from a dbg_value node through SDISel.
30 /// We do not use SDValue here to avoid including its header.
31 class SDDbgValue {
32 public:
33  enum DbgValueKind {
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.
38  };
39 private:
40  union {
41  struct {
42  SDNode *Node; ///< Valid for expressions.
43  unsigned ResNo; ///< Valid for expressions.
44  } s;
45  const Value *Const; ///< Valid for constants.
46  unsigned FrameIx; ///< Valid for stack objects.
47  unsigned VReg; ///< Valid for registers.
48  } u;
49  DIVariable *Var;
50  DIExpression *Expr;
51  DebugLoc DL;
52  unsigned Order;
53  enum DbgValueKind kind;
54  bool IsIndirect;
55  bool Invalid = false;
56 
57 public:
58  /// Constructor for non-constants.
59  SDDbgValue(DIVariable *Var, DIExpression *Expr, SDNode *N, unsigned R,
60  bool indir, DebugLoc dl, unsigned O)
61  : Var(Var), Expr(Expr), DL(std::move(dl)), Order(O), IsIndirect(indir) {
62  kind = SDNODE;
63  u.s.Node = N;
64  u.s.ResNo = R;
65  }
66 
67  /// Constructor for constants.
68  SDDbgValue(DIVariable *Var, DIExpression *Expr, const Value *C, DebugLoc dl,
69  unsigned O)
70  : Var(Var), Expr(Expr), DL(std::move(dl)), Order(O), IsIndirect(false) {
71  kind = CONST;
72  u.Const = C;
73  }
74 
75  /// Constructor for virtual registers and frame indices.
76  SDDbgValue(DIVariable *Var, DIExpression *Expr, unsigned VRegOrFrameIdx,
77  bool IsIndirect, DebugLoc DL, unsigned Order,
78  enum DbgValueKind Kind)
79  : Var(Var), Expr(Expr), DL(DL), Order(Order), IsIndirect(IsIndirect) {
80  assert((Kind == VREG || Kind == FRAMEIX) &&
81  "Invalid SDDbgValue constructor");
82  kind = Kind;
83  if (kind == VREG)
84  u.VReg = VRegOrFrameIdx;
85  else
86  u.FrameIx = VRegOrFrameIdx;
87  }
88 
89  /// Returns the kind.
90  DbgValueKind getKind() const { return kind; }
91 
92  /// Returns the DIVariable pointer for the variable.
93  DIVariable *getVariable() const { return Var; }
94 
95  /// Returns the DIExpression pointer for the expression.
96  DIExpression *getExpression() const { return Expr; }
97 
98  /// Returns the SDNode* for a register ref
99  SDNode *getSDNode() const { assert (kind==SDNODE); return u.s.Node; }
100 
101  /// Returns the ResNo for a register ref
102  unsigned getResNo() const { assert (kind==SDNODE); return u.s.ResNo; }
103 
104  /// Returns the Value* for a constant
105  const Value *getConst() const { assert (kind==CONST); return u.Const; }
106 
107  /// Returns the FrameIx for a stack object
108  unsigned getFrameIx() const { assert (kind==FRAMEIX); return u.FrameIx; }
109 
110  /// Returns the Virtual Register for a VReg
111  unsigned getVReg() const { assert (kind==VREG); return u.VReg; }
112 
113  /// Returns whether this is an indirect value.
114  bool isIndirect() const { return IsIndirect; }
115 
116  /// Returns the DebugLoc.
117  DebugLoc getDebugLoc() const { return DL; }
118 
119  /// Returns the SDNodeOrder. This is the order of the preceding node in the
120  /// input.
121  unsigned getOrder() const { return Order; }
122 
123  /// setIsInvalidated / isInvalidated - Setter / getter of the "Invalidated"
124  /// property. A SDDbgValue is invalid if the SDNode that produces the value is
125  /// deleted.
126  void setIsInvalidated() { Invalid = true; }
127  bool isInvalidated() const { return Invalid; }
128 
129  LLVM_DUMP_METHOD void dump(raw_ostream &OS) const;
130 };
131 
132 /// Holds the information from a dbg_label node through SDISel.
133 /// We do not use SDValue here to avoid including its header.
134 class SDDbgLabel {
135  MDNode *Label;
136  DebugLoc DL;
137  unsigned Order;
138 
139 public:
140  SDDbgLabel(MDNode *Label, DebugLoc dl, unsigned O)
141  : Label(Label), DL(std::move(dl)), Order(O) {}
142 
143  /// Returns the MDNode pointer for the label.
144  MDNode *getLabel() const { return Label; }
145 
146  /// Returns the DebugLoc.
147  DebugLoc getDebugLoc() const { return DL; }
148 
149  /// Returns the SDNodeOrder. This is the order of the preceding node in the
150  /// input.
151  unsigned getOrder() const { return Order; }
152 };
153 
154 } // end llvm namespace
155 
156 #endif
unsigned VReg
Valid for registers.
uint64_t CallInst * C
This class represents lattice values for constants.
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:864
unsigned FrameIx
Valid for stack objects.
struct llvm::SDDbgValue::@349::@350 s
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:938
unsigned getFrameIx() const
Returns the FrameIx for a stack object.
const Value * Const
Valid for constants.
#define LLVM_DUMP_METHOD
Definition: Compiler.h:74
Value is contents of a stack location.
LLVM_DUMP_METHOD void dump(raw_ostream &OS) const
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
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:46
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.