[GHC] #14872: Hex Literals in GHC Core
#14872: Hex Literals in GHC Core -------------------------------------+------------------------------------- Reporter: andrewthad | Owner: (none) Type: feature | Status: new request | Priority: lowest | Milestone: Component: Compiler | Version: 8.2.2 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: -------------------------------------+------------------------------------- Sometimes, when I'm doing stuff that involves twiddling bits, it would be nicer to see integer literals in hexadecimal when I dump core with `-ddump-simpl`. For example, in a project I'm working on, I've got this: {{{ detectNull :: Word -> Word detectNull x = (x - repeatHexZeroOne) .&. complement x .&. repeatHexEightZero detectArtifact :: Word -> Word -> Word detectArtifact x artifact = detectNull (applyArtifact x artifact) applyArtifact :: Word -> Word -> Word applyArtifact = xor repeatHexZeroOne :: Word repeatHexZeroOne = div maxBound 255 repeatHexEightZero :: Word repeatHexEightZero = 128 * (div maxBound 255 :: Word) }}} Once everything gets unboxed and constant-folding happens, in GHC core, the places where I used `repeatHexZeroOne` show `72340172838076673##` (on a 64-bit machine). This is accurate, but it would be nice I could give a flag to make it show `0x0101010101010101##` instead. This would make it easier for me to confirm that the arithmetic I used to generate a bit pattern actually generated what I thought it did. Admittedly, we'd probably want leading zeroes to get chopped off so that small integer literals didn't show up with 15 zeroes in front of them. So, realistically, it might show up as `0x101010101010101##`. Or maybe it could always to padded with leading zeroes until the length was a power of two. Anyway, not important, but I thought it would be nice to have. Possible flag name: `-ddump-hex-literals`. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14872> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14872: Hex Literals in GHC Core -------------------------------------+------------------------------------- Reporter: andrewthad | Owner: (none) Type: feature request | Status: new Priority: lowest | Milestone: Component: Compiler | Version: 8.2.2 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 simonpj): Fine with me. Maybe `Word#` should ''always'' be shown in hex? But yes, a flag to control is always good. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14872#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14872: Hex Literals in GHC Core -------------------------------------+------------------------------------- Reporter: andrewthad | Owner: (none) Type: feature request | Status: new Priority: lowest | Milestone: Component: Compiler | Version: 8.2.2 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by mpickering): * keywords: => newcomer -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14872#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14872: Hex Literals in GHC Core -------------------------------------+------------------------------------- Reporter: andrewthad | Owner: (none) Type: feature request | Status: new Priority: lowest | Milestone: Component: Compiler | Version: 8.2.2 Resolution: | Keywords: newcomer 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 andrewthad): I'm working on this now. I should have something up on phabricator soon. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14872#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14872: Hex Literals in GHC Core -------------------------------------+------------------------------------- Reporter: andrewthad | Owner: andrewthad Type: feature request | Status: new Priority: lowest | Milestone: Component: Compiler | Version: 8.2.2 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by ulysses4ever): * owner: (none) => andrewthad -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14872#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14872: Hex Literals in GHC Core -------------------------------------+------------------------------------- Reporter: andrewthad | Owner: andrewthad Type: feature request | Status: new Priority: lowest | Milestone: Component: Compiler | Version: 8.2.2 Resolution: | Keywords: newcomer 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 andrewthad): I went ahead and pushed it up to github in case I somehow destroy it by accident: https://github.com/andrewthad/ghc/tree/dump-word-hex-literals I'll get this on phabricator soon. I'm getting a weird linking error late in compilation, but I suspect that's from failing to update submodules. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14872#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14872: Hex Literals in GHC Core -------------------------------------+------------------------------------- Reporter: andrewthad | Owner: andrewthad Type: feature request | Status: new Priority: lowest | Milestone: Component: Compiler | Version: 8.2.2 Resolution: | Keywords: newcomer 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 andrewthad): In case anyone has seen this error before: {{{ "@LdNoGoldCmd@" -r -o libraries/ghc-prim/dist-install/build/HSghc- prim-0.5.2.0.o libraries/ghc-prim/dist-install/build/GHC/CString.o libraries/ghc-prim/dist-install/build/GHC/Classes.o libraries/ghc-prim /dist-install/build/GHC/Debug.o libraries/ghc-prim/dist- install/build/GHC/IntWord64.o libraries/ghc-prim/dist- install/build/GHC/Magic.o libraries/ghc-prim/dist- install/build/GHC/PrimopWrappers.o libraries/ghc-prim/dist- install/build/GHC/Tuple.o libraries/ghc-prim/dist- install/build/GHC/Types.o libraries/ghc-prim/dist- install/build/cbits/atomic.o libraries/ghc-prim/dist- install/build/cbits/bswap.o libraries/ghc-prim/dist- install/build/cbits/clz.o libraries/ghc-prim/dist- install/build/cbits/ctz.o libraries/ghc-prim/dist- install/build/cbits/debug.o libraries/ghc-prim/dist- install/build/cbits/longlong.o libraries/ghc-prim/dist- install/build/cbits/pdep.o libraries/ghc-prim/dist- install/build/cbits/pext.o libraries/ghc-prim/dist- install/build/cbits/popcnt.o libraries/ghc-prim/dist- install/build/cbits/word2float.o /bin/bash: @LdNoGoldCmd@: command not found libraries/ghc-prim/ghc.mk:4: recipe for target 'libraries/ghc-prim/dist- install/build/HSghc-prim-0.5.2.0.o' failed }}} I'll try blowing out the directory later today and reapplying the patch to master if this isn't something that anyone else knows a simple fix for. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14872#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14872: Hex Literals in GHC Core -------------------------------------+------------------------------------- Reporter: andrewthad | Owner: andrewthad Type: feature request | Status: new Priority: lowest | Milestone: Component: Compiler | Version: 8.2.2 Resolution: | Keywords: newcomer 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 andrewthad): Differential is on phabricator now: https://phabricator.haskell.org/D4465 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14872#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14872: Hex Literals in GHC Core -------------------------------------+------------------------------------- Reporter: andrewthad | Owner: andrewthad Type: feature request | Status: new Priority: lowest | Milestone: Component: Compiler | Version: 8.2.2 Resolution: | Keywords: newcomer 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 Ben Gamari <ben@…>): In [changeset:"a00b88b9a27736c9c41f1921fcb6b7759ad8425e/ghc" a00b88b/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="a00b88b9a27736c9c41f1921fcb6b7759ad8425e" Implement -dword-hex-literals Provide flag for showing showing Word# and Word64# as hexadecimal when dumping GHC core. The only affects Word, not Int, and it prefixes the hexadecimal with enough zeroes to make the total character count a power of two. For example: - 0x0C0C instead of 0xC0C - 0x00BA00BA instead of 0xBA00BA This also affects the presentation of Word# and Word64# in GHC's error messages. It is not expected that the flag will be used for this, but it is a side-effect worth noting. Test Plan: none Reviewers: bgamari, simonpj Reviewed By: simonpj Subscribers: simonpj, mpickering, rwbarton, thomie, carter, andrewthad GHC Trac Issues: #14872 Differential Revision: https://phabricator.haskell.org/D4465 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14872#comment:8> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#14872: Hex Literals in GHC Core -------------------------------------+------------------------------------- Reporter: andrewthad | Owner: andrewthad Type: feature request | Status: closed Priority: lowest | Milestone: 8.6.1 Component: Compiler | Version: 8.2.2 Resolution: fixed | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => closed * resolution: => fixed * milestone: => 8.6.1 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14872#comment:9> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC