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