summaryrefslogtreecommitdiff
path: root/compiler/prelude
diff options
context:
space:
mode:
authorIan Lynagh <ian@well-typed.com>2013-06-09 12:10:35 +0100
committerIan Lynagh <ian@well-typed.com>2013-06-09 12:10:35 +0100
commit1c5b0511a89488f5280523569d45ee61c0d09ffa (patch)
treeccdb8a6ff90162e4d26318b901c473ab5a7f90cc /compiler/prelude
parent972c044d5da72cee3a43209ccb41e2229914211c (diff)
downloadhaskell-1c5b0511a89488f5280523569d45ee61c0d09ffa.tar.gz
Add support for byte endian swapping for Word 16/32/64.
* Exposes bSwap{,16,32,64}# primops * Add a new machops MO_BSwap * Use a Stg implementation (hs_bswap{16,32,64}) for other implementation in NCG. * Generate bswap in X86 NCG for 32 and 64 bits, and for 16 bits, bswap+shr instead of using xchg. * Generate llvm.bswap intrinsics in llvm codegen. Patch from Vincent Hanquez.
Diffstat (limited to 'compiler/prelude')
-rw-r--r--compiler/prelude/primops.txt.pp9
1 files changed, 9 insertions, 0 deletions
diff --git a/compiler/prelude/primops.txt.pp b/compiler/prelude/primops.txt.pp
index 45472816c0..d6bdae861d 100644
--- a/compiler/prelude/primops.txt.pp
+++ b/compiler/prelude/primops.txt.pp
@@ -363,6 +363,15 @@ primop PopCnt64Op "popCnt64#" GenPrimOp WORD64 -> Word#
primop PopCntOp "popCnt#" Monadic Word# -> Word#
{Count the number of set bits in a word.}
+primop BSwap16Op "byteSwap16#" Monadic Word# -> Word#
+ {Swap bytes in the lower 16 bits of a word. The higher bytes are undefined. }
+primop BSwap32Op "byteSwap32#" Monadic Word# -> Word#
+ {Swap bytes in the lower 32 bits of a word. The higher bytes are undefined. }
+primop BSwap64Op "byteSwap64#" GenPrimOp WORD64 -> WORD64
+ {Swap bytes in a 64 bits of a word.}
+primop BSwapOp "byteSwap#" Monadic Word# -> Word#
+ {Swap bytes in a word.}
+
------------------------------------------------------------------------
section "Narrowings"
{Explicit narrowing of native-sized ints or words.}