add a new MachineBasicBlock::getSymbol method, replacing

the AsmPrinter::GetMBBSymbol.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94515 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2010-01-26 04:55:51 +00:00
parent 030c4bfbc9
commit f71cb015c1
19 changed files with 51 additions and 43 deletions

View File

@ -14,15 +14,18 @@
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/BasicBlock.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
#include "llvm/Target/TargetRegisterInfo.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetInstrDesc.h"
#include "llvm/Target/TargetInstrInfo.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Assembly/Writer.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/LeakDetector.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Assembly/Writer.h"
#include <algorithm>
using namespace llvm;
@ -36,6 +39,18 @@ MachineBasicBlock::~MachineBasicBlock() {
LeakDetector::removeGarbageObject(this);
}
/// getSymbol - Return the MCSymbol for this basic block.
///
MCSymbol *MachineBasicBlock::getSymbol(MCContext &Ctx) const {
SmallString<60> Name;
const MachineFunction *MF = getParent();
raw_svector_ostream(Name)
<< MF->getTarget().getMCAsmInfo()->getPrivateGlobalPrefix() << "BB"
<< MF->getFunctionNumber() << '_' << getNumber();
return Ctx.GetOrCreateSymbol(Name.str());
}
raw_ostream &llvm::operator<<(raw_ostream &OS, const MachineBasicBlock &MBB) {
MBB.print(OS);
return OS;