X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Flib%2Fstd%2FPrelBits.lhs;h=114ce2e72b58f8ee7dbda593d931858aed50c296;hb=f539427ba1a13e672c6057dfa25c17ae93627d09;hp=d8a8ffd1fe3ba2141f6827c04b7d47584e9387af;hpb=d9af408e5c512501cfa991f5e4a76c9154bca917;p=ghc-hetmet.git diff --git a/ghc/lib/std/PrelBits.lhs b/ghc/lib/std/PrelBits.lhs index d8a8ffd..114ce2e 100644 --- a/ghc/lib/std/PrelBits.lhs +++ b/ghc/lib/std/PrelBits.lhs @@ -23,7 +23,7 @@ import PrelNum -- Removing all fixities is a fairly safe fix; fixing the "one fixity -- per symbol per program" limitation in Hugs would take a lot longer. #ifndef __HUGS__ -infixl 8 `shift`, `rotate` +infixl 8 `shift`, `rotate`, `shiftL`, `shiftR`, `rotateL`, `rotateR` infixl 7 .&. infixl 6 `xor` infixl 5 .|. @@ -61,22 +61,21 @@ instance Bits Int where (I# x#) `xor` (I# y#) = I# (word2Int# (int2Word# x# `xor#` int2Word# y#)) complement (I# x#) = I# (word2Int# (int2Word# x# `xor#` int2Word# (-1#))) (I# x#) `shift` (I# i#) - | i# >=# 0# = I# (x# `iShiftL#` i#) - | otherwise = I# (x# `iShiftRA#` negateInt# i#) + | i# ==# 0# = I# x# + | i# >=# wsib = 0 + | i# ># 0# = I# (x# `uncheckedIShiftL#` i#) + | i# <=# nwsib = I# (if x# <# 0# then -1# else 0#) + | otherwise = I# (x# `uncheckedIShiftRA#` negateInt# i#) + where + wsib = WORD_SIZE_IN_BITS# {- work around preprocessor problem (??) -} + nwsib = negateInt# wsib (I# x#) `rotate` (I# i#) = -#if WORD_SIZE_IN_BYTES == 4 - I# (word2Int# ((x'# `shiftL#` i'#) `or#` - (x'# `shiftRL#` (32# -# i'#)))) + I# (word2Int# ((x'# `uncheckedShiftL#` i'#) `or#` + (x'# `uncheckedShiftRL#` (wsib -# i'#)))) where - x'# = int2Word# x# - i'# = word2Int# (int2Word# i# `and#` int2Word# 31#) -#else - I# (word2Int# ((x'# `shiftL#` i'#) `or#` - (x'# `shiftRL#` (64# -# i'#)))) - where - x'# = int2Word# x# - i'# = word2Int# (int2Word# i# `and#` int2Word# 63#) -#endif - bitSize _ = WORD_SIZE_IN_BYTES * 8 + x'# = int2Word# x# + i'# = word2Int# (int2Word# i# `and#` int2Word# (wsib -# 1#)) + wsib = WORD_SIZE_IN_BITS# + bitSize _ = WORD_SIZE_IN_BITS isSigned _ = True \end{code}