factor/core/compiler/pentium4/intrinsics.factor

60 lines
1.4 KiB
Factor
Raw Permalink 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
2006-11-07 16:00:53 -05:00
M: float-regs (%replace) drop swap %allot-float ;
2006-05-05 20:06:57 -04:00
2006-05-05 02:08:37 -04:00
: define-float-op ( word op -- )
2006-11-08 21:04:46 -05:00
[ "x" operand "y" operand ] swap add H{
2006-10-28 02:43:33 -04:00
{ +input+ { { float "x" } { float "y" } } }
{ +output+ { "x" } }
2006-05-05 02:08:37 -04:00
} define-intrinsic ;
{
{ float+ ADDSD }
{ float- SUBSD }
{ float* MULSD }
{ float/f DIVSD }
} [
first2 define-float-op
] each
: define-float-jump ( word op -- )
2006-11-08 21:04:46 -05:00
[ "x" operand "y" operand UCOMISD ] swap add
{ { float "x" } { float "y" } } define-if-intrinsic ;
2006-05-05 02:08:37 -04:00
{
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
\ float>fixnum [
2006-11-29 16:26:23 -05:00
"out" operand "in" operand CVTTSD2SI
"out" operand tag-bits SHL
] H{
{ +input+ { { float "in" } } }
{ +scratch+ { { f "out" } } }
{ +output+ { "out" } }
} define-intrinsic
\ fixnum>float [
"in" operand tag-bits SAR
"out" operand "in" operand CVTSI2SD
] H{
{ +input+ { { f "in" } } }
{ +scratch+ { { float "out" } } }
{ +output+ { "out" } }
} define-intrinsic