basis/cpu: eliminate some usages of rot
parent
b71e14d89f
commit
1afd001393
|
@ -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.
|
||||
USING: kernel namespaces words io.binary math math.order
|
||||
USING: kernel namespaces words math math.order locals
|
||||
cpu.ppc.assembler.backend ;
|
||||
IN: cpu.ppc.assembler
|
||||
|
||||
|
@ -189,9 +189,9 @@ MTSPR: LR 8
|
|||
MTSPR: CTR 9
|
||||
|
||||
! Pseudo-instructions
|
||||
: LI ( value dst -- ) 0 rot ADDI ; inline
|
||||
: LI ( value dst -- ) swap [ 0 ] dip 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
|
||||
: 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 -- ) (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? ;
|
||||
: LOAD ( n r -- ) over immediate? [ LI ] [ LOAD32 ] if ;
|
||||
|
|
|
@ -62,7 +62,7 @@ M: rs-loc loc-reg drop rs-reg ;
|
|||
M: ppc %peek loc>operand LWZ ;
|
||||
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-r ( n -- ) rs-reg (%inc) ;
|
||||
|
|
|
@ -208,13 +208,13 @@ M: x86 %unbox-small-struct ( size -- )
|
|||
{ 2 [ %unbox-struct-2 ] }
|
||||
} case ;
|
||||
|
||||
M: x86.32 %unbox-large-struct ( n c-type -- )
|
||||
M:: x86.32 %unbox-large-struct ( n c-type -- )
|
||||
! Alien must be in EAX.
|
||||
! Compute destination address
|
||||
ECX rot stack@ LEA
|
||||
ECX n stack@ LEA
|
||||
12 [
|
||||
! Push struct size
|
||||
heap-size PUSH
|
||||
c-type heap-size PUSH
|
||||
! Push destination address
|
||||
ECX PUSH
|
||||
! Push source address
|
||||
|
|
|
@ -102,13 +102,12 @@ M: x86.64 %unbox-small-struct ( c-type -- )
|
|||
flatten-value-type [ %unbox-struct-field ] each-index
|
||||
] 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
|
||||
heap-size
|
||||
! Load destination address
|
||||
param-reg-2 rot param@ LEA
|
||||
! Load structure size
|
||||
param-reg-3 swap MOV
|
||||
! Load destination address into param-reg-2
|
||||
param-reg-2 n param@ LEA
|
||||
! Load structure size into param-reg-3
|
||||
param-reg-3 c-type heap-size MOV
|
||||
! Copy the struct to the C stack
|
||||
"to_value_struct" f %alien-invoke ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue