Forgot to check that debug information is supported.
[oota-llvm.git] / utils / TableGen / AsmWriterEmitter.cpp
index e2cd5dc031013edc3a7de5559e85f6cd00872606..6d2fa5578c9c7e99f40744ae7955d632e5e574ab 100644 (file)
@@ -48,7 +48,7 @@ namespace llvm {
     // To make VS STL happy
     AsmWriterOperand():OperandType(isLiteralTextOperand) {}
 
-    AsmWriterOperand(const std::string &LitStr)
+    explicit AsmWriterOperand(const std::string &LitStr)
       : OperandType(isLiteralTextOperand), Str(LitStr) {}
 
     AsmWriterOperand(const std::string &Printer, unsigned OpNo, 
@@ -640,6 +640,17 @@ void AsmWriterEmitter::run(std::ostream &O) {
   }
   O << "\";\n\n";
 
+  O << "  if (TAI->doesSupportDebugInformation()) {\n"
+    << "    const MachineFunction *MF = MI->getParent()->getParent();\n"
+    << "    static DebugLoc PrevDL = DebugLoc::getUnknownLoc();\n"
+    << "    DebugLoc CurDL = MI->getDebugLoc();\n\n"
+    << "    if (!CurDL.isUnknown() && PrevDL != CurDL) {\n"
+    << "      DebugLocTuple DLT = MF->getDebugLocTuple(CurDL);\n"
+    << "      printLabel(DW->RecordSourceLine(DLT.Line, DLT.Col, DLT.Src));\n"
+    << "    }\n\n"
+    << "    PrevDL = CurDL;\n"
+    << "  }\n\n";
+
   O << "  if (MI->getOpcode() == TargetInstrInfo::INLINEASM) {\n"
     << "    O << \"\\t\";\n"
     << "    printInlineAsm(MI);\n"