Dale Johannesen | 06a2663 | 2010-03-06 00:03:23 +0000 | [diff] [blame] | 1 | //===-- 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 | |
| 20 | namespace llvm { |
| 21 | |
| 22 | class MDNode; |
| 23 | class SDNode; |
| 24 | class Value; |
| 25 | |
| 26 | /// SDDbgValue - Holds the information from a dbg_value node through SDISel. |
| 27 | /// Either Const or Node is nonzero, but not both. |
| 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 { |
| 33 | SD = 0, |
| 34 | CNST = 1, |
| 35 | FX = 2 |
| 36 | }; |
| 37 | private: |
| 38 | enum DbgValueKind kind; |
| 39 | union { |
| 40 | struct { |
| 41 | SDNode *Node; // valid for non-constants |
| 42 | unsigned ResNo; // valid for non-constants |
| 43 | } s; |
| 44 | Value *Const; // valid for constants |
| 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; |
Dale Johannesen | 06a2663 | 2010-03-06 00:03:23 +0000 | [diff] [blame] | 51 | public: |
| 52 | // Constructor for non-constants. |
Dale Johannesen | fab4a25 | 2010-03-08 05:39:50 +0000 | [diff] [blame] | 53 | SDDbgValue(MDNode *mdP, SDNode *N, unsigned R, uint64_t off, DebugLoc dl, |
Dale Johannesen | bfdf7f3 | 2010-03-10 22:13:47 +0000 | [diff] [blame^] | 54 | unsigned O) : mdPtr(mdP), Offset(off), DL(dl), Order(O) { |
| 55 | kind = SD; |
| 56 | u.s.Node = N; |
| 57 | u.s.ResNo = R; |
| 58 | } |
Dale Johannesen | 06a2663 | 2010-03-06 00:03:23 +0000 | [diff] [blame] | 59 | |
| 60 | // Constructor for constants. |
Dale Johannesen | fab4a25 | 2010-03-08 05:39:50 +0000 | [diff] [blame] | 61 | SDDbgValue(MDNode *mdP, Value *C, uint64_t off, DebugLoc dl, unsigned O) : |
Dale Johannesen | bfdf7f3 | 2010-03-10 22:13:47 +0000 | [diff] [blame^] | 62 | mdPtr(mdP), Offset(off), DL(dl), Order(O) { |
| 63 | kind = CNST; |
| 64 | u.Const = C; |
| 65 | } |
| 66 | |
| 67 | // Constructor for frame indices. |
| 68 | SDDbgValue(MDNode *mdP, unsigned FI, uint64_t off, DebugLoc dl, unsigned O) : |
| 69 | mdPtr(mdP), Offset(off), DL(dl), Order(O) { |
| 70 | kind = FX; |
| 71 | u.FrameIx = FI; |
| 72 | } |
| 73 | |
| 74 | // Returns the kind. |
| 75 | DbgValueKind getKind() { return kind; } |
Dale Johannesen | 06a2663 | 2010-03-06 00:03:23 +0000 | [diff] [blame] | 76 | |
| 77 | // Returns the MDNode pointer. |
| 78 | MDNode *getMDPtr() { return mdPtr; } |
| 79 | |
Dale Johannesen | bfdf7f3 | 2010-03-10 22:13:47 +0000 | [diff] [blame^] | 80 | // Returns the SDNode* for a register ref |
| 81 | SDNode *getSDNode() { assert (kind==SD); return u.s.Node; } |
Dale Johannesen | 06a2663 | 2010-03-06 00:03:23 +0000 | [diff] [blame] | 82 | |
Dale Johannesen | bfdf7f3 | 2010-03-10 22:13:47 +0000 | [diff] [blame^] | 83 | // Returns the ResNo for a register ref |
| 84 | unsigned getResNo() { assert (kind==SD); return u.s.ResNo; } |
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 Value* for a constant |
| 87 | Value *getConst() { assert (kind==CNST); return u.Const; } |
| 88 | |
| 89 | // Returns the FrameIx for a stack object |
| 90 | unsigned getFrameIx() { assert (kind==FX); return u.FrameIx; } |
Dale Johannesen | 06a2663 | 2010-03-06 00:03:23 +0000 | [diff] [blame] | 91 | |
| 92 | // Returns the offset. |
| 93 | uint64_t getOffset() { return Offset; } |
| 94 | |
| 95 | // Returns the DebugLoc. |
| 96 | DebugLoc getDebugLoc() { return DL; } |
Dale Johannesen | fab4a25 | 2010-03-08 05:39:50 +0000 | [diff] [blame] | 97 | |
| 98 | // Returns the SDNodeOrder. This is the order of the preceding node in the |
| 99 | // input. |
| 100 | unsigned getOrder() { return Order; } |
Dale Johannesen | 06a2663 | 2010-03-06 00:03:23 +0000 | [diff] [blame] | 101 | }; |
| 102 | |
| 103 | } // end llvm namespace |
| 104 | |
| 105 | #endif |