summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2015-10-30 19:53:52 +0100
committerBen Gamari <ben@smart-cactus.org>2015-10-30 19:54:00 +0100
commit42e85284b7be4aa298cff51119f33a72c0e3bd7a (patch)
tree266fb824f1b648d645a6da9a22734a87855928ab /testsuite
parent2624298a0d81e348b879c521b9fae3f389ebab08 (diff)
downloadhaskell-42e85284b7be4aa298cff51119f33a72c0e3bd7a.tar.gz
CmmParse: Expose popcnt operations
Make various population count operations available via C-- syntax under the names %popcnt{8,16,32,64}. Fixes #11037. Reviewers: simonmar, austin, ekmett Reviewed By: austin, ekmett Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1402 GHC Trac Issues: #11037
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/codeGen/should_run/PopCnt.hs9
-rw-r--r--testsuite/tests/codeGen/should_run/PopCnt.stdout2
-rw-r--r--testsuite/tests/codeGen/should_run/PopCnt_cmm.cmm9
-rw-r--r--testsuite/tests/codeGen/should_run/all.T2
4 files changed, 22 insertions, 0 deletions
diff --git a/testsuite/tests/codeGen/should_run/PopCnt.hs b/testsuite/tests/codeGen/should_run/PopCnt.hs
new file mode 100644
index 0000000000..e6c99a498e
--- /dev/null
+++ b/testsuite/tests/codeGen/should_run/PopCnt.hs
@@ -0,0 +1,9 @@
+{-# LANGUAGE MagicHash,GHCForeignImportPrim,UnliftedFFITypes #-}
+module Main where
+
+import GHC.Exts
+
+foreign import prim "do_popcnt32" popcnt32 :: Int# -> Int#
+
+main = print (I# (popcnt32 0xffff#))
+
diff --git a/testsuite/tests/codeGen/should_run/PopCnt.stdout b/testsuite/tests/codeGen/should_run/PopCnt.stdout
new file mode 100644
index 0000000000..b5794c5ecf
--- /dev/null
+++ b/testsuite/tests/codeGen/should_run/PopCnt.stdout
@@ -0,0 +1,2 @@
+16
+
diff --git a/testsuite/tests/codeGen/should_run/PopCnt_cmm.cmm b/testsuite/tests/codeGen/should_run/PopCnt_cmm.cmm
new file mode 100644
index 0000000000..21e02fafca
--- /dev/null
+++ b/testsuite/tests/codeGen/should_run/PopCnt_cmm.cmm
@@ -0,0 +1,9 @@
+#include "Cmm.h"
+
+do_popcnt32 (W_ x)
+{
+ W_ res;
+ (res) = prim %popcnt32(x);
+ R1 = res;
+ jump %ENTRY_CODE(Sp(0)) [R1];
+}
diff --git a/testsuite/tests/codeGen/should_run/all.T b/testsuite/tests/codeGen/should_run/all.T
index 13eda788de..defd9b2d44 100644
--- a/testsuite/tests/codeGen/should_run/all.T
+++ b/testsuite/tests/codeGen/should_run/all.T
@@ -139,3 +139,5 @@ test('T10414', [only_ways(['threaded2']), extra_ways(['threaded2'])],
test('T10521', normal, compile_and_run, [''])
test('T10521b', normal, compile_and_run, [''])
test('T10870', normal, compile_and_run, [''])
+test('PopCnt', omit_ways(['ghci']), multi_compile_and_run,
+ ['PopCnt', [('PopCnt_cmm.cmm', '')], '']) \ No newline at end of file