Consolidate concatenations of constants.
(vl-merge-consts x) → new-x
(vl-merge-consts-aux x) returns
Startwidth is the width of the initial sequence of constants. If this initial sequence involves any bits which are Z or X, then weirdval is a vl-bitlist-p whose value is the same as the bits of this initial sequence, and startval is nil. Otherwise, weirdval is nil and startval is the value of the initial sequence. Rest is the remaining expressions, with constants consolidated.
Example: Suppose we have
STARTWIDTH = 6 ;; sum of widths of initial constants STARTVAL = 53 ;; hex 3a, value of concatenated initial constants WEIRDVAL = nil REST = { foo[4:3], 14'ha10 } ;; remaining exprs, constants consolidated
If we have
STARTWIDTH = 6 ;; sum of widths of initial constants STARTVAL = nil WEIRDVAL = bits 1x1010 REST = { foo[4:3], 14'ha10 } ;; remaining exprs, constants consolidated
Theorem:
(defthm return-type-of-vl-merge-consts.new-x (b* ((?new-x (vl-merge-consts x))) (vl-exprlist-p new-x)) :rule-classes :rewrite)
Theorem:
(defthm return-type-of-vl-merge-consts-aux.startwidth (b* (((mv ?startwidth ?startval ?weirdval common-lisp::?rest) (vl-merge-consts-aux x))) (natp startwidth)) :rule-classes :type-prescription)
Theorem:
(defthm return-type-of-vl-merge-consts-aux.startval (b* (((mv ?startwidth ?startval ?weirdval common-lisp::?rest) (vl-merge-consts-aux x))) (maybe-natp startval)) :rule-classes :type-prescription)
Theorem:
(defthm return-type-of-vl-merge-consts-aux.weirdval (b* (((mv ?startwidth ?startval ?weirdval common-lisp::?rest) (vl-merge-consts-aux x))) (vl-bitlist-p weirdval)) :rule-classes :rewrite)
Theorem:
(defthm return-type-of-vl-merge-consts-aux.rest (b* (((mv ?startwidth ?startval ?weirdval common-lisp::?rest) (vl-merge-consts-aux x))) (vl-exprlist-p rest)) :rule-classes :rewrite)
Theorem:
(defthm true-listp-of-vl-merge-consts-aux->exprs (true-listp (mv-nth 3 (vl-merge-consts-aux x))) :rule-classes :type-prescription)
Theorem:
(defthm true-listp-of-vl-merge-consts->exprs (true-listp (vl-merge-consts x)) :rule-classes :type-prescription)
Theorem:
(defthm vl-merge-consts-aux-invar (b* (((mv width val bits ?exprs) (vl-merge-consts-aux x))) (and (implies val (not bits)) (implies (not val) (equal (len bits) width)) (implies val (< val (expt 2 width))))))
Theorem:
(defthm vl-merge-consts-of-vl-exprlist-fix-x (equal (vl-merge-consts (vl-exprlist-fix x)) (vl-merge-consts x)))
Theorem:
(defthm vl-merge-consts-aux-of-vl-exprlist-fix-x (equal (vl-merge-consts-aux (vl-exprlist-fix x)) (vl-merge-consts-aux x)))
Theorem:
(defthm vl-merge-consts-vl-exprlist-equiv-congruence-on-x (implies (vl-exprlist-equiv x x-equiv) (equal (vl-merge-consts x) (vl-merge-consts x-equiv))) :rule-classes :congruence)
Theorem:
(defthm vl-merge-consts-aux-vl-exprlist-equiv-congruence-on-x (implies (vl-exprlist-equiv x x-equiv) (equal (vl-merge-consts-aux x) (vl-merge-consts-aux x-equiv))) :rule-classes :congruence)