0.8.13.47:
[sbcl.git] / src / compiler / generic / vm-fndb.lisp
1 ;;;; signatures of machine-specific functions
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!C")
13 \f
14 ;;;; internal type predicates
15
16 ;;; Simple TYPEP uses that don't have any standard predicate are
17 ;;; translated into non-standard unary predicates.
18 (defknown (fixnump bignump ratiop
19            short-float-p single-float-p double-float-p long-float-p
20            complex-rational-p complex-float-p complex-single-float-p
21            complex-double-float-p #!+long-float complex-long-float-p
22            complex-vector-p
23            base-char-p %standard-char-p %instancep
24            base-string-p simple-base-string-p
25            array-header-p
26            simple-array-p simple-array-nil-p vector-nil-p
27            simple-array-unsigned-byte-2-p
28            simple-array-unsigned-byte-4-p simple-array-unsigned-byte-7-p
29            simple-array-unsigned-byte-8-p simple-array-unsigned-byte-15-p
30            simple-array-unsigned-byte-16-p
31            #!+#.(cl:if (cl:= 32 sb!vm:n-word-bits) '(and) '(or))
32            simple-array-unsigned-byte-29-p
33            simple-array-unsigned-byte-31-p
34            simple-array-unsigned-byte-32-p
35            #!+#.(cl:if (cl:= 64 sb!vm:n-word-bits) '(and) '(or))
36            simple-array-unsigned-byte-60-p
37            #!+#.(cl:if (cl:= 64 sb!vm:n-word-bits) '(and) '(or))
38            simple-array-unsigned-byte-63-p
39            #!+#.(cl:if (cl:= 64 sb!vm:n-word-bits) '(and) '(or))
40            simple-array-unsigned-byte-64-p
41            simple-array-signed-byte-8-p simple-array-signed-byte-16-p
42            #!+#.(cl:if (cl:= 32 sb!vm:n-word-bits) '(and) '(or))
43            simple-array-signed-byte-30-p
44            simple-array-signed-byte-32-p
45            #!+#.(cl:if (cl:= 64 sb!vm:n-word-bits) '(and) '(or))
46            simple-array-signed-byte-61-p
47            #!+#.(cl:if (cl:= 64 sb!vm:n-word-bits) '(and) '(or))
48            simple-array-signed-byte-64-p
49            simple-array-single-float-p simple-array-double-float-p
50            #!+long-float simple-array-long-float-p
51            simple-array-complex-single-float-p
52            simple-array-complex-double-float-p
53            #!+long-float simple-array-complex-long-float-p
54            system-area-pointer-p realp unsigned-byte-32-p signed-byte-32-p
55            vector-t-p weak-pointer-p code-component-p lra-p
56            funcallable-instance-p)
57   (t) boolean (movable foldable flushable))
58 \f
59 ;;;; miscellaneous "sub-primitives"
60
61 (defknown %sp-string-compare
62   (simple-string index index simple-string index index)
63   (or index null)
64   (foldable flushable))
65
66 (defknown %sxhash-simple-string (simple-string) index
67   (foldable flushable))
68
69 (defknown %sxhash-simple-substring (simple-string index) index
70   (foldable flushable))
71
72 (defknown symbol-hash (symbol) (integer 0 #.sb!xc:most-positive-fixnum)
73   (flushable movable))
74
75 (defknown %set-symbol-hash (symbol (integer 0 #.sb!xc:most-positive-fixnum))
76   t (unsafe))
77
78 (defknown vector-length (vector) index (flushable))
79
80 (defknown vector-sap ((simple-unboxed-array (*))) system-area-pointer
81   (flushable))
82
83 (defknown lowtag-of (t) (unsigned-byte #.sb!vm:n-lowtag-bits)
84   (flushable movable))
85 (defknown widetag-of (t) (unsigned-byte #.sb!vm:n-widetag-bits)
86   (flushable movable))
87
88 (defknown (get-header-data get-closure-length) (t) (unsigned-byte 24)
89   (flushable))
90 (defknown set-header-data (t (unsigned-byte 24)) t
91   (unsafe))
92
93 (defknown %array-dimension (t index) index
94   (flushable))
95 (defknown %set-array-dimension (t index index) index
96   ())
97 (defknown %array-rank (t) index
98   (flushable))
99
100 (defknown %make-instance (index) instance
101   (unsafe))
102 (defknown %instance-layout (instance) layout
103   (foldable flushable))
104 (defknown %set-instance-layout (instance layout) layout
105   (unsafe))
106 (defknown %instance-length (instance) index
107   (foldable flushable))
108 (defknown %instance-ref (instance index) t
109   (flushable))
110 (defknown %instance-set (instance index t) t
111   (unsafe))
112 (defknown %layout-invalid-error (t layout) nil)
113
114
115 (sb!xc:deftype raw-vector () '(simple-array sb!vm:word (*)))
116
117 (defknown %raw-ref-single (raw-vector index) single-float
118   (foldable flushable))
119 (defknown %raw-ref-double (raw-vector index) double-float
120   (foldable flushable))
121 #!+long-float
122 (defknown %raw-ref-long (raw-vector index) long-float
123   (foldable flushable))
124 (defknown %raw-set-single (raw-vector index single-float) single-float
125   (unsafe))
126 (defknown %raw-set-double (raw-vector index double-float) double-float
127   (unsafe))
128 #!+long-float
129 (defknown %raw-set-long (raw-vector index long-float) long-float
130   (unsafe))
131
132 (defknown %raw-ref-complex-single (raw-vector index) (complex single-float)
133   (foldable flushable))
134 (defknown %raw-ref-complex-double (raw-vector index) (complex double-float)
135   (foldable flushable))
136
137 (defknown %raw-set-complex-single (raw-vector index (complex single-float))
138   (complex single-float)
139   (unsafe))
140 (defknown %raw-set-complex-double (raw-vector index (complex double-float))
141   (complex double-float)
142   (unsafe))
143
144
145 (defknown %raw-bits (t fixnum) sb!vm:word
146   (foldable flushable))
147 (defknown (%set-raw-bits) (t fixnum sb!vm:word) sb!vm:word
148   (unsafe))
149
150
151 (defknown allocate-vector ((unsigned-byte 8) index index) (simple-array * (*))
152   (flushable movable))
153
154 (defknown make-array-header ((unsigned-byte 8) (unsigned-byte 24)) array
155   (flushable movable))
156
157
158 (defknown make-weak-pointer (t) weak-pointer
159   (flushable))
160
161 (defknown %make-complex (real real) complex
162   (flushable movable))
163 (defknown %make-ratio (rational rational) ratio
164   (flushable movable))
165 (defknown make-value-cell (t) t
166   (flushable movable))
167
168 (defknown (dynamic-space-free-pointer binding-stack-pointer-sap
169                                       control-stack-pointer-sap)  ()
170   system-area-pointer
171   (flushable))
172 \f
173 ;;;; debugger support
174
175 (defknown current-sp () system-area-pointer (movable flushable))
176 (defknown current-fp () system-area-pointer (movable flushable))
177 (defknown stack-ref (system-area-pointer index) t (flushable))
178 (defknown %set-stack-ref (system-area-pointer index t) t (unsafe))
179 (defknown lra-code-header (t) t (movable flushable))
180 (defknown fun-code-header (t) t (movable flushable))
181 (defknown make-lisp-obj (sb!vm:word) t (movable flushable))
182 (defknown get-lisp-obj-address (t) sb!vm:word (movable flushable))
183 (defknown fun-word-offset (function) index (movable flushable))
184 \f
185 ;;;; 32-bit logical operations
186
187 (defknown merge-bits ((unsigned-byte 5) sb!vm:word sb!vm:word)
188   sb!vm:word
189   (foldable flushable movable))
190
191 (defknown word-logical-not (sb!vm:word) sb!vm:word
192   (foldable flushable movable))
193
194 (defknown (word-logical-and word-logical-nand
195            word-logical-or word-logical-nor
196            word-logical-xor word-logical-eqv
197            word-logical-andc1 word-logical-andc2
198            word-logical-orc1 word-logical-orc2)
199           (sb!vm:word sb!vm:word) sb!vm:word
200   (foldable flushable movable))
201
202 (defknown (shift-towards-start shift-towards-end) (sb!vm:word fixnum)
203   sb!vm:word
204   (foldable flushable movable))
205 \f
206 ;;;; bignum operations
207
208 (defknown %allocate-bignum (bignum-index) bignum-type
209   (flushable))
210
211 (defknown %bignum-length (bignum-type) bignum-index
212   (foldable flushable movable))
213
214 (defknown %bignum-set-length (bignum-type bignum-index) bignum-type
215   (unsafe))
216
217 (defknown %bignum-ref (bignum-type bignum-index) bignum-element-type
218   (flushable))
219
220 (defknown %bignum-set (bignum-type bignum-index bignum-element-type)
221   bignum-element-type
222   (unsafe))
223
224 (defknown %digit-0-or-plusp (bignum-element-type) boolean
225   (foldable flushable movable))
226
227 (defknown (%add-with-carry %subtract-with-borrow)
228           (bignum-element-type bignum-element-type (mod 2))
229   (values bignum-element-type (mod 2))
230   (foldable flushable movable))
231
232 (defknown %multiply-and-add
233           (bignum-element-type bignum-element-type bignum-element-type
234                                &optional bignum-element-type)
235   (values bignum-element-type bignum-element-type)
236   (foldable flushable movable))
237
238 (defknown %multiply (bignum-element-type bignum-element-type)
239   (values bignum-element-type bignum-element-type)
240   (foldable flushable movable))
241
242 (defknown %lognot (bignum-element-type) bignum-element-type
243   (foldable flushable movable))
244
245 (defknown (%logand %logior %logxor) (bignum-element-type bignum-element-type)
246   bignum-element-type
247   (foldable flushable movable))
248
249 (defknown %fixnum-to-digit (fixnum) bignum-element-type
250   (foldable flushable movable))
251
252 (defknown %floor (bignum-element-type bignum-element-type bignum-element-type)
253   (values bignum-element-type bignum-element-type)
254   (foldable flushable movable))
255
256 (defknown %fixnum-digit-with-correct-sign (bignum-element-type)
257   (signed-byte #.sb!vm:n-word-bits)
258   (foldable flushable movable))
259
260 (defknown (%ashl %ashr %digit-logical-shift-right)
261           (bignum-element-type (mod 32)) bignum-element-type
262   (foldable flushable movable))
263 \f
264 ;;;; bit-bashing routines
265
266 (defknown copy-to-system-area
267           ((simple-unboxed-array (*)) index system-area-pointer index index)
268   (values)
269   ())
270
271 (defknown copy-from-system-area
272           (system-area-pointer index (simple-unboxed-array (*)) index index)
273   (values)
274   ())
275
276 (defknown system-area-copy
277           (system-area-pointer index system-area-pointer index index)
278   (values)
279   ())
280
281 (defknown bit-bash-copy
282           ((simple-unboxed-array (*)) index
283            (simple-unboxed-array (*)) index index)
284   (values)
285   ())
286
287 ;;; (not really a bit-bashing routine, but starting to take over from
288 ;;; bit-bashing routines in byte-sized copies as of sbcl-0.6.12.29:)
289 (defknown %byte-blt
290   ((or (simple-unboxed-array (*)) system-area-pointer) index
291    (or (simple-unboxed-array (*)) system-area-pointer) index index)
292   (values)
293   ())
294 \f
295 ;;;; code/function/fdefn object manipulation routines
296
297 (defknown code-instructions (t) system-area-pointer (flushable movable))
298 (defknown code-header-ref (t index) t (flushable))
299 (defknown code-header-set (t index t) t ())
300
301 (defknown fun-subtype (function) (unsigned-byte #.sb!vm:n-widetag-bits)
302   (flushable))
303 (defknown ((setf fun-subtype))
304           ((unsigned-byte #.sb!vm:n-widetag-bits) function)
305   (unsigned-byte #.sb!vm:n-widetag-bits)
306   ())
307
308 (defknown make-fdefn (t) fdefn (flushable movable))
309 (defknown fdefn-p (t) boolean (movable foldable flushable))
310 (defknown fdefn-name (fdefn) t (foldable flushable))
311 (defknown fdefn-fun (fdefn) (or function null) (flushable))
312 (defknown (setf fdefn-fun) (function fdefn) t (unsafe))
313 (defknown fdefn-makunbound (fdefn) t ())
314
315 (defknown %simple-fun-self (function) function
316   (flushable))
317 (defknown (setf %simple-fun-self) (function function) function
318   (unsafe))
319
320 (defknown %closure-fun (function) function
321   (flushable))
322
323 (defknown %closure-index-ref (function index) t
324   (flushable))
325
326 (defknown %make-funcallable-instance (index layout) function
327   (unsafe))
328
329 (defknown %funcallable-instance-info (function index) t (flushable))
330 (defknown %set-funcallable-instance-info (function index t) t (unsafe))
331 \f
332 ;;;; mutator accessors
333
334 (defknown mutator-self () system-area-pointer (flushable movable))
335
336 (defknown %data-vector-and-index (array index)
337                                  (values (simple-array * (*)) index)
338                                  (foldable flushable))