From d8d0aee26a5a759085bfa9114302e507c8685599 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 22 Jan 2010 21:00:45 +0000 Subject: [PATCH] reenable the label loop comments and switch them to use the formatted comment emission stuff. I'm going to rewrite this though because the current output doesn't make sense. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94215 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 107 ++++++++++---------------- 1 file changed, 40 insertions(+), 67 deletions(-) diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 276b334f67d..0b8633bf597 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -1677,6 +1677,8 @@ void AsmPrinter::EmitBasicBlockStart(const MachineBasicBlock *MBB) const { if (const BasicBlock *BB = MBB->getBasicBlock()) if (BB->hasName()) OutStreamer.AddComment("%" + BB->getName()); + + EmitComments(*MBB); OutStreamer.AddBlankLine(); } } else { @@ -1684,16 +1686,11 @@ void AsmPrinter::EmitBasicBlockStart(const MachineBasicBlock *MBB) const { if (const BasicBlock *BB = MBB->getBasicBlock()) if (BB->hasName()) OutStreamer.AddComment("%" + BB->getName()); + EmitComments(*MBB); } + OutStreamer.EmitLabel(GetMBBSymbol(MBB->getNumber())); } - - // Print some comments to accompany the label. - // FIXME: REENABLE. - if (0 && VerboseAsm) { - EmitComments(*MBB); - O << '\n'; - } } /// printPICJumpTableSetLabel - This method prints a set label for the @@ -1850,78 +1847,54 @@ void AsmPrinter::EmitComments(const MachineInstr &MI) const { /// PrintChildLoopComment - Print comments about child loops within /// the loop for this basic block, with nesting. -/// -static void PrintChildLoopComment(formatted_raw_ostream &O, - const MachineLoop *loop, - const MCAsmInfo *MAI, - int FunctionNumber) { +static void PrintChildLoopComment(MCStreamer &O, const MachineLoop *Loop, + unsigned FunctionNumber) { + raw_ostream &OS = O.GetCommentOS(); // Add child loop information - for(MachineLoop::iterator cl = loop->begin(), - clend = loop->end(); - cl != clend; - ++cl) { - MachineBasicBlock *Header = (*cl)->getHeader(); + for (MachineLoop::iterator CL = Loop->begin(), E = Loop->end();CL != E; ++CL){ + MachineBasicBlock *Header = (*CL)->getHeader(); assert(Header && "No header for loop"); - - O << '\n'; - O.PadToColumn(MAI->getCommentColumn()); - - O << MAI->getCommentString(); - O.indent(((*cl)->getLoopDepth()-1)*2) - << " Child Loop BB" << FunctionNumber << "_" - << Header->getNumber() << " Depth " << (*cl)->getLoopDepth(); - - PrintChildLoopComment(O, *cl, MAI, FunctionNumber); + OS.indent(((*CL)->getLoopDepth()-1)*2) + << "Child Loop BB" << FunctionNumber << "_" + << Header->getNumber() << " Depth " << (*CL)->getLoopDepth() << '\n'; + PrintChildLoopComment(O, *CL, FunctionNumber); } } /// EmitComments - Pretty-print comments for basic blocks void AsmPrinter::EmitComments(const MachineBasicBlock &MBB) const { - if (VerboseAsm) { - // Add loop depth information - const MachineLoop *loop = LI->getLoopFor(&MBB); + assert(VerboseAsm && "Shouldn't be called unless in verbose asm mode"); + + // Add loop depth information + const MachineLoop *Loop = LI->getLoopFor(&MBB); + if (Loop == 0) return; - if (loop) { - // Print a newline after bb# annotation. - O << "\n"; - O.PadToColumn(MAI->getCommentColumn()); - O << MAI->getCommentString() << " Loop Depth " << loop->getLoopDepth() - << '\n'; + OutStreamer.AddComment("Loop Depth " + Twine(Loop->getLoopDepth())); - O.PadToColumn(MAI->getCommentColumn()); + MachineBasicBlock *Header = Loop->getHeader(); + assert(Header && "No header for loop"); + + if (Header != &MBB) { + OutStreamer.AddComment("Loop Header is BB" + Twine(getFunctionNumber()) + + "_" + Twine(Loop->getHeader()->getNumber())); + } else { + OutStreamer.AddComment("Loop Header"); + PrintChildLoopComment(OutStreamer, Loop, getFunctionNumber()); + } - MachineBasicBlock *Header = loop->getHeader(); - assert(Header && "No header for loop"); - - if (Header == &MBB) { - O << MAI->getCommentString() << " Loop Header"; - PrintChildLoopComment(O, loop, MAI, getFunctionNumber()); - } - else { - O << MAI->getCommentString() << " Loop Header is BB" - << getFunctionNumber() << "_" << loop->getHeader()->getNumber(); - } + if (Loop->empty()) + OutStreamer.AddComment("Inner Loop"); - if (loop->empty()) { - O << '\n'; - O.PadToColumn(MAI->getCommentColumn()); - O << MAI->getCommentString() << " Inner Loop"; - } + raw_ostream &OS = OutStreamer.GetCommentOS(); - // Add parent loop information - for (const MachineLoop *CurLoop = loop->getParentLoop(); - CurLoop; - CurLoop = CurLoop->getParentLoop()) { - MachineBasicBlock *Header = CurLoop->getHeader(); - assert(Header && "No header for loop"); + // Add parent loop information. + for (const MachineLoop *CurLoop = Loop->getParentLoop(); CurLoop; + CurLoop = CurLoop->getParentLoop()) { + MachineBasicBlock *Header = CurLoop->getHeader(); + assert(Header && "No header for loop"); - O << '\n'; - O.PadToColumn(MAI->getCommentColumn()); - O << MAI->getCommentString(); - O.indent((CurLoop->getLoopDepth()-1)*2) - << " Inside Loop BB" << getFunctionNumber() << "_" - << Header->getNumber() << " Depth " << CurLoop->getLoopDepth(); - } - } + OS.indent(CurLoop->getLoopDepth()*2) + << "Inside Loop BB" << getFunctionNumber() << "_" + << Header->getNumber() << " Depth " << CurLoop->getLoopDepth() << '\n'; } }