Enforce consistency between DEFINE-COLD-FOP and DEFINE-FOP.
[sbcl.git] / src / compiler / generic / vm-fndb.lisp
blobf68408e5aec233a7bee6133d7a5f90290b444e00
1 ;;;; signatures of machine-specific functions
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!C")
14 ;;;; internal type predicates
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 #!+sb-unicode base-char-p
24 %standard-char-p %instancep
25 base-string-p simple-base-string-p
26 #!+sb-unicode character-string-p
27 #!+sb-unicode simple-character-string-p
28 array-header-p
29 sequencep extended-sequence-p
30 simple-array-p simple-array-nil-p vector-nil-p
31 simple-array-unsigned-byte-2-p
32 simple-array-unsigned-byte-4-p simple-array-unsigned-byte-7-p
33 simple-array-unsigned-byte-8-p simple-array-unsigned-byte-15-p
34 simple-array-unsigned-byte-16-p
36 simple-array-unsigned-fixnum-p
38 simple-array-unsigned-byte-31-p
39 simple-array-unsigned-byte-32-p
40 #!+#.(cl:if (cl:= 64 sb!vm:n-word-bits) '(and) '(or))
41 simple-array-unsigned-byte-63-p
42 #!+#.(cl:if (cl:= 64 sb!vm:n-word-bits) '(and) '(or))
43 simple-array-unsigned-byte-64-p
44 simple-array-signed-byte-8-p simple-array-signed-byte-16-p
46 simple-array-fixnum-p
48 simple-array-signed-byte-32-p
49 #!+#.(cl:if (cl:= 64 sb!vm:n-word-bits) '(and) '(or))
50 simple-array-signed-byte-64-p
51 simple-array-single-float-p simple-array-double-float-p
52 #!+long-float simple-array-long-float-p
53 simple-array-complex-single-float-p
54 simple-array-complex-double-float-p
55 #!+long-float simple-array-complex-long-float-p
56 simple-rank-1-array-*-p
57 system-area-pointer-p realp
58 ;; #!+#.(cl:if (cl:= 32 sb!vm:n-word-bits) '(and) '(or))
59 unsigned-byte-32-p
60 ;; #!+#.(cl:if (cl:= 32 sb!vm:n-word-bits) '(and) '(or))
61 signed-byte-32-p
62 #!+#.(cl:if (cl:= 64 sb!vm:n-word-bits) '(and) '(or))
63 unsigned-byte-64-p
64 #!+#.(cl:if (cl:= 64 sb!vm:n-word-bits) '(and) '(or))
65 signed-byte-64-p
66 weak-pointer-p code-component-p lra-p
67 simple-fun-p
68 closurep
69 funcallable-instance-p)
70 (t) boolean (movable foldable flushable))
72 (defknown #.(loop for (name) in *vector-without-complex-typecode-infos*
73 collect name)
74 (t) boolean (movable foldable flushable))
76 (defknown %other-pointer-p (t) boolean
77 (movable foldable flushable always-translatable))
79 ;; Return T if the first arg is an other-pointer and its widetag
80 ;; is in the collection specified by the second arg.
81 (defknown %other-pointer-subtype-p (t list) boolean
82 (movable foldable flushable always-translatable))
84 ;;;; miscellaneous "sub-primitives"
86 (defknown pointer-hash (t) hash (flushable))
88 (defknown %sp-string-compare
89 (simple-string index index simple-string index index)
90 (or index null)
91 (foldable flushable))
93 (defknown %sxhash-simple-string (simple-string) hash
94 (foldable flushable))
96 (defknown (%sxhash-simple-substring compute-symbol-hash)
97 (simple-string index) hash
98 (foldable flushable))
100 (defknown symbol-hash (symbol) hash
101 (flushable movable))
103 (defknown %set-symbol-hash (symbol hash)
104 t ())
106 (defknown symbol-info-vector (symbol) (or null simple-vector))
108 (defknown initialize-vector ((simple-array * (*)) &rest t)
109 (simple-array * (*))
110 (always-translatable flushable)
111 :result-arg 0)
113 (defknown vector-fill* (t t t t) vector
115 :result-arg 0)
117 (defknown vector-length (vector) index (flushable dx-safe))
119 (defknown vector-sap ((simple-unboxed-array (*))) system-area-pointer
120 (flushable))
122 (defknown lowtag-of (t) (unsigned-byte #.sb!vm:n-lowtag-bits)
123 (flushable movable))
124 (defknown widetag-of (t) (unsigned-byte #.sb!vm:n-widetag-bits)
125 (flushable movable))
127 (defknown (get-header-data get-closure-length) (t) (unsigned-byte 24)
128 (flushable))
129 (defknown set-header-data (t (unsigned-byte 24)) t
132 (defknown %array-dimension (t index) index
133 (flushable))
134 (defknown %set-array-dimension (t index index) index
136 (defknown %array-rank (t) index
137 (flushable))
139 (defknown %make-instance (index) instance
140 (flushable))
141 (defknown %make-structure-instance (defstruct-description list &rest t) instance
142 (flushable always-translatable))
143 (defknown %instance-layout (instance) layout
144 (foldable flushable))
145 (defknown %set-instance-layout (instance layout) layout
147 (defknown %instance-length (instance) index
148 (foldable flushable))
149 (defknown %instance-ref (instance index) t
150 (flushable always-translatable))
151 (defknown %instance-set (instance index t) t
152 (always-translatable))
153 (defknown %layout-invalid-error (t layout) nil)
155 (defknown %raw-instance-ref/word (instance index) sb!vm:word
156 (flushable always-translatable))
157 (defknown %raw-instance-set/word (instance index sb!vm:word) sb!vm:word
158 (always-translatable))
159 (defknown %raw-instance-ref/single (instance index) single-float
160 (flushable always-translatable))
161 (defknown %raw-instance-set/single (instance index single-float) single-float
162 (always-translatable))
163 (defknown %raw-instance-ref/double (instance index) double-float
164 (flushable always-translatable))
165 (defknown %raw-instance-set/double (instance index double-float) double-float
166 (always-translatable))
167 (defknown %raw-instance-ref/complex-single (instance index)
168 (complex single-float)
169 (flushable always-translatable))
170 (defknown %raw-instance-set/complex-single
171 (instance index (complex single-float))
172 (complex single-float)
173 (always-translatable))
174 (defknown %raw-instance-ref/complex-double (instance index)
175 (complex double-float)
176 (flushable always-translatable))
177 (defknown %raw-instance-set/complex-double
178 (instance index (complex double-float))
179 (complex double-float)
180 (always-translatable))
182 #!+(or x86 x86-64 ppc)
183 (defknown %raw-instance-atomic-incf/word (instance index sb!vm:word) sb!vm:word
184 (always-translatable))
185 #!+(or x86 x86-64 ppc)
186 (defknown %array-atomic-incf/word (t index sb!vm:word) sb!vm:word
187 (always-translatable))
189 ;;; These two are mostly used for bit-bashing operations.
190 (defknown %vector-raw-bits (t fixnum) sb!vm:word
191 (flushable))
192 (defknown (%set-vector-raw-bits) (t fixnum sb!vm:word) sb!vm:word
196 (defknown allocate-vector ((unsigned-byte 8) index
197 ;; The number of words is later converted
198 ;; to bytes, make sure it fits.
199 (and index
200 (mod #.(- (expt 2
201 (- sb!vm:n-word-bits
202 sb!vm:word-shift
203 ;; all the allocation routines expect a signed word
205 ;; The size is double-word aligned, which is done by adding
206 ;; (1- (/ sb-vm:n-word-bits 2)) and then masking.
207 ;; Make sure addition doesn't overflow.
208 3))))
209 (simple-array * (*))
210 (flushable movable))
212 (defknown make-array-header ((unsigned-byte 8) (unsigned-byte 24)) array
213 (flushable movable))
216 (defknown make-weak-pointer (t) weak-pointer
217 (flushable))
219 (defknown %make-complex (real real) complex
220 (flushable movable))
221 (defknown %make-ratio (rational rational) ratio
222 (flushable movable))
223 (defknown make-value-cell (t) t
224 (flushable movable))
226 #!+sb-simd-pack
227 (progn
228 (defknown simd-pack-p (t) boolean (foldable movable flushable))
229 (defknown %simd-pack-tag (simd-pack) fixnum (movable flushable))
230 (defknown %make-simd-pack (fixnum (unsigned-byte 64) (unsigned-byte 64))
231 simd-pack
232 (flushable movable foldable))
233 (defknown %make-simd-pack-double (double-float double-float)
234 (simd-pack double-float)
235 (flushable movable foldable))
236 (defknown %make-simd-pack-single (single-float single-float
237 single-float single-float)
238 (simd-pack single-float)
239 (flushable movable foldable))
240 (defknown %make-simd-pack-ub32 ((unsigned-byte 32) (unsigned-byte 32)
241 (unsigned-byte 32) (unsigned-byte 32))
242 (simd-pack integer)
243 (flushable movable foldable))
244 (defknown %make-simd-pack-ub64 ((unsigned-byte 64) (unsigned-byte 64))
245 (simd-pack integer)
246 (flushable movable foldable))
247 (defknown (%simd-pack-low %simd-pack-high) (simd-pack)
248 (unsigned-byte 64)
249 (flushable movable foldable))
250 (defknown %simd-pack-ub32s (simd-pack)
251 (values (unsigned-byte 32) (unsigned-byte 32)
252 (unsigned-byte 32) (unsigned-byte 32))
253 (flushable movable foldable))
254 (defknown %simd-pack-ub64s (simd-pack)
255 (values (unsigned-byte 64) (unsigned-byte 64))
256 (flushable movable foldable))
257 (defknown %simd-pack-singles (simd-pack)
258 (values single-float single-float single-float single-float)
259 (flushable movable foldable))
260 (defknown %simd-pack-doubles (simd-pack)
261 (values double-float double-float)
262 (flushable movable foldable)))
264 ;;;; threading
266 (defknown (dynamic-space-free-pointer binding-stack-pointer-sap
267 control-stack-pointer-sap) ()
268 system-area-pointer
269 (flushable))
271 (defknown ensure-symbol-tls-index (symbol) fixnum)
274 ;;;; debugger support
276 (defknown current-sp () system-area-pointer (movable flushable))
277 (defknown current-fp () system-area-pointer (movable flushable))
278 (defknown stack-ref (system-area-pointer index) t (flushable))
279 (defknown %set-stack-ref (system-area-pointer index t) t ())
280 (defknown lra-code-header (t) t (movable flushable))
281 (defknown fun-code-header (t) t (movable flushable))
282 (defknown %make-lisp-obj (sb!vm:word) t (movable flushable))
283 (defknown get-lisp-obj-address (t) sb!vm:word (movable flushable))
284 (defknown fun-word-offset (function) index (movable flushable))
286 ;;;; 32-bit logical operations
288 (defknown word-logical-not (sb!vm:word) sb!vm:word
289 (foldable flushable movable))
291 (defknown (word-logical-and word-logical-nand
292 word-logical-or word-logical-nor
293 word-logical-xor word-logical-eqv
294 word-logical-andc1 word-logical-andc2
295 word-logical-orc1 word-logical-orc2)
296 (sb!vm:word sb!vm:word) sb!vm:word
297 (foldable flushable movable))
299 (defknown (shift-towards-start shift-towards-end) (sb!vm:word fixnum)
300 sb!vm:word
301 (foldable flushable movable))
303 ;;;; bignum operations
305 (defknown %allocate-bignum (bignum-length) bignum-type
306 (flushable))
308 (defknown %bignum-length (bignum-type) bignum-length
309 (foldable flushable movable))
311 (defknown %bignum-set-length (bignum-type bignum-length) bignum-type
314 (defknown %bignum-ref (bignum-type bignum-index) bignum-element-type
315 (flushable))
316 #!+(or x86 x86-64)
317 (defknown %bignum-ref-with-offset (bignum-type fixnum (signed-byte 24))
318 bignum-element-type (flushable always-translatable))
320 (defknown %bignum-set (bignum-type bignum-index bignum-element-type)
321 bignum-element-type
324 (defknown %digit-0-or-plusp (bignum-element-type) boolean
325 (foldable flushable movable))
327 (defknown (%add-with-carry %subtract-with-borrow)
328 (bignum-element-type bignum-element-type (mod 2))
329 (values bignum-element-type (mod 2))
330 (foldable flushable movable))
332 (defknown %multiply-and-add
333 (bignum-element-type bignum-element-type bignum-element-type
334 &optional bignum-element-type)
335 (values bignum-element-type bignum-element-type)
336 (foldable flushable movable))
338 (defknown %multiply (bignum-element-type bignum-element-type)
339 (values bignum-element-type bignum-element-type)
340 (foldable flushable movable))
342 (defknown %lognot (bignum-element-type) bignum-element-type
343 (foldable flushable movable))
345 (defknown (%logand %logior %logxor) (bignum-element-type bignum-element-type)
346 bignum-element-type
347 (foldable flushable movable))
349 (defknown %fixnum-to-digit (fixnum) bignum-element-type
350 (foldable flushable movable))
352 (defknown %bigfloor (bignum-element-type bignum-element-type bignum-element-type)
353 (values bignum-element-type bignum-element-type)
354 (foldable flushable movable))
356 (defknown %fixnum-digit-with-correct-sign (bignum-element-type)
357 (signed-byte #.sb!vm:n-word-bits)
358 (foldable flushable movable))
360 (defknown (%ashl %ashr %digit-logical-shift-right)
361 (bignum-element-type (mod #.sb!vm:n-word-bits)) bignum-element-type
362 (foldable flushable movable))
364 ;;;; bit-bashing routines
366 ;;; FIXME: there's some ugly duplication between the (INTERN (FORMAT ...))
367 ;;; magic here and the same magic in src/code/bit-bash.lisp. I don't know
368 ;;; of any good way to clean it up, but it's definitely violating OAOO.
369 (macrolet ((define-known-copiers ()
370 `(progn
371 ,@(loop for i = 1 then (* i 2)
372 collect `(defknown ,(intern (format nil "UB~D-BASH-COPY" i)
373 (find-package "SB!KERNEL"))
374 ((simple-unboxed-array (*)) index (simple-unboxed-array (*)) index index)
375 (values)
377 collect `(defknown ,(intern (format nil "SYSTEM-AREA-UB~D-COPY" i)
378 (find-package "SB!KERNEL"))
379 (system-area-pointer index system-area-pointer index index)
380 (values)
382 collect `(defknown ,(intern (format nil "COPY-UB~D-TO-SYSTEM-AREA" i)
383 (find-package "SB!KERNEL"))
384 ((simple-unboxed-array (*)) index system-area-pointer index index)
385 (values)
387 collect `(defknown ,(intern (format nil "COPY-UB~D-FROM-SYSTEM-AREA" i)
388 (find-package "SB!KERNEL"))
389 (system-area-pointer index (simple-unboxed-array (*)) index index)
390 (values)
392 until (= i sb!vm:n-word-bits)))))
393 (define-known-copiers))
395 ;;; (not really a bit-bashing routine, but starting to take over from
396 ;;; bit-bashing routines in byte-sized copies as of sbcl-0.6.12.29:)
397 (defknown %byte-blt
398 ((or (simple-unboxed-array (*)) system-area-pointer) index
399 (or (simple-unboxed-array (*)) system-area-pointer) index index)
400 (values)
403 ;;;; code/function/fdefn object manipulation routines
405 (defknown code-instructions (t) system-area-pointer (flushable movable))
406 (defknown code-header-ref (t index) t (flushable))
407 (defknown code-header-set (t index t) t ())
409 (defknown fun-subtype (function) (unsigned-byte #.sb!vm:n-widetag-bits)
410 (flushable))
411 (defknown ((setf fun-subtype))
412 ((unsigned-byte #.sb!vm:n-widetag-bits) function)
413 (unsigned-byte #.sb!vm:n-widetag-bits)
416 (defknown make-fdefn (t) fdefn (flushable movable))
417 (defknown fdefn-p (t) boolean (movable foldable flushable))
418 (defknown fdefn-name (fdefn) t (foldable flushable))
419 (defknown fdefn-fun (fdefn) (or function null) (flushable))
420 (defknown (setf fdefn-fun) (function fdefn) t ())
421 (defknown fdefn-makunbound (fdefn) t ())
423 (defknown %simple-fun-self (function) function
424 (flushable))
425 (defknown (setf %simple-fun-self) (function function) function
428 (defknown %closure-fun (function) function
429 (flushable))
431 (defknown %closure-index-ref (function index) t
432 (flushable))
434 (defknown %make-funcallable-instance (index) function
437 (defknown %funcallable-instance-info (function index) t (flushable))
438 (defknown %set-funcallable-instance-info (function index t) t ())
441 (defknown %data-vector-and-index (array index)
442 (values (simple-array * (*)) index)
443 (foldable flushable))