devirtualize AsmPrinter::printBasicBlockLabel since it is never overridden.

Move GetMBBSymbol up to AsmPrinter and make printBasicBlockLabel use it so that
we only have one place that decides what to name bb labels.  Hopefully various
clients of printBasicBlockLabel can start using GetMBBSymbol instead.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81652 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2009-09-12 23:02:08 +00:00
parent deb8c1547e
commit 7cb384dcca
4 changed files with 25 additions and 20 deletions

View File

@ -46,6 +46,7 @@ namespace llvm {
class MCContext; class MCContext;
class MCSection; class MCSection;
class MCStreamer; class MCStreamer;
class MCSymbol;
class DwarfWriter; class DwarfWriter;
class Mangler; class Mangler;
class MCAsmInfo; class MCAsmInfo;
@ -345,6 +346,16 @@ namespace llvm {
/// instructions, do not use this function outside of llvm-mc. /// instructions, do not use this function outside of llvm-mc.
virtual void printMCInst(const MCInst *MI); virtual void printMCInst(const MCInst *MI);
/// GetMBBSymbol - Return the MCSymbol corresponding to the specified basic
/// block label.
MCSymbol *GetMBBSymbol(unsigned MBBID) const;
/// printBasicBlockLabel - This method prints the label for the specified
/// MachineBasicBlock
void printBasicBlockLabel(const MachineBasicBlock *MBB,
bool printAlign = false,
bool printColon = false,
bool printComment = true) const;
protected: protected:
/// EmitZeros - Emit a block of zeros. /// EmitZeros - Emit a block of zeros.
/// ///
@ -375,13 +386,7 @@ namespace llvm {
/// that is an implicit def. /// that is an implicit def.
virtual void printImplicitDef(const MachineInstr *MI) const; virtual void printImplicitDef(const MachineInstr *MI) const;
/// printBasicBlockLabel - This method prints the label for the specified
/// MachineBasicBlock
virtual void printBasicBlockLabel(const MachineBasicBlock *MBB,
bool printAlign = false,
bool printColon = false,
bool printComment = true) const;
/// printPICJumpTableSetLabel - This method prints a set label for the /// printPICJumpTableSetLabel - This method prints a set label for the
/// specified MachineBasicBlock for a jumptable entry. /// specified MachineBasicBlock for a jumptable entry.
virtual void printPICJumpTableSetLabel(unsigned uid, virtual void printPICJumpTableSetLabel(unsigned uid,

View File

@ -28,6 +28,7 @@
#include "llvm/MC/MCInst.h" #include "llvm/MC/MCInst.h"
#include "llvm/MC/MCSection.h" #include "llvm/MC/MCSection.h"
#include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/Support/CommandLine.h" #include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormattedStream.h" #include "llvm/Support/FormattedStream.h"
@ -1634,6 +1635,15 @@ bool AsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
return true; return true;
} }
MCSymbol *AsmPrinter::GetMBBSymbol(unsigned MBBID) const {
SmallString<60> Name;
raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix() << "BB"
<< getFunctionNumber() << '_' << MBBID;
return OutContext.GetOrCreateSymbol(Name.str());
}
/// printBasicBlockLabel - This method prints the label for the specified /// printBasicBlockLabel - This method prints the label for the specified
/// MachineBasicBlock /// MachineBasicBlock
void AsmPrinter::printBasicBlockLabel(const MachineBasicBlock *MBB, void AsmPrinter::printBasicBlockLabel(const MachineBasicBlock *MBB,
@ -1646,8 +1656,8 @@ void AsmPrinter::printBasicBlockLabel(const MachineBasicBlock *MBB,
EmitAlignment(Log2_32(Align)); EmitAlignment(Log2_32(Align));
} }
O << MAI->getPrivateGlobalPrefix() << "BB" << getFunctionNumber() << '_' GetMBBSymbol(MBB->getNumber())->print(O, MAI);
<< MBB->getNumber();
if (printColon) if (printColon)
O << ':'; O << ':';
if (printComment) { if (printComment) {

View File

@ -45,15 +45,6 @@ MCSymbol *X86MCInstLower::GetPICBaseSymbol() const {
return Ctx.GetOrCreateSymbol(Name.str()); return Ctx.GetOrCreateSymbol(Name.str());
} }
MCSymbol *X86MCInstLower::GetMBBSymbol(unsigned MBBID) const {
SmallString<60> Name;
raw_svector_ostream(Name) << AsmPrinter.MAI->getPrivateGlobalPrefix() << "BB"
<< AsmPrinter.getFunctionNumber() << '_' << MBBID;
return Ctx.GetOrCreateSymbol(Name.str());
}
/// LowerGlobalAddressOperand - Lower an MO_GlobalAddress operand to an /// LowerGlobalAddressOperand - Lower an MO_GlobalAddress operand to an
/// MCOperand. /// MCOperand.
@ -320,7 +311,7 @@ void X86MCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
break; break;
case MachineOperand::MO_MachineBasicBlock: case MachineOperand::MO_MachineBasicBlock:
MCOp = MCOperand::CreateExpr(MCSymbolRefExpr::Create( MCOp = MCOperand::CreateExpr(MCSymbolRefExpr::Create(
GetMBBSymbol(MO.getMBB()->getNumber()), Ctx)); AsmPrinter.GetMBBSymbol(MO.getMBB()->getNumber()), Ctx));
break; break;
case MachineOperand::MO_GlobalAddress: case MachineOperand::MO_GlobalAddress:
MCOp = LowerSymbolOperand(MO, GetGlobalAddressSymbol(MO)); MCOp = LowerSymbolOperand(MO, GetGlobalAddressSymbol(MO));

View File

@ -36,7 +36,6 @@ public:
MCSymbol *GetPICBaseSymbol() const; MCSymbol *GetPICBaseSymbol() const;
MCSymbol *GetMBBSymbol(unsigned MBBID) const;
MCSymbol *GetGlobalAddressSymbol(const MachineOperand &MO) const; MCSymbol *GetGlobalAddressSymbol(const MachineOperand &MO) const;
MCSymbol *GetExternalSymbolSymbol(const MachineOperand &MO) const; MCSymbol *GetExternalSymbolSymbol(const MachineOperand &MO) const;
MCSymbol *GetJumpTableSymbol(const MachineOperand &MO) const; MCSymbol *GetJumpTableSymbol(const MachineOperand &MO) const;