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 %other-pointer-p
24 base-string-p simple-base-string-p
25 #!+sb-unicode character-string-p
26 #!+sb-unicode simple-character-string-p
28 sequencep extended-sequence-p
29 simple-array-p simple-array-nil-p vector-nil-p
30 simple-array-unsigned-byte-2-p
31 simple-array-unsigned-byte-4-p simple-array-unsigned-byte-7-p
32 simple-array-unsigned-byte-8-p simple-array-unsigned-byte-15-p
33 simple-array-unsigned-byte-16-p
35 simple-array-unsigned-fixnum-p
37 simple-array-unsigned-byte-31-p
38 simple-array-unsigned-byte-32-p
39 #!+#.(cl:if (cl:= 64 sb!vm:n-word-bits) '(and) '(or))
40 simple-array-unsigned-byte-63-p
41 #!+#.(cl:if (cl:= 64 sb!vm:n-word-bits) '(and) '(or))
42 simple-array-unsigned-byte-64-p
43 simple-array-signed-byte-8-p simple-array-signed-byte-16-p
47 simple-array-signed-byte-32-p
48 #!+#.(cl:if (cl:= 64 sb!vm:n-word-bits) '(and) '(or))
49 simple-array-signed-byte-64-p
50 simple-array-single-float-p simple-array-double-float-p
51 #!+long-float simple-array-long-float-p
52 simple-array-complex-single-float-p
53 simple-array-complex-double-float-p
54 #!+long-float simple-array-complex-long-float-p
55 system-area-pointer-p realp
56 ;; #!+#.(cl:if (cl:= 32 sb!vm:n-word-bits) '(and) '(or))
58 ;; #!+#.(cl:if (cl:= 32 sb!vm:n-word-bits) '(and) '(or))
60 #!+#.(cl:if (cl:= 64 sb!vm:n-word-bits) '(and) '(or))
62 #!+#.(cl:if (cl:= 64 sb!vm:n-word-bits) '(and) '(or))
64 weak-pointer-p code-component-p lra-p
65 funcallable-instance-p)
66 (t) boolean (movable foldable flushable))
67 (defknown #.(loop for (name) in *vector-without-complex-typecode-infos*
69 (t) boolean (movable foldable flushable))
71 ;;;; miscellaneous "sub-primitives"
73 (defknown pointer-hash (t) hash (flushable))
75 (defknown %sp-string-compare
76 (simple-string index index simple-string index index)
80 (defknown %sxhash-simple-string (simple-string) hash
83 (defknown %sxhash-simple-substring (simple-string index) hash
86 (defknown symbol-hash (symbol) hash
89 (defknown %set-symbol-hash (symbol hash)
92 (defknown initialize-vector ((simple-array * (*)) &rest t)
94 (always-translatable flushable)
97 (defknown vector-fill* (t t t t) vector
101 (defknown vector-length (vector) index (flushable dx-safe))
103 (defknown vector-sap ((simple-unboxed-array (*))) system-area-pointer
106 (defknown lowtag-of (t) (unsigned-byte #.sb!vm:n-lowtag-bits)
108 (defknown widetag-of (t) (unsigned-byte #.sb!vm:n-widetag-bits)
111 (defknown (get-header-data get-closure-length) (t) (unsigned-byte 24)
113 (defknown set-header-data (t (unsigned-byte 24)) t
116 (defknown %array-dimension (t index) index
118 (defknown %set-array-dimension (t index index) index
120 (defknown %array-rank (t) index
123 (defknown %make-instance (index) instance
125 (defknown %make-structure-instance (defstruct-description list &rest t) instance
126 (flushable always-translatable))
127 (defknown %instance-layout (instance) layout
128 (foldable flushable))
129 (defknown %set-instance-layout (instance layout) layout
131 (defknown %instance-length (instance) index
132 (foldable flushable))
133 (defknown %instance-ref (instance index) t
134 (flushable always-translatable))
135 (defknown %instance-set (instance index t) t
136 (always-translatable))
137 (defknown %layout-invalid-error (t layout) nil)
139 (defknown %raw-instance-ref/word (instance index) sb!vm:word
140 (flushable always-translatable))
141 (defknown %raw-instance-set/word (instance index sb!vm:word) sb!vm:word
142 (always-translatable))
143 (defknown %raw-instance-ref/single (instance index) single-float
144 (flushable always-translatable))
145 (defknown %raw-instance-set/single (instance index single-float) single-float
146 (always-translatable))
147 (defknown %raw-instance-ref/double (instance index) double-float
148 (flushable always-translatable))
149 (defknown %raw-instance-set/double (instance index double-float) double-float
150 (always-translatable))
151 (defknown %raw-instance-ref/complex-single (instance index)
152 (complex single-float)
153 (flushable always-translatable))
154 (defknown %raw-instance-set/complex-single
155 (instance index (complex single-float))
156 (complex single-float)
157 (always-translatable))
158 (defknown %raw-instance-ref/complex-double (instance index)
159 (complex double-float)
160 (flushable always-translatable))
161 (defknown %raw-instance-set/complex-double
162 (instance index (complex double-float))
163 (complex double-float)
164 (always-translatable))
166 #!+(or x86 x86-64 ppc)
167 (defknown %raw-instance-atomic-incf/word (instance index sb!vm:word) sb!vm:word
168 (always-translatable))
169 #!+(or x86 x86-64 ppc)
170 (defknown %array-atomic-incf/word (t index sb!vm:word) sb!vm:word
171 (always-translatable))
173 ;;; These two are mostly used for bit-bashing operations.
174 (defknown %vector-raw-bits (t fixnum) sb!vm:word
176 (defknown (%set-vector-raw-bits) (t fixnum sb!vm:word) sb!vm:word
180 (defknown allocate-vector ((unsigned-byte 8) index index) (simple-array * (*))
183 (defknown make-array-header ((unsigned-byte 8) (unsigned-byte 24)) array
187 (defknown make-weak-pointer (t) weak-pointer
190 (defknown %make-complex (real real) complex
192 (defknown %make-ratio (rational rational) ratio
194 (defknown make-value-cell (t) t
199 (defknown (dynamic-space-free-pointer binding-stack-pointer-sap
200 control-stack-pointer-sap) ()
204 ;;;; debugger support
206 (defknown current-sp () system-area-pointer (movable flushable))
207 (defknown current-fp () system-area-pointer (movable flushable))
208 (defknown stack-ref (system-area-pointer index) t (flushable))
209 (defknown %set-stack-ref (system-area-pointer index t) t ())
210 (defknown lra-code-header (t) t (movable flushable))
211 (defknown fun-code-header (t) t (movable flushable))
212 (defknown %make-lisp-obj (sb!vm:word) t (movable flushable))
213 (defknown get-lisp-obj-address (t) sb!vm:word (movable flushable))
214 (defknown fun-word-offset (function) index (movable flushable))
216 ;;;; 32-bit logical operations
218 (defknown word-logical-not (sb!vm:word) sb!vm:word
219 (foldable flushable movable))
221 (defknown (word-logical-and word-logical-nand
222 word-logical-or word-logical-nor
223 word-logical-xor word-logical-eqv
224 word-logical-andc1 word-logical-andc2
225 word-logical-orc1 word-logical-orc2)
226 (sb!vm:word sb!vm:word) sb!vm:word
227 (foldable flushable movable))
229 (defknown (shift-towards-start shift-towards-end) (sb!vm:word fixnum)
231 (foldable flushable movable))
233 ;;;; bignum operations
235 (defknown %allocate-bignum (bignum-index) bignum-type
238 (defknown %bignum-length (bignum-type) bignum-index
239 (foldable flushable movable))
241 (defknown %bignum-set-length (bignum-type bignum-index) bignum-type
244 (defknown %bignum-ref (bignum-type bignum-index) bignum-element-type
247 (defknown %bignum-ref-with-offset (bignum-type bignum-index (signed-byte 24))
248 bignum-element-type (flushable always-translatable))
250 (defknown %bignum-set (bignum-type bignum-index bignum-element-type)
254 (defknown %bignum-set-with-offset
255 (bignum-type bignum-index (signed-byte 24) bignum-element-type)
256 bignum-element-type (always-translatable))
258 (defknown %digit-0-or-plusp (bignum-element-type) boolean
259 (foldable flushable movable))
261 (defknown (%add-with-carry %subtract-with-borrow)
262 (bignum-element-type bignum-element-type (mod 2))
263 (values bignum-element-type (mod 2))
264 (foldable flushable movable))
266 (defknown %multiply-and-add
267 (bignum-element-type bignum-element-type bignum-element-type
268 &optional bignum-element-type)
269 (values bignum-element-type bignum-element-type)
270 (foldable flushable movable))
272 (defknown %multiply (bignum-element-type bignum-element-type)
273 (values bignum-element-type bignum-element-type)
274 (foldable flushable movable))
276 (defknown %lognot (bignum-element-type) bignum-element-type
277 (foldable flushable movable))
279 (defknown (%logand %logior %logxor) (bignum-element-type bignum-element-type)
281 (foldable flushable movable))
283 (defknown %fixnum-to-digit (fixnum) bignum-element-type
284 (foldable flushable movable))
286 (defknown %bigfloor (bignum-element-type bignum-element-type bignum-element-type)
287 (values bignum-element-type bignum-element-type)
288 (foldable flushable movable))
290 (defknown %fixnum-digit-with-correct-sign (bignum-element-type)
291 (signed-byte #.sb!vm:n-word-bits)
292 (foldable flushable movable))
294 (defknown (%ashl %ashr %digit-logical-shift-right)
295 (bignum-element-type (mod #.sb!vm:n-word-bits)) bignum-element-type
296 (foldable flushable movable))
298 ;;;; bit-bashing routines
300 ;;; FIXME: there's some ugly duplication between the (INTERN (FORMAT ...))
301 ;;; magic here and the same magic in src/code/bit-bash.lisp. I don't know
302 ;;; of any good way to clean it up, but it's definitely violating OAOO.
303 (macrolet ((define-known-copiers ()
305 ,@(loop for i = 1 then (* i 2)
306 collect `(defknown ,(intern (format nil "UB~D-BASH-COPY" i)
307 (find-package "SB!KERNEL"))
308 ((simple-unboxed-array (*)) index (simple-unboxed-array (*)) index index)
311 collect `(defknown ,(intern (format nil "SYSTEM-AREA-UB~D-COPY" i)
312 (find-package "SB!KERNEL"))
313 (system-area-pointer index system-area-pointer index index)
316 collect `(defknown ,(intern (format nil "COPY-UB~D-TO-SYSTEM-AREA" i)
317 (find-package "SB!KERNEL"))
318 ((simple-unboxed-array (*)) index system-area-pointer index index)
321 collect `(defknown ,(intern (format nil "COPY-UB~D-FROM-SYSTEM-AREA" i)
322 (find-package "SB!KERNEL"))
323 (system-area-pointer index (simple-unboxed-array (*)) index index)
326 until (= i sb!vm:n-word-bits)))))
327 (define-known-copiers))
329 ;;; (not really a bit-bashing routine, but starting to take over from
330 ;;; bit-bashing routines in byte-sized copies as of sbcl-0.6.12.29:)
332 ((or (simple-unboxed-array (*)) system-area-pointer) index
333 (or (simple-unboxed-array (*)) system-area-pointer) index index)
337 ;;;; code/function/fdefn object manipulation routines
339 (defknown code-instructions (t) system-area-pointer (flushable movable))
340 (defknown code-header-ref (t index) t (flushable))
341 (defknown code-header-set (t index t) t ())
343 (defknown fun-subtype (function) (unsigned-byte #.sb!vm:n-widetag-bits)
345 (defknown ((setf fun-subtype))
346 ((unsigned-byte #.sb!vm:n-widetag-bits) function)
347 (unsigned-byte #.sb!vm:n-widetag-bits)
350 (defknown make-fdefn (t) fdefn (flushable movable))
351 (defknown fdefn-p (t) boolean (movable foldable flushable))
352 (defknown fdefn-name (fdefn) t (foldable flushable))
353 (defknown fdefn-fun (fdefn) (or function null) (flushable))
354 (defknown (setf fdefn-fun) (function fdefn) t ())
355 (defknown fdefn-makunbound (fdefn) t ())
357 (defknown %simple-fun-self (function) function
359 (defknown (setf %simple-fun-self) (function function) function
362 (defknown %closure-fun (function) function
365 (defknown %closure-index-ref (function index) t
368 (defknown %make-funcallable-instance (index) function
371 (defknown %funcallable-instance-info (function index) t (flushable))
372 (defknown %set-funcallable-instance-info (function index t) t ())
374 ;;;; mutator accessors
376 (defknown mutator-self () system-area-pointer (flushable movable))
378 (defknown %data-vector-and-index (array index)
379 (values (simple-array * (*)) index)
380 (foldable flushable))