[commit: ghc] master: Avoid local label syntax for assembler on AIX (343349d)

git at git.haskell.org git at git.haskell.org
Thu Mar 24 19:41:52 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/343349df1f19f21899818d647bf570e489d0cf8f/ghc

>---------------------------------------------------------------

commit 343349df1f19f21899818d647bf570e489d0cf8f
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date:   Thu Mar 24 20:35:42 2016 +0100

    Avoid local label syntax for assembler on AIX
    
    Unfortunately (for inline `__asm__()` uses), IBM's `as` doesn't seem to support
    local labels[1] like GNU `as` does so we need to workaround this when on AIX.
    
     [1]: https://sourceware.org/binutils/docs/as/Symbol-Names.html#Symbol-Names
    
    Turns out this also addresses the long-standing bug #485
    
    Reviewed By: bgamari, trommler
    
    Differential Revision: https://phabricator.haskell.org/D2029


>---------------------------------------------------------------

343349df1f19f21899818d647bf570e489d0cf8f
 includes/stg/SMP.h | 20 ++++++++++++++++++++
 rts/AdjustorAsm.S  | 14 +++++++++-----
 2 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/includes/stg/SMP.h b/includes/stg/SMP.h
index 756f040..21f05ed 100644
--- a/includes/stg/SMP.h
+++ b/includes/stg/SMP.h
@@ -121,9 +121,18 @@ xchg(StgPtr p, StgWord w)
         );
 #elif powerpc_HOST_ARCH
     __asm__ __volatile__ (
+# if aix_HOST_OS
+        /* IBM's assembler doesn't seem to support local labels so we use
+         * explicit relative numeric offsets to workaround this limitation
+         */
+        "       lwarx     %0, 0, %2\n"
+        "       stwcx.    %1, 0, %2\n"
+        "       bne-      $-8"
+# else // aix_HOST_OS
         "1:     lwarx     %0, 0, %2\n"
         "       stwcx.    %1, 0, %2\n"
         "       bne-      1b"
+# endif
         :"=&r" (result)
         :"r" (w), "r" (p)
     );
@@ -205,12 +214,23 @@ cas(StgVolatilePtr p, StgWord o, StgWord n)
 #elif powerpc_HOST_ARCH
     StgWord result;
     __asm__ __volatile__ (
+# if aix_HOST_OS
+        /* IBM's assembler doesn't seem to support local labels so we use
+         * explicit relative numeric offsets to workaround this limitation
+         */
+        "       lwarx     %0, 0, %3\n"
+        "       cmpw      %0, %1\n"
+        "       bne       $+12\n"
+        "       stwcx.    %2, 0, %3\n"
+        "       bne-      $-16\n"
+# else // aix_HOST_OS
         "1:     lwarx     %0, 0, %3\n"
         "       cmpw      %0, %1\n"
         "       bne       2f\n"
         "       stwcx.    %2, 0, %3\n"
         "       bne-      1b\n"
         "2:"
+# endif // !aix_HOST_OS
         :"=&r" (result)
         :"r" (o), "r" (n), "r" (p)
         :"cc", "memory"
diff --git a/rts/AdjustorAsm.S b/rts/AdjustorAsm.S
index ca7ae36..1713acb 100644
--- a/rts/AdjustorAsm.S
+++ b/rts/AdjustorAsm.S
@@ -63,8 +63,12 @@
 #define r31 31
 #endif
 
-
+#if defined(aix_HOST_OS)
+/* IBM's assembler needs a different pseudo-op to declare a .text section */
+.csect .text[PR]
+#else
 .text
+#endif
 #if LEADING_UNDERSCORE
     .globl _adjustorCode
 _adjustorCode:
@@ -101,14 +105,14 @@ adjustorCode:
 
     LOAD    r12, EXTRA_WORDS_OFF(r2)
     mtctr   r12
-    b       2f
-1:
+    b       L2
+L1:
     LOAD    r0, LINKAGE_AREA_SIZE +  8*WS(r30)
     STORE   r0, LINKAGE_AREA_SIZE + 10*WS(r31)
     addi    r30, r30, WS
     addi    r31, r31, WS
-2:
-    bdnz    1b
+L2:
+    bdnz    L1
 
         /* Restore r30 and r31 now.
         */



More information about the ghc-commits mailing list