[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: TTG: only allow VarBind at GhcTc

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Tue Jun 6 14:09:33 UTC 2023



Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC


Commits:
58ccf02e by sheaf at 2023-06-05T16:00:47-04:00
TTG: only allow VarBind at GhcTc

The VarBind constructor of HsBind is only used at the GhcTc stage.
This commit makes that explicit by setting the extension field of
VarBind to be DataConCantHappen at all other stages.

This allows us to delete a dead code path in GHC.HsToCore.Quote.rep_bind,
and remove some panics.

- - - - -
7e291b50 by Matthew Craven at 2023-06-06T10:09:18-04:00
Generate Addr# access ops programmatically

The existing utils/genprimopcode/gen_bytearray_ops.py was
relocated and extended for this purpose.  Additionally, hadrian
now knows about this script and uses it when generating primops.txt

- - - - -
ede1f236 by Matthew Pickering at 2023-06-06T10:09:18-04:00
ghcup-metadata: Only add Nightly tag when replacing LatestNightly

Previously we were always adding the Nightly tag, but this led to all
the previous builds getting an increasing number of nightly tags over
time. Now we just add it once, when we remove the LatestNightly tag.

- - - - -


11 changed files:

- .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py
- − compiler/GHC/Builtin/bytearray-ops.txt.pp
- utils/genprimopcode/gen_bytearray_ops.py → compiler/GHC/Builtin/gen_bytearray_addr_access_ops.py
- compiler/GHC/Builtin/primops.txt.pp
- compiler/GHC/Hs/Binds.hs
- compiler/GHC/Hs/Utils.hs
- compiler/GHC/HsToCore/Quote.hs
- compiler/GHC/Rename/Bind.hs
- compiler/GHC/Tc/Gen/Bind.hs
- hadrian/src/Rules/Generate.hs
- rts/gen_event_types.py


Changes:

=====================================
.gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py
=====================================
@@ -264,7 +264,7 @@ def setNightlyTags(ghcup_metadata):
     for version in ghcup_metadata['ghcupDownloads']['GHC']:
         if "LatestNightly" in ghcup_metadata['ghcupDownloads']['GHC'][version]["viTags"]:
             ghcup_metadata['ghcupDownloads']['GHC'][version]["viTags"].remove("LatestNightly")
-        ghcup_metadata['ghcupDownloads']['GHC'][version]["viTags"].append("Nightly")
+            ghcup_metadata['ghcupDownloads']['GHC'][version]["viTags"].append("Nightly")
 
 
 


=====================================
compiler/GHC/Builtin/bytearray-ops.txt.pp deleted
=====================================
@@ -1,551 +0,0 @@
-
-------------------------------------
--- ByteArray# operations
-------------------------------------
-
-
--- Do not edit. This file is generated by utils/genprimopcode/gen_bytearray_ops.py.
--- To regenerate run,
---
---      python3 utils/genprimops/gen_bytearray_ops.py > compiler/GHC/Builtin/bytearray-ops.txt.pp
-
-
-------------------------------------
--- aligned index operations
-------------------------------------
-
-primop IndexByteArrayOp_Char "indexCharArray#" GenPrimOp
-   ByteArray# -> Int# -> Char#
-   {Read a 8-bit character; offset in bytes.}
-   with can_fail = True
-
-primop IndexByteArrayOp_WideChar "indexWideCharArray#" GenPrimOp
-   ByteArray# -> Int# -> Char#
-   {Read a 32-bit character; offset in 4-byte words.}
-   with can_fail = True
-
-primop IndexByteArrayOp_Int "indexIntArray#" GenPrimOp
-   ByteArray# -> Int# -> Int#
-   {Read a word-sized integer; offset in machine words.}
-   with can_fail = True
-
-primop IndexByteArrayOp_Word "indexWordArray#" GenPrimOp
-   ByteArray# -> Int# -> Word#
-   {Read a word-sized unsigned integer; offset in machine words.}
-   with can_fail = True
-
-primop IndexByteArrayOp_Addr "indexAddrArray#" GenPrimOp
-   ByteArray# -> Int# -> Addr#
-   {Read a machine address; offset in machine words.}
-   with can_fail = True
-
-primop IndexByteArrayOp_Float "indexFloatArray#" GenPrimOp
-   ByteArray# -> Int# -> Float#
-   {Read a single-precision floating-point value; offset in 4-byte words.}
-   with can_fail = True
-
-primop IndexByteArrayOp_Double "indexDoubleArray#" GenPrimOp
-   ByteArray# -> Int# -> Double#
-   {Read a double-precision floating-point value; offset in 8-byte words.}
-   with can_fail = True
-
-primop IndexByteArrayOp_StablePtr "indexStablePtrArray#" GenPrimOp
-   ByteArray# -> Int# -> StablePtr# a
-   {Read a 'StablePtr#' value; offset in machine words.}
-   with can_fail = True
-
-primop IndexByteArrayOp_Int8 "indexInt8Array#" GenPrimOp
-   ByteArray# -> Int# -> Int8#
-   {Read a 8-bit signed integer; offset in bytes.}
-   with can_fail = True
-
-primop IndexByteArrayOp_Int16 "indexInt16Array#" GenPrimOp
-   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#
-   {Read a 32-bit signed integer; offset in 4-byte words.}
-   with can_fail = True
-
-primop IndexByteArrayOp_Int64 "indexInt64Array#" GenPrimOp
-   ByteArray# -> Int# -> Int64#
-   {Read a 64-bit signed integer; offset in 8-byte words.}
-   with can_fail = True
-
-primop IndexByteArrayOp_Word8 "indexWord8Array#" GenPrimOp
-   ByteArray# -> Int# -> Word8#
-   {Read a 8-bit unsigned integer; offset in bytes.}
-   with can_fail = True
-
-primop IndexByteArrayOp_Word16 "indexWord16Array#" GenPrimOp
-   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#
-   {Read a 32-bit unsigned integer; offset in 4-byte words.}
-   with can_fail = True
-
-primop IndexByteArrayOp_Word64 "indexWord64Array#" GenPrimOp
-   ByteArray# -> Int# -> Word64#
-   {Read a 64-bit unsigned integer; offset in 8-byte words.}
-   with can_fail = True
-
-
-------------------------------------
--- unaligned index operations
-------------------------------------
-
-primop IndexByteArrayOp_Word8AsChar "indexWord8ArrayAsChar#" GenPrimOp
-   ByteArray# -> Int# -> Char#
-   {Read a 8-bit character; offset in bytes.}
-   with can_fail = True
-
-primop IndexByteArrayOp_Word8AsWideChar "indexWord8ArrayAsWideChar#" GenPrimOp
-   ByteArray# -> Int# -> Char#
-   {Read a 32-bit character; offset in bytes.}
-   with can_fail = True
-
-primop IndexByteArrayOp_Word8AsInt "indexWord8ArrayAsInt#" GenPrimOp
-   ByteArray# -> Int# -> Int#
-   {Read a word-sized integer; offset in bytes.}
-   with can_fail = True
-
-primop IndexByteArrayOp_Word8AsWord "indexWord8ArrayAsWord#" GenPrimOp
-   ByteArray# -> Int# -> Word#
-   {Read a word-sized unsigned integer; offset in bytes.}
-   with can_fail = True
-
-primop IndexByteArrayOp_Word8AsAddr "indexWord8ArrayAsAddr#" GenPrimOp
-   ByteArray# -> Int# -> Addr#
-   {Read a machine address; offset in bytes.}
-   with can_fail = True
-
-primop IndexByteArrayOp_Word8AsFloat "indexWord8ArrayAsFloat#" GenPrimOp
-   ByteArray# -> Int# -> Float#
-   {Read a single-precision floating-point value; offset in bytes.}
-   with can_fail = True
-
-primop IndexByteArrayOp_Word8AsDouble "indexWord8ArrayAsDouble#" GenPrimOp
-   ByteArray# -> Int# -> Double#
-   {Read a double-precision floating-point value; offset in bytes.}
-   with can_fail = True
-
-primop IndexByteArrayOp_Word8AsStablePtr "indexWord8ArrayAsStablePtr#" GenPrimOp
-   ByteArray# -> Int# -> StablePtr# a
-   {Read a 'StablePtr#' value; offset in bytes.}
-   with can_fail = True
-
-primop IndexByteArrayOp_Word8AsInt16 "indexWord8ArrayAsInt16#" GenPrimOp
-   ByteArray# -> Int# -> Int16#
-   {Read a 16-bit signed integer; offset in bytes.}
-   with can_fail = True
-
-primop IndexByteArrayOp_Word8AsInt32 "indexWord8ArrayAsInt32#" GenPrimOp
-   ByteArray# -> Int# -> Int32#
-   {Read a 32-bit signed integer; offset in bytes.}
-   with can_fail = True
-
-primop IndexByteArrayOp_Word8AsInt64 "indexWord8ArrayAsInt64#" GenPrimOp
-   ByteArray# -> Int# -> Int64#
-   {Read a 64-bit signed integer; offset in bytes.}
-   with can_fail = True
-
-primop IndexByteArrayOp_Word8AsWord16 "indexWord8ArrayAsWord16#" GenPrimOp
-   ByteArray# -> Int# -> Word16#
-   {Read a 16-bit unsigned integer; offset in bytes.}
-   with can_fail = True
-
-primop IndexByteArrayOp_Word8AsWord32 "indexWord8ArrayAsWord32#" GenPrimOp
-   ByteArray# -> Int# -> Word32#
-   {Read a 32-bit unsigned integer; offset in bytes.}
-   with can_fail = True
-
-primop IndexByteArrayOp_Word8AsWord64 "indexWord8ArrayAsWord64#" GenPrimOp
-   ByteArray# -> Int# -> Word64#
-   {Read a 64-bit unsigned integer; offset in bytes.}
-   with can_fail = True
-
-
-------------------------------------
--- aligned read operations
-------------------------------------
-
-primop ReadByteArrayOp_Char "readCharArray#" GenPrimOp
-   MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #)
-   {Read a 8-bit character; offset in bytes.}
-   with has_side_effects = True
-        can_fail = True
-
-primop ReadByteArrayOp_WideChar "readWideCharArray#" GenPrimOp
-   MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #)
-   {Read a 32-bit character; offset in 4-byte words.}
-   with has_side_effects = True
-        can_fail = True
-
-primop ReadByteArrayOp_Int "readIntArray#" GenPrimOp
-   MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)
-   {Read a word-sized integer; offset in machine words.}
-   with has_side_effects = True
-        can_fail = True
-
-primop ReadByteArrayOp_Word "readWordArray#" GenPrimOp
-   MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)
-   {Read a word-sized unsigned integer; offset in machine words.}
-   with has_side_effects = True
-        can_fail = True
-
-primop ReadByteArrayOp_Addr "readAddrArray#" GenPrimOp
-   MutableByteArray# s -> Int# -> State# s -> (# State# s, Addr# #)
-   {Read a machine address; offset in machine words.}
-   with has_side_effects = True
-        can_fail = True
-
-primop ReadByteArrayOp_Float "readFloatArray#" GenPrimOp
-   MutableByteArray# s -> Int# -> State# s -> (# State# s, Float# #)
-   {Read a single-precision floating-point value; offset in 4-byte words.}
-   with has_side_effects = True
-        can_fail = True
-
-primop ReadByteArrayOp_Double "readDoubleArray#" GenPrimOp
-   MutableByteArray# s -> Int# -> State# s -> (# State# s, Double# #)
-   {Read a double-precision floating-point value; offset in 8-byte words.}
-   with has_side_effects = True
-        can_fail = True
-
-primop ReadByteArrayOp_StablePtr "readStablePtrArray#" GenPrimOp
-   MutableByteArray# s -> Int# -> State# s -> (# State# s, StablePtr# a #)
-   {Read a 'StablePtr#' value; offset in machine words.}
-   with has_side_effects = True
-        can_fail = True
-
-primop ReadByteArrayOp_Int8 "readInt8Array#" GenPrimOp
-   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, 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# #)
-   {Read a 32-bit signed integer; offset in 4-byte words.}
-   with has_side_effects = True
-        can_fail = True
-
-primop ReadByteArrayOp_Int64 "readInt64Array#" GenPrimOp
-   MutableByteArray# s -> Int# -> State# s -> (# State# s, Int64# #)
-   {Read a 64-bit signed integer; offset in 8-byte words.}
-   with has_side_effects = True
-        can_fail = True
-
-primop ReadByteArrayOp_Word8 "readWord8Array#" GenPrimOp
-   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, 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# #)
-   {Read a 32-bit unsigned integer; offset in 4-byte words.}
-   with has_side_effects = True
-        can_fail = True
-
-primop ReadByteArrayOp_Word64 "readWord64Array#" GenPrimOp
-   MutableByteArray# s -> Int# -> State# s -> (# State# s, Word64# #)
-   {Read a 64-bit unsigned integer; offset in 8-byte words.}
-   with has_side_effects = True
-        can_fail = True
-
-
-------------------------------------
--- unaligned read operations
-------------------------------------
-
-primop ReadByteArrayOp_Word8AsChar "readWord8ArrayAsChar#" GenPrimOp
-   MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #)
-   {Read a 8-bit character; offset in bytes.}
-   with has_side_effects = True
-        can_fail = True
-
-primop ReadByteArrayOp_Word8AsWideChar "readWord8ArrayAsWideChar#" GenPrimOp
-   MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #)
-   {Read a 32-bit character; offset in bytes.}
-   with has_side_effects = True
-        can_fail = True
-
-primop ReadByteArrayOp_Word8AsInt "readWord8ArrayAsInt#" GenPrimOp
-   MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)
-   {Read a word-sized integer; offset in bytes.}
-   with has_side_effects = True
-        can_fail = True
-
-primop ReadByteArrayOp_Word8AsWord "readWord8ArrayAsWord#" GenPrimOp
-   MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)
-   {Read a word-sized unsigned integer; offset in bytes.}
-   with has_side_effects = True
-        can_fail = True
-
-primop ReadByteArrayOp_Word8AsAddr "readWord8ArrayAsAddr#" GenPrimOp
-   MutableByteArray# s -> Int# -> State# s -> (# State# s, Addr# #)
-   {Read a machine address; offset in bytes.}
-   with has_side_effects = True
-        can_fail = True
-
-primop ReadByteArrayOp_Word8AsFloat "readWord8ArrayAsFloat#" GenPrimOp
-   MutableByteArray# s -> Int# -> State# s -> (# State# s, Float# #)
-   {Read a single-precision floating-point value; offset in bytes.}
-   with has_side_effects = True
-        can_fail = True
-
-primop ReadByteArrayOp_Word8AsDouble "readWord8ArrayAsDouble#" GenPrimOp
-   MutableByteArray# s -> Int# -> State# s -> (# State# s, Double# #)
-   {Read a double-precision floating-point value; offset in bytes.}
-   with has_side_effects = True
-        can_fail = True
-
-primop ReadByteArrayOp_Word8AsStablePtr "readWord8ArrayAsStablePtr#" GenPrimOp
-   MutableByteArray# s -> Int# -> State# s -> (# State# s, StablePtr# a #)
-   {Read a 'StablePtr#' value; offset in bytes.}
-   with has_side_effects = True
-        can_fail = True
-
-primop ReadByteArrayOp_Word8AsInt16 "readWord8ArrayAsInt16#" GenPrimOp
-   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# #)
-   {Read a 32-bit signed integer; offset in bytes.}
-   with has_side_effects = True
-        can_fail = True
-
-primop ReadByteArrayOp_Word8AsInt64 "readWord8ArrayAsInt64#" GenPrimOp
-   MutableByteArray# s -> Int# -> State# s -> (# State# s, Int64# #)
-   {Read a 64-bit signed integer; offset in bytes.}
-   with has_side_effects = True
-        can_fail = True
-
-primop ReadByteArrayOp_Word8AsWord16 "readWord8ArrayAsWord16#" GenPrimOp
-   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# #)
-   {Read a 32-bit unsigned integer; offset in bytes.}
-   with has_side_effects = True
-        can_fail = True
-
-primop ReadByteArrayOp_Word8AsWord64 "readWord8ArrayAsWord64#" GenPrimOp
-   MutableByteArray# s -> Int# -> State# s -> (# State# s, Word64# #)
-   {Read a 64-bit unsigned integer; offset in bytes.}
-   with has_side_effects = True
-        can_fail = True
-
-
-------------------------------------
--- aligned write operations
-------------------------------------
-
-primop WriteByteArrayOp_Char "writeCharArray#" GenPrimOp
-   MutableByteArray# s -> Int# -> Char# -> State# s -> State# s
-   {Write a 8-bit character; offset in bytes.}
-   with has_side_effects = True
-        can_fail = True
-
-primop WriteByteArrayOp_WideChar "writeWideCharArray#" GenPrimOp
-   MutableByteArray# s -> Int# -> Char# -> State# s -> State# s
-   {Write a 32-bit character; offset in 4-byte words.}
-   with has_side_effects = True
-        can_fail = True
-
-primop WriteByteArrayOp_Int "writeIntArray#" GenPrimOp
-   MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
-   {Write a word-sized integer; offset in machine words.}
-   with has_side_effects = True
-        can_fail = True
-
-primop WriteByteArrayOp_Word "writeWordArray#" GenPrimOp
-   MutableByteArray# s -> Int# -> Word# -> State# s -> State# s
-   {Write a word-sized unsigned integer; offset in machine words.}
-   with has_side_effects = True
-        can_fail = True
-
-primop WriteByteArrayOp_Addr "writeAddrArray#" GenPrimOp
-   MutableByteArray# s -> Int# -> Addr# -> State# s -> State# s
-   {Write a machine address; offset in machine words.}
-   with has_side_effects = True
-        can_fail = True
-
-primop WriteByteArrayOp_Float "writeFloatArray#" GenPrimOp
-   MutableByteArray# s -> Int# -> Float# -> State# s -> State# s
-   {Write a single-precision floating-point value; offset in 4-byte words.}
-   with has_side_effects = True
-        can_fail = True
-
-primop WriteByteArrayOp_Double "writeDoubleArray#" GenPrimOp
-   MutableByteArray# s -> Int# -> Double# -> State# s -> State# s
-   {Write a double-precision floating-point value; offset in 8-byte words.}
-   with has_side_effects = True
-        can_fail = True
-
-primop WriteByteArrayOp_StablePtr "writeStablePtrArray#" GenPrimOp
-   MutableByteArray# s -> Int# -> StablePtr# a -> State# s -> State# s
-   {Write a 'StablePtr#' value; offset in machine words.}
-   with has_side_effects = True
-        can_fail = True
-
-primop WriteByteArrayOp_Int8 "writeInt8Array#" GenPrimOp
-   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# -> 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
-   {Write a 32-bit signed integer; offset in 4-byte words.}
-   with has_side_effects = True
-        can_fail = True
-
-primop WriteByteArrayOp_Int64 "writeInt64Array#" GenPrimOp
-   MutableByteArray# s -> Int# -> Int64# -> State# s -> State# s
-   {Write a 64-bit signed integer; offset in 8-byte words.}
-   with has_side_effects = True
-        can_fail = True
-
-primop WriteByteArrayOp_Word8 "writeWord8Array#" GenPrimOp
-   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# -> 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
-   {Write a 32-bit unsigned integer; offset in 4-byte words.}
-   with has_side_effects = True
-        can_fail = True
-
-primop WriteByteArrayOp_Word64 "writeWord64Array#" GenPrimOp
-   MutableByteArray# s -> Int# -> Word64# -> State# s -> State# s
-   {Write a 64-bit unsigned integer; offset in 8-byte words.}
-   with has_side_effects = True
-        can_fail = True
-
-
-------------------------------------
--- unaligned write operations
-------------------------------------
-
-primop WriteByteArrayOp_Word8AsChar "writeWord8ArrayAsChar#" GenPrimOp
-   MutableByteArray# s -> Int# -> Char# -> State# s -> State# s
-   {Write a 8-bit character; offset in bytes.}
-   with has_side_effects = True
-        can_fail = True
-
-primop WriteByteArrayOp_Word8AsWideChar "writeWord8ArrayAsWideChar#" GenPrimOp
-   MutableByteArray# s -> Int# -> Char# -> State# s -> State# s
-   {Write a 32-bit character; offset in bytes.}
-   with has_side_effects = True
-        can_fail = True
-
-primop WriteByteArrayOp_Word8AsInt "writeWord8ArrayAsInt#" GenPrimOp
-   MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
-   {Write a word-sized integer; offset in bytes.}
-   with has_side_effects = True
-        can_fail = True
-
-primop WriteByteArrayOp_Word8AsWord "writeWord8ArrayAsWord#" GenPrimOp
-   MutableByteArray# s -> Int# -> Word# -> State# s -> State# s
-   {Write a word-sized unsigned integer; offset in bytes.}
-   with has_side_effects = True
-        can_fail = True
-
-primop WriteByteArrayOp_Word8AsAddr "writeWord8ArrayAsAddr#" GenPrimOp
-   MutableByteArray# s -> Int# -> Addr# -> State# s -> State# s
-   {Write a machine address; offset in bytes.}
-   with has_side_effects = True
-        can_fail = True
-
-primop WriteByteArrayOp_Word8AsFloat "writeWord8ArrayAsFloat#" GenPrimOp
-   MutableByteArray# s -> Int# -> Float# -> State# s -> State# s
-   {Write a single-precision floating-point value; offset in bytes.}
-   with has_side_effects = True
-        can_fail = True
-
-primop WriteByteArrayOp_Word8AsDouble "writeWord8ArrayAsDouble#" GenPrimOp
-   MutableByteArray# s -> Int# -> Double# -> State# s -> State# s
-   {Write a double-precision floating-point value; offset in bytes.}
-   with has_side_effects = True
-        can_fail = True
-
-primop WriteByteArrayOp_Word8AsStablePtr "writeWord8ArrayAsStablePtr#" GenPrimOp
-   MutableByteArray# s -> Int# -> StablePtr# a -> State# s -> State# s
-   {Write a 'StablePtr#' value; offset in bytes.}
-   with has_side_effects = True
-        can_fail = True
-
-primop WriteByteArrayOp_Word8AsInt16 "writeWord8ArrayAsInt16#" GenPrimOp
-   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
-   {Write a 32-bit signed integer; offset in bytes.}
-   with has_side_effects = True
-        can_fail = True
-
-primop WriteByteArrayOp_Word8AsInt64 "writeWord8ArrayAsInt64#" GenPrimOp
-   MutableByteArray# s -> Int# -> Int64# -> State# s -> State# s
-   {Write a 64-bit signed integer; offset in bytes.}
-   with has_side_effects = True
-        can_fail = True
-
-primop WriteByteArrayOp_Word8AsWord16 "writeWord8ArrayAsWord16#" GenPrimOp
-   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
-   {Write a 32-bit unsigned integer; offset in bytes.}
-   with has_side_effects = True
-        can_fail = True
-
-primop WriteByteArrayOp_Word8AsWord64 "writeWord8ArrayAsWord64#" GenPrimOp
-   MutableByteArray# s -> Int# -> Word64# -> State# s -> State# s
-   {Write a 64-bit unsigned integer; offset in bytes.}
-   with has_side_effects = True
-        can_fail = True
-


=====================================
utils/genprimopcode/gen_bytearray_ops.py → compiler/GHC/Builtin/gen_bytearray_addr_access_ops.py
=====================================
@@ -1,8 +1,32 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
+# This script generates the primop descriptions for many similar ByteArray#
+# and Addr# access operations.  Its output is #include-d into primops.txt.pp.
+
 from typing import Optional, NamedTuple
 import textwrap
+import argparse
+
+arg_parser = argparse.ArgumentParser()
+arg_parser.add_argument('addr_or_bytearray',
+                        choices = ["addr-access-ops", "bytearray-access-ops"],
+                        )
+arg_parser.add_argument('output_file',
+                        type=argparse.FileType('w'),
+                        metavar='FILE',
+                        )
+args = arg_parser.parse_args()
+write = args.output_file.write
+
+
+
+write('''
+-- Do not edit.
+-- This file is generated by compiler/GHC/Builtin/gen_bytearray_addr_access_ops.py.
+-- (The build system should take care of this for you.)
+
+''')
 
 class ElementType(NamedTuple):
     name: str
@@ -28,26 +52,13 @@ element_types = [
     ElementType("StablePtr", "StablePtr# a", "'StablePtr#' value",                    MACH_WORD),
 ]
 
-# TODO: Eventually when the sized integer primops use proper unboxed types we
-# should rather do:
-#
-#for n in [8,16,32,64]:
-#    element_types += [ ElementType(f"Int{n}",  f"Int{n}#",  f"{n}-bit signed integer",   n // 8) ]
-#
-#for n in [8,16,32,64]:
-#    element_types += [ ElementType(f"Word{n}", f"Word{n}#", f"{n}-bit unsigned integer", n // 8) ]
-
-element_types += [
-    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),
-]
+for n in [8,16,32,64]:
+    element_types += [
+        ElementType(f"Int{n}",  f"Int{n}#",
+                    f"{n}-bit signed integer",   n // 8),
+        ElementType(f"Word{n}", f"Word{n}#",
+                    f"{n}-bit unsigned integer", n // 8)
+    ]
 
 def pretty_offset(n: Optional[int]) -> str:
     if n == MACH_WORD:
@@ -57,87 +68,134 @@ def pretty_offset(n: Optional[int]) -> str:
     else:
         return f'{n}-byte words'
 
+def get_align_warn(n: ElementType) -> str:
+    if n.width == 1:
+        return ''
+    return '''
+        On some platforms, the access may fail
+        for an insufficiently aligned @Addr#@.
+    '''
+
 def print_block(template: str, **kwargs) -> None:
-    print(textwrap.dedent(template.format(**kwargs)).lstrip())
+    write(textwrap.dedent(template.format(**kwargs)).lstrip())
+    write('\n')
 
 def header(s: str):
-    print('')
+    write('\n')
     print_block('''
         ------------------------------------
         -- {s}
         ------------------------------------
     ''', s=s)
 
+if args.addr_or_bytearray == "bytearray-access-ops":
+    header("ByteArray# operations")
 
-header("ByteArray# operations")
-
-print('''
--- Do not edit. This file is generated by utils/genprimopcode/gen_bytearray_ops.py.
--- To regenerate run,
---
---      python3 utils/genprimops/gen_bytearray_ops.py > compiler/GHC/Builtin/bytearray-ops.txt.pp
-''')
-
-header('aligned index operations')
-for t in element_types:
-    offset = pretty_offset(t.width)
-    print_block('''
+    header('aligned index operations')
+    for t in element_types:
+        offset = pretty_offset(t.width)
+        print_block('''
         primop IndexByteArrayOp_{name} "index{name}Array#" GenPrimOp
            ByteArray# -> Int# -> {rep_ty}
            {{Read a {desc}; offset in {offset}.}}
            with can_fail = True
-    ''', offset = offset, **t._asdict())
+        ''', offset = offset, **t._asdict())
 
-header('unaligned index operations')
-for t in element_types:
-    if t.name in ['Int8', 'Word8']: continue
-    print_block('''
+    header('unaligned index operations')
+    for t in element_types:
+        if t.name in ['Int8', 'Word8']: continue
+        print_block('''
         primop IndexByteArrayOp_Word8As{name} "indexWord8ArrayAs{name}#" GenPrimOp
            ByteArray# -> Int# -> {rep_ty}
            {{Read a {desc}; offset in bytes.}}
            with can_fail = True
-    ''', **t._asdict())
+        ''', **t._asdict())
 
-header('aligned read operations')
-for t in element_types:
-    offset = pretty_offset(t.width)
-    print_block('''
+    header('aligned read operations')
+    for t in element_types:
+        offset = pretty_offset(t.width)
+        print_block('''
         primop ReadByteArrayOp_{name} "read{name}Array#" GenPrimOp
            MutableByteArray# s -> Int# -> State# s -> (# State# s, {rep_ty} #)
            {{Read a {desc}; offset in {offset}.}}
            with has_side_effects = True
                 can_fail = True
-    ''', offset = offset, **t._asdict())
+        ''', offset = offset, **t._asdict())
 
-header('unaligned read operations')
-for t in element_types:
-    if t.name in ['Int8', 'Word8']: continue
-    print_block('''
+    header('unaligned read operations')
+    for t in element_types:
+        if t.name in ['Int8', 'Word8']: continue
+        print_block('''
         primop ReadByteArrayOp_Word8As{name} "readWord8ArrayAs{name}#" GenPrimOp
            MutableByteArray# s -> Int# -> State# s -> (# State# s, {rep_ty} #)
            {{Read a {desc}; offset in bytes.}}
            with has_side_effects = True
                 can_fail = True
-    ''', **t._asdict())
+        ''', **t._asdict())
 
-header('aligned write operations')
-for t in element_types:
-    offset = pretty_offset(t.width)
-    print_block('''
+    header('aligned write operations')
+    for t in element_types:
+        offset = pretty_offset(t.width)
+        print_block('''
         primop WriteByteArrayOp_{name} "write{name}Array#" GenPrimOp
            MutableByteArray# s -> Int# -> {rep_ty} -> State# s -> State# s
            {{Write a {desc}; offset in {offset}.}}
            with has_side_effects = True
                 can_fail = True
-    ''', offset = offset, **t._asdict())
+        ''', offset = offset, **t._asdict())
 
-header('unaligned write operations')
-for t in element_types:
-    if t.name in ['Int8', 'Word8']: continue
-    print_block('''
+    header('unaligned write operations')
+    for t in element_types:
+        if t.name in ['Int8', 'Word8']: continue
+        print_block('''
         primop WriteByteArrayOp_Word8As{name} "writeWord8ArrayAs{name}#" GenPrimOp
            MutableByteArray# s -> Int# -> {rep_ty} -> State# s -> State# s
            {{Write a {desc}; offset in bytes.}}
            with has_side_effects = True
                 can_fail = True
-    ''', **t._asdict())
+        ''', **t._asdict())
+
+
+else: # addr_or_bytearray == "addr-access-ops":
+    header("Addr# access operations")
+
+    header('aligned index operations')
+    for t in element_types:
+        offset = pretty_offset(t.width)
+        align_warn = get_align_warn(t)
+        print_block('''
+        primop IndexOffAddrOp_{name} "index{name}OffAddr#" GenPrimOp
+           Addr# -> Int# -> {rep_ty}
+           {{ Read a {desc}; offset in {offset}.
+              {align_warn}
+           }}
+           with can_fail = True
+        ''', offset = offset, align_warn = align_warn, **t._asdict())
+
+    header('aligned read operations')
+    for t in element_types:
+        offset = pretty_offset(t.width)
+        align_warn = get_align_warn(t)
+        print_block('''
+        primop ReadOffAddrOp_{name} "read{name}OffAddr#" GenPrimOp
+           Addr# -> Int# -> State# s -> (# State# s, {rep_ty} #)
+           {{ Read a {desc}; offset in {offset}.
+              {align_warn}
+           }}
+           with has_side_effects = True
+                can_fail = True
+        ''', offset = offset, align_warn = align_warn, **t._asdict())
+
+    header('aligned write operations')
+    for t in element_types:
+        offset = pretty_offset(t.width)
+        align_warn = get_align_warn(t)
+        print_block('''
+        primop WriteOffAddrOp_{name} "write{name}OffAddr#" GenPrimOp
+           Addr# -> Int# -> {rep_ty} -> State# s -> State# s
+           {{ Write a {desc}; offset in {offset}.
+              {align_warn}
+           }}
+           with has_side_effects = True
+                can_fail = True
+        ''', offset = offset, align_warn = align_warn, **t._asdict())


=====================================
compiler/GHC/Builtin/primops.txt.pp
=====================================
@@ -1941,7 +1941,7 @@ primop  GetSizeofMutableByteArrayOp "getSizeofMutableByteArray#" GenPrimOp
 
    @since 0.5.0.0}
 
-#include "bytearray-ops.txt.pp"
+#include "bytearray-access-ops.txt.pp"
 
 primop  CompareByteArraysOp "compareByteArrays#" GenPrimOp
    ByteArray# -> Int# -> ByteArray# -> Int# -> Int# -> Int#
@@ -2242,233 +2242,7 @@ primop   AddrNeOp  "neAddr#"   Compare   Addr# -> Addr# -> Int#
 primop   AddrLtOp  "ltAddr#"   Compare   Addr# -> Addr# -> Int#
 primop   AddrLeOp  "leAddr#"   Compare   Addr# -> Addr# -> Int#
 
-primop IndexOffAddrOp_Char "indexCharOffAddr#" GenPrimOp
-   Addr# -> Int# -> Char#
-   {Reads 8-bit character; offset in bytes.}
-   with can_fail = True
-
-primop IndexOffAddrOp_WideChar "indexWideCharOffAddr#" GenPrimOp
-   Addr# -> Int# -> Char#
-   {Reads 31-bit character; offset in 4-byte words.}
-   with can_fail = True
-
-primop IndexOffAddrOp_Int "indexIntOffAddr#" GenPrimOp
-   Addr# -> Int# -> Int#
-   with can_fail = True
-
-primop IndexOffAddrOp_Word "indexWordOffAddr#" GenPrimOp
-   Addr# -> Int# -> Word#
-   with can_fail = True
-
-primop IndexOffAddrOp_Addr "indexAddrOffAddr#" GenPrimOp
-   Addr# -> Int# -> Addr#
-   with can_fail = True
-
-primop IndexOffAddrOp_Float "indexFloatOffAddr#" GenPrimOp
-   Addr# -> Int# -> Float#
-   with can_fail = True
-
-primop IndexOffAddrOp_Double "indexDoubleOffAddr#" GenPrimOp
-   Addr# -> Int# -> Double#
-   with can_fail = True
-
-primop IndexOffAddrOp_StablePtr "indexStablePtrOffAddr#" GenPrimOp
-   Addr# -> Int# -> StablePtr# a
-   with can_fail = True
-
-primop IndexOffAddrOp_Int8 "indexInt8OffAddr#" GenPrimOp
-   Addr# -> Int# -> Int8#
-   with can_fail = True
-
-primop IndexOffAddrOp_Int16 "indexInt16OffAddr#" GenPrimOp
-   Addr# -> Int# -> Int16#
-   with can_fail = True
-
-primop IndexOffAddrOp_Int32 "indexInt32OffAddr#" GenPrimOp
-   Addr# -> Int# -> Int32#
-   with can_fail = True
-
-primop IndexOffAddrOp_Int64 "indexInt64OffAddr#" GenPrimOp
-   Addr# -> Int# -> Int64#
-   with can_fail = True
-
-primop IndexOffAddrOp_Word8 "indexWord8OffAddr#" GenPrimOp
-   Addr# -> Int# -> Word8#
-   with can_fail = True
-
-primop IndexOffAddrOp_Word16 "indexWord16OffAddr#" GenPrimOp
-   Addr# -> Int# -> Word16#
-   with can_fail = True
-
-primop IndexOffAddrOp_Word32 "indexWord32OffAddr#" GenPrimOp
-   Addr# -> Int# -> Word32#
-   with can_fail = True
-
-primop IndexOffAddrOp_Word64 "indexWord64OffAddr#" GenPrimOp
-   Addr# -> Int# -> Word64#
-   with can_fail = True
-
-primop ReadOffAddrOp_Char "readCharOffAddr#" GenPrimOp
-   Addr# -> Int# -> State# s -> (# State# s, Char# #)
-   {Reads 8-bit character; offset in bytes.}
-   with has_side_effects = True
-        can_fail         = True
-
-primop ReadOffAddrOp_WideChar "readWideCharOffAddr#" GenPrimOp
-   Addr# -> Int# -> State# s -> (# State# s, Char# #)
-   {Reads 31-bit character; offset in 4-byte words.}
-   with has_side_effects = True
-        can_fail         = True
-
-primop ReadOffAddrOp_Int "readIntOffAddr#" GenPrimOp
-   Addr# -> Int# -> State# s -> (# State# s, Int# #)
-   with has_side_effects = True
-        can_fail         = True
-
-primop ReadOffAddrOp_Word "readWordOffAddr#" GenPrimOp
-   Addr# -> Int# -> State# s -> (# State# s, Word# #)
-   with has_side_effects = True
-        can_fail         = True
-
-primop ReadOffAddrOp_Addr "readAddrOffAddr#" GenPrimOp
-   Addr# -> Int# -> State# s -> (# State# s, Addr# #)
-   with has_side_effects = True
-        can_fail         = True
-
-primop ReadOffAddrOp_Float "readFloatOffAddr#" GenPrimOp
-   Addr# -> Int# -> State# s -> (# State# s, Float# #)
-   with has_side_effects = True
-        can_fail         = True
-
-primop ReadOffAddrOp_Double "readDoubleOffAddr#" GenPrimOp
-   Addr# -> Int# -> State# s -> (# State# s, Double# #)
-   with has_side_effects = True
-        can_fail         = True
-
-primop ReadOffAddrOp_StablePtr "readStablePtrOffAddr#" GenPrimOp
-   Addr# -> Int# -> State# s -> (# State# s, StablePtr# a #)
-   with has_side_effects = True
-        can_fail         = True
-
-primop ReadOffAddrOp_Int8 "readInt8OffAddr#" GenPrimOp
-   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, Int16# #)
-   with has_side_effects = True
-        can_fail         = True
-
-primop ReadOffAddrOp_Int32 "readInt32OffAddr#" GenPrimOp
-   Addr# -> Int# -> State# s -> (# State# s, Int32# #)
-   with has_side_effects = True
-        can_fail         = True
-
-primop ReadOffAddrOp_Int64 "readInt64OffAddr#" GenPrimOp
-   Addr# -> Int# -> State# s -> (# State# s, Int64# #)
-   with has_side_effects = True
-        can_fail         = True
-
-primop ReadOffAddrOp_Word8 "readWord8OffAddr#" GenPrimOp
-   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, Word16# #)
-   with has_side_effects = True
-        can_fail         = True
-
-primop ReadOffAddrOp_Word32 "readWord32OffAddr#" GenPrimOp
-   Addr# -> Int# -> State# s -> (# State# s, Word32# #)
-   with has_side_effects = True
-        can_fail         = True
-
-primop ReadOffAddrOp_Word64 "readWord64OffAddr#" GenPrimOp
-   Addr# -> Int# -> State# s -> (# State# s, Word64# #)
-   with has_side_effects = True
-        can_fail         = True
-
-primop  WriteOffAddrOp_Char "writeCharOffAddr#" GenPrimOp
-   Addr# -> Int# -> Char# -> State# s -> State# s
-   with has_side_effects = True
-        can_fail         = True
-
-primop  WriteOffAddrOp_WideChar "writeWideCharOffAddr#" GenPrimOp
-   Addr# -> Int# -> Char# -> State# s -> State# s
-   with has_side_effects = True
-        can_fail         = True
-
-primop  WriteOffAddrOp_Int "writeIntOffAddr#" GenPrimOp
-   Addr# -> Int# -> Int# -> State# s -> State# s
-   with has_side_effects = True
-        can_fail         = True
-
-primop  WriteOffAddrOp_Word "writeWordOffAddr#" GenPrimOp
-   Addr# -> Int# -> Word# -> State# s -> State# s
-   with has_side_effects = True
-        can_fail         = True
-
-primop  WriteOffAddrOp_Addr "writeAddrOffAddr#" GenPrimOp
-   Addr# -> Int# -> Addr# -> State# s -> State# s
-   with has_side_effects = True
-        can_fail         = True
-
-primop  WriteOffAddrOp_Float "writeFloatOffAddr#" GenPrimOp
-   Addr# -> Int# -> Float# -> State# s -> State# s
-   with has_side_effects = True
-        can_fail         = True
-
-primop  WriteOffAddrOp_Double "writeDoubleOffAddr#" GenPrimOp
-   Addr# -> Int# -> Double# -> State# s -> State# s
-   with has_side_effects = True
-        can_fail         = True
-
-primop  WriteOffAddrOp_StablePtr "writeStablePtrOffAddr#" GenPrimOp
-   Addr# -> Int# -> StablePtr# a -> State# s -> State# s
-   with has_side_effects = True
-        can_fail         = True
-
-primop  WriteOffAddrOp_Int8 "writeInt8OffAddr#" GenPrimOp
-   Addr# -> Int# -> Int8# -> State# s -> State# s
-   with has_side_effects = True
-        can_fail         = True
-
-primop  WriteOffAddrOp_Int16 "writeInt16OffAddr#" GenPrimOp
-   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
-   with has_side_effects = True
-        can_fail         = True
-
-primop  WriteOffAddrOp_Int64 "writeInt64OffAddr#" GenPrimOp
-   Addr# -> Int# -> Int64# -> State# s -> State# s
-   with has_side_effects = True
-        can_fail         = True
-
-primop  WriteOffAddrOp_Word8 "writeWord8OffAddr#" GenPrimOp
-   Addr# -> Int# -> Word8# -> State# s -> State# s
-   with has_side_effects = True
-        can_fail         = True
-
-primop  WriteOffAddrOp_Word16 "writeWord16OffAddr#" GenPrimOp
-   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
-   with has_side_effects = True
-        can_fail         = True
-
-primop  WriteOffAddrOp_Word64 "writeWord64OffAddr#" GenPrimOp
-   Addr# -> Int# -> Word64# -> State# s -> State# s
-   with has_side_effects = True
-        can_fail         = True
+#include "addr-access-ops.txt.pp"
 
 primop  InterlockedExchange_Addr "atomicExchangeAddrAddr#" GenPrimOp
    Addr# -> Addr# -> State# s -> (# State# s, Addr# #)


=====================================
compiler/GHC/Hs/Binds.hs
=====================================
@@ -1,5 +1,6 @@
 {-# LANGUAGE CPP #-}
 {-# LANGUAGE ConstraintKinds #-}
+{-# LANGUAGE DataKinds #-}
 {-# LANGUAGE DeriveDataTypeable #-}
 {-# LANGUAGE FlexibleContexts #-}
 {-# LANGUAGE FlexibleInstances #-}
@@ -120,7 +121,11 @@ type instance XPatBind    GhcTc (GhcPass pR) =
     , ( [CoreTickish]       -- Ticks to put on the rhs, if any
       , [[CoreTickish]] ) ) -- and ticks to put on the bound variables.
 
-type instance XVarBind    (GhcPass pL) (GhcPass pR) = NoExtField
+type instance XVarBind (GhcPass pL) (GhcPass pR) = XVarBindGhc pL pR
+type family XVarBindGhc pL pR where
+  XVarBindGhc 'Typechecked 'Typechecked = NoExtField
+  XVarBindGhc _     _                   = DataConCantHappen
+
 type instance XPatSynBind (GhcPass pL) (GhcPass pR) = NoExtField
 
 type instance XXHsBindsLR GhcPs pR = DataConCantHappen


=====================================
compiler/GHC/Hs/Utils.hs
=====================================
@@ -819,7 +819,7 @@ mkTopFunBind origin fn ms = FunBind { fun_id = fn
 mkHsVarBind :: SrcSpan -> RdrName -> LHsExpr GhcPs -> LHsBind GhcPs
 mkHsVarBind loc var rhs = mkSimpleGeneratedFunBind loc var [] rhs
 
-mkVarBind :: IdP (GhcPass p) -> LHsExpr (GhcPass p) -> LHsBind (GhcPass p)
+mkVarBind :: IdP GhcTc -> LHsExpr GhcTc -> LHsBind GhcTc
 mkVarBind var rhs = L (getLoc rhs) $
                     VarBind { var_ext = noExtField,
                               var_id = var, var_rhs = rhs }


=====================================
compiler/GHC/HsToCore/Quote.hs
=====================================
@@ -1931,15 +1931,6 @@ rep_bind (L loc (PatBind { pat_lhs = pat
         ; ans' <- wrapGenSyms ss ans
         ; return (locA loc, ans') }
 
-rep_bind (L _ (VarBind { var_id = v, var_rhs = e}))
- =   do { v' <- lookupBinder v
-        ; e2 <- repLE e
-        ; x <- repNormal e2
-        ; patcore <- repPvar v'
-        ; empty_decls <- coreListM decTyConName []
-        ; ans <- repVal patcore x empty_decls
-        ; return (srcLocSpan (getSrcLoc v), ans) }
-
 rep_bind (L loc (PatSynBind _ (PSB { psb_id   = syn
                                    , psb_args = args
                                    , psb_def  = pat
@@ -1978,6 +1969,8 @@ rep_bind (L loc (PatSynBind _ (PSB { psb_id   = syn
     wrapGenArgSyms (RecCon _) _  dec = return dec
     wrapGenArgSyms _          ss dec = wrapGenSyms ss dec
 
+rep_bind (L _ (VarBind { var_ext = x })) = dataConCantHappen x
+
 repPatSynD :: Core TH.Name
            -> Core (M TH.PatSynArgs)
            -> Core (M TH.PatSynDir)


=====================================
compiler/GHC/Rename/Bind.hs
=====================================
@@ -542,7 +542,7 @@ rnBind sig_fn (PatSynBind x bind)
   = do  { (bind', name, fvs) <- rnPatSynBind sig_fn bind
         ; return (PatSynBind x bind', name, fvs) }
 
-rnBind _ b@(VarBind {}) = pprPanic "rnBind" (ppr b)
+rnBind _ (VarBind { var_ext = x }) = dataConCantHappen x
 
  -- See Note [Pattern bindings that bind no variables]
 isOkNoBindPattern :: LPat GhcRn -> Bool


=====================================
compiler/GHC/Tc/Gen/Bind.hs
=====================================
@@ -780,11 +780,12 @@ checkMonomorphismRestriction mbis lbinds
     no_mr_name _ = Nothing
 
     -- The Haskell 98 monomorphism restriction
+    restricted :: HsBindLR GhcRn GhcRn -> Bool
     restricted (PatBind {})                              = True
-    restricted (VarBind { var_id = v })                  = mr_needed_for v
     restricted (FunBind { fun_id = v, fun_matches = m }) = restricted_match m
                                                            && mr_needed_for (unLoc v)
-    restricted b = pprPanic "isRestrictedGroup/unrestricted" (ppr b)
+    restricted (VarBind { var_ext = x })                 = dataConCantHappen x
+    restricted b@(PatSynBind {}) = pprPanic "isRestrictedGroup/unrestricted" (ppr b)
 
     restricted_match mg = matchGroupArity mg == 0
         -- No args => like a pattern binding
@@ -1518,8 +1519,10 @@ tcLhs sig_fn no_gen (PatBind { pat_lhs = pat, pat_rhs = grhss })
                       Just (TcIdSig sig) -> Right (name, sig)
                       _                  -> Left name
 
-tcLhs _ _ other_bind = pprPanic "tcLhs" (ppr other_bind)
-        -- AbsBind, VarBind impossible
+tcLhs _ _ b@(PatSynBind {}) = pprPanic "tcLhs: PatSynBind" (ppr b)
+  -- pattern synonyms are handled separately; see tc_single
+
+tcLhs _ _ (VarBind { var_ext = x }) = dataConCantHappen x
 
 lookupMBI :: Name -> TcM MonoBindInfo
 -- After typechecking the pattern, look up the binder


=====================================
hadrian/src/Rules/Generate.hs
=====================================
@@ -32,6 +32,17 @@ primopsSource = "compiler/GHC/Builtin/primops.txt.pp"
 primopsTxt :: Stage -> FilePath
 primopsTxt stage = buildDir (vanillaContext stage compiler) -/- "primops.txt"
 
+accessOpsSource :: FilePath
+accessOpsSource = "compiler/GHC/Builtin/gen_bytearray_addr_access_ops.py"
+
+byteArrayAccessOpsTxt :: Stage -> FilePath
+byteArrayAccessOpsTxt stage
+  = buildDir (vanillaContext stage compiler) -/- "bytearray-access-ops.txt.pp"
+
+addrAccessOpsTxt :: Stage -> FilePath
+addrAccessOpsTxt stage
+  = buildDir (vanillaContext stage compiler) -/- "addr-access-ops.txt.pp"
+
 isGeneratedCmmFile :: FilePath -> Bool
 isGeneratedCmmFile file = takeBaseName file == "AutoApply"
 
@@ -142,8 +153,21 @@ generatePackageCode context@(Context stage pkg _ _) = do
             root -/- "**" -/- dir -/- "GHC/Platform/Host.hs" %> go generatePlatformHostHs
 
     when (pkg == compiler) $ do
+        let ba_ops_txt = root -/- byteArrayAccessOpsTxt stage
+        let addr_ops_txt = root -/- addrAccessOpsTxt stage
+        ba_ops_txt %> \file -> do
+            need [accessOpsSource]
+            runBuilder Python
+              [accessOpsSource, "bytearray-access-ops", file]
+              [] []
+        addr_ops_txt %> \file -> do
+            need [accessOpsSource]
+            runBuilder Python
+              [accessOpsSource, "addr-access-ops", file]
+              [] []
         root -/- primopsTxt stage %> \file -> do
-            need $ [primopsSource]
+            need $ [primopsSource, ba_ops_txt, addr_ops_txt]
+            -- ba_ops_txt and addr_ops_txt get #include-d
             build $ target context HsCpp [primopsSource] [file]
 
     when (pkg == rts) $ do


=====================================
rts/gen_event_types.py
=====================================
@@ -157,7 +157,7 @@ def generate_event_types_array() -> str:
     pr = lambda s: x.append(s)
 
     pr('/*')
-    pr(' * Do not edit: This file is generated by event_types.py')
+    pr(' * Do not edit: This file is generated by gen_event_types.py')
     pr(' */')
     pr('')
     pr('EventType eventTypes[] = {')
@@ -184,7 +184,7 @@ def generate_event_types_defines() -> str:
     pr = lambda s: x.append(s)
 
     pr('/*')
-    pr(' * Do not edit: This file is generated by event_types.py')
+    pr(' * Do not edit: This file is generated by gen_event_types.py')
     pr(' */')
     pr('')
     pr('#pragma once')



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/080d54a5b14d788d53bc98d5905e090489e78686...ede1f236c63e4d5c5c1c8c03b52c37656584fa90

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/080d54a5b14d788d53bc98d5905e090489e78686...ede1f236c63e4d5c5c1c8c03b52c37656584fa90
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230606/fd411516/attachment-0001.html>


More information about the ghc-commits mailing list