summaryrefslogtreecommitdiff
path: root/libraries/ghc-prim/cbits
Commit message (Collapse)AuthorAgeFilesLines
* Workaround GCC `__ctzdi2` intrinsic linker errorsHerbert Valerio Riedel2014-08-171-1/+17
| | | | | | | | | | | | | | | | | | | | | | | On Linux/i386 the 64bit `__builtin_ctzll()` instrinsic doesn't get inlined by GCC but rather a short `__ctzdi2` runtime function is inserted when needed into compiled object files. This causes failures for the four test-cases TEST="T8639_api T8628 dynCompileExpr T5313" with error messages of the kind dynCompileExpr: .../libraries/ghc-prim/dist-install/build/libHSghcpr_BE58KUgBe9ELCsPXiJ1Q2r.a: unknown symbol `__ctzdi2' dynCompileExpr: dynCompileExpr: unable to load package `ghc-prim' This workaround forces GCC on 32bit x86 to to express `hs_ctz64` in terms of the 32bit `__builtin_ctz()` (this is no loss, as there's no 64bit BSF instruction on i686 anyway) and thus avoid the problematic out-of-line runtime function. Note: `__builtin_ctzll()` is used since e0c1767d0ea8d12e0a4badf43682a08784e379c6 (re #9340)
* Implement new CLZ and CTZ primops (re #9340)Herbert Valerio Riedel2014-08-142-0/+82
| | | | | | | | | | | | | | | | | | | | | | | | This implements the new primops clz#, clz32#, clz64#, ctz#, ctz32#, ctz64# which provide efficient implementations of the popular count-leading-zero and count-trailing-zero respectively (see testcase for a pure Haskell reference implementation). On x86, NCG as well as LLVM generates code based on the BSF/BSR instructions (which need extra logic to make the 0-case well-defined). Test Plan: validate and succesful tests on i686 and amd64 Reviewers: rwbarton, simonmar, ezyang, austin Subscribers: simonmar, relrod, ezyang, carter Differential Revision: https://phabricator.haskell.org/D144 GHC Trac Issues: #9340
* Re-add more primops for atomic ops on byte arraysJohan Tibell2014-06-301-0/+306
| | | | | | | | | | | | | | | | | | | | | | | This is the second attempt to add this functionality. The first attempt was reverted in 950fcae46a82569e7cd1fba1637a23b419e00ecd, due to register allocator failure on x86. Given how the register allocator currently works, we don't have enough registers on x86 to support cmpxchg using complicated addressing modes. Instead we fall back to a simpler addressing mode on x86. Adds the following primops: * atomicReadIntArray# * atomicWriteIntArray# * fetchSubIntArray# * fetchOrIntArray# * fetchXorIntArray# * fetchAndIntArray# Makes these pre-existing out-of-line primops inline: * fetchAddIntArray# * casIntArray#
* Revert "Add more primops for atomic ops on byte arrays"Johan Tibell2014-06-261-306/+0
| | | | | | | | This commit caused the register allocator to fail on i386. This reverts commit d8abf85f8ca176854e9d5d0b12371c4bc402aac3 and 04dd7cb3423f1940242fdfe2ea2e3b8abd68a177 (the second being a fix to the first).
* Work around lack of __sync_fetch_and_nand in clangJohan Tibell2014-06-261-0/+26
| | | | | clang chose to not implement this function. See http://llvm.org/bugs/show_bug.cgi?id=8842
* Add more primops for atomic ops on byte arraysJohan Tibell2014-06-241-0/+280
| | | | | | | | | | | | | | | | | | | Summary: Add more primops for atomic ops on byte arrays Adds the following primops: * atomicReadIntArray# * atomicWriteIntArray# * fetchSubIntArray# * fetchOrIntArray# * fetchXorIntArray# * fetchAndIntArray# Makes these pre-existing out-of-line primops inline: * fetchAddIntArray# * casIntArray#
* Make argument types in popcnt.c match declared primop typesReid Barton2014-03-221-10/+10
| | | | | | | | | | | | | | | On 64-bit Mac OS, gcc 4.2 (which comes with Xcode 4.6) generates code that assumes that an argument that is smaller than the register it is passed in has been sign- or zero-extended. But ghc thinks the types of the PopCnt*Op primops are Word# -> Word#, so it passes the entire argument word to the hs_popcnt* function as though it was declared to have an argument of type StgWord. Segfaults ensue. The easiest fix is to sidestep all this zero-extension business by declaring the hs_popcnt* functions to take a whole StgWord (when their argument would fit in a register), thereby matching the list of primops. Fixes #7684.
* Change return type for emulated 64bit comparisonsJan Stolarek2013-08-161-13/+13
| | | | | | | In the previous patch I used Int64# as a return value for comparison primops used on 32bit machines for comparing Int64# and Word64#. This obviously wasn't a good idea. This patch changes return type from emulated Int64# to a native Int#.
* Comparison primops return Int# (Fixes #6135)Jan Stolarek2013-07-261-15/+13
| | | | | For a deatiled discussion of this changes please visit the wiki page: http://hackage.haskell.org/trac/ghc/wiki/PrimBool
* add other architecture for bswap in a form of Stg functions.Ian Lynagh2013-06-091-0/+27
| | | | Patch from Vincent Hanquez
* Add word2floatJohan Tibell2012-12-061-0/+15
|
* Fix return type of hs_popcntXDaniel Fischer2011-08-271-12/+12
| | | | | | | | | | | All the hs_popcntX functions should return an StgWord in accordance with the primop types. I'm not sure whether the argument should also become an StgWord (except for the 64-bit versions), the primops have type Word# -> Word#, but we have e.g. StgWord hs_popcnt8(StgWord8 x). StgWord8 is an unsigned char (usually, at least), but I think arguments are passed at least word-sized to C-functions, so it probably works. For the moment it works and passes tests, I'll ask tibbe to be sure.
* Add fallbacks for processor specific instructions (e.g. POPCNT). These ↵Johan Tibell2011-08-161-0/+82
| | | | fallbacks are referred to by code generated by GHC.
* Update to follow RTS tidyp changesSimon Marlow2009-08-011-1/+1
|
* Add a debugErrLn function, which is like debugLn except it prints to stderrIan Lynagh2009-07-101-0/+4
|
* Remove the Integer functions; they're now in integer-gmp insteadIan Lynagh2009-06-151-38/+0
|
* Add a GHC.Debug module, with debugLn :: [Char] -> IO ()Ian Lynagh2009-06-201-0/+6
|
* Add GHC.IntWord32 and GHC.IntWord64 (from base)Ian Lynagh2008-03-251-0/+129