4d7d53f1b6635eb88877ede3515d97747264f94a
[sbcl.git] / src / assembly / hppa / support.lisp
1 ;;;; the machine-specific support routines needed by the file assembler
2
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.
11
12 (in-package "SB!VM")
13
14 (!def-vm-support-routine generate-call-sequence (name style vop)
15   (ecase style
16     (:raw
17      (with-unique-names (fixup)
18        (values
19         `((let ((fixup (make-fixup ',name :assembly-routine)))
20             (inst ldil fixup ,fixup)
21             (inst ble fixup lisp-heap-space ,fixup :nullify t))
22           (inst nop))
23         `((:temporary (:scs (any-reg) :from (:eval 0) :to (:eval 1))
24                       ,fixup)))))
25     (:full-call
26      (let ((temp (make-symbol "TEMP"))
27            (nfp-save (make-symbol "NFP-SAVE"))
28            (lra (make-symbol "LRA")))
29        (values
30         `((let ((lra-label (gen-label))
31                 (cur-nfp (current-nfp-tn ,vop)))
32             (when cur-nfp
33               (store-stack-tn ,nfp-save cur-nfp))
34             (inst compute-lra-from-code code-tn lra-label ,temp ,lra)
35             (note-this-location ,vop :call-site)
36             (let ((fixup (make-fixup ',name :assembly-routine)))
37               (inst ldil fixup ,temp)
38               (inst be fixup lisp-heap-space ,temp :nullify t))
39             (emit-return-pc lra-label)
40             (note-this-location ,vop :single-value-return)
41             (move ocfp-tn csp-tn)
42             (inst compute-code-from-lra code-tn lra-label ,temp code-tn)
43             (when cur-nfp
44               (load-stack-tn cur-nfp ,nfp-save))))
45         `((:temporary (:scs (non-descriptor-reg) :from (:eval 0) :to (:eval 1))
46                       ,temp)
47           (:temporary (:sc descriptor-reg :offset lra-offset
48                            :from (:eval 0) :to (:eval 1))
49                       ,lra)
50           (:temporary (:scs (control-stack) :offset nfp-save-offset)
51                       ,nfp-save)
52           (:save-p :compute-only)))))
53     (:none
54      (with-unique-names (fixup)
55        (values
56         `((let ((fixup (make-fixup ',name :assembly-routine)))
57             (inst ldil fixup ,fixup)
58             (inst be fixup lisp-heap-space ,fixup :nullify t)))
59         `((:temporary (:scs (any-reg) :from (:eval 0) :to (:eval 1))
60                       ,fixup)))))))
61
62 (!def-vm-support-routine generate-return-sequence (style)
63   (ecase style
64     (:raw
65      `((inst bv lip-tn :nullify t)))
66     (:full-call
67      `((lisp-return (make-random-tn :kind :normal
68                                     :sc (sc-or-lose 'descriptor-reg)
69                                     :offset lra-offset)
70                     :offset 1)))
71     (:none)))
72
73 (defun return-machine-address (scp)
74   (context-register scp lip-offset))