Revert r240137 (Fixed/added namespace ending comments using clang-tidy. NFC)
[oota-llvm.git] / lib / CodeGen / SelectionDAG / SDNodeDbgValue.h
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/ADT/SmallVector.h"
18 #include "llvm/IR/DebugLoc.h"
19 #include "llvm/Support/DataTypes.h"
20
21 namespace llvm {
22
23 class MDNode;
24 class SDNode;
25 class Value;
26
27 /// SDDbgValue - Holds the information from a dbg_value node through SDISel.
28 /// We do not use SDValue here to avoid including its header.
29
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   };
37 private:
38   union {
39     struct {
40       SDNode *Node;         // valid for expressions
41       unsigned ResNo;       // valid for expressions
42     } s;
43     const Value *Const;     // valid for constants
44     unsigned FrameIx;       // valid for stack objects
45   } u;
46   MDNode *Var;
47   MDNode *Expr;
48   uint64_t Offset;
49   DebugLoc DL;
50   unsigned Order;
51   enum DbgValueKind kind;
52   bool IsIndirect;
53   bool Invalid = false;
54
55 public:
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) {
60     kind = SDNODE;
61     u.s.Node = N;
62     u.s.ResNo = R;
63   }
64
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) {
69     kind = CONST;
70     u.Const = C;
71   }
72
73   // Constructor for frame indices.
74   SDDbgValue(MDNode *Var, MDNode *Expr, unsigned FI, uint64_t off, DebugLoc dl,
75              unsigned O)
76       : Var(Var), Expr(Expr), Offset(off), DL(dl), Order(O), IsIndirect(false) {
77     kind = FRAMEIX;
78     u.FrameIx = FI;
79   }
80
81   // Returns the kind.
82   DbgValueKind getKind() const { return kind; }
83
84   // Returns the MDNode pointer for the variable.
85   MDNode *getVariable() const { return Var; }
86
87   // Returns the MDNode pointer for the expression.
88   MDNode *getExpression() const { return Expr; }
89
90   // Returns the SDNode* for a register ref
91   SDNode *getSDNode() const { assert (kind==SDNODE); return u.s.Node; }
92
93   // Returns the ResNo for a register ref
94   unsigned getResNo() const { assert (kind==SDNODE); return u.s.ResNo; }
95
96   // Returns the Value* for a constant
97   const Value *getConst() const { assert (kind==CONST); return u.Const; }
98
99   // Returns the FrameIx for a stack object
100   unsigned getFrameIx() const { assert (kind==FRAMEIX); return u.FrameIx; }
101
102   // Returns whether this is an indirect value.
103   bool isIndirect() const { return IsIndirect; }
104
105   // Returns the offset.
106   uint64_t getOffset() const { return Offset; }
107
108   // Returns the DebugLoc.
109   DebugLoc getDebugLoc() const { return DL; }
110
111   // Returns the SDNodeOrder.  This is the order of the preceding node in the
112   // input.
113   unsigned getOrder() const { return Order; }
114
115   // setIsInvalidated / isInvalidated - Setter / getter of the "Invalidated"
116   // property. A SDDbgValue is invalid if the SDNode that produces the value is
117   // deleted.
118   void setIsInvalidated() { Invalid = true; }
119   bool isInvalidated() const { return Invalid; }
120 };
121
122 } // end llvm namespace
123
124 #endif