Propagate the final width and type of an expression into an identifier or HID.
(vl-hidexpr-expandsizes x finalwidth finaltype ss ctx warnings) → (mv successp warnings new-x)
Function:
(defun vl-hidexpr-expandsizes (x finalwidth finaltype ss ctx warnings) (declare (xargs :guard (and (vl-expr-p x) (natp finalwidth) (vl-exprtype-p finaltype) (vl-scopestack-p ss) (vl-context-p ctx) (vl-warninglist-p warnings)))) (let ((__function__ 'vl-hidexpr-expandsizes)) (declare (ignorable __function__)) (b* ((x (vl-expr-fix x)) (ctx (vl-context-fix ctx)) (finalwidth (lnfix finalwidth)) (finaltype (vl-exprtype-fix finaltype)) ((mv warnings origwidth) (vl-expr-selfsize x ss ctx warnings)) ((mv warnings origtype) (vl-expr-typedecide x ss ctx warnings)) ((unless (and origwidth origtype)) (mv nil (fatal :type :vl-programming-error :msg "~a0: expected to only try to expand sizes for atoms ~ whose sizes types can be successfully determined, ~ but we failed to determine the size or type of ~a1." :args (list ctx x)) x)) ((when (> origwidth finalwidth)) (mv nil (fatal :type :vl-programming-error :msg "~a0: origwidth > finalwidth when expanding ~a1. This ~ indicates a serious bug in our sizing code." :args (list ctx x)) x)) ((unless (or (eq origtype finaltype) (and (eq origtype :vl-signed) (eq finaltype :vl-unsigned)))) (mv nil (fatal :type :vl-programming-error :msg "~a0: origtype is ~s1 but finaltype is ~s2 when ~ expanding ~a3. This indicates a serious bug in our ~ typing code." :args (list ctx origtype finaltype x)) x)) (new-x (if (vl-fast-atom-p x) (change-vl-atom x :finalwidth finalwidth :finaltype finaltype) (change-vl-nonatom x :finalwidth finalwidth :finaltype finaltype)))) (mv t (ok) new-x))))
Theorem:
(defthm booleanp-of-vl-hidexpr-expandsizes.successp (b* (((mv ?successp ?warnings ?new-x) (vl-hidexpr-expandsizes x finalwidth finaltype ss ctx warnings))) (booleanp successp)) :rule-classes :type-prescription)
Theorem:
(defthm vl-warninglist-p-of-vl-hidexpr-expandsizes.warnings (b* (((mv ?successp ?warnings ?new-x) (vl-hidexpr-expandsizes x finalwidth finaltype ss ctx warnings))) (vl-warninglist-p warnings)) :rule-classes :rewrite)
Theorem:
(defthm vl-expr-p-of-vl-hidexpr-expandsizes.new-x (b* (((mv ?successp ?warnings ?new-x) (vl-hidexpr-expandsizes x finalwidth finaltype ss ctx warnings))) (vl-expr-p new-x)) :rule-classes :rewrite)
Theorem:
(defthm no-change-loserp-of-vl-hidexpr-expandsizes (let ((ret (vl-hidexpr-expandsizes x finalwidth finaltype ss ctx warnings))) (implies (not (mv-nth 0 ret)) (equal (mv-nth 2 ret) (vl-expr-fix x)))))
Theorem:
(defthm vl-expr-welltyped-p-of-vl-hidexpr-expandsizes (let ((ret (vl-hidexpr-expandsizes x finalwidth finaltype ss ctx warnings))) (implies (and (mv-nth 0 ret) (vl-idexpr-p x)) (vl-expr-welltyped-p (mv-nth 2 ret)))))
Theorem:
(defthm warning-irrelevance-of-vl-hidexpr-expandsizes (let ((ret1 (vl-hidexpr-expandsizes x finalwidth finaltype ss ctx warnings)) (ret2 (vl-hidexpr-expandsizes x finalwidth finaltype ss nil nil))) (implies (syntaxp (not (and (equal ctx ''nil) (equal warnings ''nil)))) (and (equal (mv-nth 0 ret1) (mv-nth 0 ret2)) (equal (mv-nth 2 ret1) (mv-nth 2 ret2))))))
Theorem:
(defthm vl-expr->finalwidth-of-vl-hidexpr-expandsizes (let ((ret (vl-hidexpr-expandsizes x finalwidth finaltype ss ctx warnings))) (implies (mv-nth 0 ret) (equal (vl-expr->finalwidth (mv-nth 2 ret)) (nfix finalwidth)))))
Theorem:
(defthm vl-expr->finaltype-of-vl-hidexpr-expandsizes (let ((ret (vl-hidexpr-expandsizes x finalwidth finaltype ss ctx warnings))) (implies (mv-nth 0 ret) (equal (vl-expr->finaltype (mv-nth 2 ret)) (vl-exprtype-fix finaltype)))))
Theorem:
(defthm vl-hidexpr-expandsizes-of-vl-expr-fix-x (equal (vl-hidexpr-expandsizes (vl-expr-fix x) finalwidth finaltype ss ctx warnings) (vl-hidexpr-expandsizes x finalwidth finaltype ss ctx warnings)))
Theorem:
(defthm vl-hidexpr-expandsizes-vl-expr-equiv-congruence-on-x (implies (vl-expr-equiv x x-equiv) (equal (vl-hidexpr-expandsizes x finalwidth finaltype ss ctx warnings) (vl-hidexpr-expandsizes x-equiv finalwidth finaltype ss ctx warnings))) :rule-classes :congruence)
Theorem:
(defthm vl-hidexpr-expandsizes-of-nfix-finalwidth (equal (vl-hidexpr-expandsizes x (nfix finalwidth) finaltype ss ctx warnings) (vl-hidexpr-expandsizes x finalwidth finaltype ss ctx warnings)))
Theorem:
(defthm vl-hidexpr-expandsizes-nat-equiv-congruence-on-finalwidth (implies (acl2::nat-equiv finalwidth finalwidth-equiv) (equal (vl-hidexpr-expandsizes x finalwidth finaltype ss ctx warnings) (vl-hidexpr-expandsizes x finalwidth-equiv finaltype ss ctx warnings))) :rule-classes :congruence)
Theorem:
(defthm vl-hidexpr-expandsizes-of-vl-exprtype-fix-finaltype (equal (vl-hidexpr-expandsizes x finalwidth (vl-exprtype-fix finaltype) ss ctx warnings) (vl-hidexpr-expandsizes x finalwidth finaltype ss ctx warnings)))
Theorem:
(defthm vl-hidexpr-expandsizes-vl-exprtype-equiv-congruence-on-finaltype (implies (vl-exprtype-equiv finaltype finaltype-equiv) (equal (vl-hidexpr-expandsizes x finalwidth finaltype ss ctx warnings) (vl-hidexpr-expandsizes x finalwidth finaltype-equiv ss ctx warnings))) :rule-classes :congruence)
Theorem:
(defthm vl-hidexpr-expandsizes-of-vl-scopestack-fix-ss (equal (vl-hidexpr-expandsizes x finalwidth finaltype (vl-scopestack-fix ss) ctx warnings) (vl-hidexpr-expandsizes x finalwidth finaltype ss ctx warnings)))
Theorem:
(defthm vl-hidexpr-expandsizes-vl-scopestack-equiv-congruence-on-ss (implies (vl-scopestack-equiv ss ss-equiv) (equal (vl-hidexpr-expandsizes x finalwidth finaltype ss ctx warnings) (vl-hidexpr-expandsizes x finalwidth finaltype ss-equiv ctx warnings))) :rule-classes :congruence)
Theorem:
(defthm vl-hidexpr-expandsizes-of-vl-context-fix-ctx (equal (vl-hidexpr-expandsizes x finalwidth finaltype ss (vl-context-fix ctx) warnings) (vl-hidexpr-expandsizes x finalwidth finaltype ss ctx warnings)))
Theorem:
(defthm vl-hidexpr-expandsizes-vl-context-equiv-congruence-on-ctx (implies (vl-context-equiv ctx ctx-equiv) (equal (vl-hidexpr-expandsizes x finalwidth finaltype ss ctx warnings) (vl-hidexpr-expandsizes x finalwidth finaltype ss ctx-equiv warnings))) :rule-classes :congruence)
Theorem:
(defthm vl-hidexpr-expandsizes-of-vl-warninglist-fix-warnings (equal (vl-hidexpr-expandsizes x finalwidth finaltype ss ctx (vl-warninglist-fix warnings)) (vl-hidexpr-expandsizes x finalwidth finaltype ss ctx warnings)))
Theorem:
(defthm vl-hidexpr-expandsizes-vl-warninglist-equiv-congruence-on-warnings (implies (vl-warninglist-equiv warnings warnings-equiv) (equal (vl-hidexpr-expandsizes x finalwidth finaltype ss ctx warnings) (vl-hidexpr-expandsizes x finalwidth finaltype ss ctx warnings-equiv))) :rule-classes :congruence)