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-8-p
29 simple-array-unsigned-byte-16-p simple-array-unsigned-byte-32-p
30 simple-array-signed-byte-8-p simple-array-signed-byte-16-p
31 simple-array-signed-byte-30-p simple-array-signed-byte-32-p
32 simple-array-single-float-p simple-array-double-float-p
33 #!+long-float simple-array-long-float-p
34 simple-array-complex-single-float-p
35 simple-array-complex-double-float-p
36 #!+long-float simple-array-complex-long-float-p
37 system-area-pointer-p realp unsigned-byte-32-p signed-byte-32-p
38 vector-t-p weak-pointer-p code-component-p lra-p
39 funcallable-instance-p)
40 (t) boolean (movable foldable flushable))
42 ;;;; miscellaneous "sub-primitives"
44 (defknown %sp-string-compare
45 (simple-string index index simple-string index index)
49 (defknown %sxhash-simple-string (simple-string) index
52 (defknown %sxhash-simple-substring (simple-string index) index
55 (defknown vector-length (vector) index (flushable))
57 (defknown vector-sap ((simple-unboxed-array (*))) system-area-pointer
60 (defknown lowtag-of (t) (unsigned-byte #.sb!vm:n-lowtag-bits)
62 (defknown widetag-of (t) (unsigned-byte #.sb!vm:n-widetag-bits)
65 (defknown (get-header-data get-closure-length) (t) (unsigned-byte 24)
67 (defknown set-header-data (t (unsigned-byte 24)) t
71 (defknown %make-instance (index) instance
73 (defknown %instance-layout (instance) layout
75 (defknown %set-instance-layout (instance layout) layout
77 (defknown %instance-length (instance) index
79 (defknown %instance-ref (instance index) t
81 (defknown %instance-set (instance index t) t
83 (defknown %layout-invalid-error (t layout) nil)
86 (sb!xc:deftype raw-vector () '(simple-array (unsigned-byte 32) (*)))
88 (defknown %raw-ref-single (raw-vector index) single-float
90 (defknown %raw-ref-double (raw-vector index) double-float
93 (defknown %raw-ref-long (raw-vector index) long-float
95 (defknown %raw-set-single (raw-vector index single-float) single-float
97 (defknown %raw-set-double (raw-vector index double-float) double-float
100 (defknown %raw-set-long (raw-vector index long-float) long-float
103 (defknown %raw-ref-complex-single (raw-vector index) (complex single-float)
104 (foldable flushable))
105 (defknown %raw-ref-complex-double (raw-vector index) (complex double-float)
106 (foldable flushable))
108 (defknown %raw-ref-complex-long (raw-vector index) (complex long-float)
109 (foldable flushable))
110 (defknown %raw-set-complex-single (raw-vector index (complex single-float))
111 (complex single-float)
113 (defknown %raw-set-complex-double (raw-vector index (complex double-float))
114 (complex double-float)
117 (defknown %raw-set-complex-long (raw-vector index (complex long-float))
121 (defknown %raw-bits (t fixnum) (unsigned-byte 32)
122 (foldable flushable))
123 (defknown (%set-raw-bits) (t fixnum (unsigned-byte 32)) (unsigned-byte 32)
127 (defknown allocate-vector ((unsigned-byte 8) index index) (simple-array * (*))
130 (defknown make-array-header ((unsigned-byte 8) (unsigned-byte 24)) array
134 (defknown make-weak-pointer (t) weak-pointer
137 (defknown %make-complex (real real) complex
139 (defknown %make-ratio (rational rational) ratio
141 (defknown make-value-cell (t) t
144 (defknown (dynamic-space-free-pointer binding-stack-pointer-sap
145 control-stack-pointer-sap) ()
149 ;;;; debugger support
151 (defknown current-sp () system-area-pointer (movable flushable))
152 (defknown current-fp () system-area-pointer (movable flushable))
153 (defknown stack-ref (system-area-pointer index) t (flushable))
154 (defknown %set-stack-ref (system-area-pointer index t) t (unsafe))
155 (defknown lra-code-header (t) t (movable flushable))
156 (defknown fun-code-header (t) t (movable flushable))
157 (defknown make-lisp-obj ((unsigned-byte 32)) t (movable flushable))
158 (defknown get-lisp-obj-address (t) (unsigned-byte 32) (movable flushable))
159 (defknown fun-word-offset (function) index (movable flushable))
161 ;;;; 32-bit logical operations
163 (defknown merge-bits ((unsigned-byte 5) (unsigned-byte 32) (unsigned-byte 32))
165 (foldable flushable movable))
167 (defknown 32bit-logical-not ((unsigned-byte 32)) (unsigned-byte 32)
168 (foldable flushable movable))
170 (defknown (32bit-logical-and 32bit-logical-nand
171 32bit-logical-or 32bit-logical-nor
172 32bit-logical-xor 32bit-logical-eqv
173 32bit-logical-andc1 32bit-logical-andc2
174 32bit-logical-orc1 32bit-logical-orc2)
175 ((unsigned-byte 32) (unsigned-byte 32)) (unsigned-byte 32)
176 (foldable flushable movable))
178 (defknown (shift-towards-start shift-towards-end) ((unsigned-byte 32) fixnum)
180 (foldable flushable movable))
182 ;;;; bignum operations
184 (defknown %allocate-bignum (bignum-index) bignum-type
187 (defknown %bignum-length (bignum-type) bignum-index
188 (foldable flushable movable))
190 (defknown %bignum-set-length (bignum-type bignum-index) bignum-type
193 (defknown %bignum-ref (bignum-type bignum-index) bignum-element-type
196 (defknown %bignum-set (bignum-type bignum-index bignum-element-type)
200 (defknown %digit-0-or-plusp (bignum-element-type) boolean
201 (foldable flushable movable))
203 (defknown (%add-with-carry %subtract-with-borrow)
204 (bignum-element-type bignum-element-type (mod 2))
205 (values bignum-element-type (mod 2))
206 (foldable flushable movable))
208 (defknown %multiply-and-add
209 (bignum-element-type bignum-element-type bignum-element-type
210 &optional bignum-element-type)
211 (values bignum-element-type bignum-element-type)
212 (foldable flushable movable))
214 (defknown %multiply (bignum-element-type bignum-element-type)
215 (values bignum-element-type bignum-element-type)
216 (foldable flushable movable))
218 (defknown %lognot (bignum-element-type) bignum-element-type
219 (foldable flushable movable))
221 (defknown (%logand %logior %logxor) (bignum-element-type bignum-element-type)
223 (foldable flushable movable))
225 (defknown %fixnum-to-digit (fixnum) bignum-element-type
226 (foldable flushable movable))
228 (defknown %floor (bignum-element-type bignum-element-type bignum-element-type)
229 (values bignum-element-type bignum-element-type)
230 (foldable flushable movable))
232 (defknown %fixnum-digit-with-correct-sign (bignum-element-type)
233 (signed-byte #.sb!vm:n-word-bits)
234 (foldable flushable movable))
236 (defknown (%ashl %ashr %digit-logical-shift-right)
237 (bignum-element-type (mod 32)) bignum-element-type
238 (foldable flushable movable))
240 ;;;; bit-bashing routines
242 (defknown copy-to-system-area
243 ((simple-unboxed-array (*)) index system-area-pointer index index)
247 (defknown copy-from-system-area
248 (system-area-pointer index (simple-unboxed-array (*)) index index)
252 (defknown system-area-copy
253 (system-area-pointer index system-area-pointer index index)
257 (defknown bit-bash-copy
258 ((simple-unboxed-array (*)) index
259 (simple-unboxed-array (*)) index index)
263 ;;; (not really a bit-bashing routine, but starting to take over from
264 ;;; bit-bashing routines in byte-sized copies as of sbcl-0.6.12.29:)
266 ((or (simple-unboxed-array (*)) system-area-pointer) index
267 (or (simple-unboxed-array (*)) system-area-pointer) index index)
271 ;;;; code/function/fdefn object manipulation routines
273 (defknown code-instructions (t) system-area-pointer (flushable movable))
274 (defknown code-header-ref (t index) t (flushable))
275 (defknown code-header-set (t index t) t ())
277 (defknown fun-subtype (function) (unsigned-byte #.sb!vm:n-widetag-bits)
279 (defknown ((setf fun-subtype))
280 ((unsigned-byte #.sb!vm:n-widetag-bits) function)
281 (unsigned-byte #.sb!vm:n-widetag-bits)
284 (defknown make-fdefn (t) fdefn (flushable movable))
285 (defknown fdefn-p (t) boolean (movable foldable flushable))
286 (defknown fdefn-name (fdefn) t (foldable flushable))
287 (defknown fdefn-fun (fdefn) (or function null) (flushable))
288 (defknown (setf fdefn-fun) (function fdefn) t (unsafe))
289 (defknown fdefn-makunbound (fdefn) t ())
291 (defknown %simple-fun-self (function) function
293 (defknown (setf %simple-fun-self) (function function) function
296 (defknown %closure-fun (function) function
299 (defknown %closure-index-ref (function index) t
302 (defknown %make-funcallable-instance (index layout) function
305 (defknown %funcallable-instance-info (function index) t (flushable))
306 (defknown %set-funcallable-instance-info (function index t) t (unsafe))
308 ;;;; mutator accessors
310 (defknown mutator-self () system-area-pointer (flushable movable))
312 (defknown %data-vector-and-index (array index)
313 (values (simple-array * (*)) index)
314 (foldable flushable))