0.8.4.8
[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
74 (defknown %make-instance (index) instance
75   (unsafe))
76 (defknown %instance-layout (instance) layout
77   (foldable flushable))
78 (defknown %set-instance-layout (instance layout) layout
79   (unsafe))
80 (defknown %instance-length (instance) index
81   (foldable flushable))
82 (defknown %instance-ref (instance index) t
83   (flushable))
84 (defknown %instance-set (instance index t) t
85   (unsafe))
86 (defknown %layout-invalid-error (t layout) nil)
87
88
89 (sb!xc:deftype raw-vector () '(simple-array (unsigned-byte 32) (*)))
90
91 (defknown %raw-ref-single (raw-vector index) single-float
92   (foldable flushable))
93 (defknown %raw-ref-double (raw-vector index) double-float
94   (foldable flushable))
95 #!+long-float
96 (defknown %raw-ref-long (raw-vector index) long-float
97   (foldable flushable))
98 (defknown %raw-set-single (raw-vector index single-float) single-float
99   (unsafe))
100 (defknown %raw-set-double (raw-vector index double-float) double-float
101   (unsafe))
102 #!+long-float
103 (defknown %raw-set-long (raw-vector index long-float) long-float
104   (unsafe))
105
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))
110 #!+long-float
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)
115   (unsafe))
116 (defknown %raw-set-complex-double (raw-vector index (complex double-float))
117   (complex double-float)
118   (unsafe))
119 #!+long-float
120 (defknown %raw-set-complex-long (raw-vector index (complex long-float))
121   (complex long-float)
122   (unsafe))
123
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)
127   (unsafe))
128
129
130 (defknown allocate-vector ((unsigned-byte 8) index index) (simple-array * (*))
131   (flushable movable))
132
133 (defknown make-array-header ((unsigned-byte 8) (unsigned-byte 24)) array
134   (flushable movable))
135
136
137 (defknown make-weak-pointer (t) weak-pointer
138   (flushable))
139
140 (defknown %make-complex (real real) complex
141   (flushable movable))
142 (defknown %make-ratio (rational rational) ratio
143   (flushable movable))
144 (defknown make-value-cell (t) t
145   (flushable movable))
146
147 (defknown (dynamic-space-free-pointer binding-stack-pointer-sap
148                                       control-stack-pointer-sap)  ()
149   system-area-pointer
150   (flushable))
151 \f
152 ;;;; debugger support
153
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))
163 \f
164 ;;;; 32-bit logical operations
165
166 (defknown merge-bits ((unsigned-byte 5) (unsigned-byte 32) (unsigned-byte 32))
167   (unsigned-byte 32)
168   (foldable flushable movable))
169
170 (defknown 32bit-logical-not ((unsigned-byte 32)) (unsigned-byte 32)
171   (foldable flushable movable))
172
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))
180
181 (defknown (shift-towards-start shift-towards-end) ((unsigned-byte 32) fixnum)
182   (unsigned-byte 32)
183   (foldable flushable movable))
184 \f
185 ;;;; bignum operations
186
187 (defknown %allocate-bignum (bignum-index) bignum-type
188   (flushable))
189
190 (defknown %bignum-length (bignum-type) bignum-index
191   (foldable flushable movable))
192
193 (defknown %bignum-set-length (bignum-type bignum-index) bignum-type
194   (unsafe))
195
196 (defknown %bignum-ref (bignum-type bignum-index) bignum-element-type
197   (flushable))
198
199 (defknown %bignum-set (bignum-type bignum-index bignum-element-type)
200   bignum-element-type
201   (unsafe))
202
203 (defknown %digit-0-or-plusp (bignum-element-type) boolean
204   (foldable flushable movable))
205
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))
210
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))
216
217 (defknown %multiply (bignum-element-type bignum-element-type)
218   (values bignum-element-type bignum-element-type)
219   (foldable flushable movable))
220
221 (defknown %lognot (bignum-element-type) bignum-element-type
222   (foldable flushable movable))
223
224 (defknown (%logand %logior %logxor) (bignum-element-type bignum-element-type)
225   bignum-element-type
226   (foldable flushable movable))
227
228 (defknown %fixnum-to-digit (fixnum) bignum-element-type
229   (foldable flushable movable))
230
231 (defknown %floor (bignum-element-type bignum-element-type bignum-element-type)
232   (values bignum-element-type bignum-element-type)
233   (foldable flushable movable))
234
235 (defknown %fixnum-digit-with-correct-sign (bignum-element-type)
236   (signed-byte #.sb!vm:n-word-bits)
237   (foldable flushable movable))
238
239 (defknown (%ashl %ashr %digit-logical-shift-right)
240           (bignum-element-type (mod 32)) bignum-element-type
241   (foldable flushable movable))
242 \f
243 ;;;; bit-bashing routines
244
245 (defknown copy-to-system-area
246           ((simple-unboxed-array (*)) index system-area-pointer index index)
247   (values)
248   ())
249
250 (defknown copy-from-system-area
251           (system-area-pointer index (simple-unboxed-array (*)) index index)
252   (values)
253   ())
254
255 (defknown system-area-copy
256           (system-area-pointer index system-area-pointer index index)
257   (values)
258   ())
259
260 (defknown bit-bash-copy
261           ((simple-unboxed-array (*)) index
262            (simple-unboxed-array (*)) index index)
263   (values)
264   ())
265
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:)
268 (defknown %byte-blt
269   ((or (simple-unboxed-array (*)) system-area-pointer) index
270    (or (simple-unboxed-array (*)) system-area-pointer) index index)
271   (values)
272   ())
273 \f
274 ;;;; code/function/fdefn object manipulation routines
275
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 ())
279
280 (defknown fun-subtype (function) (unsigned-byte #.sb!vm:n-widetag-bits)
281   (flushable))
282 (defknown ((setf fun-subtype))
283           ((unsigned-byte #.sb!vm:n-widetag-bits) function)
284   (unsigned-byte #.sb!vm:n-widetag-bits)
285   ())
286
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 ())
293
294 (defknown %simple-fun-self (function) function
295   (flushable))
296 (defknown (setf %simple-fun-self) (function function) function
297   (unsafe))
298
299 (defknown %closure-fun (function) function
300   (flushable))
301
302 (defknown %closure-index-ref (function index) t
303   (flushable))
304
305 (defknown %make-funcallable-instance (index layout) function
306   (unsafe))
307
308 (defknown %funcallable-instance-info (function index) t (flushable))
309 (defknown %set-funcallable-instance-info (function index t) t (unsafe))
310 \f
311 ;;;; mutator accessors
312
313 (defknown mutator-self () system-area-pointer (flushable movable))
314
315 (defknown %data-vector-and-index (array index)
316                                  (values (simple-array * (*)) index)
317                                  (foldable flushable))