2005-12-10 01:02:13 -05:00
|
|
|
! Copyright (C) 2005 Slava Pestov.
|
|
|
|
! See http://factor.sf.net/license.txt for BSD license.
|
|
|
|
IN: compiler-backend
|
2006-01-20 21:37:38 -05:00
|
|
|
USING: alien assembler kernel math sequences ;
|
|
|
|
|
|
|
|
GENERIC: store-insn ( offset reg-class -- )
|
|
|
|
|
|
|
|
GENERIC: load-insn ( elt parameter reg-class -- )
|
|
|
|
|
|
|
|
M: int-regs store-insn drop >r 3 1 r> stack@ STW ;
|
|
|
|
|
|
|
|
M: int-regs load-insn drop 3 + 1 rot stack@ LWZ ;
|
2005-12-10 01:02:13 -05:00
|
|
|
|
2005-12-24 16:08:15 -05:00
|
|
|
M: %unbox generate-node ( vop -- )
|
2006-01-20 21:37:38 -05:00
|
|
|
drop
|
|
|
|
! Call the unboxer
|
|
|
|
1 input f compile-c-call
|
|
|
|
! Store the return value on the C stack
|
|
|
|
0 input 2 input store-insn ;
|
2005-12-24 16:08:15 -05:00
|
|
|
|
|
|
|
M: %parameter generate-node ( vop -- )
|
|
|
|
! Move a value from the C stack into the fastcall register
|
2006-01-20 21:37:38 -05:00
|
|
|
drop 0 input 1 input 2 input load-insn ;
|
2005-12-24 16:08:15 -05:00
|
|
|
|
2006-01-20 21:37:38 -05:00
|
|
|
M: %box generate-node ( vop -- )
|
|
|
|
drop
|
|
|
|
! Move return value of C function into input register
|
|
|
|
param-regs first RAX MOV
|
|
|
|
0 input f compile-c-call ;
|
2005-12-24 16:08:15 -05:00
|
|
|
|
|
|
|
M: %cleanup generate-node ( vop -- ) drop ;
|