blob: 6cccfc01534197c3837a99236b0fb0ac3b670bd2 [file] [log] [blame]
Dale Johannesen06a26632010-03-06 00:03:23 +00001//===-- llvm/CodeGen/SDDbgValue.h - SD dbg_value handling--------*- C++ -*-===//
2//
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
14#ifndef LLVM_CODEGEN_SDDBGVALUE_H
15#define LLVM_CODEGEN_SDDBGVALUE_H
16
17#include "llvm/ADT/SmallVector.h"
18#include "llvm/Support/DebugLoc.h"
19
20namespace llvm {
21
22class MDNode;
23class SDNode;
24class Value;
25
26/// SDDbgValue - Holds the information from a dbg_value node through SDISel.
Dale Johannesen06a26632010-03-06 00:03:23 +000027/// We do not use SDValue here to avoid including its header.
28
29class SDDbgValue {
Dale Johannesenbfdf7f32010-03-10 22:13:47 +000030public:
31 enum DbgValueKind {
Dale Johannesene3b85332010-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 Johannesenbfdf7f32010-03-10 22:13:47 +000035 };
36private:
37 enum DbgValueKind kind;
38 union {
39 struct {
Dale Johannesene3b85332010-03-10 23:37:24 +000040 SDNode *Node; // valid for expressions
41 unsigned ResNo; // valid for expressions
Dale Johannesenbfdf7f32010-03-10 22:13:47 +000042 } s;
43 Value *Const; // valid for constants
44 unsigned FrameIx; // valid for stack objects
45 } u;
Dale Johannesen06a26632010-03-06 00:03:23 +000046 MDNode *mdPtr;
47 uint64_t Offset;
48 DebugLoc DL;
Dale Johannesenfab4a252010-03-08 05:39:50 +000049 unsigned Order;
Dale Johannesen06a26632010-03-06 00:03:23 +000050public:
51 // Constructor for non-constants.
Dale Johannesenfab4a252010-03-08 05:39:50 +000052 SDDbgValue(MDNode *mdP, SDNode *N, unsigned R, uint64_t off, DebugLoc dl,
Dale Johannesenbfdf7f32010-03-10 22:13:47 +000053 unsigned O) : mdPtr(mdP), Offset(off), DL(dl), Order(O) {
Dale Johannesene3b85332010-03-10 23:37:24 +000054 kind = SDNODE;
Dale Johannesenbfdf7f32010-03-10 22:13:47 +000055 u.s.Node = N;
56 u.s.ResNo = R;
57 }
Dale Johannesen06a26632010-03-06 00:03:23 +000058
59 // Constructor for constants.
Dale Johannesenfab4a252010-03-08 05:39:50 +000060 SDDbgValue(MDNode *mdP, Value *C, uint64_t off, DebugLoc dl, unsigned O) :
Dale Johannesenbfdf7f32010-03-10 22:13:47 +000061 mdPtr(mdP), Offset(off), DL(dl), Order(O) {
Dale Johannesene3b85332010-03-10 23:37:24 +000062 kind = CONST;
Dale Johannesenbfdf7f32010-03-10 22:13:47 +000063 u.Const = C;
64 }
65
66 // Constructor for frame indices.
67 SDDbgValue(MDNode *mdP, unsigned FI, uint64_t off, DebugLoc dl, unsigned O) :
68 mdPtr(mdP), Offset(off), DL(dl), Order(O) {
Dale Johannesene3b85332010-03-10 23:37:24 +000069 kind = FRAMEIX;
Dale Johannesenbfdf7f32010-03-10 22:13:47 +000070 u.FrameIx = FI;
71 }
72
73 // Returns the kind.
74 DbgValueKind getKind() { return kind; }
Dale Johannesen06a26632010-03-06 00:03:23 +000075
76 // Returns the MDNode pointer.
77 MDNode *getMDPtr() { return mdPtr; }
78
Dale Johannesenbfdf7f32010-03-10 22:13:47 +000079 // Returns the SDNode* for a register ref
Dale Johannesene3b85332010-03-10 23:37:24 +000080 SDNode *getSDNode() { assert (kind==SDNODE); return u.s.Node; }
Dale Johannesen06a26632010-03-06 00:03:23 +000081
Dale Johannesenbfdf7f32010-03-10 22:13:47 +000082 // Returns the ResNo for a register ref
Dale Johannesene3b85332010-03-10 23:37:24 +000083 unsigned getResNo() { assert (kind==SDNODE); return u.s.ResNo; }
Dale Johannesen06a26632010-03-06 00:03:23 +000084
Dale Johannesenbfdf7f32010-03-10 22:13:47 +000085 // Returns the Value* for a constant
Dale Johannesene3b85332010-03-10 23:37:24 +000086 Value *getConst() { assert (kind==CONST); return u.Const; }
Dale Johannesenbfdf7f32010-03-10 22:13:47 +000087
88 // Returns the FrameIx for a stack object
Dale Johannesene3b85332010-03-10 23:37:24 +000089 unsigned getFrameIx() { assert (kind==FRAMEIX); return u.FrameIx; }
Dale Johannesen06a26632010-03-06 00:03:23 +000090
91 // Returns the offset.
92 uint64_t getOffset() { return Offset; }
93
94 // Returns the DebugLoc.
95 DebugLoc getDebugLoc() { return DL; }
Dale Johannesenfab4a252010-03-08 05:39:50 +000096
97 // Returns the SDNodeOrder. This is the order of the preceding node in the
98 // input.
99 unsigned getOrder() { return Order; }
Dale Johannesen06a26632010-03-06 00:03:23 +0000100};
101
102} // end llvm namespace
103
104#endif