Add DebugLoc field and simple accessors.
authorDale Johannesen <dalej@apple.com>
Tue, 27 Jan 2009 21:41:04 +0000 (21:41 +0000)
committerDale Johannesen <dalej@apple.com>
Tue, 27 Jan 2009 21:41:04 +0000 (21:41 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63136 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/SelectionDAGNodes.h

index 7a5cd3b43eed39e5295cdd95dd84662ff23bb2c0..f1cd6c08c11bf5ccbb6e780512afc104ab910053 100644 (file)
@@ -30,6 +30,7 @@
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/RecyclingAllocator.h"
 #include "llvm/Support/DataTypes.h"
+#include "llvm/CodeGen/DebugLoc.h"
 #include <cassert>
 
 namespace llvm {
@@ -901,6 +902,7 @@ public:
   inline bool isTargetOpcode() const;
   inline bool isMachineOpcode() const;
   inline unsigned getMachineOpcode() const;
+  inline DebugLoc getDebugLoc() const;
 
   
   /// reachesChainWithoutSideEffects - Return true if this operand (which must
@@ -1077,6 +1079,9 @@ private:
   /// NodeId - Unique id per SDNode in the DAG.
   int NodeId;
 
+  /// debugLoc - source line information.
+  DebugLoc debugLoc;
+
   /// OperandList - The values that are used by this operation.
   ///
   SDUse *OperandList;
@@ -1146,6 +1151,12 @@ public:
   /// setNodeId - Set unique node id.
   void setNodeId(int Id) { NodeId = Id; }
 
+  /// getDebugLoc - Return the source location info.
+  DebugLoc getDebugLoc() const { return debugLoc; }
+
+  /// setDebugLoc - Set source location info.
+  void setDebugLoc(DebugLoc sl) { debugLoc = sl; }
+
   /// use_iterator - This class provides iterator support for SDUse
   /// operands that use a specific SDNode. 
   class use_iterator
@@ -1326,9 +1337,11 @@ protected:
     return Ret;
   }
 
+  /// The constructors that supply DebugLoc explicitly should be preferred
+  /// for new code.
   SDNode(unsigned Opc, SDVTList VTs, const SDValue *Ops, unsigned NumOps)
     : NodeType(Opc), OperandsNeedDelete(true), SubclassData(0),
-      NodeId(-1),
+      NodeId(-1), debugLoc(DebugLoc::getNoDebugLoc()),
       OperandList(NumOps ? new SDUse[NumOps] : 0),
       ValueList(VTs.VTs),
       NumOperands(NumOps), NumValues(VTs.NumVTs),
@@ -1343,8 +1356,33 @@ protected:
   /// set later with InitOperands.
   SDNode(unsigned Opc, SDVTList VTs)
     : NodeType(Opc), OperandsNeedDelete(false), SubclassData(0),
-      NodeId(-1), OperandList(0), ValueList(VTs.VTs),
-      NumOperands(0), NumValues(VTs.NumVTs),
+      NodeId(-1), debugLoc(DebugLoc::getNoDebugLoc()), OperandList(0), 
+      ValueList(VTs.VTs), NumOperands(0), NumValues(VTs.NumVTs),
+      UseList(NULL) {}
+
+  /// The next two constructors specify DebugLoc explicitly; the intent
+  /// is that they will replace the above two over time, and eventually
+  /// the ones above can be removed.
+  SDNode(unsigned Opc, SDVTList VTs, const SDValue *Ops, unsigned NumOps,
+         DebugLoc sl)
+    : NodeType(Opc), OperandsNeedDelete(true), SubclassData(0),
+      NodeId(-1), debugLoc(sl),
+      OperandList(NumOps ? new SDUse[NumOps] : 0),
+      ValueList(VTs.VTs),
+      NumOperands(NumOps), NumValues(VTs.NumVTs),
+      UseList(NULL) {
+    for (unsigned i = 0; i != NumOps; ++i) {
+      OperandList[i].setUser(this);
+      OperandList[i].setInitial(Ops[i]);
+    }
+  }
+
+  /// This constructor adds no operands itself; operands can be
+  /// set later with InitOperands.
+  SDNode(unsigned Opc, SDVTList VTs, DebugLoc sl)
+    : NodeType(Opc), OperandsNeedDelete(false), SubclassData(0),
+      NodeId(-1), debugLoc(sl), OperandList(0),
+      ValueList(VTs.VTs), NumOperands(0), NumValues(VTs.NumVTs),
       UseList(NULL) {}
   
   /// InitOperands - Initialize the operands list of this with 1 operand.
@@ -1441,6 +1479,9 @@ inline bool SDValue::use_empty() const {
 inline bool SDValue::hasOneUse() const {
   return Node->hasNUsesOfValue(1, ResNo);
 }
+inline DebugLoc SDValue::getDebugLoc() const {
+  return Node->getDebugLoc();
+}
 
 // Define inline functions from the SDUse class.