2 ;;; Written by Rob MacLachlan
4 ;;; Converted for SPARC by William Lott.
9 (define-vop (reset-stack-pointer)
10 (:args
(ptr :scs
(any-reg)))
15 ;;; Push some values onto the stack, returning the start and number of values
16 ;;; pushed as results. It is assumed that the Vals are wired to the standard
17 ;;; argument locations. Nvals is the number of values to push.
19 ;;; The generator cost is pseudo-random. We could get it right by defining a
20 ;;; bogus SC that reflects the costs of the memory-to-memory moves for each
21 ;;; operand, but this seems unworthwhile.
23 (define-vop (push-values)
24 (:args
(vals :more t
))
25 (:results
(start :scs
(any-reg) :from
:load
)
26 (count :scs
(any-reg)))
28 (:temporary
(:scs
(descriptor-reg)) temp
)
30 (inst mr start csp-tn
)
31 (inst addi csp-tn csp-tn
(* nvals sb
!vm
:n-word-bytes
))
32 (do ((val vals
(tn-ref-across val
))
35 (let ((tn (tn-ref-tn val
)))
40 (load-stack-tn temp tn
)
41 (storew temp start i
)))))
42 (inst lr count
(fixnumize nvals
))))
44 ;;; Push a list of values on the stack, returning Start and Count as used in
45 ;;; unknown values continuations.
47 (define-vop (values-list)
48 (:args
(arg :scs
(descriptor-reg) :target list
))
51 (:results
(start :scs
(any-reg))
52 (count :scs
(any-reg)))
53 (:temporary
(:scs
(descriptor-reg) :type list
:from
(:argument
0)) list
)
54 (:temporary
(:scs
(descriptor-reg)) temp
)
55 (:temporary
(:scs
(non-descriptor-reg)) ndescr
)
57 (:save-p
:compute-only
)
59 (let ((loop (gen-label))
66 (inst cmpw list null-tn
)
67 (loadw temp list sb
!vm
:cons-car-slot sb
!vm
:list-pointer-lowtag
)
69 (loadw list list sb
!vm
:cons-cdr-slot sb
!vm
:list-pointer-lowtag
)
70 (inst addi csp-tn csp-tn sb
!vm
:n-word-bytes
)
71 (storew temp csp-tn -
1)
72 (test-type list ndescr loop nil sb
!vm
:list-pointer-lowtag
)
73 (error-call vop bogus-arg-to-values-list-error list
)
76 (inst sub count csp-tn start
))))
79 ;;; Copy the more arg block to the top of the stack so we can use them
80 ;;; as function arguments.
82 (define-vop (%more-arg-values
)
83 (:args
(context :scs
(descriptor-reg any-reg
) :target src
)
84 (skip :scs
(any-reg zero immediate
))
85 (num :scs
(any-reg) :target count
))
86 (:arg-types
* positive-fixnum positive-fixnum
)
87 (:temporary
(:sc any-reg
:from
(:argument
0)) src
)
88 (:temporary
(:sc any-reg
:from
(:argument
2)) dst
)
89 (:temporary
(:sc descriptor-reg
:from
(:argument
1)) temp
)
90 (:temporary
(:sc any-reg
) i
)
91 (:results
(start :scs
(any-reg))
92 (count :scs
(any-reg)))
96 (inst mr src context
))
98 (inst addi src context
(* (tn-value skip
) n-word-bytes
)))
100 (inst add src context skip
)))
102 (inst mr start csp-tn
)
105 (inst add csp-tn csp-tn count
)
110 (inst lwzx temp src i
)
111 (inst stwx temp dst i
)