Skip to content
AsmPrinter.cpp 69.3 KiB
Newer Older
David Greene's avatar
 
David Greene committed

    O << '\n';
    O.PadToColumn(MAI->getCommentColumn());
David Greene's avatar
 
David Greene committed

    O.indent(((*cl)->getLoopDepth()-1)*2)
David Greene's avatar
 
David Greene committed
      << " Child Loop BB" << FunctionNumber << "_"
      << Header->getNumber() << " Depth " << (*cl)->getLoopDepth();

    PrintChildLoopComment(O, *cl, MAI, FunctionNumber);
David Greene's avatar
 
David Greene committed
  }
}

David Greene's avatar
 
David Greene committed
/// EmitComments - Pretty-print comments for basic blocks
David Greene's avatar
 
David Greene committed
void AsmPrinter::EmitComments(const MachineBasicBlock &MBB) const {
David Greene's avatar
 
David Greene committed
  if (VerboseAsm) {
David Greene's avatar
 
David Greene committed
    // Add loop depth information
    const MachineLoop *loop = LI->getLoopFor(&MBB);

    if (loop) {
      // Print a newline after bb# annotation.
      O << "\n";
      O.PadToColumn(MAI->getCommentColumn());
      O << MAI->getCommentString() << " Loop Depth " << loop->getLoopDepth()
David Greene's avatar
 
David Greene committed
        << '\n';

      O.PadToColumn(MAI->getCommentColumn());
David Greene's avatar
 
David Greene committed

      MachineBasicBlock *Header = loop->getHeader();
      assert(Header && "No header for loop");
      
      if (Header == &MBB) {
        O << MAI->getCommentString() << " Loop Header";
        PrintChildLoopComment(O, loop, MAI, getFunctionNumber());
David Greene's avatar
 
David Greene committed
      }
      else {
        O << MAI->getCommentString() << " Loop Header is BB"
David Greene's avatar
 
David Greene committed
          << getFunctionNumber() << "_" << loop->getHeader()->getNumber();
      }

      if (loop->empty()) {
        O << '\n';
        O.PadToColumn(MAI->getCommentColumn());
        O << MAI->getCommentString() << " Inner Loop";
David Greene's avatar
 
David Greene committed
      }

      // 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)
David Greene's avatar
 
David Greene committed
          << " Inside Loop BB" << getFunctionNumber() << "_"
David Greene's avatar
 
David Greene committed
          << Header->getNumber() << " Depth " << CurLoop->getLoopDepth();
      }
    }
  }
}