home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / pcl / src-16f.lha / compiler / sparc / alloc.lisp < prev    next >
Encoding:
Text File  |  1991-11-06  |  4.3 KB  |  125 lines

  1. ;;; -*- Package: SPARC -*-
  2. ;;;
  3. ;;; **********************************************************************
  4. ;;; This code was written as part of the Spice Lisp project at
  5. ;;; Carnegie-Mellon University, and has been placed in the public domain.
  6. ;;; If you want to use this code or any part of Spice Lisp, please contact
  7. ;;; Scott Fahlman (FAHLMAN@CMUC). 
  8. ;;; **********************************************************************
  9. ;;;
  10. ;;; $Header: alloc.lisp,v 1.2 91/04/03 00:54:51 wlott Exp $
  11. ;;;
  12. ;;; Allocation VOPs for the SPARC port.
  13. ;;;
  14. ;;; Written by William Lott.
  15. ;;; 
  16.  
  17. (in-package "SPARC")
  18.  
  19.  
  20. ;;;; LIST and LIST*
  21.  
  22. (define-vop (list-or-list*)
  23.   (:args (things :more t))
  24.   (:temporary (:scs (descriptor-reg) :type list) ptr)
  25.   (:temporary (:scs (descriptor-reg)) temp)
  26.   (:temporary (:scs (descriptor-reg) :type list :to (:result 0) :target result)
  27.           res)
  28.   (:temporary (:scs (non-descriptor-reg) :type random) ndescr)
  29.   (:info num)
  30.   (:results (result :scs (descriptor-reg)))
  31.   (:variant-vars star)
  32.   (:policy :safe)
  33.   (:generator 0
  34.     (cond ((zerop num)
  35.        (move result null-tn))
  36.       ((and star (= num 1))
  37.        (move result (tn-ref-tn things)))
  38.       (t
  39.        (macrolet
  40.            ((store-car (tn list &optional (slot cons-car-slot))
  41.           `(let ((reg
  42.               (sc-case ,tn
  43.                 ((any-reg descriptor-reg zero null)
  44.                  ,tn)
  45.                 (control-stack
  46.                  (load-stack-tn temp ,tn)
  47.                  temp))))
  48.              (storew reg ,list ,slot list-pointer-type))))
  49.          (let ((cons-cells (if star (1- num) num)))
  50.            (pseudo-atomic (ndescr)
  51.          (inst add res alloc-tn list-pointer-type)
  52.          (inst add alloc-tn alloc-tn
  53.                (* (pad-data-block cons-size) cons-cells))
  54.          (move ptr res)
  55.          (dotimes (i (1- cons-cells))
  56.            (store-car (tn-ref-tn things) ptr)
  57.            (setf things (tn-ref-across things))
  58.            (inst add ptr ptr (pad-data-block cons-size))
  59.            (storew ptr ptr
  60.                (- cons-cdr-slot cons-size)
  61.                list-pointer-type))
  62.          (store-car (tn-ref-tn things) ptr)
  63.          (cond (star
  64.             (setf things (tn-ref-across things))
  65.             (store-car (tn-ref-tn things) ptr cons-cdr-slot))
  66.                (t
  67.             (storew null-tn ptr
  68.                 cons-cdr-slot list-pointer-type)))
  69.          (assert (null (tn-ref-across things)))
  70.          (move result res))))))))
  71.  
  72. (define-vop (list list-or-list*)
  73.   (:variant nil))
  74.  
  75. (define-vop (list* list-or-list*)
  76.   (:variant t))
  77.  
  78.  
  79. ;;;; Special purpose inline allocators.
  80.  
  81. (define-vop (allocate-code-object)
  82.   (:args (boxed-arg :scs (any-reg))
  83.      (unboxed-arg :scs (any-reg)))
  84.   (:results (result :scs (descriptor-reg)))
  85.   (:temporary (:scs (non-descriptor-reg)) ndescr)
  86.   (:temporary (:scs (any-reg) :from (:argument 0)) boxed)
  87.   (:temporary (:scs (non-descriptor-reg) :from (:argument 1)) unboxed)
  88.   (:generator 100
  89.     (inst add boxed boxed-arg (fixnum (1+ code-trace-table-offset-slot)))
  90.     (inst and boxed (lognot lowtag-mask))
  91.     (inst srl unboxed unboxed-arg word-shift)
  92.     (inst add unboxed lowtag-mask)
  93.     (inst and unboxed (lognot lowtag-mask))
  94.     (pseudo-atomic (ndescr)
  95.       (inst add result alloc-tn other-pointer-type)
  96.       (inst add alloc-tn boxed)
  97.       (inst add alloc-tn unboxed)
  98.       (inst sll ndescr boxed (- type-bits word-shift))
  99.       (inst or ndescr code-header-type)
  100.       (storew ndescr result 0 other-pointer-type)
  101.       (storew unboxed result code-code-size-slot other-pointer-type)
  102.       (storew null-tn result code-entry-points-slot other-pointer-type)
  103.       (storew null-tn result code-debug-info-slot other-pointer-type))))
  104.  
  105. (define-vop (make-symbol)
  106.   (:args (name :scs (descriptor-reg) :to :eval))
  107.   (:temporary (:scs (non-descriptor-reg)) temp)
  108.   (:results (result :scs (descriptor-reg) :from :argument))
  109.   (:policy :fast-safe)
  110.   (:translate make-symbol)
  111.   (:generator 37
  112.     (with-fixed-allocation (result temp symbol-header-type symbol-size)
  113.       (inst li temp unbound-marker-type)
  114.       (storew temp result symbol-value-slot other-pointer-type)
  115.       (storew temp result symbol-function-slot other-pointer-type)
  116.       (storew temp result symbol-setf-function-slot other-pointer-type)
  117.       (inst li temp (make-fixup "_undefined_tramp" :foreign))
  118.       (storew temp result symbol-raw-function-addr-slot
  119.           other-pointer-type)
  120.       (storew null-tn result symbol-plist-slot other-pointer-type)
  121.       (storew name result symbol-name-slot other-pointer-type)
  122.       (storew null-tn result symbol-package-slot other-pointer-type))))
  123.  
  124.  
  125.