2005-09-05 17:36:20 -04:00
|
|
|
IN: compiler-backend
|
2005-12-10 01:27:41 -05:00
|
|
|
USING: alien assembler compiler compiler-backend kernel
|
|
|
|
sequences ;
|
2005-09-04 19:24:24 -04:00
|
|
|
|
2005-09-05 17:14:15 -04:00
|
|
|
! x86 register assignments
|
2005-12-05 19:07:41 -05:00
|
|
|
! EAX, ECX, EDX vregs
|
2005-09-05 17:14:15 -04:00
|
|
|
! ESI datastack
|
|
|
|
! EBX callstack
|
|
|
|
|
2005-09-09 22:34:24 -04:00
|
|
|
: fixnum-imm? ( -- ? )
|
|
|
|
#! Can fixnum operations take immediate operands?
|
|
|
|
t ; inline
|
|
|
|
|
2005-12-07 00:14:24 -05:00
|
|
|
: ds-reg ESI ; inline
|
|
|
|
: cs-reg EBX ; inline
|
2005-12-07 03:37:05 -05:00
|
|
|
: return-reg EAX ; inline
|
2005-12-07 00:14:24 -05:00
|
|
|
: remainder-reg EDX ; inline
|
|
|
|
|
2005-12-04 22:06:12 -05:00
|
|
|
: vregs { EAX ECX EDX } ; inline
|
2005-10-18 20:19:10 -04:00
|
|
|
|
2005-12-10 01:27:41 -05:00
|
|
|
: compile-c-call ( symbol dll -- )
|
|
|
|
2dup dlsym CALL 1 0 rel-dlsym ;
|
2005-12-10 01:02:13 -05:00
|
|
|
|
|
|
|
: compile-c-call* ( symbol dll args -- operands )
|
|
|
|
[ [ PUSH ] each compile-c-call ] keep
|
|
|
|
[ drop 0 scratch POP ] each ;
|
|
|
|
|
2005-10-18 20:19:10 -04:00
|
|
|
! On x86, parameters are never passed in registers.
|
|
|
|
M: int-regs fastcall-regs drop 0 ;
|
|
|
|
M: int-regs reg-class-size drop 4 ;
|
|
|
|
M: float-regs fastcall-regs drop 0 ;
|
|
|
|
|
|
|
|
: dual-fp/int-regs? f ;
|
2005-12-04 22:55:02 -05:00
|
|
|
|
|
|
|
: address-operand ( address -- operand )
|
|
|
|
#! On x86, we can always use an address as an operand
|
|
|
|
#! directly.
|
|
|
|
; inline
|
|
|
|
|
|
|
|
: fixnum>slot@ 1 SHR ; inline
|
2005-12-07 03:37:05 -05:00
|
|
|
|
|
|
|
: prepare-division CDQ ; inline
|