factor MBB label lowering better
authorChris Lattner <sabre@nondot.org>
Sat, 12 Sep 2009 21:06:08 +0000 (21:06 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 12 Sep 2009 21:06:08 +0000 (21:06 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81630 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/AsmPrinter/X86MCInstLower.cpp
lib/Target/X86/AsmPrinter/X86MCInstLower.h

index 625be15390bd4c3dcca8fa0d340086f1edaecd02..023882ce5dae1c9cfa1af447ce6a96ecc1f7c997 100644 (file)
@@ -45,13 +45,12 @@ MCSymbol *X86MCInstLower::GetPICBaseSymbol() const {
   return Ctx.GetOrCreateSymbol(Name.str());
 }
 
-MCOperand X86MCInstLower::LowerMBBOperand(const MachineOperand &MO) const {
+MCSymbol *X86MCInstLower::GetMBBSymbol(unsigned MBBID) const {
   SmallString<60> Name;
   raw_svector_ostream(Name) << AsmPrinter.MAI->getPrivateGlobalPrefix() << "BB"
-      << AsmPrinter.getFunctionNumber() << '_' << MO.getMBB()->getNumber();
+      << AsmPrinter.getFunctionNumber() << '_' << MBBID;
 
-  MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name.str());
-  return MCOperand::CreateExpr(MCSymbolRefExpr::Create(Sym, Ctx));
+  return Ctx.GetOrCreateSymbol(Name.str());
 }
 
 
@@ -320,7 +319,8 @@ void X86MCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
       MCOp = MCOperand::CreateImm(MO.getImm());
       break;
     case MachineOperand::MO_MachineBasicBlock:
-      MCOp = LowerMBBOperand(MO);
+      MCOp = MCOperand::CreateExpr(MCSymbolRefExpr::Create(
+                              GetMBBSymbol(MO.getMBB()->getNumber()), Ctx));
       break;
     case MachineOperand::MO_GlobalAddress:
       MCOp = LowerSymbolOperand(MO, GetGlobalAddressSymbol(MO));
index 2f9691ed097827b1800101444e0d2014f10d1583..3329b90cda3db56d98b628ba063da836a00ade8a 100644 (file)
@@ -36,7 +36,7 @@ public:
 
   MCSymbol *GetPICBaseSymbol() const;
   
-  MCOperand LowerMBBOperand(const MachineOperand &MO) const;
+  MCSymbol *GetMBBSymbol(unsigned MBBID) const;
   MCSymbol *GetGlobalAddressSymbol(const MachineOperand &MO) const;
   MCSymbol *GetExternalSymbolSymbol(const MachineOperand &MO) const;
   MCSymbol *GetJumpTableSymbol(const MachineOperand &MO) const;