summaryrefslogtreecommitdiff
path: root/compiler/prelude
diff options
context:
space:
mode:
authorJan Stolarek <jan.stolarek@p.lodz.pl>2013-02-15 13:10:36 +0100
committerSimon Marlow <marlowsd@gmail.com>2013-02-18 09:37:49 +0000
commit29e86f9b178d3cf436629641ec1f2502c67f0347 (patch)
treecbc66f8bb4e25c803f2a48ced1a54eb8ea0ab063 /compiler/prelude
parent1bb33135e0f46369dd8ddbf8b71f87fc211511e8 (diff)
downloadhaskell-29e86f9b178d3cf436629641ec1f2502c67f0347.tar.gz
Primitive bitwise operations on Int# (Fixes #7689)
Diffstat (limited to 'compiler/prelude')
-rw-r--r--compiler/prelude/PrelRules.lhs9
-rw-r--r--compiler/prelude/primops.txt.pp11
2 files changed, 20 insertions, 0 deletions
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;