diff options
author | Johan Tibell <johan.tibell@gmail.com> | 2014-08-12 09:34:27 +0200 |
---|---|---|
committer | Johan Tibell <johan.tibell@gmail.com> | 2014-08-12 22:13:21 +0200 |
commit | a6fd7b5c4b8439bfcc56bf6924de64f4f32e7211 (patch) | |
tree | 988d07fc9617e7a9b1491c508e9ad2df60fa06e2 /compiler/cmm | |
parent | 6f862dfae20afdcd671133f3534b1bf5c25bbd9b (diff) | |
download | haskell-a6fd7b5c4b8439bfcc56bf6924de64f4f32e7211.tar.gz |
Add some Haddocks to SMRep
Diffstat (limited to 'compiler/cmm')
-rw-r--r-- | compiler/cmm/SMRep.lhs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/compiler/cmm/SMRep.lhs b/compiler/cmm/SMRep.lhs index 9fab530b7f..0713620c5a 100644 --- a/compiler/cmm/SMRep.lhs +++ b/compiler/cmm/SMRep.lhs @@ -71,19 +71,30 @@ import Data.Bits %************************************************************************ \begin{code} -type WordOff = Int -- Word offset, or word count -type ByteOff = Int -- Byte offset, or byte count +-- | Word offset, or word count +type WordOff = Int +-- | Byte offset, or byte count +type ByteOff = Int + +-- | Round up the given byte count to the next byte count that's a +-- multiple of the machine's word size. roundUpToWords :: DynFlags -> ByteOff -> ByteOff roundUpToWords dflags n = (n + (wORD_SIZE dflags - 1)) .&. (complement (wORD_SIZE dflags - 1)) +-- | Convert the given number of words to a number of bytes. +-- +-- This function morally has type @WordOff -> ByteOff@, but uses @Num +-- a@ to allow for overloading. wordsToBytes :: Num a => DynFlags -> a -> a wordsToBytes dflags n = fromIntegral (wORD_SIZE dflags) * n {-# SPECIALIZE wordsToBytes :: DynFlags -> Int -> Int #-} {-# SPECIALIZE wordsToBytes :: DynFlags -> Word -> Word #-} {-# SPECIALIZE wordsToBytes :: DynFlags -> Integer -> Integer #-} +-- | First round the given byte count up to a multiple of the +-- machine's word size and then convert the result to words. bytesToWordsRoundUp :: DynFlags -> ByteOff -> WordOff bytesToWordsRoundUp dflags n = (n + word_size - 1) `quot` word_size where word_size = wORD_SIZE dflags |