We have logic in there to emit a default debugging label at the beginning of a
[oota-llvm.git] / utils / TableGen / AsmWriterEmitter.cpp
index 4ba22758a600e17658e2a60ab9f5677e945d8fc8..06495d883414e0003f24fb80e723c59cbedbbc9d 100644 (file)
@@ -45,7 +45,10 @@ namespace llvm {
     /// an operand, specified with syntax like ${opname:modifier}.
     std::string MiModifier;
 
-    AsmWriterOperand(const std::string &LitStr)
+    // To make VS STL happy
+    AsmWriterOperand():OperandType(isLiteralTextOperand) {}
+
+    explicit AsmWriterOperand(const std::string &LitStr)
       : OperandType(isLiteralTextOperand), Str(LitStr) {}
 
     AsmWriterOperand(const std::string &Printer, unsigned OpNo, 
@@ -363,7 +366,7 @@ FindUniqueOperandCommands(std::vector<std::string> &UniqueOperandCommands,
   
   for (unsigned i = 0, e = NumberedInstructions.size(); i != e; ++i) {
     const AsmWriterInst *Inst = getAsmWriterInstByID(i);
-    if (Inst == 0) continue;  // PHI, INLINEASM, LABEL, etc.
+    if (Inst == 0) continue;  // PHI, INLINEASM, DBG_LABEL, etc.
     
     std::string Command;
     if (Inst->Operands.empty())
@@ -536,7 +539,7 @@ void AsmWriterEmitter::run(std::ostream &O) {
   }
   
   // Figure out how many bits we used for the string index.
-  unsigned AsmStrBits = Log2_32_Ceil(MaxStringIdx);
+  unsigned AsmStrBits = Log2_32_Ceil(MaxStringIdx+1);
   
   // To reduce code size, we compactify common instructions into a few bits
   // in the opcode-indexed table.
@@ -637,11 +640,25 @@ void AsmWriterEmitter::run(std::ostream &O) {
   }
   O << "\";\n\n";
 
+  O << "  if (TAI->doesSupportDebugInformation() &&\n"
+    << "      DW->ShouldEmitDwarfDebug()) {\n"
+    << "    const MachineFunction *MF = MI->getParent()->getParent();\n"
+    << "    DebugLoc CurDL = MI->getDebugLoc();\n\n"
+    << "    if (!CurDL.isUnknown()) {\n"
+    << "      static DebugLocTuple PrevDLT(~0U, ~0U, ~0U);\n"
+    << "      DebugLocTuple CurDLT = MF->getDebugLocTuple(CurDL);\n\n"
+    << "      if (PrevDLT.Src != ~0U && PrevDLT != CurDLT)\n"
+    << "        printLabel(DW->RecordSourceLine(CurDLT.Line, CurDLT.Col,\n"
+    << "                                        CurDLT.Src));\n\n"
+    << "      PrevDLT = CurDLT;\n"
+    << "    }\n"
+    << "  }\n\n";
+
   O << "  if (MI->getOpcode() == TargetInstrInfo::INLINEASM) {\n"
     << "    O << \"\\t\";\n"
     << "    printInlineAsm(MI);\n"
     << "    return true;\n"
-    << "  } else if (MI->getOpcode() == TargetInstrInfo::LABEL) {\n"
+    << "  } else if (MI->isLabel()) {\n"
     << "    printLabel(MI);\n"
     << "    return true;\n"
     << "  } else if (MI->getOpcode() == TargetInstrInfo::DECLARE) {\n"