[commit: ghc] wip/aarch64-regd: Implement AArch64 codegen in `mkJumpToAddr` (for GHCi) (686720d)

git at git.haskell.org git at git.haskell.org
Thu Dec 17 21:53:41 UTC 2015


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

On branch  : wip/aarch64-regd
Link       : http://ghc.haskell.org/trac/ghc/changeset/686720d4f64e7c2244b446697a918c2832db6a65/ghc

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

commit 686720d4f64e7c2244b446697a918c2832db6a65
Author: Erik de Castro Lopo <erikd at mega-nerd.com>
Date:   Thu Dec 17 20:45:17 2015 +1100

    Implement AArch64 codegen in `mkJumpToAddr` (for GHCi)


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

686720d4f64e7c2244b446697a918c2832db6a65
 libraries/ghci/GHCi/InfoTable.hsc | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/libraries/ghci/GHCi/InfoTable.hsc b/libraries/ghci/GHCi/InfoTable.hsc
index d9d6314..cbd58a4 100644
--- a/libraries/ghci/GHCi/InfoTable.hsc
+++ b/libraries/ghci/GHCi/InfoTable.hsc
@@ -54,6 +54,7 @@ funPtrToInt :: FunPtr a -> Int
 funPtrToInt (FunPtr a) = I## (addr2Int## a)
 
 data Arch = ArchSPARC | ArchPPC | ArchX86 | ArchX86_64 | ArchAlpha | ArchARM
+ | ArchARM64
  deriving Show
 
 platform :: Arch
@@ -70,6 +71,8 @@ platform =
        ArchAlpha
 #elif defined(arm_HOST_ARCH)
        ArchARM
+#elif defined(aarch64_HOST_ARCH)
+       ArchARM64
 #endif
 
 mkJumpToAddr :: EntryFunPtr -> ItblCodes
@@ -173,6 +176,22 @@ mkJumpToAddr a = case platform of
                 , 0x11, 0xff, 0x2f, 0xe1
                 , byte0 w32, byte1 w32, byte2 w32, byte3 w32]
 
+    ArchARM64 { } ->
+        -- Generates:
+        --
+        --      ldr     x1, label
+        --      br      x1
+        -- label:
+        --      .quad <addr>
+        --
+        -- which looks like:
+        --     0:       58000041        ldr     x1, <label>
+        --     4:       d61f0020        br      x1
+       let w64 = fromIntegral (funPtrToInt a) :: Word64
+       in Right [ 0x58000041
+                , 0xd61f0020
+                , fromIntegral w64
+                , fromIntegral (w64 `shiftR` 32) ]
 
 byte0 :: (Integral w) => w -> Word8
 byte0 w = fromIntegral w



More information about the ghc-commits mailing list