factor MBB label lowering better

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81630 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2009-09-12 21:06:08 +00:00
parent e9434dbff4
commit d8d2050637
2 changed files with 6 additions and 6 deletions

View File

@ -45,13 +45,12 @@ MCSymbol *X86MCInstLower::GetPICBaseSymbol() const {
return Ctx.GetOrCreateSymbol(Name.str()); return Ctx.GetOrCreateSymbol(Name.str());
} }
MCOperand X86MCInstLower::LowerMBBOperand(const MachineOperand &MO) const { MCSymbol *X86MCInstLower::GetMBBSymbol(unsigned MBBID) const {
SmallString<60> Name; SmallString<60> Name;
raw_svector_ostream(Name) << AsmPrinter.MAI->getPrivateGlobalPrefix() << "BB" raw_svector_ostream(Name) << AsmPrinter.MAI->getPrivateGlobalPrefix() << "BB"
<< AsmPrinter.getFunctionNumber() << '_' << MO.getMBB()->getNumber(); << AsmPrinter.getFunctionNumber() << '_' << MBBID;
MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name.str()); return Ctx.GetOrCreateSymbol(Name.str());
return MCOperand::CreateExpr(MCSymbolRefExpr::Create(Sym, Ctx));
} }
@ -320,7 +319,8 @@ void X86MCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
MCOp = MCOperand::CreateImm(MO.getImm()); MCOp = MCOperand::CreateImm(MO.getImm());
break; break;
case MachineOperand::MO_MachineBasicBlock: case MachineOperand::MO_MachineBasicBlock:
MCOp = LowerMBBOperand(MO); MCOp = MCOperand::CreateExpr(MCSymbolRefExpr::Create(
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,7 @@ public:
MCSymbol *GetPICBaseSymbol() const; MCSymbol *GetPICBaseSymbol() const;
MCOperand LowerMBBOperand(const MachineOperand &MO) 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;