blob: 7638ea2ae162c04276d08be37d5d32bbfdc2bfee [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"
19
20namespace llvm {
21
22class MDNode;
23class SDNode;
24class Value;
25
26/// SDDbgValue - Holds the information from a dbg_value node through SDISel.
Dale Johannesen06a26632010-03-06 00:03:23 +000027/// We do not use SDValue here to avoid including its header.
28
29class SDDbgValue {
Dale Johannesenbfdf7f32010-03-10 22:13:47 +000030public:
31 enum DbgValueKind {
Dale Johannesene3b85332010-03-10 23:37:24 +000032 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
Dale Johannesenbfdf7f32010-03-10 22:13:47 +000035 };
36private:
37 enum DbgValueKind kind;
38 union {
39 struct {
Dale Johannesene3b85332010-03-10 23:37:24 +000040 SDNode *Node; // valid for expressions
41 unsigned ResNo; // valid for expressions
Dale Johannesenbfdf7f32010-03-10 22:13:47 +000042 } s;
43 Value *Const; // valid for constants
44 unsigned FrameIx; // valid for stack objects
45 } u;
Dale Johannesen06a26632010-03-06 00:03:23 +000046 MDNode *mdPtr;
47 uint64_t Offset;
48 DebugLoc DL;
Dale Johannesenfab4a252010-03-08 05:39:50 +000049 unsigned Order;
Evan Chengbfcb3052010-03-25 01:38:16 +000050 bool Invalid;
Dale Johannesen06a26632010-03-06 00:03:23 +000051public:
52 // Constructor for non-constants.
Dale Johannesenfab4a252010-03-08 05:39:50 +000053 SDDbgValue(MDNode *mdP, SDNode *N, unsigned R, uint64_t off, DebugLoc dl,
Evan Chengbfcb3052010-03-25 01:38:16 +000054 unsigned O) : mdPtr(mdP), Offset(off), DL(dl), Order(O),
55 Invalid(false) {
Dale Johannesene3b85332010-03-10 23:37:24 +000056 kind = SDNODE;
Dale Johannesenbfdf7f32010-03-10 22:13:47 +000057 u.s.Node = N;
58 u.s.ResNo = R;
59 }
Dale Johannesen06a26632010-03-06 00:03:23 +000060
61 // Constructor for constants.
Dale Johannesenfab4a252010-03-08 05:39:50 +000062 SDDbgValue(MDNode *mdP, Value *C, uint64_t off, DebugLoc dl, unsigned O) :
Evan Chengc388ace2010-03-25 05:50:26 +000063 mdPtr(mdP), Offset(off), DL(dl), Order(O), Invalid(false) {
Dale Johannesene3b85332010-03-10 23:37:24 +000064 kind = CONST;
Dale Johannesenbfdf7f32010-03-10 22:13:47 +000065 u.Const = C;
66 }
67
68 // Constructor for frame indices.
69 SDDbgValue(MDNode *mdP, unsigned FI, uint64_t off, DebugLoc dl, unsigned O) :
Evan Chengc388ace2010-03-25 05:50:26 +000070 mdPtr(mdP), Offset(off), DL(dl), Order(O), Invalid(false) {
Dale Johannesene3b85332010-03-10 23:37:24 +000071 kind = FRAMEIX;
Dale Johannesenbfdf7f32010-03-10 22:13:47 +000072 u.FrameIx = FI;
73 }
74
75 // Returns the kind.
76 DbgValueKind getKind() { return kind; }
Dale Johannesen06a26632010-03-06 00:03:23 +000077
78 // Returns the MDNode pointer.
79 MDNode *getMDPtr() { return mdPtr; }
80
Dale Johannesenbfdf7f32010-03-10 22:13:47 +000081 // Returns the SDNode* for a register ref
Dale Johannesene3b85332010-03-10 23:37:24 +000082 SDNode *getSDNode() { assert (kind==SDNODE); return u.s.Node; }
Dale Johannesen06a26632010-03-06 00:03:23 +000083
Dale Johannesenbfdf7f32010-03-10 22:13:47 +000084 // Returns the ResNo for a register ref
Dale Johannesene3b85332010-03-10 23:37:24 +000085 unsigned getResNo() { assert (kind==SDNODE); return u.s.ResNo; }
Dale Johannesen06a26632010-03-06 00:03:23 +000086
Dale Johannesenbfdf7f32010-03-10 22:13:47 +000087 // Returns the Value* for a constant
Dale Johannesene3b85332010-03-10 23:37:24 +000088 Value *getConst() { assert (kind==CONST); return u.Const; }
Dale Johannesenbfdf7f32010-03-10 22:13:47 +000089
90 // Returns the FrameIx for a stack object
Dale Johannesene3b85332010-03-10 23:37:24 +000091 unsigned getFrameIx() { assert (kind==FRAMEIX); return u.FrameIx; }
Dale Johannesen06a26632010-03-06 00:03:23 +000092
93 // Returns the offset.
94 uint64_t getOffset() { return Offset; }
95
96 // Returns the DebugLoc.
97 DebugLoc getDebugLoc() { return DL; }
Dale Johannesenfab4a252010-03-08 05:39:50 +000098
99 // Returns the SDNodeOrder. This is the order of the preceding node in the
100 // input.
101 unsigned getOrder() { return Order; }
Evan Chengbfcb3052010-03-25 01:38:16 +0000102
103 // setIsInvalidated / isInvalidated - Setter / getter of the "Invalidated"
104 // property. A SDDbgValue is invalid if the SDNode that produces the value is
105 // deleted.
106 void setIsInvalidated() { Invalid = true; }
107 bool isInvalidated() { return Invalid; }
Dale Johannesen06a26632010-03-06 00:03:23 +0000108};
109
110} // end llvm namespace
111
112#endif