db6030081f3e4827e97452ff3e0be9dc061e944a
[sbcl.git] / src / compiler / generic / vm-ir2tran.lisp
1 ;;;; This software is part of the SBCL system. See the README file for
2 ;;;; more information.
3 ;;;;
4 ;;;; This software is derived from the CMU CL system, which was
5 ;;;; written at Carnegie Mellon University and released into the
6 ;;;; public domain. The software is in the public domain and is
7 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
8 ;;;; files for more information.
9
10 (in-package "SB!C")
11
12 (defoptimizer ir2-convert-reffer ((object) node block name offset lowtag)
13   (let* ((cont (node-cont node))
14          (locs (continuation-result-tns cont
15                                         (list *backend-t-primitive-type*)))
16          (res (first locs)))
17     (vop slot node block (continuation-tn node block object)
18          name offset lowtag res)
19     (move-continuation-result node block locs cont)))
20
21 (defoptimizer ir2-convert-setter ((object value) node block name offset lowtag)
22   (let ((value-tn (continuation-tn node block value)))
23     (vop set-slot node block (continuation-tn node block object) value-tn
24          name offset lowtag)
25     (move-continuation-result node block (list value-tn) (node-cont node))))
26
27 ;;; FIXME: Isn't there a name for this which looks less like a typo?
28 ;;; (The name IR2-CONVERT-SETTER is used for something else, just above.)
29 (defoptimizer ir2-convert-setfer ((value object) node block name offset lowtag)
30   (let ((value-tn (continuation-tn node block value)))
31     (vop set-slot node block (continuation-tn node block object) value-tn
32          name offset lowtag)
33     (move-continuation-result node block (list value-tn) (node-cont node))))
34
35 (defun do-inits (node block name result lowtag inits args)
36   (let ((unbound-marker-tn nil))
37     (dolist (init inits)
38       (let ((kind (car init))
39             (slot (cdr init)))
40         (vop set-slot node block result
41              (ecase kind
42                (:arg
43                 (aver args)
44                 (continuation-tn node block (pop args)))
45                (:unbound
46                 (or unbound-marker-tn
47                     (setf unbound-marker-tn
48                           (let ((tn (make-restricted-tn
49                                      nil
50                                      (sc-number-or-lose 'sb!vm::any-reg))))
51                             (vop make-unbound-marker node block tn)
52                             tn))))
53                (:null
54                 (emit-constant nil)))
55              name slot lowtag))))
56   (aver (null args)))
57
58 (defun do-fixed-alloc (node block name words type lowtag result)
59   (vop fixed-alloc node block name words type lowtag result))
60
61 (defoptimizer ir2-convert-fixed-allocation
62               ((&rest args) node block name words type lowtag inits)
63   (let* ((cont (node-cont node))
64          (locs (continuation-result-tns cont
65                                         (list *backend-t-primitive-type*)))
66          (result (first locs)))
67     (do-fixed-alloc node block name words type lowtag result)
68     (do-inits node block name result lowtag inits args)
69     (move-continuation-result node block locs cont)))
70
71 (defoptimizer ir2-convert-variable-allocation
72               ((extra &rest args) node block name words type lowtag inits)
73   (let* ((cont (node-cont node))
74          (locs (continuation-result-tns cont
75                                         (list *backend-t-primitive-type*)))
76          (result (first locs)))
77     (if (constant-continuation-p extra)
78         (let ((words (+ (continuation-value extra) words)))
79           (do-fixed-alloc node block name words type lowtag result))
80         (vop var-alloc node block (continuation-tn node block extra) name words
81              type lowtag result))
82     (do-inits node block name result lowtag inits args)
83     (move-continuation-result node block locs cont)))