blob: bce69d79ab12b2dff5b8bd2d43af58db53d81425 [file] [log] [blame]
Evan Cheng00fd0b62010-03-14 19:56:39 +00001//===-- llvm/CodeGen/SDNodeDbgValue.h - SelectionDAG dbg_value --*- C++ -*-===//
Dale Johannesen10a77ad2010-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
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000014#ifndef LLVM_LIB_CODEGEN_SELECTIONDAG_SDNODEDBGVALUE_H
15#define LLVM_LIB_CODEGEN_SELECTIONDAG_SDNODEDBGVALUE_H
Dale Johannesen10a77ad2010-03-06 00:03:23 +000016
17#include "llvm/ADT/SmallVector.h"
Chandler Carruth92051402014-03-05 10:30:38 +000018#include "llvm/IR/DebugLoc.h"
Michael J. Spencer447762d2010-11-29 18:16:10 +000019#include "llvm/Support/DataTypes.h"
Dale Johannesen10a77ad2010-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 Johannesen10a77ad2010-03-06 00:03:23 +000028/// We do not use SDValue here to avoid including its header.
29
Benjamin Kramer079b96e2013-09-11 18:05:11 +000030class SDDbgValue {
Dale Johannesen49de0602010-03-10 22:13:47 +000031public:
32 enum DbgValueKind {
Dale Johannesen29108f02010-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 Johannesen49de0602010-03-10 22:13:47 +000036 };
37private:
38 enum DbgValueKind kind;
39 union {
40 struct {
Dale Johannesen29108f02010-03-10 23:37:24 +000041 SDNode *Node; // valid for expressions
42 unsigned ResNo; // valid for expressions
Dale Johannesen49de0602010-03-10 22:13:47 +000043 } s;
Dan Gohmanbcaf6812010-04-15 01:51:59 +000044 const Value *Const; // valid for constants
Dale Johannesen49de0602010-03-10 22:13:47 +000045 unsigned FrameIx; // valid for stack objects
46 } u;
Adrian Prantl87b7eb92014-10-01 18:55:02 +000047 MDNode *Var;
48 MDNode *Expr;
Adrian Prantl32da8892014-04-25 20:49:25 +000049 bool IsIndirect;
Dale Johannesen10a77ad2010-03-06 00:03:23 +000050 uint64_t Offset;
51 DebugLoc DL;
Dale Johannesen30488c62010-03-08 05:39:50 +000052 unsigned Order;
Evan Cheng563fe3c2010-03-25 01:38:16 +000053 bool Invalid;
Dale Johannesen10a77ad2010-03-06 00:03:23 +000054public:
55 // Constructor for non-constants.
Adrian Prantl87b7eb92014-10-01 18:55:02 +000056 SDDbgValue(MDNode *Var, MDNode *Expr, SDNode *N, unsigned R, bool indir,
57 uint64_t off, DebugLoc dl, unsigned O)
58 : Var(Var), Expr(Expr), IsIndirect(indir), Offset(off), DL(dl), Order(O),
59 Invalid(false) {
Dale Johannesen29108f02010-03-10 23:37:24 +000060 kind = SDNODE;
Dale Johannesen49de0602010-03-10 22:13:47 +000061 u.s.Node = N;
62 u.s.ResNo = R;
63 }
Dale Johannesen10a77ad2010-03-06 00:03:23 +000064
65 // Constructor for constants.
Adrian Prantl87b7eb92014-10-01 18:55:02 +000066 SDDbgValue(MDNode *Var, MDNode *Expr, const Value *C, uint64_t off,
67 DebugLoc dl, unsigned O)
68 : Var(Var), Expr(Expr), IsIndirect(false), Offset(off), DL(dl), Order(O),
69 Invalid(false) {
Dale Johannesen29108f02010-03-10 23:37:24 +000070 kind = CONST;
Dale Johannesen49de0602010-03-10 22:13:47 +000071 u.Const = C;
72 }
73
74 // Constructor for frame indices.
Adrian Prantl87b7eb92014-10-01 18:55:02 +000075 SDDbgValue(MDNode *Var, MDNode *Expr, unsigned FI, uint64_t off, DebugLoc dl,
76 unsigned O)
77 : Var(Var), Expr(Expr), IsIndirect(false), Offset(off), DL(dl), Order(O),
78 Invalid(false) {
Dale Johannesen29108f02010-03-10 23:37:24 +000079 kind = FRAMEIX;
Dale Johannesen49de0602010-03-10 22:13:47 +000080 u.FrameIx = FI;
81 }
82
83 // Returns the kind.
Adrian Prantl13c58822014-10-13 20:43:47 +000084 DbgValueKind getKind() const { return kind; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +000085
Adrian Prantl87b7eb92014-10-01 18:55:02 +000086 // Returns the MDNode pointer for the variable.
Adrian Prantl13c58822014-10-13 20:43:47 +000087 MDNode *getVariable() const { return Var; }
Adrian Prantl87b7eb92014-10-01 18:55:02 +000088
89 // Returns the MDNode pointer for the expression.
Adrian Prantl13c58822014-10-13 20:43:47 +000090 MDNode *getExpression() const { return Expr; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +000091
Dale Johannesen49de0602010-03-10 22:13:47 +000092 // Returns the SDNode* for a register ref
Adrian Prantl13c58822014-10-13 20:43:47 +000093 SDNode *getSDNode() const { assert (kind==SDNODE); return u.s.Node; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +000094
Dale Johannesen49de0602010-03-10 22:13:47 +000095 // Returns the ResNo for a register ref
Adrian Prantl13c58822014-10-13 20:43:47 +000096 unsigned getResNo() const { assert (kind==SDNODE); return u.s.ResNo; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +000097
Dale Johannesen49de0602010-03-10 22:13:47 +000098 // Returns the Value* for a constant
Adrian Prantl13c58822014-10-13 20:43:47 +000099 const Value *getConst() const { assert (kind==CONST); return u.Const; }
Dale Johannesen49de0602010-03-10 22:13:47 +0000100
101 // Returns the FrameIx for a stack object
Adrian Prantl13c58822014-10-13 20:43:47 +0000102 unsigned getFrameIx() const { assert (kind==FRAMEIX); return u.FrameIx; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +0000103
Adrian Prantl32da8892014-04-25 20:49:25 +0000104 // Returns whether this is an indirect value.
Adrian Prantl13c58822014-10-13 20:43:47 +0000105 bool isIndirect() const { return IsIndirect; }
Adrian Prantl32da8892014-04-25 20:49:25 +0000106
Dale Johannesen10a77ad2010-03-06 00:03:23 +0000107 // Returns the offset.
Adrian Prantl13c58822014-10-13 20:43:47 +0000108 uint64_t getOffset() const { return Offset; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +0000109
110 // Returns the DebugLoc.
Adrian Prantl13c58822014-10-13 20:43:47 +0000111 DebugLoc getDebugLoc() const { return DL; }
Dale Johannesen30488c62010-03-08 05:39:50 +0000112
113 // Returns the SDNodeOrder. This is the order of the preceding node in the
114 // input.
Adrian Prantl13c58822014-10-13 20:43:47 +0000115 unsigned getOrder() const { return Order; }
Evan Cheng563fe3c2010-03-25 01:38:16 +0000116
117 // setIsInvalidated / isInvalidated - Setter / getter of the "Invalidated"
118 // property. A SDDbgValue is invalid if the SDNode that produces the value is
119 // deleted.
120 void setIsInvalidated() { Invalid = true; }
Adrian Prantl13c58822014-10-13 20:43:47 +0000121 bool isInvalidated() const { return Invalid; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +0000122};
123
124} // end llvm namespace
125
126#endif