Optimize expressions throughout a module.
(vl-module-optimize x ss) → new-x
Function:
(defun vl-module-optimize (x ss) (declare (xargs :guard (and (vl-module-p x) (vl-scopestack-p ss)))) (let ((__function__ 'vl-module-optimize)) (declare (ignorable __function__)) (b* ((x (vl-module-fix x)) (ss (vl-scopestack-push x ss)) ((when (vl-module->hands-offp x)) x) ((mv modinsts-changedp modinsts) (vl-modinstlist-optimize (vl-module->modinsts x) ss)) ((mv gateinsts-changedp gateinsts) (vl-gateinstlist-optimize (vl-module->gateinsts x) ss)) ((mv assigns-changedp assigns) (vl-assignlist-optimize (vl-module->assigns x) ss))) (if (or modinsts-changedp gateinsts-changedp assigns-changedp) (change-vl-module x :modinsts modinsts :gateinsts gateinsts :assigns assigns) x))))
Theorem:
(defthm vl-module-p-of-vl-module-optimize (b* ((new-x (vl-module-optimize x ss))) (vl-module-p new-x)) :rule-classes :rewrite)
Theorem:
(defthm vl-module-optimize-of-vl-module-fix-x (equal (vl-module-optimize (vl-module-fix x) ss) (vl-module-optimize x ss)))
Theorem:
(defthm vl-module-optimize-vl-module-equiv-congruence-on-x (implies (vl-module-equiv x x-equiv) (equal (vl-module-optimize x ss) (vl-module-optimize x-equiv ss))) :rule-classes :congruence)
Theorem:
(defthm vl-module-optimize-of-vl-scopestack-fix-ss (equal (vl-module-optimize x (vl-scopestack-fix ss)) (vl-module-optimize x ss)))
Theorem:
(defthm vl-module-optimize-vl-scopestack-equiv-congruence-on-ss (implies (vl-scopestack-equiv ss ss-equiv) (equal (vl-module-optimize x ss) (vl-module-optimize x ss-equiv))) :rule-classes :congruence)