diff --git a/basis/cpu/x86/32/32.factor b/basis/cpu/x86/32/32.factor index f1da80f3f5..54a25310d6 100755 --- a/basis/cpu/x86/32/32.factor +++ b/basis/cpu/x86/32/32.factor @@ -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 diff --git a/basis/cpu/x86/64/64.factor b/basis/cpu/x86/64/64.factor index f8e9310d64..6c2acac628 100644 --- a/basis/cpu/x86/64/64.factor +++ b/basis/cpu/x86/64/64.factor @@ -150,4 +150,4 @@ USE: vocabs { [ os windows? ] [ "cpu.x86.64.windows" require ] } } cond -check-sse +check-cpu-features diff --git a/basis/cpu/x86/features/features.factor b/basis/cpu/x86/features/features.factor index e333c8c6b5..7c4026bb6b 100644 --- a/basis/cpu/x86/features/features.factor +++ b/basis/cpu/x86/features/features.factor @@ -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" ] } diff --git a/basis/cpu/x86/x86.factor b/basis/cpu/x86/x86.factor index 51e32c643d..832ee51bd5 100644 --- a/basis/cpu/x86/x86.factor +++ b/basis/cpu/x86/x86.factor @@ -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 ;