diff --git a/basis/bootstrap/compiler/compiler.factor b/basis/bootstrap/compiler/compiler.factor index 91e1c0de79..15bbec1be8 100644 --- a/basis/bootstrap/compiler/compiler.factor +++ b/basis/bootstrap/compiler/compiler.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2007, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays assocs assocs.private classes -classes.tuple.private compiler.units hashtables +classes.tuple.private compiler.units cpu.architecture hashtables hashtables.private io kernel libc math math.parser memory namespaces namespaces.private quotations quotations.private sbufs sequences sequences.private splitting system vectors @@ -20,6 +20,8 @@ IN: bootstrap.compiler "cpu." cpu name>> append require +enable-cpu-features + enable-optimizer ! Push all tuple layouts to tenured space to improve method caching diff --git a/basis/cpu/architecture/architecture-docs.factor b/basis/cpu/architecture/architecture-docs.factor index 3f7ef19503..c19133cdf8 100644 --- a/basis/cpu/architecture/architecture-docs.factor +++ b/basis/cpu/architecture/architecture-docs.factor @@ -207,10 +207,6 @@ HELP: %local-allot { $description "Emits machine code for stack \"allocating\" a chunk of memory. No memory is really allocated and instead a pointer to it is just put in the destination register." } { $see-also ##local-allot } ; -HELP: reg-class-of -{ $values { "rep" representation } { "reg-class" reg-class } } -{ $description "Register class for values of the given representation." } ; - HELP: %replace-imm { $values { "src" integer } @@ -325,6 +321,9 @@ HELP: fused-unboxing? { $values { "?" boolean } } { $description "Whether this architecture support " { $link %load-float } ", " { $link %load-double } ", and " { $link %load-vector } "." } ; +HELP: enable-cpu-features +{ $description "This word is run when compiling the compiler during bootstrap and enables optional features that the processor is found to support." } ; + HELP: gc-root-offset { $values { "spill-slot" spill-slot } { "n" integer } } { $description "Offset in the " { $link stack-frame } " for the word being constructed where the spill slot is located. The value is given in " { $link cell } " units." } @@ -361,6 +360,10 @@ HELP: rep-size { $values { "rep" representation } { "n" integer } } { $description "Size in bytes of a representation." } ; +HELP: reg-class-of +{ $values { "rep" representation } { "reg-class" reg-class } } +{ $description "Register class for values of the given representation." } ; + HELP: return-regs { $values { "regs" assoc } } { $description "What registers that will be used for function return values of which class." } ; diff --git a/basis/cpu/architecture/architecture.factor b/basis/cpu/architecture/architecture.factor index 66dddc453a..55b13c48b5 100644 --- a/basis/cpu/architecture/architecture.factor +++ b/basis/cpu/architecture/architecture.factor @@ -601,3 +601,5 @@ HOOK: %callback-inputs cpu ( reg-outputs stack-outputs -- ) HOOK: %callback-outputs cpu ( reg-inputs -- ) HOOK: stack-cleanup cpu ( stack-size return abi -- n ) + +HOOK: enable-cpu-features cpu ( -- ) diff --git a/basis/cpu/ppc/ppc.factor b/basis/cpu/ppc/ppc.factor index 80e54f606d..f4a75c75cc 100644 --- a/basis/cpu/ppc/ppc.factor +++ b/basis/cpu/ppc/ppc.factor @@ -44,8 +44,6 @@ CONSTANT: ds-reg 14 CONSTANT: rs-reg 15 CONSTANT: vm-reg 16 -enable-float-intrinsics - M: ppc machine-registers ( -- assoc ) { { int-regs $[ 3 12 [a,b] 17 29 [a,b] append ] } @@ -1059,6 +1057,9 @@ M: ppc immediate-arithmetic? ( n -- ? ) -32768 32767 between? ; M: ppc immediate-bitwise? ( n -- ? ) 0 65535 between? ; M: ppc immediate-store? ( n -- ? ) immediate-comparand? ; +M: ppc enable-cpu-features ( -- ) + enable-float-intrinsics ; + USE: vocabs { { [ os linux? ] [ diff --git a/basis/cpu/x86/32/32.factor b/basis/cpu/x86/32/32.factor index 6d9a92d9aa..7dbf72cb74 100755 --- a/basis/cpu/x86/32/32.factor +++ b/basis/cpu/x86/32/32.factor @@ -238,5 +238,3 @@ M: x86.32 (cpuid) ( eax ecx regs -- ) EDI 12 [+] EDX MOV EDI POP ] alien-assembly ; - -check-cpu-features diff --git a/basis/cpu/x86/64/64.factor b/basis/cpu/x86/64/64.factor index 4df2ef61d9..f098b6339c 100644 --- a/basis/cpu/x86/64/64.factor +++ b/basis/cpu/x86/64/64.factor @@ -134,13 +134,7 @@ M: x86.64 (cpuid) ( rax rcx regs -- ) RSI 12 [+] EDX MOV ] alien-assembly ; -! The result of reading 4 bytes from memory is a fixnum on -! x86-64. -enable-alien-4-intrinsics - { { [ os unix? ] [ "cpu.x86.64.unix" require ] } { [ os windows? ] [ "cpu.x86.64.windows" require ] } } cond - -check-cpu-features diff --git a/basis/cpu/x86/sse/sse.factor b/basis/cpu/x86/sse/sse.factor index d977e07f0c..dfdd19efc3 100644 --- a/basis/cpu/x86/sse/sse.factor +++ b/basis/cpu/x86/sse/sse.factor @@ -923,7 +923,3 @@ M: x86.64 %scalar>integer ( dst src rep -- ) M: x86 %vector>scalar %copy ; M: x86 %scalar>vector %copy ; - -enable-float-intrinsics -enable-float-min/max -enable-fsqrt diff --git a/basis/cpu/x86/x86.factor b/basis/cpu/x86/x86.factor index 54059236fe..6a6e5dca3f 100644 --- a/basis/cpu/x86/x86.factor +++ b/basis/cpu/x86/x86.factor @@ -774,28 +774,40 @@ M: x86 immediate-bitwise? ( n -- ? ) { cc/<>= [ src1 src2 compare call( a b -- ) label JP ] } } case ; -enable-min/max -enable-log2 - M:: x86 %bit-test ( dst src1 src2 temp -- ) src1 src2 BT dst temp \ CMOVB (%boolean) ; -enable-bit-test +M: x86 enable-cpu-features ( -- ) + enable-min/max + enable-log2 + enable-bit-test -: check-sse ( -- ) + ! The result of reading 4 bytes from memory is a fixnum on + ! x86-64. + cpu x86.64? [ enable-alien-4-intrinsics ] when + + ! These words uses alien-assembly + optimizing-compiler compiler-impl [ + { (sse-version) popcnt? } compile + ] with-variable + + ! SSE floats "Checking for multimedia extensions... " write flush sse-version [ sse-string " detected" append print ] - [ 20 < "cpu.x86.x87" "cpu.x86.sse" ? require ] bi ; + [ + 20 < [ "cpu.x86.x87" require ] [ + "cpu.x86.sse" require + enable-float-min/max + ] if + ] bi -: check-popcnt ( -- ) + ! POPCNT enable-popcnt? [ "Building with POPCNT support" print enable-bit-count - ] when ; + ] when -: check-cpu-features ( -- ) - [ { (sse-version) popcnt? } compile ] with-optimizer - check-sse - check-popcnt ; + enable-float-intrinsics + enable-fsqrt ; diff --git a/basis/cpu/x86/x87/x87.factor b/basis/cpu/x86/x87/x87.factor index 739399b581..f8997b78f7 100644 --- a/basis/cpu/x86/x87/x87.factor +++ b/basis/cpu/x86/x87/x87.factor @@ -97,6 +97,3 @@ M: x86 %compare-float-ordered-branch ( label src1 src2 cc -- ) M: x86 %compare-float-unordered-branch ( label src1 src2 cc -- ) [ [ FUCOMI ] compare-op ] (%compare-float-branch) ; - -enable-float-intrinsics -enable-fsqrt