Skip to content

Bringing back powerpc-apple-darwin support: WIP, advice needed

@trommler @bgamari I have made patches to revert the earlier removal of Darwin PPC support: 374e4470

I will appreciate some advice. Immediate issues:

patch-ppc-Ppr.diff should be changed in the following section to match new syntax, but how to do it correctly?

@@ -253,18 +293,42 @@
         where
           lo16 = fromInteger (i .&. 0xffff) :: Int16
 
-   LO i              -> pprImm platform i <> text "@l"
-   HI i              -> pprImm platform i <> text "@h"
-   HA (ImmInt i)     -> pprImm platform (HA (ImmInteger (toInteger i)))
-   HA (ImmInteger i) -> pprImm platform (ImmInteger ha16)
-        where
-          ha16 = if lo16 >= 0x8000 then hi16+1 else hi16
-          hi16 = (i `shiftR` 16)
-          lo16 = i .&. 0xffff
-
-   HA i        -> pprImm platform i <> text "@ha"
-   HIGHERA i   -> pprImm platform i <> text "@highera"
-   HIGHESTA i  -> pprImm platform i <> text "@highesta"
+pprImm (LO i)
+  = sdocWithPlatform $ \platform ->
+    if platformOS platform == OSDarwin
+    then hcat [ text "lo16(", pprImm i, rparen ]
+    else pprImm i <> text "@l"
+
+pprImm (HI i)
+  = sdocWithPlatform $ \platform ->
+    if platformOS platform == OSDarwin
+    then hcat [ text "hi16(", pprImm i, rparen ]
+    else pprImm i <> text "@h"
+
+pprImm (HA (ImmInt i))     = pprImm (HA (ImmInteger (toInteger i)))
+pprImm (HA (ImmInteger i)) = pprImm (ImmInteger ha16)
+  where
+    ha16 = if lo16 >= 0x8000 then hi16+1 else hi16
+    hi16 = (i `shiftR` 16)
+    lo16 = i .&. 0xffff
+
+pprImm (HA i)
+  = sdocWithPlatform $ \platform ->
+    if platformOS platform == OSDarwin
+    then hcat [ text "ha16(", pprImm i, rparen ]
+    else pprImm i <> text "@ha"
+
+pprImm (HIGHERA i)
+  = sdocWithPlatform $ \platform ->
+    if platformOS platform == OSDarwin
+    then panic "PPC.pprImm: highera not implemented on Darwin"
+    else pprImm i <> text "@highera"
+
+pprImm (HIGHESTA i)
+  = sdocWithPlatform $ \platform ->
+    if platformOS platform == OSDarwin
+    then panic "PPC.pprImm: highesta not implemented on Darwin"
+    else pprImm i <> text "@highesta"
  1. patch-PPC_Darwin.diff is in fact an added back file, does it integrate as-is?

  2. I am unsure if llvm-targets file is something essential, but I do not understand special syntax it uses (in addition to standard triples).

I will look through in more detail into portions of pre-8.6.x code that may be ppc-relevant and see if something extra can/has to be restored. In the meanwhile, any suggestions are greatly appreciated.

P. S. As far as I understand, I need to cross-compile on x86_64 first in any case to build ghc-boot for a native ppc compiler. I am thinking to do it on 10.6.8 which supports compilation for Intel and PowerPC both out-of-the-box. Are there any important but non-obvious points to consider?PPC_patches_v1.zip

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information