emit jump table an alias ".set" directives through MCStreamer as
authorChris Lattner <sabre@nondot.org>
Tue, 26 Jan 2010 21:53:08 +0000 (21:53 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 26 Jan 2010 21:53:08 +0000 (21:53 +0000)
assignments.

.set x, a-b

is the same as:

x = a-b

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

lib/CodeGen/AsmPrinter/AsmPrinter.cpp
lib/CodeGen/AsmPrinter/DwarfPrinter.cpp
test/CodeGen/ARM/aliases.ll
test/CodeGen/X86/aliases.ll

index d2c1721012a6ef779d1483a8adcd9625eb57abd6..50e88773e8b645bb37e032347fe10f5e923705b3 100644 (file)
@@ -336,7 +336,9 @@ bool AsmPrinter::doFinalization(Module &M) {
 
       printVisibility(Name, I->getVisibility());
 
-      O << "\t.set\t" << *Name << ", " << *Target << '\n';
+      // Emit the directives as assignments aka .set:
+      OutStreamer.EmitAssignment(Name, 
+                                 MCSymbolRefExpr::Create(Target, OutContext));
     }
   }
 
@@ -525,9 +527,11 @@ void AsmPrinter::EmitJumpTableInfo(MachineFunction &MF) {
         const MachineBasicBlock *MBB = JTBBs[ii];
         if (!EmittedSets.insert(MBB)) continue;
         
-        O << "\t.set\t"
-          << *GetJTSetSymbol(JTI, MBB->getNumber()) << ','
-          << *MBB->getSymbol(OutContext) << '-' << *Base << '\n';
+        // .set LJTSet, LBB32-base
+        const MCExpr *LHS =
+          MCSymbolRefExpr::Create(MBB->getSymbol(OutContext), OutContext);
+        OutStreamer.EmitAssignment(GetJTSetSymbol(JTI, MBB->getNumber()),
+                                MCBinaryExpr::CreateSub(LHS, Base, OutContext));
       }
     }          
     
index f659c51908b106680dd5c3e369ddefb710df65b8..415390bc2817fabf7a11b17c164ddf3cb17ccbcc 100644 (file)
@@ -201,6 +201,7 @@ void DwarfPrinter::EmitDifference(const char *TagHi, unsigned NumberHi,
                                   const char *TagLo, unsigned NumberLo,
                                   bool IsSmall) {
   if (MAI->hasSetDirective()) {
+    // FIXME: switch to OutStreamer.EmitAssignment.
     O << "\t.set\t";
     PrintLabelName("set", SetCounter, Flavor);
     O << ",";
@@ -232,6 +233,7 @@ void DwarfPrinter::EmitSectionOffset(const char* Label, const char* Section,
     printAbsolute = MAI->isAbsoluteDebugSectionOffsets();
 
   if (MAI->hasSetDirective() && useSet) {
+    // FIXME: switch to OutStreamer.EmitAssignment.
     O << "\t.set\t";
     PrintLabelName("set", SetCounter, Flavor);
     O << ",";
index b2c03147740bad71d0e5638eced7b9bbe01d0844..31c500756c4ed5cf4970d4b520ed4631004b1ea8 100644 (file)
@@ -1,5 +1,5 @@
 ; RUN: llc < %s -mtriple=arm-linux-gnueabi -o %t
-; RUN: grep set %t   | count 5
+; RUN: grep { = } %t   | count 5
 ; RUN: grep globl %t | count 4
 ; RUN: grep weak %t  | count 1
 
index a71aa922227053977fbebbcaf5d2085f9f664147..3020eb3c7192b55244ea6a343037cd21f52c988b 100644 (file)
@@ -1,5 +1,6 @@
 ; RUN: llc < %s -mtriple=i686-pc-linux-gnu -asm-verbose=false -o %t
-; RUN: grep set %t   | count 23
+; RUN: grep { = } %t   | count 7
+; RUN: grep set %t   | count 16
 ; RUN: grep globl %t | count 6
 ; RUN: grep weak %t  | count 1
 ; RUN: grep hidden %t | count 1