Commit e02a4c27 authored by Erik de Castro Lopo's avatar Erik de Castro Lopo

Fix build for AArch64/Arm64

Test Plan: Build an AArch64 cross compiler.

Reviewers: hvr, bgamari, austin

Reviewed By: bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D1654
parent 0e9a331f
......@@ -57,6 +57,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
......@@ -73,6 +74,10 @@ platform =
ArchAlpha
#elif defined(arm_HOST_ARCH)
ArchARM
#elif defined(aarch64_HOST_ARCH)
ArchARM64
#else
#error Unknown architecture
#endif
mkJumpToAddr :: EntryFunPtr -> ItblCodes
......@@ -176,6 +181,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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment