simplify asmprinter: only emit .set directives when entries have
authorChris Lattner <sabre@nondot.org>
Tue, 26 Jan 2010 05:15:20 +0000 (05:15 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 26 Jan 2010 05:15:20 +0000 (05:15 +0000)
EK_LabelDifference32 kind and the target has .set support.  Simplify
X86AsmPrinter::printPICJumpTableSetLabel to make use of recent helpers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94518 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter/AsmPrinter.cpp
lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp

index 1b58f1ab00f9c18dad57902e7725c1ab521e4954..c1b45c3917cc2521095c7d6c5986f4859745a456 100644 (file)
@@ -511,14 +511,16 @@ void AsmPrinter::EmitJumpTableInfo(MachineFunction &MF) {
     // If this jump table was deleted, ignore it. 
     if (JTBBs.empty()) continue;
 
-    // For PIC codegen, if possible we want to use the SetDirective to reduce
-    // the number of relocations the assembler will generate for the jump table.
-    // Set directives are all printed before the jump table itself.
-    SmallPtrSet<MachineBasicBlock*, 16> EmittedSets;
-    if (MAI->getSetDirective() && IsPic)
+    // For the EK_LabelDifference32 entry, if the target supports .set, emit a
+    // .set directive for each unique entry.  This reduces the number of
+    // 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]);
+    }
     
     // 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
index cc1241390206b7adeec0497cd6d848f236b255a8..9f1424b7cbc4f3fb42a753c9a1975b207a158c6e 100644 (file)
@@ -455,17 +455,8 @@ void X86AsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op,
 
 void X86AsmPrinter::printPICJumpTableSetLabel(unsigned uid,
                                            const MachineBasicBlock *MBB) const {
-  if (!MAI->getSetDirective())
-    return;
-
-  // We don't need .set machinery if we have GOT-style relocations
-  if (Subtarget->isPICStyleGOT())  // X86-32 on ELF.
-    return;
-
-  O << MAI->getSetDirective() << ' ' << MAI->getPrivateGlobalPrefix()
-    << getFunctionNumber() << '_' << uid << "_set_" << MBB->getNumber() << ',';
-  
-  O << *MBB->getSymbol(OutContext);
+  O << MAI->getSetDirective() << ' ' << *GetJTSetSymbol(uid, MBB->getNumber())
+    << ',' << *MBB->getSymbol(OutContext);
   
   if (Subtarget->isPICStyleRIPRel())
     O << '-' << *GetJTISymbol(uid) << '\n';