Check an array index against the corresponding array bounds.
(vl-follow-hidexpr-dimcheck name index dim &key strictp) → err
In strict mode, we require that the
In non-strict mode, we tolerate unresolved indices and declaration bounds. Note that we still do bounds checking if the indices and array bounds happen to be resolved.
Function:
(defun vl-follow-hidexpr-dimcheck-fn (name index dim strictp) (declare (xargs :guard (and (stringp name) (vl-expr-p index) (vl-dimension-p dim) (booleanp strictp)))) (let ((__function__ 'vl-follow-hidexpr-dimcheck)) (declare (ignorable __function__)) (b* ((dim (vl-dimension-fix dim))) (vl-dimension-case dim (:unsized nil) (:star nil) (:datatype (if strictp (vmsg "unimplemented: check dimension against datatype-based associative dimension ~a0" dim) nil)) (:queue (if strictp (vmsg "unimplemented: check dimension against queue dimension ~a0" dim) nil)) (:range (b* (((unless (vl-expr-resolved-p index)) (if strictp (vmsg "unresolved array index") nil)) ((unless (vl-range-resolved-p dim.range)) (if strictp (vmsg "unresolved bounds on declaration of ~s0" (string-fix name)) nil)) (idxval (vl-resolved->val index)) (msbval (vl-resolved->val dim.msb)) (lsbval (vl-resolved->val dim.lsb)) (minval (min msbval lsbval)) (maxval (max msbval lsbval)) ((unless (and (<= minval idxval) (<= idxval maxval))) (vmsg "array index ~x0 out of bounds (~x1 to ~x2)" idxval minval maxval))) nil))))))
Theorem:
(defthm return-type-of-vl-follow-hidexpr-dimcheck (b* ((err (vl-follow-hidexpr-dimcheck-fn name index dim strictp))) (iff (vl-msg-p err) err)) :rule-classes :rewrite)
Theorem:
(defthm vl-follow-hidexpr-dimcheck-fn-of-str-fix-name (equal (vl-follow-hidexpr-dimcheck-fn (str-fix name) index dim strictp) (vl-follow-hidexpr-dimcheck-fn name index dim strictp)))
Theorem:
(defthm vl-follow-hidexpr-dimcheck-fn-streqv-congruence-on-name (implies (streqv name name-equiv) (equal (vl-follow-hidexpr-dimcheck-fn name index dim strictp) (vl-follow-hidexpr-dimcheck-fn name-equiv index dim strictp))) :rule-classes :congruence)
Theorem:
(defthm vl-follow-hidexpr-dimcheck-fn-of-vl-expr-fix-index (equal (vl-follow-hidexpr-dimcheck-fn name (vl-expr-fix index) dim strictp) (vl-follow-hidexpr-dimcheck-fn name index dim strictp)))
Theorem:
(defthm vl-follow-hidexpr-dimcheck-fn-vl-expr-equiv-congruence-on-index (implies (vl-expr-equiv index index-equiv) (equal (vl-follow-hidexpr-dimcheck-fn name index dim strictp) (vl-follow-hidexpr-dimcheck-fn name index-equiv dim strictp))) :rule-classes :congruence)
Theorem:
(defthm vl-follow-hidexpr-dimcheck-fn-of-vl-dimension-fix-dim (equal (vl-follow-hidexpr-dimcheck-fn name index (vl-dimension-fix dim) strictp) (vl-follow-hidexpr-dimcheck-fn name index dim strictp)))
Theorem:
(defthm vl-follow-hidexpr-dimcheck-fn-vl-dimension-equiv-congruence-on-dim (implies (vl-dimension-equiv dim dim-equiv) (equal (vl-follow-hidexpr-dimcheck-fn name index dim strictp) (vl-follow-hidexpr-dimcheck-fn name index dim-equiv strictp))) :rule-classes :congruence)
Theorem:
(defthm vl-follow-hidexpr-dimcheck-fn-of-bool-fix-strictp (equal (vl-follow-hidexpr-dimcheck-fn name index dim (acl2::bool-fix strictp)) (vl-follow-hidexpr-dimcheck-fn name index dim strictp)))
Theorem:
(defthm vl-follow-hidexpr-dimcheck-fn-iff-congruence-on-strictp (implies (iff strictp strictp-equiv) (equal (vl-follow-hidexpr-dimcheck-fn name index dim strictp) (vl-follow-hidexpr-dimcheck-fn name index dim strictp-equiv))) :rule-classes :congruence)