blob: d43a0447a6cf98e9ce63b7f360e0cca72e522cd4 [file] [log] [blame]
Dale Johannesen06a26632010-03-06 00:03:23 +00001//===-- llvm/CodeGen/SDDbgValue.h - SD dbg_value handling--------*- 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_SDDBGVALUE_H
15#define LLVM_CODEGEN_SDDBGVALUE_H
16
17#include "llvm/ADT/SmallVector.h"
18#include "llvm/Support/DebugLoc.h"
19
20namespace llvm {
21
22class MDNode;
23class SDNode;
24class Value;
25
26/// SDDbgValue - Holds the information from a dbg_value node through SDISel.
27/// Either Const or Node is nonzero, but not both.
28/// We do not use SDValue here to avoid including its header.
29
30class SDDbgValue {
31 SDNode *Node; // valid for non-constants
32 unsigned ResNo; // valid for non-constants
33 Value *Const; // valid for constants
34 MDNode *mdPtr;
35 uint64_t Offset;
36 DebugLoc DL;
Dale Johannesenfab4a252010-03-08 05:39:50 +000037 unsigned Order;
Dale Johannesen06a26632010-03-06 00:03:23 +000038public:
39 // Constructor for non-constants.
Dale Johannesenfab4a252010-03-08 05:39:50 +000040 SDDbgValue(MDNode *mdP, SDNode *N, unsigned R, uint64_t off, DebugLoc dl,
41 unsigned O) :
42 Node(N), ResNo(R), Const(0), mdPtr(mdP), Offset(off), DL(dl), Order(O) {}
Dale Johannesen06a26632010-03-06 00:03:23 +000043
44 // Constructor for constants.
Dale Johannesenfab4a252010-03-08 05:39:50 +000045 SDDbgValue(MDNode *mdP, Value *C, uint64_t off, DebugLoc dl, unsigned O) :
46 Node(0), ResNo(0), Const(C), mdPtr(mdP), Offset(off), DL(dl), Order(O) {}
Dale Johannesen06a26632010-03-06 00:03:23 +000047
48 // Returns the MDNode pointer.
49 MDNode *getMDPtr() { return mdPtr; }
50
51 // Returns the SDNode* (valid for non-constants only).
52 SDNode *getSDNode() { assert (!Const); return Node; }
53
54 // Returns the ResNo (valid for non-constants only).
55 unsigned getResNo() { assert (!Const); return ResNo; }
56
57 // Returns the Value* for a constant (invalid for non-constants).
58 Value *getConst() { assert (!Node); return Const; }
59
60 // Returns the offset.
61 uint64_t getOffset() { return Offset; }
62
63 // Returns the DebugLoc.
64 DebugLoc getDebugLoc() { return DL; }
Dale Johannesenfab4a252010-03-08 05:39:50 +000065
66 // Returns the SDNodeOrder. This is the order of the preceding node in the
67 // input.
68 unsigned getOrder() { return Order; }
Dale Johannesen06a26632010-03-06 00:03:23 +000069};
70
71} // end llvm namespace
72
73#endif