[llvm-commits] [llvm] r94446 - in /llvm/trunk/lib: CodeGen/AsmPrinter/AsmPrinter.cpp Target/X86/AsmPrinter/X86AsmPrinter.cpp

Chris Lattner sabre at nondot.org
Mon Jan 25 13:01:59 PST 2010


Author: lattner
Date: Mon Jan 25 15:01:58 2010
New Revision: 94446

URL: http://llvm.org/viewvc/llvm-project?rev=94446&view=rev
Log:
pull the non-pic jump table case out of printPICJumpTableEntry
and MCize the non-pic case.  Now printPICJumpTableEntry really
is just about printing PIC entries.

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
    llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=94446&r1=94445&r2=94446&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Mon Jan 25 15:01:58 2010
@@ -524,9 +524,16 @@
 
     OutStreamer.EmitLabel(GetJTISymbol(i));
 
-    for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii) {
-      printPICJumpTableEntry(MJTI, JTBBs[ii], i);
-      O << '\n';
+    if (!IsPic) {
+      unsigned EntrySize = MJTI->getEntrySize();
+      for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii) {
+        MCSymbol *MBBSym = GetMBBSymbol(JTBBs[ii]->getNumber());
+        OutStreamer.EmitValue(MCSymbolRefExpr::Create(MBBSym, OutContext),
+                              EntrySize, /*addrspace*/0);
+      }      
+    } else {
+      for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii)
+        printPICJumpTableEntry(MJTI, JTBBs[ii], i);
     }
   }
 }
@@ -534,12 +541,9 @@
 void AsmPrinter::printPICJumpTableEntry(const MachineJumpTableInfo *MJTI,
                                         const MachineBasicBlock *MBB,
                                         unsigned uid)  const {
-  bool isPIC = TM.getRelocationModel() == Reloc::PIC_;
-  
   // Use JumpTableDirective otherwise honor the entry size from the jump table
   // info.
-  const char *JTEntryDirective = 0;
-  if (isPIC) JTEntryDirective = MAI->getPICJumpTableDirective();
+  const char *JTEntryDirective = MAI->getPICJumpTableDirective();
   bool HadJTEntryDirective = JTEntryDirective != NULL;
   if (!HadJTEntryDirective) {
     JTEntryDirective = MJTI->getEntrySize() == 4 ?
@@ -553,9 +557,7 @@
   // emit the table entries as differences between two text section labels.
   // If we're emitting non-PIC code, then emit the entries as direct
   // references to the target basic blocks.
-  if (!isPIC) {
-    O << *GetMBBSymbol(MBB->getNumber());
-  } else if (MAI->getSetDirective()) {
+  if (MAI->getSetDirective()) {
     O << MAI->getPrivateGlobalPrefix() << getFunctionNumber()
       << '_' << uid << "_set_" << MBB->getNumber();
   } else {
@@ -565,6 +567,7 @@
     if (!HadJTEntryDirective) 
       O << '-' << *GetJTISymbol(uid);
   }
+  O << '\n';
 }
 
 

Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp?rev=94446&r1=94445&r2=94446&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Mon Jan 25 15:01:58 2010
@@ -498,8 +498,9 @@
       << '_' << uid << "_set_" << MBB->getNumber();
   } else if (Subtarget->isPICStyleGOT())
     O << *GetMBBSymbol(MBB->getNumber()) << "@GOTOFF";
-  else
+  else  // mdynamic-no-pic
     O << *GetMBBSymbol(MBB->getNumber());
+  O << '\n';
 }
 
 bool X86AsmPrinter::printAsmMRegister(const MachineOperand &MO, char Mode) {





More information about the llvm-commits mailing list