blob: 307808e357870954b24539ecd8987c75496060e3 [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;
Dale Johannesen10a77ad2010-03-06 00:03:23 +000047 MDNode *mdPtr;
Adrian Prantl32da8892014-04-25 20:49:25 +000048 bool IsIndirect;
Dale Johannesen10a77ad2010-03-06 00:03:23 +000049 uint64_t Offset;
50 DebugLoc DL;
Dale Johannesen30488c62010-03-08 05:39:50 +000051 unsigned Order;
Evan Cheng563fe3c2010-03-25 01:38:16 +000052 bool Invalid;
Dale Johannesen10a77ad2010-03-06 00:03:23 +000053public:
54 // Constructor for non-constants.
Adrian Prantl32da8892014-04-25 20:49:25 +000055 SDDbgValue(MDNode *mdP, SDNode *N, unsigned R,
56 bool indir, uint64_t off, DebugLoc dl,
57 unsigned O) : mdPtr(mdP), IsIndirect(indir),
58 Offset(off), DL(dl), Order(O),
Evan Cheng563fe3c2010-03-25 01:38:16 +000059 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.
Dan Gohmanbcaf6812010-04-15 01:51:59 +000066 SDDbgValue(MDNode *mdP, const Value *C, uint64_t off, DebugLoc dl,
67 unsigned O) :
Adrian Prantl32da8892014-04-25 20:49:25 +000068 mdPtr(mdP), 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.
75 SDDbgValue(MDNode *mdP, unsigned FI, uint64_t off, DebugLoc dl, unsigned O) :
Adrian Prantl32da8892014-04-25 20:49:25 +000076 mdPtr(mdP), IsIndirect(false), Offset(off), DL(dl), Order(O),
77 Invalid(false) {
Dale Johannesen29108f02010-03-10 23:37:24 +000078 kind = FRAMEIX;
Dale Johannesen49de0602010-03-10 22:13:47 +000079 u.FrameIx = FI;
80 }
81
82 // Returns the kind.
83 DbgValueKind getKind() { return kind; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +000084
85 // Returns the MDNode pointer.
86 MDNode *getMDPtr() { return mdPtr; }
87
Dale Johannesen49de0602010-03-10 22:13:47 +000088 // Returns the SDNode* for a register ref
Dale Johannesen29108f02010-03-10 23:37:24 +000089 SDNode *getSDNode() { assert (kind==SDNODE); return u.s.Node; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +000090
Dale Johannesen49de0602010-03-10 22:13:47 +000091 // Returns the ResNo for a register ref
Dale Johannesen29108f02010-03-10 23:37:24 +000092 unsigned getResNo() { assert (kind==SDNODE); return u.s.ResNo; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +000093
Dale Johannesen49de0602010-03-10 22:13:47 +000094 // Returns the Value* for a constant
Dan Gohmanbcaf6812010-04-15 01:51:59 +000095 const Value *getConst() { assert (kind==CONST); return u.Const; }
Dale Johannesen49de0602010-03-10 22:13:47 +000096
97 // Returns the FrameIx for a stack object
Dale Johannesen29108f02010-03-10 23:37:24 +000098 unsigned getFrameIx() { assert (kind==FRAMEIX); return u.FrameIx; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +000099
Adrian Prantl32da8892014-04-25 20:49:25 +0000100 // Returns whether this is an indirect value.
101 bool isIndirect() { return IsIndirect; }
102
Dale Johannesen10a77ad2010-03-06 00:03:23 +0000103 // Returns the offset.
104 uint64_t getOffset() { return Offset; }
105
106 // Returns the DebugLoc.
107 DebugLoc getDebugLoc() { return DL; }
Dale Johannesen30488c62010-03-08 05:39:50 +0000108
109 // Returns the SDNodeOrder. This is the order of the preceding node in the
110 // input.
111 unsigned getOrder() { return Order; }
Evan Cheng563fe3c2010-03-25 01:38:16 +0000112
113 // setIsInvalidated / isInvalidated - Setter / getter of the "Invalidated"
114 // property. A SDDbgValue is invalid if the SDNode that produces the value is
115 // deleted.
116 void setIsInvalidated() { Invalid = true; }
117 bool isInvalidated() { return Invalid; }
Dale Johannesen10a77ad2010-03-06 00:03:23 +0000118};
119
120} // end llvm namespace
121
122#endif