diff options
author | Alex Dzyoba <alex@dzyoba.com> | 2016-05-20 20:28:38 +0000 |
---|---|---|
committer | Austin Seipp <austin@well-typed.com> | 2016-05-20 20:28:49 +0000 |
commit | 43589f5cad0926ec077214e7a21a27ef7a8cfe25 (patch) | |
tree | b863cb0c53c8a309a3604c95b0046ab4fe494573 | |
parent | 08e47ca9849ab986d0367746a003754fcf0d4176 (diff) | |
download | haskell-43589f5cad0926ec077214e7a21a27ef7a8cfe25.tar.gz |
testsuite: add CmmSwitchTest for 32-bit platforms
Move CmmSwitchTest to CmmSwitchTest64, because it's broken on 32-bit
platforms. Create CmmSwitchTest32 that repeats CmmSwitchTest64 for
platforms with 32-bit wordsize.
Reviewed By: nomeata, austin, bgamari, thomie
Differential Revision: https://phabricator.haskell.org/D2226
GHC Trac Issues: #11297
-rw-r--r-- | testsuite/tests/codeGen/should_run/CmmSwitchTest32.hs | 791 | ||||
-rw-r--r-- | testsuite/tests/codeGen/should_run/CmmSwitchTest64.hs (renamed from testsuite/tests/codeGen/should_run/CmmSwitchTest.hs) | 342 | ||||
-rw-r--r-- | testsuite/tests/codeGen/should_run/CmmSwitchTestGen.hs | 59 | ||||
-rw-r--r-- | testsuite/tests/codeGen/should_run/all.T | 5 |
4 files changed, 1148 insertions, 49 deletions
diff --git a/testsuite/tests/codeGen/should_run/CmmSwitchTest32.hs b/testsuite/tests/codeGen/should_run/CmmSwitchTest32.hs new file mode 100644 index 0000000000..748d5a0c07 --- /dev/null +++ b/testsuite/tests/codeGen/should_run/CmmSwitchTest32.hs @@ -0,0 +1,791 @@ +-- This file is generated from CmmSwitchTestGen! @generated +{-# LANGUAGE MagicHash, NegativeLiterals #-} +import Control.Monad (unless, forM_) +import GHC.Exts +{-# NOINLINE aa #-} +aa :: Int# -> Int# +aa 1# = 42# +aa 2# = 43# +aa 3# = 43# +aa 4# = 44# +aa 5# = 44# +aa 6# = 45# +aa 7# = 45# +aa 8# = 46# +aa 9# = 46# +aa 10# = 47# +aa _ = 1337# + +{-# NOINLINE ab #-} +ab :: Int# -> Int# +ab 0# = 42# +ab 1# = 42# +ab 2# = 43# +ab 3# = 43# +ab 4# = 44# +ab 5# = 44# +ab 6# = 45# +ab 7# = 45# +ab 8# = 46# +ab 9# = 46# +ab 10# = 47# +ab _ = 1337# + +{-# NOINLINE ac #-} +ac :: Int# -> Int# +ac 1# = 42# +ac 2# = 43# +ac 3# = 43# +ac _ = 1337# + +{-# NOINLINE ad #-} +ad :: Int# -> Int# +ad 1# = 42# +ad 2# = 43# +ad 3# = 43# +ad 4# = 44# +ad _ = 1337# + +{-# NOINLINE ae #-} +ae :: Int# -> Int# +ae 1# = 42# +ae 2# = 43# +ae 3# = 43# +ae 4# = 44# +ae 5# = 44# +ae _ = 1337# + +{-# NOINLINE af #-} +af :: Int# -> Int# +af -1# = 41# +af 0# = 42# +af 1# = 42# +af 2# = 43# +af 3# = 43# +af 4# = 44# +af 5# = 44# +af 6# = 45# +af 7# = 45# +af 8# = 46# +af 9# = 46# +af 10# = 47# +af _ = 1337# + +{-# NOINLINE ag #-} +ag :: Int# -> Int# +ag -10# = 37# +ag -9# = 37# +ag -8# = 38# +ag -7# = 38# +ag -6# = 39# +ag -5# = 39# +ag -4# = 40# +ag -3# = 40# +ag -2# = 41# +ag -1# = 41# +ag 0# = 42# +ag 1# = 42# +ag 2# = 43# +ag 3# = 43# +ag 4# = 44# +ag 5# = 44# +ag 6# = 45# +ag 7# = 45# +ag 8# = 46# +ag 9# = 46# +ag 10# = 47# +ag _ = 1337# + +{-# NOINLINE ah #-} +ah :: Int# -> Int# +ah -20# = 32# +ah -19# = 32# +ah -18# = 33# +ah -17# = 33# +ah -16# = 34# +ah -15# = 34# +ah -14# = 35# +ah -13# = 35# +ah -12# = 36# +ah -11# = 36# +ah -10# = 37# +ah 0# = 42# +ah 1# = 42# +ah 2# = 43# +ah 3# = 43# +ah 4# = 44# +ah 5# = 44# +ah 6# = 45# +ah 7# = 45# +ah 8# = 46# +ah 9# = 46# +ah 10# = 47# +ah _ = 1337# + +{-# NOINLINE ai #-} +ai :: Int# -> Int# +ai -20# = 32# +ai -19# = 32# +ai -18# = 33# +ai -17# = 33# +ai -16# = 34# +ai -15# = 34# +ai -14# = 35# +ai -13# = 35# +ai -12# = 36# +ai -11# = 36# +ai -10# = 37# +ai 1# = 42# +ai 2# = 43# +ai 3# = 43# +ai 4# = 44# +ai 5# = 44# +ai 6# = 45# +ai 7# = 45# +ai 8# = 46# +ai 9# = 46# +ai 10# = 47# +ai _ = 1337# + +{-# NOINLINE aj #-} +aj :: Int# -> Int# +aj -2147483648# = -1073741782# +aj 0# = 42# +aj 2147483647# = 1073741865# +aj _ = 1337# + +{-# NOINLINE ak #-} +ak :: Int# -> Int# +ak 2147483637# = 1073741860# +ak 2147483638# = 1073741861# +ak 2147483639# = 1073741861# +ak 2147483640# = 1073741862# +ak 2147483641# = 1073741862# +ak 2147483642# = 1073741863# +ak 2147483643# = 1073741863# +ak 2147483644# = 1073741864# +ak 2147483645# = 1073741864# +ak 2147483646# = 1073741865# +ak 2147483647# = 1073741865# +ak _ = 1337# + +{-# NOINLINE al #-} +al :: Int# -> Int# +al -2147483648# = -1073741782# +al -2147483647# = -1073741782# +al -2147483646# = -1073741781# +al -2147483645# = -1073741781# +al -2147483644# = -1073741780# +al -2147483643# = -1073741780# +al -2147483642# = -1073741779# +al -2147483641# = -1073741779# +al -2147483640# = -1073741778# +al -2147483639# = -1073741778# +al -2147483638# = -1073741777# +al 2147483637# = 1073741860# +al 2147483638# = 1073741861# +al 2147483639# = 1073741861# +al 2147483640# = 1073741862# +al 2147483641# = 1073741862# +al 2147483642# = 1073741863# +al 2147483643# = 1073741863# +al 2147483644# = 1073741864# +al 2147483645# = 1073741864# +al 2147483646# = 1073741865# +al 2147483647# = 1073741865# +al _ = 1337# + +{-# NOINLINE am #-} +am :: Word# -> Word# +am 0## = 42## +am 1## = 42## +am 2## = 43## +am 3## = 43## +am 4## = 44## +am 5## = 44## +am 6## = 45## +am 7## = 45## +am 8## = 46## +am 9## = 46## +am 10## = 47## +am _ = 1337## + +{-# NOINLINE an #-} +an :: Word# -> Word# +an 1## = 42## +an 2## = 43## +an 3## = 43## +an 4## = 44## +an 5## = 44## +an 6## = 45## +an 7## = 45## +an 8## = 46## +an 9## = 46## +an 10## = 47## +an _ = 1337## + +{-# NOINLINE ao #-} +ao :: Word# -> Word# +ao 0## = 42## +ao _ = 1337## + +{-# NOINLINE ap #-} +ap :: Word# -> Word# +ap 0## = 42## +ap 1## = 42## +ap _ = 1337## + +{-# NOINLINE aq #-} +aq :: Word# -> Word# +aq 0## = 42## +aq 1## = 42## +aq 2## = 43## +aq _ = 1337## + +{-# NOINLINE ar #-} +ar :: Word# -> Word# +ar 0## = 42## +ar 1## = 42## +ar 2## = 43## +ar 3## = 43## +ar _ = 1337## + +{-# NOINLINE as #-} +as :: Word# -> Word# +as 0## = 42## +as 1## = 42## +as 2## = 43## +as 3## = 43## +as 4## = 44## +as _ = 1337## + +{-# NOINLINE at #-} +at :: Word# -> Word# +at 1## = 42## +at _ = 1337## + +{-# NOINLINE au #-} +au :: Word# -> Word# +au 1## = 42## +au 2## = 43## +au _ = 1337## + +{-# NOINLINE av #-} +av :: Word# -> Word# +av 1## = 42## +av 2## = 43## +av 3## = 43## +av _ = 1337## + +{-# NOINLINE aw #-} +aw :: Word# -> Word# +aw 1## = 42## +aw 2## = 43## +aw 3## = 43## +aw 4## = 44## +aw _ = 1337## + +{-# NOINLINE ax #-} +ax :: Word# -> Word# +ax 1## = 42## +ax 2## = 43## +ax 3## = 43## +ax 4## = 44## +ax 5## = 44## +ax _ = 1337## + +{-# NOINLINE ay #-} +ay :: Word# -> Word# +ay 0## = 42## +ay 4294967295## = 2147483689## +ay _ = 1337## + +{-# NOINLINE az #-} +az :: Word# -> Word# +az 4294967285## = 2147483684## +az 4294967286## = 2147483685## +az 4294967287## = 2147483685## +az 4294967288## = 2147483686## +az 4294967289## = 2147483686## +az 4294967290## = 2147483687## +az 4294967291## = 2147483687## +az 4294967292## = 2147483688## +az 4294967293## = 2147483688## +az 4294967294## = 2147483689## +az 4294967295## = 2147483689## +az _ = 1337## + +{-# NOINLINE ba #-} +ba :: Word# -> Word# +ba 0## = 42## +ba 1## = 42## +ba 2## = 43## +ba 3## = 43## +ba 4## = 44## +ba 5## = 44## +ba 6## = 45## +ba 7## = 45## +ba 8## = 46## +ba 9## = 46## +ba 10## = 47## +ba 4294967285## = 2147483684## +ba 4294967286## = 2147483685## +ba 4294967287## = 2147483685## +ba 4294967288## = 2147483686## +ba 4294967289## = 2147483686## +ba 4294967290## = 2147483687## +ba 4294967291## = 2147483687## +ba 4294967292## = 2147483688## +ba 4294967293## = 2147483688## +ba 4294967294## = 2147483689## +ba 4294967295## = 2147483689## +ba _ = 1337## + +aa_check :: IO () +aa_check = forM_ + [ (0,1337) + , (1,42) + , (2,43) + , (3,43) + , (4,44) + , (5,44) + , (6,45) + , (7,45) + , (8,46) + , (9,46) + , (10,47) + , (11,1337)] $ \(I# i,o) -> do + let r = I# (aa i) + unless (r == o) $ putStrLn $ "ERR: aa (" ++ show (I# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." + +ab_check :: IO () +ab_check = forM_ + [ (-1,1337) + , (0,42) + , (1,42) + , (2,43) + , (3,43) + , (4,44) + , (5,44) + , (6,45) + , (7,45) + , (8,46) + , (9,46) + , (10,47) + , (11,1337)] $ \(I# i,o) -> do + let r = I# (ab i) + unless (r == o) $ putStrLn $ "ERR: ab (" ++ show (I# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." + +ac_check :: IO () +ac_check = forM_ + [ (0,1337) + , (1,42) + , (2,43) + , (3,43) + , (4,1337)] $ \(I# i,o) -> do + let r = I# (ac i) + unless (r == o) $ putStrLn $ "ERR: ac (" ++ show (I# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." + +ad_check :: IO () +ad_check = forM_ + [ (0,1337) + , (1,42) + , (2,43) + , (3,43) + , (4,44) + , (5,1337)] $ \(I# i,o) -> do + let r = I# (ad i) + unless (r == o) $ putStrLn $ "ERR: ad (" ++ show (I# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." + +ae_check :: IO () +ae_check = forM_ + [ (0,1337) + , (1,42) + , (2,43) + , (3,43) + , (4,44) + , (5,44) + , (6,1337)] $ \(I# i,o) -> do + let r = I# (ae i) + unless (r == o) $ putStrLn $ "ERR: ae (" ++ show (I# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." + +af_check :: IO () +af_check = forM_ + [ (-2,1337) + , (-1,41) + , (0,42) + , (1,42) + , (2,43) + , (3,43) + , (4,44) + , (5,44) + , (6,45) + , (7,45) + , (8,46) + , (9,46) + , (10,47) + , (11,1337)] $ \(I# i,o) -> do + let r = I# (af i) + unless (r == o) $ putStrLn $ "ERR: af (" ++ show (I# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." + +ag_check :: IO () +ag_check = forM_ + [ (-11,1337) + , (-10,37) + , (-9,37) + , (-8,38) + , (-7,38) + , (-6,39) + , (-5,39) + , (-4,40) + , (-3,40) + , (-2,41) + , (-1,41) + , (0,42) + , (1,42) + , (2,43) + , (3,43) + , (4,44) + , (5,44) + , (6,45) + , (7,45) + , (8,46) + , (9,46) + , (10,47) + , (11,1337)] $ \(I# i,o) -> do + let r = I# (ag i) + unless (r == o) $ putStrLn $ "ERR: ag (" ++ show (I# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." + +ah_check :: IO () +ah_check = forM_ + [ (-21,1337) + , (-20,32) + , (-19,32) + , (-18,33) + , (-17,33) + , (-16,34) + , (-15,34) + , (-14,35) + , (-13,35) + , (-12,36) + , (-11,36) + , (-10,37) + , (-9,1337) + , (-1,1337) + , (0,42) + , (1,42) + , (2,43) + , (3,43) + , (4,44) + , (5,44) + , (6,45) + , (7,45) + , (8,46) + , (9,46) + , (10,47) + , (11,1337)] $ \(I# i,o) -> do + let r = I# (ah i) + unless (r == o) $ putStrLn $ "ERR: ah (" ++ show (I# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." + +ai_check :: IO () +ai_check = forM_ + [ (-21,1337) + , (-20,32) + , (-19,32) + , (-18,33) + , (-17,33) + , (-16,34) + , (-15,34) + , (-14,35) + , (-13,35) + , (-12,36) + , (-11,36) + , (-10,37) + , (-9,1337) + , (0,1337) + , (1,42) + , (2,43) + , (3,43) + , (4,44) + , (5,44) + , (6,45) + , (7,45) + , (8,46) + , (9,46) + , (10,47) + , (11,1337)] $ \(I# i,o) -> do + let r = I# (ai i) + unless (r == o) $ putStrLn $ "ERR: ai (" ++ show (I# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." + +aj_check :: IO () +aj_check = forM_ + [ (-2147483648,-1073741782) + , (-2147483647,1337) + , (-1,1337) + , (0,42) + , (1,1337) + , (2147483646,1337) + , (2147483647,1073741865)] $ \(I# i,o) -> do + let r = I# (aj i) + unless (r == o) $ putStrLn $ "ERR: aj (" ++ show (I# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." + +ak_check :: IO () +ak_check = forM_ + [ (2147483636,1337) + , (2147483637,1073741860) + , (2147483638,1073741861) + , (2147483639,1073741861) + , (2147483640,1073741862) + , (2147483641,1073741862) + , (2147483642,1073741863) + , (2147483643,1073741863) + , (2147483644,1073741864) + , (2147483645,1073741864) + , (2147483646,1073741865) + , (2147483647,1073741865)] $ \(I# i,o) -> do + let r = I# (ak i) + unless (r == o) $ putStrLn $ "ERR: ak (" ++ show (I# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." + +al_check :: IO () +al_check = forM_ + [ (-2147483648,-1073741782) + , (-2147483647,-1073741782) + , (-2147483646,-1073741781) + , (-2147483645,-1073741781) + , (-2147483644,-1073741780) + , (-2147483643,-1073741780) + , (-2147483642,-1073741779) + , (-2147483641,-1073741779) + , (-2147483640,-1073741778) + , (-2147483639,-1073741778) + , (-2147483638,-1073741777) + , (-2147483637,1337) + , (2147483636,1337) + , (2147483637,1073741860) + , (2147483638,1073741861) + , (2147483639,1073741861) + , (2147483640,1073741862) + , (2147483641,1073741862) + , (2147483642,1073741863) + , (2147483643,1073741863) + , (2147483644,1073741864) + , (2147483645,1073741864) + , (2147483646,1073741865) + , (2147483647,1073741865)] $ \(I# i,o) -> do + let r = I# (al i) + unless (r == o) $ putStrLn $ "ERR: al (" ++ show (I# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." + +am_check :: IO () +am_check = forM_ + [ (0,42) + , (1,42) + , (2,43) + , (3,43) + , (4,44) + , (5,44) + , (6,45) + , (7,45) + , (8,46) + , (9,46) + , (10,47) + , (11,1337)] $ \(W# i,o) -> do + let r = W# (am i) + unless (r == o) $ putStrLn $ "ERR: am (" ++ show (W# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." + +an_check :: IO () +an_check = forM_ + [ (0,1337) + , (1,42) + , (2,43) + , (3,43) + , (4,44) + , (5,44) + , (6,45) + , (7,45) + , (8,46) + , (9,46) + , (10,47) + , (11,1337)] $ \(W# i,o) -> do + let r = W# (an i) + unless (r == o) $ putStrLn $ "ERR: an (" ++ show (W# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." + +ao_check :: IO () +ao_check = forM_ + [ (0,42) + , (1,1337)] $ \(W# i,o) -> do + let r = W# (ao i) + unless (r == o) $ putStrLn $ "ERR: ao (" ++ show (W# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." + +ap_check :: IO () +ap_check = forM_ + [ (0,42) + , (1,42) + , (2,1337)] $ \(W# i,o) -> do + let r = W# (ap i) + unless (r == o) $ putStrLn $ "ERR: ap (" ++ show (W# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." + +aq_check :: IO () +aq_check = forM_ + [ (0,42) + , (1,42) + , (2,43) + , (3,1337)] $ \(W# i,o) -> do + let r = W# (aq i) + unless (r == o) $ putStrLn $ "ERR: aq (" ++ show (W# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." + +ar_check :: IO () +ar_check = forM_ + [ (0,42) + , (1,42) + , (2,43) + , (3,43) + , (4,1337)] $ \(W# i,o) -> do + let r = W# (ar i) + unless (r == o) $ putStrLn $ "ERR: ar (" ++ show (W# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." + +as_check :: IO () +as_check = forM_ + [ (0,42) + , (1,42) + , (2,43) + , (3,43) + , (4,44) + , (5,1337)] $ \(W# i,o) -> do + let r = W# (as i) + unless (r == o) $ putStrLn $ "ERR: as (" ++ show (W# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." + +at_check :: IO () +at_check = forM_ + [ (0,1337) + , (1,42) + , (2,1337)] $ \(W# i,o) -> do + let r = W# (at i) + unless (r == o) $ putStrLn $ "ERR: at (" ++ show (W# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." + +au_check :: IO () +au_check = forM_ + [ (0,1337) + , (1,42) + , (2,43) + , (3,1337)] $ \(W# i,o) -> do + let r = W# (au i) + unless (r == o) $ putStrLn $ "ERR: au (" ++ show (W# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." + +av_check :: IO () +av_check = forM_ + [ (0,1337) + , (1,42) + , (2,43) + , (3,43) + , (4,1337)] $ \(W# i,o) -> do + let r = W# (av i) + unless (r == o) $ putStrLn $ "ERR: av (" ++ show (W# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." + +aw_check :: IO () +aw_check = forM_ + [ (0,1337) + , (1,42) + , (2,43) + , (3,43) + , (4,44) + , (5,1337)] $ \(W# i,o) -> do + let r = W# (aw i) + unless (r == o) $ putStrLn $ "ERR: aw (" ++ show (W# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." + +ax_check :: IO () +ax_check = forM_ + [ (0,1337) + , (1,42) + , (2,43) + , (3,43) + , (4,44) + , (5,44) + , (6,1337)] $ \(W# i,o) -> do + let r = W# (ax i) + unless (r == o) $ putStrLn $ "ERR: ax (" ++ show (W# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." + +ay_check :: IO () +ay_check = forM_ + [ (0,42) + , (1,1337) + , (4294967294,1337) + , (4294967295,2147483689)] $ \(W# i,o) -> do + let r = W# (ay i) + unless (r == o) $ putStrLn $ "ERR: ay (" ++ show (W# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." + +az_check :: IO () +az_check = forM_ + [ (4294967284,1337) + , (4294967285,2147483684) + , (4294967286,2147483685) + , (4294967287,2147483685) + , (4294967288,2147483686) + , (4294967289,2147483686) + , (4294967290,2147483687) + , (4294967291,2147483687) + , (4294967292,2147483688) + , (4294967293,2147483688) + , (4294967294,2147483689) + , (4294967295,2147483689)] $ \(W# i,o) -> do + let r = W# (az i) + unless (r == o) $ putStrLn $ "ERR: az (" ++ show (W# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." + +ba_check :: IO () +ba_check = forM_ + [ (0,42) + , (1,42) + , (2,43) + , (3,43) + , (4,44) + , (5,44) + , (6,45) + , (7,45) + , (8,46) + , (9,46) + , (10,47) + , (11,1337) + , (4294967284,1337) + , (4294967285,2147483684) + , (4294967286,2147483685) + , (4294967287,2147483685) + , (4294967288,2147483686) + , (4294967289,2147483686) + , (4294967290,2147483687) + , (4294967291,2147483687) + , (4294967292,2147483688) + , (4294967293,2147483688) + , (4294967294,2147483689) + , (4294967295,2147483689)] $ \(W# i,o) -> do + let r = W# (ba i) + unless (r == o) $ putStrLn $ "ERR: ba (" ++ show (W# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." + +main = do + aa_check + ab_check + ac_check + ad_check + ae_check + af_check + ag_check + ah_check + ai_check + aj_check + ak_check + al_check + am_check + an_check + ao_check + ap_check + aq_check + ar_check + as_check + at_check + au_check + av_check + aw_check + ax_check + ay_check + az_check + ba_check + + diff --git a/testsuite/tests/codeGen/should_run/CmmSwitchTest.hs b/testsuite/tests/codeGen/should_run/CmmSwitchTest64.hs index 4fbe822b3b..64ddc5418f 100644 --- a/testsuite/tests/codeGen/should_run/CmmSwitchTest.hs +++ b/testsuite/tests/codeGen/should_run/CmmSwitchTest64.hs @@ -1,4 +1,5 @@ -{-# LANGUAGE MagicHash #-} +-- This file is generated from CmmSwitchTestGen! @generated +{-# LANGUAGE MagicHash, NegativeLiterals #-} import Control.Monad (unless, forM_) import GHC.Exts {-# NOINLINE aa #-} @@ -341,137 +342,420 @@ ba 18446744073709551615## = 9223372036854775849## ba _ = 1337## aa_check :: IO () -aa_check = forM_ [(0,1337), (1,42), (2,43), (3,43), (4,44), (5,44), (6,45), (7,45), (8,46), (9,46), (10,47), (11,1337)] $ \(I# i,o) -> do +aa_check = forM_ + [ (0,1337) + , (1,42) + , (2,43) + , (3,43) + , (4,44) + , (5,44) + , (6,45) + , (7,45) + , (8,46) + , (9,46) + , (10,47) + , (11,1337)] $ \(I# i,o) -> do let r = I# (aa i) unless (r == o) $ putStrLn $ "ERR: aa (" ++ show (I# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." ab_check :: IO () -ab_check = forM_ [(-1,1337), (0,42), (1,42), (2,43), (3,43), (4,44), (5,44), (6,45), (7,45), (8,46), (9,46), (10,47), (11,1337)] $ \(I# i,o) -> do +ab_check = forM_ + [ (-1,1337) + , (0,42) + , (1,42) + , (2,43) + , (3,43) + , (4,44) + , (5,44) + , (6,45) + , (7,45) + , (8,46) + , (9,46) + , (10,47) + , (11,1337)] $ \(I# i,o) -> do let r = I# (ab i) unless (r == o) $ putStrLn $ "ERR: ab (" ++ show (I# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." ac_check :: IO () -ac_check = forM_ [(0,1337), (1,42), (2,43), (3,43), (4,1337)] $ \(I# i,o) -> do +ac_check = forM_ + [ (0,1337) + , (1,42) + , (2,43) + , (3,43) + , (4,1337)] $ \(I# i,o) -> do let r = I# (ac i) unless (r == o) $ putStrLn $ "ERR: ac (" ++ show (I# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." ad_check :: IO () -ad_check = forM_ [(0,1337), (1,42), (2,43), (3,43), (4,44), (5,1337)] $ \(I# i,o) -> do +ad_check = forM_ + [ (0,1337) + , (1,42) + , (2,43) + , (3,43) + , (4,44) + , (5,1337)] $ \(I# i,o) -> do let r = I# (ad i) unless (r == o) $ putStrLn $ "ERR: ad (" ++ show (I# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." ae_check :: IO () -ae_check = forM_ [(0,1337), (1,42), (2,43), (3,43), (4,44), (5,44), (6,1337)] $ \(I# i,o) -> do +ae_check = forM_ + [ (0,1337) + , (1,42) + , (2,43) + , (3,43) + , (4,44) + , (5,44) + , (6,1337)] $ \(I# i,o) -> do let r = I# (ae i) unless (r == o) $ putStrLn $ "ERR: ae (" ++ show (I# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." af_check :: IO () -af_check = forM_ [(-2,1337), (-1,41), (0,42), (1,42), (2,43), (3,43), (4,44), (5,44), (6,45), (7,45), (8,46), (9,46), (10,47), (11,1337)] $ \(I# i,o) -> do +af_check = forM_ + [ (-2,1337) + , (-1,41) + , (0,42) + , (1,42) + , (2,43) + , (3,43) + , (4,44) + , (5,44) + , (6,45) + , (7,45) + , (8,46) + , (9,46) + , (10,47) + , (11,1337)] $ \(I# i,o) -> do let r = I# (af i) unless (r == o) $ putStrLn $ "ERR: af (" ++ show (I# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." ag_check :: IO () -ag_check = forM_ [(-11,1337), (-10,37), (-9,37), (-8,38), (-7,38), (-6,39), (-5,39), (-4,40), (-3,40), (-2,41), (-1,41), (0,42), (1,42), (2,43), (3,43), (4,44), (5,44), (6,45), (7,45), (8,46), (9,46), (10,47), (11,1337)] $ \(I# i,o) -> do +ag_check = forM_ + [ (-11,1337) + , (-10,37) + , (-9,37) + , (-8,38) + , (-7,38) + , (-6,39) + , (-5,39) + , (-4,40) + , (-3,40) + , (-2,41) + , (-1,41) + , (0,42) + , (1,42) + , (2,43) + , (3,43) + , (4,44) + , (5,44) + , (6,45) + , (7,45) + , (8,46) + , (9,46) + , (10,47) + , (11,1337)] $ \(I# i,o) -> do let r = I# (ag i) unless (r == o) $ putStrLn $ "ERR: ag (" ++ show (I# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." ah_check :: IO () -ah_check = forM_ [(-21,1337), (-20,32), (-19,32), (-18,33), (-17,33), (-16,34), (-15,34), (-14,35), (-13,35), (-12,36), (-11,36), (-10,37), (-9,1337), (-1,1337), (0,42), (1,42), (2,43), (3,43), (4,44), (5,44), (6,45), (7,45), (8,46), (9,46), (10,47), (11,1337)] $ \(I# i,o) -> do +ah_check = forM_ + [ (-21,1337) + , (-20,32) + , (-19,32) + , (-18,33) + , (-17,33) + , (-16,34) + , (-15,34) + , (-14,35) + , (-13,35) + , (-12,36) + , (-11,36) + , (-10,37) + , (-9,1337) + , (-1,1337) + , (0,42) + , (1,42) + , (2,43) + , (3,43) + , (4,44) + , (5,44) + , (6,45) + , (7,45) + , (8,46) + , (9,46) + , (10,47) + , (11,1337)] $ \(I# i,o) -> do let r = I# (ah i) unless (r == o) $ putStrLn $ "ERR: ah (" ++ show (I# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." ai_check :: IO () -ai_check = forM_ [(-21,1337), (-20,32), (-19,32), (-18,33), (-17,33), (-16,34), (-15,34), (-14,35), (-13,35), (-12,36), (-11,36), (-10,37), (-9,1337), (0,1337), (1,42), (2,43), (3,43), (4,44), (5,44), (6,45), (7,45), (8,46), (9,46), (10,47), (11,1337)] $ \(I# i,o) -> do +ai_check = forM_ + [ (-21,1337) + , (-20,32) + , (-19,32) + , (-18,33) + , (-17,33) + , (-16,34) + , (-15,34) + , (-14,35) + , (-13,35) + , (-12,36) + , (-11,36) + , (-10,37) + , (-9,1337) + , (0,1337) + , (1,42) + , (2,43) + , (3,43) + , (4,44) + , (5,44) + , (6,45) + , (7,45) + , (8,46) + , (9,46) + , (10,47) + , (11,1337)] $ \(I# i,o) -> do let r = I# (ai i) unless (r == o) $ putStrLn $ "ERR: ai (" ++ show (I# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." aj_check :: IO () -aj_check = forM_ [(-9223372036854775808,-4611686018427387862), (-9223372036854775807,1337), (-1,1337), (0,42), (1,1337), (9223372036854775806,1337), (9223372036854775807,4611686018427387945)] $ \(I# i,o) -> do +aj_check = forM_ + [ (-9223372036854775808,-4611686018427387862) + , (-9223372036854775807,1337) + , (-1,1337) + , (0,42) + , (1,1337) + , (9223372036854775806,1337) + , (9223372036854775807,4611686018427387945)] $ \(I# i,o) -> do let r = I# (aj i) unless (r == o) $ putStrLn $ "ERR: aj (" ++ show (I# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." ak_check :: IO () -ak_check = forM_ [(9223372036854775796,1337), (9223372036854775797,4611686018427387940), (9223372036854775798,4611686018427387941), (9223372036854775799,4611686018427387941), (9223372036854775800,4611686018427387942), (9223372036854775801,4611686018427387942), (9223372036854775802,4611686018427387943), (9223372036854775803,4611686018427387943), (9223372036854775804,4611686018427387944), (9223372036854775805,4611686018427387944), (9223372036854775806,4611686018427387945), (9223372036854775807,4611686018427387945)] $ \(I# i,o) -> do +ak_check = forM_ + [ (9223372036854775796,1337) + , (9223372036854775797,4611686018427387940) + , (9223372036854775798,4611686018427387941) + , (9223372036854775799,4611686018427387941) + , (9223372036854775800,4611686018427387942) + , (9223372036854775801,4611686018427387942) + , (9223372036854775802,4611686018427387943) + , (9223372036854775803,4611686018427387943) + , (9223372036854775804,4611686018427387944) + , (9223372036854775805,4611686018427387944) + , (9223372036854775806,4611686018427387945) + , (9223372036854775807,4611686018427387945)] $ \(I# i,o) -> do let r = I# (ak i) unless (r == o) $ putStrLn $ "ERR: ak (" ++ show (I# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." al_check :: IO () -al_check = forM_ [(-9223372036854775808,-4611686018427387862), (-9223372036854775807,-4611686018427387862), (-9223372036854775806,-4611686018427387861), (-9223372036854775805,-4611686018427387861), (-9223372036854775804,-4611686018427387860), (-9223372036854775803,-4611686018427387860), (-9223372036854775802,-4611686018427387859), (-9223372036854775801,-4611686018427387859), (-9223372036854775800,-4611686018427387858), (-9223372036854775799,-4611686018427387858), (-9223372036854775798,-4611686018427387857), (-9223372036854775797,1337), (9223372036854775796,1337), (9223372036854775797,4611686018427387940), (9223372036854775798,4611686018427387941), (9223372036854775799,4611686018427387941), (9223372036854775800,4611686018427387942), (9223372036854775801,4611686018427387942), (9223372036854775802,4611686018427387943), (9223372036854775803,4611686018427387943), (9223372036854775804,4611686018427387944), (9223372036854775805,4611686018427387944), (9223372036854775806,4611686018427387945), (9223372036854775807,4611686018427387945)] $ \(I# i,o) -> do +al_check = forM_ + [ (-9223372036854775808,-4611686018427387862) + , (-9223372036854775807,-4611686018427387862) + , (-9223372036854775806,-4611686018427387861) + , (-9223372036854775805,-4611686018427387861) + , (-9223372036854775804,-4611686018427387860) + , (-9223372036854775803,-4611686018427387860) + , (-9223372036854775802,-4611686018427387859) + , (-9223372036854775801,-4611686018427387859) + , (-9223372036854775800,-4611686018427387858) + , (-9223372036854775799,-4611686018427387858) + , (-9223372036854775798,-4611686018427387857) + , (-9223372036854775797,1337) + , (9223372036854775796,1337) + , (9223372036854775797,4611686018427387940) + , (9223372036854775798,4611686018427387941) + , (9223372036854775799,4611686018427387941) + , (9223372036854775800,4611686018427387942) + , (9223372036854775801,4611686018427387942) + , (9223372036854775802,4611686018427387943) + , (9223372036854775803,4611686018427387943) + , (9223372036854775804,4611686018427387944) + , (9223372036854775805,4611686018427387944) + , (9223372036854775806,4611686018427387945) + , (9223372036854775807,4611686018427387945)] $ \(I# i,o) -> do let r = I# (al i) unless (r == o) $ putStrLn $ "ERR: al (" ++ show (I# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." am_check :: IO () -am_check = forM_ [(0,42), (1,42), (2,43), (3,43), (4,44), (5,44), (6,45), (7,45), (8,46), (9,46), (10,47), (11,1337)] $ \(W# i,o) -> do +am_check = forM_ + [ (0,42) + , (1,42) + , (2,43) + , (3,43) + , (4,44) + , (5,44) + , (6,45) + , (7,45) + , (8,46) + , (9,46) + , (10,47) + , (11,1337)] $ \(W# i,o) -> do let r = W# (am i) unless (r == o) $ putStrLn $ "ERR: am (" ++ show (W# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." an_check :: IO () -an_check = forM_ [(0,1337), (1,42), (2,43), (3,43), (4,44), (5,44), (6,45), (7,45), (8,46), (9,46), (10,47), (11,1337)] $ \(W# i,o) -> do +an_check = forM_ + [ (0,1337) + , (1,42) + , (2,43) + , (3,43) + , (4,44) + , (5,44) + , (6,45) + , (7,45) + , (8,46) + , (9,46) + , (10,47) + , (11,1337)] $ \(W# i,o) -> do let r = W# (an i) unless (r == o) $ putStrLn $ "ERR: an (" ++ show (W# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." ao_check :: IO () -ao_check = forM_ [(0,42), (1,1337)] $ \(W# i,o) -> do +ao_check = forM_ + [ (0,42) + , (1,1337)] $ \(W# i,o) -> do let r = W# (ao i) unless (r == o) $ putStrLn $ "ERR: ao (" ++ show (W# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." ap_check :: IO () -ap_check = forM_ [(0,42), (1,42), (2,1337)] $ \(W# i,o) -> do +ap_check = forM_ + [ (0,42) + , (1,42) + , (2,1337)] $ \(W# i,o) -> do let r = W# (ap i) unless (r == o) $ putStrLn $ "ERR: ap (" ++ show (W# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." aq_check :: IO () -aq_check = forM_ [(0,42), (1,42), (2,43), (3,1337)] $ \(W# i,o) -> do +aq_check = forM_ + [ (0,42) + , (1,42) + , (2,43) + , (3,1337)] $ \(W# i,o) -> do let r = W# (aq i) unless (r == o) $ putStrLn $ "ERR: aq (" ++ show (W# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." ar_check :: IO () -ar_check = forM_ [(0,42), (1,42), (2,43), (3,43), (4,1337)] $ \(W# i,o) -> do +ar_check = forM_ + [ (0,42) + , (1,42) + , (2,43) + , (3,43) + , (4,1337)] $ \(W# i,o) -> do let r = W# (ar i) unless (r == o) $ putStrLn $ "ERR: ar (" ++ show (W# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." as_check :: IO () -as_check = forM_ [(0,42), (1,42), (2,43), (3,43), (4,44), (5,1337)] $ \(W# i,o) -> do +as_check = forM_ + [ (0,42) + , (1,42) + , (2,43) + , (3,43) + , (4,44) + , (5,1337)] $ \(W# i,o) -> do let r = W# (as i) unless (r == o) $ putStrLn $ "ERR: as (" ++ show (W# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." at_check :: IO () -at_check = forM_ [(0,1337), (1,42), (2,1337)] $ \(W# i,o) -> do +at_check = forM_ + [ (0,1337) + , (1,42) + , (2,1337)] $ \(W# i,o) -> do let r = W# (at i) unless (r == o) $ putStrLn $ "ERR: at (" ++ show (W# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." au_check :: IO () -au_check = forM_ [(0,1337), (1,42), (2,43), (3,1337)] $ \(W# i,o) -> do +au_check = forM_ + [ (0,1337) + , (1,42) + , (2,43) + , (3,1337)] $ \(W# i,o) -> do let r = W# (au i) unless (r == o) $ putStrLn $ "ERR: au (" ++ show (W# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." av_check :: IO () -av_check = forM_ [(0,1337), (1,42), (2,43), (3,43), (4,1337)] $ \(W# i,o) -> do +av_check = forM_ + [ (0,1337) + , (1,42) + , (2,43) + , (3,43) + , (4,1337)] $ \(W# i,o) -> do let r = W# (av i) unless (r == o) $ putStrLn $ "ERR: av (" ++ show (W# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." aw_check :: IO () -aw_check = forM_ [(0,1337), (1,42), (2,43), (3,43), (4,44), (5,1337)] $ \(W# i,o) -> do +aw_check = forM_ + [ (0,1337) + , (1,42) + , (2,43) + , (3,43) + , (4,44) + , (5,1337)] $ \(W# i,o) -> do let r = W# (aw i) unless (r == o) $ putStrLn $ "ERR: aw (" ++ show (W# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." ax_check :: IO () -ax_check = forM_ [(0,1337), (1,42), (2,43), (3,43), (4,44), (5,44), (6,1337)] $ \(W# i,o) -> do +ax_check = forM_ + [ (0,1337) + , (1,42) + , (2,43) + , (3,43) + , (4,44) + , (5,44) + , (6,1337)] $ \(W# i,o) -> do let r = W# (ax i) unless (r == o) $ putStrLn $ "ERR: ax (" ++ show (W# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." ay_check :: IO () -ay_check = forM_ [(0,42), (1,1337), (18446744073709551614,1337), (18446744073709551615,9223372036854775849)] $ \(W# i,o) -> do +ay_check = forM_ + [ (0,42) + , (1,1337) + , (18446744073709551614,1337) + , (18446744073709551615,9223372036854775849)] $ \(W# i,o) -> do let r = W# (ay i) unless (r == o) $ putStrLn $ "ERR: ay (" ++ show (W# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." az_check :: IO () -az_check = forM_ [(18446744073709551604,1337), (18446744073709551605,9223372036854775844), (18446744073709551606,9223372036854775845), (18446744073709551607,9223372036854775845), (18446744073709551608,9223372036854775846), (18446744073709551609,9223372036854775846), (18446744073709551610,9223372036854775847), (18446744073709551611,9223372036854775847), (18446744073709551612,9223372036854775848), (18446744073709551613,9223372036854775848), (18446744073709551614,9223372036854775849), (18446744073709551615,9223372036854775849)] $ \(W# i,o) -> do +az_check = forM_ + [ (18446744073709551604,1337) + , (18446744073709551605,9223372036854775844) + , (18446744073709551606,9223372036854775845) + , (18446744073709551607,9223372036854775845) + , (18446744073709551608,9223372036854775846) + , (18446744073709551609,9223372036854775846) + , (18446744073709551610,9223372036854775847) + , (18446744073709551611,9223372036854775847) + , (18446744073709551612,9223372036854775848) + , (18446744073709551613,9223372036854775848) + , (18446744073709551614,9223372036854775849) + , (18446744073709551615,9223372036854775849)] $ \(W# i,o) -> do let r = W# (az i) unless (r == o) $ putStrLn $ "ERR: az (" ++ show (W# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." ba_check :: IO () -ba_check = forM_ [(0,42), (1,42), (2,43), (3,43), (4,44), (5,44), (6,45), (7,45), (8,46), (9,46), (10,47), (11,1337), (18446744073709551604,1337), (18446744073709551605,9223372036854775844), (18446744073709551606,9223372036854775845), (18446744073709551607,9223372036854775845), (18446744073709551608,9223372036854775846), (18446744073709551609,9223372036854775846), (18446744073709551610,9223372036854775847), (18446744073709551611,9223372036854775847), (18446744073709551612,9223372036854775848), (18446744073709551613,9223372036854775848), (18446744073709551614,9223372036854775849), (18446744073709551615,9223372036854775849)] $ \(W# i,o) -> do +ba_check = forM_ + [ (0,42) + , (1,42) + , (2,43) + , (3,43) + , (4,44) + , (5,44) + , (6,45) + , (7,45) + , (8,46) + , (9,46) + , (10,47) + , (11,1337) + , (18446744073709551604,1337) + , (18446744073709551605,9223372036854775844) + , (18446744073709551606,9223372036854775845) + , (18446744073709551607,9223372036854775845) + , (18446744073709551608,9223372036854775846) + , (18446744073709551609,9223372036854775846) + , (18446744073709551610,9223372036854775847) + , (18446744073709551611,9223372036854775847) + , (18446744073709551612,9223372036854775848) + , (18446744073709551613,9223372036854775848) + , (18446744073709551614,9223372036854775849) + , (18446744073709551615,9223372036854775849)] $ \(W# i,o) -> do let r = W# (ba i) unless (r == o) $ putStrLn $ "ERR: ba (" ++ show (W# i)++ ") is " ++ show r ++ " and not " ++ show o ++"." @@ -503,3 +787,5 @@ main = do ay_check az_check ba_check + + diff --git a/testsuite/tests/codeGen/should_run/CmmSwitchTestGen.hs b/testsuite/tests/codeGen/should_run/CmmSwitchTestGen.hs index 61af0decac..640f8cb60f 100644 --- a/testsuite/tests/codeGen/should_run/CmmSwitchTestGen.hs +++ b/testsuite/tests/codeGen/should_run/CmmSwitchTestGen.hs @@ -1,10 +1,12 @@ {-# LANGUAGE TupleSections #-} --- Generates CmmSwitch.hs +-- Generates CmmSwitchTest.hs import qualified Data.Set as S +import Data.Int import Data.Word import Data.List +import System.Environment output :: Integer -> Integer output n = n`div`2 + 42 @@ -12,7 +14,9 @@ output n = n`div`2 + 42 def :: Integer def = 1337 -type Spec = (String, Bool, [Integer]) +data Bits = X32 | X64 + deriving Eq +type Spec = (String, Bool, [Integer], Bits) primtyp True = "Int#" primtyp False = "Word#" @@ -26,7 +30,7 @@ hash False = "##" primLit s v = show v ++ hash s genSwitch :: Spec -> String -genSwitch (name, signed, values) = unlines $ +genSwitch (name, signed, values, _) = unlines $ [ "{-# NOINLINE " ++ name ++ " #-}" ] ++ [ name ++ " :: " ++ primtyp signed ++ " -> " ++ primtyp signed ] ++ [ name ++ " " ++ primLit signed v ++ " = " ++ primLit signed (output v) @@ -34,9 +38,9 @@ genSwitch (name, signed, values) = unlines $ [ name ++ " _ = " ++ primLit signed def ] genCheck :: Spec -> String -genCheck (name, signed, values) = unlines $ +genCheck (name, signed, values, bits) = unlines $ [ checkName name ++ " :: IO ()" - , checkName name ++ " = forM_ [" ++ pairs ++ "] $ \\(" ++ con signed ++ " i,o) -> do" + , checkName name ++ " = forM_\n [ " ++ pairs ++ "] $ \\(" ++ con signed ++ " i,o) -> do" , " let r = " ++ con signed ++ " (" ++ name ++ " i)" , " unless (r == o) $ putStrLn $ \"ERR: " ++ name ++ " (\" ++ show (" ++ con signed ++ " i)++ \") is \" ++ show r ++ \" and not \" ++ show o ++\".\"" ] @@ -44,20 +48,23 @@ genCheck (name, signed, values) = unlines $ f x | x `S.member` range = output x | otherwise = def range = S.fromList values + minS = if bits == X32 then minS32 else minS64 + maxS = if bits == X32 then maxS32 else maxS64 + maxU = if bits == X32 then maxU32 else maxU64 checkValues = S.toList $ S.fromList $ [ v' | v <- values, v' <- [v-1,v,v+1], if signed then v' >= minS && v' <= maxS else v' >= minU && v' <= maxU ] - pairs = intercalate ", " ["(" ++ show v ++ "," ++ show (f v) ++ ")" | v <- checkValues ] + pairs = intercalate "\n , " ["(" ++ show v ++ "," ++ show (f v) ++ ")" | v <- checkValues ] checkName :: String -> String checkName f = f ++ "_check" genMain :: [Spec] -> String -genMain specs = unlines $ "main = do" : [ " " ++ checkName n | (n,_,_) <- specs ] +genMain specs = unlines $ "main = do" : [ " " ++ checkName n | (n,_,_,_) <- specs ] genMod :: [Spec] -> String genMod specs = unlines $ - "-- This file is generated from CmmSwitchGen!" : + "-- This file is generated from CmmSwitchTestGen! @generated" : "{-# LANGUAGE MagicHash, NegativeLiterals #-}" : "import Control.Monad (unless, forM_)" : "import GHC.Exts" : @@ -65,12 +72,19 @@ genMod specs = unlines $ map genCheck specs ++ [ genMain specs ] -main = putStrLn $ - genMod $ zipWith (\n (s,v) -> (n,s,v)) names $ signedChecks ++ unsignedChecks +main = do + args <- getArgs + bits <- parse args + putStrLn $ + genMod $ zipWith (\n (s,v) -> (n,s,v,bits)) names $ signedChecks bits ++ unsignedChecks bits +parse :: [String] -> IO Bits -- Use IO to avoid lazy parsing +parse ["-32"] = return X32 +parse ["-64"] = return X64 +parse _ = error "Please, supply -32 or -64 option" -signedChecks :: [(Bool, [Integer])] -signedChecks = map (True,) +signedChecks :: Bits -> [(Bool, [Integer])] +signedChecks bits = map (True,) [ [1..10] , [0..10] , [1..3] @@ -84,16 +98,23 @@ signedChecks = map (True,) , [maxS-10 .. maxS] , [minS..minS+10]++[maxS-10 .. maxS] ] + where + minS = if bits == X32 then minS32 else minS64 + maxS = if bits == X32 then maxS32 else maxS64 -minU, maxU, minS, maxS :: Integer +minU, maxU32, maxU64, minS32, minS64, maxS32, maxS64 :: Integer minU = 0 -maxU = fromIntegral (maxBound :: Word) -minS = fromIntegral (minBound :: Int) -maxS = fromIntegral (maxBound :: Int) +maxU32 = fromIntegral (maxBound :: Word32) +maxU64 = fromIntegral (maxBound :: Word64) +minS32 = fromIntegral (minBound :: Int32) +minS64 = fromIntegral (minBound :: Int64) +maxS32 = fromIntegral (maxBound :: Int32) +maxS64 = fromIntegral (maxBound :: Int64) -unsignedChecks :: [(Bool, [Integer])] -unsignedChecks = map (False,) + +unsignedChecks :: Bits -> [(Bool, [Integer])] +unsignedChecks bits = map (False,) [ [0..10] , [1..10] , [0] @@ -110,6 +131,8 @@ unsignedChecks = map (False,) , [maxU-10 .. maxU] , [minU..minU+10]++[maxU-10 .. maxU] ] + where + maxU = if bits == X32 then maxU32 else maxU64 names :: [String] names = [ c1:c2:[] | c1 <- ['a'..'z'], c2 <- ['a'..'z']] diff --git a/testsuite/tests/codeGen/should_run/all.T b/testsuite/tests/codeGen/should_run/all.T index 921f2c3aaa..b8bc4f60c2 100644 --- a/testsuite/tests/codeGen/should_run/all.T +++ b/testsuite/tests/codeGen/should_run/all.T @@ -127,9 +127,8 @@ test('T9013', omit_ways(['ghci']), # ghci doesn't support unboxed tuples compile_and_run, ['']) test('T9340', normal, compile_and_run, ['']) test('cgrun074', normal, compile_and_run, ['']) -test('CmmSwitchTest', - [when(fast(), skip), when(wordsize(32), expect_broken(11297))], - compile_and_run, ['']) +test('CmmSwitchTest32', unless(wordsize(32), skip), compile_and_run, ['']) +test('CmmSwitchTest64', unless(wordsize(64), skip), compile_and_run, ['']) # Skipping WAY=ghci, because it is not broken. test('T10245', [omit_ways(['ghci']), expect_broken(10246)], compile_and_run, ['']) test('T10246', expect_broken(10246), compile_and_run, ['']) |