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 ;;; Push some values onto the stack, returning the start and number of
20 ;;; values pushed as results. It is assumed that the Vals are wired to
21 ;;; the standard argument locations. Nvals is the number of values to
24 ;;; The generator cost is pseudo-random. We could get it right by
25 ;;; defining a bogus SC that reflects the costs of the
26 ;;; memory-to-memory moves for each operand, but this seems
28 (define-vop (push-values)
32 (start :scs (any-reg))
33 (count :scs (any-reg)))
35 (:temporary (:scs (descriptor-reg)) temp)
36 (:temporary (:scs (descriptor-reg)
41 (move csp-tn start-temp)
42 (inst lda csp-tn (* nvals n-word-bytes) csp-tn)
43 (do ((val vals (tn-ref-across val))
46 (let ((tn (tn-ref-tn val)))
49 (storew tn start-temp i))
51 (load-stack-tn temp tn)
52 (storew temp start-temp i)))))
53 (move start-temp start)
54 (inst li (fixnumize nvals) count)))
56 ;;; Push a list of values on the stack, returning Start and Count as
57 ;;; used in unknown values continuations.
58 (define-vop (values-list)
59 (:args (arg :scs (descriptor-reg) :target list))
62 (:results (start :scs (any-reg))
63 (count :scs (any-reg)))
64 (:temporary (:scs (descriptor-reg) :type list :from (:argument 0)) list)
65 (:temporary (:scs (non-descriptor-reg)) temp)
66 (:temporary (:scs (non-descriptor-reg)) ndescr)
68 (:save-p :compute-only)
74 (inst cmpeq list null-tn temp)
76 (loadw temp list cons-car-slot list-pointer-lowtag)
77 (loadw list list cons-cdr-slot list-pointer-lowtag)
78 (inst lda csp-tn n-word-bytes csp-tn)
79 (storew temp csp-tn -1)
80 (inst and list lowtag-mask ndescr)
81 (inst xor ndescr list-pointer-lowtag ndescr)
82 (inst beq ndescr loop)
83 (error-call vop bogus-argument-to-values-list-error list)
86 (inst subq csp-tn start count)))
88 ;;; Copy the &MORE arg block to the top of the stack so we can use
89 ;;; them as function arguments.
90 (define-vop (%more-arg-values)
91 (:args (context :scs (descriptor-reg any-reg) :target src)
92 (skip :scs (any-reg zero immediate))
93 (num :scs (any-reg) :target count))
94 (:arg-types * positive-fixnum positive-fixnum)
95 (:temporary (:sc any-reg :from (:argument 0)) src)
96 (:temporary (:sc any-reg :from (:argument 2)) dst)
97 (:temporary (:sc descriptor-reg :from (:argument 1)) temp)
98 (:temporary (:sc non-descriptor-reg) temp1)
99 (:results (start :scs (any-reg))
100 (count :scs (any-reg)))
106 (inst lda src (* (tn-value skip) n-word-bytes) context))
108 (inst addq context skip src)))
110 (inst move csp-tn start)
112 (inst move csp-tn dst)
113 (inst addq csp-tn count csp-tn)
115 (inst ldl temp 0 src)
116 (inst addq src 4 src)
117 (inst addq dst 4 dst)
118 (inst stl temp -4 dst)
119 (inst cmpeq dst csp-tn temp1)
120 (inst beq temp1 loop)