1 ;;;; the Alpha implementation of unknown-values VOPs
3 ;;;; This software is part of the SBCL system. See the README file for
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.
14 (define-vop (reset-stack-pointer)
15 (:args (ptr :scs (any-reg)))
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 (:ignore r-moved-ptrs)
29 (move last-nipped-ptr dest)
30 (move last-preserved-ptr src)
31 (inst cmple csp-tn src temp)
35 (inst addq dest n-word-bytes dest)
36 (inst addq src n-word-bytes src)
38 (inst cmple csp-tn src temp)
41 (inst lda csp-tn 0 dest)
42 (inst subq src dest src)
43 (loop for moved = moved-ptrs then (tn-ref-across moved)
45 do (sc-case (tn-ref-tn moved)
46 ((descriptor-reg any-reg)
47 (inst subq (tn-ref-tn moved) src (tn-ref-tn moved)))
49 (load-stack-tn temp (tn-ref-tn moved))
50 (inst subq temp src temp)
51 (store-stack-tn (tn-ref-tn moved) temp))))))
53 ;;; Push some values onto the stack, returning the start and number of
54 ;;; values pushed as results. It is assumed that the Vals are wired to
55 ;;; the standard argument locations. Nvals is the number of values to
58 ;;; The generator cost is pseudo-random. We could get it right by
59 ;;; defining a bogus SC that reflects the costs of the
60 ;;; memory-to-memory moves for each operand, but this seems
62 (define-vop (push-values)
66 (start :scs (any-reg))
67 (count :scs (any-reg)))
69 (:temporary (:scs (descriptor-reg)) temp)
70 (:temporary (:scs (descriptor-reg)
75 (move csp-tn start-temp)
76 (inst lda csp-tn (* nvals n-word-bytes) csp-tn)
77 (do ((val vals (tn-ref-across val))
80 (let ((tn (tn-ref-tn val)))
83 (storew tn start-temp i))
85 (load-stack-tn temp tn)
86 (storew temp start-temp i)))))
87 (move start-temp start)
88 (inst li (fixnumize nvals) count)))
90 ;;; Push a list of values on the stack, returning Start and Count as
91 ;;; used in unknown values continuations.
92 (define-vop (values-list)
93 (:args (arg :scs (descriptor-reg) :target list))
96 (:results (start :scs (any-reg))
97 (count :scs (any-reg)))
98 (:temporary (:scs (descriptor-reg) :type list :from (:argument 0)) list)
99 (:temporary (:scs (non-descriptor-reg)) temp)
100 (:temporary (:scs (non-descriptor-reg)) ndescr)
102 (:save-p :compute-only)
108 (inst cmpeq list null-tn temp)
110 (loadw temp list cons-car-slot list-pointer-lowtag)
111 (loadw list list cons-cdr-slot list-pointer-lowtag)
112 (inst lda csp-tn n-word-bytes csp-tn)
113 (storew temp csp-tn -1)
114 (inst and list lowtag-mask ndescr)
115 (inst xor ndescr list-pointer-lowtag ndescr)
116 (inst beq ndescr loop)
117 (error-call vop bogus-arg-to-values-list-error list)
120 (inst subq csp-tn start count)))
122 ;;; Copy the &MORE arg block to the top of the stack so we can use
123 ;;; them as function arguments.
124 (define-vop (%more-arg-values)
125 (:args (context :scs (descriptor-reg any-reg) :target src)
126 (skip :scs (any-reg zero immediate))
127 (num :scs (any-reg) :target count))
128 (:arg-types * positive-fixnum positive-fixnum)
129 (:temporary (:sc any-reg :from (:argument 0)) src)
130 (:temporary (:sc any-reg :from (:argument 2)) dst)
131 (:temporary (:sc descriptor-reg :from (:argument 1)) temp)
132 (:temporary (:sc non-descriptor-reg) temp1)
133 (:results (start :scs (any-reg))
134 (count :scs (any-reg)))
140 (inst lda src (* (tn-value skip) n-word-bytes) context))
142 (inst addq context skip src)))
144 (inst move csp-tn start)
146 (inst move csp-tn dst)
147 (inst addq csp-tn count csp-tn)
149 (inst ldl temp 0 src)
150 (inst addq src 4 src)
151 (inst addq dst 4 dst)
152 (inst stl temp -4 dst)
153 (inst cmpeq dst csp-tn temp1)
154 (inst beq temp1 loop)