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