cvs commit: fptools/ghc/compiler/prelude primops.txt.pp fptools/ghc/includes
PrimOps.h fptools/ghc/lib/std PrelBase.lhs PrelBits.lhs
PrelGHC.hi-boot.pp PrelInt.lhs PrelWord.lhs
Fri, 7 Dec 2001 03:34:49 -0800
sewardj 2001/12/07 03:34:48 PST
ghc/lib/std PrelBase.lhs PrelBits.lhs
Change the story on shifting primops: SllOp, SrlOp, ISllOp, ISraOp, ISrlOp.
In the old primop story, these were implemented by C macros which
checked that the shift amount did not exceed the word size, and if so
returns a suitable value (0 or -1). This gives consistent, defined
behaviour for any shift amount. However, these checks were not
implemented on the NCG route, an inconsistency.
New story: these primops do NOT check their args; they just do the shift.
Shift values >= word size give undefined results. To reflect this, their
Haskell names have been prefixed with 'unchecked'.
The checks are now done on the Bits instances in the Prelude. This means
all code generation routes are consistently checked, and hopefully the
simplifier will remove the checks for literal shift amounts.
I have tried to fix up the implementation for 64-bit platforms too, but
not having one to hand, I don't know if it will work as-is.
Revision Changes Path
1.11 +16 -11 fptools/ghc/compiler/prelude/primops.txt.pp
1.87 +6 -6 fptools/ghc/includes/PrimOps.h
1.56 +7 -7 fptools/ghc/lib/std/PrelBase.lhs
1.6 +13 -7 fptools/ghc/lib/std/PrelBits.lhs
1.10 +5 -5 fptools/ghc/lib/std/PrelGHC.hi-boot.pp
1.23 +50 -32 fptools/ghc/lib/std/PrelInt.lhs
1.19 +52 -33 fptools/ghc/lib/std/PrelWord.lhs
1.5 +8 -7 fptools/ghc/lib/std/cbits/longlong.c