summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2020-12-03 18:54:54 +0100
committerJohn Ericson <John.Ericson@Obsidian.Systems>2021-02-27 19:42:51 +0000
commitb7c1e487fcdd77f31fd8da2cc849b5d54a723255 (patch)
treeb9ba6e542f96973162ba5f0149028e7590e6f77b
parent157fe938eabf6428fa9de42d57f8cfad08b38ddb (diff)
downloadhaskell-wip/primop-naming-consistency.tar.gz
Fix array and cleanup conversion primops (#19026)wip/primop-naming-consistency
The first change makes the array ones use the proper fixed-size types, which also means that just like before, they can be used without explicit conversions with the boxed sized types. (Before, it was Int# / Word# on both sides, now it is fixed sized on both sides). For the second change, don't use "extend" or "narrow" in some of the user-facing primops names for conversions. - Names like `narrowInt32#` are misleading when `Int` is 32-bits. - Names like `extendInt64#` are flat-out wrong when `Int is 32-bits. - `narrow{Int,Word}<N>#` however map a type to itself, and so don't suffer from this problem. They are left as-is. These changes are batched together because Alex happend to use the array ops. We can only use released versions of Alex at this time, sadly, and I don't want to have to have a release thatwon't work for the final GHC 9.2. So by combining these we get all the changes for Alex done at once. Bump hackage state in a few places, and also make that workflow slightly easier for the future. Bump minimum Alex version Bump Cabal, array, bytestring, containers, text, and binary submodules
-rw-r--r--.gitlab-ci.yml13
-rwxr-xr-x.gitlab/ci.sh8
-rw-r--r--aclocal.m48
-rw-r--r--compiler/GHC/Builtin/bytearray-ops.txt.pp60
-rw-r--r--compiler/GHC/Builtin/primops.txt.pp93
-rw-r--r--compiler/GHC/CmmToAsm/Ppr.hs14
-rw-r--r--compiler/GHC/Data/FastString.hs4
-rw-r--r--compiler/GHC/StgToCmm/Prim.hs96
-rw-r--r--compiler/GHC/Tc/Deriv/Generate.hs43
-rw-r--r--hadrian/cabal.project3
-rw-r--r--hadrian/hadrian.cabal3
-rw-r--r--hadrian/stack.yaml1
m---------libraries/Cabal0
m---------libraries/array0
-rw-r--r--libraries/base/GHC/Float/ConversionUtils.hs2
-rw-r--r--libraries/base/GHC/IO/Encoding/CodePage.hs6
-rw-r--r--libraries/base/GHC/IO/Encoding/UTF16.hs4
-rw-r--r--libraries/base/GHC/IO/Encoding/UTF32.hs8
-rw-r--r--libraries/base/GHC/IO/Encoding/UTF8.hs18
-rw-r--r--libraries/base/GHC/Int.hs260
-rw-r--r--libraries/base/GHC/Storable.hs24
-rw-r--r--libraries/base/GHC/Word.hs256
m---------libraries/binary0
m---------libraries/bytestring0
m---------libraries/containers0
-rw-r--r--libraries/ghc-bignum/src/GHC/Num/Backend/GMP.hs10
-rw-r--r--libraries/ghc-bignum/src/GHC/Num/Primitives.hs16
-rw-r--r--libraries/ghc-boot/GHC/Utils/Encoding.hs45
-rw-r--r--libraries/ghc-heap/tests/tso_and_stack_closures.hs2
-rw-r--r--libraries/ghc-prim/changelog.md18
-rw-r--r--libraries/ghci/GHCi/BreakArray.hs26
m---------libraries/text0
-rw-r--r--testsuite/tests/array/should_run/arr020.hs4
-rw-r--r--testsuite/tests/cmm/opt/T18141.hs4
-rw-r--r--testsuite/tests/codeGen/should_compile/T18614.hs2
-rw-r--r--testsuite/tests/codeGen/should_compile/cg006.hs2
-rw-r--r--testsuite/tests/codeGen/should_run/T2080.hs2
-rw-r--r--testsuite/tests/codeGen/should_run/cgrun070.hs4
-rw-r--r--testsuite/tests/codeGen/should_run/cgrun072.hs4
-rw-r--r--testsuite/tests/codeGen/should_run/cgrun075.hs6
-rw-r--r--testsuite/tests/codeGen/should_run/cgrun076.hs6
-rw-r--r--testsuite/tests/codeGen/should_run/compareByteArrays.hs4
-rw-r--r--testsuite/tests/ffi/should_run/PrimFFIInt16.hs22
-rw-r--r--testsuite/tests/ffi/should_run/PrimFFIInt32.hs22
-rw-r--r--testsuite/tests/ffi/should_run/PrimFFIInt8.hs22
-rw-r--r--testsuite/tests/ffi/should_run/PrimFFIWord16.hs22
-rw-r--r--testsuite/tests/ffi/should_run/PrimFFIWord32.hs22
-rw-r--r--testsuite/tests/ffi/should_run/PrimFFIWord8.hs22
-rw-r--r--testsuite/tests/ffi/should_run/T16650a.hs5
-rw-r--r--testsuite/tests/ffi/should_run/T16650b.hs5
-rw-r--r--testsuite/tests/ffi/should_run/UnliftedNewtypesByteArrayOffset.hs5
-rw-r--r--testsuite/tests/lib/integer/integerImportExport.hs4
-rw-r--r--testsuite/tests/numeric/should_compile/T16402.stderr-ws-324
-rw-r--r--testsuite/tests/numeric/should_compile/T16402.stderr-ws-642
-rw-r--r--testsuite/tests/parser/should_run/BinaryLiterals2.hs2
-rw-r--r--testsuite/tests/primops/should_run/ArithInt16.hs20
-rw-r--r--testsuite/tests/primops/should_run/ArithInt32.hs20
-rw-r--r--testsuite/tests/primops/should_run/ArithInt8.hs20
-rw-r--r--testsuite/tests/primops/should_run/ArithWord16.hs20
-rw-r--r--testsuite/tests/primops/should_run/ArithWord32.hs20
-rw-r--r--testsuite/tests/primops/should_run/ArithWord8.hs20
-rw-r--r--testsuite/tests/primops/should_run/CStringLength.hs12
-rw-r--r--testsuite/tests/primops/should_run/CmpInt16.hs2
-rw-r--r--testsuite/tests/primops/should_run/CmpInt32.hs2
-rw-r--r--testsuite/tests/primops/should_run/CmpInt8.hs2
-rw-r--r--testsuite/tests/primops/should_run/CmpWord16.hs2
-rw-r--r--testsuite/tests/primops/should_run/CmpWord32.hs2
-rw-r--r--testsuite/tests/primops/should_run/CmpWord8.hs2
-rw-r--r--testsuite/tests/primops/should_run/ShowPrim.hs6
-rw-r--r--testsuite/tests/primops/should_run/ShowPrim.stdout6
-rw-r--r--testsuite/tests/primops/should_run/T4442.hs151
-rw-r--r--testsuite/tests/profiling/should_run/T3001-2.hs4
-rw-r--r--testsuite/tests/rts/T17088.hs4
-rw-r--r--testsuite/tests/simplCore/should_compile/T5359a.hs4
-rw-r--r--utils/genprimopcode/gen_bytearray_ops.py18
75 files changed, 821 insertions, 754 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 77ba17b8c7..dbd38087be 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -2,7 +2,7 @@ variables:
GIT_SSL_NO_VERIFY: "1"
# Commit of ghc/ci-images repository from which to pull Docker images
- DOCKER_REV: 0da9c4be73f2d73868f610d20352af856e8f2727
+ DOCKER_REV: 706cc974bfe7a54c5036185ddf4817d3a8fd5b0d
# Sequential version number capturing the versions of all tools fetched by
# .gitlab/ci.sh. Used for invalidation of GitLab CI cache.
@@ -16,6 +16,8 @@ variables:
GIT_SUBMODULE_STRATEGY: "recursive"
+ HACKAGE_INDEX_STATE: "2020-12-21T14:48:20Z"
+
# Reduce XZ compression level for regular jobs (it is bumped to 9 for releases
# and nightly jobs). In my experiments I've got the following bindist size in
# the given time for each compression level (with the quick flavour):
@@ -219,6 +221,7 @@ lint-release-changelogs:
BUILD_FLAVOUR: "validate"
script:
- .gitlab/ci.sh setup
+ - "cabal update --index=$HACKAGE_INDEX_STATE"
- .gitlab/ci.sh configure
- .gitlab/ci.sh build_hadrian
- .gitlab/ci.sh test_hadrian
@@ -319,8 +322,8 @@ hadrian-ghc-in-ghci:
script:
- git clean -xdf && git submodule foreach git clean -xdf
- .gitlab/ci.sh setup
+ - "cabal update --index=$HACKAGE_INDEX_STATE"
- .gitlab/ci.sh configure
- - cabal update
- cd hadrian; cabal new-build -j`../mk/detect-cpu-count.sh` --with-compiler=$GHC --project-file=ci.project; cd ..
# Load ghc-in-ghci then immediately exit and check the modules loaded
- echo ":q" | hadrian/ghci -j`mk/detect-cpu-count.sh`| tail -n2 | grep "Ok,"
@@ -349,7 +352,7 @@ hadrian-ghc-in-ghci:
- git submodule update --init --recursive
- git checkout .gitmodules
- .gitlab/ci.sh setup
- - cabal update
+ - "cabal update --index=$HACKAGE_INDEX_STATE"
- cd hadrian; cabal new-build -j`../mk/detect-cpu-count.sh` --with-compiler=$GHC --project-file=ci.project; cd ..
after_script:
- cp -Rf $HOME/.cabal cabal-cache
@@ -1193,6 +1196,8 @@ perf-nofib:
- if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/'
tags:
- x86_64-linux
+ before_script:
+ - "cabal update --index=$HACKAGE_INDEX_STATE"
script:
- root=$(pwd)/ghc
- |
@@ -1204,7 +1209,7 @@ perf-nofib:
popd
rm -Rf tmp
- export BOOT_HC=$GHC
- - cabal update; cabal install -w "$BOOT_HC" --lib regex-compat
+ - cabal install -w "$BOOT_HC" --lib regex-compat
- export PATH=$root/bin:$PATH
- make -C nofib boot mode=fast -j$CPUS
- "make -C nofib EXTRA_RUNTEST_OPTS='-cachegrind +RTS -V0 -RTS' NoFibRuns=1 mode=fast -j$CPUS 2>&1 | tee nofib.log"
diff --git a/.gitlab/ci.sh b/.gitlab/ci.sh
index c6dd28e00b..8cebcd1d71 100755
--- a/.gitlab/ci.sh
+++ b/.gitlab/ci.sh
@@ -8,9 +8,9 @@
set -e -o pipefail
# Configuration:
-hackage_index_state="2020-09-14T19:30:43Z"
+HACKAGE_INDEX_STATE="2020-12-21T14:48:20Z" # TODO dedup with yaml's def
MIN_HAPPY_VERSION="1.20"
-MIN_ALEX_VERSION="3.2"
+MIN_ALEX_VERSION="3.2.6"
TOP="$(pwd)"
if [ ! -d "$TOP/.gitlab" ]; then
@@ -305,7 +305,7 @@ function setup_toolchain() {
cabal_install="$CABAL v2-install \
--with-compiler=$GHC \
- --index-state=$hackage_index_state \
+ --index-state=$HACKAGE_INDEX_STATE \
--installdir=$toolchain/bin \
--overwrite-policy=always"
@@ -315,7 +315,7 @@ function setup_toolchain() {
*) ;;
esac
- cabal update
+ cabal update --index="$HACKAGE_INDEX_STATE"
info "Building happy..."
$cabal_install happy --constraint="happy>=$MIN_HAPPY_VERSION"
diff --git a/aclocal.m4 b/aclocal.m4
index 088893a0fe..15cebfb18f 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1102,10 +1102,10 @@ changequote([, ])dnl
])
if test ! -f compiler/GHC/Parser/Lexer.hs || test ! -f compiler/GHC/Cmm/Lexer.hs
then
- FP_COMPARE_VERSIONS([$fptools_cv_alex_version],[-lt],[3.1.7],
- [AC_MSG_ERROR([Alex version 3.1.7 or later is required to compile GHC.])])[]
- FP_COMPARE_VERSIONS([$fptools_cv_alex_version],[-ge],[3.2.6],
- [AC_MSG_ERROR([Alex version 3.2.5 or earlier is required to compile GHC. See GHC issue 19099 for more information.])])[]
+ FP_COMPARE_VERSIONS([$fptools_cv_alex_version],[-lt],[3.2.6],
+ [AC_MSG_ERROR([Alex >= 3.2.6 && < 4 is required to compile GHC.])])[]
+ FP_COMPARE_VERSIONS([$fptools_cv_alex_version],[-ge],[4.0.0],
+ [AC_MSG_ERROR([Alex >= 3.2.6 && < 4 is required to compile GHC.])])[]
fi
AlexVersion=$fptools_cv_alex_version;
AC_SUBST(AlexVersion)
diff --git a/compiler/GHC/Builtin/bytearray-ops.txt.pp b/compiler/GHC/Builtin/bytearray-ops.txt.pp
index 75f420479f..6ed9028c6b 100644
--- a/compiler/GHC/Builtin/bytearray-ops.txt.pp
+++ b/compiler/GHC/Builtin/bytearray-ops.txt.pp
@@ -55,17 +55,17 @@ primop IndexByteArrayOp_StablePtr "indexStablePtrArray#" GenPrimOp
with can_fail = True
primop IndexByteArrayOp_Int8 "indexInt8Array#" GenPrimOp
- ByteArray# -> Int# -> Int#
+ ByteArray# -> Int# -> Int8#
{Read a 8-bit signed integer; offset in bytes.}
with can_fail = True
primop IndexByteArrayOp_Int16 "indexInt16Array#" GenPrimOp
- ByteArray# -> Int# -> Int#
+ ByteArray# -> Int# -> Int16#
{Read a 16-bit signed integer; offset in 2-byte words.}
with can_fail = True
primop IndexByteArrayOp_Int32 "indexInt32Array#" GenPrimOp
- ByteArray# -> Int# -> INT32
+ ByteArray# -> Int# -> Int32#
{Read a 32-bit signed integer; offset in 4-byte words.}
with can_fail = True
@@ -75,17 +75,17 @@ primop IndexByteArrayOp_Int64 "indexInt64Array#" GenPrimOp
with can_fail = True
primop IndexByteArrayOp_Word8 "indexWord8Array#" GenPrimOp
- ByteArray# -> Int# -> Word#
+ ByteArray# -> Int# -> Word8#
{Read a 8-bit unsigned integer; offset in bytes.}
with can_fail = True
primop IndexByteArrayOp_Word16 "indexWord16Array#" GenPrimOp
- ByteArray# -> Int# -> Word#
+ ByteArray# -> Int# -> Word16#
{Read a 16-bit unsigned integer; offset in 2-byte words.}
with can_fail = True
primop IndexByteArrayOp_Word32 "indexWord32Array#" GenPrimOp
- ByteArray# -> Int# -> WORD32
+ ByteArray# -> Int# -> Word32#
{Read a 32-bit unsigned integer; offset in 4-byte words.}
with can_fail = True
@@ -140,12 +140,12 @@ primop IndexByteArrayOp_Word8AsStablePtr "indexWord8ArrayAsStablePtr#" GenPrimOp
with can_fail = True
primop IndexByteArrayOp_Word8AsInt16 "indexWord8ArrayAsInt16#" GenPrimOp
- ByteArray# -> Int# -> Int#
+ ByteArray# -> Int# -> Int16#
{Read a 16-bit signed integer; offset in bytes.}
with can_fail = True
primop IndexByteArrayOp_Word8AsInt32 "indexWord8ArrayAsInt32#" GenPrimOp
- ByteArray# -> Int# -> INT32
+ ByteArray# -> Int# -> Int32#
{Read a 32-bit signed integer; offset in bytes.}
with can_fail = True
@@ -155,12 +155,12 @@ primop IndexByteArrayOp_Word8AsInt64 "indexWord8ArrayAsInt64#" GenPrimOp
with can_fail = True
primop IndexByteArrayOp_Word8AsWord16 "indexWord8ArrayAsWord16#" GenPrimOp
- ByteArray# -> Int# -> Word#
+ ByteArray# -> Int# -> Word16#
{Read a 16-bit unsigned integer; offset in bytes.}
with can_fail = True
primop IndexByteArrayOp_Word8AsWord32 "indexWord8ArrayAsWord32#" GenPrimOp
- ByteArray# -> Int# -> WORD32
+ ByteArray# -> Int# -> Word32#
{Read a 32-bit unsigned integer; offset in bytes.}
with can_fail = True
@@ -223,19 +223,19 @@ primop ReadByteArrayOp_StablePtr "readStablePtrArray#" GenPrimOp
can_fail = True
primop ReadByteArrayOp_Int8 "readInt8Array#" GenPrimOp
- MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)
+ MutableByteArray# s -> Int# -> State# s -> (# State# s, Int8# #)
{Read a 8-bit signed integer; offset in bytes.}
with has_side_effects = True
can_fail = True
primop ReadByteArrayOp_Int16 "readInt16Array#" GenPrimOp
- MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)
+ MutableByteArray# s -> Int# -> State# s -> (# State# s, Int16# #)
{Read a 16-bit signed integer; offset in 2-byte words.}
with has_side_effects = True
can_fail = True
primop ReadByteArrayOp_Int32 "readInt32Array#" GenPrimOp
- MutableByteArray# s -> Int# -> State# s -> (# State# s, INT32 #)
+ MutableByteArray# s -> Int# -> State# s -> (# State# s, Int32# #)
{Read a 32-bit signed integer; offset in 4-byte words.}
with has_side_effects = True
can_fail = True
@@ -247,19 +247,19 @@ primop ReadByteArrayOp_Int64 "readInt64Array#" GenPrimOp
can_fail = True
primop ReadByteArrayOp_Word8 "readWord8Array#" GenPrimOp
- MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)
+ MutableByteArray# s -> Int# -> State# s -> (# State# s, Word8# #)
{Read a 8-bit unsigned integer; offset in bytes.}
with has_side_effects = True
can_fail = True
primop ReadByteArrayOp_Word16 "readWord16Array#" GenPrimOp
- MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)
+ MutableByteArray# s -> Int# -> State# s -> (# State# s, Word16# #)
{Read a 16-bit unsigned integer; offset in 2-byte words.}
with has_side_effects = True
can_fail = True
primop ReadByteArrayOp_Word32 "readWord32Array#" GenPrimOp
- MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD32 #)
+ MutableByteArray# s -> Int# -> State# s -> (# State# s, Word32# #)
{Read a 32-bit unsigned integer; offset in 4-byte words.}
with has_side_effects = True
can_fail = True
@@ -324,13 +324,13 @@ primop ReadByteArrayOp_Word8AsStablePtr "readWord8ArrayAsStablePtr#" GenPrimOp
can_fail = True
primop ReadByteArrayOp_Word8AsInt16 "readWord8ArrayAsInt16#" GenPrimOp
- MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)
+ MutableByteArray# s -> Int# -> State# s -> (# State# s, Int16# #)
{Read a 16-bit signed integer; offset in bytes.}
with has_side_effects = True
can_fail = True
primop ReadByteArrayOp_Word8AsInt32 "readWord8ArrayAsInt32#" GenPrimOp
- MutableByteArray# s -> Int# -> State# s -> (# State# s, INT32 #)
+ MutableByteArray# s -> Int# -> State# s -> (# State# s, Int32# #)
{Read a 32-bit signed integer; offset in bytes.}
with has_side_effects = True
can_fail = True
@@ -342,13 +342,13 @@ primop ReadByteArrayOp_Word8AsInt64 "readWord8ArrayAsInt64#" GenPrimOp
can_fail = True
primop ReadByteArrayOp_Word8AsWord16 "readWord8ArrayAsWord16#" GenPrimOp
- MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)
+ MutableByteArray# s -> Int# -> State# s -> (# State# s, Word16# #)
{Read a 16-bit unsigned integer; offset in bytes.}
with has_side_effects = True
can_fail = True
primop ReadByteArrayOp_Word8AsWord32 "readWord8ArrayAsWord32#" GenPrimOp
- MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD32 #)
+ MutableByteArray# s -> Int# -> State# s -> (# State# s, Word32# #)
{Read a 32-bit unsigned integer; offset in bytes.}
with has_side_effects = True
can_fail = True
@@ -413,19 +413,19 @@ primop WriteByteArrayOp_StablePtr "writeStablePtrArray#" GenPrimOp
can_fail = True
primop WriteByteArrayOp_Int8 "writeInt8Array#" GenPrimOp
- MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
+ MutableByteArray# s -> Int# -> Int8# -> State# s -> State# s
{Write a 8-bit signed integer; offset in bytes.}
with has_side_effects = True
can_fail = True
primop WriteByteArrayOp_Int16 "writeInt16Array#" GenPrimOp
- MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
+ MutableByteArray# s -> Int# -> Int16# -> State# s -> State# s
{Write a 16-bit signed integer; offset in 2-byte words.}
with has_side_effects = True
can_fail = True
primop WriteByteArrayOp_Int32 "writeInt32Array#" GenPrimOp
- MutableByteArray# s -> Int# -> INT32 -> State# s -> State# s
+ MutableByteArray# s -> Int# -> Int32# -> State# s -> State# s
{Write a 32-bit signed integer; offset in 4-byte words.}
with has_side_effects = True
can_fail = True
@@ -437,19 +437,19 @@ primop WriteByteArrayOp_Int64 "writeInt64Array#" GenPrimOp
can_fail = True
primop WriteByteArrayOp_Word8 "writeWord8Array#" GenPrimOp
- MutableByteArray# s -> Int# -> Word# -> State# s -> State# s
+ MutableByteArray# s -> Int# -> Word8# -> State# s -> State# s
{Write a 8-bit unsigned integer; offset in bytes.}
with has_side_effects = True
can_fail = True
primop WriteByteArrayOp_Word16 "writeWord16Array#" GenPrimOp
- MutableByteArray# s -> Int# -> Word# -> State# s -> State# s
+ MutableByteArray# s -> Int# -> Word16# -> State# s -> State# s
{Write a 16-bit unsigned integer; offset in 2-byte words.}
with has_side_effects = True
can_fail = True
primop WriteByteArrayOp_Word32 "writeWord32Array#" GenPrimOp
- MutableByteArray# s -> Int# -> WORD32 -> State# s -> State# s
+ MutableByteArray# s -> Int# -> Word32# -> State# s -> State# s
{Write a 32-bit unsigned integer; offset in 4-byte words.}
with has_side_effects = True
can_fail = True
@@ -514,13 +514,13 @@ primop WriteByteArrayOp_Word8AsStablePtr "writeWord8ArrayAsStablePtr#" GenPrimOp
can_fail = True
primop WriteByteArrayOp_Word8AsInt16 "writeWord8ArrayAsInt16#" GenPrimOp
- MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
+ MutableByteArray# s -> Int# -> Int16# -> State# s -> State# s
{Write a 16-bit signed integer; offset in bytes.}
with has_side_effects = True
can_fail = True
primop WriteByteArrayOp_Word8AsInt32 "writeWord8ArrayAsInt32#" GenPrimOp
- MutableByteArray# s -> Int# -> INT32 -> State# s -> State# s
+ MutableByteArray# s -> Int# -> Int32# -> State# s -> State# s
{Write a 32-bit signed integer; offset in bytes.}
with has_side_effects = True
can_fail = True
@@ -532,13 +532,13 @@ primop WriteByteArrayOp_Word8AsInt64 "writeWord8ArrayAsInt64#" GenPrimOp
can_fail = True
primop WriteByteArrayOp_Word8AsWord16 "writeWord8ArrayAsWord16#" GenPrimOp
- MutableByteArray# s -> Int# -> Word# -> State# s -> State# s
+ MutableByteArray# s -> Int# -> Word16# -> State# s -> State# s
{Write a 16-bit unsigned integer; offset in bytes.}
with has_side_effects = True
can_fail = True
primop WriteByteArrayOp_Word8AsWord32 "writeWord8ArrayAsWord32#" GenPrimOp
- MutableByteArray# s -> Int# -> WORD32 -> State# s -> State# s
+ MutableByteArray# s -> Int# -> Word32# -> State# s -> State# s
{Write a 32-bit unsigned integer; offset in bytes.}
with has_side_effects = True
can_fail = True
diff --git a/compiler/GHC/Builtin/primops.txt.pp b/compiler/GHC/Builtin/primops.txt.pp
index fe9ffa6f00..8389de098c 100644
--- a/compiler/GHC/Builtin/primops.txt.pp
+++ b/compiler/GHC/Builtin/primops.txt.pp
@@ -247,9 +247,6 @@ section "The word size story."
-- Define synonyms for indexing ops.
-#define INT32 Int#
-#define WORD32 Word#
-
#if WORD_SIZE_IN_BITS < 64
#define INT64 Int64#
#define WORD64 Word64#
@@ -289,8 +286,8 @@ section "Int8#"
primtype Int8#
-primop Int8ToIntOp "extendInt8#" GenPrimOp Int8# -> Int#
-primop IntToInt8Op "narrowInt8#" GenPrimOp Int# -> Int8#
+primop Int8ToIntOp "int8ToInt#" GenPrimOp Int8# -> Int#
+primop IntToInt8Op "intToInt8#" GenPrimOp Int# -> Int8#
primop Int8NegOp "negateInt8#" GenPrimOp Int8# -> Int8#
@@ -337,8 +334,8 @@ section "Word8#"
primtype Word8#
-primop Word8ToWordOp "extendWord8#" GenPrimOp Word8# -> Word#
-primop WordToWord8Op "narrowWord8#" GenPrimOp Word# -> Word8#
+primop Word8ToWordOp "word8ToWord#" GenPrimOp Word8# -> Word#
+primop WordToWord8Op "wordToWord8#" GenPrimOp Word# -> Word8#
primop Word8AddOp "plusWord8#" GenPrimOp Word8# -> Word8# -> Word8#
with
@@ -393,8 +390,8 @@ section "Int16#"
primtype Int16#
-primop Int16ToIntOp "extendInt16#" GenPrimOp Int16# -> Int#
-primop IntToInt16Op "narrowInt16#" GenPrimOp Int# -> Int16#
+primop Int16ToIntOp "int16ToInt#" GenPrimOp Int16# -> Int#
+primop IntToInt16Op "intToInt16#" GenPrimOp Int# -> Int16#
primop Int16NegOp "negateInt16#" GenPrimOp Int16# -> Int16#
@@ -441,8 +438,8 @@ section "Word16#"
primtype Word16#
-primop Word16ToWordOp "extendWord16#" GenPrimOp Word16# -> Word#
-primop WordToWord16Op "narrowWord16#" GenPrimOp Word# -> Word16#
+primop Word16ToWordOp "word16ToWord#" GenPrimOp Word16# -> Word#
+primop WordToWord16Op "wordToWord16#" GenPrimOp Word# -> Word16#
primop Word16AddOp "plusWord16#" GenPrimOp Word16# -> Word16# -> Word16#
with
@@ -497,8 +494,8 @@ section "Int32#"
primtype Int32#
-primop Int32ToIntOp "extendInt32#" GenPrimOp Int32# -> Int#
-primop IntToInt32Op "narrowInt32#" GenPrimOp Int# -> Int32#
+primop Int32ToIntOp "int32ToInt#" GenPrimOp Int32# -> Int#
+primop IntToInt32Op "intToInt32#" GenPrimOp Int# -> Int32#
primop Int32NegOp "negateInt32#" GenPrimOp Int32# -> Int32#
@@ -545,8 +542,8 @@ section "Word32#"
primtype Word32#
-primop Word32ToWordOp "extendWord32#" GenPrimOp Word32# -> Word#
-primop WordToWord32Op "narrowWord32#" GenPrimOp Word# -> Word32#
+primop Word32ToWordOp "word32ToWord#" GenPrimOp Word32# -> Word#
+primop WordToWord32Op "wordToWord32#" GenPrimOp Word# -> Word32#
primop Word32AddOp "plusWord32#" GenPrimOp Word32# -> Word32# -> Word32#
with
@@ -2046,15 +2043,15 @@ primop IndexOffAddrOp_StablePtr "indexStablePtrOffAddr#" GenPrimOp
with can_fail = True
primop IndexOffAddrOp_Int8 "indexInt8OffAddr#" GenPrimOp
- Addr# -> Int# -> Int#
+ Addr# -> Int# -> Int8#
with can_fail = True
primop IndexOffAddrOp_Int16 "indexInt16OffAddr#" GenPrimOp
- Addr# -> Int# -> Int#
+ Addr# -> Int# -> Int16#
with can_fail = True
primop IndexOffAddrOp_Int32 "indexInt32OffAddr#" GenPrimOp
- Addr# -> Int# -> INT32
+ Addr# -> Int# -> Int32#
with can_fail = True
primop IndexOffAddrOp_Int64 "indexInt64OffAddr#" GenPrimOp
@@ -2062,15 +2059,15 @@ primop IndexOffAddrOp_Int64 "indexInt64OffAddr#" GenPrimOp
with can_fail = True
primop IndexOffAddrOp_Word8 "indexWord8OffAddr#" GenPrimOp
- Addr# -> Int# -> Word#
+ Addr# -> Int# -> Word8#
with can_fail = True
primop IndexOffAddrOp_Word16 "indexWord16OffAddr#" GenPrimOp
- Addr# -> Int# -> Word#
+ Addr# -> Int# -> Word16#
with can_fail = True
primop IndexOffAddrOp_Word32 "indexWord32OffAddr#" GenPrimOp
- Addr# -> Int# -> WORD32
+ Addr# -> Int# -> Word32#
with can_fail = True
primop IndexOffAddrOp_Word64 "indexWord64OffAddr#" GenPrimOp
@@ -2120,17 +2117,17 @@ primop ReadOffAddrOp_StablePtr "readStablePtrOffAddr#" GenPrimOp
can_fail = True
primop ReadOffAddrOp_Int8 "readInt8OffAddr#" GenPrimOp
- Addr# -> Int# -> State# s -> (# State# s, Int# #)
+ Addr# -> Int# -> State# s -> (# State# s, Int8# #)
with has_side_effects = True
can_fail = True
primop ReadOffAddrOp_Int16 "readInt16OffAddr#" GenPrimOp
- Addr# -> Int# -> State# s -> (# State# s, Int# #)
+ Addr# -> Int# -> State# s -> (# State# s, Int16# #)
with has_side_effects = True
can_fail = True
primop ReadOffAddrOp_Int32 "readInt32OffAddr#" GenPrimOp
- Addr# -> Int# -> State# s -> (# State# s, INT32 #)
+ Addr# -> Int# -> State# s -> (# State# s, Int32# #)
with has_side_effects = True
can_fail = True
@@ -2140,17 +2137,17 @@ primop ReadOffAddrOp_Int64 "readInt64OffAddr#" GenPrimOp
can_fail = True
primop ReadOffAddrOp_Word8 "readWord8OffAddr#" GenPrimOp
- Addr# -> Int# -> State# s -> (# State# s, Word# #)
+ Addr# -> Int# -> State# s -> (# State# s, Word8# #)
with has_side_effects = True
can_fail = True
primop ReadOffAddrOp_Word16 "readWord16OffAddr#" GenPrimOp
- Addr# -> Int# -> State# s -> (# State# s, Word# #)
+ Addr# -> Int# -> State# s -> (# State# s, Word16# #)
with has_side_effects = True
can_fail = True
primop ReadOffAddrOp_Word32 "readWord32OffAddr#" GenPrimOp
- Addr# -> Int# -> State# s -> (# State# s, WORD32 #)
+ Addr# -> Int# -> State# s -> (# State# s, Word32# #)
with has_side_effects = True
can_fail = True
@@ -2200,17 +2197,17 @@ primop WriteOffAddrOp_StablePtr "writeStablePtrOffAddr#" GenPrimOp
can_fail = True
primop WriteOffAddrOp_Int8 "writeInt8OffAddr#" GenPrimOp
- Addr# -> Int# -> Int# -> State# s -> State# s
+ Addr# -> Int# -> Int8# -> State# s -> State# s
with has_side_effects = True
can_fail = True
primop WriteOffAddrOp_Int16 "writeInt16OffAddr#" GenPrimOp
- Addr# -> Int# -> Int# -> State# s -> State# s
+ Addr# -> Int# -> Int16# -> State# s -> State# s
with has_side_effects = True
can_fail = True
primop WriteOffAddrOp_Int32 "writeInt32OffAddr#" GenPrimOp
- Addr# -> Int# -> INT32 -> State# s -> State# s
+ Addr# -> Int# -> Int32# -> State# s -> State# s
with has_side_effects = True
can_fail = True
@@ -2220,17 +2217,17 @@ primop WriteOffAddrOp_Int64 "writeInt64OffAddr#" GenPrimOp
can_fail = True
primop WriteOffAddrOp_Word8 "writeWord8OffAddr#" GenPrimOp
- Addr# -> Int# -> Word# -> State# s -> State# s
+ Addr# -> Int# -> Word8# -> State# s -> State# s
with has_side_effects = True
can_fail = True
primop WriteOffAddrOp_Word16 "writeWord16OffAddr#" GenPrimOp
- Addr# -> Int# -> Word# -> State# s -> State# s
+ Addr# -> Int# -> Word16# -> State# s -> State# s
with has_side_effects = True
can_fail = True
primop WriteOffAddrOp_Word32 "writeWord32OffAddr#" GenPrimOp
- Addr# -> Int# -> WORD32 -> State# s -> State# s
+ Addr# -> Int# -> Word32# -> State# s -> State# s
with has_side_effects = True
can_fail = True
@@ -3419,20 +3416,20 @@ section "SIMD Vectors"
------------------------------------------------------------------------
#define ALL_VECTOR_TYPES \
- [<Int8,Int#,16>,<Int16,Int#,8>,<Int32,INT32,4>,<Int64,INT64,2> \
- ,<Int8,Int#,32>,<Int16,Int#,16>,<Int32,INT32,8>,<Int64,INT64,4> \
- ,<Int8,Int#,64>,<Int16,Int#,32>,<Int32,INT32,16>,<Int64,INT64,8> \
- ,<Word8,Word#,16>,<Word16,Word#,8>,<Word32,WORD32,4>,<Word64,WORD64,2> \
- ,<Word8,Word#,32>,<Word16,Word#,16>,<Word32,WORD32,8>,<Word64,WORD64,4> \
- ,<Word8,Word#,64>,<Word16,Word#,32>,<Word32,WORD32,16>,<Word64,WORD64,8> \
+ [<Int8,Int8#,16>,<Int16,Int16#,8>,<Int32,Int32#,4>,<Int64,INT64,2> \
+ ,<Int8,Int8#,32>,<Int16,Int16#,16>,<Int32,Int32#,8>,<Int64,INT64,4> \
+ ,<Int8,Int8#,64>,<Int16,Int16#,32>,<Int32,Int32#,16>,<Int64,INT64,8> \
+ ,<Word8,Word#,16>,<Word16,Word#,8>,<Word32,Word32#,4>,<Word64,WORD64,2> \
+ ,<Word8,Word#,32>,<Word16,Word#,16>,<Word32,Word32#,8>,<Word64,WORD64,4> \
+ ,<Word8,Word#,64>,<Word16,Word#,32>,<Word32,Word32#,16>,<Word64,WORD64,8> \
,<Float,Float#,4>,<Double,Double#,2> \
,<Float,Float#,8>,<Double,Double#,4> \
,<Float,Float#,16>,<Double,Double#,8>]
#define SIGNED_VECTOR_TYPES \
- [<Int8,Int#,16>,<Int16,Int#,8>,<Int32,INT32,4>,<Int64,INT64,2> \
- ,<Int8,Int#,32>,<Int16,Int#,16>,<Int32,INT32,8>,<Int64,INT64,4> \
- ,<Int8,Int#,64>,<Int16,Int#,32>,<Int32,INT32,16>,<Int64,INT64,8> \
+ [<Int8,Int8#,16>,<Int16,Int16#,8>,<Int32,Int32#,4>,<Int64,INT64,2> \
+ ,<Int8,Int8#,32>,<Int16,Int16#,16>,<Int32,Int32#,8>,<Int64,INT64,4> \
+ ,<Int8,Int8#,64>,<Int16,Int16#,32>,<Int32,Int32#,16>,<Int64,INT64,8> \
,<Float,Float#,4>,<Double,Double#,2> \
,<Float,Float#,8>,<Double,Double#,4> \
,<Float,Float#,16>,<Double,Double#,8>]
@@ -3443,12 +3440,12 @@ section "SIMD Vectors"
,<Float,Float#,16>,<Double,Double#,8>]
#define INT_VECTOR_TYPES \
- [<Int8,Int#,16>,<Int16,Int#,8>,<Int32,INT32,4>,<Int64,INT64,2> \
- ,<Int8,Int#,32>,<Int16,Int#,16>,<Int32,INT32,8>,<Int64,INT64,4> \
- ,<Int8,Int#,64>,<Int16,Int#,32>,<Int32,INT32,16>,<Int64,INT64,8> \
- ,<Word8,Word#,16>,<Word16,Word#,8>,<Word32,WORD32,4>,<Word64,WORD64,2> \
- ,<Word8,Word#,32>,<Word16,Word#,16>,<Word32,WORD32,8>,<Word64,WORD64,4> \
- ,<Word8,Word#,64>,<Word16,Word#,32>,<Word32,WORD32,16>,<Word64,WORD64,8>]
+ [<Int8,Int8#,16>,<Int16,Int16#,8>,<Int32,Int32#,4>,<Int64,INT64,2> \
+ ,<Int8,Int8#,32>,<Int16,Int16#,16>,<Int32,Int32#,8>,<Int64,INT64,4> \
+ ,<Int8,Int8#,64>,<Int16,Int16#,32>,<Int32,Int32#,16>,<Int64,INT64,8> \
+ ,<Word8,Word#,16>,<Word16,Word#,8>,<Word32,Word32#,4>,<Word64,WORD64,2> \
+ ,<Word8,Word#,32>,<Word16,Word#,16>,<Word32,Word32#,8>,<Word64,WORD64,4> \
+ ,<Word8,Word#,64>,<Word16,Word#,32>,<Word32,Word32#,16>,<Word64,WORD64,8>]
primtype VECTOR
with llvm_only = True
diff --git a/compiler/GHC/CmmToAsm/Ppr.hs b/compiler/GHC/CmmToAsm/Ppr.hs
index a3606219da..8fba238cd1 100644
--- a/compiler/GHC/CmmToAsm/Ppr.hs
+++ b/compiler/GHC/CmmToAsm/Ppr.hs
@@ -38,15 +38,13 @@ import Data.Word
import Data.Bits
import Data.ByteString (ByteString)
import qualified Data.ByteString as BS
-import GHC.Exts hiding (extendWord8#)
+import GHC.Exts
import GHC.Word
-#if MIN_VERSION_base(4,16,0)
-import GHC.Base (extendWord8#)
-#else
-extendWord8# :: Word# -> Word#
-extendWord8# w = w
-{-# INLINE extendWord8# #-}
+#if !MIN_VERSION_base(4,16,0)
+word8ToWord# :: Word# -> Word#
+word8ToWord# w = w
+{-# INLINE word8ToWord# #-}
#endif
-- -----------------------------------------------------------------------------
@@ -111,7 +109,7 @@ pprASCII str
-- we know that the Chars we create are in the ASCII range
-- so we bypass the check in "chr"
chr' :: Word8 -> Char
- chr' (W8# w#) = C# (chr# (word2Int# (extendWord8# w#)))
+ chr' (W8# w#) = C# (chr# (word2Int# (word8ToWord# w#)))
octal :: Word8 -> String
octal w = [ chr' (ord0 + (w `unsafeShiftR` 6) .&. 0x07)
diff --git a/compiler/GHC/Data/FastString.hs b/compiler/GHC/Data/FastString.hs
index d9363fe2e4..1388563ca7 100644
--- a/compiler/GHC/Data/FastString.hs
+++ b/compiler/GHC/Data/FastString.hs
@@ -566,7 +566,11 @@ hashStr sbs@(SBS.SBS ba#) = loop 0# 0#
-- DO NOT move this let binding! indexCharOffAddr# reads from the
-- pointer so we need to evaluate this based on the length check
-- above. Not doing this right caused #17909.
+#if __GLASGOW_HASKELL__ >= 901
+ !c = int8ToInt# (indexInt8Array# ba# n)
+#else
!c = indexInt8Array# ba# n
+#endif
!h2 = (h *# 16777619#) `xorI#` c
in
loop h2 (n +# 1#)
diff --git a/compiler/GHC/StgToCmm/Prim.hs b/compiler/GHC/StgToCmm/Prim.hs
index 2ea28a8eb2..b7fde9642c 100644
--- a/compiler/GHC/StgToCmm/Prim.hs
+++ b/compiler/GHC/StgToCmm/Prim.hs
@@ -457,19 +457,19 @@ emitPrimOp dflags primop = case primop of
IndexOffAddrOp_StablePtr -> \args -> opIntoRegs $ \res ->
doIndexOffAddrOp Nothing (bWord platform) res args
IndexOffAddrOp_Int8 -> \args -> opIntoRegs $ \res ->
- doIndexOffAddrOp (Just (mo_s_8ToWord platform)) b8 res args
+ doIndexOffAddrOp Nothing b8 res args
IndexOffAddrOp_Int16 -> \args -> opIntoRegs $ \res ->
- doIndexOffAddrOp (Just (mo_s_16ToWord platform)) b16 res args
+ doIndexOffAddrOp Nothing b16 res args
IndexOffAddrOp_Int32 -> \args -> opIntoRegs $ \res ->
- doIndexOffAddrOp (Just (mo_s_32ToWord platform)) b32 res args
+ doIndexOffAddrOp Nothing b32 res args
IndexOffAddrOp_Int64 -> \args -> opIntoRegs $ \res ->
doIndexOffAddrOp Nothing b64 res args
IndexOffAddrOp_Word8 -> \args -> opIntoRegs $ \res ->
- doIndexOffAddrOp (Just (mo_u_8ToWord platform)) b8 res args
+ doIndexOffAddrOp Nothing b8 res args
IndexOffAddrOp_Word16 -> \args -> opIntoRegs $ \res ->
- doIndexOffAddrOp (Just (mo_u_16ToWord platform)) b16 res args
+ doIndexOffAddrOp Nothing b16 res args
IndexOffAddrOp_Word32 -> \args -> opIntoRegs $ \res ->
- doIndexOffAddrOp (Just (mo_u_32ToWord platform)) b32 res args
+ doIndexOffAddrOp Nothing b32 res args
IndexOffAddrOp_Word64 -> \args -> opIntoRegs $ \res ->
doIndexOffAddrOp Nothing b64 res args
@@ -492,19 +492,19 @@ emitPrimOp dflags primop = case primop of
ReadOffAddrOp_StablePtr -> \args -> opIntoRegs $ \res ->
doIndexOffAddrOp Nothing (bWord platform) res args
ReadOffAddrOp_Int8 -> \args -> opIntoRegs $ \res ->
- doIndexOffAddrOp (Just (mo_s_8ToWord platform)) b8 res args
+ doIndexOffAddrOp Nothing b8 res args
ReadOffAddrOp_Int16 -> \args -> opIntoRegs $ \res ->
- doIndexOffAddrOp (Just (mo_s_16ToWord platform)) b16 res args
+ doIndexOffAddrOp Nothing b16 res args
ReadOffAddrOp_Int32 -> \args -> opIntoRegs $ \res ->
- doIndexOffAddrOp (Just (mo_s_32ToWord platform)) b32 res args
+ doIndexOffAddrOp Nothing b32 res args
ReadOffAddrOp_Int64 -> \args -> opIntoRegs $ \res ->
doIndexOffAddrOp Nothing b64 res args
ReadOffAddrOp_Word8 -> \args -> opIntoRegs $ \res ->
- doIndexOffAddrOp (Just (mo_u_8ToWord platform)) b8 res args
+ doIndexOffAddrOp Nothing b8 res args
ReadOffAddrOp_Word16 -> \args -> opIntoRegs $ \res ->
- doIndexOffAddrOp (Just (mo_u_16ToWord platform)) b16 res args
+ doIndexOffAddrOp Nothing b16 res args
ReadOffAddrOp_Word32 -> \args -> opIntoRegs $ \res ->
- doIndexOffAddrOp (Just (mo_u_32ToWord platform)) b32 res args
+ doIndexOffAddrOp Nothing b32 res args
ReadOffAddrOp_Word64 -> \args -> opIntoRegs $ \res ->
doIndexOffAddrOp Nothing b64 res args
@@ -527,19 +527,19 @@ emitPrimOp dflags primop = case primop of
IndexByteArrayOp_StablePtr -> \args -> opIntoRegs $ \res ->
doIndexByteArrayOp Nothing (bWord platform) res args
IndexByteArrayOp_Int8 -> \args -> opIntoRegs $ \res ->
- doIndexByteArrayOp (Just (mo_s_8ToWord platform)) b8 res args
+ doIndexByteArrayOp Nothing b8 res args
IndexByteArrayOp_Int16 -> \args -> opIntoRegs $ \res ->
- doIndexByteArrayOp (Just (mo_s_16ToWord platform)) b16 res args
+ doIndexByteArrayOp Nothing b16 res args
IndexByteArrayOp_Int32 -> \args -> opIntoRegs $ \res ->
- doIndexByteArrayOp (Just (mo_s_32ToWord platform)) b32 res args
+ doIndexByteArrayOp Nothing b32 res args
IndexByteArrayOp_Int64 -> \args -> opIntoRegs $ \res ->
doIndexByteArrayOp Nothing b64 res args
IndexByteArrayOp_Word8 -> \args -> opIntoRegs $ \res ->
- doIndexByteArrayOp (Just (mo_u_8ToWord platform)) b8 res args
+ doIndexByteArrayOp Nothing b8 res args
IndexByteArrayOp_Word16 -> \args -> opIntoRegs $ \res ->
- doIndexByteArrayOp (Just (mo_u_16ToWord platform)) b16 res args
+ doIndexByteArrayOp Nothing b16 res args
IndexByteArrayOp_Word32 -> \args -> opIntoRegs $ \res ->
- doIndexByteArrayOp (Just (mo_u_32ToWord platform)) b32 res args
+ doIndexByteArrayOp Nothing b32 res args
IndexByteArrayOp_Word64 -> \args -> opIntoRegs $ \res ->
doIndexByteArrayOp Nothing b64 res args
@@ -562,19 +562,19 @@ emitPrimOp dflags primop = case primop of
ReadByteArrayOp_StablePtr -> \args -> opIntoRegs $ \res ->
doIndexByteArrayOp Nothing (bWord platform) res args
ReadByteArrayOp_Int8 -> \args -> opIntoRegs $ \res ->
- doIndexByteArrayOp (Just (mo_s_8ToWord platform)) b8 res args
+ doIndexByteArrayOp Nothing b8 res args
ReadByteArrayOp_Int16 -> \args -> opIntoRegs $ \res ->
- doIndexByteArrayOp (Just (mo_s_16ToWord platform)) b16 res args
+ doIndexByteArrayOp Nothing b16 res args
ReadByteArrayOp_Int32 -> \args -> opIntoRegs $ \res ->
- doIndexByteArrayOp (Just (mo_s_32ToWord platform)) b32 res args
+ doIndexByteArrayOp Nothing b32 res args
ReadByteArrayOp_Int64 -> \args -> opIntoRegs $ \res ->
doIndexByteArrayOp Nothing b64 res args
ReadByteArrayOp_Word8 -> \args -> opIntoRegs $ \res ->
- doIndexByteArrayOp (Just (mo_u_8ToWord platform)) b8 res args
+ doIndexByteArrayOp Nothing b8 res args
ReadByteArrayOp_Word16 -> \args -> opIntoRegs $ \res ->
- doIndexByteArrayOp (Just (mo_u_16ToWord platform)) b16 res args
+ doIndexByteArrayOp Nothing b16 res args
ReadByteArrayOp_Word32 -> \args -> opIntoRegs $ \res ->
- doIndexByteArrayOp (Just (mo_u_32ToWord platform)) b32 res args
+ doIndexByteArrayOp Nothing b32 res args
ReadByteArrayOp_Word64 -> \args -> opIntoRegs $ \res ->
doIndexByteArrayOp Nothing b64 res args
@@ -597,15 +597,15 @@ emitPrimOp dflags primop = case primop of
IndexByteArrayOp_Word8AsStablePtr -> \args -> opIntoRegs $ \res ->
doIndexByteArrayOpAs Nothing (bWord platform) b8 res args
IndexByteArrayOp_Word8AsInt16 -> \args -> opIntoRegs $ \res ->
- doIndexByteArrayOpAs (Just (mo_s_16ToWord platform)) b16 b8 res args
+ doIndexByteArrayOpAs Nothing b16 b8 res args
IndexByteArrayOp_Word8AsInt32 -> \args -> opIntoRegs $ \res ->
- doIndexByteArrayOpAs (Just (mo_s_32ToWord platform)) b32 b8 res args
+ doIndexByteArrayOpAs Nothing b32 b8 res args
IndexByteArrayOp_Word8AsInt64 -> \args -> opIntoRegs $ \res ->
doIndexByteArrayOpAs Nothing b64 b8 res args
IndexByteArrayOp_Word8AsWord16 -> \args -> opIntoRegs $ \res ->
- doIndexByteArrayOpAs (Just (mo_u_16ToWord platform)) b16 b8 res args
+ doIndexByteArrayOpAs Nothing b16 b8 res args
IndexByteArrayOp_Word8AsWord32 -> \args -> opIntoRegs $ \res ->
- doIndexByteArrayOpAs (Just (mo_u_32ToWord platform)) b32 b8 res args
+ doIndexByteArrayOpAs Nothing b32 b8 res args
IndexByteArrayOp_Word8AsWord64 -> \args -> opIntoRegs $ \res ->
doIndexByteArrayOpAs Nothing b64 b8 res args
@@ -628,15 +628,15 @@ emitPrimOp dflags primop = case primop of
ReadByteArrayOp_Word8AsStablePtr -> \args -> opIntoRegs $ \res ->
doIndexByteArrayOpAs Nothing (bWord platform) b8 res args
ReadByteArrayOp_Word8AsInt16 -> \args -> opIntoRegs $ \res ->
- doIndexByteArrayOpAs (Just (mo_s_16ToWord platform)) b16 b8 res args
+ doIndexByteArrayOpAs Nothing b16 b8 res args
ReadByteArrayOp_Word8AsInt32 -> \args -> opIntoRegs $ \res ->
- doIndexByteArrayOpAs (Just (mo_s_32ToWord platform)) b32 b8 res args
+ doIndexByteArrayOpAs Nothing b32 b8 res args
ReadByteArrayOp_Word8AsInt64 -> \args -> opIntoRegs $ \res ->
doIndexByteArrayOpAs Nothing b64 b8 res args
ReadByteArrayOp_Word8AsWord16 -> \args -> opIntoRegs $ \res ->
- doIndexByteArrayOpAs (Just (mo_u_16ToWord platform)) b16 b8 res args
+ doIndexByteArrayOpAs Nothing b16 b8 res args
ReadByteArrayOp_Word8AsWord32 -> \args -> opIntoRegs $ \res ->
- doIndexByteArrayOpAs (Just (mo_u_32ToWord platform)) b32 b8 res args
+ doIndexByteArrayOpAs Nothing b32 b8 res args
ReadByteArrayOp_Word8AsWord64 -> \args -> opIntoRegs $ \res ->
doIndexByteArrayOpAs Nothing b64 b8 res args
@@ -659,19 +659,19 @@ emitPrimOp dflags primop = case primop of
WriteOffAddrOp_StablePtr -> \args -> opIntoRegs $ \res ->
doWriteOffAddrOp Nothing (bWord platform) res args
WriteOffAddrOp_Int8 -> \args -> opIntoRegs $ \res ->
- doWriteOffAddrOp (Just (mo_WordTo8 platform)) b8 res args
+ doWriteOffAddrOp Nothing b8 res args
WriteOffAddrOp_Int16 -> \args -> opIntoRegs $ \res ->
- doWriteOffAddrOp (Just (mo_WordTo16 platform)) b16 res args
+ doWriteOffAddrOp Nothing b16 res args
WriteOffAddrOp_Int32 -> \args -> opIntoRegs $ \res ->
- doWriteOffAddrOp (Just (mo_WordTo32 platform)) b32 res args
+ doWriteOffAddrOp Nothing b32 res args
WriteOffAddrOp_Int64 -> \args -> opIntoRegs $ \res ->
doWriteOffAddrOp Nothing b64 res args
WriteOffAddrOp_Word8 -> \args -> opIntoRegs $ \res ->
- doWriteOffAddrOp (Just (mo_WordTo8 platform)) b8 res args
+ doWriteOffAddrOp Nothing b8 res args
WriteOffAddrOp_Word16 -> \args -> opIntoRegs $ \res ->
- doWriteOffAddrOp (Just (mo_WordTo16 platform)) b16 res args
+ doWriteOffAddrOp Nothing b16 res args
WriteOffAddrOp_Word32 -> \args -> opIntoRegs $ \res ->
- doWriteOffAddrOp (Just (mo_WordTo32 platform)) b32 res args
+ doWriteOffAddrOp Nothing b32 res args
WriteOffAddrOp_Word64 -> \args -> opIntoRegs $ \res ->
doWriteOffAddrOp Nothing b64 res args
@@ -694,19 +694,19 @@ emitPrimOp dflags primop = case primop of
WriteByteArrayOp_StablePtr -> \args -> opIntoRegs $ \res ->
doWriteByteArrayOp Nothing (bWord platform) res args
WriteByteArrayOp_Int8 -> \args -> opIntoRegs $ \res ->
- doWriteByteArrayOp (Just (mo_WordTo8 platform)) b8 res args
+ doWriteByteArrayOp Nothing b8 res args
WriteByteArrayOp_Int16 -> \args -> opIntoRegs $ \res ->
- doWriteByteArrayOp (Just (mo_WordTo16 platform)) b16 res args
+ doWriteByteArrayOp Nothing b16 res args
WriteByteArrayOp_Int32 -> \args -> opIntoRegs $ \res ->
- doWriteByteArrayOp (Just (mo_WordTo32 platform)) b32 res args
+ doWriteByteArrayOp Nothing b32 res args
WriteByteArrayOp_Int64 -> \args -> opIntoRegs $ \res ->
doWriteByteArrayOp Nothing b64 res args
WriteByteArrayOp_Word8 -> \args -> opIntoRegs $ \res ->
- doWriteByteArrayOp (Just (mo_WordTo8 platform)) b8 res args
+ doWriteByteArrayOp Nothing b8 res args
WriteByteArrayOp_Word16 -> \args -> opIntoRegs $ \res ->
- doWriteByteArrayOp (Just (mo_WordTo16 platform)) b16 res args
+ doWriteByteArrayOp Nothing b16 res args
WriteByteArrayOp_Word32 -> \args -> opIntoRegs $ \res ->
- doWriteByteArrayOp (Just (mo_WordTo32 platform)) b32 res args
+ doWriteByteArrayOp Nothing b32 res args
WriteByteArrayOp_Word64 -> \args -> opIntoRegs $ \res ->
doWriteByteArrayOp Nothing b64 res args
@@ -729,15 +729,15 @@ emitPrimOp dflags primop = case primop of
WriteByteArrayOp_Word8AsStablePtr -> \args -> opIntoRegs $ \res ->
doWriteByteArrayOp Nothing b8 res args
WriteByteArrayOp_Word8AsInt16 -> \args -> opIntoRegs $ \res ->
- doWriteByteArrayOp (Just (mo_WordTo16 platform)) b8 res args
+ doWriteByteArrayOp Nothing b8 res args
WriteByteArrayOp_Word8AsInt32 -> \args -> opIntoRegs $ \res ->
- doWriteByteArrayOp (Just (mo_WordTo32 platform)) b8 res args
+ doWriteByteArrayOp Nothing b8 res args
WriteByteArrayOp_Word8AsInt64 -> \args -> opIntoRegs $ \res ->
doWriteByteArrayOp Nothing b8 res args
WriteByteArrayOp_Word8AsWord16 -> \args -> opIntoRegs $ \res ->
- doWriteByteArrayOp (Just (mo_WordTo16 platform)) b8 res args
+ doWriteByteArrayOp Nothing b8 res args
WriteByteArrayOp_Word8AsWord32 -> \args -> opIntoRegs $ \res ->
- doWriteByteArrayOp (Just (mo_WordTo32 platform)) b8 res args
+ doWriteByteArrayOp Nothing b8 res args
WriteByteArrayOp_Word8AsWord64 -> \args -> opIntoRegs $ \res ->
doWriteByteArrayOp Nothing b8 res args
diff --git a/compiler/GHC/Tc/Deriv/Generate.hs b/compiler/GHC/Tc/Deriv/Generate.hs
index 0f374700dd..7b97d7bf22 100644
--- a/compiler/GHC/Tc/Deriv/Generate.hs
+++ b/compiler/GHC/Tc/Deriv/Generate.hs
@@ -1496,9 +1496,9 @@ gfoldl_RDR, gunfold_RDR, toConstr_RDR, dataTypeOf_RDR, mkConstrTag_RDR,
eqAddr_RDR , ltAddr_RDR , geAddr_RDR , gtAddr_RDR , leAddr_RDR ,
eqFloat_RDR , ltFloat_RDR , geFloat_RDR , gtFloat_RDR , leFloat_RDR ,
eqDouble_RDR, ltDouble_RDR, geDouble_RDR, gtDouble_RDR, leDouble_RDR,
- extendWord8_RDR, extendInt8_RDR,
- extendWord16_RDR, extendInt16_RDR,
- extendWord32_RDR, extendInt32_RDR
+ word8ToWord_RDR , int8ToInt_RDR ,
+ word16ToWord_RDR, int16ToInt_RDR,
+ word32ToWord_RDR, int32ToInt_RDR
:: RdrName
gfoldl_RDR = varQual_RDR gENERICS (fsLit "gfoldl")
gunfold_RDR = varQual_RDR gENERICS (fsLit "gunfold")
@@ -1588,14 +1588,15 @@ leDouble_RDR = varQual_RDR gHC_PRIM (fsLit "<=##")
gtDouble_RDR = varQual_RDR gHC_PRIM (fsLit ">##" )
geDouble_RDR = varQual_RDR gHC_PRIM (fsLit ">=##")
-extendWord8_RDR = varQual_RDR gHC_PRIM (fsLit "extendWord8#")
-extendInt8_RDR = varQual_RDR gHC_PRIM (fsLit "extendInt8#")
+word8ToWord_RDR = varQual_RDR gHC_PRIM (fsLit "word8ToWord#")
+int8ToInt_RDR = varQual_RDR gHC_PRIM (fsLit "int8ToInt#")
-extendWord16_RDR = varQual_RDR gHC_PRIM (fsLit "extendWord16#")
-extendInt16_RDR = varQual_RDR gHC_PRIM (fsLit "extendInt16#")
+word16ToWord_RDR = varQual_RDR gHC_PRIM (fsLit "word16ToWord#")
+int16ToInt_RDR = varQual_RDR gHC_PRIM (fsLit "int16ToInt#")
+
+word32ToWord_RDR = varQual_RDR gHC_PRIM (fsLit "word32ToWord#")
+int32ToInt_RDR = varQual_RDR gHC_PRIM (fsLit "int32ToInt#")
-extendWord32_RDR = varQual_RDR gHC_PRIM (fsLit "extendWord32#")
-extendInt32_RDR = varQual_RDR gHC_PRIM (fsLit "extendInt32#")
{-
************************************************************************
@@ -2364,22 +2365,22 @@ boxConTbl =
, (doublePrimTy, nlHsApp (nlHsVar $ getRdrName doubleDataCon))
, (int8PrimTy,
nlHsApp (nlHsVar $ getRdrName intDataCon)
- . nlHsApp (nlHsVar extendInt8_RDR))
+ . nlHsApp (nlHsVar int8ToInt_RDR))
, (word8PrimTy,
nlHsApp (nlHsVar $ getRdrName wordDataCon)
- . nlHsApp (nlHsVar extendWord8_RDR))
+ . nlHsApp (nlHsVar word8ToWord_RDR))
, (int16PrimTy,
nlHsApp (nlHsVar $ getRdrName intDataCon)
- . nlHsApp (nlHsVar extendInt16_RDR))
+ . nlHsApp (nlHsVar int16ToInt_RDR))
, (word16PrimTy,
nlHsApp (nlHsVar $ getRdrName wordDataCon)
- . nlHsApp (nlHsVar extendWord16_RDR))
+ . nlHsApp (nlHsVar word16ToWord_RDR))
, (int32PrimTy,
nlHsApp (nlHsVar $ getRdrName intDataCon)
- . nlHsApp (nlHsVar extendInt32_RDR))
+ . nlHsApp (nlHsVar int32ToInt_RDR))
, (word32PrimTy,
nlHsApp (nlHsVar $ getRdrName wordDataCon)
- . nlHsApp (nlHsVar extendWord32_RDR))
+ . nlHsApp (nlHsVar word32ToWord_RDR))
]
@@ -2401,12 +2402,12 @@ postfixModTbl
primConvTbl :: [(Type, String)]
primConvTbl =
- [ (int8PrimTy, "narrowInt8#")
- , (word8PrimTy, "narrowWord8#")
- , (int16PrimTy, "narrowInt16#")
- , (word16PrimTy, "narrowWord16#")
- , (int32PrimTy, "narrowInt32#")
- , (word32PrimTy, "narrowWord32#")
+ [ (int8PrimTy, "intToInt8#")
+ , (word8PrimTy, "wordToWord8#")
+ , (int16PrimTy, "intToInt16#")
+ , (word16PrimTy, "wordToWord16#")
+ , (int32PrimTy, "intToInt32#")
+ , (word32PrimTy, "wordToWord32#")
]
litConTbl :: [(Type, LHsExpr GhcPs -> LHsExpr GhcPs)]
diff --git a/hadrian/cabal.project b/hadrian/cabal.project
index d5f656d172..834cd17362 100644
--- a/hadrian/cabal.project
+++ b/hadrian/cabal.project
@@ -1,10 +1,9 @@
packages: ./
-- This essentially freezes the build plan for hadrian
-index-state: 2020-09-14T19:30:43Z
+index-state: 2020-12-21T14:48:20Z
-- N.B. Compile with -O0 since this is not a performance-critical executable
-- and the Cabal takes nearly twice as long to build with -O1. See #16817.
package Cabal
optimization: False
-
diff --git a/hadrian/hadrian.cabal b/hadrian/hadrian.cabal
index 0b54bed039..c39d5a92cf 100644
--- a/hadrian/hadrian.cabal
+++ b/hadrian/hadrian.cabal
@@ -147,8 +147,7 @@ executable hadrian
, shake >= 0.18.3 && < 0.20
, transformers >= 0.4 && < 0.6
, unordered-containers >= 0.2.1 && < 0.3
- build-tools: alex >= 3.1 && < 3.2.6
- -- See GHC#19099 for why we constrain alex < 3.2.6.
+ build-tools: alex >= 3.2.6 && < 4
, happy >= 1.20.0 && < 1.21
ghc-options: -Wall
-Wincomplete-record-updates
diff --git a/hadrian/stack.yaml b/hadrian/stack.yaml
index 44acdf5246..9147e2dc57 100644
--- a/hadrian/stack.yaml
+++ b/hadrian/stack.yaml
@@ -14,4 +14,5 @@ nix:
- perl
extra-deps:
+- alex-3.2.6
- happy-1.20.0
diff --git a/libraries/Cabal b/libraries/Cabal
-Subproject d30b8f3ec0b0873b9d2eb245afdd53fabacdb88
+Subproject 23ca3cb318418aaf4aafd3db862278a12a794a2
diff --git a/libraries/array b/libraries/array
-Subproject c7a696e3e6d5a6b00d3e00ca694af916f15bcff
+Subproject 3e4334a6f39d92090bf3ded86b84d7cd1817ce2
diff --git a/libraries/base/GHC/Float/ConversionUtils.hs b/libraries/base/GHC/Float/ConversionUtils.hs
index 5d9de64179..dc35bd09a3 100644
--- a/libraries/base/GHC/Float/ConversionUtils.hs
+++ b/libraries/base/GHC/Float/ConversionUtils.hs
@@ -64,6 +64,6 @@ elimZerosInt# n e =
-- | Number of trailing zero bits in a byte
zeroCount :: Int# -> Int#
-zeroCount i = indexInt8OffAddr# arr (word2Int# (narrow8Word# (int2Word# i))) -- index must be in [0,255]
+zeroCount i = int8ToInt# (indexInt8OffAddr# arr (word2Int# (narrow8Word# (int2Word# i)))) -- index must be in [0,255]
where
arr = "\8\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\4\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\5\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\4\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\6\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\4\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\5\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\4\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\7\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\4\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\5\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\4\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\6\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\4\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\5\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0\4\0\1\0\2\0\1\0\3\0\1\0\2\0\1\0"#
diff --git a/libraries/base/GHC/IO/Encoding/CodePage.hs b/libraries/base/GHC/IO/Encoding/CodePage.hs
index 6c77e65c41..39430c5ee0 100644
--- a/libraries/base/GHC/IO/Encoding/CodePage.hs
+++ b/libraries/base/GHC/IO/Encoding/CodePage.hs
@@ -170,15 +170,15 @@ lookupCompact maxVal indexes values x
{-# INLINE indexInt #-}
indexInt :: ConvArray Int -> Int -> Int
-indexInt (ConvArray p) (I# i) = I# (indexInt16OffAddr# p i)
+indexInt (ConvArray p) (I# i) = I# (int16ToInt# (indexInt16OffAddr# p i))
{-# INLINE indexWord8 #-}
indexWord8 :: ConvArray Word8 -> Int -> Word8
-indexWord8 (ConvArray p) (I# i) = W8# (narrowWord8# (indexWord8OffAddr# p i))
+indexWord8 (ConvArray p) (I# i) = W8# (indexWord8OffAddr# p i)
{-# INLINE indexChar #-}
indexChar :: ConvArray Char -> Int -> Char
-indexChar (ConvArray p) (I# i) = C# (chr# (indexInt16OffAddr# p i))
+indexChar (ConvArray p) (I# i) = C# (chr# (int16ToInt# (indexInt16OffAddr# p i)))
#endif
diff --git a/libraries/base/GHC/IO/Encoding/UTF16.hs b/libraries/base/GHC/IO/Encoding/UTF16.hs
index c77c131eef..a0878d4fce 100644
--- a/libraries/base/GHC/IO/Encoding/UTF16.hs
+++ b/libraries/base/GHC/IO/Encoding/UTF16.hs
@@ -342,8 +342,8 @@ utf16le_encode
chr2 :: Word16 -> Word16 -> Char
chr2 (W16# a#) (W16# b#) = C# (chr# (upper# +# lower# +# 0x10000#))
where
- !x# = word2Int# (extendWord16# a#)
- !y# = word2Int# (extendWord16# b#)
+ !x# = word2Int# (word16ToWord# a#)
+ !y# = word2Int# (word16ToWord# b#)
!upper# = uncheckedIShiftL# (x# -# 0xD800#) 10#
!lower# = y# -# 0xDC00#
{-# INLINE chr2 #-}
diff --git a/libraries/base/GHC/IO/Encoding/UTF32.hs b/libraries/base/GHC/IO/Encoding/UTF32.hs
index c14b365a04..379f76066b 100644
--- a/libraries/base/GHC/IO/Encoding/UTF32.hs
+++ b/libraries/base/GHC/IO/Encoding/UTF32.hs
@@ -309,10 +309,10 @@ chr4 :: Word8 -> Word8 -> Word8 -> Word8 -> Char
chr4 (W8# x1#) (W8# x2#) (W8# x3#) (W8# x4#) =
C# (chr# (z1# +# z2# +# z3# +# z4#))
where
- !y1# = word2Int# (extendWord8# x1#)
- !y2# = word2Int# (extendWord8# x2#)
- !y3# = word2Int# (extendWord8# x3#)
- !y4# = word2Int# (extendWord8# x4#)
+ !y1# = word2Int# (word8ToWord# x1#)
+ !y2# = word2Int# (word8ToWord# x2#)
+ !y3# = word2Int# (word8ToWord# x3#)
+ !y4# = word2Int# (word8ToWord# x4#)
!z1# = uncheckedIShiftL# y1# 24#
!z2# = uncheckedIShiftL# y2# 16#
!z3# = uncheckedIShiftL# y3# 8#
diff --git a/libraries/base/GHC/IO/Encoding/UTF8.hs b/libraries/base/GHC/IO/Encoding/UTF8.hs
index d887a92960..4513ab68b6 100644
--- a/libraries/base/GHC/IO/Encoding/UTF8.hs
+++ b/libraries/base/GHC/IO/Encoding/UTF8.hs
@@ -283,8 +283,8 @@ ord4 c = assert (n >= 0x10000) (x1,x2,x3,x4)
chr2 :: Word8 -> Word8 -> Char
chr2 (W8# x1#) (W8# x2#) = C# (chr# (z1# +# z2#))
where
- !y1# = word2Int# (extendWord8# x1#)
- !y2# = word2Int# (extendWord8# x2#)
+ !y1# = word2Int# (word8ToWord# x1#)
+ !y2# = word2Int# (word8ToWord# x2#)
!z1# = uncheckedIShiftL# (y1# -# 0xC0#) 6#
!z2# = y2# -# 0x80#
{-# INLINE chr2 #-}
@@ -292,9 +292,9 @@ chr2 (W8# x1#) (W8# x2#) = C# (chr# (z1# +# z2#))
chr3 :: Word8 -> Word8 -> Word8 -> Char
chr3 (W8# x1#) (W8# x2#) (W8# x3#) = C# (chr# (z1# +# z2# +# z3#))
where
- !y1# = word2Int# (extendWord8# x1#)
- !y2# = word2Int# (extendWord8# x2#)
- !y3# = word2Int# (extendWord8# x3#)
+ !y1# = word2Int# (word8ToWord# x1#)
+ !y2# = word2Int# (word8ToWord# x2#)
+ !y3# = word2Int# (word8ToWord# x3#)
!z1# = uncheckedIShiftL# (y1# -# 0xE0#) 12#
!z2# = uncheckedIShiftL# (y2# -# 0x80#) 6#
!z3# = y3# -# 0x80#
@@ -304,10 +304,10 @@ chr4 :: Word8 -> Word8 -> Word8 -> Word8 -> Char
chr4 (W8# x1#) (W8# x2#) (W8# x3#) (W8# x4#) =
C# (chr# (z1# +# z2# +# z3# +# z4#))
where
- !y1# = word2Int# (extendWord8# x1#)
- !y2# = word2Int# (extendWord8# x2#)
- !y3# = word2Int# (extendWord8# x3#)
- !y4# = word2Int# (extendWord8# x4#)
+ !y1# = word2Int# (word8ToWord# x1#)
+ !y2# = word2Int# (word8ToWord# x2#)
+ !y3# = word2Int# (word8ToWord# x3#)
+ !y4# = word2Int# (word8ToWord# x4#)
!z1# = uncheckedIShiftL# (y1# -# 0xF0#) 18#
!z2# = uncheckedIShiftL# (y2# -# 0x80#) 12#
!z3# = uncheckedIShiftL# (y3# -# 0x80#) 6#
diff --git a/libraries/base/GHC/Int.hs b/libraries/base/GHC/Int.hs
index 2af0856bb7..2fe7d6ce8c 100644
--- a/libraries/base/GHC/Int.hs
+++ b/libraries/base/GHC/Int.hs
@@ -69,8 +69,8 @@ instance Eq Int8 where
(/=) = neInt8
eqInt8, neInt8 :: Int8 -> Int8 -> Bool
-eqInt8 (I8# x) (I8# y) = isTrue# ((extendInt8# x) ==# (extendInt8# y))
-neInt8 (I8# x) (I8# y) = isTrue# ((extendInt8# x) /=# (extendInt8# y))
+eqInt8 (I8# x) (I8# y) = isTrue# ((int8ToInt# x) ==# (int8ToInt# y))
+neInt8 (I8# x) (I8# y) = isTrue# ((int8ToInt# x) /=# (int8ToInt# y))
{-# INLINE [1] eqInt8 #-}
{-# INLINE [1] neInt8 #-}
@@ -86,10 +86,10 @@ instance Ord Int8 where
{-# INLINE [1] ltInt8 #-}
{-# INLINE [1] leInt8 #-}
gtInt8, geInt8, ltInt8, leInt8 :: Int8 -> Int8 -> Bool
-(I8# x) `gtInt8` (I8# y) = isTrue# ((extendInt8# x) ># (extendInt8# y))
-(I8# x) `geInt8` (I8# y) = isTrue# ((extendInt8# x) >=# (extendInt8# y))
-(I8# x) `ltInt8` (I8# y) = isTrue# ((extendInt8# x) <# (extendInt8# y))
-(I8# x) `leInt8` (I8# y) = isTrue# ((extendInt8# x) <=# (extendInt8# y))
+(I8# x) `gtInt8` (I8# y) = isTrue# ((int8ToInt# x) ># (int8ToInt# y))
+(I8# x) `geInt8` (I8# y) = isTrue# ((int8ToInt# x) >=# (int8ToInt# y))
+(I8# x) `ltInt8` (I8# y) = isTrue# ((int8ToInt# x) <# (int8ToInt# y))
+(I8# x) `leInt8` (I8# y) = isTrue# ((int8ToInt# x) <=# (int8ToInt# y))
-- | @since 2.01
instance Show Int8 where
@@ -97,16 +97,16 @@ instance Show Int8 where
-- | @since 2.01
instance Num Int8 where
- (I8# x#) + (I8# y#) = I8# (narrowInt8# ((extendInt8# x#) +# (extendInt8# y#)))
- (I8# x#) - (I8# y#) = I8# (narrowInt8# ((extendInt8# x#) -# (extendInt8# y#)))
- (I8# x#) * (I8# y#) = I8# (narrowInt8# ((extendInt8# x#) *# (extendInt8# y#)))
- negate (I8# x#) = I8# (narrowInt8# (negateInt# (extendInt8# x#)))
+ (I8# x#) + (I8# y#) = I8# (intToInt8# ((int8ToInt# x#) +# (int8ToInt# y#)))
+ (I8# x#) - (I8# y#) = I8# (intToInt8# ((int8ToInt# x#) -# (int8ToInt# y#)))
+ (I8# x#) * (I8# y#) = I8# (intToInt8# ((int8ToInt# x#) *# (int8ToInt# y#)))
+ negate (I8# x#) = I8# (intToInt8# (negateInt# (int8ToInt# x#)))
abs x | x >= 0 = x
| otherwise = negate x
signum x | x > 0 = 1
signum 0 = 0
signum _ = -1
- fromInteger i = I8# (narrowInt8# (integerToInt# i))
+ fromInteger i = I8# (intToInt8# (integerToInt# i))
-- | @since 2.01
instance Real Int8 where
@@ -122,9 +122,9 @@ instance Enum Int8 where
| otherwise = predError "Int8"
toEnum i@(I# i#)
| i >= fromIntegral (minBound::Int8) && i <= fromIntegral (maxBound::Int8)
- = I8# (narrowInt8# i#)
+ = I8# (intToInt8# i#)
| otherwise = toEnumError "Int8" i (minBound::Int8, maxBound::Int8)
- fromEnum (I8# x#) = I# (extendInt8# x#)
+ fromEnum (I8# x#) = I# (int8ToInt# x#)
enumFrom = boundedEnumFrom
enumFromThen = boundedEnumFromThen
@@ -133,34 +133,34 @@ instance Integral Int8 where
quot x@(I8# x#) y@(I8# y#)
| y == 0 = divZeroError
| y == (-1) && x == minBound = overflowError -- Note [Order of tests]
- | otherwise = I8# (narrowInt8# ((extendInt8# x#) `quotInt#` (extendInt8# y#)))
+ | otherwise = I8# (intToInt8# ((int8ToInt# x#) `quotInt#` (int8ToInt# y#)))
rem (I8# x#) y@(I8# y#)
| y == 0 = divZeroError
- | otherwise = I8# (narrowInt8# ((extendInt8# x#) `remInt#` (extendInt8# y#)))
+ | otherwise = I8# (intToInt8# ((int8ToInt# x#) `remInt#` (int8ToInt# y#)))
div x@(I8# x#) y@(I8# y#)
| y == 0 = divZeroError
| y == (-1) && x == minBound = overflowError -- Note [Order of tests]
- | otherwise = I8# (narrowInt8# ((extendInt8# x#) `divInt#` (extendInt8# y#)))
+ | otherwise = I8# (intToInt8# ((int8ToInt# x#) `divInt#` (int8ToInt# y#)))
mod (I8# x#) y@(I8# y#)
| y == 0 = divZeroError
- | otherwise = I8# (narrowInt8# ((extendInt8# x#) `modInt#` (extendInt8# y#)))
+ | otherwise = I8# (intToInt8# ((int8ToInt# x#) `modInt#` (int8ToInt# y#)))
quotRem x@(I8# x#) y@(I8# y#)
| y == 0 = divZeroError
-- Note [Order of tests]
| y == (-1) && x == minBound = (overflowError, 0)
- | otherwise = case (extendInt8# x#) `quotRemInt#` (extendInt8# y#) of
+ | otherwise = case (int8ToInt# x#) `quotRemInt#` (int8ToInt# y#) of
(# q, r #) ->
- (I8# (narrowInt8# q),
- I8# (narrowInt8# r))
+ (I8# (intToInt8# q),
+ I8# (intToInt8# r))
divMod x@(I8# x#) y@(I8# y#)
| y == 0 = divZeroError
-- Note [Order of tests]
| y == (-1) && x == minBound = (overflowError, 0)
- | otherwise = case (extendInt8# x#) `divModInt#` (extendInt8# y#) of
+ | otherwise = case (int8ToInt# x#) `divModInt#` (int8ToInt# y#) of
(# d, m #) ->
- (I8# (narrowInt8# d),
- I8# (narrowInt8# m))
- toInteger (I8# x#) = IS (extendInt8# x#)
+ (I8# (intToInt8# d),
+ I8# (intToInt8# m))
+ toInteger (I8# x#) = IS (int8ToInt# x#)
-- | @since 2.01
instance Bounded Int8 where
@@ -184,34 +184,34 @@ instance Bits Int8 where
{-# INLINE testBit #-}
{-# INLINE popCount #-}
- (I8# x#) .&. (I8# y#) = I8# (narrowInt8# ((extendInt8# x#) `andI#` (extendInt8# y#)))
- (I8# x#) .|. (I8# y#) = I8# (narrowInt8# ((extendInt8# x#) `orI#` (extendInt8# y#)))
- (I8# x#) `xor` (I8# y#) = I8# (narrowInt8# ((extendInt8# x#) `xorI#` (extendInt8# y#)))
- complement (I8# x#) = I8# (narrowInt8# (notI# (extendInt8# x#)))
+ (I8# x#) .&. (I8# y#) = I8# (intToInt8# ((int8ToInt# x#) `andI#` (int8ToInt# y#)))
+ (I8# x#) .|. (I8# y#) = I8# (intToInt8# ((int8ToInt# x#) `orI#` (int8ToInt# y#)))
+ (I8# x#) `xor` (I8# y#) = I8# (intToInt8# ((int8ToInt# x#) `xorI#` (int8ToInt# y#)))
+ complement (I8# x#) = I8# (intToInt8# (notI# (int8ToInt# x#)))
(I8# x#) `shift` (I# i#)
- | isTrue# (i# >=# 0#) = I8# (narrowInt8# ((extendInt8# x#) `iShiftL#` i#))
- | otherwise = I8# (narrowInt8# ((extendInt8# x#) `iShiftRA#` negateInt# i#))
+ | isTrue# (i# >=# 0#) = I8# (intToInt8# ((int8ToInt# x#) `iShiftL#` i#))
+ | otherwise = I8# (intToInt8# ((int8ToInt# x#) `iShiftRA#` negateInt# i#))
(I8# x#) `shiftL` (I# i#)
- | isTrue# (i# >=# 0#) = I8# (narrowInt8# ((extendInt8# x#) `iShiftL#` i#))
+ | isTrue# (i# >=# 0#) = I8# (intToInt8# ((int8ToInt# x#) `iShiftL#` i#))
| otherwise = overflowError
- (I8# x#) `unsafeShiftL` (I# i#) = I8# (narrowInt8# ((extendInt8# x#) `uncheckedIShiftL#` i#))
+ (I8# x#) `unsafeShiftL` (I# i#) = I8# (intToInt8# ((int8ToInt# x#) `uncheckedIShiftL#` i#))
(I8# x#) `shiftR` (I# i#)
- | isTrue# (i# >=# 0#) = I8# (narrowInt8# ((extendInt8# x#) `iShiftRA#` i#))
+ | isTrue# (i# >=# 0#) = I8# (intToInt8# ((int8ToInt# x#) `iShiftRA#` i#))
| otherwise = overflowError
- (I8# x#) `unsafeShiftR` (I# i#) = I8# (narrowInt8# ((extendInt8# x#) `uncheckedIShiftRA#` i#))
+ (I8# x#) `unsafeShiftR` (I# i#) = I8# (intToInt8# ((int8ToInt# x#) `uncheckedIShiftRA#` i#))
(I8# x#) `rotate` (I# i#)
| isTrue# (i'# ==# 0#)
= I8# x#
| otherwise
- = I8# (narrowInt8# (word2Int# ((x'# `uncheckedShiftL#` i'#) `or#`
+ = I8# (intToInt8# (word2Int# ((x'# `uncheckedShiftL#` i'#) `or#`
(x'# `uncheckedShiftRL#` (8# -# i'#)))))
where
- !x'# = narrow8Word# (int2Word# (extendInt8# x#))
+ !x'# = narrow8Word# (int2Word# (int8ToInt# x#))
!i'# = word2Int# (int2Word# i# `and#` 7##)
bitSizeMaybe i = Just (finiteBitSize i)
bitSize i = finiteBitSize i
isSigned _ = True
- popCount (I8# x#) = I# (word2Int# (popCnt8# (int2Word# (extendInt8# x#))))
+ popCount (I8# x#) = I# (word2Int# (popCnt8# (int2Word# (int8ToInt# x#))))
bit = bitDefault
testBit = testBitDefault
@@ -220,13 +220,13 @@ instance FiniteBits Int8 where
{-# INLINE countLeadingZeros #-}
{-# INLINE countTrailingZeros #-}
finiteBitSize _ = 8
- countLeadingZeros (I8# x#) = I# (word2Int# (clz8# (int2Word# (extendInt8# x#))))
- countTrailingZeros (I8# x#) = I# (word2Int# (ctz8# (int2Word# (extendInt8# x#))))
+ countLeadingZeros (I8# x#) = I# (word2Int# (clz8# (int2Word# (int8ToInt# x#))))
+ countTrailingZeros (I8# x#) = I# (word2Int# (ctz8# (int2Word# (int8ToInt# x#))))
{-# RULES
"fromIntegral/Int8->Int8" fromIntegral = id :: Int8 -> Int8
-"fromIntegral/a->Int8" fromIntegral = \x -> case fromIntegral x of I# x# -> I8# (narrowInt8# x#)
-"fromIntegral/Int8->a" fromIntegral = \(I8# x#) -> fromIntegral (I# (extendInt8# x#))
+"fromIntegral/a->Int8" fromIntegral = \x -> case fromIntegral x of I# x# -> I8# (intToInt8# x#)
+"fromIntegral/Int8->a" fromIntegral = \(I8# x#) -> fromIntegral (I# (int8ToInt# x#))
#-}
{-# RULES
@@ -276,8 +276,8 @@ instance Eq Int16 where
(/=) = neInt16
eqInt16, neInt16 :: Int16 -> Int16 -> Bool
-eqInt16 (I16# x) (I16# y) = isTrue# ((extendInt16# x) ==# (extendInt16# y))
-neInt16 (I16# x) (I16# y) = isTrue# ((extendInt16# x) /=# (extendInt16# y))
+eqInt16 (I16# x) (I16# y) = isTrue# ((int16ToInt# x) ==# (int16ToInt# y))
+neInt16 (I16# x) (I16# y) = isTrue# ((int16ToInt# x) /=# (int16ToInt# y))
{-# INLINE [1] eqInt16 #-}
{-# INLINE [1] neInt16 #-}
@@ -293,10 +293,10 @@ instance Ord Int16 where
{-# INLINE [1] ltInt16 #-}
{-# INLINE [1] leInt16 #-}
gtInt16, geInt16, ltInt16, leInt16 :: Int16 -> Int16 -> Bool
-(I16# x) `gtInt16` (I16# y) = isTrue# ((extendInt16# x) ># (extendInt16# y))
-(I16# x) `geInt16` (I16# y) = isTrue# ((extendInt16# x) >=# (extendInt16# y))
-(I16# x) `ltInt16` (I16# y) = isTrue# ((extendInt16# x) <# (extendInt16# y))
-(I16# x) `leInt16` (I16# y) = isTrue# ((extendInt16# x) <=# (extendInt16# y))
+(I16# x) `gtInt16` (I16# y) = isTrue# ((int16ToInt# x) ># (int16ToInt# y))
+(I16# x) `geInt16` (I16# y) = isTrue# ((int16ToInt# x) >=# (int16ToInt# y))
+(I16# x) `ltInt16` (I16# y) = isTrue# ((int16ToInt# x) <# (int16ToInt# y))
+(I16# x) `leInt16` (I16# y) = isTrue# ((int16ToInt# x) <=# (int16ToInt# y))
-- | @since 2.01
instance Show Int16 where
@@ -304,16 +304,16 @@ instance Show Int16 where
-- | @since 2.01
instance Num Int16 where
- (I16# x#) + (I16# y#) = I16# (narrowInt16# ((extendInt16# x#) +# (extendInt16# y#)))
- (I16# x#) - (I16# y#) = I16# (narrowInt16# ((extendInt16# x#) -# (extendInt16# y#)))
- (I16# x#) * (I16# y#) = I16# (narrowInt16# ((extendInt16# x#) *# (extendInt16# y#)))
- negate (I16# x#) = I16# (narrowInt16# (negateInt# (extendInt16# x#)))
+ (I16# x#) + (I16# y#) = I16# (intToInt16# ((int16ToInt# x#) +# (int16ToInt# y#)))
+ (I16# x#) - (I16# y#) = I16# (intToInt16# ((int16ToInt# x#) -# (int16ToInt# y#)))
+ (I16# x#) * (I16# y#) = I16# (intToInt16# ((int16ToInt# x#) *# (int16ToInt# y#)))
+ negate (I16# x#) = I16# (intToInt16# (negateInt# (int16ToInt# x#)))
abs x | x >= 0 = x
| otherwise = negate x
signum x | x > 0 = 1
signum 0 = 0
signum _ = -1
- fromInteger i = I16# (narrowInt16# (integerToInt# i))
+ fromInteger i = I16# (intToInt16# (integerToInt# i))
-- | @since 2.01
instance Real Int16 where
@@ -329,9 +329,9 @@ instance Enum Int16 where
| otherwise = predError "Int16"
toEnum i@(I# i#)
| i >= fromIntegral (minBound::Int16) && i <= fromIntegral (maxBound::Int16)
- = I16# (narrowInt16# i#)
+ = I16# (intToInt16# i#)
| otherwise = toEnumError "Int16" i (minBound::Int16, maxBound::Int16)
- fromEnum (I16# x#) = I# (extendInt16# x#)
+ fromEnum (I16# x#) = I# (int16ToInt# x#)
enumFrom = boundedEnumFrom
enumFromThen = boundedEnumFromThen
@@ -340,34 +340,34 @@ instance Integral Int16 where
quot x@(I16# x#) y@(I16# y#)
| y == 0 = divZeroError
| y == (-1) && x == minBound = overflowError -- Note [Order of tests]
- | otherwise = I16# (narrowInt16# ((extendInt16# x#) `quotInt#` (extendInt16# y#)))
+ | otherwise = I16# (intToInt16# ((int16ToInt# x#) `quotInt#` (int16ToInt# y#)))
rem (I16# x#) y@(I16# y#)
| y == 0 = divZeroError
- | otherwise = I16# (narrowInt16# ((extendInt16# x#) `remInt#` (extendInt16# y#)))
+ | otherwise = I16# (intToInt16# ((int16ToInt# x#) `remInt#` (int16ToInt# y#)))
div x@(I16# x#) y@(I16# y#)
| y == 0 = divZeroError
| y == (-1) && x == minBound = overflowError -- Note [Order of tests]
- | otherwise = I16# (narrowInt16# ((extendInt16# x#) `divInt#` (extendInt16# y#)))
+ | otherwise = I16# (intToInt16# ((int16ToInt# x#) `divInt#` (int16ToInt# y#)))
mod (I16# x#) y@(I16# y#)
| y == 0 = divZeroError
- | otherwise = I16# (narrowInt16# ((extendInt16# x#) `modInt#` (extendInt16# y#)))
+ | otherwise = I16# (intToInt16# ((int16ToInt# x#) `modInt#` (int16ToInt# y#)))
quotRem x@(I16# x#) y@(I16# y#)
| y == 0 = divZeroError
-- Note [Order of tests]
| y == (-1) && x == minBound = (overflowError, 0)
- | otherwise = case (extendInt16# x#) `quotRemInt#` (extendInt16# y#) of
+ | otherwise = case (int16ToInt# x#) `quotRemInt#` (int16ToInt# y#) of
(# q, r #) ->
- (I16# (narrowInt16# q),
- I16# (narrowInt16# r))
+ (I16# (intToInt16# q),
+ I16# (intToInt16# r))
divMod x@(I16# x#) y@(I16# y#)
| y == 0 = divZeroError
-- Note [Order of tests]
| y == (-1) && x == minBound = (overflowError, 0)
- | otherwise = case (extendInt16# x#) `divModInt#` (extendInt16# y#) of
+ | otherwise = case (int16ToInt# x#) `divModInt#` (int16ToInt# y#) of
(# d, m #) ->
- (I16# (narrowInt16# d),
- I16# (narrowInt16# m))
- toInteger (I16# x#) = IS (extendInt16# x#)
+ (I16# (intToInt16# d),
+ I16# (intToInt16# m))
+ toInteger (I16# x#) = IS (int16ToInt# x#)
-- | @since 2.01
instance Bounded Int16 where
@@ -391,34 +391,34 @@ instance Bits Int16 where
{-# INLINE testBit #-}
{-# INLINE popCount #-}
- (I16# x#) .&. (I16# y#) = I16# (narrowInt16# ((extendInt16# x#) `andI#` (extendInt16# y#)))
- (I16# x#) .|. (I16# y#) = I16# (narrowInt16# ((extendInt16# x#) `orI#` (extendInt16# y#)))
- (I16# x#) `xor` (I16# y#) = I16# (narrowInt16# ((extendInt16# x#) `xorI#` (extendInt16# y#)))
- complement (I16# x#) = I16# (narrowInt16# (notI# (extendInt16# x#)))
+ (I16# x#) .&. (I16# y#) = I16# (intToInt16# ((int16ToInt# x#) `andI#` (int16ToInt# y#)))
+ (I16# x#) .|. (I16# y#) = I16# (intToInt16# ((int16ToInt# x#) `orI#` (int16ToInt# y#)))
+ (I16# x#) `xor` (I16# y#) = I16# (intToInt16# ((int16ToInt# x#) `xorI#` (int16ToInt# y#)))
+ complement (I16# x#) = I16# (intToInt16# (notI# (int16ToInt# x#)))
(I16# x#) `shift` (I# i#)
- | isTrue# (i# >=# 0#) = I16# (narrowInt16# ((extendInt16# x#) `iShiftL#` i#))
- | otherwise = I16# (narrowInt16# ((extendInt16# x#) `iShiftRA#` negateInt# i#))
+ | isTrue# (i# >=# 0#) = I16# (intToInt16# ((int16ToInt# x#) `iShiftL#` i#))
+ | otherwise = I16# (intToInt16# ((int16ToInt# x#) `iShiftRA#` negateInt# i#))
(I16# x#) `shiftL` (I# i#)
- | isTrue# (i# >=# 0#) = I16# (narrowInt16# ((extendInt16# x#) `iShiftL#` i#))
+ | isTrue# (i# >=# 0#) = I16# (intToInt16# ((int16ToInt# x#) `iShiftL#` i#))
| otherwise = overflowError
- (I16# x#) `unsafeShiftL` (I# i#) = I16# (narrowInt16# ((extendInt16# x#) `uncheckedIShiftL#` i#))
+ (I16# x#) `unsafeShiftL` (I# i#) = I16# (intToInt16# ((int16ToInt# x#) `uncheckedIShiftL#` i#))
(I16# x#) `shiftR` (I# i#)
- | isTrue# (i# >=# 0#) = I16# (narrowInt16# ((extendInt16# x#) `iShiftRA#` i#))
+ | isTrue# (i# >=# 0#) = I16# (intToInt16# ((int16ToInt# x#) `iShiftRA#` i#))
| otherwise = overflowError
- (I16# x#) `unsafeShiftR` (I# i#) = I16# (narrowInt16# ((extendInt16# x#) `uncheckedIShiftRA#` i#))
+ (I16# x#) `unsafeShiftR` (I# i#) = I16# (intToInt16# ((int16ToInt# x#) `uncheckedIShiftRA#` i#))
(I16# x#) `rotate` (I# i#)
| isTrue# (i'# ==# 0#)
= I16# x#
| otherwise
- = I16# (narrowInt16# (word2Int# ((x'# `uncheckedShiftL#` i'#) `or#`
+ = I16# (intToInt16# (word2Int# ((x'# `uncheckedShiftL#` i'#) `or#`
(x'# `uncheckedShiftRL#` (16# -# i'#)))))
where
- !x'# = narrow16Word# (int2Word# (extendInt16# x#))
+ !x'# = narrow16Word# (int2Word# (int16ToInt# x#))
!i'# = word2Int# (int2Word# i# `and#` 15##)
bitSizeMaybe i = Just (finiteBitSize i)
bitSize i = finiteBitSize i
isSigned _ = True
- popCount (I16# x#) = I# (word2Int# (popCnt16# (int2Word# (extendInt16# x#))))
+ popCount (I16# x#) = I# (word2Int# (popCnt16# (int2Word# (int16ToInt# x#))))
bit = bitDefault
testBit = testBitDefault
@@ -427,15 +427,15 @@ instance FiniteBits Int16 where
{-# INLINE countLeadingZeros #-}
{-# INLINE countTrailingZeros #-}
finiteBitSize _ = 16
- countLeadingZeros (I16# x#) = I# (word2Int# (clz16# (int2Word# (extendInt16# x#))))
- countTrailingZeros (I16# x#) = I# (word2Int# (ctz16# (int2Word# (extendInt16# x#))))
+ countLeadingZeros (I16# x#) = I# (word2Int# (clz16# (int2Word# (int16ToInt# x#))))
+ countTrailingZeros (I16# x#) = I# (word2Int# (ctz16# (int2Word# (int16ToInt# x#))))
{-# RULES
-"fromIntegral/Word8->Int16" fromIntegral = \(W8# x#) -> I16# (narrowInt16# (word2Int# (extendWord8# x#)))
-"fromIntegral/Int8->Int16" fromIntegral = \(I8# x#) -> I16# (narrowInt16# (extendInt8# x#))
+"fromIntegral/Word8->Int16" fromIntegral = \(W8# x#) -> I16# (intToInt16# (word2Int# (word8ToWord# x#)))
+"fromIntegral/Int8->Int16" fromIntegral = \(I8# x#) -> I16# (intToInt16# (int8ToInt# x#))
"fromIntegral/Int16->Int16" fromIntegral = id :: Int16 -> Int16
-"fromIntegral/a->Int16" fromIntegral = \x -> case fromIntegral x of I# x# -> I16# (narrowInt16# x#)
-"fromIntegral/Int16->a" fromIntegral = \(I16# x#) -> fromIntegral (I# (extendInt16# x#))
+"fromIntegral/a->Int16" fromIntegral = \x -> case fromIntegral x of I# x# -> I16# (intToInt16# x#)
+"fromIntegral/Int16->a" fromIntegral = \(I16# x#) -> fromIntegral (I# (int16ToInt# x#))
#-}
{-# RULES
@@ -488,8 +488,8 @@ instance Eq Int32 where
(/=) = neInt32
eqInt32, neInt32 :: Int32 -> Int32 -> Bool
-eqInt32 (I32# x) (I32# y) = isTrue# ((extendInt32# x) ==# (extendInt32# y))
-neInt32 (I32# x) (I32# y) = isTrue# ((extendInt32# x) /=# (extendInt32# y))
+eqInt32 (I32# x) (I32# y) = isTrue# ((int32ToInt# x) ==# (int32ToInt# y))
+neInt32 (I32# x) (I32# y) = isTrue# ((int32ToInt# x) /=# (int32ToInt# y))
{-# INLINE [1] eqInt32 #-}
{-# INLINE [1] neInt32 #-}
@@ -505,10 +505,10 @@ instance Ord Int32 where
{-# INLINE [1] ltInt32 #-}
{-# INLINE [1] leInt32 #-}
gtInt32, geInt32, ltInt32, leInt32 :: Int32 -> Int32 -> Bool
-(I32# x) `gtInt32` (I32# y) = isTrue# ((extendInt32# x) ># (extendInt32# y))
-(I32# x) `geInt32` (I32# y) = isTrue# ((extendInt32# x) >=# (extendInt32# y))
-(I32# x) `ltInt32` (I32# y) = isTrue# ((extendInt32# x) <# (extendInt32# y))
-(I32# x) `leInt32` (I32# y) = isTrue# ((extendInt32# x) <=# (extendInt32# y))
+(I32# x) `gtInt32` (I32# y) = isTrue# ((int32ToInt# x) ># (int32ToInt# y))
+(I32# x) `geInt32` (I32# y) = isTrue# ((int32ToInt# x) >=# (int32ToInt# y))
+(I32# x) `ltInt32` (I32# y) = isTrue# ((int32ToInt# x) <# (int32ToInt# y))
+(I32# x) `leInt32` (I32# y) = isTrue# ((int32ToInt# x) <=# (int32ToInt# y))
-- | @since 2.01
instance Show Int32 where
@@ -516,16 +516,16 @@ instance Show Int32 where
-- | @since 2.01
instance Num Int32 where
- (I32# x#) + (I32# y#) = I32# (narrowInt32# ((extendInt32# x#) +# (extendInt32# y#)))
- (I32# x#) - (I32# y#) = I32# (narrowInt32# ((extendInt32# x#) -# (extendInt32# y#)))
- (I32# x#) * (I32# y#) = I32# (narrowInt32# ((extendInt32# x#) *# (extendInt32# y#)))
- negate (I32# x#) = I32# (narrowInt32# (negateInt# (extendInt32# x#)))
+ (I32# x#) + (I32# y#) = I32# (intToInt32# ((int32ToInt# x#) +# (int32ToInt# y#)))
+ (I32# x#) - (I32# y#) = I32# (intToInt32# ((int32ToInt# x#) -# (int32ToInt# y#)))
+ (I32# x#) * (I32# y#) = I32# (intToInt32# ((int32ToInt# x#) *# (int32ToInt# y#)))
+ negate (I32# x#) = I32# (intToInt32# (negateInt# (int32ToInt# x#)))
abs x | x >= 0 = x
| otherwise = negate x
signum x | x > 0 = 1
signum 0 = 0
signum _ = -1
- fromInteger i = I32# (narrowInt32# (integerToInt# i))
+ fromInteger i = I32# (intToInt32# (integerToInt# i))
-- | @since 2.01
instance Enum Int32 where
@@ -536,14 +536,14 @@ instance Enum Int32 where
| x /= minBound = x - 1
| otherwise = predError "Int32"
#if WORD_SIZE_IN_BITS == 32
- toEnum (I# i#) = I32# (narrowInt32# i#)
+ toEnum (I# i#) = I32# (intToInt32# i#)
#else
toEnum i@(I# i#)
| i >= fromIntegral (minBound::Int32) && i <= fromIntegral (maxBound::Int32)
- = I32# (narrowInt32# i#)
+ = I32# (intToInt32# i#)
| otherwise = toEnumError "Int32" i (minBound::Int32, maxBound::Int32)
#endif
- fromEnum (I32# x#) = I# (extendInt32# x#)
+ fromEnum (I32# x#) = I# (int32ToInt# x#)
enumFrom = boundedEnumFrom
enumFromThen = boundedEnumFromThen
@@ -552,42 +552,42 @@ instance Integral Int32 where
quot x@(I32# x#) y@(I32# y#)
| y == 0 = divZeroError
| y == (-1) && x == minBound = overflowError -- Note [Order of tests]
- | otherwise = I32# (narrowInt32# ((extendInt32# x#) `quotInt#` (extendInt32# y#)))
+ | otherwise = I32# (intToInt32# ((int32ToInt# x#) `quotInt#` (int32ToInt# y#)))
rem (I32# x#) y@(I32# y#)
| y == 0 = divZeroError
-- The quotRem CPU instruction fails for minBound `quotRem` -1,
-- but minBound `rem` -1 is well-defined (0). We therefore
-- special-case it.
| y == (-1) = 0
- | otherwise = I32# (narrowInt32# ((extendInt32# x#) `remInt#` (extendInt32# y#)))
+ | otherwise = I32# (intToInt32# ((int32ToInt# x#) `remInt#` (int32ToInt# y#)))
div x@(I32# x#) y@(I32# y#)
| y == 0 = divZeroError
| y == (-1) && x == minBound = overflowError -- Note [Order of tests]
- | otherwise = I32# (narrowInt32# ((extendInt32# x#) `divInt#` (extendInt32# y#)))
+ | otherwise = I32# (intToInt32# ((int32ToInt# x#) `divInt#` (int32ToInt# y#)))
mod (I32# x#) y@(I32# y#)
| y == 0 = divZeroError
-- The divMod CPU instruction fails for minBound `divMod` -1,
-- but minBound `mod` -1 is well-defined (0). We therefore
-- special-case it.
| y == (-1) = 0
- | otherwise = I32# (narrowInt32# ((extendInt32# x#) `modInt#` (extendInt32# y#)))
+ | otherwise = I32# (intToInt32# ((int32ToInt# x#) `modInt#` (int32ToInt# y#)))
quotRem x@(I32# x#) y@(I32# y#)
| y == 0 = divZeroError
-- Note [Order of tests]
| y == (-1) && x == minBound = (overflowError, 0)
- | otherwise = case (extendInt32# x#) `quotRemInt#` (extendInt32# y#) of
+ | otherwise = case (int32ToInt# x#) `quotRemInt#` (int32ToInt# y#) of
(# q, r #) ->
- (I32# (narrowInt32# q),
- I32# (narrowInt32# r))
+ (I32# (intToInt32# q),
+ I32# (intToInt32# r))
divMod x@(I32# x#) y@(I32# y#)
| y == 0 = divZeroError
-- Note [Order of tests]
| y == (-1) && x == minBound = (overflowError, 0)
- | otherwise = case (extendInt32# x#) `divModInt#` (extendInt32# y#) of
+ | otherwise = case (int32ToInt# x#) `divModInt#` (int32ToInt# y#) of
(# d, m #) ->
- (I32# (narrowInt32# d),
- I32# (narrowInt32# m))
- toInteger (I32# x#) = IS (extendInt32# x#)
+ (I32# (intToInt32# d),
+ I32# (intToInt32# m))
+ toInteger (I32# x#) = IS (int32ToInt# x#)
-- | @since 2.01
instance Read Int32 where
@@ -600,35 +600,35 @@ instance Bits Int32 where
{-# INLINE testBit #-}
{-# INLINE popCount #-}
- (I32# x#) .&. (I32# y#) = I32# (narrowInt32# ((extendInt32# x#) `andI#` (extendInt32# y#)))
- (I32# x#) .|. (I32# y#) = I32# (narrowInt32# ((extendInt32# x#) `orI#` (extendInt32# y#)))
- (I32# x#) `xor` (I32# y#) = I32# (narrowInt32# ((extendInt32# x#) `xorI#` (extendInt32# y#)))
- complement (I32# x#) = I32# (narrowInt32# (notI# (extendInt32# x#)))
+ (I32# x#) .&. (I32# y#) = I32# (intToInt32# ((int32ToInt# x#) `andI#` (int32ToInt# y#)))
+ (I32# x#) .|. (I32# y#) = I32# (intToInt32# ((int32ToInt# x#) `orI#` (int32ToInt# y#)))
+ (I32# x#) `xor` (I32# y#) = I32# (intToInt32# ((int32ToInt# x#) `xorI#` (int32ToInt# y#)))
+ complement (I32# x#) = I32# (intToInt32# (notI# (int32ToInt# x#)))
(I32# x#) `shift` (I# i#)
- | isTrue# (i# >=# 0#) = I32# (narrowInt32# ((extendInt32# x#) `iShiftL#` i#))
- | otherwise = I32# (narrowInt32# ((extendInt32# x#) `iShiftRA#` negateInt# i#))
+ | isTrue# (i# >=# 0#) = I32# (intToInt32# ((int32ToInt# x#) `iShiftL#` i#))
+ | otherwise = I32# (intToInt32# ((int32ToInt# x#) `iShiftRA#` negateInt# i#))
(I32# x#) `shiftL` (I# i#)
- | isTrue# (i# >=# 0#) = I32# (narrowInt32# ((extendInt32# x#) `iShiftL#` i#))
+ | isTrue# (i# >=# 0#) = I32# (intToInt32# ((int32ToInt# x#) `iShiftL#` i#))
| otherwise = overflowError
(I32# x#) `unsafeShiftL` (I# i#) =
- I32# (narrowInt32# ((extendInt32# x#) `uncheckedIShiftL#` i#))
+ I32# (intToInt32# ((int32ToInt# x#) `uncheckedIShiftL#` i#))
(I32# x#) `shiftR` (I# i#)
- | isTrue# (i# >=# 0#) = I32# (narrowInt32# ((extendInt32# x#) `iShiftRA#` i#))
+ | isTrue# (i# >=# 0#) = I32# (intToInt32# ((int32ToInt# x#) `iShiftRA#` i#))
| otherwise = overflowError
- (I32# x#) `unsafeShiftR` (I# i#) = I32# (narrowInt32# ((extendInt32# x#) `uncheckedIShiftRA#` i#))
+ (I32# x#) `unsafeShiftR` (I# i#) = I32# (intToInt32# ((int32ToInt# x#) `uncheckedIShiftRA#` i#))
(I32# x#) `rotate` (I# i#)
| isTrue# (i'# ==# 0#)
= I32# x#
| otherwise
- = I32# (narrowInt32# (word2Int# ((x'# `uncheckedShiftL#` i'#) `or#`
+ = I32# (intToInt32# (word2Int# ((x'# `uncheckedShiftL#` i'#) `or#`
(x'# `uncheckedShiftRL#` (32# -# i'#)))))
where
- !x'# = narrow32Word# (int2Word# (extendInt32# x#))
+ !x'# = narrow32Word# (int2Word# (int32ToInt# x#))
!i'# = word2Int# (int2Word# i# `and#` 31##)
bitSizeMaybe i = Just (finiteBitSize i)
bitSize i = finiteBitSize i
isSigned _ = True
- popCount (I32# x#) = I# (word2Int# (popCnt32# (int2Word# (extendInt32# x#))))
+ popCount (I32# x#) = I# (word2Int# (popCnt32# (int2Word# (int32ToInt# x#))))
bit = bitDefault
testBit = testBitDefault
@@ -637,17 +637,17 @@ instance FiniteBits Int32 where
{-# INLINE countLeadingZeros #-}
{-# INLINE countTrailingZeros #-}
finiteBitSize _ = 32
- countLeadingZeros (I32# x#) = I# (word2Int# (clz32# (int2Word# (extendInt32# x#))))
- countTrailingZeros (I32# x#) = I# (word2Int# (ctz32# (int2Word# (extendInt32# x#))))
+ countLeadingZeros (I32# x#) = I# (word2Int# (clz32# (int2Word# (int32ToInt# x#))))
+ countTrailingZeros (I32# x#) = I# (word2Int# (ctz32# (int2Word# (int32ToInt# x#))))
{-# RULES
-"fromIntegral/Word8->Int32" fromIntegral = \(W8# x#) -> I32# (narrowInt32# (word2Int# (extendWord8# x#)))
-"fromIntegral/Word16->Int32" fromIntegral = \(W16# x#) -> I32# (narrowInt32# (word2Int# (extendWord16# x#)))
-"fromIntegral/Int8->Int32" fromIntegral = \(I8# x#) -> I32# (narrowInt32# (extendInt8# x#))
-"fromIntegral/Int16->Int32" fromIntegral = \(I16# x#) -> I32# (narrowInt32# (extendInt16# x#))
+"fromIntegral/Word8->Int32" fromIntegral = \(W8# x#) -> I32# (intToInt32# (word2Int# (word8ToWord# x#)))
+"fromIntegral/Word16->Int32" fromIntegral = \(W16# x#) -> I32# (intToInt32# (word2Int# (word16ToWord# x#)))
+"fromIntegral/Int8->Int32" fromIntegral = \(I8# x#) -> I32# (intToInt32# (int8ToInt# x#))
+"fromIntegral/Int16->Int32" fromIntegral = \(I16# x#) -> I32# (intToInt32# (int16ToInt# x#))
"fromIntegral/Int32->Int32" fromIntegral = id :: Int32 -> Int32
-"fromIntegral/a->Int32" fromIntegral = \x -> case fromIntegral x of I# x# -> I32# (narrowInt32# x#)
-"fromIntegral/Int32->a" fromIntegral = \(I32# x#) -> fromIntegral (I# (extendInt32# x#))
+"fromIntegral/a->Int32" fromIntegral = \x -> case fromIntegral x of I# x# -> I32# (intToInt32# x#)
+"fromIntegral/Int32->a" fromIntegral = \(I32# x#) -> fromIntegral (I# (int32ToInt# x#))
#-}
{-# RULES
diff --git a/libraries/base/GHC/Storable.hs b/libraries/base/GHC/Storable.hs
index 359c136b2b..d9b9382211 100644
--- a/libraries/base/GHC/Storable.hs
+++ b/libraries/base/GHC/Storable.hs
@@ -91,17 +91,17 @@ readDoubleOffPtr (Ptr a) (I# i)
readStablePtrOffPtr (Ptr a) (I# i)
= IO $ \s -> case readStablePtrOffAddr# a i s of (# s2, x #) -> (# s2, StablePtr x #)
readInt8OffPtr (Ptr a) (I# i)
- = IO $ \s -> case readInt8OffAddr# a i s of (# s2, x #) -> (# s2, I8# (narrowInt8# x) #)
+ = IO $ \s -> case readInt8OffAddr# a i s of (# s2, x #) -> (# s2, I8# x #)
readWord8OffPtr (Ptr a) (I# i)
- = IO $ \s -> case readWord8OffAddr# a i s of (# s2, x #) -> (# s2, W8# (narrowWord8# x) #)
+ = IO $ \s -> case readWord8OffAddr# a i s of (# s2, x #) -> (# s2, W8# x #)
readInt16OffPtr (Ptr a) (I# i)
- = IO $ \s -> case readInt16OffAddr# a i s of (# s2, x #) -> (# s2, I16# (narrowInt16# x) #)
+ = IO $ \s -> case readInt16OffAddr# a i s of (# s2, x #) -> (# s2, I16# x #)
readWord16OffPtr (Ptr a) (I# i)
- = IO $ \s -> case readWord16OffAddr# a i s of (# s2, x #) -> (# s2, W16# (narrowWord16# x) #)
+ = IO $ \s -> case readWord16OffAddr# a i s of (# s2, x #) -> (# s2, W16# x #)
readInt32OffPtr (Ptr a) (I# i)
- = IO $ \s -> case readInt32OffAddr# a i s of (# s2, x #) -> (# s2, I32# (narrowInt32# x) #)
+ = IO $ \s -> case readInt32OffAddr# a i s of (# s2, x #) -> (# s2, I32# x #)
readWord32OffPtr (Ptr a) (I# i)
- = IO $ \s -> case readWord32OffAddr# a i s of (# s2, x #) -> (# s2, W32# (narrowWord32# x) #)
+ = IO $ \s -> case readWord32OffAddr# a i s of (# s2, x #) -> (# s2, W32# x #)
readInt64OffPtr (Ptr a) (I# i)
= IO $ \s -> case readInt64OffAddr# a i s of (# s2, x #) -> (# s2, I64# x #)
readWord64OffPtr (Ptr a) (I# i)
@@ -141,17 +141,17 @@ writeDoubleOffPtr (Ptr a) (I# i) (D# x)
writeStablePtrOffPtr (Ptr a) (I# i) (StablePtr x)
= IO $ \s -> case writeStablePtrOffAddr# a i x s of s2 -> (# s2 , () #)
writeInt8OffPtr (Ptr a) (I# i) (I8# x)
- = IO $ \s -> case writeInt8OffAddr# a i (extendInt8# x) s of s2 -> (# s2, () #)
+ = IO $ \s -> case writeInt8OffAddr# a i x s of s2 -> (# s2, () #)
writeWord8OffPtr (Ptr a) (I# i) (W8# x)
- = IO $ \s -> case writeWord8OffAddr# a i (extendWord8# x) s of s2 -> (# s2, () #)
+ = IO $ \s -> case writeWord8OffAddr# a i x s of s2 -> (# s2, () #)
writeInt16OffPtr (Ptr a) (I# i) (I16# x)
- = IO $ \s -> case writeInt16OffAddr# a i (extendInt16# x) s of s2 -> (# s2, () #)
+ = IO $ \s -> case writeInt16OffAddr# a i x s of s2 -> (# s2, () #)
writeWord16OffPtr (Ptr a) (I# i) (W16# x)
- = IO $ \s -> case writeWord16OffAddr# a i (extendWord16# x) s of s2 -> (# s2, () #)
+ = IO $ \s -> case writeWord16OffAddr# a i x s of s2 -> (# s2, () #)
writeInt32OffPtr (Ptr a) (I# i) (I32# x)
- = IO $ \s -> case writeInt32OffAddr# a i (extendInt32# x) s of s2 -> (# s2, () #)
+ = IO $ \s -> case writeInt32OffAddr# a i x s of s2 -> (# s2, () #)
writeWord32OffPtr (Ptr a) (I# i) (W32# x)
- = IO $ \s -> case writeWord32OffAddr# a i (extendWord32# x) s of s2 -> (# s2, () #)
+ = IO $ \s -> case writeWord32OffAddr# a i x s of s2 -> (# s2, () #)
writeInt64OffPtr (Ptr a) (I# i) (I64# x)
= IO $ \s -> case writeInt64OffAddr# a i x s of s2 -> (# s2, () #)
writeWord64OffPtr (Ptr a) (I# i) (W64# x)
diff --git a/libraries/base/GHC/Word.hs b/libraries/base/GHC/Word.hs
index 02dcdfcd1a..77d63cc9d7 100644
--- a/libraries/base/GHC/Word.hs
+++ b/libraries/base/GHC/Word.hs
@@ -80,8 +80,8 @@ instance Eq Word8 where
(/=) = neWord8
eqWord8, neWord8 :: Word8 -> Word8 -> Bool
-eqWord8 (W8# x) (W8# y) = isTrue# ((extendWord8# x) `eqWord#` (extendWord8# y))
-neWord8 (W8# x) (W8# y) = isTrue# ((extendWord8# x) `neWord#` (extendWord8# y))
+eqWord8 (W8# x) (W8# y) = isTrue# ((word8ToWord# x) `eqWord#` (word8ToWord# y))
+neWord8 (W8# x) (W8# y) = isTrue# ((word8ToWord# x) `neWord#` (word8ToWord# y))
{-# INLINE [1] eqWord8 #-}
{-# INLINE [1] neWord8 #-}
@@ -97,10 +97,10 @@ instance Ord Word8 where
{-# INLINE [1] ltWord8 #-}
{-# INLINE [1] leWord8 #-}
gtWord8, geWord8, ltWord8, leWord8 :: Word8 -> Word8 -> Bool
-(W8# x) `gtWord8` (W8# y) = isTrue# ((extendWord8# x) `gtWord#` (extendWord8# y))
-(W8# x) `geWord8` (W8# y) = isTrue# ((extendWord8# x) `geWord#` (extendWord8# y))
-(W8# x) `ltWord8` (W8# y) = isTrue# ((extendWord8# x) `ltWord#` (extendWord8# y))
-(W8# x) `leWord8` (W8# y) = isTrue# ((extendWord8# x) `leWord#` (extendWord8# y))
+(W8# x) `gtWord8` (W8# y) = isTrue# ((word8ToWord# x) `gtWord#` (word8ToWord# y))
+(W8# x) `geWord8` (W8# y) = isTrue# ((word8ToWord# x) `geWord#` (word8ToWord# y))
+(W8# x) `ltWord8` (W8# y) = isTrue# ((word8ToWord# x) `ltWord#` (word8ToWord# y))
+(W8# x) `leWord8` (W8# y) = isTrue# ((word8ToWord# x) `leWord#` (word8ToWord# y))
-- | @since 2.01
instance Show Word8 where
@@ -108,14 +108,14 @@ instance Show Word8 where
-- | @since 2.01
instance Num Word8 where
- (W8# x#) + (W8# y#) = W8# (narrowWord8# ((extendWord8# x#) `plusWord#` (extendWord8# y#)))
- (W8# x#) - (W8# y#) = W8# (narrowWord8# ((extendWord8# x#) `minusWord#` (extendWord8# y#)))
- (W8# x#) * (W8# y#) = W8# (narrowWord8# ((extendWord8# x#) `timesWord#` (extendWord8# y#)))
- negate (W8# x#) = W8# (narrowWord8# (int2Word# (negateInt# (word2Int# ((extendWord8# x#))))))
+ (W8# x#) + (W8# y#) = W8# (wordToWord8# ((word8ToWord# x#) `plusWord#` (word8ToWord# y#)))
+ (W8# x#) - (W8# y#) = W8# (wordToWord8# ((word8ToWord# x#) `minusWord#` (word8ToWord# y#)))
+ (W8# x#) * (W8# y#) = W8# (wordToWord8# ((word8ToWord# x#) `timesWord#` (word8ToWord# y#)))
+ negate (W8# x#) = W8# (wordToWord8# (int2Word# (negateInt# (word2Int# ((word8ToWord# x#))))))
abs x = x
signum 0 = 0
signum _ = 1
- fromInteger i = W8# (narrowWord8# (integerToWord# i))
+ fromInteger i = W8# (wordToWord8# (integerToWord# i))
-- | @since 2.01
instance Real Word8 where
@@ -131,36 +131,36 @@ instance Enum Word8 where
| otherwise = predError "Word8"
toEnum i@(I# i#)
| i >= 0 && i <= fromIntegral (maxBound::Word8)
- = W8# (narrowWord8# (int2Word# i#))
+ = W8# (wordToWord8# (int2Word# i#))
| otherwise = toEnumError "Word8" i (minBound::Word8, maxBound::Word8)
- fromEnum (W8# x#) = I# (word2Int# (extendWord8# x#))
+ fromEnum (W8# x#) = I# (word2Int# (word8ToWord# x#))
enumFrom = boundedEnumFrom
enumFromThen = boundedEnumFromThen
-- | @since 2.01
instance Integral Word8 where
quot (W8# x#) y@(W8# y#)
- | y /= 0 = W8# (narrowWord8# ((extendWord8# x#) `quotWord#` (extendWord8# y#)))
+ | y /= 0 = W8# (wordToWord8# ((word8ToWord# x#) `quotWord#` (word8ToWord# y#)))
| otherwise = divZeroError
rem (W8# x#) y@(W8# y#)
- | y /= 0 = W8# (narrowWord8# ((extendWord8# x#) `remWord#` (extendWord8# y#)))
+ | y /= 0 = W8# (wordToWord8# ((word8ToWord# x#) `remWord#` (word8ToWord# y#)))
| otherwise = divZeroError
div (W8# x#) y@(W8# y#)
- | y /= 0 = W8# (narrowWord8# ((extendWord8# x#) `quotWord#` (extendWord8# y#)))
+ | y /= 0 = W8# (wordToWord8# ((word8ToWord# x#) `quotWord#` (word8ToWord# y#)))
| otherwise = divZeroError
mod (W8# x#) y@(W8# y#)
- | y /= 0 = W8# (narrowWord8# ((extendWord8# x#) `remWord#` (extendWord8# y#)))
+ | y /= 0 = W8# (wordToWord8# ((word8ToWord# x#) `remWord#` (word8ToWord# y#)))
| otherwise = divZeroError
quotRem (W8# x#) y@(W8# y#)
- | y /= 0 = case (extendWord8# x#) `quotRemWord#` (extendWord8# y#) of
+ | y /= 0 = case (word8ToWord# x#) `quotRemWord#` (word8ToWord# y#) of
(# q, r #) ->
- (W8# (narrowWord8# q), W8# (narrowWord8# r))
+ (W8# (wordToWord8# q), W8# (wordToWord8# r))
| otherwise = divZeroError
divMod (W8# x#) y@(W8# y#)
- | y /= 0 = (W8# (narrowWord8# ((extendWord8# x#) `quotWord#` (extendWord8# y#)))
- ,W8# (narrowWord8# ((extendWord8# x#) `remWord#` (extendWord8# y#))))
+ | y /= 0 = (W8# (wordToWord8# ((word8ToWord# x#) `quotWord#` (word8ToWord# y#)))
+ ,W8# (wordToWord8# ((word8ToWord# x#) `remWord#` (word8ToWord# y#))))
| otherwise = divZeroError
- toInteger (W8# x#) = IS (word2Int# (extendWord8# x#))
+ toInteger (W8# x#) = IS (word2Int# (word8ToWord# x#))
-- | @since 2.01
instance Bounded Word8 where
@@ -180,32 +180,32 @@ instance Bits Word8 where
{-# INLINE testBit #-}
{-# INLINE popCount #-}
- (W8# x#) .&. (W8# y#) = W8# (narrowWord8# ((extendWord8# x#) `and#` (extendWord8# y#)))
- (W8# x#) .|. (W8# y#) = W8# (narrowWord8# ((extendWord8# x#) `or#` (extendWord8# y#)))
- (W8# x#) `xor` (W8# y#) = W8# (narrowWord8# ((extendWord8# x#) `xor#` (extendWord8# y#)))
- complement (W8# x#) = W8# (narrowWord8# (not# (extendWord8# x#)))
+ (W8# x#) .&. (W8# y#) = W8# (wordToWord8# ((word8ToWord# x#) `and#` (word8ToWord# y#)))
+ (W8# x#) .|. (W8# y#) = W8# (wordToWord8# ((word8ToWord# x#) `or#` (word8ToWord# y#)))
+ (W8# x#) `xor` (W8# y#) = W8# (wordToWord8# ((word8ToWord# x#) `xor#` (word8ToWord# y#)))
+ complement (W8# x#) = W8# (wordToWord8# (not# (word8ToWord# x#)))
(W8# x#) `shift` (I# i#)
- | isTrue# (i# >=# 0#) = W8# (narrowWord8# ((extendWord8# x#) `shiftL#` i#))
- | otherwise = W8# (narrowWord8# ((extendWord8# x#) `shiftRL#` negateInt# i#))
+ | isTrue# (i# >=# 0#) = W8# (wordToWord8# ((word8ToWord# x#) `shiftL#` i#))
+ | otherwise = W8# (wordToWord8# ((word8ToWord# x#) `shiftRL#` negateInt# i#))
(W8# x#) `shiftL` (I# i#)
- | isTrue# (i# >=# 0#) = W8# (narrowWord8# ((extendWord8# x#) `shiftL#` i#))
+ | isTrue# (i# >=# 0#) = W8# (wordToWord8# ((word8ToWord# x#) `shiftL#` i#))
| otherwise = overflowError
(W8# x#) `unsafeShiftL` (I# i#) =
- W8# (narrowWord8# ((extendWord8# x#) `uncheckedShiftL#` i#))
+ W8# (wordToWord8# ((word8ToWord# x#) `uncheckedShiftL#` i#))
(W8# x#) `shiftR` (I# i#)
- | isTrue# (i# >=# 0#) = W8# (narrowWord8# ((extendWord8# x#) `shiftRL#` i#))
+ | isTrue# (i# >=# 0#) = W8# (wordToWord8# ((word8ToWord# x#) `shiftRL#` i#))
| otherwise = overflowError
- (W8# x#) `unsafeShiftR` (I# i#) = W8# (narrowWord8# ((extendWord8# x#) `uncheckedShiftRL#` i#))
+ (W8# x#) `unsafeShiftR` (I# i#) = W8# (wordToWord8# ((word8ToWord# x#) `uncheckedShiftRL#` i#))
(W8# x#) `rotate` (I# i#)
| isTrue# (i'# ==# 0#) = W8# x#
- | otherwise = W8# (narrowWord8# (((extendWord8# x#) `uncheckedShiftL#` i'#) `or#`
- ((extendWord8# x#) `uncheckedShiftRL#` (8# -# i'#))))
+ | otherwise = W8# (wordToWord8# (((word8ToWord# x#) `uncheckedShiftL#` i'#) `or#`
+ ((word8ToWord# x#) `uncheckedShiftRL#` (8# -# i'#))))
where
!i'# = word2Int# (int2Word# i# `and#` 7##)
bitSizeMaybe i = Just (finiteBitSize i)
bitSize i = finiteBitSize i
isSigned _ = False
- popCount (W8# x#) = I# (word2Int# (popCnt8# (extendWord8# x#)))
+ popCount (W8# x#) = I# (word2Int# (popCnt8# (word8ToWord# x#)))
bit = bitDefault
testBit = testBitDefault
@@ -214,14 +214,14 @@ instance FiniteBits Word8 where
{-# INLINE countLeadingZeros #-}
{-# INLINE countTrailingZeros #-}
finiteBitSize _ = 8
- countLeadingZeros (W8# x#) = I# (word2Int# (clz8# (extendWord8# x#)))
- countTrailingZeros (W8# x#) = I# (word2Int# (ctz8# (extendWord8# x#)))
+ countLeadingZeros (W8# x#) = I# (word2Int# (clz8# (word8ToWord# x#)))
+ countTrailingZeros (W8# x#) = I# (word2Int# (ctz8# (word8ToWord# x#)))
{-# RULES
"fromIntegral/Word8->Word8" fromIntegral = id :: Word8 -> Word8
"fromIntegral/Word8->Integer" fromIntegral = toInteger :: Word8 -> Integer
-"fromIntegral/a->Word8" fromIntegral = \x -> case fromIntegral x of W# x# -> W8# (narrowWord8# x#)
-"fromIntegral/Word8->a" fromIntegral = \(W8# x#) -> fromIntegral (W# (extendWord8# x#))
+"fromIntegral/a->Word8" fromIntegral = \x -> case fromIntegral x of W# x# -> W8# (wordToWord8# x#)
+"fromIntegral/Word8->a" fromIntegral = \(W8# x#) -> fromIntegral (W# (word8ToWord# x#))
#-}
{-# RULES
@@ -271,8 +271,8 @@ instance Eq Word16 where
(/=) = neWord16
eqWord16, neWord16 :: Word16 -> Word16 -> Bool
-eqWord16 (W16# x) (W16# y) = isTrue# ((extendWord16# x) `eqWord#` (extendWord16# y))
-neWord16 (W16# x) (W16# y) = isTrue# ((extendWord16# x) `neWord#` (extendWord16# y))
+eqWord16 (W16# x) (W16# y) = isTrue# ((word16ToWord# x) `eqWord#` (word16ToWord# y))
+neWord16 (W16# x) (W16# y) = isTrue# ((word16ToWord# x) `neWord#` (word16ToWord# y))
{-# INLINE [1] eqWord16 #-}
{-# INLINE [1] neWord16 #-}
@@ -288,10 +288,10 @@ instance Ord Word16 where
{-# INLINE [1] ltWord16 #-}
{-# INLINE [1] leWord16 #-}
gtWord16, geWord16, ltWord16, leWord16 :: Word16 -> Word16 -> Bool
-(W16# x) `gtWord16` (W16# y) = isTrue# ((extendWord16# x) `gtWord#` (extendWord16# y))
-(W16# x) `geWord16` (W16# y) = isTrue# ((extendWord16# x) `geWord#` (extendWord16# y))
-(W16# x) `ltWord16` (W16# y) = isTrue# ((extendWord16# x) `ltWord#` (extendWord16# y))
-(W16# x) `leWord16` (W16# y) = isTrue# ((extendWord16# x) `leWord#` (extendWord16# y))
+(W16# x) `gtWord16` (W16# y) = isTrue# ((word16ToWord# x) `gtWord#` (word16ToWord# y))
+(W16# x) `geWord16` (W16# y) = isTrue# ((word16ToWord# x) `geWord#` (word16ToWord# y))
+(W16# x) `ltWord16` (W16# y) = isTrue# ((word16ToWord# x) `ltWord#` (word16ToWord# y))
+(W16# x) `leWord16` (W16# y) = isTrue# ((word16ToWord# x) `leWord#` (word16ToWord# y))
-- | @since 2.01
instance Show Word16 where
@@ -299,14 +299,14 @@ instance Show Word16 where
-- | @since 2.01
instance Num Word16 where
- (W16# x#) + (W16# y#) = W16# (narrowWord16# ((extendWord16# x#) `plusWord#` (extendWord16# y#)))
- (W16# x#) - (W16# y#) = W16# (narrowWord16# ((extendWord16# x#) `minusWord#` (extendWord16# y#)))
- (W16# x#) * (W16# y#) = W16# (narrowWord16# ((extendWord16# x#) `timesWord#` (extendWord16# y#)))
- negate (W16# x#) = W16# (narrowWord16# (int2Word# (negateInt# (word2Int# (extendWord16# x#)))))
+ (W16# x#) + (W16# y#) = W16# (wordToWord16# ((word16ToWord# x#) `plusWord#` (word16ToWord# y#)))
+ (W16# x#) - (W16# y#) = W16# (wordToWord16# ((word16ToWord# x#) `minusWord#` (word16ToWord# y#)))
+ (W16# x#) * (W16# y#) = W16# (wordToWord16# ((word16ToWord# x#) `timesWord#` (word16ToWord# y#)))
+ negate (W16# x#) = W16# (wordToWord16# (int2Word# (negateInt# (word2Int# (word16ToWord# x#)))))
abs x = x
signum 0 = 0
signum _ = 1
- fromInteger i = W16# (narrowWord16# (integerToWord# i))
+ fromInteger i = W16# (wordToWord16# (integerToWord# i))
-- | @since 2.01
instance Real Word16 where
@@ -322,36 +322,36 @@ instance Enum Word16 where
| otherwise = predError "Word16"
toEnum i@(I# i#)
| i >= 0 && i <= fromIntegral (maxBound::Word16)
- = W16# (narrowWord16# (int2Word# i#))
+ = W16# (wordToWord16# (int2Word# i#))
| otherwise = toEnumError "Word16" i (minBound::Word16, maxBound::Word16)
- fromEnum (W16# x#) = I# (word2Int# (extendWord16# x#))
+ fromEnum (W16# x#) = I# (word2Int# (word16ToWord# x#))
enumFrom = boundedEnumFrom
enumFromThen = boundedEnumFromThen
-- | @since 2.01
instance Integral Word16 where
quot (W16# x#) y@(W16# y#)
- | y /= 0 = W16# (narrowWord16# ((extendWord16# x#) `quotWord#` (extendWord16# y#)))
+ | y /= 0 = W16# (wordToWord16# ((word16ToWord# x#) `quotWord#` (word16ToWord# y#)))
| otherwise = divZeroError
rem (W16# x#) y@(W16# y#)
- | y /= 0 = W16# (narrowWord16# ((extendWord16# x#) `remWord#` (extendWord16# y#)))
+ | y /= 0 = W16# (wordToWord16# ((word16ToWord# x#) `remWord#` (word16ToWord# y#)))
| otherwise = divZeroError
div (W16# x#) y@(W16# y#)
- | y /= 0 = W16# (narrowWord16# ((extendWord16# x#) `quotWord#` (extendWord16# y#)))
+ | y /= 0 = W16# (wordToWord16# ((word16ToWord# x#) `quotWord#` (word16ToWord# y#)))
| otherwise = divZeroError
mod (W16# x#) y@(W16# y#)
- | y /= 0 = W16# (narrowWord16# ((extendWord16# x#) `remWord#` (extendWord16# y#)))
+ | y /= 0 = W16# (wordToWord16# ((word16ToWord# x#) `remWord#` (word16ToWord# y#)))
| otherwise = divZeroError
quotRem (W16# x#) y@(W16# y#)
- | y /= 0 = case (extendWord16# x#) `quotRemWord#` (extendWord16# y#) of
+ | y /= 0 = case (word16ToWord# x#) `quotRemWord#` (word16ToWord# y#) of
(# q, r #) ->
- (W16# (narrowWord16# q), W16# (narrowWord16# r))
+ (W16# (wordToWord16# q), W16# (wordToWord16# r))
| otherwise = divZeroError
divMod (W16# x#) y@(W16# y#)
- | y /= 0 = (W16# (narrowWord16# ((extendWord16# x#) `quotWord#` (extendWord16# y#)))
- ,W16# (narrowWord16# ((extendWord16# x#) `remWord#` (extendWord16# y#))))
+ | y /= 0 = (W16# (wordToWord16# ((word16ToWord# x#) `quotWord#` (word16ToWord# y#)))
+ ,W16# (wordToWord16# ((word16ToWord# x#) `remWord#` (word16ToWord# y#))))
| otherwise = divZeroError
- toInteger (W16# x#) = IS (word2Int# (extendWord16# x#))
+ toInteger (W16# x#) = IS (word2Int# (word16ToWord# x#))
-- | @since 2.01
instance Bounded Word16 where
@@ -371,32 +371,32 @@ instance Bits Word16 where
{-# INLINE testBit #-}
{-# INLINE popCount #-}
- (W16# x#) .&. (W16# y#) = W16# (narrowWord16# ((extendWord16# x#) `and#` (extendWord16# y#)))
- (W16# x#) .|. (W16# y#) = W16# (narrowWord16# ((extendWord16# x#) `or#` (extendWord16# y#)))
- (W16# x#) `xor` (W16# y#) = W16# (narrowWord16# ((extendWord16# x#) `xor#` (extendWord16# y#)))
- complement (W16# x#) = W16# (narrowWord16# (not# (extendWord16# x#)))
+ (W16# x#) .&. (W16# y#) = W16# (wordToWord16# ((word16ToWord# x#) `and#` (word16ToWord# y#)))
+ (W16# x#) .|. (W16# y#) = W16# (wordToWord16# ((word16ToWord# x#) `or#` (word16ToWord# y#)))
+ (W16# x#) `xor` (W16# y#) = W16# (wordToWord16# ((word16ToWord# x#) `xor#` (word16ToWord# y#)))
+ complement (W16# x#) = W16# (wordToWord16# (not# (word16ToWord# x#)))
(W16# x#) `shift` (I# i#)
- | isTrue# (i# >=# 0#) = W16# (narrowWord16# ((extendWord16# x#) `shiftL#` i#))
- | otherwise = W16# (narrowWord16# ((extendWord16# x#) `shiftRL#` negateInt# i#))
+ | isTrue# (i# >=# 0#) = W16# (wordToWord16# ((word16ToWord# x#) `shiftL#` i#))
+ | otherwise = W16# (wordToWord16# ((word16ToWord# x#) `shiftRL#` negateInt# i#))
(W16# x#) `shiftL` (I# i#)
- | isTrue# (i# >=# 0#) = W16# (narrowWord16# ((extendWord16# x#) `shiftL#` i#))
+ | isTrue# (i# >=# 0#) = W16# (wordToWord16# ((word16ToWord# x#) `shiftL#` i#))
| otherwise = overflowError
(W16# x#) `unsafeShiftL` (I# i#) =
- W16# (narrowWord16# ((extendWord16# x#) `uncheckedShiftL#` i#))
+ W16# (wordToWord16# ((word16ToWord# x#) `uncheckedShiftL#` i#))
(W16# x#) `shiftR` (I# i#)
- | isTrue# (i# >=# 0#) = W16# (narrowWord16# ((extendWord16# x#) `shiftRL#` i#))
+ | isTrue# (i# >=# 0#) = W16# (wordToWord16# ((word16ToWord# x#) `shiftRL#` i#))
| otherwise = overflowError
- (W16# x#) `unsafeShiftR` (I# i#) = W16# (narrowWord16# ((extendWord16# x#) `uncheckedShiftRL#` i#))
+ (W16# x#) `unsafeShiftR` (I# i#) = W16# (wordToWord16# ((word16ToWord# x#) `uncheckedShiftRL#` i#))
(W16# x#) `rotate` (I# i#)
| isTrue# (i'# ==# 0#) = W16# x#
- | otherwise = W16# (narrowWord16# (((extendWord16# x#) `uncheckedShiftL#` i'#) `or#`
- ((extendWord16# x#) `uncheckedShiftRL#` (16# -# i'#))))
+ | otherwise = W16# (wordToWord16# (((word16ToWord# x#) `uncheckedShiftL#` i'#) `or#`
+ ((word16ToWord# x#) `uncheckedShiftRL#` (16# -# i'#))))
where
!i'# = word2Int# (int2Word# i# `and#` 15##)
bitSizeMaybe i = Just (finiteBitSize i)
bitSize i = finiteBitSize i
isSigned _ = False
- popCount (W16# x#) = I# (word2Int# (popCnt16# (extendWord16# x#)))
+ popCount (W16# x#) = I# (word2Int# (popCnt16# (word16ToWord# x#)))
bit = bitDefault
testBit = testBitDefault
@@ -405,21 +405,21 @@ instance FiniteBits Word16 where
{-# INLINE countLeadingZeros #-}
{-# INLINE countTrailingZeros #-}
finiteBitSize _ = 16
- countLeadingZeros (W16# x#) = I# (word2Int# (clz16# (extendWord16# x#)))
- countTrailingZeros (W16# x#) = I# (word2Int# (ctz16# (extendWord16# x#)))
+ countLeadingZeros (W16# x#) = I# (word2Int# (clz16# (word16ToWord# x#)))
+ countTrailingZeros (W16# x#) = I# (word2Int# (ctz16# (word16ToWord# x#)))
-- | Reverse order of bytes in 'Word16'.
--
-- @since 4.7.0.0
byteSwap16 :: Word16 -> Word16
-byteSwap16 (W16# w#) = W16# (narrowWord16# (byteSwap16# (extendWord16# w#)))
+byteSwap16 (W16# w#) = W16# (wordToWord16# (byteSwap16# (word16ToWord# w#)))
{-# RULES
-"fromIntegral/Word8->Word16" fromIntegral = \(W8# x#) -> W16# (narrowWord16# (extendWord8# x#))
+"fromIntegral/Word8->Word16" fromIntegral = \(W8# x#) -> W16# (wordToWord16# (word8ToWord# x#))
"fromIntegral/Word16->Word16" fromIntegral = id :: Word16 -> Word16
"fromIntegral/Word16->Integer" fromIntegral = toInteger :: Word16 -> Integer
-"fromIntegral/a->Word16" fromIntegral = \x -> case fromIntegral x of W# x# -> W16# (narrowWord16# x#)
-"fromIntegral/Word16->a" fromIntegral = \(W16# x#) -> fromIntegral (W# (extendWord16# x#))
+"fromIntegral/a->Word16" fromIntegral = \x -> case fromIntegral x of W# x# -> W16# (wordToWord16# x#)
+"fromIntegral/Word16->a" fromIntegral = \(W16# x#) -> fromIntegral (W# (word16ToWord# x#))
#-}
{-# RULES
@@ -505,8 +505,8 @@ instance Eq Word32 where
(/=) = neWord32
eqWord32, neWord32 :: Word32 -> Word32 -> Bool
-eqWord32 (W32# x) (W32# y) = isTrue# ((extendWord32# x) `eqWord#` (extendWord32# y))
-neWord32 (W32# x) (W32# y) = isTrue# ((extendWord32# x) `neWord#` (extendWord32# y))
+eqWord32 (W32# x) (W32# y) = isTrue# ((word32ToWord# x) `eqWord#` (word32ToWord# y))
+neWord32 (W32# x) (W32# y) = isTrue# ((word32ToWord# x) `neWord#` (word32ToWord# y))
{-# INLINE [1] eqWord32 #-}
{-# INLINE [1] neWord32 #-}
@@ -522,21 +522,21 @@ instance Ord Word32 where
{-# INLINE [1] ltWord32 #-}
{-# INLINE [1] leWord32 #-}
gtWord32, geWord32, ltWord32, leWord32 :: Word32 -> Word32 -> Bool
-(W32# x) `gtWord32` (W32# y) = isTrue# ((extendWord32# x) `gtWord#` (extendWord32# y))
-(W32# x) `geWord32` (W32# y) = isTrue# ((extendWord32# x) `geWord#` (extendWord32# y))
-(W32# x) `ltWord32` (W32# y) = isTrue# ((extendWord32# x) `ltWord#` (extendWord32# y))
-(W32# x) `leWord32` (W32# y) = isTrue# ((extendWord32# x) `leWord#` (extendWord32# y))
+(W32# x) `gtWord32` (W32# y) = isTrue# ((word32ToWord# x) `gtWord#` (word32ToWord# y))
+(W32# x) `geWord32` (W32# y) = isTrue# ((word32ToWord# x) `geWord#` (word32ToWord# y))
+(W32# x) `ltWord32` (W32# y) = isTrue# ((word32ToWord# x) `ltWord#` (word32ToWord# y))
+(W32# x) `leWord32` (W32# y) = isTrue# ((word32ToWord# x) `leWord#` (word32ToWord# y))
-- | @since 2.01
instance Num Word32 where
- (W32# x#) + (W32# y#) = W32# (narrowWord32# ((extendWord32# x#) `plusWord#` (extendWord32# y#)))
- (W32# x#) - (W32# y#) = W32# (narrowWord32# ((extendWord32# x#) `minusWord#` (extendWord32# y#)))
- (W32# x#) * (W32# y#) = W32# (narrowWord32# ((extendWord32# x#) `timesWord#` (extendWord32# y#)))
- negate (W32# x#) = W32# (narrowWord32# (int2Word# (negateInt# (word2Int# (extendWord32# x#)))))
+ (W32# x#) + (W32# y#) = W32# (wordToWord32# ((word32ToWord# x#) `plusWord#` (word32ToWord# y#)))
+ (W32# x#) - (W32# y#) = W32# (wordToWord32# ((word32ToWord# x#) `minusWord#` (word32ToWord# y#)))
+ (W32# x#) * (W32# y#) = W32# (wordToWord32# ((word32ToWord# x#) `timesWord#` (word32ToWord# y#)))
+ negate (W32# x#) = W32# (wordToWord32# (int2Word# (negateInt# (word2Int# (word32ToWord# x#)))))
abs x = x
signum 0 = 0
signum _ = 1
- fromInteger i = W32# (narrowWord32# (integerToWord# i))
+ fromInteger i = W32# (wordToWord32# (integerToWord# i))
-- | @since 2.01
instance Enum Word32 where
@@ -551,19 +551,19 @@ instance Enum Word32 where
#if WORD_SIZE_IN_BITS > 32
&& i <= fromIntegral (maxBound::Word32)
#endif
- = W32# (narrowWord32# (int2Word# i#))
+ = W32# (wordToWord32# (int2Word# i#))
| otherwise = toEnumError "Word32" i (minBound::Word32, maxBound::Word32)
#if WORD_SIZE_IN_BITS == 32
fromEnum x@(W32# x#)
| x <= fromIntegral (maxBound::Int)
- = I# (word2Int# (extendWord32# x#))
+ = I# (word2Int# (word32ToWord# x#))
| otherwise = fromEnumError "Word32" x
enumFrom = integralEnumFrom
enumFromThen = integralEnumFromThen
enumFromTo = integralEnumFromTo
enumFromThenTo = integralEnumFromThenTo
#else
- fromEnum (W32# x#) = I# (word2Int# (extendWord32# x#))
+ fromEnum (W32# x#) = I# (word2Int# (word32ToWord# x#))
enumFrom = boundedEnumFrom
enumFromThen = boundedEnumFromThen
#endif
@@ -571,34 +571,34 @@ instance Enum Word32 where
-- | @since 2.01
instance Integral Word32 where
quot (W32# x#) y@(W32# y#)
- | y /= 0 = W32# (narrowWord32# ((extendWord32# x#) `quotWord#` (extendWord32# y#)))
+ | y /= 0 = W32# (wordToWord32# ((word32ToWord# x#) `quotWord#` (word32ToWord# y#)))
| otherwise = divZeroError
rem (W32# x#) y@(W32# y#)
- | y /= 0 = W32# (narrowWord32# ((extendWord32# x#) `remWord#` (extendWord32# y#)))
+ | y /= 0 = W32# (wordToWord32# ((word32ToWord# x#) `remWord#` (word32ToWord# y#)))
| otherwise = divZeroError
div (W32# x#) y@(W32# y#)
- | y /= 0 = W32# (narrowWord32# ((extendWord32# x#) `quotWord#` (extendWord32# y#)))
+ | y /= 0 = W32# (wordToWord32# ((word32ToWord# x#) `quotWord#` (word32ToWord# y#)))
| otherwise = divZeroError
mod (W32# x#) y@(W32# y#)
- | y /= 0 = W32# (narrowWord32# ((extendWord32# x#) `remWord#` (extendWord32# y#)))
+ | y /= 0 = W32# (wordToWord32# ((word32ToWord# x#) `remWord#` (word32ToWord# y#)))
| otherwise = divZeroError
quotRem (W32# x#) y@(W32# y#)
- | y /= 0 = case (extendWord32# x#) `quotRemWord#` (extendWord32# y#) of
+ | y /= 0 = case (word32ToWord# x#) `quotRemWord#` (word32ToWord# y#) of
(# q, r #) ->
- (W32# (narrowWord32# q), W32# (narrowWord32# r))
+ (W32# (wordToWord32# q), W32# (wordToWord32# r))
| otherwise = divZeroError
divMod (W32# x#) y@(W32# y#)
- | y /= 0 = (W32# (narrowWord32# ((extendWord32# x#) `quotWord#` (extendWord32# y#)))
- ,W32# (narrowWord32# ((extendWord32# x#) `remWord#` (extendWord32# y#))))
+ | y /= 0 = (W32# (wordToWord32# ((word32ToWord# x#) `quotWord#` (word32ToWord# y#)))
+ ,W32# (wordToWord32# ((word32ToWord# x#) `remWord#` (word32ToWord# y#))))
| otherwise = divZeroError
toInteger (W32# x#)
#if WORD_SIZE_IN_BITS == 32
| isTrue# (i# >=# 0#) = IS i#
- | otherwise = integerFromWord# (extendWord32# x#)
+ | otherwise = integerFromWord# (word32ToWord# x#)
where
- !i# = word2Int# (extendWord32# x#)
+ !i# = word2Int# (word32ToWord# x#)
#else
- = IS (word2Int# (extendWord32# x#))
+ = IS (word2Int# (word32ToWord# x#))
#endif
-- | @since 2.01
@@ -608,32 +608,32 @@ instance Bits Word32 where
{-# INLINE testBit #-}
{-# INLINE popCount #-}
- (W32# x#) .&. (W32# y#) = W32# (narrowWord32# ((extendWord32# x#) `and#` (extendWord32# y#)))
- (W32# x#) .|. (W32# y#) = W32# (narrowWord32# ((extendWord32# x#) `or#` (extendWord32# y#)))
- (W32# x#) `xor` (W32# y#) = W32# (narrowWord32# ((extendWord32# x#) `xor#` (extendWord32# y#)))
- complement (W32# x#) = W32# (narrowWord32# (not# (extendWord32# x#)))
+ (W32# x#) .&. (W32# y#) = W32# (wordToWord32# ((word32ToWord# x#) `and#` (word32ToWord# y#)))
+ (W32# x#) .|. (W32# y#) = W32# (wordToWord32# ((word32ToWord# x#) `or#` (word32ToWord# y#)))
+ (W32# x#) `xor` (W32# y#) = W32# (wordToWord32# ((word32ToWord# x#) `xor#` (word32ToWord# y#)))
+ complement (W32# x#) = W32# (wordToWord32# (not# (word32ToWord# x#)))
(W32# x#) `shift` (I# i#)
- | isTrue# (i# >=# 0#) = W32# (narrowWord32# ((extendWord32# x#) `shiftL#` i#))
- | otherwise = W32# (narrowWord32# ((extendWord32# x#) `shiftRL#` negateInt# i#))
+ | isTrue# (i# >=# 0#) = W32# (wordToWord32# ((word32ToWord# x#) `shiftL#` i#))
+ | otherwise = W32# (wordToWord32# ((word32ToWord# x#) `shiftRL#` negateInt# i#))
(W32# x#) `shiftL` (I# i#)
- | isTrue# (i# >=# 0#) = W32# (narrowWord32# ((extendWord32# x#) `shiftL#` i#))
+ | isTrue# (i# >=# 0#) = W32# (wordToWord32# ((word32ToWord# x#) `shiftL#` i#))
| otherwise = overflowError
(W32# x#) `unsafeShiftL` (I# i#) =
- W32# (narrowWord32# ((extendWord32# x#) `uncheckedShiftL#` i#))
+ W32# (wordToWord32# ((word32ToWord# x#) `uncheckedShiftL#` i#))
(W32# x#) `shiftR` (I# i#)
- | isTrue# (i# >=# 0#) = W32# (narrowWord32# ((extendWord32# x#) `shiftRL#` i#))
+ | isTrue# (i# >=# 0#) = W32# (wordToWord32# ((word32ToWord# x#) `shiftRL#` i#))
| otherwise = overflowError
- (W32# x#) `unsafeShiftR` (I# i#) = W32# (narrowWord32# ((extendWord32# x#) `uncheckedShiftRL#` i#))
+ (W32# x#) `unsafeShiftR` (I# i#) = W32# (wordToWord32# ((word32ToWord# x#) `uncheckedShiftRL#` i#))
(W32# x#) `rotate` (I# i#)
| isTrue# (i'# ==# 0#) = W32# x#
- | otherwise = W32# (narrowWord32# (((extendWord32# x#) `uncheckedShiftL#` i'#) `or#`
- ((extendWord32# x#) `uncheckedShiftRL#` (32# -# i'#))))
+ | otherwise = W32# (wordToWord32# (((word32ToWord# x#) `uncheckedShiftL#` i'#) `or#`
+ ((word32ToWord# x#) `uncheckedShiftRL#` (32# -# i'#))))
where
!i'# = word2Int# (int2Word# i# `and#` 31##)
bitSizeMaybe i = Just (finiteBitSize i)
bitSize i = finiteBitSize i
isSigned _ = False
- popCount (W32# x#) = I# (word2Int# (popCnt32# (extendWord32# x#)))
+ popCount (W32# x#) = I# (word2Int# (popCnt32# (word32ToWord# x#)))
bit = bitDefault
testBit = testBitDefault
@@ -642,16 +642,16 @@ instance FiniteBits Word32 where
{-# INLINE countLeadingZeros #-}
{-# INLINE countTrailingZeros #-}
finiteBitSize _ = 32
- countLeadingZeros (W32# x#) = I# (word2Int# (clz32# (extendWord32# x#)))
- countTrailingZeros (W32# x#) = I# (word2Int# (ctz32# (extendWord32# x#)))
+ countLeadingZeros (W32# x#) = I# (word2Int# (clz32# (word32ToWord# x#)))
+ countTrailingZeros (W32# x#) = I# (word2Int# (ctz32# (word32ToWord# x#)))
{-# RULES
-"fromIntegral/Word8->Word32" fromIntegral = \(W8# x#) -> W32# (narrowWord32# (extendWord8# x#))
-"fromIntegral/Word16->Word32" fromIntegral = \(W16# x#) -> W32# (narrowWord32# (extendWord16# x#))
+"fromIntegral/Word8->Word32" fromIntegral = \(W8# x#) -> W32# (wordToWord32# (word8ToWord# x#))
+"fromIntegral/Word16->Word32" fromIntegral = \(W16# x#) -> W32# (wordToWord32# (word16ToWord# x#))
"fromIntegral/Word32->Word32" fromIntegral = id :: Word32 -> Word32
"fromIntegral/Word32->Integer" fromIntegral = toInteger :: Word32 -> Integer
-"fromIntegral/a->Word32" fromIntegral = \x -> case fromIntegral x of W# x# -> W32# (narrowWord32# x#)
-"fromIntegral/Word32->a" fromIntegral = \(W32# x#) -> fromIntegral (W# (extendWord32# x#))
+"fromIntegral/a->Word32" fromIntegral = \x -> case fromIntegral x of W# x# -> W32# (wordToWord32# x#)
+"fromIntegral/Word32->a" fromIntegral = \(W32# x#) -> fromIntegral (W# (word32ToWord# x#))
#-}
-- | @since 2.01
@@ -682,7 +682,7 @@ instance Ix Word32 where
--
-- @since 4.7.0.0
byteSwap32 :: Word32 -> Word32
-byteSwap32 (W32# w#) = W32# (narrowWord32# (byteSwap32# (extendWord32# w#)))
+byteSwap32 (W32# w#) = W32# (wordToWord32# (byteSwap32# (word32ToWord# w#)))
------------------------------------------------------------------------
-- type Word64
@@ -1052,19 +1052,19 @@ byteSwap64 (W64# w#) = W64# (byteSwap# w#)
--
-- @since 4.12.0.0
bitReverse8 :: Word8 -> Word8
-bitReverse8 (W8# w#) = W8# (narrowWord8# (bitReverse8# (extendWord8# w#)))
+bitReverse8 (W8# w#) = W8# (wordToWord8# (bitReverse8# (word8ToWord# w#)))
-- | Reverse the order of the bits in a 'Word16'.
--
-- @since 4.12.0.0
bitReverse16 :: Word16 -> Word16
-bitReverse16 (W16# w#) = W16# (narrowWord16# (bitReverse16# (extendWord16# w#)))
+bitReverse16 (W16# w#) = W16# (wordToWord16# (bitReverse16# (word16ToWord# w#)))
-- | Reverse the order of the bits in a 'Word32'.
--
-- @since 4.12.0.0
bitReverse32 :: Word32 -> Word32
-bitReverse32 (W32# w#) = W32# (narrowWord32# (bitReverse32# (extendWord32# w#)))
+bitReverse32 (W32# w#) = W32# (wordToWord32# (bitReverse32# (word32ToWord# w#)))
-- | Reverse the order of the bits in a 'Word64'.
--
diff --git a/libraries/binary b/libraries/binary
-Subproject 890fcc606d5c9052bdb016d786289dadc29cd46
+Subproject d0c3f06716be373e4195535a76f94f1bba8ab97
diff --git a/libraries/bytestring b/libraries/bytestring
-Subproject 36c2df1feaf10fde8d5848ac47b98d6d62c4e1d
+Subproject da9d8d80f3bdb440cf4fbba65c08e289f58535a
diff --git a/libraries/containers b/libraries/containers
-Subproject 3d05a4ec97fea535593c63a12c188259e641854
+Subproject 7fb91ca53b1aca7c077b36a0c1f8f785d177da3
diff --git a/libraries/ghc-bignum/src/GHC/Num/Backend/GMP.hs b/libraries/ghc-bignum/src/GHC/Num/Backend/GMP.hs
index 649a7acc70..3fd4394bcf 100644
--- a/libraries/ghc-bignum/src/GHC/Num/Backend/GMP.hs
+++ b/libraries/ghc-bignum/src/GHC/Num/Backend/GMP.hs
@@ -435,11 +435,11 @@ integer_gcde a b = case runRW# io of (# _, a #) -> a
case readInt32OffAddr# sg_ptr 0# s of { (# s, sg #) ->
case touch# szs s of { s ->
-- shrink x, y and g to their actual sizes and freeze them
- let !sx = absI# ssx in
- let !sy = absI# ssy in
+ let !sx = absI# (int32ToInt# ssx) in
+ let !sy = absI# (int32ToInt# ssy) in
case mwaSetSize# mbx sx s of { s ->
case mwaSetSize# mby sy s of { s ->
- case mwaSetSize# mbg sg s of { s ->
+ case mwaSetSize# mbg (int32ToInt# sg) s of { s ->
-- return x, y and g as Integer
case unsafeFreezeByteArray# mbx s of { (# s, bx #) ->
@@ -447,8 +447,8 @@ integer_gcde a b = case runRW# io of (# _, a #) -> a
case unsafeFreezeByteArray# mbg s of { (# s, bg #) ->
(# s, (# integerFromBigNat# bg
- , integerFromBigNatSign# (ssx <# 0#) bx
- , integerFromBigNatSign# (ssy <# 0#) by #) #)
+ , integerFromBigNatSign# (int32ToInt# ssx <# 0#) bx
+ , integerFromBigNatSign# (int32ToInt# ssy <# 0#) by #) #)
}}}}}}}}}}}}}}}}
diff --git a/libraries/ghc-bignum/src/GHC/Num/Primitives.hs b/libraries/ghc-bignum/src/GHC/Num/Primitives.hs
index 589600e047..d286a8d933 100644
--- a/libraries/ghc-bignum/src/GHC/Num/Primitives.hs
+++ b/libraries/ghc-bignum/src/GHC/Num/Primitives.hs
@@ -334,7 +334,7 @@ wordToAddrLE# x addr = go x 0#
= (# s, int2Word# c #)
| True
- = case writeWord8OffAddr# addr c (w `and#` 0xFF##) s of
+ = case writeWord8OffAddr# addr c (wordToWord8# w) s of
s' -> go (w `uncheckedShiftRL#` 8#) (c +# 1#) s'
-- | Write a Word to @/addr/@ in base-256 big-endian representation and
@@ -349,7 +349,7 @@ wordToAddrBE# w addr = go 0# (WORD_SIZE_IN_BITS# -# clz)
= (# s, int2Word# c #)
| True
- , w' <- (w `uncheckedShiftRL#` (sh -# 8#)) `and#` 0xFF##
+ , w' <- wordToWord8# (w `uncheckedShiftRL#` (sh -# 8#))
= case writeWord8OffAddr# addr c w' s of
s' -> go (c +# 1#) (sh -# 8#) s'
@@ -386,7 +386,7 @@ wordFromAddrLE# n addr s0 = go 0## 0# s0
| True
= case readWord8OffAddr# addr c s of
- (# s', b #) -> go (w `or#` (b `uncheckedShiftL#` (c `uncheckedIShiftL#` 3#)))
+ (# s', b #) -> go (w `or#` (word8ToWord# b `uncheckedShiftL#` (c `uncheckedIShiftL#` 3#)))
(c +# 1#)
s'
@@ -412,7 +412,7 @@ wordFromAddrBE# n addr s0 = go 0## 0# s0
| True
= case readWord8OffAddr# addr c s of
- (# s', b #) -> go ((w `uncheckedShiftL#` 8#) `or#` b)
+ (# s', b #) -> go ((w `uncheckedShiftL#` 8#) `or#` word8ToWord# b)
(c +# 1#)
s'
@@ -459,7 +459,7 @@ wordToMutableByteArrayLE# x mba off = go x 0#
= (# s, int2Word# c #)
| True
- = case writeWord8Array# mba (word2Int# off +# c) (w `and#` 0xFF##) s of
+ = case writeWord8Array# mba (word2Int# off +# c) (wordToWord8# w) s of
s' -> go (w `uncheckedShiftRL#` 8#) (c +# 1#) s'
-- | Write a Word to @/MutableByteArray/@ in base-256 big-endian representation and
@@ -476,7 +476,7 @@ wordToMutableByteArrayBE# w mba off = go 0# (WORD_SIZE_IN_BITS# -# clz)
= (# s, int2Word# c #)
| True
- , w' <- (w `uncheckedShiftRL#` (sh -# 8#)) `and#` 0xFF##
+ , w' <- wordToWord8# (w `uncheckedShiftRL#` (sh -# 8#))
= case writeWord8Array# mba (word2Int# off +# c) w' s of
s' -> go (c +# 1#) (sh -# 8#) s'
@@ -531,7 +531,7 @@ wordFromByteArrayLE# n ba off =
| True
= case indexWord8Array# ba (word2Int# off +# c) of
- b -> go (w `or#` (b `uncheckedShiftL#` (c `uncheckedIShiftL#` 3#)))
+ b -> go (w `or#` (word8ToWord# b `uncheckedShiftL#` (c `uncheckedIShiftL#` 3#)))
(c +# 1#)
in go 0## 0#
@@ -557,7 +557,7 @@ wordFromByteArrayBE# n ba off = go 0## 0#
| True
= case indexWord8Array# ba (word2Int# off +# c) of
- b -> go ((w `uncheckedShiftL#` 8#) `or#` b) (c +# 1#)
+ b -> go ((w `uncheckedShiftL#` 8#) `or#` word8ToWord# b) (c +# 1#)
-- | Read a Word from @/ByteArray/@ in base-256 representation.
--
diff --git a/libraries/ghc-boot/GHC/Utils/Encoding.hs b/libraries/ghc-boot/GHC/Utils/Encoding.hs
index 0f84be189b..519b607425 100644
--- a/libraries/ghc-boot/GHC/Utils/Encoding.hs
+++ b/libraries/ghc-boot/GHC/Utils/Encoding.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
{-# LANGUAGE BangPatterns, MagicHash, UnboxedTuples #-}
{-# OPTIONS_GHC -O2 -fno-warn-name-shadowing #-}
-- We always optimise this, otherwise performance of a non-optimised
@@ -116,11 +117,20 @@ utf8DecodeChar# indexWord8# =
utf8DecodeCharAddr# :: Addr# -> Int# -> (# Char#, Int# #)
utf8DecodeCharAddr# a# off# =
+#if !MIN_VERSION_base(4,16,0)
utf8DecodeChar# (\i# -> indexWord8OffAddr# a# (i# +# off#))
+#else
+ utf8DecodeChar# (\i# -> word8ToWord# (indexWord8OffAddr# a# (i# +# off#)))
+#endif
utf8DecodeCharByteArray# :: ByteArray# -> Int# -> (# Char#, Int# #)
utf8DecodeCharByteArray# ba# off# =
+#if !MIN_VERSION_base(4,16,0)
utf8DecodeChar# (\i# -> indexWord8Array# ba# (i# +# off#))
+#else
+ utf8DecodeChar# (\i# -> word8ToWord# (indexWord8Array# ba# (i# +# off#)))
+#endif
+
utf8DecodeChar :: Ptr Word8 -> (Char, Int)
utf8DecodeChar !(Ptr a#) =
@@ -184,16 +194,29 @@ utf8CompareShortByteString (SBS a1) (SBS a2) = go 0# 0#
| isTrue# (off1 >=# sz1) = LT
| isTrue# (off2 >=# sz2) = GT
| otherwise =
+#if !MIN_VERSION_base(4,16,0)
let !b1_1 = indexWord8Array# a1 off1
!b2_1 = indexWord8Array# a2 off2
+#else
+ let !b1_1 = word8ToWord# (indexWord8Array# a1 off1)
+ !b2_1 = word8ToWord# (indexWord8Array# a2 off2)
+#endif
in case b1_1 of
0xC0## -> case b2_1 of
0xC0## -> go (off1 +# 1#) (off2 +# 1#)
+#if !MIN_VERSION_base(4,16,0)
_ -> case indexWord8Array# a1 (off1 +# 1#) of
+#else
+ _ -> case word8ToWord# (indexWord8Array# a1 (off1 +# 1#)) of
+#endif
0x80## -> LT
_ -> go (off1 +# 1#) (off2 +# 1#)
_ -> case b2_1 of
+#if !MIN_VERSION_base(4,16,0)
0xC0## -> case indexWord8Array# a2 (off2 +# 1#) of
+#else
+ 0xC0## -> case word8ToWord# (indexWord8Array# a2 (off2 +# 1#)) of
+#endif
0x80## -> GT
_ -> go (off1 +# 1#) (off2 +# 1#)
_ | isTrue# (b1_1 `gtWord#` b2_1) -> GT
@@ -218,10 +241,10 @@ countUTF8Chars (SBS ba) = go 0# 0#
(# _, nBytes# #) -> go (i# +# nBytes#) (n# +# 1#)
{-# INLINE utf8EncodeChar #-}
-utf8EncodeChar :: (Int# -> Word# -> State# s -> State# s)
+utf8EncodeChar :: (Int# -> Word8# -> State# s -> State# s)
-> Char -> ST s Int
utf8EncodeChar write# c =
- let x = ord c in
+ let x = fromIntegral (ord c) in
case () of
_ | x > 0 && x <= 0x007f -> do
write 0 x
@@ -245,15 +268,24 @@ utf8EncodeChar write# c =
return 4
where
{-# INLINE write #-}
- write (I# off#) (I# c#) = ST $ \s ->
- case write# off# (int2Word# c#) s of
+ write (I# off#) (W# c#) = ST $ \s ->
+#if !MIN_VERSION_base(4,16,0)
+ case write# off# (narrowWord8# c#) s of
+#else
+ case write# off# (wordToWord8# c#) s of
+#endif
s -> (# s, () #)
utf8EncodeString :: Ptr Word8 -> String -> IO ()
utf8EncodeString (Ptr a#) str = go a# str
where go !_ [] = return ()
go a# (c:cs) = do
+#if !MIN_VERSION_base(4,16,0)
+ -- writeWord8OffAddr# was taking a Word#
+ I# off# <- stToIO $ utf8EncodeChar (\i w -> writeWord8OffAddr# a# i (extendWord8# w)) c
+#else
I# off# <- stToIO $ utf8EncodeChar (writeWord8OffAddr# a#) c
+#endif
go (a# `plusAddr#` off#) cs
utf8EncodeShortByteString :: String -> IO ShortByteString
@@ -267,7 +299,12 @@ utf8EncodeShortByteString str = IO $ \s ->
where
go _ _ [] = return ()
go mba# i# (c:cs) = do
+#if !MIN_VERSION_base(4,16,0)
+ -- writeWord8Array# was taking a Word#
+ I# off# <- utf8EncodeChar (\j# w -> writeWord8Array# mba# (i# +# j#) (extendWord8# w)) c
+#else
I# off# <- utf8EncodeChar (\j# -> writeWord8Array# mba# (i# +# j#)) c
+#endif
go mba# (i# +# off#) cs
utf8EncodedLength :: String -> Int
diff --git a/libraries/ghc-heap/tests/tso_and_stack_closures.hs b/libraries/ghc-heap/tests/tso_and_stack_closures.hs
index 42e871bb1f..313076f890 100644
--- a/libraries/ghc-heap/tests/tso_and_stack_closures.hs
+++ b/libraries/ghc-heap/tests/tso_and_stack_closures.hs
@@ -133,7 +133,7 @@ createAndUnpackTSOAndSTACKClosure = do
in (# s', MBA mba# #)
forM_ [0..heapRepSize-1] $ \i@(I# i#) -> do
W8# w <- peekElemOff ptrHeapRep i
- IO (\s -> (# writeWord8Array# mutHeapRepBA i# (extendWord8# w) s, () #))
+ IO (\s -> (# writeWord8Array# mutHeapRepBA i# w s, () #))
BA heapRep <- IO $ \s -> let
(# s', ba# #) = unsafeFreezeByteArray# mutHeapRepBA s
in (# s', BA ba# #)
diff --git a/libraries/ghc-prim/changelog.md b/libraries/ghc-prim/changelog.md
index a4465684d6..6c7723068f 100644
--- a/libraries/ghc-prim/changelog.md
+++ b/libraries/ghc-prim/changelog.md
@@ -1,3 +1,21 @@
+## 0.8.0 (edit as necessary)
+
+- Change array access primops to use type with size maxing the element size:
+
+ - `index{Int,Word}<N>Array# :: ByteArray# -> Int# -> {Int,Word}<N>#`
+ - `indexWord8ArrayAs{Int,Word}<N># :: ByteArray# -> Int# -> {Int,Word}<N>#`
+ - `read{Int,Word}<N>Array# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, {Int,Word}<N># #)`
+ - `write{Int,Word}<N>Array# :: MutableByteArray# s -> Int# -> {Int,Word}<N># -> State# s -> State# s`
+ - `readWord8ArrayAs{Int,Word}<N># :: MutableByteArray# s -> Int# -> State# s -> (# State# s, {Int,Word}<N># #)`
+ - `writeWord8ArrayAs{Int,Word}<N># :: MutableByteArray# s -> Int# -> {Int,Word}<N># -> State# s -> State# s`
+
+ This was already the for the 64-bit access primops, but not the smaller ones.
+
+- Rename some numeric prim type conversion primops:
+
+ - `extend{Int,Word}<N>#` -> `extend<N>To{Int,Word}#`
+ - `narrow{Int,Word}<N>#` -> `intTo{Int,Word}<N>#`
+
## 0.7.0 (edit as necessary)
- Shipped with GHC 9.0.1
diff --git a/libraries/ghci/GHCi/BreakArray.hs b/libraries/ghci/GHCi/BreakArray.hs
index 05d13bda67..18c1d96b30 100644
--- a/libraries/ghci/GHCi/BreakArray.hs
+++ b/libraries/ghci/GHCi/BreakArray.hs
@@ -32,20 +32,10 @@ import Control.Monad
import Data.Word
import GHC.Word
-import GHC.Exts hiding (extendWord8#, narrowWord8#)
+import GHC.Exts
import GHC.IO ( IO(..) )
import System.IO.Unsafe ( unsafeDupablePerformIO )
-#if MIN_VERSION_base(4,16,0)
-import GHC.Base (extendWord8#, narrowWord8#)
-#else
-narrowWord8#, extendWord8# :: Word# -> Word#
-narrowWord8# w = w
-extendWord8# w = w
-{-# INLINE narrowWord8# #-}
-{-# INLINE extendWord8# #-}
-#endif
-
data BreakArray = BA (MutableByteArray# RealWorld)
breakOff, breakOn :: Word8
@@ -104,22 +94,22 @@ newBreakArray :: Int -> IO BreakArray
newBreakArray entries@(I# sz) = do
BA array <- allocBA entries
case breakOff of
- W8# off -> do
+ off -> do
let loop n | isTrue# (n ==# sz) = return ()
- | otherwise = do writeBA# array n (extendWord8# off); loop (n +# 1#)
+ | otherwise = do writeBA# array n off; loop (n +# 1#)
loop 0#
return $ BA array
-writeBA# :: MutableByteArray# RealWorld -> Int# -> Word# -> IO ()
-writeBA# array i word = IO $ \s ->
- case writeWord8Array# array i word s of { s -> (# s, () #) }
+writeBA# :: MutableByteArray# RealWorld -> Int# -> Word8 -> IO ()
+writeBA# array i (W8# w) = IO $ \s ->
+ case writeWord8Array# array i w s of { s -> (# s, () #) }
writeBreakArray :: BreakArray -> Int -> Word8 -> IO ()
-writeBreakArray (BA array) (I# i) (W8# word) = writeBA# array i (extendWord8# word)
+writeBreakArray (BA array) (I# i) word = writeBA# array i word
readBA# :: MutableByteArray# RealWorld -> Int# -> IO Word8
readBA# array i = IO $ \s ->
- case readWord8Array# array i s of { (# s, c #) -> (# s, W8# (narrowWord8# c) #) }
+ case readWord8Array# array i s of { (# s, c #) -> (# s, W8# c #) }
readBreakArray :: BreakArray -> Int -> IO Word8
readBreakArray (BA array) (I# i) = readBA# array i
diff --git a/libraries/text b/libraries/text
-Subproject f1a2e141a79ebc0a57ab2d641db00cef3ff60a4
+Subproject 3ed977de30e9fb74af33ce9ea4efa4a284c17bd
diff --git a/testsuite/tests/array/should_run/arr020.hs b/testsuite/tests/array/should_run/arr020.hs
index db715b054e..0dacf78216 100644
--- a/testsuite/tests/array/should_run/arr020.hs
+++ b/testsuite/tests/array/should_run/arr020.hs
@@ -20,12 +20,12 @@ newByteArray (I# n#)
writeByteArray :: MutableByteArray s -> Int -> Word32 -> ST s ()
writeByteArray (MutableByteArray mba#) (I# i#) (W32# w#)
- = ST $ \s# -> case writeWord32Array# mba# i# (extendWord32# w#) s# of
+ = ST $ \s# -> case writeWord32Array# mba# i# w# s# of
s'# -> (# s'#, () #)
indexArray :: ByteArray Word32 -> Int -> Word32
indexArray (ByteArray arr#) (I# i#)
- = W32# (narrowWord32# (indexWord32Array# arr# i#))
+ = W32# (indexWord32Array# arr# i#)
unsafeFreezeByteArray :: MutableByteArray s -> ST s (ByteArray e)
unsafeFreezeByteArray (MutableByteArray mba#)
diff --git a/testsuite/tests/cmm/opt/T18141.hs b/testsuite/tests/cmm/opt/T18141.hs
index 9f2c2a79c7..f324f4f6f0 100644
--- a/testsuite/tests/cmm/opt/T18141.hs
+++ b/testsuite/tests/cmm/opt/T18141.hs
@@ -12,6 +12,6 @@ x# `divInt8#` y#
((x# `plusInt8#` one#) `quotInt8#` y#) `subInt8#` one#
| otherwise = x# `quotInt8#` y#
where
- zero# = narrowInt8# 0#
- one# = narrowInt8# 1#
+ zero# = intToInt8# 0#
+ one# = intToInt8# 1#
diff --git a/testsuite/tests/codeGen/should_compile/T18614.hs b/testsuite/tests/codeGen/should_compile/T18614.hs
index ae055e3cfd..f1d80d8409 100644
--- a/testsuite/tests/codeGen/should_compile/T18614.hs
+++ b/testsuite/tests/codeGen/should_compile/T18614.hs
@@ -8,4 +8,4 @@ import GHC.Exts
main = pure ()
test :: Word8# -> Word8#
-test x = x `plusWord8#` narrowWord8# 1##
+test x = x `plusWord8#` wordToWord8# 1##
diff --git a/testsuite/tests/codeGen/should_compile/cg006.hs b/testsuite/tests/codeGen/should_compile/cg006.hs
index 494b37937b..4ae3f5a2e9 100644
--- a/testsuite/tests/codeGen/should_compile/cg006.hs
+++ b/testsuite/tests/codeGen/should_compile/cg006.hs
@@ -5,4 +5,4 @@ module ShouldCompile where
import GHC.Base
class Unboxable a where
writeUnboxable :: MutableByteArray# RealWorld -> a -> State# RealWorld -> State# RealWorld
- writeUnboxable arr a s = writeInt8Array# arr 0# (getTag 0) s
+ writeUnboxable arr a s = writeInt8Array# arr 0# (intToInt8# (getTag 0)) s
diff --git a/testsuite/tests/codeGen/should_run/T2080.hs b/testsuite/tests/codeGen/should_run/T2080.hs
index 924e77a30f..8645d510e3 100644
--- a/testsuite/tests/codeGen/should_run/T2080.hs
+++ b/testsuite/tests/codeGen/should_run/T2080.hs
@@ -10,7 +10,7 @@ utf8DecodeChar# :: Addr# -> Bool -> Bool
{-# NOINLINE utf8DecodeChar# #-}
utf8DecodeChar# a# fred =
case () of
- _ | isTrue# (word2Int# (indexWord8OffAddr# a# 0#) <=# 0x7F#) -> True
+ _ | isTrue# (word2Int# (word8ToWord# (indexWord8OffAddr# a# 0#)) <=# 0x7F#) -> True
-- Omitting the next line gives an ASSERT error:
-- ghc-6.9: panic! (the 'impossible' happened)
diff --git a/testsuite/tests/codeGen/should_run/cgrun070.hs b/testsuite/tests/codeGen/should_run/cgrun070.hs
index 53f640116f..d37032a707 100644
--- a/testsuite/tests/codeGen/should_run/cgrun070.hs
+++ b/testsuite/tests/codeGen/should_run/cgrun070.hs
@@ -196,11 +196,11 @@ touch a = unsafeIOToST $ IO $ \s# ->
indexWord8Array :: ByteArray -> Int -> Word8
indexWord8Array arr (I# i#) = case indexWord8Array# (unBA arr) i# of
- a -> W8# (narrowWord8# a)
+ a -> W8# a
writeWord8Array :: MByteArray s -> Int -> Word8 -> ST s ()
writeWord8Array marr (I# i#) (W8# a) = ST $ \ s# ->
- case writeWord8Array# (unMBA marr) i# (extendWord8# a) s# of
+ case writeWord8Array# (unMBA marr) i# a s# of
s2# -> (# s2#, () #)
unsafeFreezeByteArray :: MByteArray s -> ST s (ByteArray)
diff --git a/testsuite/tests/codeGen/should_run/cgrun072.hs b/testsuite/tests/codeGen/should_run/cgrun072.hs
index fb1b26252f..b97ce56d01 100644
--- a/testsuite/tests/codeGen/should_run/cgrun072.hs
+++ b/testsuite/tests/codeGen/should_run/cgrun072.hs
@@ -31,10 +31,10 @@ main = do putStrLn test_primop_bSwap16
putStrLn test'_base_bSwap64
bswap16 :: Word16 -> Word16
-bswap16 (W16# w#) = W16# (narrowWord16# (byteSwap16# (extendWord16# w#)))
+bswap16 (W16# w#) = W16# (wordToWord16# (byteSwap16# (word16ToWord# w#)))
bswap32 :: Word32 -> Word32
-bswap32 (W32# w#) = W32# (narrowWord32# (byteSwap32# (extendWord32# w#)))
+bswap32 (W32# w#) = W32# (wordToWord32# (byteSwap32# (word32ToWord# w#)))
bswap64 :: Word64 -> Word64
bswap64 (W64# w#) = W64# (byteSwap64# w#)
diff --git a/testsuite/tests/codeGen/should_run/cgrun075.hs b/testsuite/tests/codeGen/should_run/cgrun075.hs
index 89a4679e5f..5babde1254 100644
--- a/testsuite/tests/codeGen/should_run/cgrun075.hs
+++ b/testsuite/tests/codeGen/should_run/cgrun075.hs
@@ -27,13 +27,13 @@ instance Pdep Word where
pdep (W# src#) (W# mask#) = W# (pdep# src# mask#)
instance Pdep Word8 where
- pdep (W8# src#) (W8# mask#) = W8# (narrowWord8# (pdep8# (extendWord8# src#) (extendWord8# mask#)))
+ pdep (W8# src#) (W8# mask#) = W8# (wordToWord8# (pdep8# (word8ToWord# src#) (word8ToWord# mask#)))
instance Pdep Word16 where
- pdep (W16# src#) (W16# mask#) = W16# (narrowWord16# (pdep16# (extendWord16# src#) (extendWord16# mask#)))
+ pdep (W16# src#) (W16# mask#) = W16# (wordToWord16# (pdep16# (word16ToWord# src#) (word16ToWord# mask#)))
instance Pdep Word32 where
- pdep (W32# src#) (W32# mask#) = W32# (narrowWord32# (pdep32# (extendWord32# src#) (extendWord32# mask#)))
+ pdep (W32# src#) (W32# mask#) = W32# (wordToWord32# (pdep32# (word32ToWord# src#) (word32ToWord# mask#)))
instance Pdep Word64 where
pdep (W64# src#) (W64# mask#) = W64# (pdep64# src# mask#)
diff --git a/testsuite/tests/codeGen/should_run/cgrun076.hs b/testsuite/tests/codeGen/should_run/cgrun076.hs
index a6ae331cf6..4779b5beb8 100644
--- a/testsuite/tests/codeGen/should_run/cgrun076.hs
+++ b/testsuite/tests/codeGen/should_run/cgrun076.hs
@@ -27,13 +27,13 @@ instance Pext Word where
pext (W# src#) (W# mask#) = W# (pext# src# mask#)
instance Pext Word8 where
- pext (W8# src#) (W8# mask#) = W8# (narrowWord8# (pext8# (extendWord8# src#) (extendWord8# mask#)))
+ pext (W8# src#) (W8# mask#) = W8# (wordToWord8# (pext8# (word8ToWord# src#) (word8ToWord# mask#)))
instance Pext Word16 where
- pext (W16# src#) (W16# mask#) = W16# (narrowWord16# (pext16# (extendWord16# src#) (extendWord16# mask#)))
+ pext (W16# src#) (W16# mask#) = W16# (wordToWord16# (pext16# (word16ToWord# src#) (word16ToWord# mask#)))
instance Pext Word32 where
- pext (W32# src#) (W32# mask#) = W32# (narrowWord32# (pext32# (extendWord32# src#) (extendWord32# mask#)))
+ pext (W32# src#) (W32# mask#) = W32# (wordToWord32# (pext32# (word32ToWord# src#) (word32ToWord# mask#)))
instance Pext Word64 where
pext (W64# src#) (W64# mask#) = W64# (pext64# src# mask#)
diff --git a/testsuite/tests/codeGen/should_run/compareByteArrays.hs b/testsuite/tests/codeGen/should_run/compareByteArrays.hs
index e155bc45a5..5bd0e58588 100644
--- a/testsuite/tests/codeGen/should_run/compareByteArrays.hs
+++ b/testsuite/tests/codeGen/should_run/compareByteArrays.hs
@@ -39,7 +39,7 @@ copyByteArray (BA# src#) (I# srcOfs#) (MBA# dest#) (I# destOfs#) (I# n#)
indexWord8Array :: BA -> Int -> Word8
indexWord8Array (BA# ba#) (I# i#)
- = W8# (narrowWord8# (indexWord8Array# ba# i#))
+ = W8# (indexWord8Array# ba# i#)
sizeofByteArray :: BA -> Int
sizeofByteArray (BA# ba#) = I# (sizeofByteArray# ba#)
@@ -54,7 +54,7 @@ newByteArray (I# n#)
writeWord8Array :: MBA s -> Int -> Word8 -> ST s ()
writeWord8Array (MBA# mba#) (I# i#) (W8# j#)
- = ST $ \s -> case writeWord8Array# mba# i# (extendWord8# j#) s of
+ = ST $ \s -> case writeWord8Array# mba# i# j# s of
s' -> (# s', () #)
unsafeFreezeByteArray :: MBA s -> ST s BA
diff --git a/testsuite/tests/ffi/should_run/PrimFFIInt16.hs b/testsuite/tests/ffi/should_run/PrimFFIInt16.hs
index 6d4eae328f..7d7737e592 100644
--- a/testsuite/tests/ffi/should_run/PrimFFIInt16.hs
+++ b/testsuite/tests/ffi/should_run/PrimFFIInt16.hs
@@ -14,15 +14,15 @@ foreign import ccall "add_all_int16"
main :: IO ()
main = do
- let a = narrowInt16# 0#
- b = narrowInt16# 1#
- c = narrowInt16# 2#
- d = narrowInt16# 3#
- e = narrowInt16# 4#
- f = narrowInt16# 5#
- g = narrowInt16# 6#
- h = narrowInt16# 7#
- i = narrowInt16# 8#
- j = narrowInt16# 9#
- x = I# (extendInt16# (add_all_int16 a b c d e f g h i j))
+ let a = intToInt16# 0#
+ b = intToInt16# 1#
+ c = intToInt16# 2#
+ d = intToInt16# 3#
+ e = intToInt16# 4#
+ f = intToInt16# 5#
+ g = intToInt16# 6#
+ h = intToInt16# 7#
+ i = intToInt16# 8#
+ j = intToInt16# 9#
+ x = I# (int16ToInt# (add_all_int16 a b c d e f g h i j))
print x
diff --git a/testsuite/tests/ffi/should_run/PrimFFIInt32.hs b/testsuite/tests/ffi/should_run/PrimFFIInt32.hs
index 511e3cec10..7ece989ea2 100644
--- a/testsuite/tests/ffi/should_run/PrimFFIInt32.hs
+++ b/testsuite/tests/ffi/should_run/PrimFFIInt32.hs
@@ -14,15 +14,15 @@ foreign import ccall "add_all_int32"
main :: IO ()
main = do
- let a = narrowInt32# 0#
- b = narrowInt32# 1#
- c = narrowInt32# 2#
- d = narrowInt32# 3#
- e = narrowInt32# 4#
- f = narrowInt32# 5#
- g = narrowInt32# 6#
- h = narrowInt32# 7#
- i = narrowInt32# 8#
- j = narrowInt32# 9#
- x = I# (extendInt32# (add_all_int32 a b c d e f g h i j))
+ let a = intToInt32# 0#
+ b = intToInt32# 1#
+ c = intToInt32# 2#
+ d = intToInt32# 3#
+ e = intToInt32# 4#
+ f = intToInt32# 5#
+ g = intToInt32# 6#
+ h = intToInt32# 7#
+ i = intToInt32# 8#
+ j = intToInt32# 9#
+ x = I# (int32ToInt# (add_all_int32 a b c d e f g h i j))
print x
diff --git a/testsuite/tests/ffi/should_run/PrimFFIInt8.hs b/testsuite/tests/ffi/should_run/PrimFFIInt8.hs
index 4124e074aa..f0ce283388 100644
--- a/testsuite/tests/ffi/should_run/PrimFFIInt8.hs
+++ b/testsuite/tests/ffi/should_run/PrimFFIInt8.hs
@@ -14,15 +14,15 @@ foreign import ccall "add_all_int8"
main :: IO ()
main = do
- let a = narrowInt8# 0#
- b = narrowInt8# 1#
- c = narrowInt8# 2#
- d = narrowInt8# 3#
- e = narrowInt8# 4#
- f = narrowInt8# 5#
- g = narrowInt8# 6#
- h = narrowInt8# 7#
- i = narrowInt8# 8#
- j = narrowInt8# 9#
- x = I# (extendInt8# (add_all_int8 a b c d e f g h i j))
+ let a = intToInt8# 0#
+ b = intToInt8# 1#
+ c = intToInt8# 2#
+ d = intToInt8# 3#
+ e = intToInt8# 4#
+ f = intToInt8# 5#
+ g = intToInt8# 6#
+ h = intToInt8# 7#
+ i = intToInt8# 8#
+ j = intToInt8# 9#
+ x = I# (int8ToInt# (add_all_int8 a b c d e f g h i j))
print x
diff --git a/testsuite/tests/ffi/should_run/PrimFFIWord16.hs b/testsuite/tests/ffi/should_run/PrimFFIWord16.hs
index 0d801433cf..30f4e2f8d8 100644
--- a/testsuite/tests/ffi/should_run/PrimFFIWord16.hs
+++ b/testsuite/tests/ffi/should_run/PrimFFIWord16.hs
@@ -14,15 +14,15 @@ foreign import ccall "add_all_word16"
main :: IO ()
main = do
- let a = narrowWord16# 0##
- b = narrowWord16# 1##
- c = narrowWord16# 2##
- d = narrowWord16# 3##
- e = narrowWord16# 4##
- f = narrowWord16# 5##
- g = narrowWord16# 6##
- h = narrowWord16# 7##
- i = narrowWord16# 8##
- j = narrowWord16# 9##
- x = W# (extendWord16# (add_all_word16 a b c d e f g h i j))
+ let a = wordToWord16# 0##
+ b = wordToWord16# 1##
+ c = wordToWord16# 2##
+ d = wordToWord16# 3##
+ e = wordToWord16# 4##
+ f = wordToWord16# 5##
+ g = wordToWord16# 6##
+ h = wordToWord16# 7##
+ i = wordToWord16# 8##
+ j = wordToWord16# 9##
+ x = W# (word16ToWord# (add_all_word16 a b c d e f g h i j))
print x
diff --git a/testsuite/tests/ffi/should_run/PrimFFIWord32.hs b/testsuite/tests/ffi/should_run/PrimFFIWord32.hs
index 996bae1b61..b20702cd2b 100644
--- a/testsuite/tests/ffi/should_run/PrimFFIWord32.hs
+++ b/testsuite/tests/ffi/should_run/PrimFFIWord32.hs
@@ -14,15 +14,15 @@ foreign import ccall "add_all_word32"
main :: IO ()
main = do
- let a = narrowWord32# 0##
- b = narrowWord32# 1##
- c = narrowWord32# 2##
- d = narrowWord32# 3##
- e = narrowWord32# 4##
- f = narrowWord32# 5##
- g = narrowWord32# 6##
- h = narrowWord32# 7##
- i = narrowWord32# 8##
- j = narrowWord32# 9##
- x = W# (extendWord32# (add_all_word32 a b c d e f g h i j))
+ let a = wordToWord32# 0##
+ b = wordToWord32# 1##
+ c = wordToWord32# 2##
+ d = wordToWord32# 3##
+ e = wordToWord32# 4##
+ f = wordToWord32# 5##
+ g = wordToWord32# 6##
+ h = wordToWord32# 7##
+ i = wordToWord32# 8##
+ j = wordToWord32# 9##
+ x = W# (word32ToWord# (add_all_word32 a b c d e f g h i j))
print x
diff --git a/testsuite/tests/ffi/should_run/PrimFFIWord8.hs b/testsuite/tests/ffi/should_run/PrimFFIWord8.hs
index 87e46636d1..bf8717ec7f 100644
--- a/testsuite/tests/ffi/should_run/PrimFFIWord8.hs
+++ b/testsuite/tests/ffi/should_run/PrimFFIWord8.hs
@@ -14,15 +14,15 @@ foreign import ccall "add_all_word8"
main :: IO ()
main = do
- let a = narrowWord8# 0##
- b = narrowWord8# 1##
- c = narrowWord8# 2##
- d = narrowWord8# 3##
- e = narrowWord8# 4##
- f = narrowWord8# 5##
- g = narrowWord8# 6##
- h = narrowWord8# 7##
- i = narrowWord8# 8##
- j = narrowWord8# 9##
- x = W# (extendWord8# (add_all_word8 a b c d e f g h i j))
+ let a = wordToWord8# 0##
+ b = wordToWord8# 1##
+ c = wordToWord8# 2##
+ d = wordToWord8# 3##
+ e = wordToWord8# 4##
+ f = wordToWord8# 5##
+ g = wordToWord8# 6##
+ h = wordToWord8# 7##
+ i = wordToWord8# 8##
+ j = wordToWord8# 9##
+ x = W# (word8ToWord# (add_all_word8 a b c d e f g h i j))
print x
diff --git a/testsuite/tests/ffi/should_run/T16650a.hs b/testsuite/tests/ffi/should_run/T16650a.hs
index 6a43a55118..3424a2c4f2 100644
--- a/testsuite/tests/ffi/should_run/T16650a.hs
+++ b/testsuite/tests/ffi/should_run/T16650a.hs
@@ -38,10 +38,11 @@ box (MutableByteArray x) = Box (unsafeCoerce# x)
luckySingleton :: IO MutableByteArray
luckySingleton = IO $ \s0 -> case newByteArray# 1# s0 of
- (# s1, marr# #) -> case writeWord8Array# marr# 0# 42## s1 of
+ (# s1, marr# #) -> case writeWord8Array# marr# 0# fortyTwo s1 of
s2 -> (# s2, MutableByteArray marr# #)
+ where W8# fortyTwo = 42
readByteArray :: MutableByteArray -> Int -> IO Word8
readByteArray (MutableByteArray b#) (I# i#) = IO $ \s0 ->
case readWord8Array# b# i# s0 of
- (# s1, w #) -> (# s1, W8# (narrowWord8# w) #)
+ (# s1, w #) -> (# s1, W8# w #)
diff --git a/testsuite/tests/ffi/should_run/T16650b.hs b/testsuite/tests/ffi/should_run/T16650b.hs
index ba0d4a72a0..06ffcb1d5e 100644
--- a/testsuite/tests/ffi/should_run/T16650b.hs
+++ b/testsuite/tests/ffi/should_run/T16650b.hs
@@ -47,13 +47,14 @@ box (MutableByteArrays x) = Box (unsafeCoerce# x)
luckySingleton :: IO MutableByteArray
luckySingleton = IO $ \s0 -> case newByteArray# 1# s0 of
- (# s1, marr# #) -> case writeWord8Array# marr# 0# 42## s1 of
+ (# s1, marr# #) -> case writeWord8Array# marr# 0# fortyTwo s1 of
s2 -> (# s2, MutableByteArray marr# #)
+ where W8# fortyTwo = 42
readByteArray :: MutableByteArray -> Int -> IO Word8
readByteArray (MutableByteArray b#) (I# i#) = IO $ \s0 ->
case readWord8Array# b# i# s0 of
- (# s1, w #) -> (# s1, W8# (narrowWord8# w) #)
+ (# s1, w #) -> (# s1, W8# w #)
-- Write a mutable byte array to the array of mutable byte arrays
-- at the given index.
diff --git a/testsuite/tests/ffi/should_run/UnliftedNewtypesByteArrayOffset.hs b/testsuite/tests/ffi/should_run/UnliftedNewtypesByteArrayOffset.hs
index 8953e9b02d..02a2c55c91 100644
--- a/testsuite/tests/ffi/should_run/UnliftedNewtypesByteArrayOffset.hs
+++ b/testsuite/tests/ffi/should_run/UnliftedNewtypesByteArrayOffset.hs
@@ -35,11 +35,12 @@ main = do
readByteArray :: MutableByteArray -> Int -> IO Word8
readByteArray (MutableByteArray b#) (I# i#) = IO $ \s0 ->
case readWord8Array# b# i# s0 of
- (# s1, w #) -> (# s1, W8# (narrowWord8# w) #)
+ (# s1, w #) -> (# s1, W8# w #)
-- Create a new mutable byte array of length 1 with the sole byte
-- set to the 105.
luckySingleton :: IO MutableByteArray
luckySingleton = IO $ \s0 -> case newByteArray# 1# s0 of
- (# s1, marr# #) -> case writeWord8Array# marr# 0# 105## s1 of
+ (# s1, marr# #) -> case writeWord8Array# marr# 0# lit105 s1 of
s2 -> (# s2, MutableByteArray marr# #)
+ where W8# lit105 = 105
diff --git a/testsuite/tests/lib/integer/integerImportExport.hs b/testsuite/tests/lib/integer/integerImportExport.hs
index ab044214ed..bef208afd0 100644
--- a/testsuite/tests/lib/integer/integerImportExport.hs
+++ b/testsuite/tests/lib/integer/integerImportExport.hs
@@ -33,13 +33,13 @@ newByteArray :: Word# -> IO MBA
newByteArray sz = IO $ \s -> case newPinnedByteArray# (word2Int# sz) s of (# s, arr #) -> (# s, MBA arr #)
indexByteArray :: ByteArray# -> Word# -> Word8
-indexByteArray a# n# = W8# (narrowWord8# (indexWord8Array# a# (word2Int# n#)))
+indexByteArray a# n# = W8# (indexWord8Array# a# (word2Int# n#))
-- indexMutableByteArray :: MutableByteArray# RealWorld -> Word# -> IO Word8
-- indexMutableByteArray a# n# = IO $ \s -> case readWord8Array# a# (word2Int# n#) s of (# s', v #) -> (# s', W# v #)
writeByteArray :: MutableByteArray# RealWorld -> Int# -> Word8 -> IO ()
-writeByteArray arr i (W8# w) = IO $ \s -> case writeWord8Array# arr i (extendWord8# w) s of s -> (# s, () #)
+writeByteArray arr i (W8# w) = IO $ \s -> case writeWord8Array# arr i w s of s -> (# s, () #)
lengthByteArray :: ByteArray# -> Word
lengthByteArray ba = W# (int2Word# (sizeofByteArray# ba))
diff --git a/testsuite/tests/numeric/should_compile/T16402.stderr-ws-32 b/testsuite/tests/numeric/should_compile/T16402.stderr-ws-32
index 726bcc374e..4f6746b670 100644
--- a/testsuite/tests/numeric/should_compile/T16402.stderr-ws-32
+++ b/testsuite/tests/numeric/should_compile/T16402.stderr-ws-32
@@ -73,7 +73,7 @@ smallInt_bar
{ (# ds1, ds2 #) ->
case {__pkg_ccall ghc-prim Int#
-> State# RealWorld -> (# State# RealWorld, Int64# #)}
- (extendInt16# (narrowInt16# ds2)) realWorld#
+ (int16ToInt# (intToInt16# ds2)) realWorld#
of
{ (# ds4, ds5 #) ->
I64# ds5
@@ -111,7 +111,7 @@ $wsmallInt_foo
{ (# ds1, ds11 #) ->
case {__pkg_ccall ghc-prim Int#
-> State# RealWorld -> (# State# RealWorld, Int64# #)}
- (extendInt16# (narrowInt16# ds11)) realWorld#
+ (int16ToInt# (intToInt16# ds11)) realWorld#
of
{ (# ds12, ds13 #) ->
ds13
diff --git a/testsuite/tests/numeric/should_compile/T16402.stderr-ws-64 b/testsuite/tests/numeric/should_compile/T16402.stderr-ws-64
index d81adaaa7b..6828811655 100644
--- a/testsuite/tests/numeric/should_compile/T16402.stderr-ws-64
+++ b/testsuite/tests/numeric/should_compile/T16402.stderr-ws-64
@@ -28,7 +28,7 @@ smallWord_foo = smallWord_bar
-- RHS size: {terms: 8, types: 3, coercions: 0, joins: 0/0}
smallInt_bar
= \ x ->
- case x of { I64# x# -> I64# (extendInt16# (narrowInt16# x#)) }
+ case x of { I64# x# -> I64# (int16ToInt# (intToInt16# x#)) }
-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
smallInt_foo = smallInt_bar
diff --git a/testsuite/tests/parser/should_run/BinaryLiterals2.hs b/testsuite/tests/parser/should_run/BinaryLiterals2.hs
index 305a12cab3..e3e2a73d33 100644
--- a/testsuite/tests/parser/should_run/BinaryLiterals2.hs
+++ b/testsuite/tests/parser/should_run/BinaryLiterals2.hs
@@ -27,4 +27,4 @@ main = do
, -0B11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
]
- print [ I8# (narrowInt8# -0B10000000#), I8# (narrowInt8# 0B1111111#) ]
+ print [ I8# (intToInt8# -0B10000000#), I8# (intToInt8# 0B1111111#) ]
diff --git a/testsuite/tests/primops/should_run/ArithInt16.hs b/testsuite/tests/primops/should_run/ArithInt16.hs
index 0f09e0b4fb..373a61ccd8 100644
--- a/testsuite/tests/primops/should_run/ArithInt16.hs
+++ b/testsuite/tests/primops/should_run/ArithInt16.hs
@@ -146,32 +146,32 @@ addMany (I# a) (I# b) (I# c) (I# d)
(I# e) (I# f) (I# g) (I# h)
(I# i) (I# j) (I# k) (I# l)
(I# m) (I# n) (I# o) (I# p)
- = I# (extendInt16# int16)
+ = I# (int16ToInt# int16)
where
!int16 = addMany#
- (narrowInt16# a) (narrowInt16# b) (narrowInt16# c) (narrowInt16# d)
- (narrowInt16# e) (narrowInt16# f) (narrowInt16# g) (narrowInt16# h)
- (narrowInt16# i) (narrowInt16# j) (narrowInt16# k) (narrowInt16# l)
- (narrowInt16# m) (narrowInt16# n) (narrowInt16# o) (narrowInt16# p)
+ (intToInt16# a) (intToInt16# b) (intToInt16# c) (intToInt16# d)
+ (intToInt16# e) (intToInt16# f) (intToInt16# g) (intToInt16# h)
+ (intToInt16# i) (intToInt16# j) (intToInt16# k) (intToInt16# l)
+ (intToInt16# m) (intToInt16# n) (intToInt16# o) (intToInt16# p)
{-# NOINLINE addMany #-}
-- Convenient and also tests higher order functions on Int16#
apply1 :: (Int16# -> Int16#) -> Int -> Int
-apply1 opToTest (I# a) = I# (extendInt16# (opToTest (narrowInt16# a)))
+apply1 opToTest (I# a) = I# (int16ToInt# (opToTest (intToInt16# a)))
{-# NOINLINE apply1 #-}
apply2 :: (Int16# -> Int16# -> Int16#) -> Int -> Int -> Int
apply2 opToTest (I# a) (I# b) =
- let (# sa, sb #) = (# narrowInt16# a, narrowInt16# b #)
+ let (# sa, sb #) = (# intToInt16# a, intToInt16# b #)
r = opToTest sa sb
- in I# (extendInt16# r)
+ in I# (int16ToInt# r)
{-# NOINLINE apply2 #-}
apply3 :: (Int16# -> Int16# -> (# Int16#, Int16# #)) -> Int -> Int -> (Int, Int)
apply3 opToTest (I# a) (I# b) =
- let (# sa, sb #) = (# narrowInt16# a, narrowInt16# b #)
+ let (# sa, sb #) = (# intToInt16# a, intToInt16# b #)
(# ra, rb #) = opToTest sa sb
- in (I# (extendInt16# ra), I# (extendInt16# rb))
+ in (I# (int16ToInt# ra), I# (int16ToInt# rb))
{-# NOINLINE apply3 #-}
instance
diff --git a/testsuite/tests/primops/should_run/ArithInt32.hs b/testsuite/tests/primops/should_run/ArithInt32.hs
index 13b3bb026e..8d1c6a4ad0 100644
--- a/testsuite/tests/primops/should_run/ArithInt32.hs
+++ b/testsuite/tests/primops/should_run/ArithInt32.hs
@@ -146,32 +146,32 @@ addMany (I# a) (I# b) (I# c) (I# d)
(I# e) (I# f) (I# g) (I# h)
(I# i) (I# j) (I# k) (I# l)
(I# m) (I# n) (I# o) (I# p)
- = I# (extendInt32# int32)
+ = I# (int32ToInt# int32)
where
!int32 = addMany#
- (narrowInt32# a) (narrowInt32# b) (narrowInt32# c) (narrowInt32# d)
- (narrowInt32# e) (narrowInt32# f) (narrowInt32# g) (narrowInt32# h)
- (narrowInt32# i) (narrowInt32# j) (narrowInt32# k) (narrowInt32# l)
- (narrowInt32# m) (narrowInt32# n) (narrowInt32# o) (narrowInt32# p)
+ (intToInt32# a) (intToInt32# b) (intToInt32# c) (intToInt32# d)
+ (intToInt32# e) (intToInt32# f) (intToInt32# g) (intToInt32# h)
+ (intToInt32# i) (intToInt32# j) (intToInt32# k) (intToInt32# l)
+ (intToInt32# m) (intToInt32# n) (intToInt32# o) (intToInt32# p)
{-# NOINLINE addMany #-}
-- Convenient and also tests higher order functions on Int32#
apply1 :: (Int32# -> Int32#) -> Int -> Int
-apply1 opToTest (I# a) = I# (extendInt32# (opToTest (narrowInt32# a)))
+apply1 opToTest (I# a) = I# (int32ToInt# (opToTest (intToInt32# a)))
{-# NOINLINE apply1 #-}
apply2 :: (Int32# -> Int32# -> Int32#) -> Int -> Int -> Int
apply2 opToTest (I# a) (I# b) =
- let (# sa, sb #) = (# narrowInt32# a, narrowInt32# b #)
+ let (# sa, sb #) = (# intToInt32# a, intToInt32# b #)
r = opToTest sa sb
- in I# (extendInt32# r)
+ in I# (int32ToInt# r)
{-# NOINLINE apply2 #-}
apply3 :: (Int32# -> Int32# -> (# Int32#, Int32# #)) -> Int -> Int -> (Int, Int)
apply3 opToTest (I# a) (I# b) =
- let (# sa, sb #) = (# narrowInt32# a, narrowInt32# b #)
+ let (# sa, sb #) = (# intToInt32# a, intToInt32# b #)
(# ra, rb #) = opToTest sa sb
- in (I# (extendInt32# ra), I# (extendInt32# rb))
+ in (I# (int32ToInt# ra), I# (int32ToInt# rb))
{-# NOINLINE apply3 #-}
instance
diff --git a/testsuite/tests/primops/should_run/ArithInt8.hs b/testsuite/tests/primops/should_run/ArithInt8.hs
index 18a472d073..4629772a7d 100644
--- a/testsuite/tests/primops/should_run/ArithInt8.hs
+++ b/testsuite/tests/primops/should_run/ArithInt8.hs
@@ -150,32 +150,32 @@ addMany (I# a) (I# b) (I# c) (I# d)
(I# e) (I# f) (I# g) (I# h)
(I# i) (I# j) (I# k) (I# l)
(I# m) (I# n) (I# o) (I# p)
- = I# (extendInt8# int8)
+ = I# (int8ToInt# int8)
where
!int8 = addMany#
- (narrowInt8# a) (narrowInt8# b) (narrowInt8# c) (narrowInt8# d)
- (narrowInt8# e) (narrowInt8# f) (narrowInt8# g) (narrowInt8# h)
- (narrowInt8# i) (narrowInt8# j) (narrowInt8# k) (narrowInt8# l)
- (narrowInt8# m) (narrowInt8# n) (narrowInt8# o) (narrowInt8# p)
+ (intToInt8# a) (intToInt8# b) (intToInt8# c) (intToInt8# d)
+ (intToInt8# e) (intToInt8# f) (intToInt8# g) (intToInt8# h)
+ (intToInt8# i) (intToInt8# j) (intToInt8# k) (intToInt8# l)
+ (intToInt8# m) (intToInt8# n) (intToInt8# o) (intToInt8# p)
{-# NOINLINE addMany #-}
-- Convenient and also tests higher order functions on Int8#
apply1 :: (Int8# -> Int8#) -> Int -> Int
-apply1 opToTest (I# a) = I# (extendInt8# (opToTest (narrowInt8# a)))
+apply1 opToTest (I# a) = I# (int8ToInt# (opToTest (intToInt8# a)))
{-# NOINLINE apply1 #-}
apply2 :: (Int8# -> Int8# -> Int8#) -> Int -> Int -> Int
apply2 opToTest (I# a) (I# b) =
- let (# sa, sb #) = (# narrowInt8# a, narrowInt8# b #)
+ let (# sa, sb #) = (# intToInt8# a, intToInt8# b #)
r = opToTest sa sb
- in I# (extendInt8# r)
+ in I# (int8ToInt# r)
{-# NOINLINE apply2 #-}
apply3 :: (Int8# -> Int8# -> (# Int8#, Int8# #)) -> Int -> Int -> (Int, Int)
apply3 opToTest (I# a) (I# b) =
- let (# sa, sb #) = (# narrowInt8# a, narrowInt8# b #)
+ let (# sa, sb #) = (# intToInt8# a, intToInt8# b #)
(# ra, rb #) = opToTest sa sb
- in (I# (extendInt8# ra), I# (extendInt8# rb))
+ in (I# (int8ToInt# ra), I# (int8ToInt# rb))
{-# NOINLINE apply3 #-}
instance
diff --git a/testsuite/tests/primops/should_run/ArithWord16.hs b/testsuite/tests/primops/should_run/ArithWord16.hs
index 5870fd4751..cd64614873 100644
--- a/testsuite/tests/primops/should_run/ArithWord16.hs
+++ b/testsuite/tests/primops/should_run/ArithWord16.hs
@@ -141,34 +141,34 @@ addMany (W# a) (W# b) (W# c) (W# d)
(W# e) (W# f) (W# g) (W# h)
(W# i) (W# j) (W# k) (W# l)
(W# m) (W# n) (W# o) (W# p)
- = W# (extendWord16# word16)
+ = W# (word16ToWord# word16)
where
!word16 =
addMany#
- (narrowWord16# a) (narrowWord16# b) (narrowWord16# c) (narrowWord16# d)
- (narrowWord16# e) (narrowWord16# f) (narrowWord16# g) (narrowWord16# h)
- (narrowWord16# i) (narrowWord16# j) (narrowWord16# k) (narrowWord16# l)
- (narrowWord16# m) (narrowWord16# n) (narrowWord16# o) (narrowWord16# p)
+ (wordToWord16# a) (wordToWord16# b) (wordToWord16# c) (wordToWord16# d)
+ (wordToWord16# e) (wordToWord16# f) (wordToWord16# g) (wordToWord16# h)
+ (wordToWord16# i) (wordToWord16# j) (wordToWord16# k) (wordToWord16# l)
+ (wordToWord16# m) (wordToWord16# n) (wordToWord16# o) (wordToWord16# p)
{-# NOINLINE addMany #-}
-- Convenient and also tests higher order functions on Word16#
apply1 :: (Word16# -> Word16#) -> Word -> Word
-apply1 opToTest (W# a) = W# (extendWord16# (opToTest (narrowWord16# a)))
+apply1 opToTest (W# a) = W# (word16ToWord# (opToTest (wordToWord16# a)))
{-# NOINLINE apply1 #-}
apply2 :: (Word16# -> Word16# -> Word16#) -> Word -> Word -> Word
apply2 opToTest (W# a) (W# b) =
- let (# sa, sb #) = (# narrowWord16# a, narrowWord16# b #)
+ let (# sa, sb #) = (# wordToWord16# a, wordToWord16# b #)
r = opToTest sa sb
- in W# (extendWord16# r)
+ in W# (word16ToWord# r)
{-# NOINLINE apply2 #-}
apply3
:: (Word16# -> Word16# -> (# Word16#, Word16# #)) -> Word -> Word -> (Word, Word)
apply3 opToTest (W# a) (W# b) =
- let (# sa, sb #) = (# narrowWord16# a, narrowWord16# b #)
+ let (# sa, sb #) = (# wordToWord16# a, wordToWord16# b #)
(# ra, rb #) = opToTest sa sb
- in (W# (extendWord16# ra), W# (extendWord16# rb))
+ in (W# (word16ToWord# ra), W# (word16ToWord# rb))
{-# NOINLINE apply3 #-}
instance
diff --git a/testsuite/tests/primops/should_run/ArithWord32.hs b/testsuite/tests/primops/should_run/ArithWord32.hs
index 5756732ce0..ad0352435e 100644
--- a/testsuite/tests/primops/should_run/ArithWord32.hs
+++ b/testsuite/tests/primops/should_run/ArithWord32.hs
@@ -141,34 +141,34 @@ addMany (W# a) (W# b) (W# c) (W# d)
(W# e) (W# f) (W# g) (W# h)
(W# i) (W# j) (W# k) (W# l)
(W# m) (W# n) (W# o) (W# p)
- = W# (extendWord32# word32)
+ = W# (word32ToWord# word32)
where
!word32 =
addMany#
- (narrowWord32# a) (narrowWord32# b) (narrowWord32# c) (narrowWord32# d)
- (narrowWord32# e) (narrowWord32# f) (narrowWord32# g) (narrowWord32# h)
- (narrowWord32# i) (narrowWord32# j) (narrowWord32# k) (narrowWord32# l)
- (narrowWord32# m) (narrowWord32# n) (narrowWord32# o) (narrowWord32# p)
+ (wordToWord32# a) (wordToWord32# b) (wordToWord32# c) (wordToWord32# d)
+ (wordToWord32# e) (wordToWord32# f) (wordToWord32# g) (wordToWord32# h)
+ (wordToWord32# i) (wordToWord32# j) (wordToWord32# k) (wordToWord32# l)
+ (wordToWord32# m) (wordToWord32# n) (wordToWord32# o) (wordToWord32# p)
{-# NOINLINE addMany #-}
-- Convenient and also tests higher order functions on Word32#
apply1 :: (Word32# -> Word32#) -> Word -> Word
-apply1 opToTest (W# a) = W# (extendWord32# (opToTest (narrowWord32# a)))
+apply1 opToTest (W# a) = W# (word32ToWord# (opToTest (wordToWord32# a)))
{-# NOINLINE apply1 #-}
apply2 :: (Word32# -> Word32# -> Word32#) -> Word -> Word -> Word
apply2 opToTest (W# a) (W# b) =
- let (# sa, sb #) = (# narrowWord32# a, narrowWord32# b #)
+ let (# sa, sb #) = (# wordToWord32# a, wordToWord32# b #)
r = opToTest sa sb
- in W# (extendWord32# r)
+ in W# (word32ToWord# r)
{-# NOINLINE apply2 #-}
apply3
:: (Word32# -> Word32# -> (# Word32#, Word32# #)) -> Word -> Word -> (Word, Word)
apply3 opToTest (W# a) (W# b) =
- let (# sa, sb #) = (# narrowWord32# a, narrowWord32# b #)
+ let (# sa, sb #) = (# wordToWord32# a, wordToWord32# b #)
(# ra, rb #) = opToTest sa sb
- in (W# (extendWord32# ra), W# (extendWord32# rb))
+ in (W# (word32ToWord# ra), W# (word32ToWord# rb))
{-# NOINLINE apply3 #-}
instance
diff --git a/testsuite/tests/primops/should_run/ArithWord8.hs b/testsuite/tests/primops/should_run/ArithWord8.hs
index b25d2b0e6f..6fea314bb2 100644
--- a/testsuite/tests/primops/should_run/ArithWord8.hs
+++ b/testsuite/tests/primops/should_run/ArithWord8.hs
@@ -145,34 +145,34 @@ addMany (W# a) (W# b) (W# c) (W# d)
(W# e) (W# f) (W# g) (W# h)
(W# i) (W# j) (W# k) (W# l)
(W# m) (W# n) (W# o) (W# p)
- = W# (extendWord8# word8)
+ = W# (word8ToWord# word8)
where
!word8 =
addMany#
- (narrowWord8# a) (narrowWord8# b) (narrowWord8# c) (narrowWord8# d)
- (narrowWord8# e) (narrowWord8# f) (narrowWord8# g) (narrowWord8# h)
- (narrowWord8# i) (narrowWord8# j) (narrowWord8# k) (narrowWord8# l)
- (narrowWord8# m) (narrowWord8# n) (narrowWord8# o) (narrowWord8# p)
+ (wordToWord8# a) (wordToWord8# b) (wordToWord8# c) (wordToWord8# d)
+ (wordToWord8# e) (wordToWord8# f) (wordToWord8# g) (wordToWord8# h)
+ (wordToWord8# i) (wordToWord8# j) (wordToWord8# k) (wordToWord8# l)
+ (wordToWord8# m) (wordToWord8# n) (wordToWord8# o) (wordToWord8# p)
{-# NOINLINE addMany #-}
-- Convenient and also tests higher order functions on Word8#
apply1 :: (Word8# -> Word8#) -> Word -> Word
-apply1 opToTest (W# a) = W# (extendWord8# (opToTest (narrowWord8# a)))
+apply1 opToTest (W# a) = W# (word8ToWord# (opToTest (wordToWord8# a)))
{-# NOINLINE apply1 #-}
apply2 :: (Word8# -> Word8# -> Word8#) -> Word -> Word -> Word
apply2 opToTest (W# a) (W# b) =
- let (# sa, sb #) = (# narrowWord8# a, narrowWord8# b #)
+ let (# sa, sb #) = (# wordToWord8# a, wordToWord8# b #)
r = opToTest sa sb
- in W# (extendWord8# r)
+ in W# (word8ToWord# r)
{-# NOINLINE apply2 #-}
apply3
:: (Word8# -> Word8# -> (# Word8#, Word8# #)) -> Word -> Word -> (Word, Word)
apply3 opToTest (W# a) (W# b) =
- let (# sa, sb #) = (# narrowWord8# a, narrowWord8# b #)
+ let (# sa, sb #) = (# wordToWord8# a, wordToWord8# b #)
(# ra, rb #) = opToTest sa sb
- in (W# (extendWord8# ra), W# (extendWord8# rb))
+ in (W# (word8ToWord# ra), W# (word8ToWord# rb))
{-# NOINLINE apply3 #-}
instance
diff --git a/testsuite/tests/primops/should_run/CStringLength.hs b/testsuite/tests/primops/should_run/CStringLength.hs
index b580e61934..ee7aac4f9b 100644
--- a/testsuite/tests/primops/should_run/CStringLength.hs
+++ b/testsuite/tests/primops/should_run/CStringLength.hs
@@ -3,6 +3,7 @@
{-# LANGUAGE UnboxedTuples #-}
import GHC.Exts
+import GHC.Word (Word8(..))
main :: IO ()
main = do
@@ -28,6 +29,11 @@ main = do
naiveStrlen "araña\NULb"# 0
naiveStrlen :: Addr# -> Int -> Int
-naiveStrlen addr !n = case indexWord8OffAddr# addr 0# of
- 0## -> n
- _ -> naiveStrlen (plusAddr# addr 1#) (n + 1)
+naiveStrlen addr !n =
+ -- TODO change back to pattern matching once we have negative literals.
+ if isTrue# (res `eqWord8#` zero)
+ then n
+ else naiveStrlen (plusAddr# addr 1#) (n + 1)
+ where
+ res = indexWord8OffAddr# addr 0#
+ W8# zero = 0
diff --git a/testsuite/tests/primops/should_run/CmpInt16.hs b/testsuite/tests/primops/should_run/CmpInt16.hs
index 3fa89b5b31..0fdec359d7 100644
--- a/testsuite/tests/primops/should_run/CmpInt16.hs
+++ b/testsuite/tests/primops/should_run/CmpInt16.hs
@@ -16,7 +16,7 @@ data TestInt16 = T16 Int16#
deriving (Eq, Ord)
mkT16 :: Int -> TestInt16
-mkT16 (I# a) = T16 (narrowInt16# a)
+mkT16 (I# a) = T16 (intToInt16# a)
main :: IO ()
main = do
diff --git a/testsuite/tests/primops/should_run/CmpInt32.hs b/testsuite/tests/primops/should_run/CmpInt32.hs
index 6f52ccecb1..a9b560664b 100644
--- a/testsuite/tests/primops/should_run/CmpInt32.hs
+++ b/testsuite/tests/primops/should_run/CmpInt32.hs
@@ -16,7 +16,7 @@ data TestInt32 = T32 Int32#
deriving (Eq, Ord)
mkT32 :: Int -> TestInt32
-mkT32 (I# a) = T32 (narrowInt32# a)
+mkT32 (I# a) = T32 (intToInt32# a)
main :: IO ()
main = do
diff --git a/testsuite/tests/primops/should_run/CmpInt8.hs b/testsuite/tests/primops/should_run/CmpInt8.hs
index 7f0bcda973..2bed2000da 100644
--- a/testsuite/tests/primops/should_run/CmpInt8.hs
+++ b/testsuite/tests/primops/should_run/CmpInt8.hs
@@ -16,7 +16,7 @@ data TestInt8 = T8 Int8#
deriving (Eq, Ord)
mkT8 :: Int -> TestInt8
-mkT8 (I# a) = T8 (narrowInt8# a)
+mkT8 (I# a) = T8 (intToInt8# a)
main :: IO ()
main = do
diff --git a/testsuite/tests/primops/should_run/CmpWord16.hs b/testsuite/tests/primops/should_run/CmpWord16.hs
index 1a69a10f4b..a5d527afd0 100644
--- a/testsuite/tests/primops/should_run/CmpWord16.hs
+++ b/testsuite/tests/primops/should_run/CmpWord16.hs
@@ -16,7 +16,7 @@ data TestWord16 = T16 Word16#
deriving (Eq, Ord)
mkT16 :: Word -> TestWord16
-mkT16 (W# a) = T16 (narrowWord16# a)
+mkT16 (W# a) = T16 (wordToWord16# a)
main :: IO ()
main = do
diff --git a/testsuite/tests/primops/should_run/CmpWord32.hs b/testsuite/tests/primops/should_run/CmpWord32.hs
index 5e422aecab..aeb7ec28e4 100644
--- a/testsuite/tests/primops/should_run/CmpWord32.hs
+++ b/testsuite/tests/primops/should_run/CmpWord32.hs
@@ -16,7 +16,7 @@ data TestWord32 = T32 Word32#
deriving (Eq, Ord)
mkT32 :: Word -> TestWord32
-mkT32 (W# a) = T32 (narrowWord32# a)
+mkT32 (W# a) = T32 (wordToWord32# a)
main :: IO ()
main = do
diff --git a/testsuite/tests/primops/should_run/CmpWord8.hs b/testsuite/tests/primops/should_run/CmpWord8.hs
index 07f683108e..813ae7c270 100644
--- a/testsuite/tests/primops/should_run/CmpWord8.hs
+++ b/testsuite/tests/primops/should_run/CmpWord8.hs
@@ -16,7 +16,7 @@ data TestWord8 = T8 Word8#
deriving (Eq, Ord)
mkT8 :: Word -> TestWord8
-mkT8 (W# a) = T8 (narrowWord8# a)
+mkT8 (W# a) = T8 (wordToWord8# a)
main :: IO ()
main = do
diff --git a/testsuite/tests/primops/should_run/ShowPrim.hs b/testsuite/tests/primops/should_run/ShowPrim.hs
index ddeb661ec4..6213ef496c 100644
--- a/testsuite/tests/primops/should_run/ShowPrim.hs
+++ b/testsuite/tests/primops/should_run/ShowPrim.hs
@@ -14,13 +14,13 @@ data Test3 = Test3 Int32# Word32#
deriving (Show)
test1 :: Test1
-test1 = Test1 (narrowInt8# 1#) (narrowWord8# 2##)
+test1 = Test1 (intToInt8# 1#) (wordToWord8# 2##)
test2 :: Test2
-test2 = Test2 (narrowInt16# 1#) (narrowWord16# 2##)
+test2 = Test2 (intToInt16# 1#) (wordToWord16# 2##)
test3 :: Test3
-test3 = Test3 (narrowInt32# 1#) (narrowWord32# 2##)
+test3 = Test3 (intToInt32# 1#) (wordToWord32# 2##)
main :: IO ()
main = do
diff --git a/testsuite/tests/primops/should_run/ShowPrim.stdout b/testsuite/tests/primops/should_run/ShowPrim.stdout
index a5dc75f39d..d4167bf32c 100644
--- a/testsuite/tests/primops/should_run/ShowPrim.stdout
+++ b/testsuite/tests/primops/should_run/ShowPrim.stdout
@@ -1,3 +1,3 @@
-Test1 (narrowInt8# 1#) (narrowWord8# 2##)
-Test2 (narrowInt16# 1#) (narrowWord16# 2##)
-Test3 (narrowInt32# 1#) (narrowWord32# 2##)
+Test1 (intToInt8# 1#) (wordToWord8# 2##)
+Test2 (intToInt16# 1#) (wordToWord16# 2##)
+Test3 (intToInt32# 1#) (wordToWord32# 2##)
diff --git a/testsuite/tests/primops/should_run/T4442.hs b/testsuite/tests/primops/should_run/T4442.hs
index d9e65006bc..dfdf93cc4f 100644
--- a/testsuite/tests/primops/should_run/T4442.hs
+++ b/testsuite/tests/primops/should_run/T4442.hs
@@ -1,4 +1,6 @@
-{-# LANGUAGE MagicHash, UnboxedTuples, CPP #-}
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE MagicHash #-}
+{-# LANGUAGE UnboxedTuples #-}
module Main where
#include "MachDeps.h"
@@ -8,32 +10,30 @@ import GHC.Stable(
StablePtr(..), castStablePtrToPtr, castPtrToStablePtr, newStablePtr)
import GHC.Exts
import Data.Char(ord)
-#if WORD_SIZE_IN_BITS < 64
-import GHC.Int (Int64(..))
-import GHC.Word (Word64(..))
-#endif
+import GHC.Int
+import GHC.Word
-assertEqual :: (Show a, Eq a) => a -> a -> IO ()
-assertEqual a b
- | a /= b = putStrLn (show a ++ " /= " ++ show b)
+assertEqual :: (Show a, Eq a) => String -> a -> a -> IO ()
+assertEqual msg a b
+ | a /= b = putStrLn (msg ++ " " ++ show a ++ " /= " ++ show b)
| otherwise = return ()
-readBytes :: MutableByteArray# s -> State# s -> Int# -> (# State# s, [Int] #)
+readBytes :: MutableByteArray# s -> State# s -> Int# -> (# State# s, [Word8] #)
readBytes marr s0 len = go s0 len []
where
go s 0# bs = (# s, bs #)
go s i bs = case readWord8Array# marr (i -# 1#) s of
- (# s', b #) -> go s' (i -# 1#) (I# (word2Int# b):bs)
+ (# s', b #) -> go s' (i -# 1#) (W8# b : bs)
-indexBytes :: ByteArray# -> Int# -> [Int]
+indexBytes :: ByteArray# -> Int# -> [Word8]
indexBytes arr len =
- [I# (word2Int# (indexWord8Array# arr i)) | I# i <- [0..I# len - 1]]
+ [W8# (indexWord8Array# arr i) | I# i <- [0..I# len - 1]]
-fillByteArray :: MutableByteArray# s -> Int# -> Int -> State# s -> State# s
-fillByteArray arr len (I# a) = go len
+fillByteArray :: MutableByteArray# s -> Int# -> Word8 -> State# s -> State# s
+fillByteArray arr len (W8# a) = go len
where
go 0# s = s
- go i s = go (i -# 1#) (writeInt8Array# arr (i -# 1#) a s)
+ go i s = go (i -# 1#) (writeWord8Array# arr (i -# 1#) a s)
test :: (Eq a, Show a)
=> String
@@ -43,7 +43,7 @@ test :: (Eq a, Show a)
-> (MutableByteArray# RealWorld -> Int# -> a -> State# RealWorld
-> State# RealWorld)
-> a
- -> [Int]
+ -> [Word8]
-> Int
-> IO ()
test name index read write val valBytes len = do
@@ -53,14 +53,14 @@ test name index read write val valBytes len = do
arrLen :: Int#
arrLen = 24#
- fillerByte :: Int
+ fillerByte :: Word8
fillerByte = 0x34
- expectedArrayBytes :: Int -> [Int]
+ expectedArrayBytes :: Int -> [Word8]
expectedArrayBytes offset =
replicate offset fillerByte
++ valBytes
- ++ replicate (I# arrLen - len - offset) fillerByte
+ ++ replicate (fromIntegral $ I# arrLen - len - offset) fillerByte
testAtOffset :: Int -> IO ()
testAtOffset offset@(I# offset#) = runRW# (\s0 -> let
@@ -73,18 +73,18 @@ test name index read write val valBytes len = do
actual1 = index arr offset#
actualBytes1 = indexBytes arr arrLen
in do
- assertEqual actual0 val
- assertEqual actual1 val
- assertEqual actualBytes0 (expectedArrayBytes offset)
- assertEqual actualBytes1 (expectedArrayBytes offset)
+ assertEqual "actual val 0" actual0 val
+ assertEqual "actual val 1" actual1 val
+ assertEqual "actualBytes0 indexed" actualBytes0 (expectedArrayBytes offset)
+ assertEqual "actualButes1 indexed" actualBytes1 (expectedArrayBytes offset)
)
-intToBytes :: Int -> Int -> [Int]
-intToBytes (I# val0) (I# len0) = let
+intToBytes :: Word -> Int -> [Word8]
+intToBytes (W# val0) (I# len0) = let
result = go val0 len0
go v 0# = []
go v len =
- I# (v `andI#` 0xff#) : go (v `uncheckedIShiftRL#` 8#) (len -# 1#)
+ W8# (wordToWord8# v) : go (v `uncheckedShiftRL#` 8#) (len -# 1#)
in
#if defined(WORDS_BIGENDIAN)
reverse result
@@ -92,28 +92,22 @@ intToBytes (I# val0) (I# len0) = let
result
#endif
-testIntArray ::
- String
- -> (ByteArray# -> Int# -> Int#)
+testIntArray :: (Eq a, Show a, Integral a, Num a)
+ => String
+ -> (ByteArray# -> Int# -> a)
-> (MutableByteArray# RealWorld -> Int# -> State# RealWorld
- -> (# State# RealWorld, Int# #))
- -> (MutableByteArray# RealWorld -> Int# -> Int# -> State# RealWorld
- -> State# RealWorld)
- -> Int
+ -> (# State# RealWorld, a #))
+ -> (MutableByteArray# RealWorld -> Int# -> a -> State# RealWorld
+ -> State# RealWorld)
+ -> a
-> Int
-> IO ()
testIntArray name0 index read write val0 len = do
doOne (name0 ++ " positive") val0
doOne (name0 ++ " negative") (negate val0)
where
- doOne name val = test
- name
- (\arr i -> I# (index arr i))
- (\arr i s -> case read arr i s of (# s', a #) -> (# s', I# a #))
- (\arr i (I# a) s -> write arr i a s)
- val
- (intToBytes val len)
- len
+ doOne name val = test name index read write
+ val (intToBytes (fromIntegral val) len) len
#if WORD_SIZE_IN_BITS == 64
testInt64Array = testIntArray
@@ -143,24 +137,19 @@ testInt64Array name0 index read write val0 len = do
len
#endif
-testWordArray ::
- String
- -> (ByteArray# -> Int# -> Word#)
+testWordArray :: (Eq a, Show a, Integral a)
+ => String
+ -> (ByteArray# -> Int# -> a)
-> (MutableByteArray# RealWorld -> Int# -> State# RealWorld
- -> (# State# RealWorld, Word# #))
- -> (MutableByteArray# RealWorld -> Int# -> Word# -> State# RealWorld
+ -> (# State# RealWorld, a #))
+ -> (MutableByteArray# RealWorld -> Int# -> a -> State# RealWorld
-> State# RealWorld)
- -> Word
+ -> a
-> Int
-> IO ()
-testWordArray name index read write val len = test
- name
- (\arr i -> W# (index arr i))
- (\arr i s -> case read arr i s of (# s', a #) -> (# s', W# a #))
- (\arr i (W# a) s -> write arr i a s)
- val
- (intToBytes (fromIntegral val) len)
- len
+testWordArray name index read write val len =
+ test name index read write
+ val (intToBytes (fromIntegral val) len) len
#if WORD_SIZE_IN_BITS == 64
testWord64Array = testWordArray
@@ -203,7 +192,7 @@ float = 123.456789
-- >>> import struct
-- >>> import binascii
-- >>> binascii.hexlify(struct.pack('>f', 123.456789))
-floatBytes :: Int
+floatBytes :: Word
floatBytes = 0x42f6e9e0
double :: Double
@@ -213,41 +202,61 @@ double = 123.45678901234
-- >>> import struct
-- >>> import binascii
-- >>> binascii.hexlify(struct.pack('>d', 123.45678901234))
-doubleBytes :: Int
+doubleBytes :: Word
doubleBytes = 0x405edd3c07fb4b09
main :: IO ()
main = do
testIntArray "Int8#"
- indexInt8Array# readInt8Array# writeInt8Array#
+ (\arr i -> I8# (indexInt8Array# arr i))
+ (\arr i s -> case readInt8Array# arr i s of (# s', a #) -> (# s', I8# a #))
+ (\arr i (I8# a) s -> writeInt8Array# arr i a s)
123 1
testIntArray "Int16#"
- indexWord8ArrayAsInt16# readWord8ArrayAsInt16# writeWord8ArrayAsInt16#
+ (\arr i -> I16# (indexWord8ArrayAsInt16# arr i))
+ (\arr i s -> case readWord8ArrayAsInt16# arr i s of (# s', a #) -> (# s', I16# a #))
+ (\arr i (I16# a) s -> writeWord8ArrayAsInt16# arr i a s)
12345 2
testIntArray "Int32#"
- indexWord8ArrayAsInt32# readWord8ArrayAsInt32# writeWord8ArrayAsInt32#
+ (\arr i -> I32# (indexWord8ArrayAsInt32# arr i))
+ (\arr i s -> case readWord8ArrayAsInt32# arr i s of (# s', a #) -> (# s', I32# a #))
+ (\arr i (I32# a) s -> writeWord8ArrayAsInt32# arr i a s)
12345678 4
testInt64Array "Int64#"
- indexWord8ArrayAsInt64# readWord8ArrayAsInt64# writeWord8ArrayAsInt64#
+ (\arr i -> I64# (indexWord8ArrayAsInt64# arr i))
+ (\arr i s -> case readWord8ArrayAsInt64# arr i s of (# s', a #) -> (# s', I64# a #))
+ (\arr i (I64# a) s -> writeWord8ArrayAsInt64# arr i a s)
1234567890123 8
testIntArray "Int#"
- indexWord8ArrayAsInt# readWord8ArrayAsInt# writeWord8ArrayAsInt#
+ (\arr i -> I# (indexWord8ArrayAsInt# arr i))
+ (\arr i s -> case readWord8ArrayAsInt# arr i s of (# s', a #) -> (# s', I# a #))
+ (\arr i (I# a) s -> writeWord8ArrayAsInt# arr i a s)
int wordSizeInBytes
testWordArray "Word8#"
- indexWord8Array# readWord8Array# writeWord8Array#
+ (\arr i -> W8# (indexWord8Array# arr i))
+ (\arr i s -> case readWord8Array# arr i s of (# s', a #) -> (# s', W8# a #))
+ (\arr i (W8# a) s -> writeWord8Array# arr i a s)
123 1
testWordArray "Word16#"
- indexWord8ArrayAsWord16# readWord8ArrayAsWord16# writeWord8ArrayAsWord16#
+ (\arr i -> W16# (indexWord8ArrayAsWord16# arr i))
+ (\arr i s -> case readWord8ArrayAsWord16# arr i s of (# s', a #) -> (# s', W16# a #))
+ (\arr i (W16# a) s -> writeWord8ArrayAsWord16# arr i a s)
12345 2
testWordArray "Word32#"
- indexWord8ArrayAsWord32# readWord8ArrayAsWord32# writeWord8ArrayAsWord32#
+ (\arr i -> W32# (indexWord8ArrayAsWord32# arr i))
+ (\arr i s -> case readWord8ArrayAsWord32# arr i s of (# s', a #) -> (# s', W32# a #))
+ (\arr i (W32# a) s -> writeWord8ArrayAsWord32# arr i a s)
12345678 4
testWord64Array "Word64#"
- indexWord8ArrayAsWord64# readWord8ArrayAsWord64# writeWord8ArrayAsWord64#
+ (\arr i -> W64# (indexWord8ArrayAsWord64# arr i))
+ (\arr i s -> case readWord8ArrayAsWord64# arr i s of (# s', a #) -> (# s', W64# a #))
+ (\arr i (W64# a) s -> writeWord8ArrayAsWord64# arr i a s)
1234567890123 8
testWordArray "Word#"
- indexWord8ArrayAsWord# readWord8ArrayAsWord# writeWord8ArrayAsWord#
+ (\arr i -> W# (indexWord8ArrayAsWord# arr i))
+ (\arr i s -> case readWord8ArrayAsWord# arr i s of (# s', a #) -> (# s', W# a #))
+ (\arr i (W# a) s -> writeWord8ArrayAsWord# arr i a s)
word wordSizeInBytes
test
@@ -257,7 +266,7 @@ main = do
case readWord8ArrayAsChar# arr i s of (# s', a #) -> (# s', C# a #))
(\arr i (C# a) s -> writeWord8ArrayAsChar# arr i a s)
'z'
- [ord 'z']
+ [fromIntegral $ ord 'z']
1
test
"WideChar#"
@@ -266,7 +275,7 @@ main = do
case readWord8ArrayAsWideChar# arr i s of (# s', a #) -> (# s', C# a #))
(\arr i (C# a) s -> writeWord8ArrayAsWideChar# arr i a s)
'𠜎' -- See http://www.i18nguy.com/unicode/supplementary-test.html
- (intToBytes (ord '𠜎') 4)
+ (intToBytes (fromIntegral $ ord '𠜎') 4)
4
test
"Addr#"
@@ -275,7 +284,7 @@ main = do
case readWord8ArrayAsAddr# arr i s of (# s', a #) -> (# s', Ptr a #))
(\arr i (Ptr a) s -> writeWord8ArrayAsAddr# arr i a s)
(nullPtr `plusPtr` int)
- (intToBytes int wordSizeInBytes)
+ (intToBytes word wordSizeInBytes)
wordSizeInBytes
stablePtr <- newStablePtr ()
@@ -288,7 +297,7 @@ main = do
(\arr i p s -> case castPtrToStablePtr p of
(StablePtr a) -> writeWord8ArrayAsStablePtr# arr i a s)
(castStablePtrToPtr stablePtr)
- (intToBytes (castStablePtrToPtr stablePtr `minusPtr` nullPtr)
+ (intToBytes (fromIntegral $ castStablePtrToPtr stablePtr `minusPtr` nullPtr)
wordSizeInBytes)
wordSizeInBytes
diff --git a/testsuite/tests/profiling/should_run/T3001-2.hs b/testsuite/tests/profiling/should_run/T3001-2.hs
index 186fd2f2f9..c7340dfd19 100644
--- a/testsuite/tests/profiling/should_run/T3001-2.hs
+++ b/testsuite/tests/profiling/should_run/T3001-2.hs
@@ -153,7 +153,7 @@ readN :: Int -> (S.ByteString -> a) -> Get a
readN n f = fmap f $ getBytes n
shiftl_w32 :: Word32 -> Int -> Word32
-shiftl_w32 (W32# w) (I# i) = W32# (narrowWord32# ((extendWord32# w) `uncheckedShiftL#` i))
+shiftl_w32 (W32# w) (I# i) = W32# (wordToWord32# ((word32ToWord# w) `uncheckedShiftL#` i))
getPtr :: Storable a => Int -> Get a
getPtr n = do
@@ -274,7 +274,7 @@ putWord32beB w = writeN 4 $ \p -> do
poke (p `plusPtr` 3) (fromIntegral (w) :: Word8)
shiftr_w32 :: Word32 -> Int -> Word32
-shiftr_w32 (W32# w) (I# i) = W32# (narrowWord32# ((extendWord32# w) `uncheckedShiftRL#` i))
+shiftr_w32 (W32# w) (I# i) = W32# (wordToWord32# ((word32ToWord# w) `uncheckedShiftRL#` i))
flush :: Builder
flush = Builder $ \ k buf@(Buffer p o u l) ->
diff --git a/testsuite/tests/rts/T17088.hs b/testsuite/tests/rts/T17088.hs
index f607ed38e3..6ca24d88d4 100644
--- a/testsuite/tests/rts/T17088.hs
+++ b/testsuite/tests/rts/T17088.hs
@@ -46,7 +46,7 @@ bytesEq (Bytes m1) (Bytes m2)
(# s', e1 #) ->
case readWord8Array# m2 i s' of
(# s'', e2 #) ->
- if isTrue# (eqWord# e1 e2)
+ if isTrue# (eqWord8# e1 e2)
then loop (i +# 1#) s''
else (# s'', False #)
@@ -56,7 +56,7 @@ bytesUnpackChars (Bytes mba)
| I# (sizeofMutableByteArray# mba) == 0 = []
| otherwise = unsafePerformIO $ do
c <- IO $ \s -> case readWord8Array# mba 0# s of
- (# s'', w #) -> (# s'', C# (chr# (word2Int# w)) #)
+ (# s'', w #) -> (# s'', C# (chr# (word2Int# (word8ToWord# w))) #)
return [c]
----------------------------------------------------------------
diff --git a/testsuite/tests/simplCore/should_compile/T5359a.hs b/testsuite/tests/simplCore/should_compile/T5359a.hs
index 8c4a0beaf7..594bd9ed18 100644
--- a/testsuite/tests/simplCore/should_compile/T5359a.hs
+++ b/testsuite/tests/simplCore/should_compile/T5359a.hs
@@ -61,7 +61,7 @@ textP arr off len | len == 0 = emptyT
{-# INLINE textP #-}
unsafeChrT :: Word16 -> Char
-unsafeChrT (W16# w#) = C# (chr# (word2Int# (extendWord16# w#)))
+unsafeChrT (W16# w#) = C# (chr# (word2Int# (word16ToWord# w#)))
{-# INLINE unsafeChrT #-}
data Array = Array ByteArray#
@@ -82,7 +82,7 @@ unsafeFreeze (MArray maBA) = ST $ \s# -> (# s#, Array (unsafeCoerce# maBA) #)
unsafeIndex :: Array -> Int -> Word16
unsafeIndex (Array aBA) (I# i#) =
- case indexWord16Array# aBA i# of r# -> (W16# (narrowWord16# r#))
+ case indexWord16Array# aBA i# of r# -> (W16# r#)
{-# INLINE unsafeIndex #-}
empty :: Array
diff --git a/utils/genprimopcode/gen_bytearray_ops.py b/utils/genprimopcode/gen_bytearray_ops.py
index 760ad150c9..46a9aa91bb 100644
--- a/utils/genprimopcode/gen_bytearray_ops.py
+++ b/utils/genprimopcode/gen_bytearray_ops.py
@@ -38,15 +38,15 @@ element_types = [
# element_types += [ ElementType(f"Word{n}", f"Word{n}#", f"{n}-bit unsigned integer", n // 8) ]
element_types += [
- ElementType("Int8", "Int#", "8-bit signed integer", 1),
- ElementType("Int16", "Int#", "16-bit signed integer", 2),
- ElementType("Int32", "INT32", "32-bit signed integer", 4),
- ElementType("Int64", "INT64", "64-bit signed integer", 8),
-
- ElementType("Word8", "Word#", "8-bit unsigned integer", 1),
- ElementType("Word16", "Word#", "16-bit unsigned integer", 2),
- ElementType("Word32", "WORD32", "32-bit unsigned integer", 4),
- ElementType("Word64", "WORD64", "64-bit unsigned integer", 8),
+ ElementType("Int8", "Int8#", "8-bit signed integer", 1),
+ ElementType("Int16", "Int16#", "16-bit signed integer", 2),
+ ElementType("Int32", "Int32#", "32-bit signed integer", 4),
+ ElementType("Int64", "INT64", "64-bit signed integer", 8),
+
+ ElementType("Word8", "Word8#", "8-bit unsigned integer", 1),
+ ElementType("Word16", "Word16#", "16-bit unsigned integer", 2),
+ ElementType("Word32", "Word32#", "32-bit unsigned integer", 4),
+ ElementType("Word64", "WORD64", "64-bit unsigned integer", 8),
]
def pretty_offset(n: Optional[int]) -> str: