Skip to content

Commit

Permalink
cpu: enable bit-test intrinsic for fixnum-bit?.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjbq7 committed Jun 18, 2015
1 parent db9cfee commit 621b50a
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions basis/compiler/cfg/instructions/instructions.factor
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions basis/compiler/cfg/intrinsics/intrinsics.factor
Expand Up @@ -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 -- ) ;
1 change: 1 addition & 0 deletions basis/compiler/codegen/codegen.factor
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions basis/cpu/architecture/architecture.factor
Expand Up @@ -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 -- )

Expand Down
6 changes: 6 additions & 0 deletions basis/cpu/x86/x86.factor
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion core/math/integers/integers.factor
Expand Up @@ -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

Expand Down

0 comments on commit 621b50a

Please sign in to comment.