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
55 #!+#.(cl:if (cl:= 32 sb!vm:n-word-bits) '(and) '(or))
57 #!+#.(cl:if (cl:= 32 sb!vm:n-word-bits) '(and) '(or))
59 #!+#.(cl:if (cl:= 64 sb!vm:n-word-bits) '(and) '(or))
61 #!+#.(cl:if (cl:= 64 sb!vm:n-word-bits) '(and) '(or))
63 vector-t-p weak-pointer-p code-component-p lra-p
64 funcallable-instance-p)
65 (t) boolean (movable foldable flushable))
67 ;;;; miscellaneous "sub-primitives"
69 (defknown %sp-string-compare
70 (simple-string index index simple-string index index)
74 (defknown %sxhash-simple-string (simple-string) index
77 (defknown %sxhash-simple-substring (simple-string index) index
80 (defknown symbol-hash (symbol) (integer 0 #.sb!xc:most-positive-fixnum)
83 (defknown %set-symbol-hash (symbol (integer 0 #.sb!xc:most-positive-fixnum))
86 (defknown vector-length (vector) index (flushable))
88 (defknown vector-sap ((simple-unboxed-array (*))) system-area-pointer
91 (defknown lowtag-of (t) (unsigned-byte #.sb!vm:n-lowtag-bits)
93 (defknown widetag-of (t) (unsigned-byte #.sb!vm:n-widetag-bits)
96 (defknown (get-header-data get-closure-length) (t) (unsigned-byte 24)
98 (defknown set-header-data (t (unsigned-byte 24)) t
101 (defknown %array-dimension (t index) index
103 (defknown %set-array-dimension (t index index) index
105 (defknown %array-rank (t) index
108 (defknown %make-instance (index) instance
110 (defknown %instance-layout (instance) layout
111 (foldable flushable))
112 (defknown %set-instance-layout (instance layout) layout
114 (defknown %instance-length (instance) index
115 (foldable flushable))
116 (defknown %instance-ref (instance index) t
118 (defknown %instance-set (instance index t) t
120 (defknown %layout-invalid-error (t layout) nil)
123 (sb!xc:deftype raw-vector () '(simple-array sb!vm:word (*)))
125 ;;; %RAW-{REF,SET}-FOO VOPs should be declared as taking a RAW-VECTOR
126 ;;; as their first argument (clarity and to match these DEFKNOWNs).
127 ;;; We declare RAW-VECTOR as a primitive type so the VOP machinery
128 ;;; will accept our VOPs as legitimate. --njf, 2004-08-10
129 (sb!vm::!def-primitive-type-alias raw-vector
130 #!+#.(cl:if (cl:= 32 sb!vm:n-word-bits) '(and) '(or))
131 sb!vm::simple-array-unsigned-byte-32
132 #!+#.(cl:if (cl:= 64 sb!vm:n-word-bits) '(and) '(or))
133 sb!vm::simple-array-unsigned-byte-64)
135 (defknown %raw-ref-single (raw-vector index) single-float
136 (foldable flushable))
137 (defknown %raw-ref-double (raw-vector index) double-float
138 (foldable flushable))
140 (defknown %raw-ref-long (raw-vector index) long-float
141 (foldable flushable))
142 (defknown %raw-set-single (raw-vector index single-float) single-float
144 (defknown %raw-set-double (raw-vector index double-float) double-float
147 (defknown %raw-set-long (raw-vector index long-float) long-float
150 (defknown %raw-ref-complex-single (raw-vector index) (complex single-float)
151 (foldable flushable))
152 (defknown %raw-ref-complex-double (raw-vector index) (complex double-float)
153 (foldable flushable))
155 (defknown %raw-set-complex-single (raw-vector index (complex single-float))
156 (complex single-float)
158 (defknown %raw-set-complex-double (raw-vector index (complex double-float))
159 (complex double-float)
163 (defknown %raw-bits (t fixnum) sb!vm:word
164 (foldable flushable))
165 (defknown (%set-raw-bits) (t fixnum sb!vm:word) sb!vm:word
169 (defknown allocate-vector ((unsigned-byte 8) index index) (simple-array * (*))
172 (defknown make-array-header ((unsigned-byte 8) (unsigned-byte 24)) array
176 (defknown make-weak-pointer (t) weak-pointer
179 (defknown %make-complex (real real) complex
181 (defknown %make-ratio (rational rational) ratio
183 (defknown make-value-cell (t) t
186 (defknown (dynamic-space-free-pointer binding-stack-pointer-sap
187 control-stack-pointer-sap) ()
191 ;;;; debugger support
193 (defknown current-sp () system-area-pointer (movable flushable))
194 (defknown current-fp () system-area-pointer (movable flushable))
195 (defknown stack-ref (system-area-pointer index) t (flushable))
196 (defknown %set-stack-ref (system-area-pointer index t) t (unsafe))
197 (defknown lra-code-header (t) t (movable flushable))
198 (defknown fun-code-header (t) t (movable flushable))
199 (defknown make-lisp-obj (sb!vm:word) t (movable flushable))
200 (defknown get-lisp-obj-address (t) sb!vm:word (movable flushable))
201 (defknown fun-word-offset (function) index (movable flushable))
203 ;;;; 32-bit logical operations
205 (defknown merge-bits ((unsigned-byte 5) sb!vm:word sb!vm:word)
207 (foldable flushable movable))
209 (defknown word-logical-not (sb!vm:word) sb!vm:word
210 (foldable flushable movable))
212 (defknown (word-logical-and word-logical-nand
213 word-logical-or word-logical-nor
214 word-logical-xor word-logical-eqv
215 word-logical-andc1 word-logical-andc2
216 word-logical-orc1 word-logical-orc2)
217 (sb!vm:word sb!vm:word) sb!vm:word
218 (foldable flushable movable))
220 (defknown (shift-towards-start shift-towards-end) (sb!vm:word fixnum)
222 (foldable flushable movable))
224 ;;;; bignum operations
226 (defknown %allocate-bignum (bignum-index) bignum-type
229 (defknown %bignum-length (bignum-type) bignum-index
230 (foldable flushable movable))
232 (defknown %bignum-set-length (bignum-type bignum-index) bignum-type
235 (defknown %bignum-ref (bignum-type bignum-index) bignum-element-type
238 (defknown %bignum-set (bignum-type bignum-index bignum-element-type)
242 (defknown %digit-0-or-plusp (bignum-element-type) boolean
243 (foldable flushable movable))
245 (defknown (%add-with-carry %subtract-with-borrow)
246 (bignum-element-type bignum-element-type (mod 2))
247 (values bignum-element-type (mod 2))
248 (foldable flushable movable))
250 (defknown %multiply-and-add
251 (bignum-element-type bignum-element-type bignum-element-type
252 &optional bignum-element-type)
253 (values bignum-element-type bignum-element-type)
254 (foldable flushable movable))
256 (defknown %multiply (bignum-element-type bignum-element-type)
257 (values bignum-element-type bignum-element-type)
258 (foldable flushable movable))
260 (defknown %lognot (bignum-element-type) bignum-element-type
261 (foldable flushable movable))
263 (defknown (%logand %logior %logxor) (bignum-element-type bignum-element-type)
265 (foldable flushable movable))
267 (defknown %fixnum-to-digit (fixnum) bignum-element-type
268 (foldable flushable movable))
270 (defknown %floor (bignum-element-type bignum-element-type bignum-element-type)
271 (values bignum-element-type bignum-element-type)
272 (foldable flushable movable))
274 (defknown %fixnum-digit-with-correct-sign (bignum-element-type)
275 (signed-byte #.sb!vm:n-word-bits)
276 (foldable flushable movable))
278 (defknown (%ashl %ashr %digit-logical-shift-right)
279 (bignum-element-type (mod #.sb!vm:n-word-bits)) bignum-element-type
280 (foldable flushable movable))
282 ;;;; bit-bashing routines
284 (defknown copy-to-system-area
285 ((simple-unboxed-array (*)) index system-area-pointer index index)
289 (defknown copy-from-system-area
290 (system-area-pointer index (simple-unboxed-array (*)) index index)
294 (defknown system-area-copy
295 (system-area-pointer index system-area-pointer index index)
299 (defknown bit-bash-copy
300 ((simple-unboxed-array (*)) index
301 (simple-unboxed-array (*)) index index)
305 ;;; (not really a bit-bashing routine, but starting to take over from
306 ;;; bit-bashing routines in byte-sized copies as of sbcl-0.6.12.29:)
308 ((or (simple-unboxed-array (*)) system-area-pointer) index
309 (or (simple-unboxed-array (*)) system-area-pointer) index index)
313 ;;;; code/function/fdefn object manipulation routines
315 (defknown code-instructions (t) system-area-pointer (flushable movable))
316 (defknown code-header-ref (t index) t (flushable))
317 (defknown code-header-set (t index t) t ())
319 (defknown fun-subtype (function) (unsigned-byte #.sb!vm:n-widetag-bits)
321 (defknown ((setf fun-subtype))
322 ((unsigned-byte #.sb!vm:n-widetag-bits) function)
323 (unsigned-byte #.sb!vm:n-widetag-bits)
326 (defknown make-fdefn (t) fdefn (flushable movable))
327 (defknown fdefn-p (t) boolean (movable foldable flushable))
328 (defknown fdefn-name (fdefn) t (foldable flushable))
329 (defknown fdefn-fun (fdefn) (or function null) (flushable))
330 (defknown (setf fdefn-fun) (function fdefn) t (unsafe))
331 (defknown fdefn-makunbound (fdefn) t ())
333 (defknown %simple-fun-self (function) function
335 (defknown (setf %simple-fun-self) (function function) function
338 (defknown %closure-fun (function) function
341 (defknown %closure-index-ref (function index) t
344 (defknown %make-funcallable-instance (index layout) function
347 (defknown %funcallable-instance-info (function index) t (flushable))
348 (defknown %set-funcallable-instance-info (function index t) t (unsafe))
350 ;;;; mutator accessors
352 (defknown mutator-self () system-area-pointer (flushable movable))
354 (defknown %data-vector-and-index (array index)
355 (values (simple-array * (*)) index)
356 (foldable flushable))