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. |
Dale Johannesen | 06a2663 | 2010-03-06 00:03:23 +0000 | [diff] [blame] | 27 | /// We do not use SDValue here to avoid including its header. |
| 28 | |
| 29 | class SDDbgValue { |
Dale Johannesen | bfdf7f3 | 2010-03-10 22:13:47 +0000 | [diff] [blame] | 30 | public: |
| 31 | enum DbgValueKind { |
Dale Johannesen | e3b8533 | 2010-03-10 23:37:24 +0000 | [diff] [blame^] | 32 | 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 Johannesen | bfdf7f3 | 2010-03-10 22:13:47 +0000 | [diff] [blame] | 35 | }; |
| 36 | private: |
| 37 | enum DbgValueKind kind; |
| 38 | union { |
| 39 | struct { |
Dale Johannesen | e3b8533 | 2010-03-10 23:37:24 +0000 | [diff] [blame^] | 40 | SDNode *Node; // valid for expressions |
| 41 | unsigned ResNo; // valid for expressions |
Dale Johannesen | bfdf7f3 | 2010-03-10 22:13:47 +0000 | [diff] [blame] | 42 | } s; |
| 43 | Value *Const; // valid for constants |
| 44 | unsigned FrameIx; // valid for stack objects |
| 45 | } u; |
Dale Johannesen | 06a2663 | 2010-03-06 00:03:23 +0000 | [diff] [blame] | 46 | MDNode *mdPtr; |
| 47 | uint64_t Offset; |
| 48 | DebugLoc DL; |
Dale Johannesen | fab4a25 | 2010-03-08 05:39:50 +0000 | [diff] [blame] | 49 | unsigned Order; |
Dale Johannesen | 06a2663 | 2010-03-06 00:03:23 +0000 | [diff] [blame] | 50 | public: |
| 51 | // Constructor for non-constants. |
Dale Johannesen | fab4a25 | 2010-03-08 05:39:50 +0000 | [diff] [blame] | 52 | SDDbgValue(MDNode *mdP, SDNode *N, unsigned R, uint64_t off, DebugLoc dl, |
Dale Johannesen | bfdf7f3 | 2010-03-10 22:13:47 +0000 | [diff] [blame] | 53 | unsigned O) : mdPtr(mdP), Offset(off), DL(dl), Order(O) { |
Dale Johannesen | e3b8533 | 2010-03-10 23:37:24 +0000 | [diff] [blame^] | 54 | kind = SDNODE; |
Dale Johannesen | bfdf7f3 | 2010-03-10 22:13:47 +0000 | [diff] [blame] | 55 | u.s.Node = N; |
| 56 | u.s.ResNo = R; |
| 57 | } |
Dale Johannesen | 06a2663 | 2010-03-06 00:03:23 +0000 | [diff] [blame] | 58 | |
| 59 | // Constructor for constants. |
Dale Johannesen | fab4a25 | 2010-03-08 05:39:50 +0000 | [diff] [blame] | 60 | SDDbgValue(MDNode *mdP, Value *C, uint64_t off, DebugLoc dl, unsigned O) : |
Dale Johannesen | bfdf7f3 | 2010-03-10 22:13:47 +0000 | [diff] [blame] | 61 | mdPtr(mdP), Offset(off), DL(dl), Order(O) { |
Dale Johannesen | e3b8533 | 2010-03-10 23:37:24 +0000 | [diff] [blame^] | 62 | kind = CONST; |
Dale Johannesen | bfdf7f3 | 2010-03-10 22:13:47 +0000 | [diff] [blame] | 63 | 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 Johannesen | e3b8533 | 2010-03-10 23:37:24 +0000 | [diff] [blame^] | 69 | kind = FRAMEIX; |
Dale Johannesen | bfdf7f3 | 2010-03-10 22:13:47 +0000 | [diff] [blame] | 70 | u.FrameIx = FI; |
| 71 | } |
| 72 | |
| 73 | // Returns the kind. |
| 74 | DbgValueKind getKind() { return kind; } |
Dale Johannesen | 06a2663 | 2010-03-06 00:03:23 +0000 | [diff] [blame] | 75 | |
| 76 | // Returns the MDNode pointer. |
| 77 | MDNode *getMDPtr() { return mdPtr; } |
| 78 | |
Dale Johannesen | bfdf7f3 | 2010-03-10 22:13:47 +0000 | [diff] [blame] | 79 | // Returns the SDNode* for a register ref |
Dale Johannesen | e3b8533 | 2010-03-10 23:37:24 +0000 | [diff] [blame^] | 80 | SDNode *getSDNode() { assert (kind==SDNODE); return u.s.Node; } |
Dale Johannesen | 06a2663 | 2010-03-06 00:03:23 +0000 | [diff] [blame] | 81 | |
Dale Johannesen | bfdf7f3 | 2010-03-10 22:13:47 +0000 | [diff] [blame] | 82 | // Returns the ResNo for a register ref |
Dale Johannesen | e3b8533 | 2010-03-10 23:37:24 +0000 | [diff] [blame^] | 83 | unsigned getResNo() { assert (kind==SDNODE); return u.s.ResNo; } |
Dale Johannesen | 06a2663 | 2010-03-06 00:03:23 +0000 | [diff] [blame] | 84 | |
Dale Johannesen | bfdf7f3 | 2010-03-10 22:13:47 +0000 | [diff] [blame] | 85 | // Returns the Value* for a constant |
Dale Johannesen | e3b8533 | 2010-03-10 23:37:24 +0000 | [diff] [blame^] | 86 | Value *getConst() { assert (kind==CONST); return u.Const; } |
Dale Johannesen | bfdf7f3 | 2010-03-10 22:13:47 +0000 | [diff] [blame] | 87 | |
| 88 | // Returns the FrameIx for a stack object |
Dale Johannesen | e3b8533 | 2010-03-10 23:37:24 +0000 | [diff] [blame^] | 89 | unsigned getFrameIx() { assert (kind==FRAMEIX); return u.FrameIx; } |
Dale Johannesen | 06a2663 | 2010-03-06 00:03:23 +0000 | [diff] [blame] | 90 | |
| 91 | // Returns the offset. |
| 92 | uint64_t getOffset() { return Offset; } |
| 93 | |
| 94 | // Returns the DebugLoc. |
| 95 | DebugLoc getDebugLoc() { return DL; } |
Dale Johannesen | fab4a25 | 2010-03-08 05:39:50 +0000 | [diff] [blame] | 96 | |
| 97 | // Returns the SDNodeOrder. This is the order of the preceding node in the |
| 98 | // input. |
| 99 | unsigned getOrder() { return Order; } |
Dale Johannesen | 06a2663 | 2010-03-06 00:03:23 +0000 | [diff] [blame] | 100 | }; |
| 101 | |
| 102 | } // end llvm namespace |
| 103 | |
| 104 | #endif |