Add unique id to debug location for debug label use (work in progress.)
authorJim Laskey <jlaskey@mac.com>
Wed, 4 Jan 2006 15:04:11 +0000 (15:04 +0000)
committerJim Laskey <jlaskey@mac.com>
Wed, 4 Jan 2006 15:04:11 +0000 (15:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25096 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/SelectionDAGNodes.h
lib/CodeGen/MachineDebugInfo.cpp
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
lib/Target/PowerPC/PPCInstrInfo.td
lib/Target/TargetSelectionDAG.td

index 21d4335720d01ed3d5a275987568f91611e05d2e..800ad3932b7fbfac04ffc5a1ae5b4031424464a6 100644 (file)
@@ -356,8 +356,9 @@ namespace ISD {
     
     // DEBUG_LOC - This node is used to represent source line information
     // embedded in the code.  It takes token chain as input, then a line number,
-    // then a column then a file id (provided by MachineDebugInfo.  It produces
-    // a token chain as output.
+    // then a column then a file id (provided by MachineDebugInfo), then a
+    // unique id (provided by MachineDebugInfo for label gen).  It produces a
+    // token chain as output.
     DEBUG_LOC,
     
     // BUILTIN_OP_END - This must be the last enum value in this list.
index 2cd30fad18b3a5ce6acb3cc8a30b9547d4b366ba..fc88b8ca00646da72047d62211d108eac9ddc17c 100644 (file)
@@ -50,6 +50,7 @@ namespace llvm {
   /// doFinalization - Tear down the debug state after completion of a module.
   ///
   bool MachineDebugInfo::doFinalization() {
+    
     return true;
   }
 
index 30a4c9f637ccca82ad03f355c08de53b1c2d3f8a..1cfa305d85874fc2b730bfa9ba9e2eeb06a2b00d 100644 (file)
@@ -2117,7 +2117,8 @@ SDOperand DAGCombiner::visitDEBUGLOC(SDNode *N) {
     return DAG.getNode(ISD::DEBUG_LOC, MVT::Other, Chain.getOperand(0),
                                                    N->getOperand(1),
                                                    N->getOperand(2),
-                                                   N->getOperand(3));
+                                                   N->getOperand(3),
+                                                   N->getOperand(4));
   }
   
   return SDOperand();
index af2c4ba13989fe563b494df6b876617b4bee0275..bd8c50a53d345fa5c3c0e3e44d947c9992309c54 100644 (file)
@@ -628,8 +628,10 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
           cast<StringSDNode>(Node->getOperand(3))->getValue();
         const std::string &dirname = 
           cast<StringSDNode>(Node->getOperand(4))->getValue();
-        unsigned id = DebugInfo.RecordSource(fname, dirname);
-        Ops.push_back(DAG.getConstant(id, MVT::i32));  // source file id
+        unsigned srcfile = DebugInfo.RecordSource(fname, dirname);
+        Ops.push_back(DAG.getConstant(srcfile, MVT::i32));  // source file id
+        unsigned id = DebugInfo.NextUniqueID();
+        Ops.push_back(DAG.getConstant(id, MVT::i32));  // label id
         Result = DAG.getNode(ISD::DEBUG_LOC, MVT::Other, Ops);
       } else {
         Result = Tmp1;  // chain
@@ -659,22 +661,27 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
     break;
     
   case ISD::DEBUG_LOC:
-    assert(Node->getNumOperands() == 4 && "Invalid DEBUG_LOC node!");
+    assert(Node->getNumOperands() == 5 && "Invalid DEBUG_LOC node!");
     switch (TLI.getOperationAction(ISD::DEBUG_LOC, MVT::Other)) {
     case TargetLowering::Promote:
     case TargetLowering::Expand:
     default: assert(0 && "This action is not supported yet!");
-    case TargetLowering::Legal:
-      Tmp1 = LegalizeOp(Node->getOperand(0));  // Legalize the chain.
-      Tmp2 = LegalizeOp(Node->getOperand(1));  // Legalize the line #.
-      Tmp3 = LegalizeOp(Node->getOperand(2));  // Legalize the col #.
-      Tmp4 = LegalizeOp(Node->getOperand(3));  // Legalize the source file id.
-      
-      if (Tmp1 != Node->getOperand(0) ||
-          Tmp2 != Node->getOperand(1) ||
-          Tmp3 != Node->getOperand(2) ||
-          Tmp4 != Node->getOperand(3)) {
-        Result = DAG.getNode(ISD::DEBUG_LOC,MVT::Other, Tmp1, Tmp2, Tmp3, Tmp4);
+    case TargetLowering::Legal: {
+        SDOperand Tmp5;
+        Tmp1 = LegalizeOp(Node->getOperand(0));  // Legalize the chain.
+        Tmp2 = LegalizeOp(Node->getOperand(1));  // Legalize the line #.
+        Tmp3 = LegalizeOp(Node->getOperand(2));  // Legalize the col #.
+        Tmp4 = LegalizeOp(Node->getOperand(3));  // Legalize the source file id.
+        Tmp5 = LegalizeOp(Node->getOperand(4));  // Legalize the label id.
+        
+        if (Tmp1 != Node->getOperand(0) ||
+            Tmp2 != Node->getOperand(1) ||
+            Tmp3 != Node->getOperand(2) ||
+            Tmp4 != Node->getOperand(3) ||
+            Tmp5 != Node->getOperand(4)) {
+          Result =
+           DAG.getNode(ISD::DEBUG_LOC,MVT::Other, Tmp1, Tmp2, Tmp3, Tmp4, Tmp5);
+        }
       }
       break;
     }
index 395eab678d514857e359ba1a57afea9204d9ebb4..3d3424d17bccd7ea5f4e723d2052cab4836aa297 100644 (file)
@@ -955,10 +955,11 @@ def V_SET0 : VXForm_setzero<1220, (ops VRRC:$vD),
 // DWARF Pseudo Instructions
 //
 
-def DWARF_LOC        : Pseudo<(ops i32imm:$line, i32imm:$col, i32imm:$file),
-                              "; .loc $file, $line, $col",
+def DWARF_LOC        : Pseudo<(ops i32imm:$line, i32imm:$col, i32imm:$file,
+                                   i32imm:$id),
+                              "; .loc $file, $line, $col\nLdebug_loc$id:",
                       [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
-                                  (i32 imm:$file))]>;
+                                  (i32 imm:$file), (i32 imm:$id))]>;
 
 //===----------------------------------------------------------------------===//
 // PowerPC Instruction Patterns
index db7c2bdd02329e14831ac6fa6db0bca5684247d7..13cd40e3916d84920f062d0fc8609c93ac5e6377 100644 (file)
@@ -440,8 +440,8 @@ class ComplexPattern<ValueType ty, int numops, string fn, list<SDNode> roots = [
 //===----------------------------------------------------------------------===//
 // Dwarf support.
 //
-def SDT_dwarf_loc : SDTypeProfile<0, 3,
-                                    [SDTCisInt<0>, SDTCisInt<1>, SDTCisInt<2>]>;
+def SDT_dwarf_loc : SDTypeProfile<0, 4,
+                      [SDTCisInt<0>, SDTCisInt<1>, SDTCisInt<2>, SDTCisInt<3>]>;
 def dwarf_loc  : SDNode<"ISD::DEBUG_LOC", SDT_dwarf_loc,[SDNPHasChain]>;