compiler: now that FFI has been deconcatenatized, we no longer need the special ##unary-float-function and ##binary-float-function fastpaths

db4
Slava Pestov 2010-08-13 23:59:19 -07:00
parent b5fc39c198
commit 1985705413
21 changed files with 9 additions and 126 deletions

View File

@ -35,8 +35,6 @@ M: ##unbox compute-stack-frame* drop vm-frame-required ;
M: ##box-long-long compute-stack-frame* drop vm-frame-required ; M: ##box-long-long compute-stack-frame* drop vm-frame-required ;
M: ##callback-inputs compute-stack-frame* drop vm-frame-required ; M: ##callback-inputs compute-stack-frame* drop vm-frame-required ;
M: ##callback-outputs compute-stack-frame* drop vm-frame-required ; M: ##callback-outputs compute-stack-frame* drop vm-frame-required ;
M: ##unary-float-function compute-stack-frame* drop vm-frame-required ;
M: ##binary-float-function compute-stack-frame* drop vm-frame-required ;
M: ##call compute-stack-frame* drop frame-required ; M: ##call compute-stack-frame* drop frame-required ;
M: ##spill compute-stack-frame* drop frame-required ; M: ##spill compute-stack-frame* drop frame-required ;

View File

@ -256,17 +256,6 @@ FOLDABLE-INSN: ##sqrt
def: dst/double-rep def: dst/double-rep
use: src/double-rep ; use: src/double-rep ;
! libc intrinsics
FOLDABLE-INSN: ##unary-float-function
def: dst/double-rep
use: src/double-rep
literal: func ;
FOLDABLE-INSN: ##binary-float-function
def: dst/double-rep
use: src1/double-rep src2/double-rep
literal: func ;
! Single/double float conversion ! Single/double float conversion
FOLDABLE-INSN: ##single>double-float FOLDABLE-INSN: ##single>double-float
def: dst/double-rep def: dst/double-rep
@ -883,8 +872,6 @@ alien-call-insn
! will be in a register. ! will be in a register.
UNION: clobber-insn UNION: clobber-insn
hairy-clobber-insn hairy-clobber-insn
##unary-float-function
##binary-float-function
##unbox ##unbox
##box ##box
##box-long-long ; ##box-long-long ;

View File

@ -9,9 +9,3 @@ IN: compiler.cfg.intrinsics.float
: emit-float-unordered-comparison ( cc -- ) : emit-float-unordered-comparison ( cc -- )
'[ _ ^^compare-float-unordered ] binary-op ; inline '[ _ ^^compare-float-unordered ] binary-op ; inline
: emit-unary-float-function ( func -- )
'[ _ ^^unary-float-function ] unary-op ;
: emit-binary-float-function ( func -- )
'[ _ ^^binary-float-function ] binary-op ;

View File

@ -123,31 +123,6 @@ IN: compiler.cfg.intrinsics
{ math.floats.private:float-max [ drop [ ^^max-float ] binary-op ] } { math.floats.private:float-max [ drop [ ^^max-float ] binary-op ] }
} enable-intrinsics ; } enable-intrinsics ;
: enable-float-functions ( -- )
{
{ math.libm:facos [ drop "acos" emit-unary-float-function ] }
{ math.libm:fasin [ drop "asin" emit-unary-float-function ] }
{ math.libm:fatan [ drop "atan" emit-unary-float-function ] }
{ math.libm:fatan2 [ drop "atan2" emit-binary-float-function ] }
{ math.libm:fcos [ drop "cos" emit-unary-float-function ] }
{ math.libm:fsin [ drop "sin" emit-unary-float-function ] }
{ math.libm:ftan [ drop "tan" emit-unary-float-function ] }
{ math.libm:fcosh [ drop "cosh" emit-unary-float-function ] }
{ math.libm:fsinh [ drop "sinh" emit-unary-float-function ] }
{ math.libm:ftanh [ drop "tanh" emit-unary-float-function ] }
{ math.libm:fexp [ drop "exp" emit-unary-float-function ] }
{ math.libm:flog [ drop "log" emit-unary-float-function ] }
{ math.libm:flog10 [ drop "log10" emit-unary-float-function ] }
{ math.libm:fpow [ drop "pow" emit-binary-float-function ] }
{ math.libm:facosh [ drop "acosh" emit-unary-float-function ] }
{ math.libm:fasinh [ drop "asinh" emit-unary-float-function ] }
{ math.libm:fatanh [ drop "atanh" emit-unary-float-function ] }
{ math.libm:fsqrt [ drop "sqrt" emit-unary-float-function ] }
{ math.floats.private:float-min [ drop "fmin" emit-binary-float-function ] }
{ math.floats.private:float-max [ drop "fmax" emit-binary-float-function ] }
{ math.private:float-mod [ drop "fmod" emit-binary-float-function ] }
} enable-intrinsics ;
: enable-min/max ( -- ) : enable-min/max ( -- )
{ {
{ math.integers.private:fixnum-min [ drop [ ^^min ] binary-op ] } { math.integers.private:fixnum-min [ drop [ ^^min ] binary-op ] }

View File

@ -4,26 +4,8 @@ compiler.cfg.save-contexts kernel namespaces tools.test
cpu.x86.assembler.operands cpu.architecture ; cpu.x86.assembler.operands cpu.architecture ;
IN: compiler.cfg.save-contexts.tests IN: compiler.cfg.save-contexts.tests
0 vreg-counter set-global
H{ } clone representations set H{ } clone representations set
V{
T{ ##unary-float-function f 2 3 "sqrt" }
T{ ##branch }
} 0 test-bb
0 get insert-save-context
[
V{
T{ ##save-context f 1 2 }
T{ ##unary-float-function f 2 3 "sqrt" }
T{ ##branch }
}
] [
0 get instructions>>
] unit-test
V{ V{
T{ ##add f 1 2 3 } T{ ##add f 1 2 3 }
T{ ##branch } T{ ##branch }

View File

@ -9,8 +9,6 @@ IN: compiler.cfg.save-contexts
GENERIC: needs-save-context? ( insn -- ? ) GENERIC: needs-save-context? ( insn -- ? )
M: ##unary-float-function needs-save-context? drop t ;
M: ##binary-float-function needs-save-context? drop t ;
M: gc-map-insn needs-save-context? drop t ; M: gc-map-insn needs-save-context? drop t ;
M: insn needs-save-context? drop f ; M: insn needs-save-context? drop f ;

View File

@ -170,8 +170,6 @@ CODEGEN: ##div-float %div-float
CODEGEN: ##min-float %min-float CODEGEN: ##min-float %min-float
CODEGEN: ##max-float %max-float CODEGEN: ##max-float %max-float
CODEGEN: ##sqrt %sqrt CODEGEN: ##sqrt %sqrt
CODEGEN: ##unary-float-function %unary-float-function
CODEGEN: ##binary-float-function %binary-float-function
CODEGEN: ##single>double-float %single>double-float CODEGEN: ##single>double-float %single>double-float
CODEGEN: ##double>single-float %double>single-float CODEGEN: ##double>single-float %double>single-float
CODEGEN: ##integer>float %integer>float CODEGEN: ##integer>float %integer>float

View File

@ -319,10 +319,9 @@ generic-comparison-ops [
] [ 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 ! Unlike the other words in math.libm, fsqrt is not inline
flog fpow fsqrt facosh fasinh fatanh } [ ! since it has an intrinsic, so we need to give it outputs here.
{ float } "default-output-classes" set-word-prop \ fsqrt { float } "default-output-classes" set-word-prop
] each
! Find a less repetitive way of doing this ! Find a less repetitive way of doing this
\ float-min { float float } "input-classes" set-word-prop \ float-min { float float } "input-classes" set-word-prop

View File

@ -292,8 +292,6 @@ HOOK: %div-float cpu ( dst src1 src2 -- )
HOOK: %min-float cpu ( dst src1 src2 -- ) HOOK: %min-float cpu ( dst src1 src2 -- )
HOOK: %max-float cpu ( dst src1 src2 -- ) HOOK: %max-float cpu ( dst src1 src2 -- )
HOOK: %sqrt cpu ( dst src -- ) HOOK: %sqrt cpu ( dst src -- )
HOOK: %unary-float-function cpu ( dst src func -- )
HOOK: %binary-float-function cpu ( dst src1 src2 func -- )
HOOK: %single>double-float cpu ( dst src -- ) HOOK: %single>double-float cpu ( dst src -- )
HOOK: %double>single-float cpu ( dst src -- ) HOOK: %double>single-float cpu ( dst src -- )

View File

@ -197,17 +197,6 @@ M: x86.32 %end-callback ( -- )
0 save-vm-ptr 0 save-vm-ptr
"end_callback" f f %c-invoke ; "end_callback" f f %c-invoke ;
M:: x86.32 %unary-float-function ( dst src func -- )
src double-rep 0 %store-stack-param
func "libm" load-library f %c-invoke
dst double-rep %load-return ;
M:: x86.32 %binary-float-function ( dst src1 src2 func -- )
src1 double-rep 0 %store-stack-param
src2 double-rep 8 %store-stack-param
func "libm" load-library f %c-invoke
dst double-rep %load-return ;
: funny-large-struct-return? ( return abi -- ? ) : funny-large-struct-return? ( return abi -- ? )
#! MINGW ABI incompatibility disaster #! MINGW ABI incompatibility disaster
[ large-struct? ] [ mingw eq? os windows? not or ] bi* and ; [ large-struct? ] [ mingw eq? os windows? not or ] bi* and ;

View File

@ -123,22 +123,6 @@ M: x86.64 %end-callback ( -- )
param-reg-0 %mov-vm-ptr param-reg-0 %mov-vm-ptr
"end_callback" f f %c-invoke ; "end_callback" f f %c-invoke ;
: float-function-param ( i src -- )
[ float-regs cdecl param-regs at nth ] dip double-rep %copy ;
M:: x86.64 %unary-float-function ( dst src func -- )
0 src float-function-param
func "libm" load-library f %c-invoke
dst double-rep %load-return ;
M:: x86.64 %binary-float-function ( dst src1 src2 func -- )
! src1 might equal dst; otherwise it will be a spill slot
! src2 is always a spill slot
0 src1 float-function-param
1 src2 float-function-param
func "libm" load-library f %c-invoke
dst double-rep %load-return ;
M: x86.64 %prepare-var-args ( -- ) RAX RAX XOR ; M: x86.64 %prepare-var-args ( -- ) RAX RAX XOR ;
M: x86.64 stack-cleanup 3drop 0 ; M: x86.64 stack-cleanup 3drop 0 ;

View File

@ -919,6 +919,5 @@ M: x86 %vector>scalar %copy ;
M: x86 %scalar>vector %copy ; M: x86 %scalar>vector %copy ;
enable-float-intrinsics enable-float-intrinsics
enable-float-functions
enable-float-min/max enable-float-min/max
enable-fsqrt enable-fsqrt

View File

@ -99,5 +99,4 @@ M: x86 %compare-float-unordered-branch ( label src1 src2 cc -- )
[ [ FUCOMI ] compare-op ] (%compare-float-branch) ; [ [ FUCOMI ] compare-op ] (%compare-float-branch) ;
enable-float-intrinsics enable-float-intrinsics
enable-float-functions
enable-fsqrt enable-fsqrt

View File

@ -1,6 +1,7 @@
! Copyright (C) 2006, 2010 Slava Pestov. ! Copyright (C) 2006, 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.c-types alien.syntax kernel words accessors ; USING: alien alien.c-types alien.syntax words ;
FROM: math => float mod ;
IN: math.libm IN: math.libm
LIBRARY: libm LIBRARY: libm
@ -50,16 +51,14 @@ FUNCTION-ALIAS: fpow
FUNCTION-ALIAS: fsqrt FUNCTION-ALIAS: fsqrt
double sqrt ( double x ) ; double sqrt ( double x ) ;
FUNCTION: double fmod ( double x, double y ) ;
M: float mod fmod ; inline
! fsqrt has an intrinsic so we don't actually want to inline it ! fsqrt has an intrinsic so we don't actually want to inline it
! unconditionally ! unconditionally
<< <<
\ fsqrt f "inline" set-word-prop \ fsqrt f "inline" set-word-prop
\ fsqrt [
drop
\ fsqrt "intrinsic" word-prop
f \ fsqrt def>> ?
] "custom-inlining" set-word-prop
>> >>
! Windows doesn't have these... ! Windows doesn't have these...

View File

@ -394,7 +394,6 @@ M: object infer-call* \ call bad-macro-input ;
\ float* { float float } { float } define-primitive \ float* make-foldable \ float* { float float } { float } define-primitive \ float* make-foldable
\ float+ { float float } { float } define-primitive \ float+ make-foldable \ float+ { float float } { float } define-primitive \ float+ make-foldable
\ float- { float float } { float } define-primitive \ float- make-foldable \ float- { float float } { float } define-primitive \ float- make-foldable
\ float-mod { float float } { float } define-primitive \ float-mod make-foldable
\ float-u< { float float } { object } define-primitive \ float-u< make-foldable \ float-u< { float float } { object } define-primitive \ float-u< make-foldable
\ float-u<= { float float } { object } define-primitive \ float-u<= make-foldable \ float-u<= { float float } { object } define-primitive \ float-u<= make-foldable
\ float-u> { float float } { object } define-primitive \ float-u> make-foldable \ float-u> { float float } { object } define-primitive \ float-u> make-foldable

View File

@ -501,7 +501,6 @@ tuple
{ "float*" "math.private" "primitive_float_multiply" (( x y -- z )) } { "float*" "math.private" "primitive_float_multiply" (( x y -- z )) }
{ "float+" "math.private" "primitive_float_add" (( x y -- z )) } { "float+" "math.private" "primitive_float_add" (( x y -- z )) }
{ "float-" "math.private" "primitive_float_subtract" (( x y -- z )) } { "float-" "math.private" "primitive_float_subtract" (( x y -- z )) }
{ "float-mod" "math.private" "primitive_float_mod" (( x y -- z )) }
{ "float-u<" "math.private" "primitive_float_less" (( x y -- ? )) } { "float-u<" "math.private" "primitive_float_less" (( x y -- ? )) }
{ "float-u<=" "math.private" "primitive_float_lesseq" (( x y -- ? )) } { "float-u<=" "math.private" "primitive_float_lesseq" (( x y -- ? )) }
{ "float-u>" "math.private" "primitive_float_greater" (( x y -- ? )) } { "float-u>" "math.private" "primitive_float_greater" (( x y -- ? )) }

View File

@ -42,11 +42,6 @@ HELP: float* ( x y -- z )
{ $description "Primitive version of " { $link * } "." } { $description "Primitive version of " { $link * } "." }
{ $warning "This word does not perform type checking, and passing objects of the wrong type can crash the runtime. User code should call the generic word " { $link * } " instead." } ; { $warning "This word does not perform type checking, and passing objects of the wrong type can crash the runtime. User code should call the generic word " { $link * } " instead." } ;
HELP: float-mod ( x y -- z )
{ $values { "x" float } { "y" float } { "z" float } }
{ $description "Primitive version of " { $link mod } "." }
{ $warning "This word does not perform type checking, and passing objects of the wrong type can crash the runtime. User code should call the generic word " { $link mod } " instead." } ;
HELP: float/f ( x y -- z ) HELP: float/f ( x y -- z )
{ $values { "x" float } { "y" float } { "z" float } } { $values { "x" float } { "y" float } { "z" float } }
{ $description "Primitive version of " { $link /f } "." } { $description "Primitive version of " { $link /f } "." }

View File

@ -38,7 +38,6 @@ M: float * float* ; inline
M: float / float/f ; inline M: float / float/f ; inline
M: float /f float/f ; inline M: float /f float/f ; inline
M: float /i float/f >integer ; inline M: float /i float/f >integer ; inline
M: float mod float-mod ; inline
M: real abs dup 0 < [ neg ] when ; inline M: real abs dup 0 < [ neg ] when ; inline

View File

@ -303,12 +303,6 @@ void factor_vm::primitive_float_divfloat()
ctx->push(allot_float(x / y)); ctx->push(allot_float(x / y));
} }
void factor_vm::primitive_float_mod()
{
POP_FLOATS(x,y);
ctx->push(allot_float(fmod(x,y)));
}
void factor_vm::primitive_float_less() void factor_vm::primitive_float_less()
{ {
POP_FLOATS(x,y); POP_FLOATS(x,y);

View File

@ -78,7 +78,6 @@ namespace factor
_(float_greatereq) \ _(float_greatereq) \
_(float_less) \ _(float_less) \
_(float_lesseq) \ _(float_lesseq) \
_(float_mod) \
_(float_multiply) \ _(float_multiply) \
_(float_subtract) \ _(float_subtract) \
_(float_to_bignum) \ _(float_to_bignum) \

View File

@ -464,7 +464,6 @@ struct factor_vm
void primitive_float_subtract(); void primitive_float_subtract();
void primitive_float_multiply(); void primitive_float_multiply();
void primitive_float_divfloat(); void primitive_float_divfloat();
void primitive_float_mod();
void primitive_float_less(); void primitive_float_less();
void primitive_float_lesseq(); void primitive_float_lesseq();
void primitive_float_greater(); void primitive_float_greater();