-
Marcin 'Qrczak' Kowalczyk authored
* Add {intToInt,wordToWord}{8,16,32}# primops. WARNING: Not implemented in ncg for Alpha and Sparc. But -O -fasm is not going to go far anyway because of other omissions. * Have full repertoire of 8,16,32-bit signed and unsigned MachMisc.Size values. Again only x86 is fully supported. They are used for {index,read,write}{Int,Word}{8,16,32}{OffAddr,Array}# and {intToInt,wordToWord}{8,16,32}# primops. * Have full repertoire of {index,read,write}\ {Char,WideChar,Int,Word,Addr,Float,Double,StablePtr,\ {Int,Word}{8,16,32,64}}\ {OffAddr,Array} primops and appropriate instances. There were various omissions in various places. * Add {plus,minus,times}Word# primops to avoid so many Word# <-> Int# coercions. * Rewrite modules PrelWord and PrelInt almost from scratch. * Simplify fromInteger and realToFrac rules. For each of {Int,Word}{8,16,32} there is just a pair of fromInteger rules replacing the source or target type with Int or Word. For {Int,Word,Int64,Word64} there are rules from any to any. Don't include rules which are derivable from inlining anyway, e.g. those mentioning Integer. Old explicit coercions are simply defined as appropriately typed fromInteger. * Various old coercion functions marked as deprecated. * Add instance Bits Int, and instance {Show,Num,Real,Enum,Integral,Bounded,Ix,Read,Bits} Word. * Coercions to sized integer types consistently behave as cutting the right amount of bits from the infinite two-complement representation. For example (fromIntegral (-1 :: Int8) :: Word64) == maxBound. * ghc/tests/numeric/should_run/arith011 tests {Int,Word}64 and instance Bits Int, and does not try to use overflowing toEnum. arith011.stdout is not updated yet because of a problem I will tell about soon. * Move fromInteger and realToFrac from Prelude to PrelReal. Move fromInt from PrelNum to PrelReal and define as fromInteger. Define toInt as fromInteger. fromInteger is the place to write integer conversion rules for. * Remove ArrayBase.newInitialisedArray, use default definition of newArray instead. * Bugs fixed: - {quot,rem}Word# primop attributes. - integerToInt64# for small negative values. - {min,max}Bound::Int on 64-bit platforms. - iShiftRL64#. - Various Bits instances. * Polishing: - Use 'ppr' instead of 'pprPrimOp' and 'text . showPrimRep'. - PrimRep.{primRepString,showPrimRepToUser} removed. - MachMisc.sizeOf returns Int instead of Integer. - Some eta reduction, parens, spacing, and reordering cleanups - sorry, couldn't resist. * Questions: - Should iShiftRL and iShiftRL64 be removed? IMHO they should, s/iShiftRA/iShiftR/, s/shiftRL/shiftR/. The behaviour on shifting is a property of the signedness of the type, not the operation! I haven't done this change.
871db587