rejigger the world so that EmitInstruction prints the \n at
the end of the instruction instead of expecting the caller to
do it.  This currently causes the asm-verbose instruction 
comments to be on the next line.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95178 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 71668f5..3358d04 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -351,15 +351,19 @@
       case TargetInstrInfo::EH_LABEL:
       case TargetInstrInfo::GC_LABEL:
         printLabel(II);
+        O << '\n';
         break;
       case TargetInstrInfo::INLINEASM:
         printInlineAsm(II);
+        O << '\n';
         break;
       case TargetInstrInfo::IMPLICIT_DEF:
         printImplicitDef(II);
+        O << '\n';
         break;
       case TargetInstrInfo::KILL:
         printKill(II);
+        O << '\n';
         break;
       default:
         EmitInstruction(II);
@@ -367,7 +371,6 @@
       }
       if (VerboseAsm)
         EmitComments(*II);
-      O << '\n';
       
       // FIXME: Clean up processDebugLoc.
       processDebugLoc(II, false);
@@ -1580,7 +1583,7 @@
   }
 }
 
-/// EmitComments - Pretty-print comments for basic blocks.
+/// PrintBasicBlockLoopComments - Pretty-print comments for basic blocks.
 static void PrintBasicBlockLoopComments(const MachineBasicBlock &MBB,
                                         const MachineLoopInfo *LI,
                                         const AsmPrinter &AP) {
@@ -1716,8 +1719,6 @@
   if (!VerboseAsm)
     return;
 
-  bool Newline = false;
-
   if (!MI.getDebugLoc().isUnknown()) {
     DILocation DLT = MF->getDILocation(MI.getDebugLoc());
 
@@ -1733,7 +1734,7 @@
     O << ':' << DLT.getLineNumber();
     if (DLT.getColumnNumber() != 0)
       O << ':' << DLT.getColumnNumber();
-    Newline = true;
+    O << '\n';
   }
 
   // Check for spills and reloads
@@ -1748,37 +1749,29 @@
   if (TM.getInstrInfo()->isLoadFromStackSlotPostFE(&MI, FI)) {
     if (FrameInfo->isSpillSlotObjectIndex(FI)) {
       MMO = *MI.memoperands_begin();
-      if (Newline) O << '\n';
       O.PadToColumn(MAI->getCommentColumn());
-      O << MAI->getCommentString() << ' ' << MMO->getSize() << "-byte Reload";
-      Newline = true;
+      O << MAI->getCommentString() << ' ' << MMO->getSize() << "-byte Reload\n";
     }
   }
   else if (TM.getInstrInfo()->hasLoadFromStackSlot(&MI, MMO, FI)) {
     if (FrameInfo->isSpillSlotObjectIndex(FI)) {
-      if (Newline) O << '\n';
       O.PadToColumn(MAI->getCommentColumn());
       O << MAI->getCommentString() << ' '
-        << MMO->getSize() << "-byte Folded Reload";
-      Newline = true;
+        << MMO->getSize() << "-byte Folded Reload\n";
     }
   }
   else if (TM.getInstrInfo()->isStoreToStackSlotPostFE(&MI, FI)) {
     if (FrameInfo->isSpillSlotObjectIndex(FI)) {
       MMO = *MI.memoperands_begin();
-      if (Newline) O << '\n';
       O.PadToColumn(MAI->getCommentColumn());
-      O << MAI->getCommentString() << ' ' << MMO->getSize() << "-byte Spill";
-      Newline = true;
+      O << MAI->getCommentString() << ' ' << MMO->getSize() << "-byte Spill\n";
     }
   }
   else if (TM.getInstrInfo()->hasStoreToStackSlot(&MI, MMO, FI)) {
     if (FrameInfo->isSpillSlotObjectIndex(FI)) {
-      if (Newline) O << '\n';
       O.PadToColumn(MAI->getCommentColumn());
       O << MAI->getCommentString() << ' '
-        << MMO->getSize() << "-byte Folded Spill";
-      Newline = true;
+        << MMO->getSize() << "-byte Folded Spill\n";
     }
   }
 
@@ -1787,9 +1780,8 @@
   if (TM.getInstrInfo()->isMoveInstr(MI, SrcReg, DstReg,
                                       SrcSubIdx, DstSubIdx)) {
     if (MI.getAsmPrinterFlag(ReloadReuse)) {
-      if (Newline) O << '\n';
       O.PadToColumn(MAI->getCommentColumn());
-      O << MAI->getCommentString() << " Reload Reuse";
+      O << MAI->getCommentString() << " Reload Reuse\n";
     }
   }
 }
diff --git a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
index 3f0bd61..7e22b62 100644
--- a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
+++ b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
@@ -1034,6 +1034,7 @@
       EmitAlignment(2);
     
     printInstruction(MI);
+    O << '\n';
   }
 }
 
diff --git a/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp b/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp
index f512256..03a49b2 100644
--- a/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp
+++ b/lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp
@@ -45,7 +45,10 @@
       return "Alpha Assembly Printer";
     }
     void printInstruction(const MachineInstr *MI);
-    void EmitInstruction(const MachineInstr *MI) { printInstruction(MI); }
+    void EmitInstruction(const MachineInstr *MI) {
+      printInstruction(MI);
+      O << '\n';
+    }
     static const char *getRegisterName(unsigned RegNo);
 
     void printOp(const MachineOperand &MO, bool IsCallOp = false);
diff --git a/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp b/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp
index 56a1462..885e697 100644
--- a/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp
+++ b/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp
@@ -52,7 +52,10 @@
     void printInstruction(const MachineInstr *MI);  // autogenerated.
     static const char *getRegisterName(unsigned RegNo);
 
-    void EmitInstruction(const MachineInstr *MI) { printInstruction(MI); }
+    void EmitInstruction(const MachineInstr *MI) {
+      printInstruction(MI);
+      O << '\n';
+    }
     bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
                          unsigned AsmVariant, const char *ExtraCode);
     bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
diff --git a/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp b/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp
index 92736c2..db653a7 100644
--- a/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp
+++ b/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp
@@ -58,6 +58,7 @@
 
     void EmitInstruction(const MachineInstr *MI) {
       printInstruction(MI);
+      O << '\n';
     }
     void printOp(const MachineOperand &MO);
 
diff --git a/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp b/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp
index 14e39f9..20cbde8 100644
--- a/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp
+++ b/lib/Target/MSP430/AsmPrinter/MSP430AsmPrinter.cpp
@@ -184,6 +184,7 @@
   MCInst TmpInst;
   MCInstLowering.Lower(MI, TmpInst);
   printMCInst(&TmpInst);
+  O << '\n';
 }
 
 static MCInstPrinter *createMSP430MCInstPrinter(const Target &T,
diff --git a/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp b/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp
index 4118e7b..5ae1cf1 100644
--- a/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp
+++ b/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp
@@ -75,7 +75,10 @@
     void emitFrameDirective();
 
     void printInstruction(const MachineInstr *MI);  // autogenerated.
-    void EmitInstruction(const MachineInstr *MI) { printInstruction(MI); }
+    void EmitInstruction(const MachineInstr *MI) {
+      printInstruction(MI);
+      O << '\n';
+    }
     virtual void EmitFunctionBodyStart();
     virtual void EmitFunctionBodyEnd();
     static const char *getRegisterName(unsigned RegNo);
diff --git a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
index 241bb90..17581a9 100644
--- a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
+++ b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
@@ -555,6 +555,7 @@
       O << ", ";
       printOperand(MI, 1);
       O << ", " << (unsigned int)SH;
+      O << '\n';
       return;
     }
   }
@@ -565,6 +566,7 @@
     printOperand(MI, 0);
     O << ", ";
     printOperand(MI, 1);
+    O << '\n';
     return;
   }
   
@@ -578,11 +580,13 @@
       O << ", ";
       printOperand(MI, 1);
       O << ", " << (unsigned int)SH;
+      O << '\n';
       return;
     }
   }
 
   printInstruction(MI);
+  O << '\n';
 }
 
 void PPCLinuxAsmPrinter::EmitFunctionEntryLabel() {
diff --git a/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp b/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp
index 950daa9..7f529fe 100644
--- a/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp
+++ b/lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp
@@ -44,6 +44,7 @@
 
     virtual void EmitInstruction(const MachineInstr *MI) {
       printInstruction(MI);
+      O << '\n';
     }
     void printInstruction(const MachineInstr *MI);  // autogenerated.
     static const char *getRegisterName(unsigned RegNo);
diff --git a/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp b/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp
index 1611ae8..965f5a1 100644
--- a/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp
+++ b/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp
@@ -79,6 +79,7 @@
 void SystemZAsmPrinter::EmitInstruction(const MachineInstr *MI) {
   // Call the autogenerated instruction printer routines.
   printInstruction(MI);
+  O << '\n';
 }
 
 void SystemZAsmPrinter::printPCRelImmOperand(const MachineInstr *MI, int OpNum){
diff --git a/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp b/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp
index b45e671..3b3b9ff 100644
--- a/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp
+++ b/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp
@@ -448,6 +448,7 @@
     }
     O << "+";
     printOperand(MI, NOps-2);
+    O << '\n';
     return;
   }
   case X86::MOVPC32r: {
@@ -475,6 +476,7 @@
     TmpInst.setOpcode(X86::POP32r);
     TmpInst.getOperand(0) = MCOperand::CreateReg(MI->getOperand(0).getReg());
     printMCInst(&TmpInst);
+    O << '\n';
     return;
   }
       
@@ -512,6 +514,7 @@
     TmpInst.addOperand(MCOperand::CreateReg(MI->getOperand(1).getReg()));
     TmpInst.addOperand(MCOperand::CreateExpr(DotExpr));
     printMCInst(&TmpInst);
+    O << '\n';
     return;
   }
   }
@@ -521,5 +524,6 @@
   
   
   printMCInst(&TmpInst);
+  O << '\n';
 }
 
diff --git a/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp b/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp
index f85217c..b9ba61e 100644
--- a/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp
+++ b/lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp
@@ -309,6 +309,7 @@
     return;
   }
   printInstruction(MI);
+  O << '\n';
 }
 
 // Force static initialization.