diff options
author | Jan Stolarek <jan.stolarek@p.lodz.pl> | 2013-02-15 13:10:36 +0100 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2013-02-18 09:37:49 +0000 |
commit | 29e86f9b178d3cf436629641ec1f2502c67f0347 (patch) | |
tree | cbc66f8bb4e25c803f2a48ced1a54eb8ea0ab063 /compiler | |
parent | 1bb33135e0f46369dd8ddbf8b71f87fc211511e8 (diff) | |
download | haskell-29e86f9b178d3cf436629641ec1f2502c67f0347.tar.gz |
Primitive bitwise operations on Int# (Fixes #7689)
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/codeGen/StgCmmPrim.hs | 4 | ||||
-rw-r--r-- | compiler/prelude/PrelRules.lhs | 9 | ||||
-rw-r--r-- | compiler/prelude/primops.txt.pp | 11 |
3 files changed, 24 insertions, 0 deletions
diff --git a/compiler/codeGen/StgCmmPrim.hs b/compiler/codeGen/StgCmmPrim.hs index 4005f6d9b4..05ef2b270c 100644 --- a/compiler/codeGen/StgCmmPrim.hs +++ b/compiler/codeGen/StgCmmPrim.hs @@ -880,6 +880,10 @@ translateOp dflags IntLeOp = Just (mo_wordSLe dflags) translateOp dflags IntGtOp = Just (mo_wordSGt dflags) translateOp dflags IntLtOp = Just (mo_wordSLt dflags) +translateOp dflags AndIOp = Just (mo_wordAnd dflags) +translateOp dflags OrIOp = Just (mo_wordOr dflags) +translateOp dflags XorIOp = Just (mo_wordXor dflags) +translateOp dflags NotIOp = Just (mo_wordNot dflags) translateOp dflags ISllOp = Just (mo_wordShl dflags) translateOp dflags ISraOp = Just (mo_wordSShr dflags) translateOp dflags ISrlOp = Just (mo_wordUShr dflags) diff --git a/compiler/prelude/PrelRules.lhs b/compiler/prelude/PrelRules.lhs index 2e55e497d7..079ab0cc98 100644 --- a/compiler/prelude/PrelRules.lhs +++ b/compiler/prelude/PrelRules.lhs @@ -100,6 +100,15 @@ primOpRules nm IntRemOp = mkPrimOpRule nm 2 [ nonZeroLit 1 >> binaryLit (intO retLit zeroi , equalArgs >> retLit zeroi , equalArgs >> retLit zeroi ] +primOpRules nm AndIOp = mkPrimOpRule nm 2 [ binaryLit (intOp2 (.&.)) + , idempotent + , zeroElem zeroi ] +primOpRules nm OrIOp = mkPrimOpRule nm 2 [ binaryLit (intOp2 (.|.)) + , idempotent + , identityDynFlags zeroi ] +primOpRules nm XorIOp = mkPrimOpRule nm 2 [ binaryLit (intOp2 xor) + , identityDynFlags zeroi + , equalArgs >> retLit zeroi ] primOpRules nm IntNegOp = mkPrimOpRule nm 1 [ unaryLit negOp , inversePrimOp IntNegOp ] primOpRules nm ISllOp = mkPrimOpRule nm 2 [ binaryLit (intOp2 Bits.shiftL) diff --git a/compiler/prelude/primops.txt.pp b/compiler/prelude/primops.txt.pp index a5b0fec908..45472816c0 100644 --- a/compiler/prelude/primops.txt.pp +++ b/compiler/prelude/primops.txt.pp @@ -217,6 +217,17 @@ primop IntQuotRemOp "quotRemInt#" GenPrimOp {Rounds towards zero.} with can_fail = True +primop AndIOp "andI#" Dyadic Int# -> Int# -> Int# + with commutable = True + +primop OrIOp "orI#" Dyadic Int# -> Int# -> Int# + with commutable = True + +primop XorIOp "xorI#" Dyadic Int# -> Int# -> Int# + with commutable = True + +primop NotIOp "notI#" Monadic Int# -> Int# + primop IntNegOp "negateInt#" Monadic Int# -> Int# primop IntAddCOp "addIntC#" GenPrimOp Int# -> Int# -> (# Int#, Int# #) {Add with carry. First member of result is (wrapped) sum; |