blob: 237d541b4cb97b72898e4de850b7d96be73cc359 [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"
Benjamin Kramer82de7d32016-05-27 14:27:24 +000019#include <utility>
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:
Dale Johannesen49de0602010-03-10 22:13:47 +000038 union {
39 struct {
Dale Johannesen29108f02010-03-10 23:37:24 +000040 SDNode *Node; // valid for expressions
41 unsigned ResNo; // valid for expressions
Dale Johannesen49de0602010-03-10 22:13:47 +000042 } s;
Dan Gohmanbcaf6812010-04-15 01:51:59 +000043 const Value *Const; // valid for constants
Dale Johannesen49de0602010-03-10 22:13:47 +000044 unsigned FrameIx; // valid for stack objects
45 } u;
Adrian Prantl87b7eb92014-10-01 18:55:02 +000046 MDNode *Var;
47 MDNode *Expr;
Dale Johannesen10a77ad2010-03-06 00:03:23 +000048 uint64_t Offset;
49 DebugLoc DL;
Dale Johannesen30488c62010-03-08 05:39:50 +000050 unsigned Order;
Duncan P. N. Exon Smith1f0c1c42015-05-22 05:35:53 +000051 enum DbgValueKind kind;
52 bool IsIndirect;
53 bool Invalid = false;
54
Dale Johannesen10a77ad2010-03-06 00:03:23 +000055public:
56 // Constructor for non-constants.
Adrian Prantl87b7eb92014-10-01 18:55:02 +000057 SDDbgValue(MDNode *Var, MDNode *Expr, SDNode *N, unsigned R, bool indir,
58 uint64_t off, DebugLoc dl, unsigned O)
Benjamin Kramer82de7d32016-05-27 14:27:24 +000059 : Var(Var), Expr(Expr), Offset(off), DL(std::move(dl)), Order(O),
60 IsIndirect(indir) {
Dale Johannesen29108f02010-03-10 23:37:24 +000061 kind = SDNODE;
Dale Johannesen49de0602010-03-10 22:13:47 +000062 u.s.Node = N;
63 u.s.ResNo = R;
64 }
Dale Johannesen10a77ad2010-03-06 00:03:23 +000065
66 // Constructor for constants.
Adrian Prantl87b7eb92014-10-01 18:55:02 +000067 SDDbgValue(MDNode *Var, MDNode *Expr, const Value *C, uint64_t off,
68 DebugLoc dl, unsigned O)
Benjamin Kramer82de7d32016-05-27 14:27:24 +000069 : Var(Var), Expr(Expr), Offset(off), DL(std::move(dl)), Order(O),
70 IsIndirect(false) {
Dale Johannesen29108f02010-03-10 23:37:24 +000071 kind = CONST;
Dale Johannesen49de0602010-03-10 22:13:47 +000072 u.Const = C;
73 }
74
75 // Constructor for frame indices.
Adrian Prantl87b7eb92014-10-01 18:55:02 +000076 SDDbgValue(MDNode *Var, MDNode *Expr, unsigned FI, uint64_t off, DebugLoc dl,
77 unsigned O)
Benjamin Kramer82de7d32016-05-27 14:27:24 +000078 : Var(Var), Expr(Expr), Offset(off), DL(std::move(dl)), Order(O),
79 IsIndirect(false) {
Dale Johannesen29108f02010-03-10 23:37:24 +000080 kind = FRAMEIX;
Dale Johannesen49de0602010-03-10 22:13:47 +000081 u.FrameIx = FI;
82 }
83
84 // Returns the kind.
Adrian Prantl13c58822014-10-13 20:43:47 +000085 DbgValueKind getKind() const { return kind; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +000086
Adrian Prantl87b7eb92014-10-01 18:55:02 +000087 // Returns the MDNode pointer for the variable.
Adrian Prantl13c58822014-10-13 20:43:47 +000088 MDNode *getVariable() const { return Var; }
Adrian Prantl87b7eb92014-10-01 18:55:02 +000089
90 // Returns the MDNode pointer for the expression.
Adrian Prantl13c58822014-10-13 20:43:47 +000091 MDNode *getExpression() const { return Expr; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +000092
Dale Johannesen49de0602010-03-10 22:13:47 +000093 // Returns the SDNode* for a register ref
Adrian Prantl13c58822014-10-13 20:43:47 +000094 SDNode *getSDNode() const { assert (kind==SDNODE); return u.s.Node; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +000095
Dale Johannesen49de0602010-03-10 22:13:47 +000096 // Returns the ResNo for a register ref
Adrian Prantl13c58822014-10-13 20:43:47 +000097 unsigned getResNo() const { assert (kind==SDNODE); return u.s.ResNo; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +000098
Dale Johannesen49de0602010-03-10 22:13:47 +000099 // Returns the Value* for a constant
Adrian Prantl13c58822014-10-13 20:43:47 +0000100 const Value *getConst() const { assert (kind==CONST); return u.Const; }
Dale Johannesen49de0602010-03-10 22:13:47 +0000101
102 // Returns the FrameIx for a stack object
Adrian Prantl13c58822014-10-13 20:43:47 +0000103 unsigned getFrameIx() const { assert (kind==FRAMEIX); return u.FrameIx; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +0000104
Adrian Prantl32da8892014-04-25 20:49:25 +0000105 // Returns whether this is an indirect value.
Adrian Prantl13c58822014-10-13 20:43:47 +0000106 bool isIndirect() const { return IsIndirect; }
Adrian Prantl32da8892014-04-25 20:49:25 +0000107
Dale Johannesen10a77ad2010-03-06 00:03:23 +0000108 // Returns the offset.
Adrian Prantl13c58822014-10-13 20:43:47 +0000109 uint64_t getOffset() const { return Offset; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +0000110
111 // Returns the DebugLoc.
Adrian Prantl13c58822014-10-13 20:43:47 +0000112 DebugLoc getDebugLoc() const { return DL; }
Dale Johannesen30488c62010-03-08 05:39:50 +0000113
114 // Returns the SDNodeOrder. This is the order of the preceding node in the
115 // input.
Adrian Prantl13c58822014-10-13 20:43:47 +0000116 unsigned getOrder() const { return Order; }
Evan Cheng563fe3c2010-03-25 01:38:16 +0000117
118 // setIsInvalidated / isInvalidated - Setter / getter of the "Invalidated"
119 // property. A SDDbgValue is invalid if the SDNode that produces the value is
120 // deleted.
121 void setIsInvalidated() { Invalid = true; }
Adrian Prantl13c58822014-10-13 20:43:47 +0000122 bool isInvalidated() const { return Invalid; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +0000123};
124
Alexander Kornienkof00654e2015-06-23 09:49:53 +0000125} // end llvm namespace
Dale Johannesen10a77ad2010-03-06 00:03:23 +0000126
127#endif