0.pre7.3:
[sbcl.git] / src / compiler / typetran.lisp
1 ;;;; This file contains stuff that implements the portable IR1
2 ;;;; semantics of type tests and coercion. The main thing we do is
3 ;;;; convert complex type operations into simpler code that can be
4 ;;;; compiled inline.
5
6 ;;;; This software is part of the SBCL system. See the README file for
7 ;;;; more information.
8 ;;;;
9 ;;;; This software is derived from the CMU CL system, which was
10 ;;;; written at Carnegie Mellon University and released into the
11 ;;;; public domain. The software is in the public domain and is
12 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
13 ;;;; files for more information.
14
15 ;;; FIXME: Many of the functions in this file could probably be
16 ;;; byte-compiled, since they're one-pass, cons-heavy code.
17
18 (in-package "SB!C")
19 \f
20 ;;;; type predicate translation
21 ;;;;
22 ;;;; We maintain a bidirectional association between type predicates
23 ;;;; and the tested type. The presence of a predicate in this
24 ;;;; association implies that it is desirable to implement tests of
25 ;;;; this type using the predicate. These are either predicates that
26 ;;;; the back end is likely to have special knowledge about, or
27 ;;;; predicates so complex that the only reasonable implentation is
28 ;;;; via function call.
29 ;;;;
30 ;;;; Some standard types (such as SEQUENCE) are best tested by letting
31 ;;;; the TYPEP source transform do its thing with the expansion. These
32 ;;;; types (and corresponding predicates) are not maintained in this
33 ;;;; association. In this case, there need not be any predicate
34 ;;;; function unless it is required by the Common Lisp specification.
35 ;;;;
36 ;;;; The mapping between predicates and type structures is considered
37 ;;;; part of the backend; different backends can support different
38 ;;;; sets of predicates.
39
40 ;;; Establish an association between the type predicate NAME and the
41 ;;; corresponding TYPE. This causes the type predicate to be
42 ;;; recognized for purposes of optimization.
43 (defmacro define-type-predicate (name type)
44   `(%define-type-predicate ',name ',type))
45 (defun %define-type-predicate (name specifier)
46   (let ((type (specifier-type specifier)))
47     (setf (gethash name *backend-predicate-types*) type)
48     (setf *backend-type-predicates*
49           (cons (cons type name)
50                 (remove name *backend-type-predicates*
51                         :key #'cdr)))
52     (%deftransform name '(function (t) *) #'fold-type-predicate)
53     name))
54 \f
55 ;;;; IR1 transforms
56
57 ;;; If we discover the type argument is constant during IR1
58 ;;; optimization, then give the source transform another chance. The
59 ;;; source transform can't pass, since we give it an explicit
60 ;;; constant. At worst, it will convert to %TYPEP, which will prevent
61 ;;; spurious attempts at transformation (and possible repeated
62 ;;; warnings.)
63 (deftransform typep ((object type))
64   (unless (constant-continuation-p type)
65     (give-up-ir1-transform "can't open-code test of non-constant type"))
66   `(typep object ',(continuation-value type)))
67
68 ;;; If the continuation OBJECT definitely is or isn't of the specified
69 ;;; type, then return T or NIL as appropriate. Otherwise quietly
70 ;;; GIVE-UP-IR1-TRANSFORM.
71 (defun ir1-transform-type-predicate (object type)
72   (declare (type continuation object) (type ctype type))
73   (let ((otype (continuation-type object)))
74     (cond ((not (types-equal-or-intersect otype type))
75            nil)
76           ((csubtypep otype type)
77            t)
78           (t
79            (give-up-ir1-transform)))))
80
81 ;;; Flush %TYPEP tests whose result is known at compile time.
82 (deftransform %typep ((object type))
83   (unless (constant-continuation-p type) (give-up-ir1-transform))
84   (ir1-transform-type-predicate
85    object
86    (specifier-type (continuation-value type))))
87
88 ;;; This is the IR1 transform for simple type predicates. It checks
89 ;;; whether the single argument is known to (not) be of the
90 ;;; appropriate type, expanding to T or NIL as appropriate.
91 (deftransform fold-type-predicate ((object) * * :node node :defun-only t)
92   (let ((ctype (gethash (leaf-name
93                          (ref-leaf
94                           (continuation-use
95                            (basic-combination-fun node))))
96                         *backend-predicate-types*)))
97     (aver ctype)
98     (ir1-transform-type-predicate object ctype)))
99
100 ;;; If FIND-CLASS is called on a constant class, locate the CLASS-CELL
101 ;;; at load time.
102 (deftransform find-class ((name) ((constant-argument symbol)) *
103                           :when :both)
104   (let* ((name (continuation-value name))
105          (cell (find-class-cell name)))
106     `(or (class-cell-class ',cell)
107          (error "class not yet defined: ~S" name))))
108 \f
109 ;;;; standard type predicates, i.e. those defined in package COMMON-LISP,
110 ;;;; plus at least one oddball (%INSTANCEP)
111 ;;;;
112 ;;;; Various other type predicates (e.g. low-level representation
113 ;;;; stuff like SIMPLE-ARRAY-SINGLE-FLOAT-P) are defined elsewhere.
114
115 ;;; FIXME: This function is only called once, at top level. Why not
116 ;;; just expand all its operations into toplevel code?
117 (defun !define-standard-type-predicates ()
118   (define-type-predicate arrayp array)
119   ; (The ATOM predicate is handled separately as (NOT CONS).)
120   (define-type-predicate bit-vector-p bit-vector)
121   (define-type-predicate characterp character)
122   (define-type-predicate compiled-function-p compiled-function)
123   (define-type-predicate complexp complex)
124   (define-type-predicate complex-rational-p (complex rational))
125   (define-type-predicate complex-float-p (complex float))
126   (define-type-predicate consp cons)
127   (define-type-predicate floatp float)
128   (define-type-predicate functionp function)
129   (define-type-predicate integerp integer)
130   (define-type-predicate keywordp keyword)
131   (define-type-predicate listp list)
132   (define-type-predicate null null)
133   (define-type-predicate numberp number)
134   (define-type-predicate rationalp rational)
135   (define-type-predicate realp real)
136   (define-type-predicate simple-bit-vector-p simple-bit-vector)
137   (define-type-predicate simple-string-p simple-string)
138   (define-type-predicate simple-vector-p simple-vector)
139   (define-type-predicate stringp string)
140   (define-type-predicate %instancep instance)
141   (define-type-predicate funcallable-instance-p funcallable-instance)
142   (define-type-predicate symbolp symbol)
143   (define-type-predicate vectorp vector))
144 (!define-standard-type-predicates)
145 \f
146 ;;;; transforms for type predicates not implemented primitively
147 ;;;;
148 ;;;; See also VM dependent transforms.
149
150 (def-source-transform atom (x)
151   `(not (consp ,x)))
152 \f
153 ;;;; TYPEP source transform
154
155 ;;; Return a form that tests the variable N-OBJECT for being in the
156 ;;; binds specified by TYPE. BASE is the name of the base type, for
157 ;;; declaration. We make SAFETY locally 0 to inhibit any checking of
158 ;;; this assertion.
159 #!-negative-zero-is-not-zero
160 (defun transform-numeric-bound-test (n-object type base)
161   (declare (type numeric-type type))
162   (let ((low (numeric-type-low type))
163         (high (numeric-type-high type)))
164     `(locally
165        (declare (optimize (safety 0)))
166        (and ,@(when low
167                 (if (consp low)
168                     `((> (the ,base ,n-object) ,(car low)))
169                     `((>= (the ,base ,n-object) ,low))))
170             ,@(when high
171                 (if (consp high)
172                     `((< (the ,base ,n-object) ,(car high)))
173                     `((<= (the ,base ,n-object) ,high))))))))
174
175 #!+negative-zero-is-not-zero
176 (defun transform-numeric-bound-test (n-object type base)
177   (declare (type numeric-type type))
178   (let ((low (numeric-type-low type))
179         (high (numeric-type-high type))
180         (float-type-p (csubtypep type (specifier-type 'float)))
181         (x (gensym))
182         (y (gensym)))
183     `(locally
184        (declare (optimize (safety 0)))
185        (and ,@(when low
186                 (if (consp low)
187                     `((let ((,x (the ,base ,n-object))
188                             (,y ,(car low)))
189                         ,(if (not float-type-p)
190                             `(> ,x ,y)
191                             `(if (and (zerop ,x) (zerop ,y))
192                                  (> (float-sign ,x) (float-sign ,y))
193                                  (> ,x ,y)))))
194                     `((let ((,x (the ,base ,n-object))
195                             (,y ,low))
196                         ,(if (not float-type-p)
197                             `(>= ,x ,y)
198                             `(if (and (zerop ,x) (zerop ,y))
199                                  (>= (float-sign ,x) (float-sign ,y))
200                                  (>= ,x ,y)))))))
201             ,@(when high
202                 (if (consp high)
203                     `((let ((,x (the ,base ,n-object))
204                             (,y ,(car high)))
205                         ,(if (not float-type-p)
206                              `(< ,x ,y)
207                              `(if (and (zerop ,x) (zerop ,y))
208                                   (< (float-sign ,x) (float-sign ,y))
209                                   (< ,x ,y)))))
210                     `((let ((,x (the ,base ,n-object))
211                             (,y ,high))
212                         ,(if (not float-type-p)
213                              `(<= ,x ,y)
214                              `(if (and (zerop ,x) (zerop ,y))
215                                   (<= (float-sign ,x) (float-sign ,y))
216                                   (<= ,x ,y)))))))))))
217
218 ;;; Do source transformation of a test of a known numeric type. We can
219 ;;; assume that the type doesn't have a corresponding predicate, since
220 ;;; those types have already been picked off. In particular, CLASS
221 ;;; must be specified, since it is unspecified only in NUMBER and
222 ;;; COMPLEX. Similarly, we assume that COMPLEXP is always specified.
223 ;;;
224 ;;; For non-complex types, we just test that the number belongs to the
225 ;;; base type, and then test that it is in bounds. When CLASS is
226 ;;; INTEGER, we check to see whether the range is no bigger than
227 ;;; FIXNUM. If so, we check for FIXNUM instead of INTEGER. This allows
228 ;;; us to use fixnum comparison to test the bounds.
229 ;;;
230 ;;; For complex types, we must test for complex, then do the above on
231 ;;; both the real and imaginary parts. When CLASS is float, we need
232 ;;; only check the type of the realpart, since the format of the
233 ;;; realpart and the imagpart must be the same.
234 (defun source-transform-numeric-typep (object type)
235   (let* ((class (numeric-type-class type))
236          (base (ecase class
237                  (integer (containing-integer-type type))
238                  (rational 'rational)
239                  (float (or (numeric-type-format type) 'float))
240                  ((nil) 'real))))
241     (once-only ((n-object object))
242       (ecase (numeric-type-complexp type)
243         (:real
244          `(and (typep ,n-object ',base)
245                ,(transform-numeric-bound-test n-object type base)))
246         (:complex
247          `(and (complexp ,n-object)
248                ,(once-only ((n-real `(realpart (the complex ,n-object)))
249                             (n-imag `(imagpart (the complex ,n-object))))
250                   `(progn
251                      ,n-imag ; ignorable
252                      (and (typep ,n-real ',base)
253                           ,@(when (eq class 'integer)
254                               `((typep ,n-imag ',base)))
255                           ,(transform-numeric-bound-test n-real type base)
256                           ,(transform-numeric-bound-test n-imag type
257                                                          base))))))))))
258
259 ;;; Do the source transformation for a test of a hairy type. AND,
260 ;;; SATISFIES and NOT are converted into the obvious code. We convert
261 ;;; unknown types to %TYPEP, emitting an efficiency note if
262 ;;; appropriate.
263 (defun source-transform-hairy-typep (object type)
264   (declare (type hairy-type type))
265   (let ((spec (hairy-type-specifier type)))
266     (cond ((unknown-type-p type)
267            (when (policy *lexenv* (> speed inhibit-warnings))
268              (compiler-note "can't open-code test of unknown type ~S"
269                             (type-specifier type)))
270            `(%typep ,object ',spec))
271           (t
272            (ecase (first spec)
273              (satisfies `(if (funcall #',(second spec) ,object) t nil))
274              ((not and)
275               (once-only ((n-obj object))
276                 `(,(first spec) ,@(mapcar #'(lambda (x)
277                                               `(typep ,n-obj ',x))
278                                           (rest spec))))))))))
279
280 ;;; Do source transformation for TYPEP of a known union type. If a
281 ;;; union type contains LIST, then we pull that out and make it into a
282 ;;; single LISTP call. Note that if SYMBOL is in the union, then LIST
283 ;;; will be a subtype even without there being any (member NIL). We
284 ;;; just drop through to the general code in this case, rather than
285 ;;; trying to optimize it.
286 (defun source-transform-union-typep (object type)
287   (let* ((types (union-type-types type))
288          (ltype (specifier-type 'list))
289          (mtype (find-if #'member-type-p types)))
290     (if (and mtype (csubtypep ltype type))
291         (let ((members (member-type-members mtype)))
292           (once-only ((n-obj object))
293             `(or (listp ,n-obj)
294                  (typep ,n-obj
295                         '(or ,@(mapcar #'type-specifier
296                                        (remove (specifier-type 'cons)
297                                                (remove mtype types)))
298                              (member ,@(remove nil members)))))))
299         (once-only ((n-obj object))
300           `(or ,@(mapcar (lambda (x)
301                            `(typep ,n-obj ',(type-specifier x)))
302                          types))))))
303
304 ;;; Do source transformation for TYPEP of a known intersection type.
305 (defun source-transform-intersection-typep (object type)
306   (once-only ((n-obj object))
307     `(and ,@(mapcar (lambda (x)
308                       `(typep ,n-obj ',(type-specifier x)))
309                     (intersection-type-types type)))))
310
311 ;;; If necessary recurse to check the cons type.
312 (defun source-transform-cons-typep (object type)
313   (let* ((car-type (cons-type-car-type type))
314          (cdr-type (cons-type-cdr-type type)))
315     (let ((car-test-p (not (or (type= car-type *wild-type*)
316                                (type= car-type (specifier-type t)))))
317           (cdr-test-p (not (or (type= cdr-type *wild-type*)
318                                (type= cdr-type (specifier-type t))))))
319       (if (and (not car-test-p) (not cdr-test-p))
320           `(consp ,object)
321           (once-only ((n-obj object))
322             `(and (consp ,n-obj)
323                   ,@(if car-test-p
324                         `((typep (car ,n-obj)
325                                  ',(type-specifier car-type))))
326                   ,@(if cdr-test-p
327                         `((typep (cdr ,n-obj)
328                                  ',(type-specifier cdr-type))))))))))
329  
330 ;;; Return the predicate and type from the most specific entry in
331 ;;; *TYPE-PREDICATES* that is a supertype of TYPE.
332 (defun find-supertype-predicate (type)
333   (declare (type ctype type))
334   (let ((res nil)
335         (res-type nil))
336     (dolist (x *backend-type-predicates*)
337       (let ((stype (car x)))
338         (when (and (csubtypep type stype)
339                    (or (not res-type)
340                        (csubtypep stype res-type)))
341           (setq res-type stype)
342           (setq res (cdr x)))))
343     (values res res-type)))
344
345 ;;; Return forms to test that OBJ has the rank and dimensions
346 ;;; specified by TYPE, where STYPE is the type we have checked against
347 ;;; (which is the same but for dimensions.)
348 (defun test-array-dimensions (obj type stype)
349   (declare (type array-type type stype))
350   (let ((obj `(truly-the ,(type-specifier stype) ,obj))
351         (dims (array-type-dimensions type)))
352     (unless (eq dims '*)
353       (collect ((res))
354         (when (eq (array-type-dimensions stype) '*)
355           (res `(= (array-rank ,obj) ,(length dims))))
356         (do ((i 0 (1+ i))
357              (dim dims (cdr dim)))
358             ((null dim))
359           (let ((dim (car dim)))
360             (unless (eq dim '*)
361               (res `(= (array-dimension ,obj ,i) ,dim)))))
362         (res)))))
363
364 ;;; If we can find a type predicate that tests for the type without
365 ;;; dimensions, then use that predicate and test for dimensions.
366 ;;; Otherwise, just do %TYPEP.
367 (defun source-transform-array-typep (obj type)
368   (multiple-value-bind (pred stype) (find-supertype-predicate type)
369     (if (and (array-type-p stype)
370              ;; (If the element type hasn't been defined yet, it's
371              ;; not safe to assume here that it will eventually
372              ;; have (UPGRADED-ARRAY-ELEMENT-TYPE type)=T, so punt.)
373              (not (unknown-type-p (array-type-element-type type)))
374              (type= (array-type-specialized-element-type stype)
375                     (array-type-specialized-element-type type))
376              (eq (array-type-complexp stype) (array-type-complexp type)))
377         (once-only ((n-obj obj))
378           `(and (,pred ,n-obj)
379                 ,@(test-array-dimensions n-obj type stype)))
380         `(%typep ,obj ',(type-specifier type)))))
381
382 ;;; Transform a type test against some instance type. The type test is
383 ;;; flushed if the result is known at compile time. If not properly
384 ;;; named, error. If sealed and has no subclasses, just test for
385 ;;; layout-EQ. If a structure then test for layout-EQ and then a
386 ;;; general test based on layout-inherits. If safety is important,
387 ;;; then we also check whether the layout for the object is invalid
388 ;;; and signal an error if so. Otherwise, look up the indirect
389 ;;; class-cell and call CLASS-CELL-TYPEP at runtime.
390 ;;;
391 ;;; KLUDGE: The :WHEN :BOTH option here is probably a suboptimal
392 ;;; solution to the problem of %INSTANCE-TYPEP forms in byte compiled
393 ;;; code; it'd probably be better just to have %INSTANCE-TYPEP forms
394 ;;; never be generated in byte compiled code, or maybe to have a DEFUN
395 ;;; %INSTANCE-TYPEP somewhere to handle them if they are. But it's not
396 ;;; terribly important because mostly, %INSTANCE-TYPEP forms *aren't*
397 ;;; generated in byte compiled code. (As of sbcl-0.6.5, they could
398 ;;; sometimes be generated when byte compiling inline functions, but
399 ;;; it's quite uncommon.) -- WHN 20000523
400 (deftransform %instance-typep ((object spec) (* *) * :node node :when :both)
401   (aver (constant-continuation-p spec))
402   (let* ((spec (continuation-value spec))
403          (class (specifier-type spec))
404          (name (sb!xc:class-name class))
405          (otype (continuation-type object))
406          (layout (let ((res (info :type :compiler-layout name)))
407                    (if (and res (not (layout-invalid res)))
408                        res
409                        nil))))
410     (cond
411       ;; Flush tests whose result is known at compile time.
412       ((not (types-equal-or-intersect otype class))
413        nil)
414       ((csubtypep otype class)
415        t)
416       ;; If not properly named, error.
417       ((not (and name (eq (sb!xc:find-class name) class)))
418        (compiler-error "can't compile TYPEP of anonymous or undefined ~
419                         class:~%  ~S"
420                        class))
421       (t
422         ;; Delay the type transform to give type propagation a chance.
423         (delay-ir1-transform node :constraint)
424
425        ;; Otherwise transform the type test.
426        (multiple-value-bind (pred get-layout)
427            (cond
428              ((csubtypep class (specifier-type 'funcallable-instance))
429               (values 'funcallable-instance-p '%funcallable-instance-layout))
430              ((csubtypep class (specifier-type 'instance))
431               (values '%instancep '%instance-layout))
432              (t
433               (values '(lambda (x) (declare (ignore x)) t) 'layout-of)))
434          (cond
435            ((and (eq (class-state class) :sealed) layout
436                  (not (class-subclasses class)))
437             ;; Sealed and has no subclasses.
438             (let ((n-layout (gensym)))
439               `(and (,pred object)
440                     (let ((,n-layout (,get-layout object)))
441                       ,@(when (policy *lexenv* (>= safety speed))
442                               `((when (layout-invalid ,n-layout)
443                                   (%layout-invalid-error object ',layout))))
444                       (eq ,n-layout ',layout)))))
445            ((and (typep class 'basic-structure-class) layout)
446             ;; structure type tests; hierarchical layout depths
447             (let ((depthoid (layout-depthoid layout))
448                   (n-layout (gensym)))
449               `(and (,pred object)
450                     (let ((,n-layout (,get-layout object)))
451                       ,@(when (policy *lexenv* (>= safety speed))
452                               `((when (layout-invalid ,n-layout)
453                                   (%layout-invalid-error object ',layout))))
454                       (if (eq ,n-layout ',layout)
455                           t
456                           (and (> (layout-depthoid ,n-layout)
457                                   ,depthoid)
458                                (locally (declare (optimize (safety 0)))
459                                  (eq (svref (layout-inherits ,n-layout)
460                                             ,depthoid)
461                                      ',layout))))))))
462            ((and layout (>= (layout-depthoid layout) 0))
463             ;; hierarchical layout depths for other things (e.g.
464             ;; CONDITIONs)
465             (let ((depthoid (layout-depthoid layout))
466                   (n-layout (gensym))
467                   (n-inherits (gensym)))
468               `(and (,pred object)
469                     (let ((,n-layout (,get-layout object)))
470                       ,@(when (policy *lexenv* (>= safety speed))
471                           `((when (layout-invalid ,n-layout)
472                               (%layout-invalid-error object ',layout))))
473                       (if (eq ,n-layout ',layout)
474                           t
475                           (let ((,n-inherits (layout-inherits ,n-layout)))
476                             (declare (optimize (safety 0)))
477                             (and (> (length ,n-inherits) ,depthoid)
478                                  (eq (svref ,n-inherits ,depthoid)
479                                      ',layout))))))))
480            (t
481             (/noshow "default case -- ,PRED and CLASS-CELL-TYPEP")
482             `(and (,pred object)
483                   (class-cell-typep (,get-layout object)
484                                     ',(find-class-cell name)
485                                     object)))))))))
486
487 ;;; If the specifier argument is a quoted constant, then we consider
488 ;;; converting into a simple predicate or other stuff. If the type is
489 ;;; constant, but we can't transform the call, then we convert to
490 ;;; %TYPEP. We only pass when the type is non-constant. This allows us
491 ;;; to recognize between calls that might later be transformed
492 ;;; successfully when a constant type is discovered. We don't give an
493 ;;; efficiency note when we pass, since the IR1 transform will give
494 ;;; one if necessary and appropriate.
495 ;;;
496 ;;; If the type is TYPE= to a type that has a predicate, then expand
497 ;;; to that predicate. Otherwise, we dispatch off of the type's type.
498 ;;; These transformations can increase space, but it is hard to tell
499 ;;; when, so we ignore policy and always do them. When byte-compiling,
500 ;;; we only do transforms that have potential for control
501 ;;; simplification. Instance type tests are converted to
502 ;;; %INSTANCE-TYPEP to allow type propagation.
503 (def-source-transform typep (object spec)
504   ;; KLUDGE: It looks bad to only do this on explicitly quoted forms,
505   ;; since that would overlook other kinds of constants. But it turns
506   ;; out that the DEFTRANSFORM for TYPEP detects any constant
507   ;; continuation, transforms it into a quoted form, and gives this
508   ;; source transform another chance, so it all works out OK, in a
509   ;; weird roundabout way. -- WHN 2001-03-18
510   (if (and (consp spec) (eq (car spec) 'quote))
511       (let ((type (specifier-type (cadr spec))))
512         (or (let ((pred (cdr (assoc type *backend-type-predicates*
513                                     :test #'type=))))
514               (when pred `(,pred ,object)))
515             (typecase type
516               (hairy-type
517                (source-transform-hairy-typep object type))
518               (union-type
519                (source-transform-union-typep object type))
520               (intersection-type
521                (source-transform-intersection-typep object type))
522               (member-type
523                `(member ,object ',(member-type-members type)))
524               (args-type
525                (compiler-warning "illegal type specifier for TYPEP: ~S"
526                                  (cadr spec))
527                `(%typep ,object ,spec))
528               (t nil))
529             (and (not (byte-compiling))
530                  (typecase type
531                    (numeric-type
532                     (source-transform-numeric-typep object type))
533                    (sb!xc:class
534                     `(%instance-typep ,object ,spec))
535                    (array-type
536                     (source-transform-array-typep object type))
537                    (cons-type
538                     (source-transform-cons-typep object type))
539                    (t nil)))
540             `(%typep ,object ,spec)))
541       (values nil t)))
542 \f
543 ;;;; coercion
544
545 (deftransform coerce ((x type) (* *) * :when :both)
546   (unless (constant-continuation-p type)
547     (give-up-ir1-transform))
548   (let ((tspec (specifier-type (continuation-value type))))
549     (if (csubtypep (continuation-type x) tspec)
550         'x
551         ;; Note: The THE here makes sure that specifiers like
552         ;; (SINGLE-FLOAT 0.0 1.0) can raise a TYPE-ERROR.
553         `(the ,(continuation-value type)
554            ,(cond
555              ((csubtypep tspec (specifier-type 'double-float))
556               '(%double-float x))       
557              ;; FIXME: #!+long-float (t ,(error "LONG-FLOAT case needed"))
558              ((csubtypep tspec (specifier-type 'float))
559               '(%single-float x))
560              ((csubtypep tspec (specifier-type 'simple-vector))
561               '(coerce-to-simple-vector x))
562              (t
563               (give-up-ir1-transform)))))))
564