blob: 9d1568f01f40f1615611ca056d6ad3105e24f95f [file] [log] [blame]
Evan Chenga8efe282010-03-14 19:56:39 +00001//===-- llvm/CodeGen/SDNodeDbgValue.h - SelectionDAG dbg_value --*- C++ -*-===//
Dale Johannesen06a26632010-03-06 00:03:23 +00002//
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
Evan Chenga8efe282010-03-14 19:56:39 +000014#ifndef LLVM_CODEGEN_SDNODEDBGVALUE_H
15#define LLVM_CODEGEN_SDNODEDBGVALUE_H
Dale Johannesen06a26632010-03-06 00:03:23 +000016
17#include "llvm/ADT/SmallVector.h"
18#include "llvm/Support/DebugLoc.h"
Benjamin Kramerfd919202010-04-02 20:47:05 +000019#include "llvm/System/DataTypes.h"
Dale Johannesen06a26632010-03-06 00:03:23 +000020
21namespace llvm {
22
23class MDNode;
24class SDNode;
25class Value;
26
27/// SDDbgValue - Holds the information from a dbg_value node through SDISel.
Dale Johannesen06a26632010-03-06 00:03:23 +000028/// We do not use SDValue here to avoid including its header.
29
30class SDDbgValue {
Dale Johannesenbfdf7f32010-03-10 22:13:47 +000031public:
32 enum DbgValueKind {
Dale Johannesene3b85332010-03-10 23:37:24 +000033 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
Dale Johannesenbfdf7f32010-03-10 22:13:47 +000036 };
37private:
38 enum DbgValueKind kind;
39 union {
40 struct {
Dale Johannesene3b85332010-03-10 23:37:24 +000041 SDNode *Node; // valid for expressions
42 unsigned ResNo; // valid for expressions
Dale Johannesenbfdf7f32010-03-10 22:13:47 +000043 } s;
44 Value *Const; // valid for constants
45 unsigned FrameIx; // valid for stack objects
46 } u;
Dale Johannesen06a26632010-03-06 00:03:23 +000047 MDNode *mdPtr;
48 uint64_t Offset;
49 DebugLoc DL;
Dale Johannesenfab4a252010-03-08 05:39:50 +000050 unsigned Order;
Evan Chengbfcb3052010-03-25 01:38:16 +000051 bool Invalid;
Dale Johannesen06a26632010-03-06 00:03:23 +000052public:
53 // Constructor for non-constants.
Dale Johannesenfab4a252010-03-08 05:39:50 +000054 SDDbgValue(MDNode *mdP, SDNode *N, unsigned R, uint64_t off, DebugLoc dl,
Evan Chengbfcb3052010-03-25 01:38:16 +000055 unsigned O) : mdPtr(mdP), Offset(off), DL(dl), Order(O),
56 Invalid(false) {
Dale Johannesene3b85332010-03-10 23:37:24 +000057 kind = SDNODE;
Dale Johannesenbfdf7f32010-03-10 22:13:47 +000058 u.s.Node = N;
59 u.s.ResNo = R;
60 }
Dale Johannesen06a26632010-03-06 00:03:23 +000061
62 // Constructor for constants.
Dale Johannesenfab4a252010-03-08 05:39:50 +000063 SDDbgValue(MDNode *mdP, Value *C, uint64_t off, DebugLoc dl, unsigned O) :
Evan Chengc388ace2010-03-25 05:50:26 +000064 mdPtr(mdP), Offset(off), DL(dl), Order(O), Invalid(false) {
Dale Johannesene3b85332010-03-10 23:37:24 +000065 kind = CONST;
Dale Johannesenbfdf7f32010-03-10 22:13:47 +000066 u.Const = C;
67 }
68
69 // Constructor for frame indices.
70 SDDbgValue(MDNode *mdP, unsigned FI, uint64_t off, DebugLoc dl, unsigned O) :
Evan Chengc388ace2010-03-25 05:50:26 +000071 mdPtr(mdP), Offset(off), DL(dl), Order(O), Invalid(false) {
Dale Johannesene3b85332010-03-10 23:37:24 +000072 kind = FRAMEIX;
Dale Johannesenbfdf7f32010-03-10 22:13:47 +000073 u.FrameIx = FI;
74 }
75
76 // Returns the kind.
77 DbgValueKind getKind() { return kind; }
Dale Johannesen06a26632010-03-06 00:03:23 +000078
79 // Returns the MDNode pointer.
80 MDNode *getMDPtr() { return mdPtr; }
81
Dale Johannesenbfdf7f32010-03-10 22:13:47 +000082 // Returns the SDNode* for a register ref
Dale Johannesene3b85332010-03-10 23:37:24 +000083 SDNode *getSDNode() { assert (kind==SDNODE); return u.s.Node; }
Dale Johannesen06a26632010-03-06 00:03:23 +000084
Dale Johannesenbfdf7f32010-03-10 22:13:47 +000085 // Returns the ResNo for a register ref
Dale Johannesene3b85332010-03-10 23:37:24 +000086 unsigned getResNo() { assert (kind==SDNODE); return u.s.ResNo; }
Dale Johannesen06a26632010-03-06 00:03:23 +000087
Dale Johannesenbfdf7f32010-03-10 22:13:47 +000088 // Returns the Value* for a constant
Dale Johannesene3b85332010-03-10 23:37:24 +000089 Value *getConst() { assert (kind==CONST); return u.Const; }
Dale Johannesenbfdf7f32010-03-10 22:13:47 +000090
91 // Returns the FrameIx for a stack object
Dale Johannesene3b85332010-03-10 23:37:24 +000092 unsigned getFrameIx() { assert (kind==FRAMEIX); return u.FrameIx; }
Dale Johannesen06a26632010-03-06 00:03:23 +000093
94 // Returns the offset.
95 uint64_t getOffset() { return Offset; }
96
97 // Returns the DebugLoc.
98 DebugLoc getDebugLoc() { return DL; }
Dale Johannesenfab4a252010-03-08 05:39:50 +000099
100 // Returns the SDNodeOrder. This is the order of the preceding node in the
101 // input.
102 unsigned getOrder() { return Order; }
Evan Chengbfcb3052010-03-25 01:38:16 +0000103
104 // setIsInvalidated / isInvalidated - Setter / getter of the "Invalidated"
105 // property. A SDDbgValue is invalid if the SDNode that produces the value is
106 // deleted.
107 void setIsInvalidated() { Invalid = true; }
108 bool isInvalidated() { return Invalid; }
Dale Johannesen06a26632010-03-06 00:03:23 +0000109};
110
111} // end llvm namespace
112
113#endif