factor/library/compiler/pentium4/intrinsics.factor

76 lines
1.9 KiB
Factor
Raw Normal View History

2006-05-05 02:08:37 -04:00
! Copyright (C) 2005, 2006 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
2006-05-05 20:06:57 -04:00
USING: alien arrays assembler generic kernel kernel-internals
2006-05-15 01:01:47 -04:00
math math-internals memory namespaces sequences words ;
2006-05-05 02:08:37 -04:00
IN: compiler
M: float-regs (%peek)
2006-05-09 11:31:10 -04:00
drop
fp-scratch swap %move-int>int
fp-scratch %move-int>float ;
2006-05-05 20:06:57 -04:00
: load-zone-ptr ( vreg -- )
#! Load pointer to start of zone array
2006-05-14 20:05:57 -04:00
dup "generations" f [ dlsym MOV ] 2keep
rel-absolute-cell rel-dlsym
dup [] MOV ;
2006-05-05 20:06:57 -04:00
: load-allot-ptr ( vreg -- )
dup load-zone-ptr dup cell [+] MOV ;
: inc-allot-ptr ( vreg n -- )
>r dup load-zone-ptr cell [+] r> ADD ;
2006-05-14 16:44:47 -04:00
: with-inline-alloc ( prequot postquot spec -- )
2006-05-05 20:06:57 -04:00
#! both quotations are called with the vreg
2006-05-09 21:37:07 -04:00
[
2006-05-14 20:05:57 -04:00
alloc-tmp-reg PUSH
alloc-tmp-reg load-allot-ptr
alloc-tmp-reg [] \ tag-header get call tag-header MOV
>r call alloc-tmp-reg \ tag get call OR
r> call alloc-tmp-reg \ size get call inc-allot-ptr
alloc-tmp-reg POP
2006-05-05 20:06:57 -04:00
] bind ; inline
M: float-regs (%replace)
2006-05-14 16:44:47 -04:00
drop
2006-05-14 20:05:57 -04:00
[ alloc-tmp-reg 8 [+] rot v>operand MOVSD ]
[ v>operand alloc-tmp-reg MOV ] H{
2006-05-05 20:06:57 -04:00
{ tag-header [ float-tag ] }
{ tag [ float-tag ] }
{ size [ 16 ] }
2006-05-09 21:37:07 -04:00
} with-inline-alloc ;
2006-05-05 20:06:57 -04:00
2006-05-05 02:08:37 -04:00
! Floats
: define-float-op ( word op -- )
[ [ "x" operand "y" operand ] % , ] [ ] make H{
{ +input { { float "x" } { float "y" } } }
{ +output { "x" } }
} define-intrinsic ;
{
{ float+ ADDSD }
{ float- SUBSD }
{ float* MULSD }
{ float/f DIVSD }
} [
first2 define-float-op
] each
: define-float-jump ( word op -- )
[
2006-05-09 22:22:21 -04:00
[ end-basic-block "x" operand "y" operand UCOMISD ] % ,
2006-05-05 02:08:37 -04:00
] [ ] make H{
{ +input { { float "x" } { float "y" } } }
} define-if-intrinsic ;
{
2006-05-05 23:06:08 -04:00
{ float< JB }
{ float<= JBE }
{ float> JA }
{ float>= JAE }
2006-05-05 02:08:37 -04:00
{ float= JE }
} [
first2 define-float-jump
] each