support.lisp 2.24 KB
Newer Older
chiles's avatar
chiles committed
1 2 3 4
;;; -*- Package: RT -*-
;;;
;;; **********************************************************************
;;; This code was written as part of the CMU Common Lisp project at
ram's avatar
ram committed
5 6 7
;;; Carnegie Mellon University, and has been placed in the public domain.
;;;
(ext:file-comment
8
  "$Header: src/assembly/rt/support.lisp $")
ram's avatar
ram committed
9
;;;
chiles's avatar
chiles committed
10 11
;;; **********************************************************************
;;;
12
;;; $Header: src/assembly/rt/support.lisp $
chiles's avatar
chiles committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
;;;
;;; This file contains the machine specific support routines needed by
;;; the file assembler.
;;;

(in-package "RT")

(def-vm-support-routine generate-call-sequence (name style vop)
  (ecase style
    (:raw
     (values
      `((inst bala (make-fixup ',name :assembly-routine)))
      nil))
    (:full-call
     (let ((nfp-save (make-symbol "NFP-SAVE"))
	   (lra (make-symbol "LRA")))
       (values
	`((let ((lra-label (gen-label))
		(cur-nfp (current-nfp-tn ,vop)))
	    (when cur-nfp
	      (store-stack-tn cur-nfp ,nfp-save))
	    (inst compute-lra-from-code ,lra code-tn lra-label)
	    ;; This absolute branch trashes the LIP register, but we don't use
	    ;; it when calling assembly routines.
	    (inst bala (make-fixup ',name :assembly-routine))
	    (emit-return-pc lra-label)
	    (note-this-location ,vop :unknown-return)
40 41 42 43 44
	    ;; Don't use MOVE.  Use a known 32-bit long instruction, so the
	    ;; returner can know how many bytes we used here in the
	    ;; multiple-value return case.  The returner wants to add a known
	    ;; quantity to LRA indicating how many values it returned.
	    (inst cal csp-tn ocfp-tn 0)
chiles's avatar
chiles committed
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
	    (inst compute-code-from-lra code-tn code-tn lra-label)
	    (when cur-nfp
	      (load-stack-tn cur-nfp ,nfp-save))))
	`((:temporary (:sc descriptor-reg :offset lra-offset
			   :from (:eval 0) :to (:eval 1))
		      ,lra)
	  (:temporary (:scs (control-stack) :offset nfp-save-offset)
		      ,nfp-save)))))
    (:none
     (values
      ;; This absolute branch trashes the LIP register, but we don't use it
      ;; when calling assembly routines.
      `((inst bala (make-fixup ',name :assembly-routine)))
      nil))))


(def-vm-support-routine generate-return-sequence (style)
  (ecase style
    (:raw
     `((inst b lip-tn)))
    (:full-call
66
     `((lisp-return lra-tn lip-tn :offset 1)))
chiles's avatar
chiles committed
67
    (:none)))