[GHC] #15486: primops.txt.pp still has support for WORD_SIZE_IN_BITS < 32

Haskell98 specifies that signed integers (type `Int` must contain at least 30 bits. GHC always implements `Int` using the primitive type `Int#`, whose size equals the `MachDeps.h` constant `WORD_SIZE_IN_BITS`.
This is normally set based on the `config.h` parameter `SIZEOF_HSWORD`, i.e., 32 bits on 32-bit machines, 64 bits on 64-bit machines. However, it can also be explicitly set to a smaller number, e.g., 31 bits, to allow
#15486: primops.txt.pp still has support for WORD_SIZE_IN_BITS < 32 -------------------------------------+------------------------------------- Reporter: ChaiTRex | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Was support for `WORD_SIZE_IN_BITS < 32` dropped? According to [https://github.com/ghc/ghc/commit/b38f08350d5c0efaa613f2f6c67dad5366aac271 this GHC commit], it appears that that support was dropped about seven years ago. Also, `find -type f | xargs -n 5 egrep 'WORD_SIZE_IN_BITS\s*<\s*32'` only finds mention of it in `primops.txt.pp`. If support for that was dropped, [https://github.com/ghc/ghc/blob/9897f6783a58265d5eaef5fb06f04320c7737e87/com... the current version of compiler/prelude/primops.txt.pp] has dead code and misleading documentation (that's apparently propagated to [https://hackage.haskell.org/package/ghc-prim-0.5.2.0/docs/GHC-Prim.html GHC.Prim documentation]) that might cause programmers to expend unnecessary effort supporting `WORD_SIZE_IN_BITS < 32` in their own code. The following documentation describes a situation that can no longer happen and continues on incorrectly past these two paragraphs: the possibility of using tag bits. Currently GHC itself has only 32-bit and 64-bit variants, '''but 30 or 31-bit code can be exported as an external core file for use in other back ends'''. The following is dead code. Further, `INT32` and `WORD32` throughout the document should be replaced with `Int#` and `Word#`: {{{#!c #if WORD_SIZE_IN_BITS < 32 #define INT32 Int32# #define WORD32 Word32# #else #define INT32 Int# #define WORD32 Word# #endif }}} Also, all code inclusively between `#if WORD_SIZE_IN_BITS < 32` lines and their matching `#endif`s can be eliminated. ---- On the other hand, if `WORD_SIZE_IN_BITS < 32` '''is''' still supported, there are a lot of cases wherein a 64-bit version of an instruction uses `INT64` or `WORD64` in its type signature, but the 32-bit version uses `Int#` or `Word#`, which robs programmers of the ability to use speedy hardware instructions on full untagged `Int32#`s or `Word32#`s. Also, the `Double#` decoder to two `Word#`s for the mantissa assumes that the `Word#`s can hold a full 32 bits according to its documentation. There are some other problems that I've forgotten as well. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15486 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15486: primops.txt.pp still has support for WORD_SIZE_IN_BITS < 32 -------------------------------------+------------------------------------- Reporter: ChaiTRex | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): I'm pretty certain any recent GHC would blow up spectacularly if you somehow managed to compile it on a `WORD_SIZE_IN_BITS < 32` platform. We ought to drop the dead code. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15486#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15486: primops.txt.pp still has support for WORD_SIZE_IN_BITS < 32 -------------------------------------+------------------------------------- Reporter: ChaiTRex | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5050 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => patch * differential: => Phab:D5050 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15486#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15486: primops.txt.pp still has support for WORD_SIZE_IN_BITS < 32
-------------------------------------+-------------------------------------
Reporter: ChaiTRex | Owner: (none)
Type: bug | Status: patch
Priority: normal | Milestone: 8.6.1
Component: Compiler | Version: 8.4.3
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D5050
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Krzysztof Gogolewski

#15486: primops.txt.pp still has support for WORD_SIZE_IN_BITS < 32 -------------------------------------+------------------------------------- Reporter: ChaiTRex | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5050 Wiki Page: | -------------------------------------+------------------------------------- Changes (by monoidal): * status: patch => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15486#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC