basis/cpu: eliminate some usages of rot

db4
Slava Pestov 2009-08-25 19:38:48 -05:00
parent b71e14d89f
commit 1afd001393
4 changed files with 16 additions and 15 deletions

View File

@ -1,6 +1,6 @@
! Copyright (C) 2005, 2008 Slava Pestov. ! Copyright (C) 2005, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: kernel namespaces words io.binary math math.order USING: kernel namespaces words math math.order locals
cpu.ppc.assembler.backend ; cpu.ppc.assembler.backend ;
IN: cpu.ppc.assembler IN: cpu.ppc.assembler
@ -189,9 +189,9 @@ MTSPR: LR 8
MTSPR: CTR 9 MTSPR: CTR 9
! Pseudo-instructions ! Pseudo-instructions
: LI ( value dst -- ) 0 rot ADDI ; inline : LI ( value dst -- ) swap [ 0 ] dip ADDI ; inline
: SUBI ( dst src1 src2 -- ) neg ADDI ; inline : SUBI ( dst src1 src2 -- ) neg ADDI ; inline
: LIS ( value dst -- ) 0 rot ADDIS ; inline : LIS ( value dst -- ) swap [ 0 ] dip ADDIS ; inline
: SUBIC ( dst src1 src2 -- ) neg ADDIC ; inline : SUBIC ( dst src1 src2 -- ) neg ADDIC ; inline
: SUBIC. ( dst src1 src2 -- ) neg ADDIC. ; inline : SUBIC. ( dst src1 src2 -- ) neg ADDIC. ; inline
: NOT ( dst src -- ) dup NOR ; inline : NOT ( dst src -- ) dup NOR ; inline
@ -204,6 +204,8 @@ MTSPR: CTR 9
: (SRWI) ( d a b -- d a b x y ) 32 over - swap 31 ; inline : (SRWI) ( d a b -- d a b x y ) 32 over - swap 31 ; inline
: SRWI ( d a b -- ) (SRWI) RLWINM ; : SRWI ( d a b -- ) (SRWI) RLWINM ;
: SRWI. ( d a b -- ) (SRWI) RLWINM. ; : SRWI. ( d a b -- ) (SRWI) RLWINM. ;
: LOAD32 ( n r -- ) [ w>h/h ] dip tuck LIS dup rot ORI ; :: LOAD32 ( n r -- )
n -16 shift HEX: 7fff bitand r LIS
r r n HEX: 7fff bitand ORI ;
: immediate? ( n -- ? ) HEX: -8000 HEX: 7fff between? ; : immediate? ( n -- ? ) HEX: -8000 HEX: 7fff between? ;
: LOAD ( n r -- ) over immediate? [ LI ] [ LOAD32 ] if ; : LOAD ( n r -- ) over immediate? [ LI ] [ LOAD32 ] if ;

View File

@ -62,7 +62,7 @@ M: rs-loc loc-reg drop rs-reg ;
M: ppc %peek loc>operand LWZ ; M: ppc %peek loc>operand LWZ ;
M: ppc %replace loc>operand STW ; M: ppc %replace loc>operand STW ;
: (%inc) ( n reg -- ) dup rot cells ADDI ; inline :: (%inc) ( n reg -- ) reg reg n cells ADDI ; inline
M: ppc %inc-d ( n -- ) ds-reg (%inc) ; M: ppc %inc-d ( n -- ) ds-reg (%inc) ;
M: ppc %inc-r ( n -- ) rs-reg (%inc) ; M: ppc %inc-r ( n -- ) rs-reg (%inc) ;

View File

@ -208,13 +208,13 @@ M: x86 %unbox-small-struct ( size -- )
{ 2 [ %unbox-struct-2 ] } { 2 [ %unbox-struct-2 ] }
} case ; } case ;
M: x86.32 %unbox-large-struct ( n c-type -- ) M:: x86.32 %unbox-large-struct ( n c-type -- )
! Alien must be in EAX. ! Alien must be in EAX.
! Compute destination address ! Compute destination address
ECX rot stack@ LEA ECX n stack@ LEA
12 [ 12 [
! Push struct size ! Push struct size
heap-size PUSH c-type heap-size PUSH
! Push destination address ! Push destination address
ECX PUSH ECX PUSH
! Push source address ! Push source address

View File

@ -102,13 +102,12 @@ M: x86.64 %unbox-small-struct ( c-type -- )
flatten-value-type [ %unbox-struct-field ] each-index flatten-value-type [ %unbox-struct-field ] each-index
] with-return-regs ; ] with-return-regs ;
M: x86.64 %unbox-large-struct ( n c-type -- ) M:: x86.64 %unbox-large-struct ( n c-type -- )
! Source is in param-reg-1 ! Source is in param-reg-1
heap-size ! Load destination address into param-reg-2
! Load destination address param-reg-2 n param@ LEA
param-reg-2 rot param@ LEA ! Load structure size into param-reg-3
! Load structure size param-reg-3 c-type heap-size MOV
param-reg-3 swap MOV
! Copy the struct to the C stack ! Copy the struct to the C stack
"to_value_struct" f %alien-invoke ; "to_value_struct" f %alien-invoke ;