]> gitweb.factorcode.org Git - factor.git/commitdiff
basis/cpu: eliminate some usages of rot
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Wed, 26 Aug 2009 00:38:48 +0000 (19:38 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Wed, 26 Aug 2009 00:38:48 +0000 (19:38 -0500)
basis/cpu/ppc/assembler/assembler.factor
basis/cpu/ppc/ppc.factor
basis/cpu/x86/32/32.factor
basis/cpu/x86/64/64.factor

index 2362bdc73c02484752c8bc2efdad7539b0242c38..f59f8779efde99713ddde63ab1dc9f15fb1dc9de 100644 (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.
-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 ;
index d6674e70970ac00c74039e7ed67002561a2532ef..aec7e85b56f25a182160f865f6eb8c6f2224d837 100644 (file)
@@ -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) ;
index bd03b47302e5c379fdcc88920f51472ee23e8b2c..74312c3718c2004d9560a9ef8ce7001680e2aad3 100755 (executable)
@@ -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
index 7c832fe66c27b5be9638ea52fbd0edf4d5229bb3..145d4ff677126e73bb34c9702397041cf46346c0 100644 (file)
@@ -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 ;