0.7.7.20-backend-cleanup-1.9:
[sbcl.git] / src / compiler / generic / late-type-vops.lisp
1 ;;;; generic type testing and checking VOPs
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 (in-package "SB!VM")
12 \f
13 (!define-type-vops fixnump check-fixnum fixnum object-not-fixnum-error
14   (even-fixnum-lowtag odd-fixnum-lowtag)
15   ;; we can save a register on the x86.
16   :variant simple
17   ;; we can save a couple of instructions and a branch on the ppc.
18   ;; FIXME: make this be FIXNUM-MASK
19   :mask 3)
20
21 (!define-type-vops functionp check-fun function object-not-fun-error
22   (fun-pointer-lowtag)
23   :mask lowtag-mask)
24
25 (!define-type-vops listp check-list list object-not-list-error
26   (list-pointer-lowtag)
27   :mask lowtag-mask)
28
29 (!define-type-vops %instancep check-instance instance object-not-instance-error
30   (instance-pointer-lowtag)
31   :mask lowtag-mask)
32
33 (!define-type-vops bignump check-bignum bignum object-not-bignum-error
34   (bignum-widetag))
35
36 (!define-type-vops ratiop check-ratio ratio object-not-ratio-error
37   (ratio-widetag))
38
39 (!define-type-vops complexp check-complex complex object-not-complex-error
40   (complex-widetag complex-single-float-widetag complex-double-float-widetag
41                    #!+long-float complex-long-float-widetag))
42
43 (!define-type-vops complex-rational-p check-complex-rational nil
44     object-not-complex-rational-error
45   (complex-widetag))
46
47 (!define-type-vops complex-float-p check-complex-float nil
48     object-not-complex-float-error
49   (complex-single-float-widetag complex-double-float-widetag
50                                 #!+long-float complex-long-float-widetag))
51
52 (!define-type-vops complex-single-float-p check-complex-single-float complex-single-float
53     object-not-complex-single-float-error
54   (complex-single-float-widetag))
55
56 (!define-type-vops complex-double-float-p check-complex-double-float complex-double-float
57     object-not-complex-double-float-error
58   (complex-double-float-widetag))
59
60 #!+long-float
61 (!define-type-vops complex-long-float-p check-complex-long-float complex-long-float
62     object-not-complex-long-float-error
63   (complex-long-float-widetag))
64
65 (!define-type-vops single-float-p check-single-float single-float
66     object-not-single-float-error
67   (single-float-widetag))
68
69 (!define-type-vops double-float-p check-double-float double-float
70     object-not-double-float-error
71   (double-float-widetag))
72
73 #!+long-float
74 (!define-type-vops long-float-p check-long-float long-float
75     object-not-long-float-error
76   (long-float-widetag))
77
78 (!define-type-vops simple-string-p check-simple-string simple-string
79     object-not-simple-string-error
80   (simple-string-widetag))
81
82 (!define-type-vops simple-bit-vector-p check-simple-bit-vector simple-bit-vector
83     object-not-simple-bit-vector-error
84   (simple-bit-vector-widetag))
85
86 (!define-type-vops simple-vector-p check-simple-vector simple-vector
87     object-not-simple-vector-error
88   (simple-vector-widetag))
89
90 (!define-type-vops simple-array-unsigned-byte-2-p
91       check-simple-array-unsigned-byte-2
92       simple-array-unsigned-byte-2
93     object-not-simple-array-unsigned-byte-2-error
94   (simple-array-unsigned-byte-2-widetag))
95
96 (!define-type-vops simple-array-unsigned-byte-4-p
97       check-simple-array-unsigned-byte-4
98       simple-array-unsigned-byte-4
99     object-not-simple-array-unsigned-byte-4-error
100   (simple-array-unsigned-byte-4-widetag))
101
102 (!define-type-vops simple-array-unsigned-byte-8-p
103       check-simple-array-unsigned-byte-8
104       simple-array-unsigned-byte-8
105     object-not-simple-array-unsigned-byte-8-error
106   (simple-array-unsigned-byte-8-widetag))
107
108 (!define-type-vops simple-array-unsigned-byte-16-p
109       check-simple-array-unsigned-byte-16
110       simple-array-unsigned-byte-16
111     object-not-simple-array-unsigned-byte-16-error
112   (simple-array-unsigned-byte-16-widetag))
113
114 (!define-type-vops simple-array-unsigned-byte-32-p
115       check-simple-array-unsigned-byte-32
116       simple-array-unsigned-byte-32
117     object-not-simple-array-unsigned-byte-32-error
118   (simple-array-unsigned-byte-32-widetag))
119
120 (!define-type-vops simple-array-signed-byte-8-p
121       check-simple-array-signed-byte-8
122       simple-array-signed-byte-8
123     object-not-simple-array-signed-byte-8-error
124   (simple-array-signed-byte-8-widetag))
125
126 (!define-type-vops simple-array-signed-byte-16-p
127       check-simple-array-signed-byte-16
128       simple-array-signed-byte-16
129     object-not-simple-array-signed-byte-16-error
130   (simple-array-signed-byte-16-widetag))
131
132 (!define-type-vops simple-array-signed-byte-30-p
133       check-simple-array-signed-byte-30
134       simple-array-signed-byte-30
135     object-not-simple-array-signed-byte-30-error
136   (simple-array-signed-byte-30-widetag))
137
138 (!define-type-vops simple-array-signed-byte-32-p
139       check-simple-array-signed-byte-32
140       simple-array-signed-byte-32
141     object-not-simple-array-signed-byte-32-error
142   (simple-array-signed-byte-32-widetag))
143
144 (!define-type-vops simple-array-single-float-p check-simple-array-single-float
145       simple-array-single-float
146     object-not-simple-array-single-float-error
147   (simple-array-single-float-widetag))
148
149 (!define-type-vops simple-array-double-float-p check-simple-array-double-float
150       simple-array-double-float
151     object-not-simple-array-double-float-error
152   (simple-array-double-float-widetag))
153
154 #!+long-float
155 (!define-type-vops simple-array-long-float-p check-simple-array-long-float
156       simple-array-long-float
157     object-not-simple-array-long-float-error
158   (simple-array-long-float-widetag))
159
160 (!define-type-vops simple-array-complex-single-float-p
161       check-simple-array-complex-single-float
162       simple-array-complex-single-float
163     object-not-simple-array-complex-single-float-error
164   (simple-array-complex-single-float-widetag))
165
166 (!define-type-vops simple-array-complex-double-float-p
167       check-simple-array-complex-double-float
168       simple-array-complex-double-float
169     object-not-simple-array-complex-double-float-error
170   (simple-array-complex-double-float-widetag))
171
172 #!+long-float
173 (!define-type-vops simple-array-complex-long-float-p
174       check-simple-array-complex-long-float
175       simple-array-complex-long-float
176     object-not-simple-array-complex-long-float-error
177   (simple-array-complex-long-float-widetag))
178
179 (!define-type-vops base-char-p check-base-char base-char
180     object-not-base-char-error
181   (base-char-widetag))
182
183 (!define-type-vops system-area-pointer-p check-system-area-pointer
184       system-area-pointer
185     object-not-sap-error
186   (sap-widetag))
187
188 (!define-type-vops weak-pointer-p check-weak-pointer weak-pointer
189     object-not-weak-pointer-error
190   (weak-pointer-widetag))
191
192 (!define-type-vops code-component-p nil nil nil
193   (code-header-widetag))
194
195 (!define-type-vops lra-p nil nil nil
196   (return-pc-header-widetag))
197
198 (!define-type-vops fdefn-p nil nil nil
199   (fdefn-widetag))
200
201 (!define-type-vops funcallable-instance-p nil nil nil
202   (funcallable-instance-header-widetag))
203
204 (!define-type-vops array-header-p nil nil nil
205   (simple-array-widetag complex-string-widetag complex-bit-vector-widetag
206                         complex-vector-widetag complex-array-widetag))
207
208 (!define-type-vops stringp check-string nil object-not-string-error
209   (simple-string-widetag complex-string-widetag))
210
211 (!define-type-vops bit-vector-p check-bit-vector nil
212     object-not-bit-vector-error
213   (simple-bit-vector-widetag complex-bit-vector-widetag))
214
215 (!define-type-vops vectorp check-vector nil object-not-vector-error
216   (simple-string-widetag
217    simple-bit-vector-widetag
218    simple-vector-widetag
219    simple-array-unsigned-byte-2-widetag
220    simple-array-unsigned-byte-4-widetag
221    simple-array-unsigned-byte-8-widetag
222    simple-array-unsigned-byte-16-widetag
223    simple-array-unsigned-byte-32-widetag
224    simple-array-signed-byte-8-widetag
225    simple-array-signed-byte-16-widetag
226    simple-array-signed-byte-30-widetag
227    simple-array-signed-byte-32-widetag
228    simple-array-single-float-widetag
229    simple-array-double-float-widetag
230    #!+long-float simple-array-long-float-widetag
231    simple-array-complex-single-float-widetag
232    simple-array-complex-double-float-widetag
233    #!+long-float simple-array-complex-long-float-widetag
234    complex-string-widetag
235    complex-bit-vector-widetag
236    complex-vector-widetag))
237
238 ;;; Note that this "type VOP" is sort of an oddball; it doesn't so
239 ;;; much test for a Lisp-level type as just expose a low-level type
240 ;;; code at the Lisp level. It is used as a building block to help us
241 ;;; to express things like the test for (TYPEP FOO '(VECTOR T))
242 ;;; efficiently in Lisp code, but it doesn't correspond to any type
243 ;;; expression which would actually occur in reasonable application
244 ;;; code. (Common Lisp doesn't have any natural way of expressing this
245 ;;; type.) Thus, there's no point in building up the full machinery of
246 ;;; associated backend type predicates and so forth as we do for
247 ;;; ordinary type VOPs.
248 (!define-type-vops complex-vector-p check-complex-vector nil
249     object-not-complex-vector-error
250   (complex-vector-widetag))
251
252 (!define-type-vops simple-array-p check-simple-array nil
253     object-not-simple-array-error
254   (simple-array-widetag
255    simple-string-widetag
256    simple-bit-vector-widetag
257    simple-vector-widetag
258    simple-array-unsigned-byte-2-widetag
259    simple-array-unsigned-byte-4-widetag
260    simple-array-unsigned-byte-8-widetag
261    simple-array-unsigned-byte-16-widetag
262    simple-array-unsigned-byte-32-widetag
263    simple-array-signed-byte-8-widetag
264    simple-array-signed-byte-16-widetag
265    simple-array-signed-byte-30-widetag
266    simple-array-signed-byte-32-widetag
267    simple-array-single-float-widetag
268    simple-array-double-float-widetag
269    #!+long-float simple-array-long-float-widetag
270    simple-array-complex-single-float-widetag
271    simple-array-complex-double-float-widetag
272    #!+long-float simple-array-complex-long-float-widetag))
273
274 (!define-type-vops arrayp check-array nil object-not-array-error
275   (simple-array-widetag
276    simple-string-widetag
277    simple-bit-vector-widetag
278    simple-vector-widetag
279    simple-array-unsigned-byte-2-widetag
280    simple-array-unsigned-byte-4-widetag
281    simple-array-unsigned-byte-8-widetag
282    simple-array-unsigned-byte-16-widetag
283    simple-array-unsigned-byte-32-widetag
284    simple-array-signed-byte-8-widetag
285    simple-array-signed-byte-16-widetag
286    simple-array-signed-byte-30-widetag
287    simple-array-signed-byte-32-widetag
288    simple-array-single-float-widetag
289    simple-array-double-float-widetag
290    #!+long-float simple-array-long-float-widetag
291    simple-array-complex-single-float-widetag
292    simple-array-complex-double-float-widetag
293    #!+long-float simple-array-complex-long-float-widetag
294    complex-string-widetag
295    complex-bit-vector-widetag
296    complex-vector-widetag
297    complex-array-widetag))
298
299 (!define-type-vops numberp check-number nil object-not-number-error
300   (even-fixnum-lowtag
301    odd-fixnum-lowtag
302    bignum-widetag
303    ratio-widetag
304    single-float-widetag
305    double-float-widetag
306    #!+long-float long-float-widetag
307    complex-widetag
308    complex-single-float-widetag
309    complex-double-float-widetag
310    #!+long-float complex-long-float-widetag))
311
312 (!define-type-vops rationalp check-rational nil object-not-rational-error
313   (even-fixnum-lowtag odd-fixnum-lowtag ratio-widetag bignum-widetag))
314
315 (!define-type-vops integerp check-integer nil object-not-integer-error
316   (even-fixnum-lowtag odd-fixnum-lowtag bignum-widetag))
317
318 (!define-type-vops floatp check-float nil object-not-float-error
319   (single-float-widetag double-float-widetag #!+long-float long-float-widetag))
320
321 (!define-type-vops realp check-real nil object-not-real-error
322   (even-fixnum-lowtag
323    odd-fixnum-lowtag
324    ratio-widetag
325    bignum-widetag
326    single-float-widetag
327    double-float-widetag
328    #!+long-float long-float-widetag))