Merge branch 'master' of git://factorcode.org/git/factor

db4
Joe Groff 2009-08-25 23:22:43 -05:00
commit ff9b54fd0c
12 changed files with 31 additions and 24 deletions

View File

@ -43,6 +43,7 @@ IN: compiler.cfg.hats
: ^^sub-float ( src1 src2 -- dst ) ^^r2 ##sub-float ; inline : ^^sub-float ( src1 src2 -- dst ) ^^r2 ##sub-float ; inline
: ^^mul-float ( src1 src2 -- dst ) ^^r2 ##mul-float ; inline : ^^mul-float ( src1 src2 -- dst ) ^^r2 ##mul-float ; inline
: ^^div-float ( src1 src2 -- dst ) ^^r2 ##div-float ; inline : ^^div-float ( src1 src2 -- dst ) ^^r2 ##div-float ; inline
: ^^sqrt ( src -- dst ) ^^r1 ##sqrt ; inline
: ^^float>integer ( src -- dst ) ^^r1 ##float>integer ; inline : ^^float>integer ( src -- dst ) ^^r1 ##float>integer ; inline
: ^^integer>float ( src -- dst ) ^^r1 ##integer>float ; inline : ^^integer>float ( src -- dst ) ^^r1 ##integer>float ; inline
: ^^allot ( size class -- dst ) ^^r2 next-vreg ##allot ; inline : ^^allot ( size class -- dst ) ^^r2 next-vreg ##allot ; inline

View File

@ -106,6 +106,7 @@ INSN: ##add-float < ##commutative ;
INSN: ##sub-float < ##binary ; INSN: ##sub-float < ##binary ;
INSN: ##mul-float < ##commutative ; INSN: ##mul-float < ##commutative ;
INSN: ##div-float < ##binary ; INSN: ##div-float < ##binary ;
INSN: ##sqrt < ##unary ;
! Float/integer conversion ! Float/integer conversion
INSN: ##float>integer < ##unary ; INSN: ##float>integer < ##unary ;
@ -256,6 +257,7 @@ UNION: output-float-insn
##sub-float ##sub-float
##mul-float ##mul-float
##div-float ##div-float
##sqrt
##integer>float ##integer>float
##unbox-float ##unbox-float
##alien-float ##alien-float
@ -267,6 +269,7 @@ UNION: input-float-insn
##sub-float ##sub-float
##mul-float ##mul-float
##div-float ##div-float
##sqrt
##float>integer ##float>integer
##box-float ##box-float
##set-alien-float ##set-alien-float

View File

@ -15,3 +15,6 @@ IN: compiler.cfg.intrinsics.float
: emit-fixnum>float ( -- ) : emit-fixnum>float ( -- )
ds-pop ^^untag-fixnum ^^integer>float ds-push ; ds-pop ^^untag-fixnum ^^integer>float ds-push ;
: emit-fsqrt ( -- )
ds-pop ^^sqrt ds-push ;

View File

@ -19,6 +19,7 @@ QUALIFIED: strings.private
QUALIFIED: classes.tuple.private QUALIFIED: classes.tuple.private
QUALIFIED: math.private QUALIFIED: math.private
QUALIFIED: math.integers.private QUALIFIED: math.integers.private
QUALIFIED: math.libm
QUALIFIED: alien.accessors QUALIFIED: alien.accessors
IN: compiler.cfg.intrinsics IN: compiler.cfg.intrinsics
@ -92,6 +93,9 @@ IN: compiler.cfg.intrinsics
alien.accessors:set-alien-double alien.accessors:set-alien-double
} [ t "intrinsic" set-word-prop ] each ; } [ t "intrinsic" set-word-prop ] each ;
: enable-fsqrt ( -- )
\ math.libm:fsqrt t "intrinsic" set-word-prop ;
: enable-fixnum-log2 ( -- ) : enable-fixnum-log2 ( -- )
\ math.integers.private:fixnum-log2 t "intrinsic" set-word-prop ; \ math.integers.private:fixnum-log2 t "intrinsic" set-word-prop ;
@ -130,6 +134,7 @@ IN: compiler.cfg.intrinsics
{ \ math.private:float= [ drop cc= emit-float-comparison ] } { \ math.private:float= [ drop cc= emit-float-comparison ] }
{ \ math.private:float>fixnum [ drop emit-float>fixnum ] } { \ math.private:float>fixnum [ drop emit-float>fixnum ] }
{ \ math.private:fixnum>float [ drop emit-fixnum>float ] } { \ math.private:fixnum>float [ drop emit-fixnum>float ] }
{ \ math.libm:fsqrt [ drop emit-fsqrt ] }
{ \ slots.private:slot [ emit-slot ] } { \ slots.private:slot [ emit-slot ] }
{ \ slots.private:set-slot [ emit-set-slot ] } { \ slots.private:set-slot [ emit-set-slot ] }
{ \ strings.private:string-nth [ drop emit-string-nth ] } { \ strings.private:string-nth [ drop emit-string-nth ] }

View File

@ -170,6 +170,8 @@ M: ##sub-float generate-insn dst/src1/src2 %sub-float ;
M: ##mul-float generate-insn dst/src1/src2 %mul-float ; M: ##mul-float generate-insn dst/src1/src2 %mul-float ;
M: ##div-float generate-insn dst/src1/src2 %div-float ; M: ##div-float generate-insn dst/src1/src2 %div-float ;
M: ##sqrt generate-insn dst/src %sqrt ;
M: ##integer>float generate-insn dst/src %integer>float ; M: ##integer>float generate-insn dst/src %integer>float ;
M: ##float>integer generate-insn dst/src %float>integer ; M: ##float>integer generate-insn dst/src %float>integer ;

View File

@ -2,11 +2,12 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: kernel effects accessors math math.private USING: kernel effects accessors math math.private
math.integers.private math.partial-dispatch math.intervals math.integers.private math.partial-dispatch math.intervals
math.parser math.order math.functions layouts words sequences sequences.private math.parser math.order math.functions math.libm layouts words
arrays assocs classes classes.algebra combinators generic.math sequences sequences.private arrays assocs classes
splitting fry locals classes.tuple alien.accessors classes.algebra combinators generic.math splitting fry locals
classes.tuple.private slots.private definitions strings.private classes.tuple alien.accessors classes.tuple.private
vectors hashtables generic quotations slots.private definitions strings.private vectors hashtables
generic quotations
stack-checker.state stack-checker.state
compiler.tree.comparisons compiler.tree.comparisons
compiler.tree.propagation.info compiler.tree.propagation.info
@ -297,3 +298,8 @@ generic-comparison-ops [
bi bi
] [ 2drop object-info ] if ] [ 2drop object-info ] if
] "outputs" set-word-prop ] "outputs" set-word-prop
{ facos fasin fatan fatan2 fcos fsin ftan fcosh fsinh ftanh fexp
flog fpow fsqrt facosh fasinh fatanh } [
{ float } "default-output-classes" set-word-prop
] each

View File

@ -110,6 +110,7 @@ HOOK: %add-float cpu ( dst src1 src2 -- )
HOOK: %sub-float cpu ( dst src1 src2 -- ) HOOK: %sub-float cpu ( dst src1 src2 -- )
HOOK: %mul-float cpu ( dst src1 src2 -- ) HOOK: %mul-float cpu ( dst src1 src2 -- )
HOOK: %div-float cpu ( dst src1 src2 -- ) HOOK: %div-float cpu ( dst src1 src2 -- )
HOOK: %sqrt cpu ( dst src -- )
HOOK: %integer>float cpu ( dst src -- ) HOOK: %integer>float cpu ( dst src -- )
HOOK: %float>integer cpu ( dst src -- ) HOOK: %float>integer cpu ( dst src -- )

View File

@ -205,7 +205,7 @@ MTSPR: CTR 9
: SRWI ( d a b -- ) (SRWI) RLWINM ; : SRWI ( d a b -- ) (SRWI) RLWINM ;
: SRWI. ( d a b -- ) (SRWI) RLWINM. ; : SRWI. ( d a b -- ) (SRWI) RLWINM. ;
:: LOAD32 ( n r -- ) :: LOAD32 ( n r -- )
n -16 shift HEX: 7fff bitand r LIS n -16 shift HEX: ffff bitand r LIS
r r n HEX: 7fff bitand ORI ; r r n HEX: ffff bitand ORI ;
: immediate? ( n -- ? ) HEX: -8000 HEX: 7fff between? ; : immediate? ( n -- ? ) HEX: -8000 HEX: 7fff between? ;
: LOAD ( n r -- ) over immediate? [ LI ] [ LOAD32 ] if ; : LOAD ( n r -- ) over immediate? [ LI ] [ LOAD32 ] if ;

View File

@ -304,6 +304,7 @@ USING: cpu.x86.features cpu.x86.features.private ;
sse2? [ sse2? [
" - yes" print " - yes" print
enable-float-intrinsics enable-float-intrinsics
enable-fsqrt
[ [
sse2? [ sse2? [
"This image was built to use SSE2, which your CPU does not support." print "This image was built to use SSE2, which your CPU does not support." print

View File

@ -203,6 +203,7 @@ enable-alien-4-intrinsics
! SSE2 is always available on x86-64. ! SSE2 is always available on x86-64.
enable-float-intrinsics enable-float-intrinsics
enable-fsqrt
USE: vocabs.loader USE: vocabs.loader

View File

@ -203,6 +203,7 @@ M: x86 %add-float nip ADDSD ;
M: x86 %sub-float nip SUBSD ; M: x86 %sub-float nip SUBSD ;
M: x86 %mul-float nip MULSD ; M: x86 %mul-float nip MULSD ;
M: x86 %div-float nip DIVSD ; M: x86 %div-float nip DIVSD ;
M: x86 %sqrt SQRTSD ;
M: x86 %integer>float CVTSI2SD ; M: x86 %integer>float CVTSI2SD ;
M: x86 %float>integer CVTTSD2SI ; M: x86 %float>integer CVTTSD2SI ;

View File

@ -5,69 +5,52 @@ IN: math.libm
: facos ( x -- y ) : facos ( x -- y )
"double" "libm" "acos" { "double" } alien-invoke ; "double" "libm" "acos" { "double" } alien-invoke ;
inline
: fasin ( x -- y ) : fasin ( x -- y )
"double" "libm" "asin" { "double" } alien-invoke ; "double" "libm" "asin" { "double" } alien-invoke ;
inline
: fatan ( x -- y ) : fatan ( x -- y )
"double" "libm" "atan" { "double" } alien-invoke ; "double" "libm" "atan" { "double" } alien-invoke ;
inline
: fatan2 ( x y -- z ) : fatan2 ( x y -- z )
"double" "libm" "atan2" { "double" "double" } alien-invoke ; "double" "libm" "atan2" { "double" "double" } alien-invoke ;
inline
: fcos ( x -- y ) : fcos ( x -- y )
"double" "libm" "cos" { "double" } alien-invoke ; "double" "libm" "cos" { "double" } alien-invoke ;
inline
: fsin ( x -- y ) : fsin ( x -- y )
"double" "libm" "sin" { "double" } alien-invoke ; "double" "libm" "sin" { "double" } alien-invoke ;
inline
: ftan ( x -- y ) : ftan ( x -- y )
"double" "libm" "tan" { "double" } alien-invoke ; "double" "libm" "tan" { "double" } alien-invoke ;
inline
: fcosh ( x -- y ) : fcosh ( x -- y )
"double" "libm" "cosh" { "double" } alien-invoke ; "double" "libm" "cosh" { "double" } alien-invoke ;
inline
: fsinh ( x -- y ) : fsinh ( x -- y )
"double" "libm" "sinh" { "double" } alien-invoke ; "double" "libm" "sinh" { "double" } alien-invoke ;
inline
: ftanh ( x -- y ) : ftanh ( x -- y )
"double" "libm" "tanh" { "double" } alien-invoke ; "double" "libm" "tanh" { "double" } alien-invoke ;
inline
: fexp ( x -- y ) : fexp ( x -- y )
"double" "libm" "exp" { "double" } alien-invoke ; "double" "libm" "exp" { "double" } alien-invoke ;
inline
: flog ( x -- y ) : flog ( x -- y )
"double" "libm" "log" { "double" } alien-invoke ; "double" "libm" "log" { "double" } alien-invoke ;
inline
: fpow ( x y -- z ) : fpow ( x y -- z )
"double" "libm" "pow" { "double" "double" } alien-invoke ; "double" "libm" "pow" { "double" "double" } alien-invoke ;
inline
: fsqrt ( x -- y ) : fsqrt ( x -- y )
"double" "libm" "sqrt" { "double" } alien-invoke ; "double" "libm" "sqrt" { "double" } alien-invoke ;
inline
! Windows doesn't have these... ! Windows doesn't have these...
: facosh ( x -- y ) : facosh ( x -- y )
"double" "libm" "acosh" { "double" } alien-invoke ; "double" "libm" "acosh" { "double" } alien-invoke ;
inline
: fasinh ( x -- y ) : fasinh ( x -- y )
"double" "libm" "asinh" { "double" } alien-invoke ; "double" "libm" "asinh" { "double" } alien-invoke ;
inline
: fatanh ( x -- y ) : fatanh ( x -- y )
"double" "libm" "atanh" { "double" } alien-invoke ; "double" "libm" "atanh" { "double" } alien-invoke ;
inline