Handle ARM constant pool values that need an explicit reference to the '.'
authorJim Grosbach <grosbach@apple.com>
Tue, 9 Nov 2010 19:40:22 +0000 (19:40 +0000)
committerJim Grosbach <grosbach@apple.com>
Tue, 9 Nov 2010 19:40:22 +0000 (19:40 +0000)
pseudo-label. (TLS stuff).

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

lib/Target/ARM/ARMAsmPrinter.cpp

index 5672bff7e94f5995f97c03bf068bc2081a2c6189..30823d7018783ce34b3a80ca637c63859dff539f 100644 (file)
@@ -666,7 +666,7 @@ EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) {
     Twine Text(DataDirective, OS.str());
     OutStreamer.EmitRawText(Text);
   } else {
-    assert(!ACPV->hasModifier() && !ACPV->mustAddCurrentAddress() &&
+    assert(!ACPV->hasModifier() &&
            "ARM binary streamer of non-trivial constant pool value!");
     if (ACPV->getPCAdjustment()) {
       MCSymbol *PCLabel = getPICLabel(MAI->getPrivateGlobalPrefix(),
@@ -679,6 +679,14 @@ EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) {
                                 MCConstantExpr::Create(ACPV->getPCAdjustment(),
                                                        OutContext),
                                 OutContext);
+      if (ACPV->mustAddCurrentAddress()) {
+        // We want "(<expr> - .)", but MC doesn't have a concept of the '.'
+        // label, so just emit a local label end reference that instead.
+        MCSymbol *DotSym = OutContext.CreateTempSymbol();
+        OutStreamer.EmitLabel(DotSym);
+        const MCExpr *DotExpr = MCSymbolRefExpr::Create(DotSym, OutContext);
+        Expr = MCBinaryExpr::CreateSub(Expr, DotExpr, OutContext);
+      }
       Expr = MCBinaryExpr::CreateSub(Expr, PCRelExpr, OutContext);
     }
     OutStreamer.EmitValue(Expr, Size);