[commit: ghc] master: UNREG: PprC: add support for of W32 literals (0238a6c)

git at git.haskell.org git at git.haskell.org
Thu Jun 14 14:05:43 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/0238a6c78102d43dae2f56192bd3486e4f9ecf1d/ghc

>---------------------------------------------------------------

commit 0238a6c78102d43dae2f56192bd3486e4f9ecf1d
Author: Sergei Trofimovich <slyfox at gentoo.org>
Date:   Thu Jun 14 09:13:32 2018 -0400

    UNREG: PprC: add support for of W32 literals
    
    Today UNREG build fails to generate sub-word literals:
    ```
      rts_dist_HC rts/dist/build/StgStartup.o
    ghc-stage1: panic! (the 'impossible' happened)
      (GHC version 8.5.20180612 for x86_64-unknown-linux):
            pprStatics: cannot emit a non-word-sized static literal
      W32
    ```
    
    The change allows combining two subwords into one word.
    
    Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org>
    
    Reviewers: simonmar, bgamari
    
    Reviewed By: bgamari
    
    Subscribers: rwbarton, thomie, carter
    
    GHC Trac Issues: #15237
    
    Differential Revision: https://phabricator.haskell.org/D4837


>---------------------------------------------------------------

0238a6c78102d43dae2f56192bd3486e4f9ecf1d
 compiler/cmm/PprC.hs | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/compiler/cmm/PprC.hs b/compiler/cmm/PprC.hs
index e8f7144..e46fff1 100644
--- a/compiler/cmm/PprC.hs
+++ b/compiler/cmm/PprC.hs
@@ -538,6 +538,14 @@ pprStatics dflags (CmmStaticLit (CmmInt i W64) : rest)
                             CmmStaticLit (CmmInt q W32) : rest)
   where r = i .&. 0xffffffff
         q = i `shiftR` 32
+pprStatics dflags (CmmStaticLit (CmmInt a W32) :
+                   CmmStaticLit (CmmInt b W32) : rest)
+  | wordWidth dflags == W64
+  = if wORDS_BIGENDIAN dflags
+    then pprStatics dflags (CmmStaticLit (CmmInt ((shiftL a 32) .|. b) W64) :
+                            rest)
+    else pprStatics dflags (CmmStaticLit (CmmInt ((shiftL b 32) .|. a) W64) :
+                            rest)
 pprStatics dflags (CmmStaticLit (CmmInt _ w) : _)
   | w /= wordWidth dflags
   = pprPanic "pprStatics: cannot emit a non-word-sized static literal" (ppr w)



More information about the ghc-commits mailing list