Forgot to check that debug information is supported.
[oota-llvm.git] / utils / TableGen / AsmWriterEmitter.cpp
index 3cb361288060c4f1dddd63cee9feaa4bf174561d..6d2fa5578c9c7e99f40744ae7955d632e5e574ab 100644 (file)
@@ -45,10 +45,10 @@ namespace llvm {
     /// an operand, specified with syntax like ${opname:modifier}.
     std::string MiModifier;
 
-       // To make VS STL happy
-       AsmWriterOperand():OperandType(isLiteralTextOperand) {}
+    // 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"