Commit 86df0f32 authored by ian@well-typed.com's avatar ian@well-typed.com

Define 'when' and 'unless' helpers

This will reduce the number of helper functions that we need
parent c4cd533a
......@@ -290,6 +290,15 @@ def skip_if_fast(opts):
# -----
def when(b, f):
if b:
return f
else:
return normal
def unless(b, f):
return when(not b, f)
def if_platform( plat, f ):
if config.platform == plat:
return f
......@@ -326,17 +335,8 @@ def unless_arch( arch, f ):
else:
return f
def if_wordsize( ws, f ):
if config.wordsize == str(ws):
return f
else:
return normal
def unless_wordsize( ws, f ):
if config.wordsize == str(ws):
return normal
else:
return f
def wordsize( ws ):
return config.wordsize == str(ws)
def if_unregisterised( f ):
if config.unregisterised:
......
......@@ -100,8 +100,8 @@ test('T7319', [ extra_ways(['prof']), only_ways(['prof']), exit_code(1),
req_profiling,
extra_hc_opts('-fprof-auto'),
extra_run_opts('+RTS -xc') ], compile_and_run, [''])
test('Word2Float32', unless_wordsize(32, skip), compile_and_run, [''])
test('Word2Float64', unless_wordsize(64, skip), compile_and_run, [''])
test('Word2Float32', unless(wordsize(32), skip), compile_and_run, [''])
test('Word2Float64', unless(wordsize(64), skip), compile_and_run, [''])
test('T7361', normal, compile_and_run, [''])
test('T7600', normal, compile_and_run, [''])
......
......@@ -11,4 +11,4 @@ test('T5486', normal, compile, [''])
test('T5681', normal, compile, [''])
test('T6158', [reqlib('vector'), reqlib('primitive')], compile, ['-package vector -package primitive'])
test('T7571', cmm_src, compile, [''])
test('T7575', unless_wordsize(32, skip), compile, [''])
test('T7575', unless(wordsize(32), skip), compile, [''])
......@@ -6,36 +6,36 @@ setTestOpts(no_lint)
test('T1969',
[if_wordsize(32,
[when(wordsize(32),
compiler_stats_range_field('peak_megabytes_allocated', 18, 1)),
# expected value: 14 (x86/Windows 17/05/10)
# 15 (x86/OS X)
# 19 (x86/OS X)
if_wordsize(64,
when(wordsize(64),
compiler_stats_range_field('peak_megabytes_allocated', 25, 1)),
# expected value: 28 (amd64/Linux)
# expected value: 34 (amd64/Linux)
# 2012-09-20 23 (amd64/Linux)
# 2012-10-03 25 (amd64/Linux if .hi exists)
if_wordsize(32,
when(wordsize(32),
compiler_stats_range_field('max_bytes_used', 6149572, 5)),
# expected value: 6707308 (x86/OS X)
# 5717704 (x86/Windows 17/05/10)
# 6149572 (x86/Linux, 31/12/09)
if_wordsize(64,
when(wordsize(64),
compiler_stats_range_field('max_bytes_used', 9000000, 20)),
# looks like the peak is around 10M, but we're
# unlikely to GC exactly on the peak.
# varies quite a lot with CLEANUP and BINDIST,
# hence 10% range.
if_wordsize(32,
when(wordsize(32),
compiler_stats_range_field('bytes allocated', 303930948, 5)),
# expected value: 215582916 (x86/Windows)
# 221667908 (x86/OS X)
# 274932264 (x86/Linux)
# 2012-10-08: 303930948 (x86/Linux, new codegen)
# 2012-10-29: 298921816 (x86/Windows; increased range to 5%
if_wordsize(64,
when(wordsize(64),
compiler_stats_range_field('bytes allocated', 658786936, 5)),
# 17/11/2009: 434,845,560 (amd64/Linux)
# 08/12/2009: 459,776,680 (amd64/Linux)
......@@ -77,23 +77,23 @@ else:
conf_3294 = skip
test('T3294',
[if_wordsize(32,
[when(wordsize(32),
compiler_stats_range_field('max_bytes_used', 17725476, 5)),
# expected value: 17725476 (x86/OS X)
# 14593500 (Windows)
if_wordsize(64,
when(wordsize(64),
compiler_stats_range_field('max_bytes_used', 44894544, 15)),
# prev: 25753192 (amd64/Linux)
# 29/08/2012: 37724352 (amd64/Linux)
# (increase due to new codegen, see #7198)
# 13/13/2012: 44894544 (amd64/Linux)
# (reason for increase unknown)
if_wordsize(32,
when(wordsize(32),
compiler_stats_range_field('bytes allocated', 1373514844, 5)),
# previous: 815479800 (x86/Linux)
# (^ increase due to new codegen, see #7198)
# 2012-10-08: 1373514844 (x86/Linux)
if_wordsize(64,
when(wordsize(64),
compiler_stats_range_field('bytes allocated', 2717327208, 5)),
# old: 1,357,587,088 (amd64/Linux)
# 29/08/2012: 2,961,778,696 (amd64/Linux)
......@@ -107,10 +107,10 @@ test('T3294',
test('T4801',
[ # expect_broken(5224),
# temporarily unbroken (#5227)
if_wordsize(32,
when(wordsize(32),
compiler_stats_range_field('peak_megabytes_allocated', 30, 20)),
if_wordsize(64,
when(wordsize(64),
compiler_stats_range_field('peak_megabytes_allocated', 49, 20)),
# prev: 50 (amd64/Linux)
# 19/10/2012: 64 (amd64/Linux) (REASON UNKNOWN!)
......@@ -120,10 +120,10 @@ test('T4801',
if_platform('x86_64-apple-darwin',
compiler_stats_range_field('peak_megabytes_allocated', 58, 1)),
# expected value: 228286660 (x86/OS X)
if_wordsize(32,
when(wordsize(32),
compiler_stats_range_field('bytes allocated', 185669232, 10)),
if_wordsize(64,
when(wordsize(64),
compiler_stats_range_field('bytes allocated', 392409984, 10)),
# prev: 360243576 (amd64/Linux)
# 19/10/2012: 447190832 (amd64/Linux) (-fPIC turned on)
......@@ -133,11 +133,11 @@ test('T4801',
if_platform('x86_64-apple-darwin',
compiler_stats_range_field('bytes allocated', 510938976, 5)),
if_wordsize(32,
when(wordsize(32),
compiler_stats_range_field('max_bytes_used', 9651948, 5)),
# expected value: x86/OS X: 9651948
# expected value: 10290952 (windows)
if_wordsize(64,
when(wordsize(64),
compiler_stats_range_field('max_bytes_used', 21657520, 15)),
# prev: 20486256 (amd64/OS X)
# 30/08/2012: 17305600--20391920 (varies a lot)
......@@ -155,30 +155,30 @@ test('T4801',
test('T3064',
[# expect_broken( 3064 ),
# expected value: 14 (x86/Linux 28-06-2012):
if_wordsize(32,
when(wordsize(32),
compiler_stats_range_field('peak_megabytes_allocated', 14, 1)),
if_wordsize(64,
when(wordsize(64),
compiler_stats_range_field('peak_megabytes_allocated', 26, 1)),
# (amd64/Linux): 18
# (amd64/Linux) 2012-02-07: 26
# expected value: 56380288 (x86/Linux) (28/6/2011)
# 111189536 (x86/Windows) (30/10/12)
if_wordsize(32,
when(wordsize(32),
compiler_stats_range_field('bytes allocated', 111189536, 10)),
if_wordsize(64,
when(wordsize(64),
compiler_stats_range_field('bytes allocated', 224798696, 5)),
# (amd64/Linux) (28/06/2011): 73259544
# (amd64/Linux) (07/02/2013): 224798696
# expected value: 2247016 (x86/Linux) (28/6/2011):
if_wordsize(32,
when(wordsize(32),
compiler_stats_range_field('max_bytes_used', 5511604, 20)),
if_wordsize(64,
when(wordsize(64),
compiler_stats_range_field('max_bytes_used', 9819288, 5)),
# (amd64/Linux, intree) (28/06/2011): 4032024
# (amd64/Linux, intree) (07/02/2013): 9819288
......@@ -194,12 +194,12 @@ test('T4007',
test('T5030',
[
if_wordsize(32,
when(wordsize(32),
compiler_stats_range_field('bytes allocated', 259547660, 10)),
# previous: 196457520
# 2012-10-08: 259547660 (x86/Linux, new codegen)
if_wordsize(64,
when(wordsize(64),
compiler_stats_range_field('bytes allocated', 602993184, 10)),
# Previously 530000000 (+/- 10%)
# 17/1/13: 602,993,184 (x86_64/Linux)
......@@ -211,10 +211,10 @@ test('T5030',
['-fcontext-stack=300'])
test('T5631',
[if_wordsize(32, # sample from x86/Linux
[when(wordsize(32), # sample from x86/Linux
compiler_stats_range_field('bytes allocated', 392904228, 10)),
# expected value: 774,595,008 (amd64/Linux):
if_wordsize(64,
when(wordsize(64),
compiler_stats_range_field('bytes allocated', 774595008, 5)),
only_ways(['normal'])
],
......@@ -223,10 +223,10 @@ test('T5631',
test('parsing001',
[# expected value: ?
if_wordsize(32,
when(wordsize(32),
compiler_stats_range_field('bytes allocated', 274000576, 10)),
# expected value: 587079016 (amd64/Linux):
if_wordsize(64,
when(wordsize(64),
compiler_stats_range_field('bytes allocated', 587079016, 5)),
only_ways(['normal']),
],
......@@ -236,10 +236,10 @@ test('parsing001',
test('T783',
[ only_ways(['normal']), # no optimisation for this one
# expected value: 175,569,928 (x86/Linux)
if_wordsize(32,
when(wordsize(32),
compiler_stats_range_field('bytes allocated', 226907420, 10)),
# 2012-10-08: 226907420 (x86/Linux)
if_wordsize(64,
when(wordsize(64),
compiler_stats_range_field('bytes allocated', 640324528, 10)),
# prev: 349,263,216 (amd64/Linux)
# 07/08/2012: 384,479,856 (amd64/Linux)
......@@ -254,12 +254,12 @@ test('T783',
test('T5321Fun',
[ only_ways(['normal']), # no optimisation for this one
# sample from x86/Linux
if_wordsize(32,
when(wordsize(32),
compiler_stats_range_field('bytes allocated', 344416344, 10)),
# prev: 300000000
# 2012-10-08: 344416344
# (increase due to new codegen)
if_wordsize(64,
when(wordsize(64),
compiler_stats_range_field('bytes allocated', 713385808, 10))
# prev: 585,521,080
# 29/08/2012: 713,385,808
......@@ -269,12 +269,12 @@ test('T5321Fun',
test('T5321FD',
[ only_ways(['normal']), # no optimisation for this one
if_wordsize(32,
when(wordsize(32),
compiler_stats_range_field('bytes allocated', 240302920, 10)),
# prev: 213380256
# 2012-10-08: 240302920 (x86/Linux)
# (increase due to new codegen)
if_wordsize(64,
when(wordsize(64),
compiler_stats_range_field('bytes allocated', 492905640, 10))
# prev: 418,306,336
# 29/08/2012: 492,905,640
......@@ -284,20 +284,20 @@ test('T5321FD',
test('T5642',
[ only_ways(['normal']),
if_wordsize(32, # sample from x86/Linux
when(wordsize(32), # sample from x86/Linux
compiler_stats_range_field('bytes allocated', 650000000, 10)),
if_wordsize(64,
when(wordsize(64),
compiler_stats_range_field('bytes allocated', 1300000000, 10))
],
compile,['-O'])
test('T5837',
[ only_ways(['normal']),
if_wordsize(32, # sample from x86/Linux
when(wordsize(32), # sample from x86/Linux
compiler_stats_range_field('bytes allocated', 40000000, 10)),
# sample: 3926235424 (amd64/Linux, 15/2/2012)
if_wordsize(64,
when(wordsize(64),
compiler_stats_range_field('bytes allocated', 81879216, 10))
# 2012-10-02 81879216
# 2012-09-20 87254264 amd64/Linux
......@@ -306,11 +306,11 @@ test('T5837',
test('T6048',
[ only_ways(['optasm']),
if_wordsize(32, # sample from x86/Linux
when(wordsize(32), # sample from x86/Linux
compiler_stats_range_field('bytes allocated', 48887164, 10)),
# prev: 38000000
# 2012-10-08: 48887164 (x86/Linux)
if_wordsize(64,
when(wordsize(64),
compiler_stats_range_field('bytes allocated', 97247032, 10))
# 18/09/2012 97247032 amd64/Linux
],
......
test('haddock.base',
[unless_in_tree_compiler(skip)
,if_wordsize(64,
,when(wordsize(64),
stats_range_field('peak_megabytes_allocated', 274, 10))
# 2012-08-14: 240 (amd64/Linux)
# 2012-09-18: 237 (amd64/Linux)
# 2012-11-12: 249 (amd64/Linux)
# 2013-01-29: 274 (amd64/Linux)
,if_wordsize(32,
,when(wordsize(32),
stats_range_field('peak_megabytes_allocated', 113, 1))
# 2012-08-14: 144 (x86/OSX)
# 2012-10-30: 113 (x86/Windows)
,if_wordsize(64,
,when(wordsize(64),
stats_range_field('max_bytes_used', 96022312, 10))
# 2012-08-14: 87374568 (amd64/Linux)
# 2012-08-21: 86428216 (amd64/Linux)
# 2012-09-20: 84794136 (amd64/Linux)
# 2012-11-12: 87265136 (amd64/Linux)
# 2013-01-29: 96022312 (amd64/Linux)
,if_wordsize(32,
,when(wordsize(32),
stats_range_field('max_bytes_used', 45574928, 1))
# 2012-08-14: 45574928 (x86/OSX)
,if_wordsize(64,
,when(wordsize(64),
stats_range_field('bytes allocated', 6064874536, 2))
# 2012-08-14: 5920822352 (amd64/Linux)
# 2012-09-20: 5829972376 (amd64/Linux)
# 2012-10-08: 5902601224 (amd64/Linux)
# 2013-01-17: 6064874536 (x86_64/Linux)
,if_wordsize(32,
,when(wordsize(32),
stats_range_field('bytes allocated', 2955470952, 1))
# 2012-08-14: 3046487920 (x86/OSX)
# 2012-10-30: 2955470952 (x86/Windows)
......@@ -37,32 +37,32 @@ test('haddock.base',
test('haddock.Cabal',
[unless_in_tree_compiler(skip)
,if_wordsize(64,
,when(wordsize(64),
stats_range_field('peak_megabytes_allocated', 217, 10))
# 2012-08-14: 202 (amd64/Linux)
# 2012-08-29: 211 (amd64/Linux, new codegen)
# 2012-09-20: 227 (amd64/Linux)
# 2012-10-08: 217 (amd64/Linux)
,if_wordsize(32,
,when(wordsize(32),
stats_range_field('peak_megabytes_allocated', 83, 1))
# 2012-08-14: 116 (x86/OSX)
# 2012-10-30: 83 (x86/Windows)
,if_wordsize(64,
,when(wordsize(64),
stats_range_field('max_bytes_used', 80590280, 15))
# 2012-08-14: 74119424 (amd64/Linux)
# 2012-08-29: 77992512 (amd64/Linux, new codegen)
# 2012-10-02: 91341568 (amd64/Linux)
# 2012-10-08: 80590280 (amd64/Linux)
,if_wordsize(32,
,when(wordsize(32),
stats_range_field('max_bytes_used', 44224896, 5))
# 2012-08-14: 47461532 (x86/OSX)
# 2012-10-30: 44224896 (x86/Windows insreased range to 5%)
,if_wordsize(64,
,when(wordsize(64),
stats_range_field('bytes allocated', 3373401360, 2))
# 2012-08-14: 3255435248 (amd64/Linux)
# 2012-08-29: 3324606664 (amd64/Linux, new codegen)
# 2012-10-08: 3373401360 (amd64/Linux)
,if_wordsize(32,
,when(wordsize(32),
stats_range_field('bytes allocated', 1733638168, 1))
# 2012-08-14: 1648610180 (x86/OSX)
# 2012-10-30: 1733638168 (x86/Windows)
......@@ -72,33 +72,33 @@ test('haddock.Cabal',
test('haddock.compiler',
[unless_in_tree_compiler(skip)
,if_wordsize(64,
,when(wordsize(64),
stats_range_field('peak_megabytes_allocated', 1240, 10))
# 2012-08-14: 1203 (amd64/Linux)
# 2012-08-21: 1199 (amd64/Linux)
# 2012-09-20: 1228 (amd64/Linux)
# 2012-10-08: 1240 (amd64/Linux)
,if_wordsize(32,
,when(wordsize(32),
stats_range_field('peak_megabytes_allocated', 606, 1))
# 2012-08-14: 631 (x86/OSX)
# 2012-10-30: 606 (x86/Windows)
,if_wordsize(64,
,when(wordsize(64),
stats_range_field('max_bytes_used', 420105120, 10))
# 2012-08-14: 428775544 (amd64/Linux)
# 2012-09-20: 437618008 (amd64/Linux)
# 2012-10-08: 442768280 (amd64/Linux)
# 2012-11-12: 420105120 (amd64/Linux)
,if_wordsize(32,
,when(wordsize(32),
stats_range_field('max_bytes_used', 220847924, 1))
# 2012-08-14: 231064920 (x86/OSX)
# 2012-10-30: 220847924 (x86/Windows)
,if_wordsize(64,
,when(wordsize(64),
stats_range_field('bytes allocated', 25990254632, 10))
# 2012-08-14: 26,070,600,504 (amd64/Linux)
# 2012-08-29: 26,353,100,288 (amd64/Linux, new CG)
# 2012-09-18: 26,882,813,032 (amd64/Linux)
# 2012-11-12: 25,990,254,632 (amd64/Linux)
,if_wordsize(32,
,when(wordsize(32),
stats_range_field('bytes allocated', 13773051312, 1))
# 2012-08-14: 13471797488 (x86/OSX)
# 2012-10-30: 13773051312 (x86/Windows)
......
......@@ -59,10 +59,10 @@ test('T3738',
[extra_clean(['T3738a.hi', 'T3738a.o']),
stats_range_field('peak_megabytes_allocated', 1, 0),
# expected value: 1 (amd64/Linux)
if_wordsize(32,
when(wordsize(32),
stats_range_field('bytes allocated', 45648, 5)),
# expected value: 45648 (x86/Linux):
if_wordsize(64,
when(wordsize(64),
stats_range_field('bytes allocated', 49400, 5)),
# expected value: 49400 (amd64/Linux)
only_ways(['normal'])
......@@ -74,10 +74,10 @@ test('MethSharing',
[stats_range_field('peak_megabytes_allocated', 1, 0),
# expected value: 1 (amd64/Linux)
# expected value: 2685858140 (x86/OS X):
if_wordsize(32,
when(wordsize(32),
stats_range_field('bytes allocated', 360940756, 5)),
# expected: 360940756 (x86/Linux)
if_wordsize(64,
when(wordsize(64),
stats_range_field('bytes allocated', 640067672, 5)),
# expected: 640067672 (amd64/Linux)
only_ways(['normal'])
......@@ -104,9 +104,9 @@ test('T149',
test('T5113',
[
if_wordsize(32,
when(wordsize(32),
stats_range_field('bytes allocated', 4000000, 5)),
if_wordsize(64,
when(wordsize(64),
stats_range_field('bytes allocated', 8000000, 5)),
only_ways(['normal']),
expect_broken(7046)
......@@ -116,9 +116,9 @@ test('T5113',
test('T4978',
[if_wordsize(32,
[when(wordsize(32),
stats_range_field('bytes allocated', 10000000, 5)),
if_wordsize(64,
when(wordsize(64),
stats_range_field('bytes allocated', 10137680, 5)),
# expected value: 10137680 (amd64/Linux)
only_ways(['normal'])
......@@ -127,10 +127,10 @@ test('T4978',
['-O2'])
test('T5205',
[if_wordsize(32,
[when(wordsize(32),
stats_range_field('bytes allocated', 47088, 5)),
# expected value: 47088 (x86/Darwin)
if_wordsize(64,
when(wordsize(64),
stats_range_field('bytes allocated', 51320, 5)),
# expected value: 51320 (amd64/Linux)
only_ways(['normal', 'optasm'])
......@@ -139,10 +139,10 @@ test('T5205',
[''])
test('T5549',
[if_wordsize(32,
[when(wordsize(32),
stats_range_field('bytes allocated', 3362958676, 5)),
# expected value: 3362958676 (Windows)
if_wordsize(64,
when(wordsize(64),
stats_range_field('bytes allocated', 6725846120, 5)),
# expected value: 6,725,846,120 (amd64/Linux)
only_ways(['normal'])
......@@ -151,10 +151,10 @@ test('T5549',
['-O'])
test('T4474a',
[if_wordsize(32,
[when(wordsize(32),
stats_range_field('bytes allocated', 1879095912, 5)),
# expected value: 1879095912 (i386/OSX)
if_wordsize(64,
when(wordsize(64),
stats_range_field('bytes allocated', 3766493912, 5)),
# expected value: 3766493912 (amd64/Linux)
only_ways(['normal'])
......@@ -162,10 +162,10 @@ test('T4474a',
compile_and_run,
['-O'])
test('T4474b',
[if_wordsize(32,
[when(wordsize(32),
stats_range_field('bytes allocated', 1879095912, 5)),
# expected value: 1879095912 (i386/OSX)
if_wordsize(64,
when(wordsize(64),
stats_range_field('bytes allocated', 3766493912, 5)),
# expected value: 3766493912 (amd64/Linux)
only_ways(['normal'])
......@@ -173,10 +173,10 @@ test('T4474b',
compile_and_run,
['-O'])
test('T4474c',
[if_wordsize(32,
[when(wordsize(32),
stats_range_field('bytes allocated', 1879095912, 5)),
# expected value: 1879095912 (i386/OSX)
if_wordsize(64,
when(wordsize(64),
stats_range_field('bytes allocated', 3766493912, 5)),
# expected value: 3766493912 (amd64/Linux)
only_ways(['normal'])
......@@ -185,10 +185,10 @@ test('T4474c',
['-O'])
test('T5237',
[if_wordsize(32,
[when(wordsize(32),
stats_range_field('bytes allocated', 78328, 5)),
# expected value: 78328 (i386/Linux)
if_wordsize(64,
when(wordsize(64),
stats_range_field('bytes allocated', 110888, 5)),
# expected value: 110888 (amd64/Linux)
only_ways(['normal'])
......@@ -197,10 +197,10 @@ test('T5237',
['-O ' + sse2_opts])
test('T5536',
[if_wordsize(32,
[when(wordsize(32),
stats_range_field('bytes allocated', 1246287228, 5)),
# expected value: 1246287228 (i386/Linux)
if_wordsize(64,
when(wordsize(64),
stats_range_field('bytes allocated', 892399040, 5)),
# expected value: 2,492,589,480 (amd64/Linux)
# 17/1/13: 892,399,040 (x86_64/Linux)
......@@ -213,16 +213,16 @@ test('T5536',
['-O'])
test('T7257',
[if_wordsize(32,
[when(wordsize(32),
stats_range_field('bytes allocated', 1150000000, 10)),
# expected value: 1246287228 (i386/Linux)
if_wordsize(32,
when(wordsize(32),
stats_range_field('peak_megabytes_allocated', 217, 5)),
# 2012-10-08: 217 (x86/Linux)
if_wordsize(64,
when(wordsize(64),
stats_range_field('bytes allocated', 1774893760, 5)),
# 2012-09-21: 1774893760 (amd64/Linux)
if_wordsize(64,
when(wordsize(64),
stats_range_field('peak_megabytes_allocated', 227, 5)),
# 2012-09-21: 227 (amd64/Linux)
......@@ -231,10 +231,10 @@ test('T7257',
compile_and_run, ['-O'])
test('Conversions',
[if_wordsize(32,
[when(wordsize(32),
stats_range_field('bytes allocated', 55316, 5)),
# 2012-12-18: Guessed 64-bit value / 2
if_wordsize(64,
when(wordsize(64),
stats_range_field('bytes allocated', 110632, 5)),
# 2012-12-18: 109608 (amd64/OS X)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment