| Evan Cheng | a8efe28 | 2010-03-14 19:56:39 +0000 | [diff] [blame] | 1 | //===-- llvm/CodeGen/SDNodeDbgValue.h - SelectionDAG dbg_value --*- C++ -*-===// | 
| Dale Johannesen | 06a2663 | 2010-03-06 00:03:23 +0000 | [diff] [blame] | 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 |  | 
| Evan Cheng | a8efe28 | 2010-03-14 19:56:39 +0000 | [diff] [blame] | 14 | #ifndef LLVM_CODEGEN_SDNODEDBGVALUE_H | 
|  | 15 | #define LLVM_CODEGEN_SDNODEDBGVALUE_H | 
| Dale Johannesen | 06a2663 | 2010-03-06 00:03:23 +0000 | [diff] [blame] | 16 |  | 
|  | 17 | #include "llvm/ADT/SmallVector.h" | 
|  | 18 | #include "llvm/Support/DebugLoc.h" | 
| Benjamin Kramer | fd91920 | 2010-04-02 20:47:05 +0000 | [diff] [blame] | 19 | #include "llvm/System/DataTypes.h" | 
| Dale Johannesen | 06a2663 | 2010-03-06 00:03:23 +0000 | [diff] [blame] | 20 |  | 
|  | 21 | namespace llvm { | 
|  | 22 |  | 
|  | 23 | class MDNode; | 
|  | 24 | class SDNode; | 
|  | 25 | class Value; | 
|  | 26 |  | 
|  | 27 | /// SDDbgValue - Holds the information from a dbg_value node through SDISel. | 
| Dale Johannesen | 06a2663 | 2010-03-06 00:03:23 +0000 | [diff] [blame] | 28 | /// We do not use SDValue here to avoid including its header. | 
|  | 29 |  | 
|  | 30 | class SDDbgValue { | 
| Dale Johannesen | bfdf7f3 | 2010-03-10 22:13:47 +0000 | [diff] [blame] | 31 | public: | 
|  | 32 | enum DbgValueKind { | 
| Dale Johannesen | e3b8533 | 2010-03-10 23:37:24 +0000 | [diff] [blame] | 33 | 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 Johannesen | bfdf7f3 | 2010-03-10 22:13:47 +0000 | [diff] [blame] | 36 | }; | 
|  | 37 | private: | 
|  | 38 | enum DbgValueKind kind; | 
|  | 39 | union { | 
|  | 40 | struct { | 
| Dale Johannesen | e3b8533 | 2010-03-10 23:37:24 +0000 | [diff] [blame] | 41 | SDNode *Node;         // valid for expressions | 
|  | 42 | unsigned ResNo;       // valid for expressions | 
| Dale Johannesen | bfdf7f3 | 2010-03-10 22:13:47 +0000 | [diff] [blame] | 43 | } s; | 
| Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame^] | 44 | const Value *Const;     // valid for constants | 
| Dale Johannesen | bfdf7f3 | 2010-03-10 22:13:47 +0000 | [diff] [blame] | 45 | unsigned FrameIx;       // valid for stack objects | 
|  | 46 | } u; | 
| Dale Johannesen | 06a2663 | 2010-03-06 00:03:23 +0000 | [diff] [blame] | 47 | MDNode *mdPtr; | 
|  | 48 | uint64_t Offset; | 
|  | 49 | DebugLoc DL; | 
| Dale Johannesen | fab4a25 | 2010-03-08 05:39:50 +0000 | [diff] [blame] | 50 | unsigned Order; | 
| Evan Cheng | bfcb305 | 2010-03-25 01:38:16 +0000 | [diff] [blame] | 51 | bool Invalid; | 
| Dale Johannesen | 06a2663 | 2010-03-06 00:03:23 +0000 | [diff] [blame] | 52 | public: | 
|  | 53 | // Constructor for non-constants. | 
| Dale Johannesen | fab4a25 | 2010-03-08 05:39:50 +0000 | [diff] [blame] | 54 | SDDbgValue(MDNode *mdP, SDNode *N, unsigned R, uint64_t off, DebugLoc dl, | 
| Evan Cheng | bfcb305 | 2010-03-25 01:38:16 +0000 | [diff] [blame] | 55 | unsigned O) : mdPtr(mdP), Offset(off), DL(dl), Order(O), | 
|  | 56 | Invalid(false) { | 
| Dale Johannesen | e3b8533 | 2010-03-10 23:37:24 +0000 | [diff] [blame] | 57 | kind = SDNODE; | 
| Dale Johannesen | bfdf7f3 | 2010-03-10 22:13:47 +0000 | [diff] [blame] | 58 | u.s.Node = N; | 
|  | 59 | u.s.ResNo = R; | 
|  | 60 | } | 
| Dale Johannesen | 06a2663 | 2010-03-06 00:03:23 +0000 | [diff] [blame] | 61 |  | 
|  | 62 | // Constructor for constants. | 
| Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame^] | 63 | SDDbgValue(MDNode *mdP, const Value *C, uint64_t off, DebugLoc dl, | 
|  | 64 | unsigned O) : | 
| Evan Cheng | c388ace | 2010-03-25 05:50:26 +0000 | [diff] [blame] | 65 | mdPtr(mdP), Offset(off), DL(dl), Order(O), Invalid(false) { | 
| Dale Johannesen | e3b8533 | 2010-03-10 23:37:24 +0000 | [diff] [blame] | 66 | kind = CONST; | 
| Dale Johannesen | bfdf7f3 | 2010-03-10 22:13:47 +0000 | [diff] [blame] | 67 | u.Const = C; | 
|  | 68 | } | 
|  | 69 |  | 
|  | 70 | // Constructor for frame indices. | 
|  | 71 | SDDbgValue(MDNode *mdP, unsigned FI, uint64_t off, DebugLoc dl, unsigned O) : | 
| Evan Cheng | c388ace | 2010-03-25 05:50:26 +0000 | [diff] [blame] | 72 | mdPtr(mdP), Offset(off), DL(dl), Order(O), Invalid(false) { | 
| Dale Johannesen | e3b8533 | 2010-03-10 23:37:24 +0000 | [diff] [blame] | 73 | kind = FRAMEIX; | 
| Dale Johannesen | bfdf7f3 | 2010-03-10 22:13:47 +0000 | [diff] [blame] | 74 | u.FrameIx = FI; | 
|  | 75 | } | 
|  | 76 |  | 
|  | 77 | // Returns the kind. | 
|  | 78 | DbgValueKind getKind() { return kind; } | 
| Dale Johannesen | 06a2663 | 2010-03-06 00:03:23 +0000 | [diff] [blame] | 79 |  | 
|  | 80 | // Returns the MDNode pointer. | 
|  | 81 | MDNode *getMDPtr() { return mdPtr; } | 
|  | 82 |  | 
| Dale Johannesen | bfdf7f3 | 2010-03-10 22:13:47 +0000 | [diff] [blame] | 83 | // Returns the SDNode* for a register ref | 
| Dale Johannesen | e3b8533 | 2010-03-10 23:37:24 +0000 | [diff] [blame] | 84 | SDNode *getSDNode() { assert (kind==SDNODE); return u.s.Node; } | 
| Dale Johannesen | 06a2663 | 2010-03-06 00:03:23 +0000 | [diff] [blame] | 85 |  | 
| Dale Johannesen | bfdf7f3 | 2010-03-10 22:13:47 +0000 | [diff] [blame] | 86 | // Returns the ResNo for a register ref | 
| Dale Johannesen | e3b8533 | 2010-03-10 23:37:24 +0000 | [diff] [blame] | 87 | unsigned getResNo() { assert (kind==SDNODE); return u.s.ResNo; } | 
| Dale Johannesen | 06a2663 | 2010-03-06 00:03:23 +0000 | [diff] [blame] | 88 |  | 
| Dale Johannesen | bfdf7f3 | 2010-03-10 22:13:47 +0000 | [diff] [blame] | 89 | // Returns the Value* for a constant | 
| Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame^] | 90 | const Value *getConst() { assert (kind==CONST); return u.Const; } | 
| Dale Johannesen | bfdf7f3 | 2010-03-10 22:13:47 +0000 | [diff] [blame] | 91 |  | 
|  | 92 | // Returns the FrameIx for a stack object | 
| Dale Johannesen | e3b8533 | 2010-03-10 23:37:24 +0000 | [diff] [blame] | 93 | unsigned getFrameIx() { assert (kind==FRAMEIX); return u.FrameIx; } | 
| Dale Johannesen | 06a2663 | 2010-03-06 00:03:23 +0000 | [diff] [blame] | 94 |  | 
|  | 95 | // Returns the offset. | 
|  | 96 | uint64_t getOffset() { return Offset; } | 
|  | 97 |  | 
|  | 98 | // Returns the DebugLoc. | 
|  | 99 | DebugLoc getDebugLoc() { return DL; } | 
| Dale Johannesen | fab4a25 | 2010-03-08 05:39:50 +0000 | [diff] [blame] | 100 |  | 
|  | 101 | // Returns the SDNodeOrder.  This is the order of the preceding node in the | 
|  | 102 | // input. | 
|  | 103 | unsigned getOrder() { return Order; } | 
| Evan Cheng | bfcb305 | 2010-03-25 01:38:16 +0000 | [diff] [blame] | 104 |  | 
|  | 105 | // setIsInvalidated / isInvalidated - Setter / getter of the "Invalidated" | 
|  | 106 | // property. A SDDbgValue is invalid if the SDNode that produces the value is | 
|  | 107 | // deleted. | 
|  | 108 | void setIsInvalidated() { Invalid = true; } | 
|  | 109 | bool isInvalidated() { return Invalid; } | 
| Dale Johannesen | 06a2663 | 2010-03-06 00:03:23 +0000 | [diff] [blame] | 110 | }; | 
|  | 111 |  | 
|  | 112 | } // end llvm namespace | 
|  | 113 |  | 
|  | 114 | #endif |