flatten non-integral types to (stack-value) on x86.32
parent
c12424f834
commit
88fbcba067
|
@ -9,7 +9,7 @@ IN: compiler.alien
|
||||||
|
|
||||||
: alien-parameters ( params -- seq )
|
: alien-parameters ( params -- seq )
|
||||||
dup parameters>>
|
dup parameters>>
|
||||||
swap return>> large-struct? [ void* prefix ] when ;
|
swap return>> large-struct? [ struct-return-pointer-type prefix ] when ;
|
||||||
|
|
||||||
: alien-return ( params -- type )
|
: alien-return ( params -- type )
|
||||||
return>> dup large-struct? [ drop void ] when ;
|
return>> dup large-struct? [ drop void ] when ;
|
||||||
|
|
|
@ -320,8 +320,17 @@ M: reg-class reg-class-full?
|
||||||
[ alloc-stack-param ] [ alloc-fastcall-param ] if
|
[ alloc-stack-param ] [ alloc-fastcall-param ] if
|
||||||
[ abi param-reg ] dip ;
|
[ abi param-reg ] dip ;
|
||||||
|
|
||||||
|
SYMBOL: (stack-value)
|
||||||
|
<< void* c-type clone \ (stack-value) define-primitive-type
|
||||||
|
stack-params \ (stack-value) c-type (>>rep) >>
|
||||||
|
|
||||||
|
: ((flatten-type)) ( type to-type -- seq )
|
||||||
|
[ stack-size cell align cell /i ] dip c-type <repetition> ; inline
|
||||||
|
|
||||||
: (flatten-int-type) ( type -- seq )
|
: (flatten-int-type) ( type -- seq )
|
||||||
stack-size cell align cell /i void* c-type <repetition> ;
|
void* ((flatten-type)) ;
|
||||||
|
: (flatten-stack-type) ( type -- seq )
|
||||||
|
(stack-value) ((flatten-type)) ;
|
||||||
|
|
||||||
GENERIC: flatten-value-type ( type -- types )
|
GENERIC: flatten-value-type ( type -- types )
|
||||||
|
|
||||||
|
|
|
@ -502,6 +502,9 @@ HOOK: immediate-arithmetic? cpu ( n -- ? )
|
||||||
! %and-imm, %or-imm, and %xor-imm?
|
! %and-imm, %or-imm, and %xor-imm?
|
||||||
HOOK: immediate-bitwise? cpu ( n -- ? )
|
HOOK: immediate-bitwise? cpu ( n -- ? )
|
||||||
|
|
||||||
|
! What c-type describes the implicit struct return pointer for large structs?
|
||||||
|
HOOK: struct-return-pointer-type cpu ( -- c-type )
|
||||||
|
|
||||||
! Is this structure small enough to be returned in registers?
|
! Is this structure small enough to be returned in registers?
|
||||||
HOOK: return-struct-in-registers? cpu ( c-type -- ? )
|
HOOK: return-struct-in-registers? cpu ( c-type -- ? )
|
||||||
|
|
||||||
|
|
|
@ -704,6 +704,8 @@ M: ppc immediate-arithmetic? ( n -- ? ) -32768 32767 between? ;
|
||||||
|
|
||||||
M: ppc immediate-bitwise? ( n -- ? ) 0 65535 between? ;
|
M: ppc immediate-bitwise? ( n -- ? ) 0 65535 between? ;
|
||||||
|
|
||||||
|
M: ppc struct-return-pointer-type void* ;
|
||||||
|
|
||||||
M: ppc return-struct-in-registers? ( c-type -- ? )
|
M: ppc return-struct-in-registers? ( c-type -- ? )
|
||||||
c-type return-in-registers?>> ;
|
c-type return-in-registers?>> ;
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
! 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: locals alien alien.c-types alien.libraries alien.syntax
|
||||||
arrays kernel fry math namespaces sequences system layouts io
|
arrays kernel fry math namespaces sequences system layouts io
|
||||||
vocabs.loader accessors init combinators command-line make
|
vocabs.loader accessors init classes.struct combinators command-line
|
||||||
compiler compiler.units compiler.constants compiler.alien
|
make compiler compiler.units compiler.constants compiler.alien
|
||||||
compiler.codegen compiler.codegen.fixup
|
compiler.codegen compiler.codegen.fixup
|
||||||
compiler.cfg.instructions compiler.cfg.builder
|
compiler.cfg.instructions compiler.cfg.builder
|
||||||
compiler.cfg.intrinsics compiler.cfg.stack-frame
|
compiler.cfg.intrinsics compiler.cfg.stack-frame
|
||||||
|
@ -357,6 +357,12 @@ M: x86.32 callback-return-rewind ( params -- n )
|
||||||
} cond ;
|
} cond ;
|
||||||
|
|
||||||
! Dreadful
|
! Dreadful
|
||||||
M: object flatten-value-type (flatten-int-type) ;
|
M: object flatten-value-type (flatten-stack-type) ;
|
||||||
|
M: struct-c-type flatten-value-type (flatten-stack-type) ;
|
||||||
|
M: long-long-type flatten-value-type (flatten-stack-type) ;
|
||||||
|
M: c-type flatten-value-type
|
||||||
|
dup rep>> int-rep? [ (flatten-int-type) ] [ (flatten-stack-type) ] if ;
|
||||||
|
|
||||||
|
M: x86.64 struct-return-pointer-type (stack-value) ;
|
||||||
|
|
||||||
check-sse
|
check-sse
|
||||||
|
|
|
@ -275,6 +275,8 @@ M:: x86.64 %call-gc ( gc-root-count temp -- )
|
||||||
! Call GC
|
! Call GC
|
||||||
"inline_gc" f %alien-invoke ;
|
"inline_gc" f %alien-invoke ;
|
||||||
|
|
||||||
|
M: x86.64 struct-return-pointer-type void* ;
|
||||||
|
|
||||||
! 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
|
||||||
|
|
|
@ -14,11 +14,6 @@ M: float-regs param-regs
|
||||||
|
|
||||||
M: x86.64 reserved-stack-space 0 ;
|
M: x86.64 reserved-stack-space 0 ;
|
||||||
|
|
||||||
SYMBOL: (stack-value)
|
|
||||||
! The ABI for passing structs by value is pretty great
|
|
||||||
<< void* c-type clone \ (stack-value) define-primitive-type
|
|
||||||
stack-params \ (stack-value) c-type (>>rep) >>
|
|
||||||
|
|
||||||
: struct-types&offset ( struct-type -- pairs )
|
: struct-types&offset ( struct-type -- pairs )
|
||||||
fields>> [
|
fields>> [
|
||||||
[ type>> ] [ offset>> ] bi 2array
|
[ type>> ] [ offset>> ] bi 2array
|
||||||
|
@ -36,8 +31,7 @@ stack-params \ (stack-value) c-type (>>rep) >>
|
||||||
] map ;
|
] map ;
|
||||||
|
|
||||||
: flatten-large-struct ( c-type -- seq )
|
: flatten-large-struct ( c-type -- seq )
|
||||||
heap-size cell align
|
(flatten-stack-type) ;
|
||||||
cell /i \ (stack-value) c-type <repetition> ;
|
|
||||||
|
|
||||||
: flatten-struct ( c-type -- seq )
|
: flatten-struct ( c-type -- seq )
|
||||||
dup heap-size 16 > [
|
dup heap-size 16 > [
|
||||||
|
|
Loading…
Reference in New Issue