cpu.x86: enable POPCNT with a flag
If bootstrapped with '-enable-popcnt' and the host CPU supports it, enable the POPCNT-based fixnum-bit-count intrinsic. Fixes #436.db4
parent
ff50cc6f0f
commit
d927a070ed
|
@ -236,4 +236,4 @@ M: x86.32 flatten-struct-type
|
|||
|
||||
M: x86.32 struct-return-on-stack? os linux? not ;
|
||||
|
||||
check-sse
|
||||
check-cpu-features
|
||||
|
|
|
@ -150,4 +150,4 @@ USE: vocabs
|
|||
{ [ os windows? ] [ "cpu.x86.64.windows" require ] }
|
||||
} cond
|
||||
|
||||
check-sse
|
||||
check-cpu-features
|
||||
|
|
|
@ -77,8 +77,6 @@ PRIVATE>
|
|||
MEMO: sse-version ( -- n )
|
||||
(sse-version) "sse-version" get string>number [ min ] when* ;
|
||||
|
||||
[ \ sse-version reset-memoized ] "cpu.x86.features" add-startup-hook
|
||||
|
||||
: sse? ( -- ? ) sse-version 10 >= ;
|
||||
: sse2? ( -- ? ) sse-version 20 >= ;
|
||||
: sse3? ( -- ? ) sse-version 30 >= ;
|
||||
|
@ -95,6 +93,12 @@ MEMO: sse-version ( -- n )
|
|||
return-reg SETB
|
||||
] alien-assembly ;
|
||||
|
||||
MEMO: enable-popcnt? ( -- ? )
|
||||
popcnt? "enable-popcnt" get and ;
|
||||
|
||||
[ { sse-version enable-popcnt? } [ reset-memoized ] each ]
|
||||
"cpu.x86.features" add-startup-hook
|
||||
|
||||
: sse-string ( version -- string )
|
||||
{
|
||||
{ 00 [ "no SSE" ] }
|
||||
|
|
|
@ -776,7 +776,17 @@ enable-log2
|
|||
|
||||
: check-sse ( -- )
|
||||
"Checking for multimedia extensions... " write flush
|
||||
[ { (sse-version) } compile ] with-optimizer
|
||||
sse-version
|
||||
[ sse-string " detected" append print ]
|
||||
[ 20 < "cpu.x86.x87" "cpu.x86.sse" ? require ] bi ;
|
||||
|
||||
: check-popcnt ( -- )
|
||||
enable-popcnt? [
|
||||
"Building with POPCNT support" print
|
||||
enable-bit-count
|
||||
] when ;
|
||||
|
||||
: check-cpu-features ( -- )
|
||||
[ { (sse-version) popcnt? } compile ] with-optimizer
|
||||
check-sse
|
||||
check-popcnt ;
|
||||
|
|
Loading…
Reference in New Issue