blob: c27f8de601f24a7fc0ecea07a28fcd9b8113e43d [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:
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)
Duncan P. N. Exon Smith1f0c1c42015-05-22 05:35:53 +000059 : Var(Var), Expr(Expr), Offset(off), DL(dl), Order(O), IsIndirect(indir) {
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)
Duncan P. N. Exon Smith1f0c1c42015-05-22 05:35:53 +000068 : Var(Var), Expr(Expr), Offset(off), DL(dl), Order(O), IsIndirect(false) {
Dale Johannesen29108f02010-03-10 23:37:24 +000069 kind = CONST;
Dale Johannesen49de0602010-03-10 22:13:47 +000070 u.Const = C;
71 }
72
73 // Constructor for frame indices.
Adrian Prantl87b7eb92014-10-01 18:55:02 +000074 SDDbgValue(MDNode *Var, MDNode *Expr, unsigned FI, uint64_t off, DebugLoc dl,
75 unsigned O)
Duncan P. N. Exon Smith1f0c1c42015-05-22 05:35:53 +000076 : Var(Var), Expr(Expr), Offset(off), DL(dl), Order(O), IsIndirect(false) {
Dale Johannesen29108f02010-03-10 23:37:24 +000077 kind = FRAMEIX;
Dale Johannesen49de0602010-03-10 22:13:47 +000078 u.FrameIx = FI;
79 }
80
81 // Returns the kind.
Adrian Prantl13c58822014-10-13 20:43:47 +000082 DbgValueKind getKind() const { return kind; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +000083
Adrian Prantl87b7eb92014-10-01 18:55:02 +000084 // Returns the MDNode pointer for the variable.
Adrian Prantl13c58822014-10-13 20:43:47 +000085 MDNode *getVariable() const { return Var; }
Adrian Prantl87b7eb92014-10-01 18:55:02 +000086
87 // Returns the MDNode pointer for the expression.
Adrian Prantl13c58822014-10-13 20:43:47 +000088 MDNode *getExpression() const { return Expr; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +000089
Dale Johannesen49de0602010-03-10 22:13:47 +000090 // Returns the SDNode* for a register ref
Adrian Prantl13c58822014-10-13 20:43:47 +000091 SDNode *getSDNode() const { assert (kind==SDNODE); return u.s.Node; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +000092
Dale Johannesen49de0602010-03-10 22:13:47 +000093 // Returns the ResNo for a register ref
Adrian Prantl13c58822014-10-13 20:43:47 +000094 unsigned getResNo() const { assert (kind==SDNODE); return u.s.ResNo; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +000095
Dale Johannesen49de0602010-03-10 22:13:47 +000096 // Returns the Value* for a constant
Adrian Prantl13c58822014-10-13 20:43:47 +000097 const Value *getConst() const { assert (kind==CONST); return u.Const; }
Dale Johannesen49de0602010-03-10 22:13:47 +000098
99 // Returns the FrameIx for a stack object
Adrian Prantl13c58822014-10-13 20:43:47 +0000100 unsigned getFrameIx() const { assert (kind==FRAMEIX); return u.FrameIx; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +0000101
Adrian Prantl32da8892014-04-25 20:49:25 +0000102 // Returns whether this is an indirect value.
Adrian Prantl13c58822014-10-13 20:43:47 +0000103 bool isIndirect() const { return IsIndirect; }
Adrian Prantl32da8892014-04-25 20:49:25 +0000104
Dale Johannesen10a77ad2010-03-06 00:03:23 +0000105 // Returns the offset.
Adrian Prantl13c58822014-10-13 20:43:47 +0000106 uint64_t getOffset() const { return Offset; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +0000107
108 // Returns the DebugLoc.
Adrian Prantl13c58822014-10-13 20:43:47 +0000109 DebugLoc getDebugLoc() const { return DL; }
Dale Johannesen30488c62010-03-08 05:39:50 +0000110
111 // Returns the SDNodeOrder. This is the order of the preceding node in the
112 // input.
Adrian Prantl13c58822014-10-13 20:43:47 +0000113 unsigned getOrder() const { return Order; }
Evan Cheng563fe3c2010-03-25 01:38:16 +0000114
115 // setIsInvalidated / isInvalidated - Setter / getter of the "Invalidated"
116 // property. A SDDbgValue is invalid if the SDNode that produces the value is
117 // deleted.
118 void setIsInvalidated() { Invalid = true; }
Adrian Prantl13c58822014-10-13 20:43:47 +0000119 bool isInvalidated() const { return Invalid; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +0000120};
121
Alexander Kornienkof00654e2015-06-23 09:49:53 +0000122} // end llvm namespace
Dale Johannesen10a77ad2010-03-06 00:03:23 +0000123
124#endif