diff --git a/basis/compiler/cfg/build-stack-frame/build-stack-frame.factor b/basis/compiler/cfg/build-stack-frame/build-stack-frame.factor index e2ce7d26e0..9773109584 100644 --- a/basis/compiler/cfg/build-stack-frame/build-stack-frame.factor +++ b/basis/compiler/cfg/build-stack-frame/build-stack-frame.factor @@ -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: ##callback-inputs 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: ##spill compute-stack-frame* drop frame-required ; diff --git a/basis/compiler/cfg/instructions/instructions.factor b/basis/compiler/cfg/instructions/instructions.factor index 78cacf9d17..c51d41443a 100644 --- a/basis/compiler/cfg/instructions/instructions.factor +++ b/basis/compiler/cfg/instructions/instructions.factor @@ -256,17 +256,6 @@ FOLDABLE-INSN: ##sqrt def: dst/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 FOLDABLE-INSN: ##single>double-float def: dst/double-rep @@ -883,8 +872,6 @@ alien-call-insn ! will be in a register. UNION: clobber-insn hairy-clobber-insn -##unary-float-function -##binary-float-function ##unbox ##box ##box-long-long ; diff --git a/basis/compiler/cfg/intrinsics/float/float.factor b/basis/compiler/cfg/intrinsics/float/float.factor index 480b46f9b3..b4a571038c 100644 --- a/basis/compiler/cfg/intrinsics/float/float.factor +++ b/basis/compiler/cfg/intrinsics/float/float.factor @@ -9,9 +9,3 @@ IN: compiler.cfg.intrinsics.float : emit-float-unordered-comparison ( cc -- ) '[ _ ^^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 ; diff --git a/basis/compiler/cfg/intrinsics/intrinsics.factor b/basis/compiler/cfg/intrinsics/intrinsics.factor index bf8ba96c34..475edb41a4 100644 --- a/basis/compiler/cfg/intrinsics/intrinsics.factor +++ b/basis/compiler/cfg/intrinsics/intrinsics.factor @@ -123,31 +123,6 @@ IN: compiler.cfg.intrinsics { math.floats.private:float-max [ drop [ ^^max-float ] binary-op ] } } 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 ( -- ) { { math.integers.private:fixnum-min [ drop [ ^^min ] binary-op ] } diff --git a/basis/compiler/cfg/save-contexts/save-contexts-tests.factor b/basis/compiler/cfg/save-contexts/save-contexts-tests.factor index fe06d4c7de..0b8c5e7873 100644 --- a/basis/compiler/cfg/save-contexts/save-contexts-tests.factor +++ b/basis/compiler/cfg/save-contexts/save-contexts-tests.factor @@ -4,26 +4,8 @@ compiler.cfg.save-contexts kernel namespaces tools.test cpu.x86.assembler.operands cpu.architecture ; IN: compiler.cfg.save-contexts.tests -0 vreg-counter set-global 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{ T{ ##add f 1 2 3 } T{ ##branch } diff --git a/basis/compiler/cfg/save-contexts/save-contexts.factor b/basis/compiler/cfg/save-contexts/save-contexts.factor index 3e42c51bc5..c14f4d46e6 100644 --- a/basis/compiler/cfg/save-contexts/save-contexts.factor +++ b/basis/compiler/cfg/save-contexts/save-contexts.factor @@ -9,8 +9,6 @@ IN: compiler.cfg.save-contexts 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: insn needs-save-context? drop f ; diff --git a/basis/compiler/codegen/codegen.factor b/basis/compiler/codegen/codegen.factor index 21a297a8a1..6e7e2e0fab 100755 --- a/basis/compiler/codegen/codegen.factor +++ b/basis/compiler/codegen/codegen.factor @@ -170,8 +170,6 @@ CODEGEN: ##div-float %div-float CODEGEN: ##min-float %min-float CODEGEN: ##max-float %max-float 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: ##double>single-float %double>single-float CODEGEN: ##integer>float %integer>float diff --git a/basis/compiler/tree/propagation/known-words/known-words.factor b/basis/compiler/tree/propagation/known-words/known-words.factor index 09750d9d3f..baa241f9c5 100644 --- a/basis/compiler/tree/propagation/known-words/known-words.factor +++ b/basis/compiler/tree/propagation/known-words/known-words.factor @@ -319,10 +319,9 @@ generic-comparison-ops [ ] [ 2drop object-info ] if ] "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 +! Unlike the other words in math.libm, fsqrt is not inline +! since it has an intrinsic, so we need to give it outputs here. +\ fsqrt { float } "default-output-classes" set-word-prop ! Find a less repetitive way of doing this \ float-min { float float } "input-classes" set-word-prop diff --git a/basis/cpu/architecture/architecture.factor b/basis/cpu/architecture/architecture.factor index 6cf4a11e22..4f6e2677f3 100644 --- a/basis/cpu/architecture/architecture.factor +++ b/basis/cpu/architecture/architecture.factor @@ -292,8 +292,6 @@ HOOK: %div-float cpu ( dst src1 src2 -- ) HOOK: %min-float cpu ( dst src1 src2 -- ) HOOK: %max-float cpu ( dst src1 src2 -- ) 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: %double>single-float cpu ( dst src -- ) diff --git a/basis/cpu/x86/32/32.factor b/basis/cpu/x86/32/32.factor index 2b667ef7f9..0f93e5e4a4 100755 --- a/basis/cpu/x86/32/32.factor +++ b/basis/cpu/x86/32/32.factor @@ -197,17 +197,6 @@ M: x86.32 %end-callback ( -- ) 0 save-vm-ptr "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 -- ? ) #! MINGW ABI incompatibility disaster [ large-struct? ] [ mingw eq? os windows? not or ] bi* and ; diff --git a/basis/cpu/x86/64/64.factor b/basis/cpu/x86/64/64.factor index 3c96f2a2b0..6861ddd99a 100644 --- a/basis/cpu/x86/64/64.factor +++ b/basis/cpu/x86/64/64.factor @@ -123,22 +123,6 @@ M: x86.64 %end-callback ( -- ) param-reg-0 %mov-vm-ptr "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 stack-cleanup 3drop 0 ; diff --git a/basis/cpu/x86/sse/sse.factor b/basis/cpu/x86/sse/sse.factor index 4d667b8821..afcc877953 100644 --- a/basis/cpu/x86/sse/sse.factor +++ b/basis/cpu/x86/sse/sse.factor @@ -919,6 +919,5 @@ M: x86 %vector>scalar %copy ; M: x86 %scalar>vector %copy ; enable-float-intrinsics -enable-float-functions enable-float-min/max enable-fsqrt diff --git a/basis/cpu/x86/x87/x87.factor b/basis/cpu/x86/x87/x87.factor index 8f267b4265..445b913bc9 100644 --- a/basis/cpu/x86/x87/x87.factor +++ b/basis/cpu/x86/x87/x87.factor @@ -99,5 +99,4 @@ M: x86 %compare-float-unordered-branch ( label src1 src2 cc -- ) [ [ FUCOMI ] compare-op ] (%compare-float-branch) ; enable-float-intrinsics -enable-float-functions enable-fsqrt diff --git a/basis/math/libm/libm.factor b/basis/math/libm/libm.factor index e8d5d27c66..148ff71a92 100644 --- a/basis/math/libm/libm.factor +++ b/basis/math/libm/libm.factor @@ -1,6 +1,7 @@ ! Copyright (C) 2006, 2010 Slava Pestov. ! 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 LIBRARY: libm @@ -50,16 +51,14 @@ FUNCTION-ALIAS: fpow FUNCTION-ALIAS: fsqrt 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 ! unconditionally << \ 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... diff --git a/basis/stack-checker/known-words/known-words.factor b/basis/stack-checker/known-words/known-words.factor index 1ae3d071f5..d136f49f76 100644 --- a/basis/stack-checker/known-words/known-words.factor +++ b/basis/stack-checker/known-words/known-words.factor @@ -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-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 diff --git a/core/bootstrap/primitives.factor b/core/bootstrap/primitives.factor index 14ed5b9717..4df08aebf9 100644 --- a/core/bootstrap/primitives.factor +++ b/core/bootstrap/primitives.factor @@ -501,7 +501,6 @@ tuple { "float*" "math.private" "primitive_float_multiply" (( x y -- z )) } { "float+" "math.private" "primitive_float_add" (( 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_lesseq" (( x y -- ? )) } { "float-u>" "math.private" "primitive_float_greater" (( x y -- ? )) } diff --git a/core/math/floats/floats-docs.factor b/core/math/floats/floats-docs.factor index 9fdf95ff3a..7f0667bf74 100644 --- a/core/math/floats/floats-docs.factor +++ b/core/math/floats/floats-docs.factor @@ -42,11 +42,6 @@ HELP: float* ( x y -- z ) { $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." } ; -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 ) { $values { "x" float } { "y" float } { "z" float } } { $description "Primitive version of " { $link /f } "." } diff --git a/core/math/floats/floats.factor b/core/math/floats/floats.factor index 97c6f7fc87..45fce36ee6 100644 --- a/core/math/floats/floats.factor +++ b/core/math/floats/floats.factor @@ -38,7 +38,6 @@ M: float * float* ; inline M: float / float/f ; inline M: float /f float/f ; inline M: float /i float/f >integer ; inline -M: float mod float-mod ; inline M: real abs dup 0 < [ neg ] when ; inline diff --git a/vm/math.cpp b/vm/math.cpp index b872e7057f..67cab3570d 100755 --- a/vm/math.cpp +++ b/vm/math.cpp @@ -303,12 +303,6 @@ void factor_vm::primitive_float_divfloat() 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() { POP_FLOATS(x,y); diff --git a/vm/primitives.hpp b/vm/primitives.hpp index 77c255afd5..ce40ca0a7e 100644 --- a/vm/primitives.hpp +++ b/vm/primitives.hpp @@ -78,7 +78,6 @@ namespace factor _(float_greatereq) \ _(float_less) \ _(float_lesseq) \ - _(float_mod) \ _(float_multiply) \ _(float_subtract) \ _(float_to_bignum) \ diff --git a/vm/vm.hpp b/vm/vm.hpp index 90e1184c7c..6aa3543c8f 100755 --- a/vm/vm.hpp +++ b/vm/vm.hpp @@ -464,7 +464,6 @@ struct factor_vm void primitive_float_subtract(); void primitive_float_multiply(); void primitive_float_divfloat(); - void primitive_float_mod(); void primitive_float_less(); void primitive_float_lesseq(); void primitive_float_greater();