Permalink
Browse files

cpu: enable bit-test intrinsic for fixnum-bit?.

  • Loading branch information...
mrjbq7 committed Jun 18, 2015
1 parent db9cfee commit 621b50a8e5c6beab78fd60c4c3a3d94f968406dd
@@ -224,6 +224,11 @@ FOLDABLE-INSN: ##bit-count
def: dst/int-rep
use: src/int-rep ;
+FOLDABLE-INSN: ##bit-test
+def: dst/tagged-rep
+use: src1/int-rep src2/int-rep
+temp: temp/int-rep ;
+
! Float arithmetic
FOLDABLE-INSN: ##add-float
def: dst/double-rep
@@ -138,5 +138,10 @@ ERROR: inline-intrinsics-not-supported word quot ;
{ math.bitwise.private:fixnum-bit-count [ drop [ ^^bit-count ] unary-op ] }
} enable-intrinsics ;
+: enable-bit-test ( -- )
+ {
+ { math.integers.private:fixnum-bit? [ drop [ ^^bit-test ] binary-op ] }
+ } enable-intrinsics ;
+
: emit-intrinsic ( node word -- )
"intrinsic" word-prop call( node -- ) ;
@@ -181,6 +181,7 @@ CODEGEN: ##not %not
CODEGEN: ##neg %neg
CODEGEN: ##log2 %log2
CODEGEN: ##bit-count %bit-count
+CODEGEN: ##bit-test %bit-test
CODEGEN: ##copy %copy
CODEGEN: ##tagged>integer %tagged>integer
CODEGEN: ##add-float %add-float
@@ -271,6 +271,7 @@ HOOK: %not cpu ( dst src -- )
HOOK: %neg cpu ( dst src -- )
HOOK: %log2 cpu ( dst src -- )
HOOK: %bit-count cpu ( dst src -- )
+HOOK: %bit-test cpu ( dst src1 src2 temp -- )
HOOK: %copy cpu ( dst src rep -- )
View
@@ -764,6 +764,12 @@ M: x86 immediate-bitwise? ( n -- ? )
enable-min/max
enable-log2
+M:: x86 %bit-test ( dst src1 src2 temp -- )
+ src1 src2 BT
+ dst temp \ CMOVB (%boolean) ;
+
+enable-bit-test
+
: check-sse ( -- )
"Checking for multimedia extensions... " write flush
sse-version
@@ -53,7 +53,7 @@ M: fixnum bitnot fixnum-bitnot ; inline
: fixnum-bit? ( x n -- ? )
{ fixnum fixnum } declare
- dup 0 >= [ neg shift even? not ] [ 2drop f ] if ; inline
+ dup 0 >= [ neg shift even? not ] [ 2drop f ] if ;
M: fixnum bit? integer>fixnum-strict fixnum-bit? ; inline

0 comments on commit 621b50a

Please sign in to comment.