summaryrefslogtreecommitdiff
path: root/ghc
diff options
context:
space:
mode:
authorrrt <unknown>2001-07-13 11:03:47 +0000
committerrrt <unknown>2001-07-13 11:03:47 +0000
commitc51aae8f14a7a7d546839d97c1b32491a8080c6a (patch)
tree6957cb51091f1f60120ef55b7dc04a228b8857a4 /ghc
parent434ef2b14b37df405602a74838b8b38d0f5b4375 (diff)
downloadhaskell-c51aae8f14a7a7d546839d97c1b32491a8080c6a.tar.gz
[project @ 2001-07-13 11:03:47 by rrt]
Move 64-bit arithmetic support into std_cbits; there's no reason for it to be in the RTS.
Diffstat (limited to 'ghc')
-rw-r--r--ghc/lib/std/PrelInt.lhs50
-rw-r--r--ghc/lib/std/PrelWord.lhs46
-rw-r--r--ghc/lib/std/cbits/longlong.c89
-rw-r--r--ghc/rts/StgLongLong.c91
4 files changed, 137 insertions, 139 deletions
diff --git a/ghc/lib/std/PrelInt.lhs b/ghc/lib/std/PrelInt.lhs
index 2041e57562..43f9db9a19 100644
--- a/ghc/lib/std/PrelInt.lhs
+++ b/ghc/lib/std/PrelInt.lhs
@@ -463,31 +463,31 @@ instance Bits Int64 where
bitSize _ = 64
isSigned _ = True
-foreign import "stg_eqInt64" unsafe eqInt64# :: Int64# -> Int64# -> Bool
-foreign import "stg_neInt64" unsafe neInt64# :: Int64# -> Int64# -> Bool
-foreign import "stg_ltInt64" unsafe ltInt64# :: Int64# -> Int64# -> Bool
-foreign import "stg_leInt64" unsafe leInt64# :: Int64# -> Int64# -> Bool
-foreign import "stg_gtInt64" unsafe gtInt64# :: Int64# -> Int64# -> Bool
-foreign import "stg_geInt64" unsafe geInt64# :: Int64# -> Int64# -> Bool
-foreign import "stg_plusInt64" unsafe plusInt64# :: Int64# -> Int64# -> Int64#
-foreign import "stg_minusInt64" unsafe minusInt64# :: Int64# -> Int64# -> Int64#
-foreign import "stg_timesInt64" unsafe timesInt64# :: Int64# -> Int64# -> Int64#
-foreign import "stg_negateInt64" unsafe negateInt64# :: Int64# -> Int64#
-foreign import "stg_quotInt64" unsafe quotInt64# :: Int64# -> Int64# -> Int64#
-foreign import "stg_remInt64" unsafe remInt64# :: Int64# -> Int64# -> Int64#
-foreign import "stg_intToInt64" unsafe intToInt64# :: Int# -> Int64#
-foreign import "stg_int64ToInt" unsafe int64ToInt# :: Int64# -> Int#
-foreign import "stg_wordToWord64" unsafe wordToWord64# :: Word# -> Word64#
-foreign import "stg_int64ToWord64" unsafe int64ToWord64# :: Int64# -> Word64#
-foreign import "stg_word64ToInt64" unsafe word64ToInt64# :: Word64# -> Int64#
-foreign import "stg_and64" unsafe and64# :: Word64# -> Word64# -> Word64#
-foreign import "stg_or64" unsafe or64# :: Word64# -> Word64# -> Word64#
-foreign import "stg_xor64" unsafe xor64# :: Word64# -> Word64# -> Word64#
-foreign import "stg_not64" unsafe not64# :: Word64# -> Word64#
-foreign import "stg_iShiftL64" unsafe iShiftL64# :: Int64# -> Int# -> Int64#
-foreign import "stg_iShiftRA64" unsafe iShiftRA64# :: Int64# -> Int# -> Int64#
-foreign import "stg_shiftL64" unsafe shiftL64# :: Word64# -> Int# -> Word64#
-foreign import "stg_shiftRL64" unsafe shiftRL64# :: Word64# -> Int# -> Word64#
+foreign import "eqInt64" unsafe eqInt64# :: Int64# -> Int64# -> Bool
+foreign import "neInt64" unsafe neInt64# :: Int64# -> Int64# -> Bool
+foreign import "ltInt64" unsafe ltInt64# :: Int64# -> Int64# -> Bool
+foreign import "leInt64" unsafe leInt64# :: Int64# -> Int64# -> Bool
+foreign import "gtInt64" unsafe gtInt64# :: Int64# -> Int64# -> Bool
+foreign import "geInt64" unsafe geInt64# :: Int64# -> Int64# -> Bool
+foreign import "plusInt64" unsafe plusInt64# :: Int64# -> Int64# -> Int64#
+foreign import "minusInt64" unsafe minusInt64# :: Int64# -> Int64# -> Int64#
+foreign import "timesInt64" unsafe timesInt64# :: Int64# -> Int64# -> Int64#
+foreign import "negateInt64" unsafe negateInt64# :: Int64# -> Int64#
+foreign import "quotInt64" unsafe quotInt64# :: Int64# -> Int64# -> Int64#
+foreign import "remInt64" unsafe remInt64# :: Int64# -> Int64# -> Int64#
+foreign import "intToInt64" unsafe intToInt64# :: Int# -> Int64#
+foreign import "int64ToInt" unsafe int64ToInt# :: Int64# -> Int#
+foreign import "wordToWord64" unsafe wordToWord64# :: Word# -> Word64#
+foreign import "int64ToWord64" unsafe int64ToWord64# :: Int64# -> Word64#
+foreign import "word64ToInt64" unsafe word64ToInt64# :: Word64# -> Int64#
+foreign import "and64" unsafe and64# :: Word64# -> Word64# -> Word64#
+foreign import "or64" unsafe or64# :: Word64# -> Word64# -> Word64#
+foreign import "xor64" unsafe xor64# :: Word64# -> Word64# -> Word64#
+foreign import "not64" unsafe not64# :: Word64# -> Word64#
+foreign import "iShiftL64" unsafe iShiftL64# :: Int64# -> Int# -> Int64#
+foreign import "iShiftRA64" unsafe iShiftRA64# :: Int64# -> Int# -> Int64#
+foreign import "shiftL64" unsafe shiftL64# :: Word64# -> Int# -> Word64#
+foreign import "shiftRL64" unsafe shiftRL64# :: Word64# -> Int# -> Word64#
{-# RULES
"fromIntegral/Int->Int64" fromIntegral = \(I# x#) -> I64# (intToInt64# x#)
diff --git a/ghc/lib/std/PrelWord.lhs b/ghc/lib/std/PrelWord.lhs
index 0a8bc1dfa6..95f84e4f3d 100644
--- a/ghc/lib/std/PrelWord.lhs
+++ b/ghc/lib/std/PrelWord.lhs
@@ -598,29 +598,29 @@ instance Bits Word64 where
bitSize _ = 64
isSigned _ = False
-foreign import "stg_eqWord64" unsafe eqWord64# :: Word64# -> Word64# -> Bool
-foreign import "stg_neWord64" unsafe neWord64# :: Word64# -> Word64# -> Bool
-foreign import "stg_ltWord64" unsafe ltWord64# :: Word64# -> Word64# -> Bool
-foreign import "stg_leWord64" unsafe leWord64# :: Word64# -> Word64# -> Bool
-foreign import "stg_gtWord64" unsafe gtWord64# :: Word64# -> Word64# -> Bool
-foreign import "stg_geWord64" unsafe geWord64# :: Word64# -> Word64# -> Bool
-foreign import "stg_int64ToWord64" unsafe int64ToWord64# :: Int64# -> Word64#
-foreign import "stg_word64ToInt64" unsafe word64ToInt64# :: Word64# -> Int64#
-foreign import "stg_plusInt64" unsafe plusInt64# :: Int64# -> Int64# -> Int64#
-foreign import "stg_minusInt64" unsafe minusInt64# :: Int64# -> Int64# -> Int64#
-foreign import "stg_timesInt64" unsafe timesInt64# :: Int64# -> Int64# -> Int64#
-foreign import "stg_negateInt64" unsafe negateInt64# :: Int64# -> Int64#
-foreign import "stg_intToInt64" unsafe intToInt64# :: Int# -> Int64#
-foreign import "stg_wordToWord64" unsafe wordToWord64# :: Word# -> Word64#
-foreign import "stg_word64ToWord" unsafe word64ToWord# :: Word64# -> Word#
-foreign import "stg_quotWord64" unsafe quotWord64# :: Word64# -> Word64# -> Word64#
-foreign import "stg_remWord64" unsafe remWord64# :: Word64# -> Word64# -> Word64#
-foreign import "stg_and64" unsafe and64# :: Word64# -> Word64# -> Word64#
-foreign import "stg_or64" unsafe or64# :: Word64# -> Word64# -> Word64#
-foreign import "stg_xor64" unsafe xor64# :: Word64# -> Word64# -> Word64#
-foreign import "stg_not64" unsafe not64# :: Word64# -> Word64#
-foreign import "stg_shiftL64" unsafe shiftL64# :: Word64# -> Int# -> Word64#
-foreign import "stg_shiftRL64" unsafe shiftRL64# :: Word64# -> Int# -> Word64#
+foreign import "eqWord64" unsafe eqWord64# :: Word64# -> Word64# -> Bool
+foreign import "neWord64" unsafe neWord64# :: Word64# -> Word64# -> Bool
+foreign import "ltWord64" unsafe ltWord64# :: Word64# -> Word64# -> Bool
+foreign import "leWord64" unsafe leWord64# :: Word64# -> Word64# -> Bool
+foreign import "gtWord64" unsafe gtWord64# :: Word64# -> Word64# -> Bool
+foreign import "geWord64" unsafe geWord64# :: Word64# -> Word64# -> Bool
+foreign import "int64ToWord64" unsafe int64ToWord64# :: Int64# -> Word64#
+foreign import "word64ToInt64" unsafe word64ToInt64# :: Word64# -> Int64#
+foreign import "plusInt64" unsafe plusInt64# :: Int64# -> Int64# -> Int64#
+foreign import "minusInt64" unsafe minusInt64# :: Int64# -> Int64# -> Int64#
+foreign import "timesInt64" unsafe timesInt64# :: Int64# -> Int64# -> Int64#
+foreign import "negateInt64" unsafe negateInt64# :: Int64# -> Int64#
+foreign import "intToInt64" unsafe intToInt64# :: Int# -> Int64#
+foreign import "wordToWord64" unsafe wordToWord64# :: Word# -> Word64#
+foreign import "word64ToWord" unsafe word64ToWord# :: Word64# -> Word#
+foreign import "quotWord64" unsafe quotWord64# :: Word64# -> Word64# -> Word64#
+foreign import "remWord64" unsafe remWord64# :: Word64# -> Word64# -> Word64#
+foreign import "and64" unsafe and64# :: Word64# -> Word64# -> Word64#
+foreign import "or64" unsafe or64# :: Word64# -> Word64# -> Word64#
+foreign import "xor64" unsafe xor64# :: Word64# -> Word64# -> Word64#
+foreign import "not64" unsafe not64# :: Word64# -> Word64#
+foreign import "shiftL64" unsafe shiftL64# :: Word64# -> Int# -> Word64#
+foreign import "shiftRL64" unsafe shiftRL64# :: Word64# -> Int# -> Word64#
{-# RULES
"fromIntegral/Int->Word64" fromIntegral = \(I# x#) -> W64# (int64ToWord64# (intToInt64# x#))
diff --git a/ghc/lib/std/cbits/longlong.c b/ghc/lib/std/cbits/longlong.c
new file mode 100644
index 0000000000..6578504d69
--- /dev/null
+++ b/ghc/lib/std/cbits/longlong.c
@@ -0,0 +1,89 @@
+/* -----------------------------------------------------------------------------
+ * $Id: longlong.c,v 1.1 2001/07/13 11:03:47 rrt Exp $
+ *
+ * (c) The GHC Team, 1998-1999
+ *
+ * Primitive operations over (64-bit) long longs
+ * (only used on 32-bit platforms.)
+ *
+ * ---------------------------------------------------------------------------*/
+
+
+/*
+Miscellaneous primitive operations on StgInt64 and StgWord64s.
+N.B. These are not primops!
+
+Instead of going the normal (boring) route of making the list
+of primitive operations even longer to cope with operations
+over 64-bit entities, we implement them instead 'out-of-line'.
+
+The primitive ops get their own routine (in C) that implements
+the operation, requiring the caller to _ccall_ out. This has
+performance implications of course, but we currently don't
+expect intensive use of either Int64 or Word64 types.
+
+The exceptions to the rule are primops that cast to and from
+64-bit entities (these are defined in PrimOps.h)
+*/
+
+#include "Stg.h"
+
+#ifdef SUPPORT_LONG_LONGS
+
+/* Relational operators */
+
+StgBool gtWord64 (StgWord64 a, StgWord64 b) {return a > b;}
+StgBool geWord64 (StgWord64 a, StgWord64 b) {return a >= b;}
+StgBool eqWord64 (StgWord64 a, StgWord64 b) {return a == b;}
+StgBool neWord64 (StgWord64 a, StgWord64 b) {return a != b;}
+StgBool ltWord64 (StgWord64 a, StgWord64 b) {return a < b;}
+StgBool leWord64 (StgWord64 a, StgWord64 b) {return a <= b;}
+
+StgBool gtInt64 (StgInt64 a, StgInt64 b) {return a > b;}
+StgBool geInt64 (StgInt64 a, StgInt64 b) {return a >= b;}
+StgBool eqInt64 (StgInt64 a, StgInt64 b) {return a == b;}
+StgBool neInt64 (StgInt64 a, StgInt64 b) {return a != b;}
+StgBool ltInt64 (StgInt64 a, StgInt64 b) {return a < b;}
+StgBool leInt64 (StgInt64 a, StgInt64 b) {return a <= b;}
+
+/* Arithmetic operators */
+
+StgWord64 remWord64 (StgWord64 a, StgWord64 b) {return a % b;}
+StgWord64 quotWord64 (StgWord64 a, StgWord64 b) {return a / b;}
+StgInt64 remInt64 (StgInt64 a, StgInt64 b) {return a % b;}
+StgInt64 quotInt64 (StgInt64 a, StgInt64 b) {return a / b;}
+StgInt64 negateInt64 (StgInt64 a) {return -a;}
+StgInt64 plusInt64 (StgInt64 a, StgInt64 b) {return a + b;}
+StgInt64 minusInt64 (StgInt64 a, StgInt64 b) {return a - b;}
+StgInt64 timesInt64 (StgInt64 a, StgInt64 b) {return a * b;}
+
+/* Logical operators: */
+
+StgWord64 and64 (StgWord64 a, StgWord64 b) {return a & b;}
+StgWord64 or64 (StgWord64 a, StgWord64 b) {return a | b;}
+StgWord64 xor64 (StgWord64 a, StgWord64 b) {return a ^ b;}
+StgWord64 not64 (StgWord64 a) {return ~a;}
+StgWord64 shiftL64 (StgWord64 a, StgInt b) {return a << b;}
+StgWord64 shiftRL64 (StgWord64 a, StgInt b) {return a >> b;}
+/* Right shifting of signed quantities is not portable in C, so
+ the behaviour you'll get from using these primops depends
+ on the whatever your C compiler is doing. ToDo: fix. -- sof 8/98
+*/
+StgInt64 iShiftL64 (StgInt64 a, StgInt b) {return a << b;}
+StgInt64 iShiftRA64 (StgInt64 a, StgInt b) {return a >> b;}
+StgInt64 iShiftRL64 (StgInt64 a, StgInt b)
+{return (StgInt64) ((StgWord64) a >> b);}
+
+/* Casting between longs and longer longs:
+ (the primops that cast between Integers and long longs are
+ expressed as macros, since these may cause some heap allocation).
+*/
+
+StgInt64 intToInt64 (StgInt i) {return (StgInt64) i;}
+StgInt int64ToInt (StgInt64 i) {return (StgInt) i;}
+StgWord64 int64ToWord64 (StgInt64 i) {return (StgWord64) i;}
+StgWord64 wordToWord64 (StgWord w) {return (StgWord64) w;}
+StgWord word64ToWord (StgWord64 w) {return (StgWord) w;}
+StgInt64 word64ToInt64 (StgWord64 w) {return (StgInt64) w;}
+
+#endif /* SUPPORT_LONG_LONGS */
diff --git a/ghc/rts/StgLongLong.c b/ghc/rts/StgLongLong.c
deleted file mode 100644
index a2d884f585..0000000000
--- a/ghc/rts/StgLongLong.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/* -----------------------------------------------------------------------------
- * $Id: StgLongLong.c,v 1.5 2001/02/28 00:01:04 qrczak Exp $
- *
- * (c) The GHC Team, 1998-1999
- *
- * Primitive operations over (64-bit) long longs
- * (only used on 32-bit platforms.)
- *
- * ---------------------------------------------------------------------------*/
-
-
-/*
-Miscellaneous primitive operations on StgInt64 and StgWord64s.
-
-Instead of going the normal (boring) route of making the list
-of primitive operations even longer to cope with operations
-over 64-bit entities, we implement them instead 'out-of-line'.
-
-The primitive ops get their own routine (in C) that implements
-the operation, requiring the caller to _ccall_ out. This has
-performance implications of course, but we currently don't
-expect intensive use of either Int64 or Word64 types.
-
-The exceptions to the rule are primops that cast to and from
-64-bit entities (these are defined in PrimOps.h)
-
-NOTE: We prefix all these primops with "stg_". No particular
-reason why.
-*/
-
-#include "Rts.h"
-
-#ifdef SUPPORT_LONG_LONGS
-
-/* Relational operators */
-
-StgBool stg_gtWord64 (StgWord64 a, StgWord64 b) {return a > b;}
-StgBool stg_geWord64 (StgWord64 a, StgWord64 b) {return a >= b;}
-StgBool stg_eqWord64 (StgWord64 a, StgWord64 b) {return a == b;}
-StgBool stg_neWord64 (StgWord64 a, StgWord64 b) {return a != b;}
-StgBool stg_ltWord64 (StgWord64 a, StgWord64 b) {return a < b;}
-StgBool stg_leWord64 (StgWord64 a, StgWord64 b) {return a <= b;}
-
-StgBool stg_gtInt64 (StgInt64 a, StgInt64 b) {return a > b;}
-StgBool stg_geInt64 (StgInt64 a, StgInt64 b) {return a >= b;}
-StgBool stg_eqInt64 (StgInt64 a, StgInt64 b) {return a == b;}
-StgBool stg_neInt64 (StgInt64 a, StgInt64 b) {return a != b;}
-StgBool stg_ltInt64 (StgInt64 a, StgInt64 b) {return a < b;}
-StgBool stg_leInt64 (StgInt64 a, StgInt64 b) {return a <= b;}
-
-/* Arithmetic operators */
-
-StgWord64 stg_remWord64 (StgWord64 a, StgWord64 b) {return a % b;}
-StgWord64 stg_quotWord64 (StgWord64 a, StgWord64 b) {return a / b;}
-StgInt64 stg_remInt64 (StgInt64 a, StgInt64 b) {return a % b;}
-StgInt64 stg_quotInt64 (StgInt64 a, StgInt64 b) {return a / b;}
-StgInt64 stg_negateInt64 (StgInt64 a) {return -a;}
-StgInt64 stg_plusInt64 (StgInt64 a, StgInt64 b) {return a + b;}
-StgInt64 stg_minusInt64 (StgInt64 a, StgInt64 b) {return a - b;}
-StgInt64 stg_timesInt64 (StgInt64 a, StgInt64 b) {return a * b;}
-
-/* Logical operators: */
-
-StgWord64 stg_and64 (StgWord64 a, StgWord64 b) {return a & b;}
-StgWord64 stg_or64 (StgWord64 a, StgWord64 b) {return a | b;}
-StgWord64 stg_xor64 (StgWord64 a, StgWord64 b) {return a ^ b;}
-StgWord64 stg_not64 (StgWord64 a) {return ~a;}
-StgWord64 stg_shiftL64 (StgWord64 a, StgInt b) {return a << b;}
-StgWord64 stg_shiftRL64 (StgWord64 a, StgInt b) {return a >> b;}
-/* Right shifting of signed quantities is not portable in C, so
- the behaviour you'll get from using these primops depends
- on the whatever your C compiler is doing. ToDo: fix. -- sof 8/98
-*/
-StgInt64 stg_iShiftL64 (StgInt64 a, StgInt b) {return a << b;}
-StgInt64 stg_iShiftRA64 (StgInt64 a, StgInt b) {return a >> b;}
-StgInt64 stg_iShiftRL64 (StgInt64 a, StgInt b)
-{return (StgInt64) ((StgWord64) a >> b);}
-
-/* Casting between longs and longer longs:
- (the primops that cast between Integers and long longs are
- expressed as macros, since these may cause some heap allocation).
-*/
-
-StgInt64 stg_intToInt64 (StgInt i) {return (StgInt64) i;}
-StgInt stg_int64ToInt (StgInt64 i) {return (StgInt) i;}
-StgWord64 stg_int64ToWord64 (StgInt64 i) {return (StgWord64) i;}
-StgWord64 stg_wordToWord64 (StgWord w) {return (StgWord64) w;}
-StgWord stg_word64ToWord (StgWord64 w) {return (StgWord) w;}
-StgInt64 stg_word64ToInt64 (StgWord64 w) {return (StgInt64) w;}
-
-#endif /* SUPPORT_LONG_LONGS */