0.8.9.28:
[sbcl.git] / src / compiler / generic / vm-fndb.lisp
1 ;;;; signatures of machine-specific functions
2
3 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; more information.
5 ;;;;
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.
11
12 (in-package "SB!C")
13 \f
14 ;;;; internal type predicates
15
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
22            complex-vector-p
23            base-char-p %standard-char-p %instancep
24            base-string-p simple-base-string-p
25            array-header-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))
44 \f
45 ;;;; miscellaneous "sub-primitives"
46
47 (defknown %sp-string-compare
48   (simple-string index index simple-string index index)
49   (or index null)
50   (foldable flushable))
51
52 (defknown %sxhash-simple-string (simple-string) index
53   (foldable flushable))
54
55 (defknown %sxhash-simple-substring (simple-string index) index
56   (foldable flushable))
57
58 (defknown vector-length (vector) index (flushable))
59
60 (defknown vector-sap ((simple-unboxed-array (*))) system-area-pointer
61   (flushable))
62
63 (defknown lowtag-of (t) (unsigned-byte #.sb!vm:n-lowtag-bits)
64   (flushable movable))
65 (defknown widetag-of (t) (unsigned-byte #.sb!vm:n-widetag-bits)
66   (flushable movable))
67
68 (defknown (get-header-data get-closure-length) (t) (unsigned-byte 24)
69   (flushable))
70 (defknown set-header-data (t (unsigned-byte 24)) t
71   (unsafe))
72
73 (defknown %array-dimension (t index) index
74   (flushable))
75 (defknown %set-array-dimension (t index index) index
76   ())
77 (defknown %array-rank (t) index
78   (flushable))
79
80 (defknown %make-instance (index) instance
81   (unsafe))
82 (defknown %instance-layout (instance) layout
83   (foldable flushable))
84 (defknown %set-instance-layout (instance layout) layout
85   (unsafe))
86 (defknown %instance-length (instance) index
87   (foldable flushable))
88 (defknown %instance-ref (instance index) t
89   (flushable))
90 (defknown %instance-set (instance index t) t
91   (unsafe))
92 (defknown %layout-invalid-error (t layout) nil)
93
94
95 (sb!xc:deftype raw-vector () '(simple-array (unsigned-byte 32) (*)))
96
97 (defknown %raw-ref-single (raw-vector index) single-float
98   (foldable flushable))
99 (defknown %raw-ref-double (raw-vector index) double-float
100   (foldable flushable))
101 #!+long-float
102 (defknown %raw-ref-long (raw-vector index) long-float
103   (foldable flushable))
104 (defknown %raw-set-single (raw-vector index single-float) single-float
105   (unsafe))
106 (defknown %raw-set-double (raw-vector index double-float) double-float
107   (unsafe))
108 #!+long-float
109 (defknown %raw-set-long (raw-vector index long-float) long-float
110   (unsafe))
111
112 (defknown %raw-ref-complex-single (raw-vector index) (complex single-float)
113   (foldable flushable))
114 (defknown %raw-ref-complex-double (raw-vector index) (complex double-float)
115   (foldable flushable))
116
117 (defknown %raw-set-complex-single (raw-vector index (complex single-float))
118   (complex single-float)
119   (unsafe))
120 (defknown %raw-set-complex-double (raw-vector index (complex double-float))
121   (complex double-float)
122   (unsafe))
123
124
125 (defknown %raw-bits (t fixnum) (unsigned-byte 32)
126   (foldable flushable))
127 (defknown (%set-raw-bits) (t fixnum (unsigned-byte 32)) (unsigned-byte 32)
128   (unsafe))
129
130
131 (defknown allocate-vector ((unsigned-byte 8) index index) (simple-array * (*))
132   (flushable movable))
133
134 (defknown make-array-header ((unsigned-byte 8) (unsigned-byte 24)) array
135   (flushable movable))
136
137
138 (defknown make-weak-pointer (t) weak-pointer
139   (flushable))
140
141 (defknown %make-complex (real real) complex
142   (flushable movable))
143 (defknown %make-ratio (rational rational) ratio
144   (flushable movable))
145 (defknown make-value-cell (t) t
146   (flushable movable))
147
148 (defknown (dynamic-space-free-pointer binding-stack-pointer-sap
149                                       control-stack-pointer-sap)  ()
150   system-area-pointer
151   (flushable))
152 \f
153 ;;;; debugger support
154
155 (defknown current-sp () system-area-pointer (movable flushable))
156 (defknown current-fp () system-area-pointer (movable flushable))
157 (defknown stack-ref (system-area-pointer index) t (flushable))
158 (defknown %set-stack-ref (system-area-pointer index t) t (unsafe))
159 (defknown lra-code-header (t) t (movable flushable))
160 (defknown fun-code-header (t) t (movable flushable))
161 (defknown make-lisp-obj ((unsigned-byte 32)) t (movable flushable))
162 (defknown get-lisp-obj-address (t) (unsigned-byte 32) (movable flushable))
163 (defknown fun-word-offset (function) index (movable flushable))
164 \f
165 ;;;; 32-bit logical operations
166
167 (defknown merge-bits ((unsigned-byte 5) (unsigned-byte 32) (unsigned-byte 32))
168   (unsigned-byte 32)
169   (foldable flushable movable))
170
171 (defknown 32bit-logical-not ((unsigned-byte 32)) (unsigned-byte 32)
172   (foldable flushable movable))
173
174 (defknown (32bit-logical-and 32bit-logical-nand
175            32bit-logical-or 32bit-logical-nor
176            32bit-logical-xor 32bit-logical-eqv
177            32bit-logical-andc1 32bit-logical-andc2
178            32bit-logical-orc1 32bit-logical-orc2)
179           ((unsigned-byte 32) (unsigned-byte 32)) (unsigned-byte 32)
180   (foldable flushable movable))
181
182 (defknown (shift-towards-start shift-towards-end) ((unsigned-byte 32) fixnum)
183   (unsigned-byte 32)
184   (foldable flushable movable))
185 \f
186 ;;;; bignum operations
187
188 (defknown %allocate-bignum (bignum-index) bignum-type
189   (flushable))
190
191 (defknown %bignum-length (bignum-type) bignum-index
192   (foldable flushable movable))
193
194 (defknown %bignum-set-length (bignum-type bignum-index) bignum-type
195   (unsafe))
196
197 (defknown %bignum-ref (bignum-type bignum-index) bignum-element-type
198   (flushable))
199
200 (defknown %bignum-set (bignum-type bignum-index bignum-element-type)
201   bignum-element-type
202   (unsafe))
203
204 (defknown %digit-0-or-plusp (bignum-element-type) boolean
205   (foldable flushable movable))
206
207 (defknown (%add-with-carry %subtract-with-borrow)
208           (bignum-element-type bignum-element-type (mod 2))
209   (values bignum-element-type (mod 2))
210   (foldable flushable movable))
211
212 (defknown %multiply-and-add
213           (bignum-element-type bignum-element-type bignum-element-type
214                                &optional bignum-element-type)
215   (values bignum-element-type bignum-element-type)
216   (foldable flushable movable))
217
218 (defknown %multiply (bignum-element-type bignum-element-type)
219   (values bignum-element-type bignum-element-type)
220   (foldable flushable movable))
221
222 (defknown %lognot (bignum-element-type) bignum-element-type
223   (foldable flushable movable))
224
225 (defknown (%logand %logior %logxor) (bignum-element-type bignum-element-type)
226   bignum-element-type
227   (foldable flushable movable))
228
229 (defknown %fixnum-to-digit (fixnum) bignum-element-type
230   (foldable flushable movable))
231
232 (defknown %floor (bignum-element-type bignum-element-type bignum-element-type)
233   (values bignum-element-type bignum-element-type)
234   (foldable flushable movable))
235
236 (defknown %fixnum-digit-with-correct-sign (bignum-element-type)
237   (signed-byte #.sb!vm:n-word-bits)
238   (foldable flushable movable))
239
240 (defknown (%ashl %ashr %digit-logical-shift-right)
241           (bignum-element-type (mod 32)) bignum-element-type
242   (foldable flushable movable))
243 \f
244 ;;;; bit-bashing routines
245
246 (defknown copy-to-system-area
247           ((simple-unboxed-array (*)) index system-area-pointer index index)
248   (values)
249   ())
250
251 (defknown copy-from-system-area
252           (system-area-pointer index (simple-unboxed-array (*)) index index)
253   (values)
254   ())
255
256 (defknown system-area-copy
257           (system-area-pointer index system-area-pointer index index)
258   (values)
259   ())
260
261 (defknown bit-bash-copy
262           ((simple-unboxed-array (*)) index
263            (simple-unboxed-array (*)) index index)
264   (values)
265   ())
266
267 ;;; (not really a bit-bashing routine, but starting to take over from
268 ;;; bit-bashing routines in byte-sized copies as of sbcl-0.6.12.29:)
269 (defknown %byte-blt
270   ((or (simple-unboxed-array (*)) system-area-pointer) index
271    (or (simple-unboxed-array (*)) system-area-pointer) index index)
272   (values)
273   ())
274 \f
275 ;;;; code/function/fdefn object manipulation routines
276
277 (defknown code-instructions (t) system-area-pointer (flushable movable))
278 (defknown code-header-ref (t index) t (flushable))
279 (defknown code-header-set (t index t) t ())
280
281 (defknown fun-subtype (function) (unsigned-byte #.sb!vm:n-widetag-bits)
282   (flushable))
283 (defknown ((setf fun-subtype))
284           ((unsigned-byte #.sb!vm:n-widetag-bits) function)
285   (unsigned-byte #.sb!vm:n-widetag-bits)
286   ())
287
288 (defknown make-fdefn (t) fdefn (flushable movable))
289 (defknown fdefn-p (t) boolean (movable foldable flushable))
290 (defknown fdefn-name (fdefn) t (foldable flushable))
291 (defknown fdefn-fun (fdefn) (or function null) (flushable))
292 (defknown (setf fdefn-fun) (function fdefn) t (unsafe))
293 (defknown fdefn-makunbound (fdefn) t ())
294
295 (defknown %simple-fun-self (function) function
296   (flushable))
297 (defknown (setf %simple-fun-self) (function function) function
298   (unsafe))
299
300 (defknown %closure-fun (function) function
301   (flushable))
302
303 (defknown %closure-index-ref (function index) t
304   (flushable))
305
306 (defknown %make-funcallable-instance (index layout) function
307   (unsafe))
308
309 (defknown %funcallable-instance-info (function index) t (flushable))
310 (defknown %set-funcallable-instance-info (function index t) t (unsafe))
311 \f
312 ;;;; mutator accessors
313
314 (defknown mutator-self () system-area-pointer (flushable movable))
315
316 (defknown %data-vector-and-index (array index)
317                                  (values (simple-array * (*)) index)
318                                  (foldable flushable))