diff options
author | Ben Gamari <ben@smart-cactus.org> | 2015-06-16 20:16:16 +0200 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2015-06-16 20:16:16 +0200 |
commit | a0d158fdd1db6b8f586bcbc1acd317d9836fb9dc (patch) | |
tree | 82a297bb2bfef97a20ba33d106b35ed9286579ee /testsuite/tests/codeGen | |
parent | d46fdf25888e624e78eefed64bd13dc205ed5fef (diff) | |
parent | 681973c31c614185229bdae4f6b7ab4f6e64753d (diff) | |
download | haskell-a0d158fdd1db6b8f586bcbc1acd317d9836fb9dc.tar.gz |
Encode alignment in MO_Memcpy and friends
Summary:
Alignment needs to be a compile-time constant. Previously the code
generators had to jump through hoops to ensure this was the case as the
alignment was passed as a CmmExpr in the arguments list. Now we take
care of this up front.
This fixes #8131.
Authored-by: Reid Barton <rwbarton@gmail.com>
Dusted-off-by: Ben Gamari <ben@smart-cactus.org>
Tests for T8131
Test Plan: Validate
Reviewers: rwbarton, austin
Reviewed By: rwbarton, austin
Subscribers: bgamari, carter, thomie
Differential Revision: https://phabricator.haskell.org/D624
GHC Trac Issues: #8131
Diffstat (limited to 'testsuite/tests/codeGen')
5 files changed, 24 insertions, 11 deletions
diff --git a/testsuite/tests/codeGen/should_fail/Makefile b/testsuite/tests/codeGen/should_fail/Makefile new file mode 100644 index 0000000000..9101fbd40a --- /dev/null +++ b/testsuite/tests/codeGen/should_fail/Makefile @@ -0,0 +1,3 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk diff --git a/testsuite/tests/codeGen/should_fail/T8131.cmm b/testsuite/tests/codeGen/should_fail/T8131.cmm new file mode 100644 index 0000000000..153fb02b24 --- /dev/null +++ b/testsuite/tests/codeGen/should_fail/T8131.cmm @@ -0,0 +1,7 @@ +#include "Cmm.h" + +testMemcpy (W_ dst, W_ src, W_ l, W_ sz) +{ + prim %memcpy(dst, src, l, sz); + return (); +} diff --git a/testsuite/tests/codeGen/should_fail/all.T b/testsuite/tests/codeGen/should_fail/all.T new file mode 100644 index 0000000000..39faebb619 --- /dev/null +++ b/testsuite/tests/codeGen/should_fail/all.T @@ -0,0 +1,3 @@ +# Tests for code generator and CMM parser + +test('T8131', cmm_src, compile_fail, ['']) diff --git a/testsuite/tests/codeGen/should_gen_asm/memcpy-unroll-conprop.cmm b/testsuite/tests/codeGen/should_gen_asm/memcpy-unroll-conprop.cmm index be4883d34f..bdb5c3cc9e 100644 --- a/testsuite/tests/codeGen/should_gen_asm/memcpy-unroll-conprop.cmm +++ b/testsuite/tests/codeGen/should_gen_asm/memcpy-unroll-conprop.cmm @@ -6,7 +6,7 @@ callMemcpy (W_ dst, W_ src) W_ size; W_ alig; size = 16; - alig = 4; +#define alig 4 if (dst != 0) { prim %memcpy(dst, src, size, alig); } diff --git a/testsuite/tests/codeGen/should_run/cgrun069_cmm.cmm b/testsuite/tests/codeGen/should_run/cgrun069_cmm.cmm index 61cc5d8bfd..13a26aa012 100644 --- a/testsuite/tests/codeGen/should_run/cgrun069_cmm.cmm +++ b/testsuite/tests/codeGen/should_run/cgrun069_cmm.cmm @@ -11,23 +11,24 @@ section "rodata" { memmoveErr : bits8[] "Memmove Error Occured\n"; } memintrinTest (W_ dummy) { - W_ size, src, dst, off, alignV, set; + W_ size, src, dst, off, set; bits8 set8; - // Need two versions as memset takes a word for historical reasons + // Need two versions as memset takes a word for historical reasons // but really its a bits8. We check that setting has ben done correctly // at the bits8 level, so need bits8 version for checking. set = 4; set8 = 4::bits8; size = 1024; - alignV = 4; +// Alignment must be constant expression +#define alignV 4 ("ptr" src) = foreign "C" malloc(size); ("ptr" dst) = foreign "C" malloc(size); // Test memset - prim %memset(src, set, size, alignV); + prim %memset(src, set, size, alignV); // Check memset worked off = 0; @@ -100,6 +101,7 @@ while3_end: return (0); } +#undef alignV // --------------------------------------------------------------------- // Tests for unrolling @@ -113,15 +115,14 @@ while3_end: // has ben done correctly at the bits8 level, so need bits8 version // for checking. #define TEST_MEMSET(ALIGN,SIZE) \ - W_ size, src, dst, off, alignV, set; \ + W_ size, src, dst, off, set; \ bits8 set8; \ set = 4; \ set8 = 4::bits8; \ size = SIZE; \ - alignV = ALIGN; \ ("ptr" src) = foreign "C" malloc(size); \ ("ptr" dst) = foreign "C" malloc(size); \ - prim %memset(src, set, size, alignV); \ + prim %memset(src, set, size, ALIGN); \ off = 0; \ loop: \ if (off == size) { \ @@ -164,9 +165,8 @@ testMemset4_7 (W_ dummy) { TEST_MEMSET(4,7); } testMemset4_8 (W_ dummy) { TEST_MEMSET(4,8); } #define TEST_MEMCPY(ALIGN,SIZE) \ - W_ size, src, dst, off, alignV; \ + W_ size, src, dst, off; \ size = SIZE; \ - alignV = ALIGN; \ ("ptr" src) = foreign "C" malloc(size); \ ("ptr" dst) = foreign "C" malloc(size); \ off = 0; \ @@ -178,7 +178,7 @@ init: \ off = off + 1; \ goto init; \ init_end: \ - prim %memcpy(dst, src, size, alignV); \ + prim %memcpy(dst, src, size, ALIGN); \ off = 0; \ loop: \ if (off == size) { \ |