Remove "-HEADER-" from SYMBOL and VALUE-CELL widetag names
[sbcl.git] / src / compiler / ppc / alloc.lisp
blob06aebeca02b545dcd45c3f492b7005c21441cf29
1 ;;;; allocation VOPs for the PPC
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.
12 (in-package "SB!VM")
14 ;;;; LIST and LIST*
15 (define-vop (list-or-list*)
16 (:args (things :more t))
17 (:temporary (:scs (descriptor-reg) :type list) ptr)
18 (:temporary (:scs (descriptor-reg)) temp)
19 (:temporary (:scs (descriptor-reg) :type list :to (:result 0) :target result)
20 res)
21 (:temporary (:sc non-descriptor-reg :offset nl3-offset) pa-flag)
22 (:temporary (:scs (non-descriptor-reg)) alloc-temp)
23 (:info num)
24 (:results (result :scs (descriptor-reg)))
25 (:variant-vars star)
26 (:policy :safe)
27 (:node-var node)
28 #!-gencgc (:ignore alloc-temp)
29 (:generator 0
30 (cond ((zerop num)
31 (move result null-tn))
32 ((and star (= num 1))
33 (move result (tn-ref-tn things)))
35 (macrolet
36 ((maybe-load (tn)
37 (once-only ((tn tn))
38 `(sc-case ,tn
39 ((any-reg descriptor-reg zero null)
40 ,tn)
41 (control-stack
42 (load-stack-tn temp ,tn)
43 temp)))))
44 (let* ((dx-p (node-stack-allocate-p node))
45 (cons-cells (if star (1- num) num))
46 (alloc (* (pad-data-block cons-size) cons-cells)))
47 (pseudo-atomic (pa-flag)
48 (if dx-p
49 (progn
50 (align-csp res)
51 (inst clrrwi res csp-tn n-lowtag-bits)
52 (inst ori res res list-pointer-lowtag)
53 (inst addi csp-tn csp-tn alloc))
54 (allocation res alloc list-pointer-lowtag :temp-tn alloc-temp
55 :flag-tn pa-flag))
56 (move ptr res)
57 (dotimes (i (1- cons-cells))
58 (storew (maybe-load (tn-ref-tn things)) ptr
59 cons-car-slot list-pointer-lowtag)
60 (setf things (tn-ref-across things))
61 (inst addi ptr ptr (pad-data-block cons-size))
62 (storew ptr ptr
63 (- cons-cdr-slot cons-size)
64 list-pointer-lowtag))
65 (storew (maybe-load (tn-ref-tn things)) ptr
66 cons-car-slot list-pointer-lowtag)
67 (storew (if star
68 (maybe-load (tn-ref-tn (tn-ref-across things)))
69 null-tn)
70 ptr cons-cdr-slot list-pointer-lowtag))
71 (move result res)))))))
73 (define-vop (list list-or-list*)
74 (:variant nil))
76 (define-vop (list* list-or-list*)
77 (:variant t))
80 ;;;; Special purpose inline allocators.
81 #!-gencgc
82 (define-vop (allocate-code-object)
83 (:args (boxed-arg :scs (any-reg))
84 (unboxed-arg :scs (any-reg)))
85 (:results (result :scs (descriptor-reg)))
86 (:temporary (:scs (non-descriptor-reg)) ndescr)
87 (:temporary (:scs (non-descriptor-reg)) size)
88 (:temporary (:scs (any-reg) :from (:argument 0)) boxed)
89 (:temporary (:scs (non-descriptor-reg)) unboxed)
90 (:temporary (:sc non-descriptor-reg :offset nl3-offset) pa-flag)
91 (:generator 100
92 (inst addi boxed boxed-arg (fixnumize (1+ code-constants-offset)))
93 (inst clrrwi boxed boxed n-lowtag-bits)
94 (inst srwi unboxed unboxed-arg word-shift)
95 (inst addi unboxed unboxed lowtag-mask)
96 (inst clrrwi unboxed unboxed n-lowtag-bits)
97 (pseudo-atomic (pa-flag)
98 ;; Note: we don't have to subtract off the 4 that was added by
99 ;; pseudo-atomic, because oring in other-pointer-lowtag just adds
100 ;; it right back.
101 (inst add size boxed unboxed)
102 (allocation result size other-pointer-lowtag :temp-tn ndescr :flag-tn pa-flag)
103 (inst slwi ndescr boxed (- n-widetag-bits word-shift))
104 (inst ori ndescr ndescr code-header-widetag)
105 (storew ndescr result 0 other-pointer-lowtag)
106 (storew unboxed-arg result code-code-size-slot other-pointer-lowtag)
107 (storew null-tn result code-debug-info-slot other-pointer-lowtag))))
109 (define-vop (make-fdefn)
110 (:args (name :scs (descriptor-reg) :to :eval))
111 (:temporary (:scs (non-descriptor-reg)) temp)
112 (:temporary (:sc non-descriptor-reg :offset nl3-offset) pa-flag)
113 (:results (result :scs (descriptor-reg) :from :argument))
114 (:policy :fast-safe)
115 (:translate make-fdefn)
116 (:generator 37
117 (with-fixed-allocation (result pa-flag temp fdefn-widetag fdefn-size)
118 (inst lr temp (make-fixup 'undefined-tramp :assembly-routine))
119 (storew name result fdefn-name-slot other-pointer-lowtag)
120 (storew null-tn result fdefn-fun-slot other-pointer-lowtag)
121 (storew temp result fdefn-raw-addr-slot other-pointer-lowtag))))
123 (define-vop (make-closure)
124 (:args (function :to :save :scs (descriptor-reg)))
125 (:info length stack-allocate-p)
126 (:temporary (:scs (non-descriptor-reg)) temp)
127 (:temporary (:sc non-descriptor-reg :offset nl3-offset) pa-flag)
128 (:results (result :scs (descriptor-reg)))
129 (:generator 10
130 (let* ((size (+ length closure-info-offset))
131 (alloc-size (pad-data-block size)))
132 (pseudo-atomic (pa-flag)
133 (if stack-allocate-p
134 (progn
135 (align-csp result)
136 (inst clrrwi. result csp-tn n-lowtag-bits)
137 (inst addi csp-tn csp-tn alloc-size)
138 (inst ori result result fun-pointer-lowtag)
139 (inst lr temp (logior (ash (1- size) n-widetag-bits) closure-header-widetag)))
140 (progn
141 (allocation result (pad-data-block size)
142 fun-pointer-lowtag :temp-tn temp :flag-tn pa-flag)
143 (inst lr temp (logior (ash (1- size) n-widetag-bits) closure-header-widetag))))
144 (storew temp result 0 fun-pointer-lowtag)
145 (storew function result closure-fun-slot fun-pointer-lowtag)))))
147 ;;; The compiler likes to be able to directly make value cells.
149 (define-vop (make-value-cell)
150 (:args (value :to :save :scs (descriptor-reg any-reg)))
151 (:temporary (:scs (non-descriptor-reg)) temp)
152 (:temporary (:sc non-descriptor-reg :offset nl3-offset) pa-flag)
153 (:info stack-allocate-p)
154 (:ignore stack-allocate-p)
155 (:results (result :scs (descriptor-reg)))
156 (:generator 10
157 (with-fixed-allocation (result pa-flag temp value-cell-widetag value-cell-size)
158 (storew value result value-cell-value-slot other-pointer-lowtag))))
162 ;;;; Automatic allocators for primitive objects.
164 (define-vop (make-unbound-marker)
165 (:args)
166 (:results (result :scs (descriptor-reg any-reg)))
167 (:generator 1
168 (inst li result unbound-marker-widetag)))
170 (define-vop (make-funcallable-instance-tramp)
171 (:args)
172 (:results (result :scs (any-reg)))
173 (:generator 1
174 (inst lr result (make-fixup 'funcallable-instance-tramp :assembly-routine))))
176 (define-vop (fixed-alloc)
177 (:args)
178 (:info name words type lowtag stack-allocate-p)
179 (:ignore name)
180 (:results (result :scs (descriptor-reg)))
181 (:temporary (:scs (non-descriptor-reg)) temp)
182 (:temporary (:sc non-descriptor-reg :offset nl3-offset) pa-flag)
183 (:generator 4
184 (with-fixed-allocation (result pa-flag temp type words
185 :lowtag lowtag
186 :stack-allocate-p stack-allocate-p)
189 (define-vop (var-alloc)
190 (:args (extra :scs (any-reg)))
191 (:arg-types positive-fixnum)
192 (:info name words type lowtag)
193 (:ignore name #!-gencgc temp)
194 (:results (result :scs (descriptor-reg)))
195 (:temporary (:scs (any-reg)) bytes)
196 (:temporary (:scs (non-descriptor-reg)) header)
197 (:temporary (:scs (non-descriptor-reg)) temp)
198 (:temporary (:sc non-descriptor-reg :offset nl3-offset) pa-flag)
199 (:generator 6
200 (inst addi bytes extra (* (1+ words) n-word-bytes))
201 (inst slwi header bytes (- n-widetag-bits n-fixnum-tag-bits))
202 (inst addi header header (+ (ash -2 n-widetag-bits) type))
203 (inst clrrwi bytes bytes n-lowtag-bits)
204 (pseudo-atomic (pa-flag)
205 (allocation result bytes lowtag :temp-tn temp :flag-tn pa-flag)
206 (storew header result 0 lowtag))))