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.
! See http://factorcode.org/license.txt for BSD license.
USING: locals alien alien.c-types alien.libraries alien.syntax
arrays kernel fry math namespaces sequences system layouts io
vocabs.loader accessors init classes.struct combinators make
words compiler.constants compiler.codegen.gc-maps
compiler.codegen.labels compiler.codegen.relocation
compiler.cfg.instructions compiler.cfg.builder
compiler.cfg.builder.alien.boxing compiler.cfg.intrinsics
compiler.cfg.stack-frame cpu.x86.assembler
cpu.x86.assembler.operands cpu.x86 cpu.architecture vm vocabs ;
USING: accessors alien alien.c-types arrays classes.struct
combinators compiler.cfg.builder.alien.boxing
compiler.codegen.gc-maps compiler.codegen.labels
compiler.codegen.relocation compiler.constants cpu.architecture
cpu.x86 cpu.x86.assembler cpu.x86.assembler.operands
cpu.x86.features kernel locals make math namespaces sequences
specialized-arrays system vocabs ;
SPECIALIZED-ARRAY: uint
FROM: layouts => cell ;
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 (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

View File

@ -1,15 +1,13 @@
! Copyright (C) 2005, 2011 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays kernel math namespaces make sequences
system layouts alien alien.c-types alien.accessors
alien.libraries slots splitting assocs combinators fry locals
compiler.constants classes.struct compiler.codegen
compiler.codegen.gc-maps compiler.codegen.labels
compiler.codegen.relocation compiler.cfg.instructions
compiler.cfg.builder compiler.cfg.intrinsics
compiler.cfg.stack-frame cpu.x86.assembler
cpu.x86.assembler.operands cpu.x86 cpu.architecture vm ;
USING: alien alien.c-types assocs combinators
compiler.cfg.intrinsics compiler.codegen.gc-maps
compiler.codegen.labels compiler.codegen.relocation
compiler.constants cpu.architecture cpu.x86 cpu.x86.assembler
cpu.x86.assembler.operands cpu.x86.features kernel locals math
sequences specialized-arrays system vocabs ;
FROM: layouts => cell cells ;
SPECIALIZED-ARRAY: uint
IN: cpu.x86.64
: 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 (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
! x86-64.
enable-alien-4-intrinsics
USE: vocabs
{
{ [ os unix? ] [ "cpu.x86.64.unix" require ] }
{ [ os windows? ] [ "cpu.x86.64.windows" require ] }

View File

@ -1,10 +1,10 @@
! Copyright (C) 2009, 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs sequences alien alien.c-types
combinators compiler compiler.codegen.labels compiler.units
cpu.architecture cpu.x86.assembler cpu.x86.assembler.operands
init io kernel locals math math.order math.parser memoize
namespaces system arrays specialized-arrays cpu.x86.64 ;
USING: alien alien.c-types arrays assocs combinators
compiler.codegen.labels cpu.architecture cpu.x86.assembler
cpu.x86.assembler.operands init kernel math math.order
math.parser memoize namespaces sequences
specialized-arrays system ;
SPECIALIZED-ARRAY: uint
IN: cpu.x86.features
@ -87,31 +87,6 @@ MEMO: sse-version ( -- n )
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 )
4 <uint-array> [ (cpuid) ] keep >array ;