]> gitweb.factorcode.org Git - factor.git/blob - basis/cpu/x86/64/unix/unix.factor
32 and 64 bit Linux PPC support
[factor.git] / basis / cpu / x86 / 64 / unix / unix.factor
1 ! Copyright (C) 2008, 2010 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors arrays sequences math splitting make assocs
4 kernel layouts system alien.c-types classes.struct
5 cpu.architecture cpu.x86.assembler cpu.x86.assembler.operands
6 cpu.x86 cpu.x86.64 compiler.cfg.builder.alien
7 compiler.cfg.builder.alien.boxing compiler.cfg.registers ;
8 IN: cpu.x86.64.unix
9
10 M: x86.64 param-regs
11     drop {
12         { int-regs { RDI RSI RDX RCX R8 R9 } }
13         { float-regs { XMM0 XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 } }
14     } ;
15
16 M: x86.64 reserved-stack-space 0 ;
17
18 : struct-types&offset ( struct-type -- pairs )
19     fields>> [
20         [ type>> ] [ offset>> ] bi 2array
21     ] map ;
22
23 : split-struct ( pairs -- seq )
24     [
25         [ 8 mod zero? [ t , ] when , ] assoc-each
26     ] { } make { t } split harvest ;
27
28 : flatten-small-struct ( c-type -- seq )
29     struct-types&offset split-struct [
30         [ c-type c-type-rep reg-class-of ] map
31         int-regs swap member? int-rep double-rep ?
32         f f 3array
33     ] map ;
34
35 M: x86.64 flatten-struct-type ( c-type -- seq )
36     dup heap-size 16 <=
37     [ flatten-small-struct ] [ call-next-method [ first t f 3array ] map ] if ;
38
39 M: x86.64 return-struct-in-registers? ( c-type -- ? )
40     heap-size 2 cells <= ;
41
42 M: x86.64 dummy-stack-params? f ;
43
44 M: x86.64 dummy-int-params? f ;
45
46 M: x86.64 dummy-fp-params? f ;
47
48 M: x86.64 %prepare-var-args RAX RAX XOR ;