1 ;;;; signatures of machine-specific functions
3 ;;;; This software is part of the SBCL system. See the README file for
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.
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
23 base-char-p %standard-char-p %instancep
24 base-string-p simple-base-string-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))
59 ;;;; miscellaneous "sub-primitives"
61 (defknown %sp-string-compare
62 (simple-string index index simple-string index index)
66 (defknown %sxhash-simple-string (simple-string) index
69 (defknown %sxhash-simple-substring (simple-string index) index
72 (defknown symbol-hash (symbol) (integer 0 #.sb!xc:most-positive-fixnum)
75 (defknown %set-symbol-hash (symbol (integer 0 #.sb!xc:most-positive-fixnum))
78 (defknown vector-length (vector) index (flushable))
80 (defknown vector-sap ((simple-unboxed-array (*))) system-area-pointer
83 (defknown lowtag-of (t) (unsigned-byte #.sb!vm:n-lowtag-bits)
85 (defknown widetag-of (t) (unsigned-byte #.sb!vm:n-widetag-bits)
88 (defknown (get-header-data get-closure-length) (t) (unsigned-byte 24)
90 (defknown set-header-data (t (unsigned-byte 24)) t
93 (defknown %array-dimension (t index) index
95 (defknown %set-array-dimension (t index index) index
97 (defknown %array-rank (t) index
100 (defknown %make-instance (index) instance
102 (defknown %instance-layout (instance) layout
103 (foldable flushable))
104 (defknown %set-instance-layout (instance layout) layout
106 (defknown %instance-length (instance) index
107 (foldable flushable))
108 (defknown %instance-ref (instance index) t
110 (defknown %instance-set (instance index t) t
112 (defknown %layout-invalid-error (t layout) nil)
115 (sb!xc:deftype raw-vector () '(simple-array sb!vm:word (*)))
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))
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
126 (defknown %raw-set-double (raw-vector index double-float) double-float
129 (defknown %raw-set-long (raw-vector index long-float) long-float
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))
137 (defknown %raw-set-complex-single (raw-vector index (complex single-float))
138 (complex single-float)
140 (defknown %raw-set-complex-double (raw-vector index (complex double-float))
141 (complex double-float)
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
151 (defknown allocate-vector ((unsigned-byte 8) index index) (simple-array * (*))
154 (defknown make-array-header ((unsigned-byte 8) (unsigned-byte 24)) array
158 (defknown make-weak-pointer (t) weak-pointer
161 (defknown %make-complex (real real) complex
163 (defknown %make-ratio (rational rational) ratio
165 (defknown make-value-cell (t) t
168 (defknown (dynamic-space-free-pointer binding-stack-pointer-sap
169 control-stack-pointer-sap) ()
173 ;;;; debugger support
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))
185 ;;;; 32-bit logical operations
187 (defknown merge-bits ((unsigned-byte 5) sb!vm:word sb!vm:word)
189 (foldable flushable movable))
191 (defknown word-logical-not (sb!vm:word) sb!vm:word
192 (foldable flushable movable))
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))
202 (defknown (shift-towards-start shift-towards-end) (sb!vm:word fixnum)
204 (foldable flushable movable))
206 ;;;; bignum operations
208 (defknown %allocate-bignum (bignum-index) bignum-type
211 (defknown %bignum-length (bignum-type) bignum-index
212 (foldable flushable movable))
214 (defknown %bignum-set-length (bignum-type bignum-index) bignum-type
217 (defknown %bignum-ref (bignum-type bignum-index) bignum-element-type
220 (defknown %bignum-set (bignum-type bignum-index bignum-element-type)
224 (defknown %digit-0-or-plusp (bignum-element-type) boolean
225 (foldable flushable movable))
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))
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))
238 (defknown %multiply (bignum-element-type bignum-element-type)
239 (values bignum-element-type bignum-element-type)
240 (foldable flushable movable))
242 (defknown %lognot (bignum-element-type) bignum-element-type
243 (foldable flushable movable))
245 (defknown (%logand %logior %logxor) (bignum-element-type bignum-element-type)
247 (foldable flushable movable))
249 (defknown %fixnum-to-digit (fixnum) bignum-element-type
250 (foldable flushable movable))
252 (defknown %floor (bignum-element-type bignum-element-type bignum-element-type)
253 (values bignum-element-type bignum-element-type)
254 (foldable flushable movable))
256 (defknown %fixnum-digit-with-correct-sign (bignum-element-type)
257 (signed-byte #.sb!vm:n-word-bits)
258 (foldable flushable movable))
260 (defknown (%ashl %ashr %digit-logical-shift-right)
261 (bignum-element-type (mod 32)) bignum-element-type
262 (foldable flushable movable))
264 ;;;; bit-bashing routines
266 (defknown copy-to-system-area
267 ((simple-unboxed-array (*)) index system-area-pointer index index)
271 (defknown copy-from-system-area
272 (system-area-pointer index (simple-unboxed-array (*)) index index)
276 (defknown system-area-copy
277 (system-area-pointer index system-area-pointer index index)
281 (defknown bit-bash-copy
282 ((simple-unboxed-array (*)) index
283 (simple-unboxed-array (*)) index index)
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:)
290 ((or (simple-unboxed-array (*)) system-area-pointer) index
291 (or (simple-unboxed-array (*)) system-area-pointer) index index)
295 ;;;; code/function/fdefn object manipulation routines
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 ())
301 (defknown fun-subtype (function) (unsigned-byte #.sb!vm:n-widetag-bits)
303 (defknown ((setf fun-subtype))
304 ((unsigned-byte #.sb!vm:n-widetag-bits) function)
305 (unsigned-byte #.sb!vm:n-widetag-bits)
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 ())
315 (defknown %simple-fun-self (function) function
317 (defknown (setf %simple-fun-self) (function function) function
320 (defknown %closure-fun (function) function
323 (defknown %closure-index-ref (function index) t
326 (defknown %make-funcallable-instance (index layout) function
329 (defknown %funcallable-instance-info (function index) t (flushable))
330 (defknown %set-funcallable-instance-info (function index t) t (unsafe))
332 ;;;; mutator accessors
334 (defknown mutator-self () system-area-pointer (flushable movable))
336 (defknown %data-vector-and-index (array index)
337 (values (simple-array * (*)) index)
338 (foldable flushable))