• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_CODEGEN_SDNODEDBGVALUE_H
15 #define LLVM_CODEGEN_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   enum DbgValueKind kind;
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   } u;
47   MDNode *mdPtr;
48   bool IsIndirect;
49   uint64_t Offset;
50   DebugLoc DL;
51   unsigned Order;
52   bool Invalid;
53 public:
54   // Constructor for non-constants.
SDDbgValue(MDNode * mdP,SDNode * N,unsigned R,bool indir,uint64_t off,DebugLoc dl,unsigned O)55   SDDbgValue(MDNode *mdP, SDNode *N, unsigned R,
56 	     bool indir, uint64_t off, DebugLoc dl,
57              unsigned O) : mdPtr(mdP), IsIndirect(indir),
58 			   Offset(off), DL(dl), Order(O),
59                            Invalid(false) {
60     kind = SDNODE;
61     u.s.Node = N;
62     u.s.ResNo = R;
63   }
64 
65   // Constructor for constants.
SDDbgValue(MDNode * mdP,const Value * C,uint64_t off,DebugLoc dl,unsigned O)66   SDDbgValue(MDNode *mdP, const Value *C, uint64_t off, DebugLoc dl,
67              unsigned O) :
68     mdPtr(mdP), IsIndirect(false), Offset(off), DL(dl), Order(O),
69     Invalid(false) {
70     kind = CONST;
71     u.Const = C;
72   }
73 
74   // Constructor for frame indices.
SDDbgValue(MDNode * mdP,unsigned FI,uint64_t off,DebugLoc dl,unsigned O)75   SDDbgValue(MDNode *mdP, unsigned FI, uint64_t off, DebugLoc dl, unsigned O) :
76     mdPtr(mdP), IsIndirect(false), Offset(off), DL(dl), Order(O),
77     Invalid(false) {
78     kind = FRAMEIX;
79     u.FrameIx = FI;
80   }
81 
82   // Returns the kind.
getKind()83   DbgValueKind getKind() { return kind; }
84 
85   // Returns the MDNode pointer.
getMDPtr()86   MDNode *getMDPtr() { return mdPtr; }
87 
88   // Returns the SDNode* for a register ref
getSDNode()89   SDNode *getSDNode() { assert (kind==SDNODE); return u.s.Node; }
90 
91   // Returns the ResNo for a register ref
getResNo()92   unsigned getResNo() { assert (kind==SDNODE); return u.s.ResNo; }
93 
94   // Returns the Value* for a constant
getConst()95   const Value *getConst() { assert (kind==CONST); return u.Const; }
96 
97   // Returns the FrameIx for a stack object
getFrameIx()98   unsigned getFrameIx() { assert (kind==FRAMEIX); return u.FrameIx; }
99 
100   // Returns whether this is an indirect value.
isIndirect()101   bool isIndirect() { return IsIndirect; }
102 
103   // Returns the offset.
getOffset()104   uint64_t getOffset() { return Offset; }
105 
106   // Returns the DebugLoc.
getDebugLoc()107   DebugLoc getDebugLoc() { return DL; }
108 
109   // Returns the SDNodeOrder.  This is the order of the preceding node in the
110   // input.
getOrder()111   unsigned getOrder() { return Order; }
112 
113   // setIsInvalidated / isInvalidated - Setter / getter of the "Invalidated"
114   // property. A SDDbgValue is invalid if the SDNode that produces the value is
115   // deleted.
setIsInvalidated()116   void setIsInvalidated() { Invalid = true; }
isInvalidated()117   bool isInvalidated() { return Invalid; }
118 };
119 
120 } // end llvm namespace
121 
122 #endif
123