Recognize certain special muxes.
We match expressions of the following forms:
1. (i1 === i2) ? i1 : (s ? i1 : i2) 2. (i1 === i2) ? i2 : (s ? i1 : i2) 3. (i1 === i2) ? i1 : (s ? i2 : i1) 4. (i1 === i2) ? i2 : (s ? i2 : i1)
Function:
(defun vl-goofymux-p (x) (declare (xargs :guard (vl-expr-p x))) (let ((__function__ 'vl-goofymux-p)) (declare (ignorable __function__)) (b* (((mv equiv i1 mux) (vl-qmark-p x)) ((unless equiv) (mv nil nil nil)) ((unless (and (not (vl-fast-atom-p equiv)) (eq (vl-nonatom->op equiv) :vl-binary-ceq))) (mv nil nil nil)) (i1-fix (vl-expr-strip i1)) (equiv-lhs (vl-expr-strip (first (vl-nonatom->args equiv)))) (equiv-rhs (vl-expr-strip (second (vl-nonatom->args equiv)))) ((unless (or (equal equiv-lhs i1-fix) (equal equiv-rhs i1-fix))) (mv nil nil nil)) ((mv sel mi1 mi2) (vl-qmark-p mux)) ((unless sel) (mv nil nil nil)) (mi1-fix (vl-expr-strip mi1)) (mi2-fix (vl-expr-strip mi2)) ((unless (or (and (equal equiv-lhs mi1-fix) (equal equiv-rhs mi2-fix)) (and (equal equiv-lhs mi2-fix) (equal equiv-rhs mi1-fix)))) (mv nil nil nil))) (mv sel mi1 mi2))))
Theorem:
(defthm return-type-of-vl-goofymux-p.s (b* (((mv ?s ?i1 ?i2) (vl-goofymux-p x))) (equal (vl-expr-p s) (if s t nil))) :rule-classes :rewrite)
Theorem:
(defthm return-type-of-vl-goofymux-p.i1 (b* (((mv ?s ?i1 ?i2) (vl-goofymux-p x))) (equal (vl-expr-p i1) (if s t nil))) :rule-classes :rewrite)
Theorem:
(defthm return-type-of-vl-goofymux-p.i2 (b* (((mv ?s ?i1 ?i2) (vl-goofymux-p x))) (equal (vl-expr-p i2) (if s t nil))) :rule-classes :rewrite)
Theorem:
(defthm vl-goofymux-p-of-vl-expr-fix-x (equal (vl-goofymux-p (vl-expr-fix x)) (vl-goofymux-p x)))
Theorem:
(defthm vl-goofymux-p-vl-expr-equiv-congruence-on-x (implies (vl-expr-equiv x x-equiv) (equal (vl-goofymux-p x) (vl-goofymux-p x-equiv))) :rule-classes :congruence)