Eliminate style-warning about undefined type GLOBAL-VAR
[sbcl.git] / src / compiler / arm / values.lisp
blob3f43ef8834419c095534af0be88b2bddd2f2b223
1 ;;;; unknown-values VOPs for the ARM VM
3 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; more information.
5 ;;;;
6 ;;;; This software is derived from the CMU CL system, which was
7 ;;;; written at Carnegie Mellon University and released into the
8 ;;;; public domain. The software is in the public domain and is
9 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
10 ;;;; files for more information.
12 (in-package "SB!VM")
14 (define-vop (reset-stack-pointer)
15 (:args (ptr :scs (any-reg)))
16 (:generator 1
17 (store-csp ptr)))
19 (define-vop (%%nip-values)
20 (:args (last-nipped-ptr :scs (any-reg) :target dest)
21 (last-preserved-ptr :scs (any-reg) :target src)
22 (moved-ptrs :scs (any-reg) :more t))
23 (:results (r-moved-ptrs :scs (any-reg) :more t))
24 (:temporary (:sc any-reg) src)
25 (:temporary (:sc any-reg) dest)
26 (:temporary (:sc non-descriptor-reg) temp)
27 (:temporary (:sc any-reg) stack-pointer)
28 (:ignore r-moved-ptrs)
29 (:generator 1
30 (move src last-preserved-ptr)
31 (move dest last-nipped-ptr)
32 (load-csp stack-pointer)
33 (inst cmp stack-pointer src)
34 (inst b :le DONE)
35 LOOP
36 (loadw temp src)
37 (inst add dest dest n-word-bytes)
38 (inst add src src n-word-bytes)
39 (storew temp dest -1)
40 (inst cmp stack-pointer src)
41 (inst b :gt LOOP)
42 DONE
43 (store-csp dest)
44 (inst sub src src dest)
45 (loop for moved = moved-ptrs then (tn-ref-across moved)
46 while moved
47 do (sc-case (tn-ref-tn moved)
48 ((descriptor-reg any-reg)
49 (inst sub (tn-ref-tn moved) (tn-ref-tn moved) src))
50 ((control-stack)
51 (load-stack-tn temp (tn-ref-tn moved))
52 (inst sub temp temp src)
53 (store-stack-tn (tn-ref-tn moved) temp))))))
55 ;;; Push some values onto the stack, returning the start and number of values
56 ;;; pushed as results. It is assumed that the Vals are wired to the standard
57 ;;; argument locations. Nvals is the number of values to push.
58 ;;;
59 ;;; The generator cost is pseudo-random. We could get it right by defining a
60 ;;; bogus SC that reflects the costs of the memory-to-memory moves for each
61 ;;; operand, but this seems unworthwhile.
62 ;;;
63 (define-vop (push-values)
64 (:args (vals :more t))
65 (:results (start :scs (any-reg) :from :load)
66 (count :scs (any-reg)))
67 (:info nvals)
68 (:temporary (:scs (descriptor-reg)) temp)
69 (:generator 20
70 (load-csp start)
71 (inst add temp start (* nvals n-word-bytes))
72 (store-csp temp)
73 (do ((val vals (tn-ref-across val))
74 (i 0 (1+ i)))
75 ((null val))
76 (let ((tn (tn-ref-tn val)))
77 (sc-case tn
78 (descriptor-reg
79 (storew tn start i))
80 (control-stack
81 (load-stack-tn temp tn)
82 (storew temp start i)))))
83 (inst mov count (fixnumize nvals))))
85 ;;; Push a list of values on the stack, returning Start and Count as used in
86 ;;; unknown values continuations.
87 ;;;
88 (define-vop (values-list)
89 (:args (arg :scs (descriptor-reg) :target list))
90 (:arg-types list)
91 (:policy :fast-safe)
92 (:results (start :scs (any-reg))
93 (count :scs (any-reg)))
94 (:temporary (:scs (descriptor-reg) :type list :from (:argument 0)) list)
95 (:temporary (:scs (descriptor-reg)) temp)
96 (:temporary (:scs (non-descriptor-reg)) ndescr)
97 (:temporary (:sc any-reg) csp-temp)
98 (:vop-var vop)
99 (:save-p :compute-only)
100 (:generator 0
101 (move list arg)
102 (load-csp start)
103 (move csp-temp start)
105 LOOP
106 (inst cmp list null-tn)
107 (loadw temp list cons-car-slot list-pointer-lowtag)
108 (inst b :eq DONE)
109 (loadw list list cons-cdr-slot list-pointer-lowtag)
110 (inst add csp-temp csp-temp n-word-bytes)
111 (store-csp csp-temp)
112 (storew temp csp-temp -1)
113 (test-type list LOOP nil (list-pointer-lowtag) :temp ndescr)
114 (error-call vop 'bogus-arg-to-values-list-error list)
116 DONE
117 (inst sub count csp-temp start)))
120 ;;; Copy the more arg block to the top of the stack so we can use them
121 ;;; as function arguments.
123 (define-vop (%more-arg-values)
124 (:args (context :scs (descriptor-reg any-reg) :target src)
125 (skip :scs (any-reg immediate))
126 (num :scs (any-reg) :target count))
127 (:arg-types * positive-fixnum positive-fixnum)
128 (:temporary (:sc any-reg :from (:argument 0)) src)
129 (:temporary (:sc any-reg :from (:argument 2)) dst)
130 (:temporary (:sc descriptor-reg :from (:argument 1)) temp)
131 (:temporary (:sc any-reg) i)
132 (:results (start :scs (any-reg))
133 (count :scs (any-reg)))
134 (:generator 20
135 (sc-case skip
136 (immediate
137 (inst add src context (* (tn-value skip) n-word-bytes)))
138 (any-reg
139 (inst add src context skip)))
140 (inst adds count num 0)
141 (load-csp start)
142 (inst b :eq DONE)
143 (inst mov dst start)
144 (inst add i start count)
145 (store-csp i)
146 (inst mov i count)
147 LOOP
148 (inst cmp i 4)
149 (inst sub i i 4)
150 (inst ldr temp (@ src i))
151 (inst str temp (@ dst i))
152 (inst b :ne LOOP)
153 DONE))