cpu.x86: Fix load order.

db4
Doug Coleman 2012-09-19 08:40:18 -07:00
parent df3f1eaa5b
commit 9c0a8b3250
3 changed files with 45 additions and 50 deletions

View File

@ -1,14 +1,13 @@
! Copyright (C) 2005, 2011 Slava Pestov. ! Copyright (C) 2005, 2011 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: locals alien alien.c-types alien.libraries alien.syntax USING: accessors alien alien.c-types arrays classes.struct
arrays kernel fry math namespaces sequences system layouts io combinators compiler.cfg.builder.alien.boxing
vocabs.loader accessors init classes.struct combinators make compiler.codegen.gc-maps compiler.codegen.labels
words compiler.constants compiler.codegen.gc-maps compiler.codegen.relocation compiler.constants cpu.architecture
compiler.codegen.labels compiler.codegen.relocation cpu.x86 cpu.x86.assembler cpu.x86.assembler.operands
compiler.cfg.instructions compiler.cfg.builder cpu.x86.features kernel locals make math namespaces sequences
compiler.cfg.builder.alien.boxing compiler.cfg.intrinsics specialized-arrays system vocabs ;
compiler.cfg.stack-frame cpu.x86.assembler SPECIALIZED-ARRAY: uint
cpu.x86.assembler.operands cpu.x86 cpu.architecture vm vocabs ;
FROM: layouts => cell ; FROM: layouts => cell ;
IN: cpu.x86.32 IN: cpu.x86.32
@ -231,4 +230,18 @@ M: x86.32 flatten-struct-type
M: x86.32 struct-return-on-stack? os linux? not ; M: x86.32 struct-return-on-stack? os linux? not ;
M: x86.32 (cpuid) ( n regs -- )
void { uint void* } cdecl [
! Save ds-reg, rs-reg
EDI PUSH
EAX ESP 4 [+] MOV
CPUID
EDI ESP 8 [+] MOV
EDI [] EAX MOV
EDI 4 [+] EBX MOV
EDI 8 [+] ECX MOV
EDI 12 [+] EDX MOV
EDI POP
] alien-assembly ;
check-cpu-features check-cpu-features

View File

@ -1,15 +1,13 @@
! Copyright (C) 2005, 2011 Slava Pestov. ! Copyright (C) 2005, 2011 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays kernel math namespaces make sequences USING: alien alien.c-types assocs combinators
system layouts alien alien.c-types alien.accessors compiler.cfg.intrinsics compiler.codegen.gc-maps
alien.libraries slots splitting assocs combinators fry locals compiler.codegen.labels compiler.codegen.relocation
compiler.constants classes.struct compiler.codegen compiler.constants cpu.architecture cpu.x86 cpu.x86.assembler
compiler.codegen.gc-maps compiler.codegen.labels cpu.x86.assembler.operands cpu.x86.features kernel locals math
compiler.codegen.relocation compiler.cfg.instructions sequences specialized-arrays system vocabs ;
compiler.cfg.builder compiler.cfg.intrinsics
compiler.cfg.stack-frame cpu.x86.assembler
cpu.x86.assembler.operands cpu.x86 cpu.architecture vm ;
FROM: layouts => cell cells ; FROM: layouts => cell cells ;
SPECIALIZED-ARRAY: uint
IN: cpu.x86.64 IN: cpu.x86.64
: param-reg ( n -- reg ) int-regs cdecl param-regs at nth ; : param-reg ( n -- reg ) int-regs cdecl param-regs at nth ;
@ -133,12 +131,21 @@ M: x86.64 float-on-stack? f ;
M: x86.64 struct-return-on-stack? f ; M: x86.64 struct-return-on-stack? f ;
M: x86.64 (cpuid) ( n regs -- )
void { uint void* } cdecl [
RAX param-reg-0 MOV
RSI param-reg-1 MOV
CPUID
RSI [] EAX MOV
RSI 4 [+] EBX MOV
RSI 8 [+] ECX MOV
RSI 12 [+] EDX MOV
] alien-assembly ;
! The result of reading 4 bytes from memory is a fixnum on ! The result of reading 4 bytes from memory is a fixnum on
! x86-64. ! x86-64.
enable-alien-4-intrinsics enable-alien-4-intrinsics
USE: vocabs
{ {
{ [ os unix? ] [ "cpu.x86.64.unix" require ] } { [ os unix? ] [ "cpu.x86.64.unix" require ] }
{ [ os windows? ] [ "cpu.x86.64.windows" require ] } { [ os windows? ] [ "cpu.x86.64.windows" require ] }

View File

@ -1,10 +1,10 @@
! Copyright (C) 2009, 2010 Slava Pestov. ! Copyright (C) 2009, 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs sequences alien alien.c-types USING: alien alien.c-types arrays assocs combinators
combinators compiler compiler.codegen.labels compiler.units compiler.codegen.labels cpu.architecture cpu.x86.assembler
cpu.architecture cpu.x86.assembler cpu.x86.assembler.operands cpu.x86.assembler.operands init kernel math math.order
init io kernel locals math math.order math.parser memoize math.parser memoize namespaces sequences
namespaces system arrays specialized-arrays cpu.x86.64 ; specialized-arrays system ;
SPECIALIZED-ARRAY: uint SPECIALIZED-ARRAY: uint
IN: cpu.x86.features IN: cpu.x86.features
@ -87,31 +87,6 @@ MEMO: sse-version ( -- n )
HOOK: (cpuid) cpu ( n regs -- ) HOOK: (cpuid) cpu ( n regs -- )
M: x86.32 (cpuid) ( n regs -- )
void { uint void* } cdecl [
! Save ds-reg, rs-reg
EDI PUSH
EAX ESP 4 [+] MOV
CPUID
EDI ESP 8 [+] MOV
EDI [] EAX MOV
EDI 4 [+] EBX MOV
EDI 8 [+] ECX MOV
EDI 12 [+] EDX MOV
EDI POP
] alien-assembly ;
M: x86.64 (cpuid) ( n regs -- )
void { uint void* } cdecl [
RAX param-reg-0 MOV
RSI param-reg-1 MOV
CPUID
RSI [] EAX MOV
RSI 4 [+] EBX MOV
RSI 8 [+] ECX MOV
RSI 12 [+] EDX MOV
] alien-assembly ;
: cpuid ( n -- 4array ) : cpuid ( n -- 4array )
4 <uint-array> [ (cpuid) ] keep >array ; 4 <uint-array> [ (cpuid) ] keep >array ;