Better SSE2 check

db4
Slava Pestov 2008-06-27 20:04:03 -05:00
parent 86765c8399
commit 97983dabb5
1 changed files with 17 additions and 3 deletions

View File

@ -5,7 +5,7 @@ cpu.x86.architecture cpu.x86.intrinsics cpu.x86.allot
cpu.architecture kernel kernel.private math namespaces sequences cpu.architecture kernel kernel.private math namespaces sequences
generator.registers generator.fixup generator system layouts generator.registers generator.fixup generator system layouts
alien.compiler combinators command-line alien.compiler combinators command-line
compiler compiler.units io vocabs.loader accessors ; compiler compiler.units io vocabs.loader accessors init ;
IN: cpu.x86.32 IN: cpu.x86.32
! We implement the FFI for Linux, OS X and Windows all at once. ! We implement the FFI for Linux, OS X and Windows all at once.
@ -262,9 +262,11 @@ os windows? [
4 "double" c-type set-c-type-align 4 "double" c-type set-c-type-align
] unless ] unless
: sse2? ( -- ? ) "Intrinsic" throw ; : (sse2?) ( -- ? ) "Intrinsic" throw ;
\ sse2? [ <<
\ (sse2?) [
{ EAX EBX ECX EDX } [ PUSH ] each { EAX EBX ECX EDX } [ PUSH ] each
EAX 1 MOV EAX 1 MOV
CPUID CPUID
@ -274,6 +276,10 @@ os windows? [
JE JE
] { } define-if-intrinsic ] { } define-if-intrinsic
>>
: sse2? ( -- ? ) (sse2?) ;
"-no-sse2" cli-args member? [ "-no-sse2" cli-args member? [
"Checking if your CPU supports SSE2..." print flush "Checking if your CPU supports SSE2..." print flush
[ optimized-recompile-hook ] recompile-hook [ [ optimized-recompile-hook ] recompile-hook [
@ -282,6 +288,14 @@ os windows? [
[ [
" - yes" print " - yes" print
"cpu.x86.sse2" require "cpu.x86.sse2" require
[
sse2? [
"This image was built to use SSE2, which your CPU does not support." print
"You will need to bootstrap Factor again." print
flush
1 exit
] unless
] "cpu.x86" add-init-hook
] [ ] [
" - no" print " - no" print
] if ] if