summaryrefslogtreecommitdiff
path: root/libraries/ghc-prim
Commit message (Collapse)AuthorAgeFilesLines
* Modules: Core operations (#13009)Sylvain Henry2020-03-181-4/+4
|
* Do not define hs_atomic{read,write}64() on non-64bitIlias Tsitsimpis2020-03-021-0/+5
| | | | | | | | | | | | | | | Do not define hs_atomicread64() and hs_atomicwrite64() on machines where WORD_SIZE_IN_BITS is less than 64, just like we do with the rest of the atomic functions which work on 64-bit values. Without this, compilation fails on MIPSel and PowerPC with the following error: /usr/bin/ld: /<<PKGBUILDDIR>>/libraries/ghc-prim/dist-install/build/libHSghc-prim-0.5.3_p.a(atomic.p_o): in function `hs_atomicread64': atomic.c:(.text.hs_atomicread64+0x8): undefined reference to `__sync_add_and_fetch_8' /usr/bin/ld: /<<PKGBUILDDIR>>/libraries/ghc-prim/dist-install/build/libHSghc-prim-0.5.3_p.a(atomic.p_o): in function `hs_atomicwrite64': atomic.c:(.text.hs_atomicwrite64+0x38): undefined reference to `__sync_bool_compare_and_swap_8' Fixes #17886.
* Optimize unpackCString# to allocate less.Andreas Klebinger2020-02-081-43/+54
| | | | | | | | | | | | | | | | | unpackCString# is a recursive function which for each iteration returns a Cons cell containing the current Char, and a thunk for unpacking the rest of the string. In this patch we change from storing addr + offset inside this thunk to storing only the addr, simply incrementing the address on each iteration. This saves one word of allocation per unpacked character. For a program like "main = print "<largishString>" this amounts to 2-3% fewer % in bytes allocated. I also removed the now redundant local unpack definitions. This removes one call per unpack operation.
* Fix typos, via a Levenshtein-style correctorBrian Wignall2020-01-041-1/+1
|
* Add `timesInt2#` primopSylvain Henry2019-12-021-0/+10
|
* Implement shrinkSmallMutableArray# and resizeSmallMutableArray#.Andrew Martin2019-10-261-0/+9
| | | | | | | | | | | | | | | | | | | | | This is a part of GHC Proposal #25: "Offer more array resizing primitives". Resources related to the proposal: - Discussion: https://github.com/ghc-proposals/ghc-proposals/pull/121 - Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0025-resize-boxed.rst Only shrinkSmallMutableArray# is implemented as a primop since a library-space implementation of resizeSmallMutableArray# (in GHC.Exts) is no less efficient than a primop would be. This may be replaced by a primop in the future if someone devises a strategy for growing arrays in-place. The library-space implementation always copies the array when growing it. This commit also tweaks the documentation of the deprecated sizeofMutableByteArray#, removing the mention of concurrency. That primop is unsound even in single-threaded applications. Additionally, the non-negativity assertion on the existing shrinkMutableByteArray# primop has been removed since this predicate is trivially always true.
* Documentation for (&&) and (&&) states that they are lazy in their second ↵Tilman Blumhagen2019-10-221-2/+2
| | | | argument (fixes #17354)
* Typo in comment [ci skip]wip/ggreif-typoGabor Greif2019-10-031-1/+1
|
* ghc-prim: Fix documentation of TypeBen Gamari2019-09-271-1/+1
| | | | As pointed out in #17243, `Type` is not the only kind having values.
* Remove unused imports of the form 'import foo ()' (Fixes #17065)James Foster2019-08-151-1/+0
| | | | | | | | | | | These kinds of imports are necessary in some cases such as importing instances of typeclasses or intentionally creating dependencies in the build system, but '-Wunused-imports' can't detect when they are no longer needed. This commit removes the unused ones currently in the code base (not including test files or submodules), with the hope that doing so may increase parallelism in the build system by removing unnecessary dependencies.
* Add Note [RuntimeRep and PrimRep] in RepTypeRichard Eisenberg2019-07-291-0/+2
| | | | | | | | | | Also adds Note [Getting from RuntimeRep to PrimRep], which deocuments a related thorny process. This Note addresses #16964, which correctly observes that documentation for this thorny design is lacking. Documentation only.
* Make stage 1 GHC target independentJohn Ericson2019-07-241-2/+2
| | | | | Now that the target macros are not being used, we remove them. This prevents target hardcoding regressions.
* Create {Int,Word}32RepJohn Ericson2019-07-171-0/+2
| | | | | | | This prepares the way for making Int32# and Word32# the actual size they claim to be. Updates binary submodule for (de)serializing the new runtime reps.
* Remove purely external primopsJohn Ericson2019-07-142-0/+106
| | | | | | | | | | | | The compiler doesn't create uses nor compiles the uses that exist specially. These are just plain C-- FFI. These `await*` ones are especially important to so convert because "true" primops are hard to make platform-specific currently. The other exports are part of this commit so this module always exports something, which avoids silly CPP elsewhere. More will be added later once `foreign import prim` is extended.
* No atomics on arm32; this will just yield stubs.Moritz Angermann2019-07-021-0/+2
| | | | | | | | | | | | | | | As such the internal linker will fail for them. The alternative would be to implement them as stubs in the linker and have them barf when called. > Not all operations are supported by all target processors. If a particular operation cannot be implemented on the target processor, a warning is generated and a call an external function is generated. The external function carries the same name as the built-in version, with an additional suffix ‘_n’ where n is the size of the data type. (https://gcc.gnu.org/onlinedocs/gcc/_005f_005fsync-Builtins.html)
* Implement the -XUnliftedNewtypes extension.Andrew Martin2019-06-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | GHC Proposal: 0013-unlifted-newtypes.rst Discussion: https://github.com/ghc-proposals/ghc-proposals/pull/98 Issues: #15219, #1311, #13595, #15883 Implementation Details: Note [Implementation of UnliftedNewtypes] Note [Unifying data family kinds] Note [Compulsory newtype unfolding] This patch introduces the -XUnliftedNewtypes extension. When this extension is enabled, GHC drops the restriction that the field in a newtype must be of kind (TYPE 'LiftedRep). This allows types like Int# and ByteArray# to be used in a newtype. Additionally, coerce is made levity-polymorphic so that it can be used with newtypes over unlifted types. The bulk of the changes are in TcTyClsDecls.hs. With -XUnliftedNewtypes, getInitialKind is more liberal, introducing a unification variable to return the kind (TYPE r0) rather than just returning (TYPE 'LiftedRep). When kind-checking a data constructor with kcConDecl, we attempt to unify the kind of a newtype with the kind of its field's type. When typechecking a data declaration with tcTyClDecl, we again perform a unification. See the implementation note for more on this. Co-authored-by: Richard Eisenberg <rae@richarde.dev>
* Ord docs: Add explanation on 'min' and 'max' operator interactionsSimon Jakobi2019-04-141-0/+4
| | | | [ci skip]
* Fix whitespace styleYuriy Syrovetskiy2019-04-081-1/+1
|
* Replace git.haskell.org with gitlab.haskell.org (#16196)Yuriy Syrovetskiy2019-04-041-1/+1
|
* Fix formatting issue in ghc-prim's changelog [skip ci]Alexandre Baldé2019-04-021-0/+1
|
* Bump ghc-prim's version where neededAlexandre2019-04-011-1/+1
|
* Add support for bitreverse primopAlexandre2019-04-013-2/+95
| | | | | | This commit includes the necessary changes in code and documentation to support a primop that reverses a word's bits. It also includes a test.
* Fix a few broken Trac links [skip ci]Chaitanya Koparkar2019-03-271-1/+1
| | | | This patch only attempts to fix links that don't automatically re-direct to the correct URL.
* ghc-heap: Introduce closureSizeBen Gamari2019-03-171-0/+8
| | | | | | This function allows the user to compute the (non-transitive) size of a heap object in words. The "closure" in the name is admittedly confusing but we are stuck with this nomenclature at this point.
* Update Trac ticket URLs to point to GitLabRyan Scott2019-03-151-1/+1
| | | | | This moves all URL references to Trac tickets to their corresponding GitLab counterparts.
* Fix invalid doc commentAlec Theriault2019-02-101-16/+22
| | | | | | The invalid doc comments were exposed by 24b39ce53eedad4cefc30f6786542d2072d1f9b0. The fix is to properly escaped the `{-` and `-}` in the doc comments. Some other miscallaneous markup issues are also fixed.
* Remove OPTIONS_HADDOCK hide in favour for not-homeAdam Sandberg Eriksson2019-01-062-2/+2
| | | | GHC Trac Issues: #15447
* Fix unused-import warningsDavid Eichmann2018-11-221-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes a fairly long-standing bug (dating back to 2015) in RdrName.bestImport, namely commit 9376249b6b78610db055a10d05f6592d6bbbea2f Author: Simon Peyton Jones <simonpj@microsoft.com> Date: Wed Oct 28 17:16:55 2015 +0000 Fix unused-import stuff in a better way In that patch got the sense of the comparison back to front, and thereby failed to implement the unused-import rules described in Note [Choosing the best import declaration] in RdrName This led to Trac #13064 and #15393 Fixing this bug revealed a bunch of unused imports in libraries; the ones in the GHC repo are part of this commit. The two important changes are * Fix the bug in bestImport * Modified the rules by adding (a) in Note [Choosing the best import declaration] in RdrName Reason: the previosu rules made Trac #5211 go bad again. And the new rule (a) makes sense to me. In unravalling this I also ended up doing a few other things * Refactor RnNames.ImportDeclUsage to use a [GlobalRdrElt] for the things that are used, rather than [AvailInfo]. This is simpler and more direct. * Rename greParentName to greParent_maybe, to follow GHC naming conventions * Delete dead code RdrName.greUsedRdrName Bumps a few submodules. Reviewers: hvr, goldfire, bgamari, simonmar, jrtc27 Subscribers: rwbarton, carter Differential Revision: https://phabricator.haskell.org/D5312
* Introduce Int16# and Word16#Abhiroop Sarkar2018-11-171-2/+4
| | | | | | | | | | | | This builds off of D4475. Bumps binary submodule. Reviewers: carter, AndreasK, hvr, goldfire, bgamari, simonmar Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D5006
* Add Int8# and Word8#Michal Terepeta2018-11-021-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is the first step of implementing: https://github.com/ghc-proposals/ghc-proposals/pull/74 The main highlights/changes: primops.txt.pp gets two new sections for two new primitive types for signed and unsigned 8-bit integers (Int8# and Word8 respectively) along with basic arithmetic and comparison operations. PrimRep/RuntimeRep get two new constructors for them. All of the primops translate into the existing MachOPs. For CmmCalls the codegen will now zero-extend the values at call site (so that they can be moved to the right register) and then truncate them back their original width. x86 native codegen needed some updates, since it wasn't able to deal with the new widths, but all the changes are quite localized. LLVM backend seems to just work. This is the second attempt at merging this, after the first attempt in D4475 had to be backed out due to regressions on i386. Bumps binary submodule. Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com> Test Plan: ./validate (on both x86-{32,64}) Reviewers: bgamari, hvr, goldfire, simonmar Subscribers: rwbarton, carter Differential Revision: https://phabricator.haskell.org/D5258
* Revert "Add Int8# and Word8#"Ben Gamari2018-10-091-3/+1
| | | | | | | | | This unfortunately broke i386 support since it introduced references to byte-sized registers that don't exist on that architecture. Reverts binary submodule This reverts commit 5d5307f943d7581d7013ffe20af22233273fba06.
* Add Int8# and Word8#Michal Terepeta2018-10-071-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is the first step of implementing: https://github.com/ghc-proposals/ghc-proposals/pull/74 The main highlights/changes: - `primops.txt.pp` gets two new sections for two new primitive types for signed and unsigned 8-bit integers (`Int8#` and `Word8` respectively) along with basic arithmetic and comparison operations. `PrimRep`/`RuntimeRep` get two new constructors for them. All of the primops translate into the existing `MachOP`s. - For `CmmCall`s the codegen will now zero-extend the values at call site (so that they can be moved to the right register) and then truncate them back their original width. - x86 native codegen needed some updates, since it wasn't able to deal with the new widths, but all the changes are quite localized. LLVM backend seems to just work. Bumps binary submodule. Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com> Test Plan: ./validate with new tests Reviewers: hvr, goldfire, bgamari, simonmar Subscribers: Abhiroop, dfeuer, rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4475
* Document the list data typeAlec Theriault2018-10-042-13/+33
| | | | | | | | | | | | | | Summary: Also qualified some identifier hyperlinks along the way. Reviewers: bgamari Reviewed By: bgamari Subscribers: rwbarton, carter GHC Trac Issues: #4861 Differential Revision: https://phabricator.haskell.org/D5158
* ghc-prim: Fix typo in traceBinaryEvent# changelog entryBen Gamari2018-10-011-1/+2
|
* ghc-prim: Add missing changelog entryBen Gamari2018-10-011-0/+34
|
* Revert "adds -latomic to. ghc-prim"Ben Gamari2018-09-204-38/+1
| | | | | | | This commit was never properly justified and relies on the existence of libatomic, which doesn't appear to exist on Darwin. This reverts commit ec9aacf3eb2975fd302609163aaef429962ecd87.
* Fix check whether GCC supports __atomic_ builtinsIlias Tsitsimpis2018-09-182-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Summary: C11 atomics are never used because: * The program used for checking whether GCC supports __atomic_ builtins fails with the following error: ``` error: size mismatch in argument 2 of `__atomic_load` int test(int *x) { int y; __atomic_load(&x, &y, __ATOMIC_SEQ_CST); return x; } ``` * There is a typo when checking if CONF_GCC_SUPPORTS__ATOMICS equals YES, resulting in PRIM_CFLAGS and PRIM_EXTRA_LIBRARIES never being set. Reviewers: bgamari Reviewed By: bgamari Subscribers: rwbarton, erikd, carter Differential Revision: https://phabricator.haskell.org/D5154
* docs: Add changelog and release notes entry for traceBinaryEvent#Ben Gamari2018-08-231-0/+7
|
* Refactor (~) to reduce the suerpclass stackSimon Peyton Jones2018-07-271-0/+6
| | | | | | | | | | | | | | | | | | | | | | | The constraint (~) used to be (effectively): class a ~~ b => (a :: k) ~ (b :: k) but, with this patch, it is now defined uniformly with (~~) and Coercible like this: class a ~# b => (a :: k) ~ (b :: k) Result: * One less superclass selection when goinng from (~) to (~#) Better for compile time and better for debugging with -ddump-simpl * The code for (~), (~~), and Coercible looks uniform, and appears together, e.g. in TysWiredIn and ClsInst.matchGlobalInst. Previously the code for (~) was different, and unique. Not only is this simpler, but it also makes the compiler a bit faster; T12227: 9% less allocation T12545: 7% less allocation This patch fixes Trac #15421
* Improve documentation of Eq, Ord instances for Float and DoubleARJANEN Loïc Jean David2018-06-171-5/+89
| | | | | | | | | | | | Reviewers: sjakobi, dfeuer, bgamari, hvr Reviewed By: sjakobi, bgamari Subscribers: rwbarton, thomie, carter GHC Trac Issues: #15078 Differential Revision: https://phabricator.haskell.org/D4736
* Embrace -XTypeInType, add -XStarIsTypeVladislav Zavialov2018-06-142-8/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Implement the "Embrace Type :: Type" GHC proposal, .../ghc-proposals/blob/master/proposals/0020-no-type-in-type.rst GHC 8.0 included a major change to GHC's type system: the Type :: Type axiom. Though casual users were protected from this by hiding its features behind the -XTypeInType extension, all programs written in GHC 8+ have the axiom behind the scenes. In order to preserve backward compatibility, various legacy features were left unchanged. For example, with -XDataKinds but not -XTypeInType, GADTs could not be used in types. Now these restrictions are lifted and -XTypeInType becomes a redundant flag that will be eventually deprecated. * Incorporate the features currently in -XTypeInType into the -XPolyKinds and -XDataKinds extensions. * Introduce a new extension -XStarIsType to control how to parse * in code and whether to print it in error messages. Test Plan: Validate Reviewers: goldfire, hvr, bgamari, alanz, simonpj Reviewed By: goldfire, simonpj Subscribers: rwbarton, thomie, mpickering, carter GHC Trac Issues: #15195 Differential Revision: https://phabricator.haskell.org/D4748
* ghc-prim: Bump versionBen Gamari2018-05-202-2/+6
| | | | | | | | | | | | | unpackClosure#'s behavior and type has changed. This caused a CPP guard in the new ghc-heap package to fail when bootstrapping with GHC 8.4. Test Plan: Validate bootstrapping with GHC 8.4 Reviewers: RyanGlScott Subscribers: rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4716
* Add 'addWordC#' PrimOpSebastian Graf2018-05-052-1/+8
| | | | | | | | | | | | | | | | | | | This is mostly for congruence with 'subWordC#' and '{add,sub}IntC#'. I found 'plusWord2#' while implementing this, which both lacks documentation and has a slightly different specification than 'addWordC#', which means the generic implementation is unnecessarily complex. While I was at it, I also added lacking meta-information on PrimOps and refactored 'subWordC#'s generic implementation to be branchless. Reviewers: bgamari, simonmar, jrtc27, dfeuer Reviewed By: bgamari, dfeuer Subscribers: dfeuer, thomie, carter Differential Revision: https://phabricator.haskell.org/D4592
* ghc-prim: Refactor and document __sync_fetch_and_nand workaroundBen Gamari2018-04-241-15/+60
| | | | | | | | | | | | | | | | ed6f9fb9d5a684d2159c29633159c3254cf04deb reduced the scope of this hack to only include Clangs which actually lack __sync_fetch_and_nand. However, this causes GHC to fail to build with -Werror on Clang due to the lack of the -Wsync-nand warning flag. As it turns out a flag controlling the warning is available under a different name, however. Test Plan: Validate with Clang, GCC Subscribers: thomie, carter GHC Trac Issues: #9678 Differential Revision: https://phabricator.haskell.org/D4613
* Proper safe coercions paper linkKirill Zaborsky2018-04-171-1/+1
|
* Fix compilation stopper on macOS with -WerrorRichard Eisenberg2018-03-261-0/+2
| | | | | | | | | Commit 94f02547083cf6df686ea0b95fed050184c533de added some pragmas that allow GCC to compile GHC, but stop macOS's clang. This adds another counter-pragma to halp clang lumber along, too. Fixes #14977.
* UNREG: fix implicit declarations from pdep and pextSergei Trofimovich2018-03-092-10/+0
| | | | | | | | | | | | | | | | | | | | | | Unreg build failed as: $ ./configure --enable-unregisterised $ make HC [stage 1] libraries/ghc-prim/dist-install/build/GHC/PrimopWrappers.o ghc_1.hc: In function 'ghczmprim_GHCziPrimopWrappers_pdep8zh_entry': ghc_1.hc:1810:9: error: error: implicit declaration of function 'hs_pdep8'; did you mean 'hs_ctz8'? [-Werror=implicit-function-declaration] _c3jz = hs_pdep8(*Sp, Sp[1]); ^~~~~~~~ hs_ctz8 | 1810 | _c3jz = hs_pdep8(*Sp, Sp[1]); | ^ Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
* ghc-prim: Silence -Wsync-nand warning in atomic.cBen Gamari2018-03-081-0/+6
| | | | | | | | | | | | GCC throws this warning to inform us that __sync_fetch_and_nand's behavior changed in GCC 4.4. However, this causes the build to fail when -Werror is used. Test Plan: Validate with -Werror Subscribers: rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4481
* ghc-prim: Reduce scope of Clang sync_fetch_and_nand workaroundBen Gamari2018-03-081-4/+9
| | | | | | | | | | | | | | As described in https://bugs.llvm.org/show_bug.cgi?id=8842, Clang removed the __sync_fetch_and_nand builtins due to inconsistency in GCC's behavior in 2010. However, GCC has since clarified the behavior of their builtins and consequently Clang re-added them in 2014. Consequently this workaround should no longer be necessary. Test Plan: Validate building with Clang Subscribers: rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4480
* Add ghc-prim.buildinfo to .gitignoreRyan Scott2018-02-201-1/+2
|