]> gitweb.factorcode.org Git - factor.git/blob - basis/compiler/alien/alien.factor
Fixing failing unit tests in compiler.tree.propagation due to constraints
[factor.git] / basis / compiler / alien / alien.factor
1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors kernel namespaces make math sequences layouts
4 alien.c-types alien.structs cpu.architecture ;
5 IN: compiler.alien
6
7 : large-struct? ( ctype -- ? )
8     dup c-struct? [ return-struct-in-registers? not ] [ drop f ] if ;
9
10 : alien-parameters ( params -- seq )
11     dup parameters>>
12     swap return>> large-struct? [ "void*" prefix ] when ;
13
14 : alien-return ( params -- ctype )
15     return>> dup large-struct? [ drop "void" ] when ;
16
17 : c-type-stack-align ( type -- align )
18     dup c-type-stack-align? [ c-type-align ] [ drop cell ] if ;
19
20 : parameter-align ( n type -- n delta )
21     [ c-type-stack-align align dup ] [ drop ] 2bi - ;
22
23 : parameter-sizes ( types -- total offsets )
24     #! Compute stack frame locations.
25     [
26         0 [
27             [ parameter-align drop dup , ] keep stack-size +
28         ] reduce cell align
29     ] { } make ;