diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2021-07-07 18:47:25 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-07-15 23:29:09 -0400 |
commit | 41d6cfc4d36ba93d82f16f9a83ea69f4e02c3810 (patch) | |
tree | 067308ecd598d42523238a96ac400a40edbe9f28 /compiler/GHC/CmmToAsm | |
parent | de98a0ce8f184c9653477ee41602f999c7a381e1 (diff) | |
download | haskell-41d6cfc4d36ba93d82f16f9a83ea69f4e02c3810.tar.gz |
Add Word64#/Int64# primops
Word64#/Int64# are only used on 32-bit architectures. Before this patch,
operations on these types were directly using the FFI. Now we use real
primops that are then lowered into ccalls.
The advantage of doing this is that we can now perform constant folding on
Word64#/Int64# (#19024).
Most of this work was done by John Ericson in !3658. However this patch
doesn't go as far as e.g. changing Word64 to always be using Word64#.
Noticeable performance improvements
T9203(normal) run/alloc 89870808.0 66662456.0 -25.8% GOOD
haddock.Cabal(normal) run/alloc 14215777340.8 12780374172.0 -10.1% GOOD
haddock.base(normal) run/alloc 15420020877.6 13643834480.0 -11.5% GOOD
Metric Decrease:
T9203
haddock.Cabal
haddock.base
Diffstat (limited to 'compiler/GHC/CmmToAsm')
-rw-r--r-- | compiler/GHC/CmmToAsm/AArch64/CodeGen.hs | 31 | ||||
-rw-r--r-- | compiler/GHC/CmmToAsm/PPC/CodeGen.hs | 33 | ||||
-rw-r--r-- | compiler/GHC/CmmToAsm/SPARC/CodeGen.hs | 30 | ||||
-rw-r--r-- | compiler/GHC/CmmToAsm/X86/CodeGen.hs | 30 |
4 files changed, 124 insertions, 0 deletions
diff --git a/compiler/GHC/CmmToAsm/AArch64/CodeGen.hs b/compiler/GHC/CmmToAsm/AArch64/CodeGen.hs index f637aeba90..19e5845a00 100644 --- a/compiler/GHC/CmmToAsm/AArch64/CodeGen.hs +++ b/compiler/GHC/CmmToAsm/AArch64/CodeGen.hs @@ -1281,6 +1281,37 @@ genCCall target dest_regs arg_regs bid = do MO_F32_Fabs -> mkCCall "fasbf" MO_F32_Sqrt -> mkCCall "sqrtf" + -- 64-bit primops + MO_I64_ToI -> mkCCall "hs_int64ToInt" + MO_I64_FromI -> mkCCall "hs_intToInt64" + MO_W64_ToW -> mkCCall "hs_word64ToWord" + MO_W64_FromW -> mkCCall "hs_wordToWord64" + MO_x64_Neg -> mkCCall "hs_neg64" + MO_x64_Add -> mkCCall "hs_add64" + MO_x64_Sub -> mkCCall "hs_sub64" + MO_x64_Mul -> mkCCall "hs_mul64" + MO_I64_Quot -> mkCCall "hs_quotInt64" + MO_I64_Rem -> mkCCall "hs_remInt64" + MO_W64_Quot -> mkCCall "hs_quotWord64" + MO_W64_Rem -> mkCCall "hs_remWord64" + MO_x64_And -> mkCCall "hs_and64" + MO_x64_Or -> mkCCall "hs_or64" + MO_x64_Xor -> mkCCall "hs_xor64" + MO_x64_Not -> mkCCall "hs_not64" + MO_x64_Shl -> mkCCall "hs_uncheckedShiftL64" + MO_I64_Shr -> mkCCall "hs_uncheckedIShiftRA64" + MO_W64_Shr -> mkCCall "hs_uncheckedShiftRL64" + MO_x64_Eq -> mkCCall "hs_eq64" + MO_x64_Ne -> mkCCall "hs_ne64" + MO_I64_Ge -> mkCCall "hs_geInt64" + MO_I64_Gt -> mkCCall "hs_gtInt64" + MO_I64_Le -> mkCCall "hs_leInt64" + MO_I64_Lt -> mkCCall "hs_ltInt64" + MO_W64_Ge -> mkCCall "hs_geWord64" + MO_W64_Gt -> mkCCall "hs_gtWord64" + MO_W64_Le -> mkCCall "hs_leWord64" + MO_W64_Lt -> mkCCall "hs_ltWord64" + -- Conversion MO_UF_Conv w -> mkCCall (word2FloatLabel w) diff --git a/compiler/GHC/CmmToAsm/PPC/CodeGen.hs b/compiler/GHC/CmmToAsm/PPC/CodeGen.hs index c821ea71a2..8ee20e06f5 100644 --- a/compiler/GHC/CmmToAsm/PPC/CodeGen.hs +++ b/compiler/GHC/CmmToAsm/PPC/CodeGen.hs @@ -2006,6 +2006,39 @@ genCCall' config gcp target dest_regs args MO_F64_Acosh -> (fsLit "acosh", False) MO_F64_Atanh -> (fsLit "atanh", False) + MO_I64_ToI -> (fsLit "hs_int64ToInt", False) + MO_I64_FromI -> (fsLit "hs_intToInt64", False) + MO_W64_ToW -> (fsLit "hs_word64ToWord", False) + MO_W64_FromW -> (fsLit "hs_wordToWord64", False) + + MO_x64_Neg -> (fsLit "hs_neg64", False) + MO_x64_Add -> (fsLit "hs_add64", False) + MO_x64_Sub -> (fsLit "hs_sub64", False) + MO_x64_Mul -> (fsLit "hs_mul64", False) + MO_I64_Quot -> (fsLit "hs_quotInt64", False) + MO_I64_Rem -> (fsLit "hs_remInt64", False) + MO_W64_Quot -> (fsLit "hs_quotWord64", False) + MO_W64_Rem -> (fsLit "hs_remWord64", False) + + MO_x64_And -> (fsLit "hs_and64", False) + MO_x64_Or -> (fsLit "hs_or64", False) + MO_x64_Xor -> (fsLit "hs_xor64", False) + MO_x64_Not -> (fsLit "hs_not64", False) + MO_x64_Shl -> (fsLit "hs_uncheckedShiftL64", False) + MO_I64_Shr -> (fsLit "hs_uncheckedIShiftRA64", False) + MO_W64_Shr -> (fsLit "hs_uncheckedShiftRL64", False) + + MO_x64_Eq -> (fsLit "hs_eq64", False) + MO_x64_Ne -> (fsLit "hs_ne64", False) + MO_I64_Ge -> (fsLit "hs_geInt64", False) + MO_I64_Gt -> (fsLit "hs_gtInt64", False) + MO_I64_Le -> (fsLit "hs_leInt64", False) + MO_I64_Lt -> (fsLit "hs_ltInt64", False) + MO_W64_Ge -> (fsLit "hs_geWord64", False) + MO_W64_Gt -> (fsLit "hs_gtWord64", False) + MO_W64_Le -> (fsLit "hs_leWord64", False) + MO_W64_Lt -> (fsLit "hs_ltWord64", False) + MO_UF_Conv w -> (word2FloatLabel w, False) MO_Memcpy _ -> (fsLit "memcpy", False) diff --git a/compiler/GHC/CmmToAsm/SPARC/CodeGen.hs b/compiler/GHC/CmmToAsm/SPARC/CodeGen.hs index 0a5152f425..56f764560c 100644 --- a/compiler/GHC/CmmToAsm/SPARC/CodeGen.hs +++ b/compiler/GHC/CmmToAsm/SPARC/CodeGen.hs @@ -658,6 +658,36 @@ outOfLineMachOp_table mop MO_F64_Acosh -> fsLit "acosh" MO_F64_Atanh -> fsLit "atanh" + MO_I64_ToI -> fsLit "hs_int64ToInt" + MO_I64_FromI -> fsLit "hs_intToInt64" + MO_W64_ToW -> fsLit "hs_word64ToWord" + MO_W64_FromW -> fsLit "hs_wordToWord64" + MO_x64_Neg -> fsLit "hs_neg64" + MO_x64_Add -> fsLit "hs_add64" + MO_x64_Sub -> fsLit "hs_sub64" + MO_x64_Mul -> fsLit "hs_mul64" + MO_I64_Quot -> fsLit "hs_quotInt64" + MO_I64_Rem -> fsLit "hs_remInt64" + MO_W64_Quot -> fsLit "hs_quotWord64" + MO_W64_Rem -> fsLit "hs_remWord64" + MO_x64_And -> fsLit "hs_and64" + MO_x64_Or -> fsLit "hs_or64" + MO_x64_Xor -> fsLit "hs_xor64" + MO_x64_Not -> fsLit "hs_not64" + MO_x64_Shl -> fsLit "hs_uncheckedShiftL64" + MO_I64_Shr -> fsLit "hs_uncheckedIShiftRA64" + MO_W64_Shr -> fsLit "hs_uncheckedShiftRL64" + MO_x64_Eq -> fsLit "hs_eq64" + MO_x64_Ne -> fsLit "hs_ne64" + MO_I64_Ge -> fsLit "hs_geInt64" + MO_I64_Gt -> fsLit "hs_gtInt64" + MO_I64_Le -> fsLit "hs_leInt64" + MO_I64_Lt -> fsLit "hs_ltInt64" + MO_W64_Ge -> fsLit "hs_geWord64" + MO_W64_Gt -> fsLit "hs_gtWord64" + MO_W64_Le -> fsLit "hs_leWord64" + MO_W64_Lt -> fsLit "hs_ltWord64" + MO_UF_Conv w -> word2FloatLabel w MO_Memcpy _ -> fsLit "memcpy" diff --git a/compiler/GHC/CmmToAsm/X86/CodeGen.hs b/compiler/GHC/CmmToAsm/X86/CodeGen.hs index 2fbe91dc34..ff25a2e53f 100644 --- a/compiler/GHC/CmmToAsm/X86/CodeGen.hs +++ b/compiler/GHC/CmmToAsm/X86/CodeGen.hs @@ -3388,6 +3388,36 @@ outOfLineCmmOp bid mop res args MO_F64_Acosh -> fsLit "acosh" MO_F64_Atanh -> fsLit "atanh" + MO_I64_ToI -> fsLit "hs_int64ToInt" + MO_I64_FromI -> fsLit "hs_intToInt64" + MO_W64_ToW -> fsLit "hs_word64ToWord" + MO_W64_FromW -> fsLit "hs_wordToWord64" + MO_x64_Neg -> fsLit "hs_neg64" + MO_x64_Add -> fsLit "hs_add64" + MO_x64_Sub -> fsLit "hs_sub64" + MO_x64_Mul -> fsLit "hs_mul64" + MO_I64_Quot -> fsLit "hs_quotInt64" + MO_I64_Rem -> fsLit "hs_remInt64" + MO_W64_Quot -> fsLit "hs_quotWord64" + MO_W64_Rem -> fsLit "hs_remWord64" + MO_x64_And -> fsLit "hs_and64" + MO_x64_Or -> fsLit "hs_or64" + MO_x64_Xor -> fsLit "hs_xor64" + MO_x64_Not -> fsLit "hs_not64" + MO_x64_Shl -> fsLit "hs_uncheckedShiftL64" + MO_I64_Shr -> fsLit "hs_uncheckedIShiftRA64" + MO_W64_Shr -> fsLit "hs_uncheckedShiftRL64" + MO_x64_Eq -> fsLit "hs_eq64" + MO_x64_Ne -> fsLit "hs_ne64" + MO_I64_Ge -> fsLit "hs_geInt64" + MO_I64_Gt -> fsLit "hs_gtInt64" + MO_I64_Le -> fsLit "hs_leInt64" + MO_I64_Lt -> fsLit "hs_ltInt64" + MO_W64_Ge -> fsLit "hs_geWord64" + MO_W64_Gt -> fsLit "hs_gtWord64" + MO_W64_Le -> fsLit "hs_leWord64" + MO_W64_Lt -> fsLit "hs_ltWord64" + MO_Memcpy _ -> fsLit "memcpy" MO_Memset _ -> fsLit "memset" MO_Memmove _ -> fsLit "memmove" |