summaryrefslogtreecommitdiff
path: root/libraries/integer-gmp
Commit message (Collapse)AuthorAgeFilesLines
* Bignum: add Natural constant folding rules (#15821)Sylvain Henry2021-01-231-4/+4
| | | | | | | | | | | | | | | | | | | * 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 `(# #)`
* Bignum: implement integerPowMod (#18427)Sylvain Henry2020-10-021-2/+9
| | | | | | | 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-021-0/+7
|
* Bignum: add bigNatFromWordArraySylvain Henry2020-09-261-0/+6
| | | | Reimplementation of integer-gmp's byteArrayToBigNat#
* Bignum: implement extended GCD (#18427)Sylvain Henry2020-09-251-0/+7
|
* Bignum: add missing compat import/export functionsSylvain Henry2020-09-021-3/+30
|
* Bignum: add BigNat compat functions (#18613)Sylvain Henry2020-08-311-0/+54
|
* Bignum: add more BigNat compat functions in integer-gmpSylvain Henry2020-08-052-0/+209
|
* Bignum: add backward compat integer-gmp functionsSylvain Henry2020-08-051-0/+24
| | | | Also enhance bigNatCheck# and isValidNatural test
* BigNum: rename BigNat typesSylvain Henry2020-07-071-4/+4
| | | | | | | | | | | | | | | Before this patch BigNat names were confusing because we had: * GHC.Num.BigNat.BigNat: unlifted type used everywhere else * GHC.Num.BigNat.BigNatW: lifted type only used to share static constants * GHC.Natural.BigNat: lifted type only used for backward compatibility After this patch we have: * GHC.Num.BigNat.BigNat#: unlifted type * GHC.Num.BigNat.BigNat: lifted type (reexported from GHC.Natural) Thanks to @RyanGlScott for spotting this.
* Add integer-gmp's ghc.mk and GNUmakefile to .gitignoreRyan Scott2020-06-282-5/+2
|
* ghc-bignum librarySylvain Henry2020-06-1725-8196/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ghc-bignum is a newer package that aims to replace the legacy integer-simple and integer-gmp packages. * it supports several backends. In particular GMP is still supported and most of the code from integer-gmp has been merged in the "gmp" backend. * the pure Haskell "native" backend is new and is much faster than the previous pure Haskell implementation provided by integer-simple * new backends are easier to write because they only have to provide a few well defined functions. All the other code is common to all backends. In particular they all share the efficient small/big number distinction previously used only in integer-gmp. * backends can all be tested against the "native" backend with a simple Cabal flag. Backends are only allowed to differ in performance, their results should be the same. * Add `integer-gmp` compat package: provide some pattern synonyms and function aliases for those in `ghc-bignum`. It is intended to avoid breaking packages that depend on `integer-gmp` internals. Update submodules: text, bytestring Metric Decrease: Conversions ManyAlternatives ManyConstructors Naperian T10359 T10547 T10678 T12150 T12227 T12234 T12425 T13035 T13719 T14936 T1969 T4801 T4830 T5237 T5549 T5837 T8766 T9020 parsing001 space_leak_001 T16190 haddock.base On ARM and i386, T17499 regresses (+6% > 5%). On x86_64 unregistered, T13701 sometimes regresses (+2.2% > 2%). Metric Increase: T17499 T13701
* integer-gmp: Bump version and add changelog entryBen Gamari2020-03-312-1/+7
|
* Make: refactor GMP rulesSylvain Henry2020-03-141-7/+8
| | | | Document and use simpler rules for the ghc-gmp.h header.
* Use configure script to detect that we should use in-tree GMP on WindowsSylvain Henry2020-03-021-6/+0
|
* Hadrian: refactor GMP in-tree build support (#17756)Sylvain Henry2020-02-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * Hadrian doesn't use integer-gmp/config.mk file anymore to determine if building GMP in-tree is required. "config.mk" is created by Cabal when the integer-gmp package is configured and this file is still untracked by Hadrian. This led to a tricky configure "race" because "config.mk" is built by the "setup-config" rule, but this rule is also used to find dependencies, in particular the "ghc-gmp.h" header, but the creation of this file was depending (without being tracked) on "config.mk". Now Hadrian only builds in-tree GMP if `--with-intree-gmp` is passed to the top-level configure script. * in-tree GMP isn't built once for all in a fixed stage (Stage1) anymore. It is built per stage which is required if we build a cross-compiler * switching between in-tree and external GMP is now supported without having to clean the build directory first. * "wrappers.c" now includes "ghc-gmp.h" instead of "ghc.h". It helps ensuring that the build system generates "ghc-gmp.h". * build in-tree GMP in "<root>/stageN/gmp/gmpbuild" and produce useful artefacts (libgmp.a, gmp.h, objs/*.o) in "<root>/stageN/gmp"
* integer-gmp: Fix unused command-line argumentBen Gamari2020-02-141-1/+1
| | | | -L is only needed during linking.
* Module hierarchy: ByteCode and Runtime (cf #13009)Sylvain Henry2020-02-121-1/+1
| | | | Update haddock submodule
* Document GMP build [skip ci]Sylvain Henry2020-02-121-0/+80
|
* Force -fPIC for intree GMP (fix #17799)Sylvain Henry2020-02-092-46/+1
| | | | | Configure intree GMP with `--with-pic` instead of patching it. Moreover the correct patching was only done for x86_64/darwin (see #17799).
* Fix typos, via a Levenshtein-style correctorBrian Wignall2020-01-041-1/+1
|
* Use the new timesInt2# primop in integer-gmp (#9431)Sylvain Henry2019-12-021-4/+19
|
* Fix typosBrian Wignall2019-11-231-1/+1
|
* Fix isValidNatural: The BigNat in NatJ# must have at least 2 limbsSimon Jakobi2019-06-071-0/+2
| | | | | | Previously the `integer-gmp` variant of `isValidNatural` would fail to detect values `<= maxBound::Word` that were incorrectly encoded using the `NatJ#` constructor.
* Update autoconf scriptsBen Gamari2019-04-252-1598/+1732
| | | | Scripts taken from autoconf a8d79c3130da83c7cacd6fee31b9acc53799c406
* Use ghc-prim < 0.7, not <= 0.6.1, as upper version boundsRyan Scott2019-04-091-1/+1
| | | | | | | Using `ghc-prim <= 0.6.1` is somewhat dodgy from a PVP point of view, as it makes it awkward to support new minor releases of `ghc-prim`. Let's instead use `< 0.7`, which is the idiomatic way of expressing PVP-compliant upper version bounds.
* integer-gmp: Write friendlier documentation for IntegerBen Gamari2019-04-031-2/+6
|
* Bump ghc-prim's version where neededAlexandre2019-04-011-1/+1
|
* Update Wiki URLs to point to GitLabTakenobu Tani2019-03-254-6/+6
| | | | | | | | | | | | | | | | | | | | | | | This moves all URL references to Trac Wiki to their corresponding GitLab counterparts. This substitution is classified as follows: 1. Automated substitution using sed with Ben's mapping rule [1] Old: ghc.haskell.org/trac/ghc/wiki/XxxYyy... New: gitlab.haskell.org/ghc/ghc/wikis/xxx-yyy... 2. Manual substitution for URLs containing `#` index Old: ghc.haskell.org/trac/ghc/wiki/XxxYyy...#Zzz New: gitlab.haskell.org/ghc/ghc/wikis/xxx-yyy...#zzz 3. Manual substitution for strings starting with `Commentary` Old: Commentary/XxxYyy... New: commentary/xxx-yyy... See also !539 [1]: https://gitlab.haskell.org/bgamari/gitlab-migration/blob/master/wiki-mapping.json
* Update Trac ticket URLs to point to GitLabRyan Scott2019-03-152-2/+2
| | | | | This moves all URL references to Trac tickets to their corresponding GitLab counterparts.
* Fix Haddock comment for Integer datatypeAlexandre Baldé2019-02-181-2/+6
| | | | | | | | | | | | Move implementation notes for Integer to Haddock named section Revert documentation named chunk change [skip ci] Haddock's named chunk feature was not used correctly in this case, as it cannot export only parts of a Haddock top level comment. As such, it was removed and replaced by a message informing the end- user to browse the source code for detailed information.
* Fix incorrectly named configure optionsAlec Theriault2019-01-271-2/+2
| | | | | | Although we should use 'AC_ARG_ENABLE' for boolean flags, it also means options get named '--enable-*', not '--with-*'. This should unbreak the --with-intree-gmp option.
* Hadrian: support in-tree GMPAlec Theriault2019-01-232-2/+4
| | | | | | | | | | | | | | | | | | | | | | Summary: This adds top-level configure flags '--with-intree-gmp' and '--with-framework-preferred', both of which are especially relevant on MacOS. Besides gaining two new flags, Hadrian also had to be taught what to do with the 'framework' in .cabal files. Test Plan: ./boot && ./configure --with-intree-gmp && ./hadrian/build.sh ./boot && ./configure --with-gmp-framework-preferred && ./hadrian/build.sh # on macos Reviewers: carter, snowleopard, alpmestan, hvr, goldfire, bgamari Subscribers: rwbarton, erikd GHC Trac Issues: #16001 Differential Revision: https://phabricator.haskell.org/D5417
* Match `integer-simple`'s API with `integer-gmp`Alec Theriault2019-01-162-2/+2
| | | | | | | | In `integer-simple`: * Added an efficient `popCountInteger` and `bitInteger` * Added an efficient `gcdInteger` and `lcmInteger` * Made `testBitInteger` more efficient
* Remove OPTIONS_HADDOCK hide in favour for not-homeAdam Sandberg Eriksson2019-01-061-1/+1
| | | | GHC Trac Issues: #15447
* integer-gmp: Fix TBA in changelogBen Gamari2018-11-071-1/+1
|
* Update integer_gmp_gcdext documentation.David Eichmann2018-10-151-7/+7
| | | | | | | | | | | | Reviewers: hvr, bgamari, monoidal Reviewed By: monoidal Subscribers: rwbarton, carter GHC Trac Issues: #15350 Differential Revision: https://phabricator.haskell.org/D5091
* Make GHC (the library) flexible in the choice of integer libraryJoachim Breitner2018-10-031-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: We have more and more users of GHC as a library, for example the Haskell-to-WebAssembly-compiler https://github.com/tweag/asterius. These need to make different decisions about various aspects of code generation than the host compiler, and ideally GHC-the-library allows them to set the `DynFlags` as needed. This patch adds a new `DynFlag` that configures which `integer` library to use. This flag is initialized by `cIntegerLibraryType` (as before), and is only used in `CorePrep` to decide whether to use `S#` or not. The other code paths that were varying based on `cIntegerLibraryType` are no now longer varying: The trick is to use `integer-wired-in` as the `-this-unit-id` when compiling either `integer-gmp` or `integer-simple`. Test Plan: Validate is happy. Reviewers: hvr, bgamari Reviewed By: bgamari Subscribers: TerrorJack, adamse, simonpj, rwbarton, carter GHC Trac Issues: #13477 Differential Revision: https://phabricator.haskell.org/D5079
* Correct limb length and assertion for gcdExtIntegerDavidEichamnn2018-08-211-3/+13
| | | | | | | | | | | | Reviewers: hvr, bgamari, monoidal Reviewed By: monoidal Subscribers: monoidal, rwbarton, thomie, carter GHC Trac Issues: #15350 Differential Revision: https://phabricator.haskell.org/D5042
* Support the GHCi debugger with -fexternal-interpreterSimon Marlow2018-07-161-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * All the tests in tests/ghci.debugger now pass with -fexternal-interpreter. These tests are now run with the ghci-ext way in addition to the normal way so we won't break it in the future. * I removed all the unsafeCoerce# calls from RtClosureInspect. Yay! The main changes are: * New messages: GetClosure and Seq. GetClosure is a remote interface to GHC.Exts.Heap.getClosureData, which required Binary instances for various datatypes. Fortunately this wasn't too painful thanks to DeriveGeneric. * No cheating by unsafeCoercing values when printing them. Now we have to turn the Closure representation back into the native representation when printing Int, Float, Double, Integer and Char. Of these, Integer was the most painful - we now have a dependency on integer-gmp due to needing access to the representation. * Fixed a bug in rts/Heap.c - it was bogusly returning stack content as pointers for an AP_STACK closure. Test Plan: * `cd testsuite/tests/ghci.debugger && make` * validate Reviewers: bgamari, patrickdoc, nomeata, angerman, hvr, erikd, goldfire Subscribers: alpmestan, snowleopard, rwbarton, thomie, carter GHC Trac Issues: #13184 Differential Revision: https://phabricator.haskell.org/D4955
* Fix gcdExtInteger (trac#15350)Bodigrim2018-07-121-1/+3
|
* Bump version numbers: base-4.11.1.0, integer-gmp-1.0.2.0Ryan Scott2018-04-133-2/+9
| | | | | | | | | | | | | | | | | | | | | This takes care of bumping the `base` and `integer-gmp` minor version numbers in anticipation of a GHC 8.4.2 release. While I was in town, I also filled in a `@since TODO` Haddock annotation for `powModSecInteger` in `integer-gmp` with `1.0.2.0`, and updated the changelog accordingly. Test Plan: ./validate Reviewers: hvr, goldfire, bgamari Reviewed By: bgamari Subscribers: thomie, carter GHC Trac Issues: #15025 Differential Revision: https://phabricator.haskell.org/D4586
* Move gmp/config.mk.in to config.mk.in, fix #14972Edward Z. Yang2018-04-104-6/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Here's how the rube goldberg machine triggered the old bug: 1. If you have a file gmp/config.mk.in, then Cabal will create a generated file in $DIST/build/gmp/config.mk 2. When you attempt to load inplace integer-gmp via GHCi, it will ask gcc (aka clang on OS X) for the file name of 'gmp', with base directory set to $DIST/build 3. There is a folder named 'gmp', and so this folder is returned as the 'library' for gmp 4. GHCi loadArchive chokes to death trying to open a library that is actually a folder This patch solves the problem by breaking the chain at (1): if we don't put config.mk in a folder named gmp, NO PROBLEM. Signed-off-by: Edward Z. Yang <ezyang@fb.com> Test Plan: validate Reviewers: angerman, hvr, bgamari Reviewed By: angerman Subscribers: erikd, thomie, carter GHC Trac Issues: #14972 Differential Revision: https://phabricator.haskell.org/D4552
* Bump autoconf version bound to >= 2.69Ben Gamari2018-03-191-1/+1
| | | | | | | | | | Reviewers: hvr Subscribers: rwbarton, thomie, erikd, carter GHC Trac Issues: #14910 Differential Revision: https://phabricator.haskell.org/D4495
* add CCX=$(CXX) to integer-gmpMoritz Angermann2018-03-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This came up when trying to build GHC HEAD with nix. We do not set CCX for integer-gmp when running ./configure. We do this however for libffi. The result is, that if CCX is not set, we default to the system one, of which there might be none (as in nixos's case). This will not show on a debian+nix or similar setup, where the system `cxx` is still in place, and only shows up when the system tries hard to sandbox everything (even cxx) as nixOS does. We use `CXX`, which is set to either `clang` or `CC_STAGE1`, and also usedfor `CC`, similar to what we do for libffi.c Test Plan: ./validate Reviewers: bgamari, hvr Reviewed By: hvr Subscribers: rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4473
* Fixup include of gmp/config.mk to use new locationHerbert Valerio Riedel2018-03-051-1/+1
| | | | | | | | | | | | | This wasn't spotted rightaway in 8f0b2f5eadf0fcb47c581907205a9db686214a69 because the include-site deliberately ignored include-errors as a Hack with the justification below: > Hack. The file gmp/config.mk doesn't exist yet after running ./configure in > the toplevel (ghc) directory. To let some toplevel make commands such as > sdist go through, right after ./configure, don't consider this an error. This may have contributed to #14891.
* integer-gmp: Simplify gmp/configure invocationBen Gamari2018-02-021-4/+1
| | | | | | | | | | | There weas lots of historical cruft to be found here. The `export SHELLOPTS` breaks on NixOS due to bash syntax in the gcc wrapper script. Reviewers: hvr Subscribers: rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4347
* Forward-port changes from GHC 8.2 branchHerbert Valerio Riedel2017-12-071-2/+11
| | | | (cherry picked from commit 3fa061a647d2fdc182eff9296eea02d6a7d516cd)
* Implement {set,clear,complement}BitBigNat primitivesHerbert Valerio Riedel2017-10-162-8/+83
| | | | | | | | | | | | | | This implements the missing `{set,clear,complement}BitBigNat` primitives and hooks them up to `Natural`'s `Bits` instance. This doesn't yet benefit `Integer`, as we still need "negative" `BigNat` variants of those primitives. Addresses #7860 (partly) Reviewed By: bgamari Differential Revision: https://phabricator.haskell.org/D3415
* integer-gmp: Fix styleBen Gamari2017-09-251-6/+6
| | | | | | | | | | | | Just fix a few inconsistencies that I encountered. [skip ci] Reviewers: austin, hvr, goldfire Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D4024