summaryrefslogtreecommitdiff
path: root/testsuite/driver/testlib.py
diff options
context:
space:
mode:
authorArtem Pyanykh <artem.pyanykh@gmail.com>2019-04-04 13:43:38 +0300
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-04-09 10:30:13 -0400
commitaf4cea7f1411e5b99e2417d7c2d3d0e697093103 (patch)
treeec9ef85347e5c8915e864573997c15aaa8cc5a73 /testsuite/driver/testlib.py
parent36d380475d9056fdf93305985be3def00aaf6cf7 (diff)
downloadhaskell-af4cea7f1411e5b99e2417d7c2d3d0e697093103.tar.gz
codegen: fix memset unroll for small bytearrays, add 64-bit sets
Fixes #16052 When the offset in `setByteArray#` is statically known, we can provide better alignment guarantees then just 1 byte. Also, memset can now do 64-bit wide sets. The current memset intrinsic is not optimal however and can be improved for the case when we know that we deal with (baseAddress at known alignment) + offset For instance, on 64-bit `setByteArray# s 1# 23# 0#` given that bytearray is 8 bytes aligned could be unrolled into `movb, movw, movl, movq, movq`; but currently it is `movb x23` since alignment of 1 is all we can embed into MO_Memset op.
Diffstat (limited to 'testsuite/driver/testlib.py')
-rw-r--r--testsuite/driver/testlib.py59
1 files changed, 57 insertions, 2 deletions
diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py
index 3fefb5274d..95274f30e5 100644
--- a/testsuite/driver/testlib.py
+++ b/testsuite/driver/testlib.py
@@ -1131,9 +1131,9 @@ def do_compile(name, way, should_fail, top_mod, extra_mods, extra_hc_opts, **kwa
# no problems found, this test passed
return passed()
-def compile_cmp_asm( name, way, extra_hc_opts ):
+def compile_cmp_asm( name, way, ext, extra_hc_opts ):
print('Compile only, extra args = ', extra_hc_opts)
- result = simple_build(name + '.cmm', way, '-keep-s-files -O ' + extra_hc_opts, 0, '', 0, 0)
+ result = simple_build(name + '.' + ext, way, '-keep-s-files -O ' + extra_hc_opts, 0, '', 0, 0)
if badResult(result):
return result
@@ -1153,6 +1153,24 @@ def compile_cmp_asm( name, way, extra_hc_opts ):
# no problems found, this test passed
return passed()
+def compile_grep_asm( name, way, ext, is_substring, extra_hc_opts ):
+ print('Compile only, extra args = ', extra_hc_opts)
+ result = simple_build(name + '.' + ext, way, '-keep-s-files -O ' + extra_hc_opts, 0, '', 0, 0)
+
+ if badResult(result):
+ return result
+
+ expected_pat_file = find_expected_file(name, 'asm')
+ actual_asm_file = add_suffix(name, 's')
+
+ if not grep_output(join_normalisers(normalise_errmsg),
+ expected_pat_file, actual_asm_file,
+ is_substring):
+ return failBecause('asm mismatch')
+
+ # no problems found, this test passed
+ return passed()
+
# -----------------------------------------------------------------------------
# Compile-and-run tests
@@ -1735,6 +1753,43 @@ def compare_outputs(way, kind, normaliser, expected_file, actual_file, diff_file
else:
return False
+# Checks that each line from pattern_file is present in actual_file as
+# a substring or regex pattern depending on is_substring.
+def grep_output(normaliser, pattern_file, actual_file, is_substring=True):
+ expected_path = in_srcdir(pattern_file)
+ actual_path = in_testdir(actual_file)
+
+ expected_patterns = read_no_crs(expected_path).strip().split('\n')
+ actual_raw = read_no_crs(actual_path)
+ actual_str = normaliser(actual_raw)
+
+ success = True
+ failed_patterns = []
+
+ def regex_match(pat, actual):
+ return re.search(pat, actual) is not None
+
+ def substring_match(pat, actual):
+ return pat in actual
+
+ def is_match(pat, actual):
+ if is_substring:
+ return substring_match(pat, actual)
+ else:
+ return regex_match(pat, actual)
+
+ for pat in expected_patterns:
+ if not is_match(pat, actual_str):
+ success = False
+ failed_patterns.append(pat)
+
+ if not success:
+ print('Actual output does not contain the following patterns:')
+ for pat in failed_patterns:
+ print(pat)
+
+ return success
+
# Note [Output comparison]
#
# We do two types of output comparison: