Fix PowerPC bignum>fixnum intrinsic

slava 2006-11-10 07:30:20 +00:00
parent 761dab4188
commit f4785a8883
1 changed files with 30 additions and 19 deletions

View File

@ -232,25 +232,36 @@ math-internals namespaces sequences words ;
{ +output+ { "x" } } { +output+ { "x" } }
} define-intrinsic } define-intrinsic
! \ bignum>fixnum [ \ bignum>fixnum [
! "nonzero" define-label "nonzero" define-label
! "end" define-label "positive" define-label
! "y" operand "x" operand cell LWZ "end" define-label
! 0 "x" operand 0 CMPI ! is it zero? "x" operand dup %untag
! "nonzero" get BNE "y" operand "x" operand cell LWZ
! 0 "y" operand LI ! if the length is 1, its just the sign and nothing else,
! "end" get B ! so output 0
! "nonzero" resolve-label 0 "y" operand 1 tag-bits shift CMPI
! "y" operand "x" operand 2 cells LWZ "nonzero" get BNE
! "y" operand dup -1 tag-bits shift MULI 0 "y" operand LI
! "x" operand dup 3 cells LWZ "end" get B
! "y" operand "y" operand "x" operand MULLW "nonzero" resolve-label
! "end" resolve-label ! load the value
! ] H{ "y" operand "x" operand 3 cells LWZ
! { +input+ { { f "x" } } } ! load the sign
! { +scratch+ { { f "y" } } } "x" operand "x" operand 2 cells LWZ
! { +output+ { "y" } } ! is the sign negative?
! } define-intrinsic 0 "x" operand 0 CMPI
"positive" get BEQ
"y" operand dup -1 MULI
"positive" resolve-label
"y" operand dup %tag-fixnum
"end" resolve-label
] H{
{ +input+ { { f "x" } } }
{ +scratch+ { { f "y" } } }
{ +clobber+ { "x" } }
{ +output+ { "y" } }
} define-intrinsic
: define-float-op ( word op -- ) : define-float-op ( word op -- )
[ [ "x" operand "x" operand "y" operand ] % , ] [ ] make H{ [ [ "x" operand "x" operand "y" operand ] % , ] [ ] make H{