2a5e4e11f57a183002a4f773a434d550e1a648ca
[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 :none)
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         `((:temporary (:scs (any-reg) :from (:eval 0) :to (:eval 1))
23                       ,fixup)))))
24     (:full-call
25      (let ((temp (make-symbol "TEMP"))
26            (nfp-save (make-symbol "NFP-SAVE"))
27            (lra (make-symbol "LRA")))
28        (values
29         `((let ((lra-label (gen-label))
30                 (cur-nfp (current-nfp-tn ,vop)))
31             (when cur-nfp
32               (store-stack-tn ,nfp-save cur-nfp))
33             (inst compute-lra-from-code code-tn lra-label ,temp ,lra)
34             (note-next-instruction ,vop :call-site)
35             (let ((fixup (make-fixup ',name :assembly-routine)))
36               (inst ldil fixup ,temp)
37               (inst be fixup lisp-heap-space ,temp :nullify t))
38             (without-scheduling ()
39               (emit-return-pc lra-label)
40               (note-this-location ,vop :single-value-return)
41               (inst move ocfp-tn csp-tn)
42               (inst nop)) ; this nop is here because of emit-return-pc align
43             (inst compute-code-from-lra code-tn lra-label ,temp code-tn)
44             (when cur-nfp
45               (load-stack-tn cur-nfp ,nfp-save))))
46         `((:temporary (:scs (non-descriptor-reg) :from (:eval 0) :to (:eval 1))
47                       ,temp)
48           (:temporary (:sc descriptor-reg :offset lra-offset
49                        :from (:eval 0) :to (:eval 1))
50                       ,lra)
51           (:temporary (:scs (control-stack) :offset nfp-save-offset)
52                       ,nfp-save)
53           (:save-p t)))))))
54
55 (!def-vm-support-routine generate-return-sequence (style)
56   (ecase style
57     (:raw
58      `((inst bv lip-tn :nullify t)))
59     (:full-call
60      `((lisp-return (make-random-tn :kind :normal
61                                     :sc (sc-or-lose 'descriptor-reg)
62                                     :offset lra-offset)
63                     :offset 1)))
64     (:none)))
65
66 (defun return-machine-address (scp)
67   (context-register scp lip-offset))