cmp: allow specifying the type of vv

This will be useful for inline locations where we don't know the real value, but
we can infer the type.
This commit is contained in:
Daniel Kochmański 2023-12-06 09:19:52 +01:00
parent 7dc7bda980
commit f68c911ece
2 changed files with 10 additions and 9 deletions

View file

@ -23,21 +23,22 @@
;;; second pass the backend decides if the referenced object can be inlined, or
;;; if it needs to be put in the data segment and initialized at load-time.
(defstruct vv
(defstruct (vv (:constructor %make-vv))
(location nil)
(used-p nil)
(always nil) ; when true then vv is never optimized
(permanent-p t)
(value nil)
(type nil)
(host-type :object))
;;; When the value is the "empty location" then it was created to be filled
;;; later and the real type of the object is not known. See DATA-EMPTY-LOC.
(defun vv-type (loc)
(let ((value (vv-value loc)))
(if (eq value *empty-loc*)
t
(type-of value))))
(defun make-vv (&rest args &key location used-p always permanent-p value type host-type)
(declare (ignore location used-p always permanent-p host-type))
(unless type
;; When the value is the "empty location" then it was created to be filled
;; later and the real type of the object is not known. See DATA-EMPTY-LOC.
(setf type (if (eq value *empty-loc*) t (type-of value))))
(apply #'%make-vv :type type args))
(defun loc-movable-p (loc)
(if (atom loc)

View file

@ -53,7 +53,7 @@
(defun p1var (form var loc)
;; Use the type of C1FORM because it might have been coerced by a THE form.
(let* ((loc-type (if loc (object-type (vv-value loc)) t))
(let* ((loc-type (if loc (vv-type loc) t))
(var-type (var-type var))
(type (type-and (type-and loc-type var-type)
(c1form-primary-type form))))