]> gitweb.factorcode.org Git - factor.git/blob - basis/cpu/x86/64/unix/unix.factor
Fixing failing unit tests in compiler.tree.propagation due to constraints
[factor.git] / basis / cpu / x86 / 64 / unix / unix.factor
1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors arrays sequences math splitting make assocs kernel
4 layouts system alien.c-types alien.structs cpu.architecture
5 cpu.x86.assembler cpu.x86.assembler.operands cpu.x86 compiler.codegen
6 compiler.cfg.registers ;
7 IN: cpu.x86.64.unix
8
9 M: int-regs param-regs
10     drop { RDI RSI RDX RCX R8 R9 } ;
11
12 M: float-regs param-regs
13     drop { XMM0 XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 } ;
14
15 M: x86.64 reserved-area-size 0 ;
16
17 ! The ABI for passing structs by value is pretty messed up
18 << "void*" c-type clone "__stack_value" define-primitive-type
19 stack-params "__stack_value" c-type (>>rep) >>
20
21 : struct-types&offset ( struct-type -- pairs )
22     fields>> [
23         [ type>> ] [ offset>> ] bi 2array
24     ] map ;
25
26 : split-struct ( pairs -- seq )
27     [
28         [ 8 mod zero? [ t , ] when , ] assoc-each
29     ] { } make { t } split harvest ;
30
31 : flatten-small-struct ( c-type -- seq )
32     struct-types&offset split-struct [
33         [ c-type c-type-rep reg-class-of ] map
34         int-regs swap member? "void*" "double" ? c-type
35     ] map ;
36
37 : flatten-large-struct ( c-type -- seq )
38     heap-size cell align
39     cell /i "__stack_value" c-type <repetition> ;
40
41 M: struct-type flatten-value-type ( type -- seq )
42     dup heap-size 16 > [
43         flatten-large-struct
44     ] [
45         flatten-small-struct
46     ] if ;
47
48 M: x86.64 return-struct-in-registers? ( c-type -- ? )
49     heap-size 2 cells <= ;
50
51 M: x86.64 dummy-stack-params? f ;
52
53 M: x86.64 dummy-int-params? f ;
54
55 M: x86.64 dummy-fp-params? f ;
56
57 M: x86.64 temp-reg R8 ;