+
+;;; CASTs are merely continuation annotations than nodes. So we wait
+;;; until value consumer deside how values should be passed, and after
+;;; that we propagate this decision backwards through CAST chain. The
+;;; exception is a dangling CAST with a type check, which we process
+;;; immediately.
+(defun ltn-analyze-cast (cast)
+ (declare (type cast cast))
+ (setf (node-tail-p cast) nil)
+ (when (and (cast-type-check cast)
+ (not (continuation-dest (node-cont cast))))
+ ;; FIXME
+ (bug "IR2 type checking of unused values in not implemented.")
+ )
+ (values))
+
+(defun ltn-annotate-casts (cont)
+ (declare (type continuation cont))
+ (do-uses (node cont)
+ (when (cast-p node)
+ (ltn-annotate-cast node))))
+
+(defun ltn-annotate-cast (cast)
+ (declare (type cast))
+ (let ((2cont (continuation-info (node-cont cast)))
+ (value (cast-value cast)))
+ (aver 2cont)
+ ;; XXX
+ (ecase (ir2-continuation-kind 2cont)
+ (:unknown
+ (annotate-unknown-values-continuation value))
+ (:fixed
+ (let* ((count (length (ir2-continuation-locs 2cont)))
+ (ctype (continuation-derived-type value)))
+ (multiple-value-bind (types rest)
+ (values-type-types ctype (specifier-type 'null))
+ (annotate-fixed-values-continuation
+ value
+ (mapcar #'primitive-type
+ (adjust-list types count rest))))))))
+ (values))
+