diff options
author | Ian Lynagh <ian@well-typed.com> | 2012-09-18 23:22:20 +0100 |
---|---|---|
committer | Ian Lynagh <ian@well-typed.com> | 2012-09-18 23:22:20 +0100 |
commit | a9b986e2fe285f844e42e573e4887a4e36ba92d4 (patch) | |
tree | 30509b6c6aa091125089208631c146ca72793758 /compiler/cmm/Bitmap.hs | |
parent | 3a4c64c1a2953bbc759a6f5c99dad31ab50dc96b (diff) | |
download | haskell-a9b986e2fe285f844e42e573e4887a4e36ba92d4.tar.gz |
Make StgWord a portable type too
StgWord is a newtyped Word64, as it needed to be something that
has a UArray instance.
Diffstat (limited to 'compiler/cmm/Bitmap.hs')
-rw-r--r-- | compiler/cmm/Bitmap.hs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/compiler/cmm/Bitmap.hs b/compiler/cmm/Bitmap.hs index 93217d5192..d48ab93093 100644 --- a/compiler/cmm/Bitmap.hs +++ b/compiler/cmm/Bitmap.hs @@ -39,12 +39,12 @@ type Bitmap = [StgWord] -- | Make a bitmap from a sequence of bits mkBitmap :: DynFlags -> [Bool] -> Bitmap mkBitmap _ [] = [] -mkBitmap dflags stuff = chunkToBitmap chunk : mkBitmap dflags rest +mkBitmap dflags stuff = chunkToBitmap dflags chunk : mkBitmap dflags rest where (chunk, rest) = splitAt (wORD_SIZE_IN_BITS dflags) stuff -chunkToBitmap :: [Bool] -> StgWord -chunkToBitmap chunk = - foldr (.|.) 0 [ 1 `shiftL` n | (True,n) <- zip chunk [0..] ] +chunkToBitmap :: DynFlags -> [Bool] -> StgWord +chunkToBitmap dflags chunk = + foldr (.|.) (toStgWord dflags 0) [ toStgWord dflags 1 `shiftL` n | (True,n) <- zip chunk [0..] ] -- | Make a bitmap where the slots specified are the /ones/ in the bitmap. -- eg. @[0,1,3], size 4 ==> 0xb@. @@ -54,7 +54,7 @@ intsToBitmap :: DynFlags -> Int -> [Int] -> Bitmap intsToBitmap dflags size slots{- must be sorted -} | size <= 0 = [] | otherwise = - (foldr (.|.) 0 (map (1 `shiftL`) these)) : + (foldr (.|.) (toStgWord dflags 0) (map (toStgWord dflags 1 `shiftL`) these)) : intsToBitmap dflags (size - wORD_SIZE_IN_BITS dflags) (map (\x -> x - wORD_SIZE_IN_BITS dflags) rest) where (these,rest) = span (< wORD_SIZE_IN_BITS dflags) slots @@ -68,12 +68,12 @@ intsToReverseBitmap :: DynFlags -> Int -> [Int] -> Bitmap intsToReverseBitmap dflags size slots{- must be sorted -} | size <= 0 = [] | otherwise = - (foldr xor init (map (1 `shiftL`) these)) : + (foldr xor (toStgWord dflags init) (map (toStgWord dflags 1 `shiftL`) these)) : intsToReverseBitmap dflags (size - wORD_SIZE_IN_BITS dflags) (map (\x -> x - wORD_SIZE_IN_BITS dflags) rest) where (these,rest) = span (< wORD_SIZE_IN_BITS dflags) slots init - | size >= wORD_SIZE_IN_BITS dflags = complement 0 + | size >= wORD_SIZE_IN_BITS dflags = -1 | otherwise = (1 `shiftL` size) - 1 {- | |