Fix make-array transforms.
[sbcl.git] / assembly / ppc / foo.lisp
1 (in-package "SB!VM")
2
3 \f
4 ;;;; Return-multiple with other than one value
5
6 (define-assembly-routine
7     (return-multiple
8      (:return-style :none))
9
10      ;; These four are really arguments.
11     ((:temp nvals any-reg nargs-offset)
12      (:temp vals any-reg nl0-offset)
13      (:temp ocfp any-reg nl1-offset)
14      (:temp lra descriptor-reg lra-offset)
15
16      ;; These are just needed to facilitate the transfer
17      (:temp lip interior-reg lip-offset)
18      (:temp count any-reg nl2-offset)
19      (:temp src any-reg nl3-offset)
20      (:temp dst any-reg cfunc-offset)
21      (:temp temp descriptor-reg l0-offset)
22
23      
24      ;; These are needed so we can get at the register args.
25      (:temp a0 descriptor-reg a0-offset)
26      (:temp a1 descriptor-reg a1-offset)
27      (:temp a2 descriptor-reg a2-offset)
28      (:temp a3 descriptor-reg a3-offset))
29
30   ;; Note, because of the way the return-multiple vop is written, we can
31   ;; assume that we are never called with nvals == 1 and that a0 has already
32   ;; been loaded.
33   (inst cmpwi nvals 0))
34 #|
35   (inst ble default-a0-and-on)
36   (inst cmpwi nvals (fixnumize 2))
37   (inst lwz a1 vals (* 1 n-word-bytes))
38   (inst ble default-a2-and-on)
39   (inst cmpwi nvals (fixnumize 3))
40   (inst lwz a2 vals (* 2 n-word-bytes))
41   (inst ble default-a3-and-on)
42   (inst cmpwi nvals (fixnumize 4))
43   (inst lwz a3 vals (* 3 n-word-bytes))
44   (inst ble done)
45
46   ;; Copy the remaining args to the top of the stack.
47   (inst addi src vals (* 4 n-word-bytes))
48   (inst addi dst cfp-tn (* 4 n-word-bytes))
49   (inst addic. count nvals (- (fixnumize 4)))
50
51   LOOP
52   (inst subic. count count (fixnumize 1))
53   (inst lwz temp src 0)
54   (inst addi src src n-word-bytes)
55   (inst stw temp dst 0)
56   (inst addi dst dst n-word-bytes)
57   (inst bge loop)
58                 
59   (inst b done)
60
61   DEFAULT-A0-AND-ON
62   (inst mr a0 null-tn)
63   (inst mr a1 null-tn)
64   DEFAULT-A2-AND-ON
65   (inst mr a2 null-tn)
66   DEFAULT-A3-AND-ON
67   (inst mr a3 null-tn)
68   DONE
69   
70   ;; Clear the stack.
71   (move ocfp-tn cfp-tn)
72   (move cfp-tn ocfp)
73   (inst add csp-tn ocfp-tn nvals)
74   
75   ;; Return.
76   (lisp-return lra lip))
77
78 \f
79 ;;;; tail-call-variable.
80
81 #+sb-assembling ;; no vop for this one either.
82 (define-assembly-routine
83     (tail-call-variable
84      (:return-style :none))
85
86     ;; These are really args.
87     ((:temp args any-reg nl0-offset)
88      (:temp lexenv descriptor-reg lexenv-offset)
89
90      ;; We need to compute this
91      (:temp nargs any-reg nargs-offset)
92
93      ;; These are needed by the blitting code.
94      (:temp src any-reg nl1-offset)
95      (:temp dst any-reg nl2-offset)
96      (:temp count any-reg nl3-offset)
97      (:temp temp descriptor-reg l0-offset)
98      (:temp lip interior-reg lip-offset)
99
100      ;; These are needed so we can get at the register args.
101      (:temp a0 descriptor-reg a0-offset)
102      (:temp a1 descriptor-reg a1-offset)
103      (:temp a2 descriptor-reg a2-offset)
104      (:temp a3 descriptor-reg a3-offset))
105
106
107   ;; Calculate NARGS (as a fixnum)
108   (inst sub nargs csp-tn args)
109      
110   ;; Load the argument regs (must do this now, 'cause the blt might
111   ;; trash these locations)
112   (inst lwz a0 args (* 0 n-word-bytes))
113   (inst lwz a1 args (* 1 n-word-bytes))
114   (inst lwz a2 args (* 2 n-word-bytes))
115   (inst lwz a3 args (* 3 n-word-bytes))
116
117   ;; Calc SRC, DST, and COUNT
118   (inst addic. count nargs (fixnumize (- register-arg-count)))
119   (inst addi src args (* n-word-bytes register-arg-count))
120   (inst ble done)
121   (inst addi dst cfp-tn (* n-word-bytes register-arg-count))
122         
123   LOOP
124   ;; Copy one arg.
125   (inst lwz temp src 0)
126   (inst addi src src n-word-bytes)
127   (inst stw temp dst 0)
128   (inst addic. count count (fixnumize -1))
129   (inst addi dst dst n-word-bytes)
130   (inst bgt loop)
131         
132   DONE
133   ;; We are done.  Do the jump.
134   (loadw temp lexenv closure-fun-slot fun-pointer-lowtag)
135   (lisp-jump temp lip))
136
137
138 \f
139 ;;;; Non-local exit noise.
140
141 (define-assembly-routine (unwind
142                           (:return-style :none)
143                           (:translate %continue-unwind)
144                           (:policy :fast-safe))
145                          ((:arg block (any-reg descriptor-reg) a0-offset)
146                           (:arg start (any-reg descriptor-reg) ocfp-offset)
147                           (:arg count (any-reg descriptor-reg) nargs-offset)
148                           (:temp lra descriptor-reg lra-offset)
149                           (:temp lip interior-reg lip-offset)
150                           (:temp cur-uwp any-reg nl0-offset)
151                           (:temp next-uwp any-reg nl1-offset)
152                           (:temp target-uwp any-reg nl2-offset))
153   (declare (ignore start count))
154
155   (let ((error (generate-error-code nil invalid-unwind-error)))
156     (inst cmpwi block 0)
157     (inst beq error))
158   
159   (load-symbol-value cur-uwp *current-unwind-protect-block*)
160   (loadw target-uwp block unwind-block-current-uwp-slot)
161   (inst cmpw cur-uwp target-uwp)
162   (inst bne do-uwp)
163       
164   (move cur-uwp block)
165
166   DO-EXIT
167       
168   (loadw cfp-tn cur-uwp unwind-block-current-cont-slot)
169   (loadw code-tn cur-uwp unwind-block-current-code-slot)
170   (loadw lra cur-uwp unwind-block-entry-pc-slot)
171   (lisp-return lra lip :frob-code nil)
172
173   DO-UWP
174
175   (loadw next-uwp cur-uwp unwind-block-current-uwp-slot)
176   (store-symbol-value next-uwp *current-unwind-protect-block*)
177   (inst b do-exit))
178
179 (define-assembly-routine (throw
180                           (:return-style :none))
181                          ((:arg target descriptor-reg a0-offset)
182                           (:arg start any-reg ocfp-offset)
183                           (:arg count any-reg nargs-offset)
184                           (:temp catch any-reg a1-offset)
185                           (:temp tag descriptor-reg a2-offset))           
186   
187   (declare (ignore start count))
188
189   (load-symbol-value catch *current-catch-block*)
190   
191   loop
192   
193   (let ((error (generate-error-code nil unseen-throw-tag-error target)))
194     (inst cmpwi catch 0)
195     (inst beq error))
196   
197   (loadw tag catch catch-block-tag-slot)
198   (inst cmpw tag target)
199   (inst beq exit)
200   (loadw catch catch catch-block-previous-catch-slot)
201   (inst b loop)
202   
203   exit
204   
205   (move target catch)
206   (inst ba (make-fixup 'unwind :assembly-routine)))
207
208
209
210 |#