summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ericson <git@JohnEricson.me>2019-06-03 23:47:10 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-12-10 19:57:39 -0500
commit8f1ceb67331cfbe075c484c8d1d6b6c9f6fc1e92 (patch)
treeddd32ac61c244c5a6cf9bbcfca2cdc5b25139cb6
parent2bbfaf8abac0854a5b7f5485aa830fec669fa602 (diff)
downloadhaskell-8f1ceb67331cfbe075c484c8d1d6b6c9f6fc1e92.tar.gz
Move Int# section of primops.txt.pp
This matches the organization of the fixed-sized ones, and keeps each Int* next to its corresponding Word*.
-rw-r--r--compiler/prelude/primops.txt.pp306
1 files changed, 153 insertions, 153 deletions
diff --git a/compiler/prelude/primops.txt.pp b/compiler/prelude/primops.txt.pp
index de7d498da1..512a15e3b2 100644
--- a/compiler/prelude/primops.txt.pp
+++ b/compiler/prelude/primops.txt.pp
@@ -231,159 +231,6 @@ primop OrdOp "ord#" GenPrimOp Char# -> Int#
with code_size = 0
------------------------------------------------------------------------
-section "Int#"
- {Operations on native-size integers (32+ bits).}
-------------------------------------------------------------------------
-
-primtype Int#
-
-primop IntAddOp "+#" Dyadic
- Int# -> Int# -> Int#
- with commutable = True
- fixity = infixl 6
-
-primop IntSubOp "-#" Dyadic Int# -> Int# -> Int#
- with fixity = infixl 6
-
-primop IntMulOp "*#"
- Dyadic Int# -> Int# -> Int#
- {Low word of signed integer multiply.}
- with commutable = True
- fixity = infixl 7
-
-primop IntMul2Op "timesInt2#" GenPrimOp
- Int# -> Int# -> (# Int#, Int#, Int# #)
- {Return a triple (isHighNeeded,high,low) where high and low are respectively
- the high and low bits of the double-word result. isHighNeeded is a cheap way
- to test if the high word is a sign-extension of the low word (isHighNeeded =
- 0#) or not (isHighNeeded = 1#).}
-
-primop IntMulMayOfloOp "mulIntMayOflo#"
- Dyadic Int# -> Int# -> Int#
- {Return non-zero if there is any possibility that the upper word of a
- signed integer multiply might contain useful information. Return
- zero only if you are completely sure that no overflow can occur.
- On a 32-bit platform, the recommended implementation is to do a
- 32 x 32 -> 64 signed multiply, and subtract result[63:32] from
- (result[31] >>signed 31). If this is zero, meaning that the
- upper word is merely a sign extension of the lower one, no
- overflow can occur.
-
- On a 64-bit platform it is not always possible to
- acquire the top 64 bits of the result. Therefore, a recommended
- implementation is to take the absolute value of both operands, and
- return 0 iff bits[63:31] of them are zero, since that means that their
- magnitudes fit within 31 bits, so the magnitude of the product must fit
- into 62 bits.
-
- If in doubt, return non-zero, but do make an effort to create the
- correct answer for small args, since otherwise the performance of
- \texttt{(*) :: Integer -> Integer -> Integer} will be poor.
- }
- with commutable = True
-
-primop IntQuotOp "quotInt#" Dyadic
- Int# -> Int# -> Int#
- {Rounds towards zero. The behavior is undefined if the second argument is
- zero.
- }
- with can_fail = True
-
-primop IntRemOp "remInt#" Dyadic
- Int# -> Int# -> Int#
- {Satisfies \texttt{(quotInt\# x y) *\# y +\# (remInt\# x y) == x}. The
- behavior is undefined if the second argument is zero.
- }
- with can_fail = True
-
-primop IntQuotRemOp "quotRemInt#" GenPrimOp
- Int# -> Int# -> (# Int#, Int# #)
- {Rounds towards zero.}
- with can_fail = True
-
-primop AndIOp "andI#" Dyadic Int# -> Int# -> Int#
- {Bitwise "and".}
- with commutable = True
-
-primop OrIOp "orI#" Dyadic Int# -> Int# -> Int#
- {Bitwise "or".}
- with commutable = True
-
-primop XorIOp "xorI#" Dyadic Int# -> Int# -> Int#
- {Bitwise "xor".}
- with commutable = True
-
-primop NotIOp "notI#" Monadic Int# -> Int#
- {Bitwise "not", also known as the binary complement.}
-
-primop IntNegOp "negateInt#" Monadic Int# -> Int#
- {Unary negation.
- Since the negative {\tt Int#} range extends one further than the
- positive range, {\tt negateInt#} of the most negative number is an
- identity operation. This way, {\tt negateInt#} is always its own inverse.}
-
-primop IntAddCOp "addIntC#" GenPrimOp Int# -> Int# -> (# Int#, Int# #)
- {Add signed integers reporting overflow.
- First member of result is the sum truncated to an {\tt Int#};
- second member is zero if the true sum fits in an {\tt Int#},
- nonzero if overflow occurred (the sum is either too large
- or too small to fit in an {\tt Int#}).}
- with code_size = 2
- commutable = True
-
-primop IntSubCOp "subIntC#" GenPrimOp Int# -> Int# -> (# Int#, Int# #)
- {Subtract signed integers reporting overflow.
- First member of result is the difference truncated to an {\tt Int#};
- second member is zero if the true difference fits in an {\tt Int#},
- nonzero if overflow occurred (the difference is either too large
- or too small to fit in an {\tt Int#}).}
- with code_size = 2
-
-primop IntGtOp ">#" Compare Int# -> Int# -> Int#
- with fixity = infix 4
-
-primop IntGeOp ">=#" Compare Int# -> Int# -> Int#
- with fixity = infix 4
-
-primop IntEqOp "==#" Compare
- Int# -> Int# -> Int#
- with commutable = True
- fixity = infix 4
-
-primop IntNeOp "/=#" Compare
- Int# -> Int# -> Int#
- with commutable = True
- fixity = infix 4
-
-primop IntLtOp "<#" Compare Int# -> Int# -> Int#
- with fixity = infix 4
-
-primop IntLeOp "<=#" Compare Int# -> Int# -> Int#
- with fixity = infix 4
-
-primop ChrOp "chr#" GenPrimOp Int# -> Char#
- with code_size = 0
-
-primop Int2WordOp "int2Word#" GenPrimOp Int# -> Word#
- with code_size = 0
-
-primop Int2FloatOp "int2Float#" GenPrimOp Int# -> Float#
-primop Int2DoubleOp "int2Double#" GenPrimOp Int# -> Double#
-
-primop Word2FloatOp "word2Float#" GenPrimOp Word# -> Float#
-primop Word2DoubleOp "word2Double#" GenPrimOp Word# -> Double#
-
-primop ISllOp "uncheckedIShiftL#" GenPrimOp Int# -> Int# -> Int#
- {Shift left. Result undefined if shift amount is not
- in the range 0 to word size - 1 inclusive.}
-primop ISraOp "uncheckedIShiftRA#" GenPrimOp Int# -> Int# -> Int#
- {Shift right arithmetic. Result undefined if shift amount is not
- in the range 0 to word size - 1 inclusive.}
-primop ISrlOp "uncheckedIShiftRL#" GenPrimOp Int# -> Int# -> Int#
- {Shift right logical. Result undefined if shift amount is not
- in the range 0 to word size - 1 inclusive.}
-
-------------------------------------------------------------------------
section "Int8#"
{Operations on 8-bit integers.}
------------------------------------------------------------------------
@@ -548,6 +395,159 @@ primop Word16LtOp "ltWord16#" Compare Word16# -> Word16# -> Int#
primop Word16NeOp "neWord16#" Compare Word16# -> Word16# -> Int#
------------------------------------------------------------------------
+section "Int#"
+ {Operations on native-size integers (32+ bits).}
+------------------------------------------------------------------------
+
+primtype Int#
+
+primop IntAddOp "+#" Dyadic
+ Int# -> Int# -> Int#
+ with commutable = True
+ fixity = infixl 6
+
+primop IntSubOp "-#" Dyadic Int# -> Int# -> Int#
+ with fixity = infixl 6
+
+primop IntMulOp "*#"
+ Dyadic Int# -> Int# -> Int#
+ {Low word of signed integer multiply.}
+ with commutable = True
+ fixity = infixl 7
+
+primop IntMul2Op "timesInt2#" GenPrimOp
+ Int# -> Int# -> (# Int#, Int#, Int# #)
+ {Return a triple (isHighNeeded,high,low) where high and low are respectively
+ the high and low bits of the double-word result. isHighNeeded is a cheap way
+ to test if the high word is a sign-extension of the low word (isHighNeeded =
+ 0#) or not (isHighNeeded = 1#).}
+
+primop IntMulMayOfloOp "mulIntMayOflo#"
+ Dyadic Int# -> Int# -> Int#
+ {Return non-zero if there is any possibility that the upper word of a
+ signed integer multiply might contain useful information. Return
+ zero only if you are completely sure that no overflow can occur.
+ On a 32-bit platform, the recommended implementation is to do a
+ 32 x 32 -> 64 signed multiply, and subtract result[63:32] from
+ (result[31] >>signed 31). If this is zero, meaning that the
+ upper word is merely a sign extension of the lower one, no
+ overflow can occur.
+
+ On a 64-bit platform it is not always possible to
+ acquire the top 64 bits of the result. Therefore, a recommended
+ implementation is to take the absolute value of both operands, and
+ return 0 iff bits[63:31] of them are zero, since that means that their
+ magnitudes fit within 31 bits, so the magnitude of the product must fit
+ into 62 bits.
+
+ If in doubt, return non-zero, but do make an effort to create the
+ correct answer for small args, since otherwise the performance of
+ \texttt{(*) :: Integer -> Integer -> Integer} will be poor.
+ }
+ with commutable = True
+
+primop IntQuotOp "quotInt#" Dyadic
+ Int# -> Int# -> Int#
+ {Rounds towards zero. The behavior is undefined if the second argument is
+ zero.
+ }
+ with can_fail = True
+
+primop IntRemOp "remInt#" Dyadic
+ Int# -> Int# -> Int#
+ {Satisfies \texttt{(quotInt\# x y) *\# y +\# (remInt\# x y) == x}. The
+ behavior is undefined if the second argument is zero.
+ }
+ with can_fail = True
+
+primop IntQuotRemOp "quotRemInt#" GenPrimOp
+ Int# -> Int# -> (# Int#, Int# #)
+ {Rounds towards zero.}
+ with can_fail = True
+
+primop AndIOp "andI#" Dyadic Int# -> Int# -> Int#
+ {Bitwise "and".}
+ with commutable = True
+
+primop OrIOp "orI#" Dyadic Int# -> Int# -> Int#
+ {Bitwise "or".}
+ with commutable = True
+
+primop XorIOp "xorI#" Dyadic Int# -> Int# -> Int#
+ {Bitwise "xor".}
+ with commutable = True
+
+primop NotIOp "notI#" Monadic Int# -> Int#
+ {Bitwise "not", also known as the binary complement.}
+
+primop IntNegOp "negateInt#" Monadic Int# -> Int#
+ {Unary negation.
+ Since the negative {\tt Int#} range extends one further than the
+ positive range, {\tt negateInt#} of the most negative number is an
+ identity operation. This way, {\tt negateInt#} is always its own inverse.}
+
+primop IntAddCOp "addIntC#" GenPrimOp Int# -> Int# -> (# Int#, Int# #)
+ {Add signed integers reporting overflow.
+ First member of result is the sum truncated to an {\tt Int#};
+ second member is zero if the true sum fits in an {\tt Int#},
+ nonzero if overflow occurred (the sum is either too large
+ or too small to fit in an {\tt Int#}).}
+ with code_size = 2
+ commutable = True
+
+primop IntSubCOp "subIntC#" GenPrimOp Int# -> Int# -> (# Int#, Int# #)
+ {Subtract signed integers reporting overflow.
+ First member of result is the difference truncated to an {\tt Int#};
+ second member is zero if the true difference fits in an {\tt Int#},
+ nonzero if overflow occurred (the difference is either too large
+ or too small to fit in an {\tt Int#}).}
+ with code_size = 2
+
+primop IntGtOp ">#" Compare Int# -> Int# -> Int#
+ with fixity = infix 4
+
+primop IntGeOp ">=#" Compare Int# -> Int# -> Int#
+ with fixity = infix 4
+
+primop IntEqOp "==#" Compare
+ Int# -> Int# -> Int#
+ with commutable = True
+ fixity = infix 4
+
+primop IntNeOp "/=#" Compare
+ Int# -> Int# -> Int#
+ with commutable = True
+ fixity = infix 4
+
+primop IntLtOp "<#" Compare Int# -> Int# -> Int#
+ with fixity = infix 4
+
+primop IntLeOp "<=#" Compare Int# -> Int# -> Int#
+ with fixity = infix 4
+
+primop ChrOp "chr#" GenPrimOp Int# -> Char#
+ with code_size = 0
+
+primop Int2WordOp "int2Word#" GenPrimOp Int# -> Word#
+ with code_size = 0
+
+primop Int2FloatOp "int2Float#" GenPrimOp Int# -> Float#
+primop Int2DoubleOp "int2Double#" GenPrimOp Int# -> Double#
+
+primop Word2FloatOp "word2Float#" GenPrimOp Word# -> Float#
+primop Word2DoubleOp "word2Double#" GenPrimOp Word# -> Double#
+
+primop ISllOp "uncheckedIShiftL#" GenPrimOp Int# -> Int# -> Int#
+ {Shift left. Result undefined if shift amount is not
+ in the range 0 to word size - 1 inclusive.}
+primop ISraOp "uncheckedIShiftRA#" GenPrimOp Int# -> Int# -> Int#
+ {Shift right arithmetic. Result undefined if shift amount is not
+ in the range 0 to word size - 1 inclusive.}
+primop ISrlOp "uncheckedIShiftRL#" GenPrimOp Int# -> Int# -> Int#
+ {Shift right logical. Result undefined if shift amount is not
+ in the range 0 to word size - 1 inclusive.}
+
+------------------------------------------------------------------------
section "Word#"
{Operations on native-sized unsigned words (32+ bits).}
------------------------------------------------------------------------