5 Miscellaneous primitive operations on StgInt64 and StgWord64s.
7 Instead of going the normal (boring) route of making the list
8 of primitive operations even longer to cope with operations
9 over 64-bit entities, we implement them instead 'out-of-line'.
11 The primitive ops get their own routine (in C) that implements
12 the operation, requiring the caller to _ccall_ out. This has
13 performance implications of course, but we currently don't
14 expect intensive use of the Int64 and Word64 types.
16 The exceptions to the rule are primops that cast to and from
19 NOTE: We prefix all these primops with "stg_". No particular
32 stg_gtWord64(StgWord64 l1, StgWord64 l2)
33 { return ( l1 > l2); }
36 stg_geWord64(StgWord64 l1, StgWord64 l2)
37 { return ( l1 >= l2); }
40 stg_eqWord64(StgWord64 l1, StgWord64 l2)
41 { return ( l1 == l2); }
44 stg_neWord64(StgWord64 l1, StgWord64 l2)
45 { return ( l1 != l2); }
48 stg_ltWord64(StgWord64 l1, StgWord64 l2)
49 { return ( l1 < l2); }
52 stg_leWord64(StgWord64 l1, StgWord64 l2)
53 { return ( l1 <= l2); }
55 /* ------------------ */
58 stg_gtInt64(StgInt64 l1, StgInt64 l2)
59 { return ( l1 > l2); }
62 stg_geInt64(StgInt64 l1, StgInt64 l2)
63 { return ( l1 >= l2); }
66 stg_eqInt64(StgInt64 l1, StgInt64 l2)
67 { return ( l1 == l2); }
70 stg_neInt64(StgInt64 l1, StgInt64 l2)
71 { return ( l1 != l2); }
74 stg_ltInt64(StgInt64 l1, StgInt64 l2)
75 { return ( l1 < l2); }
78 stg_leInt64(StgInt64 l1, StgInt64 l2)
79 { return ( l1 <= l2); }
90 stg_remWord64(StgWord64 a, StgWord64 b)
94 stg_quotWord64(StgWord64 a, StgWord64 b)
98 stg_remInt64(StgInt64 a, StgInt64 b)
102 stg_quotInt64(StgInt64 a, StgInt64 b)
106 stg_negateInt64(StgInt64 a)
110 stg_plusInt64(StgInt64 a, StgInt64 b)
114 stg_minusInt64(StgInt64 a, StgInt64 b)
118 stg_timesInt64(StgInt64 a, StgInt64 b)
130 stg_and64(StgWord64 a, StgWord64 b)
134 stg_or64(StgWord64 a, StgWord64 b)
138 stg_xor64(StgWord64 a, StgWord64 b)
142 stg_not64(StgWord64 a)
146 stg_shiftL64(StgWord64 a, StgInt b)
150 stg_shiftRL64(StgWord64 a, StgInt b)
154 stg_iShiftL64(StgInt64 a, StgInt b)
157 /* Right shifting of signed quantities is not portable in C, so
158 the behaviour you'll get from using these primops depends
159 on the whatever your C compiler is doing. ToDo: fix. -- sof 8/98
163 stg_iShiftRA64(StgInt64 a, StgInt b)
167 stg_iShiftRL64(StgInt64 a, StgInt b)
175 Casting between longs and longer longs:
176 (the primops that cast from to/from Integers and long longs are
177 expressed as macros, since these may cause some heap allocation).
181 stg_intToInt64(StgInt i)
182 { return ( (StgInt64)i ); }
185 stg_int64ToInt(StgInt64 i)
186 { return ( (StgInt)i ); }
189 stg_int64ToWord64(StgInt64 i)
190 { return ( (StgWord64)i ); }
193 stg_wordToWord64(StgWord w)
194 { return ( (StgWord64)w ); }
197 stg_word64ToWord(StgWord64 w)
198 { return ( (StgWord)w ); }
201 stg_word64ToInt64(StgWord64 w)
202 { return ( (StgInt64)w ); }