Progress towards shepherding debug info through SelectionDAG.
[oota-llvm.git] / lib / CodeGen / SelectionDAG / SDDbgValue.h
index d43a0447a6cf98e9ce63b7f360e0cca72e522cd4..1b7ba18afeacc04e1901a41449878c5b52addd6f 100644 (file)
@@ -28,9 +28,22 @@ class Value;
 /// We do not use SDValue here to avoid including its header.
 
 class SDDbgValue {
-  SDNode *Node;           // valid for non-constants
-  unsigned ResNo;         // valid for non-constants
-  Value *Const;           // valid for constants
+public:
+  enum DbgValueKind {
+    SD = 0,
+    CNST = 1,
+    FX = 2
+  };
+private:
+  enum DbgValueKind kind;
+  union {
+    struct {
+      SDNode *Node;         // valid for non-constants
+      unsigned ResNo;       // valid for non-constants
+    } s;
+    Value *Const;           // valid for constants
+    unsigned FrameIx;       // valid for stack objects
+  } u;
   MDNode *mdPtr;
   uint64_t Offset;
   DebugLoc DL;
@@ -38,24 +51,43 @@ class SDDbgValue {
 public:
   // Constructor for non-constants.
   SDDbgValue(MDNode *mdP, SDNode *N, unsigned R, uint64_t off, DebugLoc dl,
-             unsigned O) :
-    Node(N), ResNo(R), Const(0), mdPtr(mdP), Offset(off), DL(dl), Order(O) {}
+             unsigned O) : mdPtr(mdP), Offset(off), DL(dl), Order(O) {
+    kind = SD;
+    u.s.Node = N;
+    u.s.ResNo = R;
+  }
 
   // Constructor for constants.
   SDDbgValue(MDNode *mdP, Value *C, uint64_t off, DebugLoc dl, unsigned O) : 
-    Node(0), ResNo(0), Const(C), mdPtr(mdP), Offset(off), DL(dl), Order(O) {}
+    mdPtr(mdP), Offset(off), DL(dl), Order(O) {
+    kind = CNST;
+    u.Const = C;
+  }
+
+  // Constructor for frame indices.
+  SDDbgValue(MDNode *mdP, unsigned FI, uint64_t off, DebugLoc dl, unsigned O) : 
+    mdPtr(mdP), Offset(off), DL(dl), Order(O) {
+    kind = FX;
+    u.FrameIx = FI;
+  }
+
+  // Returns the kind.
+  DbgValueKind getKind() { return kind; }
 
   // Returns the MDNode pointer.
   MDNode *getMDPtr() { return mdPtr; }
 
-  // Returns the SDNode* (valid for non-constants only).
-  SDNode *getSDNode() { assert (!Const); return Node; }
+  // Returns the SDNode* for a register ref
+  SDNode *getSDNode() { assert (kind==SD); return u.s.Node; }
+
+  // Returns the ResNo for a register ref
+  unsigned getResNo() { assert (kind==SD); return u.s.ResNo; }
 
-  // Returns the ResNo (valid for non-constants only).
-  unsigned getResNo() { assert (!Const); return ResNo; }
+  // Returns the Value* for a constant
+  Value *getConst() { assert (kind==CNST); return u.Const; }
 
-  // Returns the Value* for a constant (invalid for non-constants).
-  Value *getConst() { assert (!Node); return Const; }
+  // Returns the FrameIx for a stack object
+  unsigned getFrameIx() { assert (kind==FX); return u.FrameIx; }
 
   // Returns the offset.
   uint64_t getOffset() { return Offset; }