- (when (operand-parse-target op)
- (unless (member (operand-parse-kind op) '(:argument :temporary))
- (error "cannot target a ~S operand: ~S" (operand-parse-kind op)
- (operand-parse-name op)))
- (let ((target (find-operand (operand-parse-target op) parse
- '(:temporary :result))))
- (targets (+ (* index max-vop-tn-refs)
- (ecase (operand-parse-kind target)
- (:result
- (+ (position-or-lose target
- (vop-parse-results parse))
- num-args))
- (:temporary
- (+ (* (position-or-lose target
- (vop-parse-temps parse))
- 2)
- num-args num-results)))))))
- (let ((born (operand-parse-born op))
- (dies (operand-parse-dies op)))
- (ecase (operand-parse-kind op)
- (:argument
- (refs (cons (cons dies nil) index)))
- (:more-argument
- (refs (cons (cons dies nil) index)))
- (:result
- (refs (cons (cons born t) index)))
- (:more-result
- (refs (cons (cons born t) index)))
- (:temporary
- (refs (cons (cons dies nil) index))
- (incf index)
- (refs (cons (cons born t) index))))
- (incf index)))
- (let* ((sorted (sort (refs)
- #'(lambda (x y)
- (let ((x-time (car x))
- (y-time (car y)))
- (if (time-spec-order x-time y-time)
- (if (time-spec-order y-time x-time)
- (and (not (cdr x)) (cdr y))
- nil)
- t)))
- :key #'car))
- (oe-type '(mod #.max-vop-tn-refs)) ; :REF-ORDERING element type
- (te-type '(mod #.(* max-vop-tn-refs 2))) ; :TARGETS element type
- (ordering (make-specializable-array
- (length sorted)
- :element-type oe-type)))
- (let ((index 0))
- (dolist (ref sorted)
- (setf (aref ordering index) (cdr ref))
- (incf index)))
- `(:num-args ,num-args
- :num-results ,num-results
- ;; KLUDGE: The (COERCE .. (SPECIALIZABLE-VECTOR ..)) wrapper
- ;; here around the result returned by
- ;; MAKE-SPECIALIZABLE-ARRAY above was of course added to
- ;; help with cross-compilation. "A sufficiently smart
- ;; compiler" should be able to optimize all this away in the
- ;; final target Lisp, leaving a single MAKE-ARRAY with no
- ;; subsequent coercion. However, I don't know whether Python
- ;; is that smart. (Can it figure out the return type of
- ;; MAKE-ARRAY? Does it know that COERCE can be optimized
- ;; away if the input type is known to be the same as the
- ;; COERCEd-to type?) At some point it would be good to test
- ;; to see whether this construct is in fact causing run-time
- ;; overhead, and fix it if so. (Some declarations of the
- ;; types returned by MAKE-ARRAY might be enough to fix it.)
- ;; However, it's probably not urgent to fix this, since it's
- ;; hard to imagine that any overhead caused by calling
- ;; COERCE and letting it decide to bail out could be large
- ;; compared to the cost of consing and GCing the vectors in
- ;; the first place. -- WHN ca. 19990701
- :ref-ordering (coerce ',ordering
- '(specializable-vector ,oe-type))
- ,@(when (targets)
- `(:targets (coerce ',(targets)
- '(specializable-vector ,te-type)))))))))
+ (when (operand-parse-target op)
+ (unless (member (operand-parse-kind op) '(:argument :temporary))
+ (error "cannot target a ~S operand: ~S" (operand-parse-kind op)
+ (operand-parse-name op)))
+ (let ((target (find-operand (operand-parse-target op) parse
+ '(:temporary :result))))
+ ;; KLUDGE: These formulas must be consistent with those in
+ ;; %EMIT-GENERIC-VOP, and this is currently maintained by
+ ;; hand. -- WHN 2002-01-30, paraphrasing APD
+ (targets (+ (* index max-vop-tn-refs)
+ (ecase (operand-parse-kind target)
+ (:result
+ (+ (position-or-lose target
+ (vop-parse-results parse))
+ num-args))
+ (:temporary
+ (+ (* (position-or-lose target
+ (vop-parse-temps parse))
+ 2)
+ 1
+ num-args
+ num-results)))))))
+ (let ((born (operand-parse-born op))
+ (dies (operand-parse-dies op)))
+ (ecase (operand-parse-kind op)
+ (:argument
+ (refs (cons (cons dies nil) index)))
+ (:more-argument
+ (refs (cons (cons dies nil) index)))
+ (:result
+ (refs (cons (cons born t) index)))
+ (:more-result
+ (refs (cons (cons born t) index)))
+ (:temporary
+ (refs (cons (cons dies nil) index))
+ (incf index)
+ (refs (cons (cons born t) index))))
+ (incf index)))
+ (let* ((sorted (stable-sort (refs)
+ (lambda (x y)
+ (let ((x-time (car x))
+ (y-time (car y)))
+ (if (time-spec-order x-time y-time)
+ (if (time-spec-order y-time x-time)
+ (and (not (cdr x)) (cdr y))
+ nil)
+ t)))
+ :key #'car))
+ ;; :REF-ORDERING element type
+ ;;
+ ;; KLUDGE: was (MOD #.MAX-VOP-TN-REFS), which is still right
+ (oe-type '(unsigned-byte 8))
+ ;; :TARGETS element-type
+ ;;
+ ;; KLUDGE: was (MOD #.(* MAX-VOP-TN-REFS 2)), which does
+ ;; not correspond to the definition in
+ ;; src/compiler/vop.lisp.
+ (te-type '(unsigned-byte 16))
+ (ordering (make-specializable-array
+ (length sorted)
+ :element-type oe-type)))
+ (let ((index 0))
+ (dolist (ref sorted)
+ (setf (aref ordering index) (cdr ref))
+ (incf index)))
+ `(:num-args ,num-args
+ :num-results ,num-results
+ ;; KLUDGE: see the comment regarding MAKE-ARRAY in
+ ;; COMPUTE-TEMPORARIES-DESCRIPTION. -- CSR, 2009-10-30
+ :ref-ordering (make-array ,(length ordering)
+ :initial-contents ',ordering
+ :element-type '(specializable ,oe-type))
+ ,@(when (targets)
+ `(:targets (make-array ,(length (targets))
+ :initial-contents ',(targets)
+ :element-type '(specializable ,te-type)))))))))