summaryrefslogtreecommitdiff
path: root/libraries/ghc-bignum
Commit message (Collapse)AuthorAgeFilesLines
* ghc-bignum: Drop redundant include-dirs fieldBen Gamari2023-03-131-2/+0
|
* Bump gmp-tarballs submoduleBen Gamari2023-01-181-0/+0
| | | | This backports the upstream fix for CVE-2021-43618, fixing #22789.
* Bump ghc-tarballs to fix #22497Ben Gamari2023-01-181-0/+0
| | | | | | | | | | | It turns out that gmp 6.2.1 uses the platform-reserved `x18` register on AArch64/Darwin. This was fixed in upstream changeset 18164:5f32dbc41afc, which was merged in 2020. Here I backport this patch although I do hope that a new release is forthcoming soon. Bumps gmp-tarballs submodule. Fixes #22497.
* Bump gmp-tarballs submoduleCheng Shao2022-11-061-0/+0
| | | | Includes a fix for wasm support, doesn't impact other targets.
* Rename Solo[constructor] to MkSoloTorsten Schmits2022-09-211-1/+1
| | | | | | | | | | | Part of proposal 475 (https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst) Moves all tuples to GHC.Tuple.Prim Updates ghc-prim version (and bumps bounds in dependents) updates haddock submodule updates deepseq submodule updates text submodule
* Drop make build systemBen Gamari2022-08-251-141/+0
| | | | | | | | | | | Here we at long last remove the `make`-based build system, it having been replaced with the Shake-based Hadrian build system. Users are encouraged to refer to the documentation in `hadrian/doc` and this [1] blog post for details on using Hadrian. Closes #17527. [1] https://www.haskell.org/ghc/blog/20220805-make-to-hadrian.html
* Bump ghc-prim and base versionsBen Gamari2022-06-271-1/+1
| | | | | | | | | To 0.9.0 and 4.17.0 respectively. Bumps array, deepseq, directory, filepath, haskeline, hpc, parsec, stm, terminfo, text, unix, haddock, and hsc2hs submodules. (cherry picked from commit ba47b95122b7b336ce1cc00896a47b584ad24095)
* ghc-bignum: Tweak integerOrSimon Jakobi2022-03-111-2/+2
| | | | | | The result of ORing two BigNats is always greater or equal to the larger of the two. Therefore it is safe to skip the magnitude checks of integerFromBigNat#.
* Improve clearBit and complementBit for NaturalSimon Jakobi2022-03-113-4/+41
| | | | | | Also optimize bigNatComplementBit#. Fixes #21175, #21181, #21194.
* Improve setBit for NaturalSimon Jakobi2022-03-073-0/+13
| | | | | | | Previously the default definition was used, which involved allocating intermediate Natural values. Fixes #21173.
* Fix a few Note inconsistenciesBen Gamari2022-02-011-1/+0
|
* Bignum: expose backendName (#20495)Sylvain Henry2021-11-096-1/+25
|
* Make Word64 use Word64# on every architectureSylvain Henry2021-11-061-3/+1
|
* Remove target dependent CPP for Word64/Int64 (#11470)Sylvain Henry2021-11-062-17/+17
| | | | | | | | | | | | | | | | | | | | | | | | | Primops types were dependent on the target word-size at *compiler* compilation time. It's an issue for multi-target as GHC may not have the correct primops types for the target. This patch fixes some primops types: if they take or return fixed 64-bit values they now always use `Int64#/Word64#`, even on 64-bit architectures (where they used `Int#/Word#` before). Users of these primops may now need to convert from Int64#/Word64# to Int#/Word# (a no-op at runtime). This is a stripped down version of !3658 which goes the all way of changing the underlying primitive types of Word64/Int64. This is left for future work. T12545 allocations increase ~4% on some CI platforms and decrease ~3% on AArch64. Metric Increase: T12545 Metric Decrease: T12545
* Bignum: add missing ruleSylvain Henry2021-10-291-0/+3
| | | | Add missing "Natural -> Integer -> Word#" rule.
* Bignum: allow Integer's signum to inline (#20361)Sylvain Henry2021-10-201-2/+0
| | | | | | | | Allow T12545 to increase because it only happens on CI with dwarf enabled and probably not related to this patch. Metric Increase: T12545
* Bignum: allow Integer predicates to inline (#20361)Sylvain Henry2021-10-201-32/+22
| | | | | | | | | T17516 allocations increase by 48% because Integer's predicates are inlined in some Ord instance methods. These methods become too big to be inlined while they probably should: this is tracked in #20516. Metric Increase: T17516
* Bignum: constant folding for bigNatCompareWord# (#20361)Sylvain Henry2021-10-201-0/+1
|
* Bignum: transfer NOINLINE from Natural to BigNatSylvain Henry2021-10-072-4/+9
|
* Bignum: allow naturalToWordClamp/Negate/Signum to inline (#20361)Sylvain Henry2021-10-071-6/+0
| | | | | We don't need built-in rules now that bignum literals (e.g. 123 :: Natural) match with their constructors (e.g. NS 123##).
* Bignum: allow inlining of naturalEq/Ne/Gt/Lt/Ge/Le/Compare (#20361)Sylvain Henry2021-10-072-5/+1
| | | | | | | | | | Perform constant folding on bigNatCompare instead. Some functions of the Enum class for Natural now need to be inlined explicitly to be specialized at call sites (because `x > lim` for Natural is inlined and the resulting function is a little too big to inline). If we don't do this, T17499 runtime allocations regresses by 16%.
* Bignum: allow naturalEq#/Ne# to inline (#20361)Sylvain Henry2021-10-072-2/+1
| | | | We now perform constant folding on bigNatEq# instead.
* Bignum: refactor conversion rulesSylvain Henry2021-09-072-2/+286
| | | | | | | | * make "passthrough" rules non built-in: they don't need to * enhance note about efficient conversions between numeric types * make integerFromNatural a little more efficient * fix noinline pragma for naturalToWordClamp# (at least with non built-in rules, we get warnings in cases like this)
* Bignum: don't allocate in bignat_mul (#20028)Sylvain Henry2021-07-191-4/+4
| | | | | We allocated the recursively entered `mul` helper function because it captures some args.
* Add Word64#/Int64# primopsSylvain Henry2021-07-152-8/+0
| | | | | | | | | | | | | | | | | | | | | | | 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
* ghc-bignum: trimed ~> trimmedMatthew Pickering2021-06-222-32/+32
| | | | Just a small typo which propagated through ghc-bignum
* Fix naturalToFloat/DoubleSylvain Henry2021-06-193-10/+5
| | | | | | | | | | | * move naturalToFloat/Double from ghc-bignum to base:GHC.Float and make them wired-in (as their integerToFloat/Double counterparts) * use the same rounding method as integerToFloat/Double. This is an oversight of 540fa6b2cff3802877ff56a47ab3611e33a9ac86 * add passthrough rules for intToFloat, intToDouble, wordToFloat, wordToDouble.
* [ci/darwin] use system provided iconv and cursesMoritz Angermann2021-05-251-1/+4
| | | | Also make sure to be able to build with non-apple-clang, while using apple's SDK on macOS
* Bignum: bump to version 1.1 (#19846)Sylvain Henry2021-05-192-1/+11
|
* Bignum: add BigNat Eq/Ord instances (#19647)Sylvain Henry2021-04-091-0/+16
|
* Bignum: remove unused extra filesSylvain Henry2021-04-051-2/+0
|
* Bignum: fix invalid hs-boot declaration (#19638)Sylvain Henry2021-04-051-1/+1
|
* ghc-bignum: Add missing source files to cabal fileBen Gamari2021-04-011-0/+2
|
* fromInteger :: Integer -> {Float,Double} now always round to nearest evenARATA Mizuki2021-03-171-11/+0
| | | | | | | | integerToFloat# and integerToDouble# were moved from ghc-bignum to base. GHC.Integer.floatFromInteger and doubleFromInteger were removed. Fixes #15926, #17231, #17782
* Fix array and cleanup conversion primops (#19026)Sylvain Henry2021-03-032-13/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The first change makes the array ones use the proper fixed-size types, which also means that just like before, they can be used without explicit conversions with the boxed sized types. (Before, it was Int# / Word# on both sides, now it is fixed sized on both sides). For the second change, don't use "extend" or "narrow" in some of the user-facing primops names for conversions. - Names like `narrowInt32#` are misleading when `Int` is 32-bits. - Names like `extendInt64#` are flat-out wrong when `Int is 32-bits. - `narrow{Int,Word}<N>#` however map a type to itself, and so don't suffer from this problem. They are left as-is. These changes are batched together because Alex happend to use the array ops. We can only use released versions of Alex at this time, sadly, and I don't want to have to have a release thatwon't work for the final GHC 9.2. So by combining these we get all the changes for Alex done at once. Bump hackage state in a few places, and also make that workflow slightly easier for the future. Bump minimum Alex version Bump Cabal, array, bytestring, containers, text, and binary submodules
* Fix Windows build with autoconf >=2.70 (#19189)Sylvain Henry2021-02-273-3447/+0
|
* Replace more autotools obsolete macros (#19189)Sylvain Henry2021-02-161-5/+5
|
* Fix typosBrian Wignall2021-02-061-1/+1
|
* Bignum: add Natural constant folding rules (#15821)Sylvain Henry2021-01-235-91/+157
| | | | | | | | | | | | | | | | | | | * Implement constant folding rules for Natural (similar to Integer ones) * Add mkCoreUbxSum helper in GHC.Core.Make * Remove naturalTo/FromInt We now only provide `naturalTo/FromWord` as the semantics is clear (truncate/zero-extend). For Int we have to deal with negative numbers (throw an exception? convert to Word beforehand?) so we leave the decision about what to do to the caller. Moreover, now that we have sized types (Int8#, Int16#, ..., Word8#, etc.) there is no reason to bless `Int#` more than `Int8#` or `Word8#` (for example). * Replaced a few `()` with `(# #)`
* Bump gmp submodule, now with arm64 supportMoritz Angermann2021-01-172-31/+31
|
* Bignum: fix for Integer/Natural Ord instancesSylvain Henry2021-01-171-21/+40
| | | | | | | | | * allow `integerCompare` to inline into `integerLe#`, etc. * use `naturalSubThrow` to implement Natural's `(-)` * use `naturalNegate` to implement Natural's `negate` * implement and use `integerToNaturalThrow` to implement Natural's `fromInteger` Thanks to @christiaanb for reporting these
* Natural: fix left shift of 0 (fix #19170)Sylvain Henry2021-01-091-1/+2
|
* [Sized Cmm] properly retain sizes.Moritz Angermann2020-11-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | This replaces all Word<N> = W<N># Word# and Int<N> = I<N># Int# with Word<N> = W<N># Word<N># and Int<N> = I<N># Int<N>#, thus providing us with properly sized primitives in the codegenerator instead of pretending they are all full machine words. This came up when implementing darwinpcs for arm64. The darwinpcs reqires us to pack function argugments in excess of registers on the stack. While most procedure call standards (pcs) assume arguments are just passed in 8 byte slots; and thus the caller does not know the exact signature to make the call, darwinpcs requires us to adhere to the prototype, and thus have the correct sizes. If we specify CInt in the FFI call, it should correspond to the C int, and not just be Word sized, when it's only half the size. This does change the expected output of T16402 but the new result is no less correct as it eliminates the narrowing (instead of the `and` as was previously done). Bumps the array, bytestring, text, and binary submodules. Co-Authored-By: Ben Gamari <ben@well-typed.com> Metric Increase: T13701 T14697
* Bignum: make GMP's bignat_add not recursiveSylvain Henry2020-11-031-4/+4
| | | | | bignat_add was a loopbreaker with an INLINE pragma (spotted by @mpickering). This patch makes it non recursive to avoid the issue.
* Bignum: fix bigNatCompareWord# bug (#18813)Sylvain Henry2020-10-101-1/+1
|
* Inline `integerDecodeDouble#` and constant-fold `decodeDouble_Int64#` insteadSebastian Graf2020-10-051-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | Currently, `integerDecodeDouble#` is known-key so that it can be recognised in constant folding. But that is very brittle and doesn't survive worker/wrapper, which we even do for `NOINLINE` things since #13143. Also it is a trade-off: The implementation of `integerDecodeDouble#` allocates an `Integer` box that never cancels aways if we don't inline it. Hence we recognise the `decodeDouble_Int64#` primop instead in constant folding, so that we can inline `integerDecodeDouble#`. As a result, `integerDecodeDouble#` no longer needs to be known-key. While doing so, I realised that we don't constant-fold `decodeFloat_Int#` either, so I also added a RULE for it. `integerDecodeDouble` is dead, so I deleted it. Part of #18092. This improves the 32-bit `realToFrac`/`toRational`: Metric Decrease: T10359
* Bignum: implement integerPowMod (#18427)Sylvain Henry2020-10-028-36/+145
| | | | | | | Incidentally fix powModInteger which was crashing in integer-gmp for negative exponents when the modular multiplicative inverse for the base didn't exist. Now we compute it explicitly with integerRecipMod so that every backend returns the same result without crashing.
* Bignum: implement integerRecipMod (#18427)Sylvain Henry2020-10-028-7/+107
|
* Bignum: add integerNegate RULESylvain Henry2020-10-011-0/+3
|
* Bignum: add bigNatFromWordArraySylvain Henry2020-09-261-0/+39
| | | | Reimplementation of integer-gmp's byteArrayToBigNat#