add new JumpTableSpecialLabelPrefix hook to asmprinter for jumptable emission.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33314 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter.cpp
index caa9da0..a9e7201 100644
--- a/lib/CodeGen/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter.cpp
@@ -244,6 +244,13 @@
         if (EmittedSets.insert(JTBBs[ii]).second)
           printSetLabel(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
+    // the assembler and linker the extents of the jump table object.  The
+    // second label is actually referenced by the code.
+    if (const char *JTLabelPrefix = TAI->getJumpTableSpecialLabelPrefix())
+      O << JTLabelPrefix << "JTI" << getFunctionNumber() << '_' << i << ":\n";
+    
     O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() 
       << '_' << i << ":\n";
     
@@ -259,7 +266,8 @@
           << '_' << i << "_set_" << JTBBs[ii]->getNumber();
       } else if (IsPic) {
         printBasicBlockLabel(JTBBs[ii], false, false);
-        //If the arch uses custom Jump Table directives, don't calc relative to JT
+        // If the arch uses custom Jump Table directives, don't calc relative to
+        // JT
         if (!HadJTEntryDirective) 
           O << '-' << TAI->getPrivateGlobalPrefix() << "JTI"
             << getFunctionNumber() << '_' << i;
diff --git a/lib/Target/TargetAsmInfo.cpp b/lib/Target/TargetAsmInfo.cpp
index 3afbddb..45ea0ee 100644
--- a/lib/Target/TargetAsmInfo.cpp
+++ b/lib/Target/TargetAsmInfo.cpp
@@ -28,6 +28,7 @@
   CommentString("#"),
   GlobalPrefix(""),
   PrivateGlobalPrefix("."),
+  JumpTableSpecialLabelPrefix(0),
   GlobalVarAddrPrefix(""),
   GlobalVarAddrSuffix(""),
   FunctionAddrPrefix(""),