diff options
| -rw-r--r-- | compiler/cmm/CmmParse.y | 7 | ||||
| -rw-r--r-- | testsuite/tests/codeGen/should_run/PopCnt.hs | 9 | ||||
| -rw-r--r-- | testsuite/tests/codeGen/should_run/PopCnt.stdout | 2 | ||||
| -rw-r--r-- | testsuite/tests/codeGen/should_run/PopCnt_cmm.cmm | 9 | ||||
| -rw-r--r-- | testsuite/tests/codeGen/should_run/all.T | 2 |
5 files changed, 28 insertions, 1 deletions
diff --git a/compiler/cmm/CmmParse.y b/compiler/cmm/CmmParse.y index 555aed25df..11e68bd4e1 100644 --- a/compiler/cmm/CmmParse.y +++ b/compiler/cmm/CmmParse.y @@ -981,7 +981,12 @@ callishMachOps = listToUFM $ ("prefetch0", (,) $ MO_Prefetch_Data 0), ("prefetch1", (,) $ MO_Prefetch_Data 1), ("prefetch2", (,) $ MO_Prefetch_Data 2), - ("prefetch3", (,) $ MO_Prefetch_Data 3) + ("prefetch3", (,) $ MO_Prefetch_Data 3), + + ( "popcnt8", (,) $ MO_PopCnt W8 ), + ( "popcnt16", (,) $ MO_PopCnt W16 ), + ( "popcnt32", (,) $ MO_PopCnt W32 ), + ( "popcnt64", (,) $ MO_PopCnt W64 ) -- ToDo: the rest, maybe -- edit: which rest? 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 |
