summaryrefslogtreecommitdiff
path: root/libraries
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2021-10-06 13:35:49 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-10-07 20:20:01 -0400
commit4d44058d63182963b3cab069dd5e8975ef06b91a (patch)
tree3fc452976d52f94a4bc2bd3c9b3aa8ad316de136 /libraries
parent714568bb9e6fed883eb773435f71e075ac33b120 (diff)
downloadhaskell-4d44058d63182963b3cab069dd5e8975ef06b91a.tar.gz
Bignum: transfer NOINLINE from Natural to BigNat
Diffstat (limited to 'libraries')
-rw-r--r--libraries/ghc-bignum/src/GHC/Num/BigNat.hs9
-rw-r--r--libraries/ghc-bignum/src/GHC/Num/Natural.hs4
2 files changed, 9 insertions, 4 deletions
diff --git a/libraries/ghc-bignum/src/GHC/Num/BigNat.hs b/libraries/ghc-bignum/src/GHC/Num/BigNat.hs
index 7749ffcbcd..b6afc533fb 100644
--- a/libraries/ghc-bignum/src/GHC/Num/BigNat.hs
+++ b/libraries/ghc-bignum/src/GHC/Num/BigNat.hs
@@ -1228,6 +1228,7 @@ bigNatCtzWord a = W# (bigNatCtzWord# a)
-- written in advance. In case of @/i/ == 0@, the function will write and report
-- zero bytes written.
bigNatToAddrLE# :: BigNat# -> Addr# -> State# s -> (# State# s, Word# #)
+{-# NOINLINE bigNatToAddrLE# #-}
bigNatToAddrLE# a addr s0
| isTrue# (sz ==# 0#) = (# s0, 0## #)
| True = case writeMSB s0 of
@@ -1257,6 +1258,7 @@ bigNatToAddrLE# a addr s0
-- written in advance. In case of @/i/ == 0@, the function will write and report
-- zero bytes written.
bigNatToAddrBE# :: BigNat# -> Addr# -> State# s -> (# State# s, Word# #)
+{-# NOINLINE bigNatToAddrBE# #-}
bigNatToAddrBE# a addr s0
| isTrue# (sz ==# 0#) = (# s0, 0## #)
| msw <- indexWordArray# a (sz -# 1#)
@@ -1316,6 +1318,7 @@ bigNatToAddr a addr e = IO \s -> case bigNatToAddr# a addr e s of
--
-- Higher limbs equal to 0 are automatically trimmed.
bigNatFromAddrLE# :: Word# -> Addr# -> State# s -> (# State# s, BigNat# #)
+{-# NOINLINE bigNatFromAddrLE# #-}
bigNatFromAddrLE# 0## _ s = (# s, bigNatZero# (# #) #)
bigNatFromAddrLE# sz addr s =
let
@@ -1351,6 +1354,7 @@ bigNatFromAddrLE# sz addr s =
--
-- Null higher limbs are automatically trimmed.
bigNatFromAddrBE# :: Word# -> Addr# -> State# s -> (# State# s, BigNat# #)
+{-# NOINLINE bigNatFromAddrBE# #-}
bigNatFromAddrBE# 0## _ s = (# s, bigNatZero# (# #) #)
bigNatFromAddrBE# sz addr s =
let
@@ -1405,6 +1409,7 @@ bigNatFromAddr# sz addr _ s = bigNatFromAddrBE# sz addr s
-- written in advance. In case of @/i/ == 0@, the function will write and report
-- zero bytes written.
bigNatToMutableByteArrayLE# :: BigNat# -> MutableByteArray# s -> Word# -> State# s -> (# State# s, Word# #)
+{-# NOINLINE bigNatToMutableByteArrayLE# #-}
bigNatToMutableByteArrayLE# a mba moff s0
| isTrue# (sz ==# 0#) = (# s0, 0## #)
| True = case writeMSB s0 of
@@ -1434,6 +1439,7 @@ bigNatToMutableByteArrayLE# a mba moff s0
-- written in advance. In case of @/i/ == 0@, the function will write and report
-- zero bytes written.
bigNatToMutableByteArrayBE# :: BigNat# -> MutableByteArray# s -> Word# -> State# s -> (# State# s, Word# #)
+{-# NOINLINE bigNatToMutableByteArrayBE# #-}
bigNatToMutableByteArrayBE# a mba moff s0
| isTrue# (sz ==# 0#) = (# s0, 0## #)
| msw <- indexWordArray# a (sz -# 1#)
@@ -1477,6 +1483,7 @@ bigNatToMutableByteArray# a mba off _ s = bigNatToMutableByteArrayBE# a mba off
--
-- Null higher limbs are automatically trimmed.
bigNatFromByteArrayLE# :: Word# -> ByteArray# -> Word# -> State# s -> (# State# s, BigNat# #)
+{-# NOINLINE bigNatFromByteArrayLE# #-}
bigNatFromByteArrayLE# 0## _ _ s = (# s, bigNatZero# (# #) #)
bigNatFromByteArrayLE# sz ba moff s =
let
@@ -1512,6 +1519,7 @@ bigNatFromByteArrayLE# sz ba moff s =
--
-- Null higher limbs are automatically trimmed.
bigNatFromByteArrayBE# :: Word# -> ByteArray# -> Word# -> State# s -> (# State# s, BigNat# #)
+{-# NOINLINE bigNatFromByteArrayBE# #-}
bigNatFromByteArrayBE# 0## _ _ s = (# s, bigNatZero# (# #) #)
bigNatFromByteArrayBE# sz ba moff s =
let
@@ -1564,6 +1572,7 @@ bigNatFromByteArray# sz ba off _ s = bigNatFromByteArrayBE# sz ba off s
-- If possible 'WordArray#', will be used directly (i.e. shared
-- /without/ cloning the 'WordArray#' into a newly allocated one)
bigNatFromWordArray# :: WordArray# -> Word# -> BigNat#
+{-# NOINLINE bigNatFromWordArray# #-}
bigNatFromWordArray# wa n0
| isTrue# (n `eqWord#` 0##)
= bigNatZero# (# #)
diff --git a/libraries/ghc-bignum/src/GHC/Num/Natural.hs b/libraries/ghc-bignum/src/GHC/Num/Natural.hs
index bf83b01a71..72b646501d 100644
--- a/libraries/ghc-bignum/src/GHC/Num/Natural.hs
+++ b/libraries/ghc-bignum/src/GHC/Num/Natural.hs
@@ -510,7 +510,6 @@ naturalSizeInBase# base (NB n) = bigNatSizeInBase# base n
-- byte first (big-endian) if @1#@ or least significant byte first
-- (little-endian) if @0#@.
naturalToAddr# :: Natural -> Addr# -> Bool# -> State# s -> (# State# s, Word# #)
-{-# NOINLINE naturalToAddr# #-}
naturalToAddr# (NS i) = wordToAddr# i
naturalToAddr# (NB n) = bigNatToAddr# n
@@ -535,7 +534,6 @@ naturalToAddr a addr e = IO \s -> case naturalToAddr# a addr e s of
--
-- Null higher limbs are automatically trimed.
naturalFromAddr# :: Word# -> Addr# -> Bool# -> State# s -> (# State# s, Natural #)
-{-# NOINLINE naturalFromAddr# #-}
naturalFromAddr# sz addr e s =
case bigNatFromAddr# sz addr e s of
(# s', n #) -> (# s', naturalFromBigNat# n #)
@@ -560,7 +558,6 @@ naturalFromAddr sz addr e = IO (naturalFromAddr# sz addr e)
-- byte first (big-endian) if @1#@ or least significant byte first
-- (little-endian) if @0#@.
naturalToMutableByteArray# :: Natural -> MutableByteArray# s -> Word# -> Bool# -> State# s -> (# State# s, Word# #)
-{-# NOINLINE naturalToMutableByteArray# #-}
naturalToMutableByteArray# (NS w) = wordToMutableByteArray# w
naturalToMutableByteArray# (NB a) = bigNatToMutableByteArray# a
@@ -574,7 +571,6 @@ naturalToMutableByteArray# (NB a) = bigNatToMutableByteArray# a
--
-- Null higher limbs are automatically trimed.
naturalFromByteArray# :: Word# -> ByteArray# -> Word# -> Bool# -> State# s -> (# State# s, Natural #)
-{-# NOINLINE naturalFromByteArray# #-}
naturalFromByteArray# sz ba off e s = case bigNatFromByteArray# sz ba off e s of
(# s', a #) -> (# s', naturalFromBigNat# a #)