SDNodeDbgValue.h revision 206083
1205218Srdivacky//===-- llvm/CodeGen/SDNodeDbgValue.h - SelectionDAG dbg_value --*- C++ -*-===//
2205218Srdivacky//
3205218Srdivacky//                     The LLVM Compiler Infrastructure
4205218Srdivacky//
5205218Srdivacky// This file is distributed under the University of Illinois Open Source
6205218Srdivacky// License. See LICENSE.TXT for details.
7205218Srdivacky//
8205218Srdivacky//===----------------------------------------------------------------------===//
9205218Srdivacky//
10205218Srdivacky// This file declares the SDDbgValue class.
11205218Srdivacky//
12205218Srdivacky//===----------------------------------------------------------------------===//
13205218Srdivacky
14205218Srdivacky#ifndef LLVM_CODEGEN_SDNODEDBGVALUE_H
15205218Srdivacky#define LLVM_CODEGEN_SDNODEDBGVALUE_H
16205218Srdivacky
17205218Srdivacky#include "llvm/ADT/SmallVector.h"
18205218Srdivacky#include "llvm/Support/DebugLoc.h"
19205218Srdivacky
20205218Srdivackynamespace llvm {
21205218Srdivacky
22205218Srdivackyclass MDNode;
23205218Srdivackyclass SDNode;
24205218Srdivackyclass Value;
25205218Srdivacky
26205218Srdivacky/// SDDbgValue - Holds the information from a dbg_value node through SDISel.
27205218Srdivacky/// We do not use SDValue here to avoid including its header.
28205218Srdivacky
29205218Srdivackyclass SDDbgValue {
30205218Srdivackypublic:
31205218Srdivacky  enum DbgValueKind {
32205218Srdivacky    SDNODE = 0,             // value is the result of an expression
33205218Srdivacky    CONST = 1,              // value is a constant
34205218Srdivacky    FRAMEIX = 2             // value is contents of a stack location
35205218Srdivacky  };
36205218Srdivackyprivate:
37205218Srdivacky  enum DbgValueKind kind;
38205218Srdivacky  union {
39205218Srdivacky    struct {
40205218Srdivacky      SDNode *Node;         // valid for expressions
41205218Srdivacky      unsigned ResNo;       // valid for expressions
42205218Srdivacky    } s;
43205218Srdivacky    Value *Const;           // valid for constants
44205218Srdivacky    unsigned FrameIx;       // valid for stack objects
45205218Srdivacky  } u;
46205218Srdivacky  MDNode *mdPtr;
47205218Srdivacky  uint64_t Offset;
48205218Srdivacky  DebugLoc DL;
49205218Srdivacky  unsigned Order;
50206083Srdivacky  bool Invalid;
51205218Srdivackypublic:
52205218Srdivacky  // Constructor for non-constants.
53205218Srdivacky  SDDbgValue(MDNode *mdP, SDNode *N, unsigned R, uint64_t off, DebugLoc dl,
54206083Srdivacky             unsigned O) : mdPtr(mdP), Offset(off), DL(dl), Order(O),
55206083Srdivacky                           Invalid(false) {
56205218Srdivacky    kind = SDNODE;
57205218Srdivacky    u.s.Node = N;
58205218Srdivacky    u.s.ResNo = R;
59205218Srdivacky  }
60205218Srdivacky
61205218Srdivacky  // Constructor for constants.
62205218Srdivacky  SDDbgValue(MDNode *mdP, Value *C, uint64_t off, DebugLoc dl, unsigned O) :
63206083Srdivacky    mdPtr(mdP), Offset(off), DL(dl), Order(O), Invalid(false) {
64205218Srdivacky    kind = CONST;
65205218Srdivacky    u.Const = C;
66205218Srdivacky  }
67205218Srdivacky
68205218Srdivacky  // Constructor for frame indices.
69205218Srdivacky  SDDbgValue(MDNode *mdP, unsigned FI, uint64_t off, DebugLoc dl, unsigned O) :
70206083Srdivacky    mdPtr(mdP), Offset(off), DL(dl), Order(O), Invalid(false) {
71205218Srdivacky    kind = FRAMEIX;
72205218Srdivacky    u.FrameIx = FI;
73205218Srdivacky  }
74205218Srdivacky
75205218Srdivacky  // Returns the kind.
76205218Srdivacky  DbgValueKind getKind() { return kind; }
77205218Srdivacky
78205218Srdivacky  // Returns the MDNode pointer.
79205218Srdivacky  MDNode *getMDPtr() { return mdPtr; }
80205218Srdivacky
81205218Srdivacky  // Returns the SDNode* for a register ref
82205218Srdivacky  SDNode *getSDNode() { assert (kind==SDNODE); return u.s.Node; }
83205218Srdivacky
84205218Srdivacky  // Returns the ResNo for a register ref
85205218Srdivacky  unsigned getResNo() { assert (kind==SDNODE); return u.s.ResNo; }
86205218Srdivacky
87205218Srdivacky  // Returns the Value* for a constant
88205218Srdivacky  Value *getConst() { assert (kind==CONST); return u.Const; }
89205218Srdivacky
90205218Srdivacky  // Returns the FrameIx for a stack object
91205218Srdivacky  unsigned getFrameIx() { assert (kind==FRAMEIX); return u.FrameIx; }
92205218Srdivacky
93205218Srdivacky  // Returns the offset.
94205218Srdivacky  uint64_t getOffset() { return Offset; }
95205218Srdivacky
96205218Srdivacky  // Returns the DebugLoc.
97205218Srdivacky  DebugLoc getDebugLoc() { return DL; }
98205218Srdivacky
99205218Srdivacky  // Returns the SDNodeOrder.  This is the order of the preceding node in the
100205218Srdivacky  // input.
101205218Srdivacky  unsigned getOrder() { return Order; }
102206083Srdivacky
103206083Srdivacky  // setIsInvalidated / isInvalidated - Setter / getter of the "Invalidated"
104206083Srdivacky  // property. A SDDbgValue is invalid if the SDNode that produces the value is
105206083Srdivacky  // deleted.
106206083Srdivacky  void setIsInvalidated() { Invalid = true; }
107206083Srdivacky  bool isInvalidated() { return Invalid; }
108205218Srdivacky};
109205218Srdivacky
110205218Srdivacky} // end llvm namespace
111205218Srdivacky
112205218Srdivacky#endif
113