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 simple-array-unsigned-byte-29-p
31 simple-array-unsigned-byte-31-p
32 simple-array-unsigned-byte-32-p
33 simple-array-signed-byte-8-p simple-array-signed-byte-16-p
34 simple-array-signed-byte-30-p simple-array-signed-byte-32-p
35 simple-array-single-float-p simple-array-double-float-p
36 #!+long-float simple-array-long-float-p
37 simple-array-complex-single-float-p
38 simple-array-complex-double-float-p
39 #!+long-float simple-array-complex-long-float-p
40 system-area-pointer-p realp unsigned-byte-32-p signed-byte-32-p
41 vector-t-p weak-pointer-p code-component-p lra-p
42 funcallable-instance-p)
43 (t) boolean (movable foldable flushable))
45 ;;;; miscellaneous "sub-primitives"
47 (defknown %sp-string-compare
48 (simple-string index index simple-string index index)
52 (defknown %sxhash-simple-string (simple-string) index
55 (defknown %sxhash-simple-substring (simple-string index) index
58 (defknown vector-length (vector) index (flushable))
60 (defknown vector-sap ((simple-unboxed-array (*))) system-area-pointer
63 (defknown lowtag-of (t) (unsigned-byte #.sb!vm:n-lowtag-bits)
65 (defknown widetag-of (t) (unsigned-byte #.sb!vm:n-widetag-bits)
68 (defknown (get-header-data get-closure-length) (t) (unsigned-byte 24)
70 (defknown set-header-data (t (unsigned-byte 24)) t
74 (defknown %make-instance (index) instance
76 (defknown %instance-layout (instance) layout
78 (defknown %set-instance-layout (instance layout) layout
80 (defknown %instance-length (instance) index
82 (defknown %instance-ref (instance index) t
84 (defknown %instance-set (instance index t) t
86 (defknown %layout-invalid-error (t layout) nil)
89 (sb!xc:deftype raw-vector () '(simple-array (unsigned-byte 32) (*)))
91 (defknown %raw-ref-single (raw-vector index) single-float
93 (defknown %raw-ref-double (raw-vector index) double-float
96 (defknown %raw-ref-long (raw-vector index) long-float
98 (defknown %raw-set-single (raw-vector index single-float) single-float
100 (defknown %raw-set-double (raw-vector index double-float) double-float
103 (defknown %raw-set-long (raw-vector index long-float) long-float
106 (defknown %raw-ref-complex-single (raw-vector index) (complex single-float)
107 (foldable flushable))
108 (defknown %raw-ref-complex-double (raw-vector index) (complex double-float)
109 (foldable flushable))
111 (defknown %raw-ref-complex-long (raw-vector index) (complex long-float)
112 (foldable flushable))
113 (defknown %raw-set-complex-single (raw-vector index (complex single-float))
114 (complex single-float)
116 (defknown %raw-set-complex-double (raw-vector index (complex double-float))
117 (complex double-float)
120 (defknown %raw-set-complex-long (raw-vector index (complex long-float))
124 (defknown %raw-bits (t fixnum) (unsigned-byte 32)
125 (foldable flushable))
126 (defknown (%set-raw-bits) (t fixnum (unsigned-byte 32)) (unsigned-byte 32)
130 (defknown allocate-vector ((unsigned-byte 8) index index) (simple-array * (*))
133 (defknown make-array-header ((unsigned-byte 8) (unsigned-byte 24)) array
137 (defknown make-weak-pointer (t) weak-pointer
140 (defknown %make-complex (real real) complex
142 (defknown %make-ratio (rational rational) ratio
144 (defknown make-value-cell (t) t
147 (defknown (dynamic-space-free-pointer binding-stack-pointer-sap
148 control-stack-pointer-sap) ()
152 ;;;; debugger support
154 (defknown current-sp () system-area-pointer (movable flushable))
155 (defknown current-fp () system-area-pointer (movable flushable))
156 (defknown stack-ref (system-area-pointer index) t (flushable))
157 (defknown %set-stack-ref (system-area-pointer index t) t (unsafe))
158 (defknown lra-code-header (t) t (movable flushable))
159 (defknown fun-code-header (t) t (movable flushable))
160 (defknown make-lisp-obj ((unsigned-byte 32)) t (movable flushable))
161 (defknown get-lisp-obj-address (t) (unsigned-byte 32) (movable flushable))
162 (defknown fun-word-offset (function) index (movable flushable))
164 ;;;; 32-bit logical operations
166 (defknown merge-bits ((unsigned-byte 5) (unsigned-byte 32) (unsigned-byte 32))
168 (foldable flushable movable))
170 (defknown 32bit-logical-not ((unsigned-byte 32)) (unsigned-byte 32)
171 (foldable flushable movable))
173 (defknown (32bit-logical-and 32bit-logical-nand
174 32bit-logical-or 32bit-logical-nor
175 32bit-logical-xor 32bit-logical-eqv
176 32bit-logical-andc1 32bit-logical-andc2
177 32bit-logical-orc1 32bit-logical-orc2)
178 ((unsigned-byte 32) (unsigned-byte 32)) (unsigned-byte 32)
179 (foldable flushable movable))
181 (defknown (shift-towards-start shift-towards-end) ((unsigned-byte 32) fixnum)
183 (foldable flushable movable))
185 ;;;; bignum operations
187 (defknown %allocate-bignum (bignum-index) bignum-type
190 (defknown %bignum-length (bignum-type) bignum-index
191 (foldable flushable movable))
193 (defknown %bignum-set-length (bignum-type bignum-index) bignum-type
196 (defknown %bignum-ref (bignum-type bignum-index) bignum-element-type
199 (defknown %bignum-set (bignum-type bignum-index bignum-element-type)
203 (defknown %digit-0-or-plusp (bignum-element-type) boolean
204 (foldable flushable movable))
206 (defknown (%add-with-carry %subtract-with-borrow)
207 (bignum-element-type bignum-element-type (mod 2))
208 (values bignum-element-type (mod 2))
209 (foldable flushable movable))
211 (defknown %multiply-and-add
212 (bignum-element-type bignum-element-type bignum-element-type
213 &optional bignum-element-type)
214 (values bignum-element-type bignum-element-type)
215 (foldable flushable movable))
217 (defknown %multiply (bignum-element-type bignum-element-type)
218 (values bignum-element-type bignum-element-type)
219 (foldable flushable movable))
221 (defknown %lognot (bignum-element-type) bignum-element-type
222 (foldable flushable movable))
224 (defknown (%logand %logior %logxor) (bignum-element-type bignum-element-type)
226 (foldable flushable movable))
228 (defknown %fixnum-to-digit (fixnum) bignum-element-type
229 (foldable flushable movable))
231 (defknown %floor (bignum-element-type bignum-element-type bignum-element-type)
232 (values bignum-element-type bignum-element-type)
233 (foldable flushable movable))
235 (defknown %fixnum-digit-with-correct-sign (bignum-element-type)
236 (signed-byte #.sb!vm:n-word-bits)
237 (foldable flushable movable))
239 (defknown (%ashl %ashr %digit-logical-shift-right)
240 (bignum-element-type (mod 32)) bignum-element-type
241 (foldable flushable movable))
243 ;;;; bit-bashing routines
245 (defknown copy-to-system-area
246 ((simple-unboxed-array (*)) index system-area-pointer index index)
250 (defknown copy-from-system-area
251 (system-area-pointer index (simple-unboxed-array (*)) index index)
255 (defknown system-area-copy
256 (system-area-pointer index system-area-pointer index index)
260 (defknown bit-bash-copy
261 ((simple-unboxed-array (*)) index
262 (simple-unboxed-array (*)) index index)
266 ;;; (not really a bit-bashing routine, but starting to take over from
267 ;;; bit-bashing routines in byte-sized copies as of sbcl-0.6.12.29:)
269 ((or (simple-unboxed-array (*)) system-area-pointer) index
270 (or (simple-unboxed-array (*)) system-area-pointer) index index)
274 ;;;; code/function/fdefn object manipulation routines
276 (defknown code-instructions (t) system-area-pointer (flushable movable))
277 (defknown code-header-ref (t index) t (flushable))
278 (defknown code-header-set (t index t) t ())
280 (defknown fun-subtype (function) (unsigned-byte #.sb!vm:n-widetag-bits)
282 (defknown ((setf fun-subtype))
283 ((unsigned-byte #.sb!vm:n-widetag-bits) function)
284 (unsigned-byte #.sb!vm:n-widetag-bits)
287 (defknown make-fdefn (t) fdefn (flushable movable))
288 (defknown fdefn-p (t) boolean (movable foldable flushable))
289 (defknown fdefn-name (fdefn) t (foldable flushable))
290 (defknown fdefn-fun (fdefn) (or function null) (flushable))
291 (defknown (setf fdefn-fun) (function fdefn) t (unsafe))
292 (defknown fdefn-makunbound (fdefn) t ())
294 (defknown %simple-fun-self (function) function
296 (defknown (setf %simple-fun-self) (function function) function
299 (defknown %closure-fun (function) function
302 (defknown %closure-index-ref (function index) t
305 (defknown %make-funcallable-instance (index layout) function
308 (defknown %funcallable-instance-info (function index) t (flushable))
309 (defknown %set-funcallable-instance-info (function index t) t (unsafe))
311 ;;;; mutator accessors
313 (defknown mutator-self () system-area-pointer (flushable movable))
315 (defknown %data-vector-and-index (array index)
316 (values (simple-array * (*)) index)
317 (foldable flushable))