aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-01-26 04:55:51 +0000
committerChris Lattner <sabre@nondot.org>2010-01-26 04:55:51 +0000
commit84d5ca9524a5d23f88083d0663ee99dca739df21 (patch)
treed8a059d88a780969f42d32dc19b89e65d2458971 /lib/CodeGen
parent408dcd3ebe187e2c098928caf9c4ce8928a30ba0 (diff)
downloadexternal_llvm-84d5ca9524a5d23f88083d0663ee99dca739df21.tar.gz
external_llvm-84d5ca9524a5d23f88083d0663ee99dca739df21.tar.bz2
external_llvm-84d5ca9524a5d23f88083d0663ee99dca739df21.zip
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
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/AsmPrinter/AsmPrinter.cpp21
-rw-r--r--lib/CodeGen/MachineBasicBlock.cpp17
2 files changed, 23 insertions, 15 deletions
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 537993373a..5c46da52c2 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -534,7 +534,7 @@ void AsmPrinter::EmitJumpTableInfo(MachineFunction &MF) {
// In non-pic mode, the entries in the jump table are direct references
// to the basic blocks.
for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii) {
- MCSymbol *MBBSym = GetMBBSymbol(JTBBs[ii]->getNumber());
+ MCSymbol *MBBSym = JTBBs[ii]->getSymbol(OutContext);
OutStreamer.EmitValue(MCSymbolRefExpr::Create(MBBSym, OutContext),
EntrySize, /*addrspace*/0);
}
@@ -557,13 +557,13 @@ void AsmPrinter::printPICJumpTableEntry(const MachineJumpTableInfo *MJTI,
case MachineJumpTableInfo::EK_BlockAddress:
// EK_BlockAddress - Each entry is a plain address of block, e.g.:
// .word LBB123
- Value = MCSymbolRefExpr::Create(GetMBBSymbol(MBB->getNumber()), OutContext);
+ Value = MCSymbolRefExpr::Create(MBB->getSymbol(OutContext), OutContext);
break;
case MachineJumpTableInfo::EK_GPRel32BlockAddress: {
// EK_GPRel32BlockAddress - Each entry is an address of block, encoded
// with a relocation as gp-relative, e.g.:
// .gprel32 LBB123
- MCSymbol *MBBSym = GetMBBSymbol(MBB->getNumber());
+ MCSymbol *MBBSym = MBB->getSymbol(OutContext);
OutStreamer.EmitGPRel32Value(MCSymbolRefExpr::Create(MBBSym, OutContext));
return;
}
@@ -587,7 +587,7 @@ void AsmPrinter::printPICJumpTableEntry(const MachineJumpTableInfo *MJTI,
break;
}
// Otherwise, use the difference as the jump table entry.
- Value = MCSymbolRefExpr::Create(GetMBBSymbol(MBB->getNumber()), OutContext);
+ Value = MCSymbolRefExpr::Create(MBB->getSymbol(OutContext), OutContext);
const MCExpr *JTI = MCSymbolRefExpr::Create(GetJTISymbol(uid), OutContext);
Value = MCBinaryExpr::CreateSub(Value, JTI, OutContext);
break;
@@ -1286,7 +1286,7 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const {
++OpNo; // Skip over the ID number.
if (Modifier[0] == 'l') // labels are target independent
- O << *GetMBBSymbol(MI->getOperand(OpNo).getMBB()->getNumber());
+ O << *MI->getOperand(OpNo).getMBB()->getSymbol(OutContext);
else {
AsmPrinter *AP = const_cast<AsmPrinter*>(this);
if ((OpFlags & 7) == 4) {
@@ -1386,13 +1386,6 @@ MCSymbol *AsmPrinter::GetBlockAddressSymbol(const Function *F,
return OutContext.GetOrCreateSymbol(NameResult.str());
}
-MCSymbol *AsmPrinter::GetMBBSymbol(unsigned MBBID) const {
- SmallString<60> Name;
- raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix() << "BB"
- << getFunctionNumber() << '_' << MBBID;
- return OutContext.GetOrCreateSymbol(Name.str());
-}
-
/// GetCPISymbol - Return the symbol for the specified constant pool entry.
MCSymbol *AsmPrinter::GetCPISymbol(unsigned CPID) const {
SmallString<60> Name;
@@ -1555,7 +1548,7 @@ void AsmPrinter::EmitBasicBlockStart(const MachineBasicBlock *MBB) const {
PrintBasicBlockLoopComments(*MBB, LI, *this);
}
- OutStreamer.EmitLabel(GetMBBSymbol(MBB->getNumber()));
+ OutStreamer.EmitLabel(MBB->getSymbol(OutContext));
}
}
@@ -1568,7 +1561,7 @@ void AsmPrinter::printPICJumpTableSetLabel(unsigned uid,
O << MAI->getSetDirective() << ' ' << MAI->getPrivateGlobalPrefix()
<< *GetJTSetSymbol(uid, MBB->getNumber()) << ','
- << *GetMBBSymbol(MBB->getNumber()) << '-' << *GetJTISymbol(uid) << '\n';
+ << *MBB->getSymbol(OutContext) << '-' << *GetJTISymbol(uid) << '\n';
}
void AsmPrinter::printVisibility(MCSymbol *Sym, unsigned Visibility) const {
diff --git a/lib/CodeGen/MachineBasicBlock.cpp b/lib/CodeGen/MachineBasicBlock.cpp
index 9215bd583b..9c318a5027 100644
--- a/lib/CodeGen/MachineBasicBlock.cpp
+++ b/lib/CodeGen/MachineBasicBlock.cpp
@@ -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;