factor/library/compiler/x86/architecture.factor

43 lines
977 B
Factor
Raw Normal View History

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-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
: 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-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 ;
! 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