aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-01-26 06:42:44 +0000
committerChris Lattner <sabre@nondot.org>2010-01-26 06:42:44 +0000
commit3b131d7cc4dc4bbb329c136705b37dc255995fbd (patch)
tree7eb571a8ace17463b8947c41013c32489e3ec9c1
parent589c6f620e8dcf3d59af1ae0e15372c934647c82 (diff)
Now that printPICJumpTableSetLabel is not overloaded,
inline it into its only caller, allowing us to simplify it and hoist bits out of the loop. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94528 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/CodeGen/AsmPrinter.h5
-rw-r--r--lib/CodeGen/AsmPrinter/AsmPrinter.cpp40
2 files changed, 18 insertions, 27 deletions
diff --git a/include/llvm/CodeGen/AsmPrinter.h b/include/llvm/CodeGen/AsmPrinter.h
index 09a5cd89b6..8607281261 100644
--- a/include/llvm/CodeGen/AsmPrinter.h
+++ b/include/llvm/CodeGen/AsmPrinter.h
@@ -348,11 +348,6 @@ namespace llvm {
/// printKill - This method prints the specified kill machine instruction.
void printKill(const MachineInstr *MI) const;
- /// printPICJumpTableSetLabel - This method prints a set label for the
- /// specified MachineBasicBlock for a jumptable entry.
- virtual void printPICJumpTableSetLabel(unsigned uid,
- const MachineBasicBlock *MBB) const;
-
/// printVisibility - This prints visibility information about symbol, if
/// this is suported by the target.
void printVisibility(MCSymbol *Sym, unsigned Visibility) const;
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 6676289e1a..a91ab22ce1 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -505,8 +505,8 @@ void AsmPrinter::EmitJumpTableInfo(MachineFunction &MF) {
EmitAlignment(Log2_32(MJTI->getEntryAlignment(*TM.getTargetData())));
- for (unsigned i = 0, e = JT.size(); i != e; ++i) {
- const std::vector<MachineBasicBlock*> &JTBBs = JT[i].MBBs;
+ for (unsigned JTI = 0, e = JT.size(); JTI != e; ++JTI) {
+ const std::vector<MachineBasicBlock*> &JTBBs = JT[JTI].MBBs;
// If this jump table was deleted, ignore it.
if (JTBBs.empty()) continue;
@@ -516,11 +516,19 @@ void AsmPrinter::EmitJumpTableInfo(MachineFunction &MF) {
// relocations the assembler will generate for the jump table.
if (MJTI->getEntryKind() == MachineJumpTableInfo::EK_LabelDifference32 &&
MAI->getSetDirective()) {
- SmallPtrSet<MachineBasicBlock*, 16> EmittedSets;
- for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii)
- if (EmittedSets.insert(JTBBs[ii]))
- printPICJumpTableSetLabel(i, JTBBs[ii]);
- }
+ SmallPtrSet<const MachineBasicBlock*, 16> EmittedSets;
+ const TargetLowering *TLI = TM.getTargetLowering();
+ const MCExpr *Base = TLI->getPICJumpTableRelocBaseExpr(&MF, JTI,
+ OutContext);
+ for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii) {
+ const MachineBasicBlock *MBB = JTBBs[ii];
+ if (!EmittedSets.insert(MBB)) continue;
+
+ O << MAI->getSetDirective() << ' '
+ << *GetJTSetSymbol(JTI, MBB->getNumber()) << ','
+ << *MBB->getSymbol(OutContext) << '-' << *Base << '\n';
+ }
+ }
// On some targets (e.g. Darwin) we want to emit two consequtive labels
// before each jump table. The first label is never referenced, but tells
@@ -529,12 +537,12 @@ void AsmPrinter::EmitJumpTableInfo(MachineFunction &MF) {
if (JTInDiffSection && MAI->getLinkerPrivateGlobalPrefix()[0])
// FIXME: This doesn't have to have any specific name, just any randomly
// named and numbered 'l' label would work. Simplify GetJTISymbol.
- OutStreamer.EmitLabel(GetJTISymbol(i, true));
+ OutStreamer.EmitLabel(GetJTISymbol(JTI, true));
- OutStreamer.EmitLabel(GetJTISymbol(i));
+ OutStreamer.EmitLabel(GetJTISymbol(JTI));
for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii)
- EmitJumpTableEntry(MJTI, JTBBs[ii], i);
+ EmitJumpTableEntry(MJTI, JTBBs[ii], JTI);
}
}
@@ -1542,18 +1550,6 @@ void AsmPrinter::EmitBasicBlockStart(const MachineBasicBlock *MBB) const {
}
}
-/// printPICJumpTableSetLabel - This method prints a set label for the
-/// specified MachineBasicBlock for a jumptable entry.
-void AsmPrinter::printPICJumpTableSetLabel(unsigned uid,
- const MachineBasicBlock *MBB) const {
- const TargetLowering *TLI = TM.getTargetLowering();
- O << MAI->getSetDirective() << ' ' << MAI->getPrivateGlobalPrefix()
- << *GetJTSetSymbol(uid, MBB->getNumber()) << ','
- << *MBB->getSymbol(OutContext) << '-'
- << *TLI->getPICJumpTableRelocBaseExpr(MF, uid, OutContext)
- << '\n';
-}
-
void AsmPrinter::printVisibility(MCSymbol *Sym, unsigned Visibility) const {
MCSymbolAttr Attr = MCSA_Invalid;