blob: d4756f7f416a7bae136e5ca4420f0b3129b9652c [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
Chandler Carruth92051402014-03-05 10:30:38 +000017#include "llvm/IR/DebugLoc.h"
Michael J. Spencer447762d2010-11-29 18:16:10 +000018#include "llvm/Support/DataTypes.h"
Dale Johannesen10a77ad2010-03-06 00:03:23 +000019
20namespace llvm {
21
22class MDNode;
23class SDNode;
24class Value;
25
26/// SDDbgValue - Holds the information from a dbg_value node through SDISel.
Dale Johannesen10a77ad2010-03-06 00:03:23 +000027/// We do not use SDValue here to avoid including its header.
28
Benjamin Kramer079b96e2013-09-11 18:05:11 +000029class SDDbgValue {
Dale Johannesen49de0602010-03-10 22:13:47 +000030public:
31 enum DbgValueKind {
Dale Johannesen29108f02010-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 Johannesen49de0602010-03-10 22:13:47 +000035 };
36private:
Dale Johannesen49de0602010-03-10 22:13:47 +000037 union {
38 struct {
Dale Johannesen29108f02010-03-10 23:37:24 +000039 SDNode *Node; // valid for expressions
40 unsigned ResNo; // valid for expressions
Dale Johannesen49de0602010-03-10 22:13:47 +000041 } s;
Dan Gohmanbcaf6812010-04-15 01:51:59 +000042 const Value *Const; // valid for constants
Dale Johannesen49de0602010-03-10 22:13:47 +000043 unsigned FrameIx; // valid for stack objects
44 } u;
Adrian Prantl87b7eb92014-10-01 18:55:02 +000045 MDNode *Var;
46 MDNode *Expr;
Dale Johannesen10a77ad2010-03-06 00:03:23 +000047 uint64_t Offset;
48 DebugLoc DL;
Dale Johannesen30488c62010-03-08 05:39:50 +000049 unsigned Order;
Duncan P. N. Exon Smith1f0c1c42015-05-22 05:35:53 +000050 enum DbgValueKind kind;
51 bool IsIndirect;
52 bool Invalid = false;
53
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)
Duncan P. N. Exon Smith1f0c1c42015-05-22 05:35:53 +000058 : Var(Var), Expr(Expr), Offset(off), DL(dl), Order(O), IsIndirect(indir) {
Dale Johannesen29108f02010-03-10 23:37:24 +000059 kind = SDNODE;
Dale Johannesen49de0602010-03-10 22:13:47 +000060 u.s.Node = N;
61 u.s.ResNo = R;
62 }
Dale Johannesen10a77ad2010-03-06 00:03:23 +000063
64 // Constructor for constants.
Adrian Prantl87b7eb92014-10-01 18:55:02 +000065 SDDbgValue(MDNode *Var, MDNode *Expr, const Value *C, uint64_t off,
66 DebugLoc dl, unsigned O)
Duncan P. N. Exon Smith1f0c1c42015-05-22 05:35:53 +000067 : Var(Var), Expr(Expr), Offset(off), DL(dl), Order(O), IsIndirect(false) {
Dale Johannesen29108f02010-03-10 23:37:24 +000068 kind = CONST;
Dale Johannesen49de0602010-03-10 22:13:47 +000069 u.Const = C;
70 }
71
72 // Constructor for frame indices.
Adrian Prantl87b7eb92014-10-01 18:55:02 +000073 SDDbgValue(MDNode *Var, MDNode *Expr, unsigned FI, uint64_t off, DebugLoc dl,
74 unsigned O)
Duncan P. N. Exon Smith1f0c1c42015-05-22 05:35:53 +000075 : Var(Var), Expr(Expr), Offset(off), DL(dl), Order(O), IsIndirect(false) {
Dale Johannesen29108f02010-03-10 23:37:24 +000076 kind = FRAMEIX;
Dale Johannesen49de0602010-03-10 22:13:47 +000077 u.FrameIx = FI;
78 }
79
80 // Returns the kind.
Adrian Prantl13c58822014-10-13 20:43:47 +000081 DbgValueKind getKind() const { return kind; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +000082
Adrian Prantl87b7eb92014-10-01 18:55:02 +000083 // Returns the MDNode pointer for the variable.
Adrian Prantl13c58822014-10-13 20:43:47 +000084 MDNode *getVariable() const { return Var; }
Adrian Prantl87b7eb92014-10-01 18:55:02 +000085
86 // Returns the MDNode pointer for the expression.
Adrian Prantl13c58822014-10-13 20:43:47 +000087 MDNode *getExpression() const { return Expr; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +000088
Dale Johannesen49de0602010-03-10 22:13:47 +000089 // Returns the SDNode* for a register ref
Adrian Prantl13c58822014-10-13 20:43:47 +000090 SDNode *getSDNode() const { assert (kind==SDNODE); return u.s.Node; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +000091
Dale Johannesen49de0602010-03-10 22:13:47 +000092 // Returns the ResNo for a register ref
Adrian Prantl13c58822014-10-13 20:43:47 +000093 unsigned getResNo() const { assert (kind==SDNODE); return u.s.ResNo; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +000094
Dale Johannesen49de0602010-03-10 22:13:47 +000095 // Returns the Value* for a constant
Adrian Prantl13c58822014-10-13 20:43:47 +000096 const Value *getConst() const { assert (kind==CONST); return u.Const; }
Dale Johannesen49de0602010-03-10 22:13:47 +000097
98 // Returns the FrameIx for a stack object
Adrian Prantl13c58822014-10-13 20:43:47 +000099 unsigned getFrameIx() const { assert (kind==FRAMEIX); return u.FrameIx; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +0000100
Adrian Prantl32da8892014-04-25 20:49:25 +0000101 // Returns whether this is an indirect value.
Adrian Prantl13c58822014-10-13 20:43:47 +0000102 bool isIndirect() const { return IsIndirect; }
Adrian Prantl32da8892014-04-25 20:49:25 +0000103
Dale Johannesen10a77ad2010-03-06 00:03:23 +0000104 // Returns the offset.
Adrian Prantl13c58822014-10-13 20:43:47 +0000105 uint64_t getOffset() const { return Offset; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +0000106
107 // Returns the DebugLoc.
Adrian Prantl13c58822014-10-13 20:43:47 +0000108 DebugLoc getDebugLoc() const { return DL; }
Dale Johannesen30488c62010-03-08 05:39:50 +0000109
110 // Returns the SDNodeOrder. This is the order of the preceding node in the
111 // input.
Adrian Prantl13c58822014-10-13 20:43:47 +0000112 unsigned getOrder() const { return Order; }
Evan Cheng563fe3c2010-03-25 01:38:16 +0000113
114 // setIsInvalidated / isInvalidated - Setter / getter of the "Invalidated"
115 // property. A SDDbgValue is invalid if the SDNode that produces the value is
116 // deleted.
117 void setIsInvalidated() { Invalid = true; }
Adrian Prantl13c58822014-10-13 20:43:47 +0000118 bool isInvalidated() const { return Invalid; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +0000119};
120
Alexander Kornienkof00654e2015-06-23 09:49:53 +0000121} // end llvm namespace
Dale Johannesen10a77ad2010-03-06 00:03:23 +0000122
123#endif