math.floats.env.x86: split off 32 and 64-bit code into sub-vocabularies

db4
Slava Pestov 2010-01-07 20:44:28 +13:00
parent 611f1572bd
commit d84f132589
5 changed files with 64 additions and 55 deletions

29
basis/math/floats/env/x86/32/32.factor vendored Normal file
View File

@ -0,0 +1,29 @@
USING: alien alien.c-types cpu.x86.assembler
cpu.x86.assembler.operands math.floats.env.x86 system ;
IN: math.floats.env.x86.32
M: x86.32 get-sse-env
void { void* } "cdecl" [
EAX ESP [] MOV
EAX [] STMXCSR
] alien-assembly ;
M: x86.32 set-sse-env
void { void* } "cdecl" [
EAX ESP [] MOV
EAX [] LDMXCSR
] alien-assembly ;
M: x86.32 get-x87-env
void { void* } "cdecl" [
EAX ESP [] MOV
EAX [] FNSTSW
EAX 2 [+] FNSTCW
] alien-assembly ;
M: x86.32 set-x87-env
void { void* } "cdecl" [
EAX ESP [] MOV
FNCLEX
EAX 2 [+] FLDCW
] alien-assembly ;

1
basis/math/floats/env/x86/32/tags.txt vendored Normal file
View File

@ -0,0 +1 @@
unportable

25
basis/math/floats/env/x86/64/64.factor vendored Normal file
View File

@ -0,0 +1,25 @@
USING: alien alien.c-types cpu.architecture cpu.x86.assembler
cpu.x86.assembler.operands math.floats.env.x86 sequences system ;
IN: math.floats.env.x86.64
M: x86.64 get-sse-env
void { void* } "cdecl" [
int-regs param-regs first [] STMXCSR
] alien-assembly ;
M: x86.64 set-sse-env
void { void* } "cdecl" [
int-regs param-regs first [] LDMXCSR
] alien-assembly ;
M: x86.64 get-x87-env
void { void* } "cdecl" [
int-regs param-regs first [] FNSTSW
int-regs param-regs first 2 [+] FNSTCW
] alien-assembly ;
M: x86.64 set-x87-env
void { void* } "cdecl" [
FNCLEX
int-regs param-regs first 2 [+] FLDCW
] alien-assembly ;

1
basis/math/floats/env/x86/64/tags.txt vendored Normal file
View File

@ -0,0 +1 @@
unportable

View File

@ -1,8 +1,7 @@
USING: accessors alien alien.c-types alien.syntax arrays assocs
biassocs classes.struct combinators cpu.architecture
cpu.x86.assembler cpu.x86.assembler.operands cpu.x86.features
kernel literals math math.bitwise math.floats.env
math.floats.env.private sequences system ;
USING: accessors alien.c-types arrays assocs biassocs
classes.struct combinators cpu.x86.features kernel literals
math math.bitwise math.floats.env math.floats.env.private
system vocabs.loader ;
IN: math.floats.env.x86
STRUCT: sse-env
@ -18,56 +17,6 @@ HOOK: set-sse-env cpu ( sse-env -- )
HOOK: get-x87-env cpu ( x87-env -- )
HOOK: set-x87-env cpu ( x87-env -- )
! 32-bit
M: x86.32 get-sse-env
void { void* } "cdecl" [
EAX ESP [] MOV
EAX [] STMXCSR
] alien-assembly ;
M: x86.32 set-sse-env
void { void* } "cdecl" [
EAX ESP [] MOV
EAX [] LDMXCSR
] alien-assembly ;
M: x86.32 get-x87-env
void { void* } "cdecl" [
EAX ESP [] MOV
EAX [] FNSTSW
EAX 2 [+] FNSTCW
] alien-assembly ;
M: x86.32 set-x87-env
void { void* } "cdecl" [
EAX ESP [] MOV
FNCLEX
EAX 2 [+] FLDCW
] alien-assembly ;
! 64-bit
M: x86.64 get-sse-env
void { void* } "cdecl" [
int-regs param-regs first [] STMXCSR
] alien-assembly ;
M: x86.64 set-sse-env
void { void* } "cdecl" [
int-regs param-regs first [] LDMXCSR
] alien-assembly ;
M: x86.64 get-x87-env
void { void* } "cdecl" [
int-regs param-regs first [] FNSTSW
int-regs param-regs first 2 [+] FNSTCW
] alien-assembly ;
M: x86.64 set-x87-env
void { void* } "cdecl" [
FNCLEX
int-regs param-regs first 2 [+] FLDCW
] alien-assembly ;
: <sse-env> ( -- sse-env )
sse-env (struct) [ get-sse-env ] keep ;
@ -178,3 +127,7 @@ M: x87-env (get-denormal-mode) ( register -- mode )
M: x87-env (set-denormal-mode) ( register mode -- register' )
drop ;
cpu {
{ x86.32 [ "math.floats.env.x86.32" ] }
{ x86.64 [ "math.floats.env.x86.64" ] }
} case require