]> gitweb.factorcode.org Git - factor.git/commitdiff
cpu.x86: enable POPCNT with a flag
authorJoe Groff <arcata@gmail.com>
Tue, 13 Dec 2011 00:43:49 +0000 (16:43 -0800)
committerJoe Groff <arcata@gmail.com>
Tue, 13 Dec 2011 00:43:49 +0000 (16:43 -0800)
If bootstrapped with '-enable-popcnt' and the host CPU supports it, enable the POPCNT-based fixnum-bit-count intrinsic. Fixes #436.

basis/cpu/x86/32/32.factor
basis/cpu/x86/64/64.factor
basis/cpu/x86/features/features.factor
basis/cpu/x86/x86.factor

index f1da80f3f5edbcf540974cb1edf4427738b18264..54a25310d6ec6aa084ced5b16ac3b59c14965c28 100755 (executable)
@@ -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
index f8e9310d64be0050a679e577c30e0619ce9e8e70..6c2acac628698cc33949403f17b69986c67d2bc0 100644 (file)
@@ -150,4 +150,4 @@ USE: vocabs
     { [ os windows? ] [ "cpu.x86.64.windows" require ] }
 } cond
 
-check-sse
+check-cpu-features
index e333c8c6b5f065a454a2e9d33abd4528a6de8f99..7c4026bb6b9fa8e4563752dcdfac1b059588a1c1 100644 (file)
@@ -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" ] }
index 51e32c643d76e8f8473bbb2b4b62016f0e20be35..832ee51bd5ea91a8fad7d929fc7d6a429d3d3660 100644 (file)
@@ -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 ;