Convert an expression to svex, maybe given a datatype that it needs to match.
(vl-expr-to-svex-maybe-typed x type ss scopes &key (compattype ':equiv)) → (mv vttree svex res-type res-size type-err)
Function:
(defun vl-expr-to-svex-maybe-typed-fn (x type ss scopes compattype) (declare (xargs :guard (and (vl-expr-p x) (vl-maybe-datatype-p type) (vl-scopestack-p ss) (vl-elabscopes-p scopes) (vl-typecompat-p compattype)))) (declare (xargs :guard (or (not type) (vl-datatype-resolved-p type)))) (let ((__function__ 'vl-expr-to-svex-maybe-typed)) (declare (ignorable __function__)) (b* ((type (vl-maybe-datatype-fix type))) (if type (b* (((mv vttree type-err svex) (vl-expr-to-svex-datatyped x nil type ss scopes :compattype compattype)) ((mv err size) (vl-datatype-size type)) ((when (or err (not size))) (mv (vwarn :type :vl-expr-to-svex-fail :msg "Datatype ~a0 for expression ~a1 couldn't be sized: ~@0" :args (list type (vl-expr-fix x) (or err "unsizable"))) svex (and (mbt (vl-datatype-resolved-p type)) type) nil type-err))) (mv vttree svex (and (mbt (vl-datatype-resolved-p type)) type) size type-err)) (b* (((mv vttree svex res-type res-size) (vl-expr-to-svex-untyped x ss scopes))) (mv vttree svex res-type res-size nil))))))
Theorem:
(defthm return-type-of-vl-expr-to-svex-maybe-typed.vttree (b* (((mv ?vttree ?svex ?res-type ?res-size ?type-err) (vl-expr-to-svex-maybe-typed-fn x type ss scopes compattype))) (and (vttree-p vttree) (sv::svarlist-addr-p (sv::constraintlist-vars (vttree->constraints vttree))))) :rule-classes :rewrite)
Theorem:
(defthm return-type-of-vl-expr-to-svex-maybe-typed.svex (b* (((mv ?vttree ?svex ?res-type ?res-size ?type-err) (vl-expr-to-svex-maybe-typed-fn x type ss scopes compattype))) (and (sv::svex-p svex) (sv::svarlist-addr-p (sv::svex-vars svex)))) :rule-classes :rewrite)
Theorem:
(defthm return-type-of-vl-expr-to-svex-maybe-typed.res-type (b* (((mv ?vttree ?svex ?res-type ?res-size ?type-err) (vl-expr-to-svex-maybe-typed-fn x type ss scopes compattype))) (and (vl-maybe-datatype-p res-type) (and (implies res-type (vl-datatype-resolved-p res-type))))) :rule-classes :rewrite)
Theorem:
(defthm maybe-natp-of-vl-expr-to-svex-maybe-typed.res-size (b* (((mv ?vttree ?svex ?res-type ?res-size ?type-err) (vl-expr-to-svex-maybe-typed-fn x type ss scopes compattype))) (maybe-natp res-size)) :rule-classes :type-prescription)
Theorem:
(defthm vl-maybe-type-error-p-of-vl-expr-to-svex-maybe-typed.type-err (b* (((mv ?vttree ?svex ?res-type ?res-size ?type-err) (vl-expr-to-svex-maybe-typed-fn x type ss scopes compattype))) (vl-maybe-type-error-p type-err)) :rule-classes :rewrite)
Theorem:
(defthm vl-expr-to-svex-maybe-typed-fn-of-vl-expr-fix-x (equal (vl-expr-to-svex-maybe-typed-fn (vl-expr-fix x) type ss scopes compattype) (vl-expr-to-svex-maybe-typed-fn x type ss scopes compattype)))
Theorem:
(defthm vl-expr-to-svex-maybe-typed-fn-vl-expr-equiv-congruence-on-x (implies (vl-expr-equiv x x-equiv) (equal (vl-expr-to-svex-maybe-typed-fn x type ss scopes compattype) (vl-expr-to-svex-maybe-typed-fn x-equiv type ss scopes compattype))) :rule-classes :congruence)
Theorem:
(defthm vl-expr-to-svex-maybe-typed-fn-of-vl-maybe-datatype-fix-type (equal (vl-expr-to-svex-maybe-typed-fn x (vl-maybe-datatype-fix type) ss scopes compattype) (vl-expr-to-svex-maybe-typed-fn x type ss scopes compattype)))
Theorem:
(defthm vl-expr-to-svex-maybe-typed-fn-vl-maybe-datatype-equiv-congruence-on-type (implies (vl-maybe-datatype-equiv type type-equiv) (equal (vl-expr-to-svex-maybe-typed-fn x type ss scopes compattype) (vl-expr-to-svex-maybe-typed-fn x type-equiv ss scopes compattype))) :rule-classes :congruence)
Theorem:
(defthm vl-expr-to-svex-maybe-typed-fn-of-vl-scopestack-fix-ss (equal (vl-expr-to-svex-maybe-typed-fn x type (vl-scopestack-fix ss) scopes compattype) (vl-expr-to-svex-maybe-typed-fn x type ss scopes compattype)))
Theorem:
(defthm vl-expr-to-svex-maybe-typed-fn-vl-scopestack-equiv-congruence-on-ss (implies (vl-scopestack-equiv ss ss-equiv) (equal (vl-expr-to-svex-maybe-typed-fn x type ss scopes compattype) (vl-expr-to-svex-maybe-typed-fn x type ss-equiv scopes compattype))) :rule-classes :congruence)
Theorem:
(defthm vl-expr-to-svex-maybe-typed-fn-of-vl-elabscopes-fix-scopes (equal (vl-expr-to-svex-maybe-typed-fn x type ss (vl-elabscopes-fix scopes) compattype) (vl-expr-to-svex-maybe-typed-fn x type ss scopes compattype)))
Theorem:
(defthm vl-expr-to-svex-maybe-typed-fn-vl-elabscopes-equiv-congruence-on-scopes (implies (vl-elabscopes-equiv scopes scopes-equiv) (equal (vl-expr-to-svex-maybe-typed-fn x type ss scopes compattype) (vl-expr-to-svex-maybe-typed-fn x type ss scopes-equiv compattype))) :rule-classes :congruence)
Theorem:
(defthm vl-expr-to-svex-maybe-typed-fn-of-vl-typecompat-fix-compattype (equal (vl-expr-to-svex-maybe-typed-fn x type ss scopes (vl-typecompat-fix compattype)) (vl-expr-to-svex-maybe-typed-fn x type ss scopes compattype)))
Theorem:
(defthm vl-expr-to-svex-maybe-typed-fn-vl-typecompat-equiv-congruence-on-compattype (implies (vl-typecompat-equiv compattype compattype-equiv) (equal (vl-expr-to-svex-maybe-typed-fn x type ss scopes compattype) (vl-expr-to-svex-maybe-typed-fn x type ss scopes compattype-equiv))) :rule-classes :congruence)