1 ;;;; the sparc 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 (inst move dest last-nipped-ptr)
30 (inst move src last-preserved-ptr)
33 (inst nop) ; not strictly necessary
36 (inst add dest dest n-word-bytes)
37 (inst add src src n-word-bytes)
43 (inst move csp-tn dest)
44 (inst sub src src dest)
45 (loop for moved = moved-ptrs then (tn-ref-across 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))
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
56 ;;; values pushed as results. It is assumed that the Vals are wired
57 ;;; to the standard argument locations. Nvals is the number of values
60 ;;; The generator cost is pseudo-random. We could get it right by
61 ;;; defining a bogus SC that reflects the costs of the
62 ;;; memory-to-memory moves for each operand, but this seems
64 (define-vop (push-values)
65 (:args (vals :more t))
66 (:results (start :scs (any-reg) :from :load)
67 (count :scs (any-reg)))
69 (:temporary (:scs (descriptor-reg)) temp)
71 (inst move start csp-tn)
72 (inst add csp-tn csp-tn (* nvals n-word-bytes))
73 (do ((val vals (tn-ref-across val))
76 (let ((tn (tn-ref-tn val)))
81 (load-stack-tn temp tn)
82 (storew temp start i)))))
83 (inst li count (fixnumize nvals))))
85 ;;; Push a list of values on the stack, returning Start and Count as
86 ;;; used in unknown values continuations.
87 (define-vop (values-list)
88 (:args (arg :scs (descriptor-reg) :target list))
91 (:results (start :scs (any-reg))
92 (count :scs (any-reg)))
93 (:temporary (:scs (descriptor-reg) :type list :from (:argument 0)) list)
94 (:temporary (:scs (descriptor-reg)) temp)
95 (:temporary (:scs (non-descriptor-reg)) ndescr)
97 (:save-p :compute-only)
99 (let ((loop (gen-label))
106 (inst cmp list null-tn)
108 (loadw temp list cons-car-slot list-pointer-lowtag)
109 (loadw list list cons-cdr-slot list-pointer-lowtag)
110 (inst add csp-tn csp-tn n-word-bytes)
111 (storew temp csp-tn -1)
112 (test-type list loop nil (list-pointer-lowtag) :temp ndescr)
113 (error-call vop bogus-arg-to-values-list-error list)
116 (inst sub count csp-tn start))))
120 ;;; Copy the more arg block to the top of the stack so we can use them
121 ;;; as function arguments.
122 (define-vop (%more-arg-values)
123 (:args (context :scs (descriptor-reg any-reg) :target src)
124 (skip :scs (any-reg zero immediate))
125 (num :scs (any-reg) :target count))
126 (:arg-types * positive-fixnum positive-fixnum)
127 (:temporary (:sc any-reg :from (:argument 0)) src)
128 (:temporary (:sc any-reg :from (:argument 2)) dst)
129 (:temporary (:sc descriptor-reg :from (:argument 1)) temp)
130 (:temporary (:sc any-reg) i)
131 (:results (start :scs (any-reg))
132 (count :scs (any-reg)))
138 (inst add src context (* (tn-value skip) n-word-bytes)))
140 (inst add src context skip)))
141 (inst orcc count zero-tn num)
143 (inst move start csp-tn)
144 (inst move dst csp-tn)
145 (inst add csp-tn count)