Commit 42e85284 authored by Ben Gamari's avatar Ben Gamari Committed by Ben Gamari
Browse files

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
parent 2624298a
...@@ -981,7 +981,12 @@ callishMachOps = listToUFM $ ...@@ -981,7 +981,12 @@ callishMachOps = listToUFM $
("prefetch0", (,) $ MO_Prefetch_Data 0), ("prefetch0", (,) $ MO_Prefetch_Data 0),
("prefetch1", (,) $ MO_Prefetch_Data 1), ("prefetch1", (,) $ MO_Prefetch_Data 1),
("prefetch2", (,) $ MO_Prefetch_Data 2), ("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 -- ToDo: the rest, maybe
-- edit: which rest? -- edit: which rest?
......
{-# LANGUAGE MagicHash,GHCForeignImportPrim,UnliftedFFITypes #-}
module Main where
import GHC.Exts
foreign import prim "do_popcnt32" popcnt32 :: Int# -> Int#
main = print (I# (popcnt32 0xffff#))
#include "Cmm.h"
do_popcnt32 (W_ x)
{
W_ res;
(res) = prim %popcnt32(x);
R1 = res;
jump %ENTRY_CODE(Sp(0)) [R1];
}
...@@ -139,3 +139,5 @@ test('T10414', [only_ways(['threaded2']), extra_ways(['threaded2'])], ...@@ -139,3 +139,5 @@ test('T10414', [only_ways(['threaded2']), extra_ways(['threaded2'])],
test('T10521', normal, compile_and_run, ['']) test('T10521', normal, compile_and_run, [''])
test('T10521b', normal, compile_and_run, ['']) test('T10521b', normal, compile_and_run, [''])
test('T10870', 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
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