When iselExpr64 (CmmLit (CmmInt i _)) is used?

Karel Gardas karel.gardas at centrum.cz
Sat Mar 1 18:12:18 UTC 2014


Hello,

I'm trying to resurrect SPARC NCG. I've switched it on and basically 
provided functions on which NCG has panic during the build, basically 
just 2 were missing so far (cut from git diff):

+genCCall (PrimTarget MO_Touch) _ _
+ = return $ nilOL
+


+iselExpr64 (CmmLit (CmmInt i _)) = do
+  (rlo, rhi) <- getNewRegPairNat II32
+  let
+      half0 = fromIntegral (fromIntegral i :: Word32)
+      half1 = fromIntegral (fromIntegral (i `shiftR` 32) :: Word32)
+      code = toOL [
+              SETHI (HI $ ImmInt half0) rlo,
+              OR False rlo (RIImm (LO $ ImmInt half0)) rlo,
+              SETHI (HI $ ImmInt half1) rhi,
+              OR False rhi (RIImm (LO $ ImmInt half1)) rhi
+             ]
+  return (ChildCode64 code rlo)


Now, my ghc-stage2 badly fails and testsuite run with stage=1 reveals 
1390 unexpected failures. Perhaps this is unrelated, but still I'd like 
to test that my iselExpr64 implementation above is correct. Is there any 
simple haskell code which makes this function in NCG run? I'm trying this:

import GHC.Prim
import GHC.Exts

main = do
         let x = 18446744073709551615#
         --- 2^64-1 = 18446744073709551615
         putStrLn (show $ I# x)
         return()


I've had a hope that unboxed long int constant is what causes iselExpr64 
being called, but generated assembly looks suspicious -- like it's not 
called so my idea was wrong here probably. Do you have any idea how to 
test this function and see its generated assembly?

BTW: I hope I got the function semantics correct as a loading of 64bit 
constant/integer into a pair of 32bits registers...

Thanks a lot!
Karel



More information about the ghc-devs mailing list