Rename SDDbgValue.h to SDNodeDbgValue.h for consistency.
[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_CODEGEN_SDNODEDBGVALUE_H
15 #define LLVM_CODEGEN_SDNODEDBGVALUE_H
16
17 #include "llvm/ADT/SmallVector.h"
18 #include "llvm/Support/DebugLoc.h"
19
20 namespace llvm {
21
22 class MDNode;
23 class SDNode;
24 class Value;
25
26 /// SDDbgValue - Holds the information from a dbg_value node through SDISel.
27 /// We do not use SDValue here to avoid including its header.
28
29 class SDDbgValue {
30 public:
31   enum DbgValueKind {
32     SDNODE = 0,             // value is the result of an expression
33     CONST = 1,              // value is a constant
34     FRAMEIX = 2             // value is contents of a stack location
35   };
36 private:
37   enum DbgValueKind kind;
38   union {
39     struct {
40       SDNode *Node;         // valid for expressions
41       unsigned ResNo;       // valid for expressions
42     } s;
43     Value *Const;           // valid for constants
44     unsigned FrameIx;       // valid for stack objects
45   } u;
46   MDNode *mdPtr;
47   uint64_t Offset;
48   DebugLoc DL;
49   unsigned Order;
50 public:
51   // Constructor for non-constants.
52   SDDbgValue(MDNode *mdP, SDNode *N, unsigned R, uint64_t off, DebugLoc dl,
53              unsigned O) : mdPtr(mdP), Offset(off), DL(dl), Order(O) {
54     kind = SDNODE;
55     u.s.Node = N;
56     u.s.ResNo = R;
57   }
58
59   // Constructor for constants.
60   SDDbgValue(MDNode *mdP, Value *C, uint64_t off, DebugLoc dl, unsigned O) : 
61     mdPtr(mdP), Offset(off), DL(dl), Order(O) {
62     kind = CONST;
63     u.Const = C;
64   }
65
66   // Constructor for frame indices.
67   SDDbgValue(MDNode *mdP, unsigned FI, uint64_t off, DebugLoc dl, unsigned O) : 
68     mdPtr(mdP), Offset(off), DL(dl), Order(O) {
69     kind = FRAMEIX;
70     u.FrameIx = FI;
71   }
72
73   // Returns the kind.
74   DbgValueKind getKind() { return kind; }
75
76   // Returns the MDNode pointer.
77   MDNode *getMDPtr() { return mdPtr; }
78
79   // Returns the SDNode* for a register ref
80   SDNode *getSDNode() { assert (kind==SDNODE); return u.s.Node; }
81
82   // Returns the ResNo for a register ref
83   unsigned getResNo() { assert (kind==SDNODE); return u.s.ResNo; }
84
85   // Returns the Value* for a constant
86   Value *getConst() { assert (kind==CONST); return u.Const; }
87
88   // Returns the FrameIx for a stack object
89   unsigned getFrameIx() { assert (kind==FRAMEIX); return u.FrameIx; }
90
91   // Returns the offset.
92   uint64_t getOffset() { return Offset; }
93
94   // Returns the DebugLoc.
95   DebugLoc getDebugLoc() { return DL; }
96
97   // Returns the SDNodeOrder.  This is the order of the preceding node in the
98   // input.
99   unsigned getOrder() { return Order; }
100 };
101
102 } // end llvm namespace
103
104 #endif