Function:
(defun vl-datatype-field-shift-amount (x field) (declare (xargs :guard (and (vl-datatype-p x) (stringp field)))) (declare (xargs :guard (vl-datatype-resolved-p x))) (let ((__function__ 'vl-datatype-field-shift-amount)) (declare (ignorable __function__)) (b* ((field (string-fix field)) (x (vl-maybe-usertype-resolve x)) (udims (vl-datatype->udims x)) (pdims (vl-datatype->pdims x)) ((when (or (consp udims) (consp pdims))) (mv (vmsg "Can't select field ~s0 from datatype ~a1 because it has dimensions" field x) nil))) (vl-datatype-case x :vl-union (if (vl-find-structmember field x.members) (mv nil 0) (mv (vmsg "~s0 is not a member of ~a1" field x) nil)) :vl-struct (vl-structmemberlist-shift-bits (rev x.members) field) :otherwise (mv (vmsg "Can't select field ~s0 from non-struct/union datatype ~a1" field x) nil)))))
Theorem:
(defthm return-type-of-vl-datatype-field-shift-amount.err (b* (((mv ?err ?shift) (vl-datatype-field-shift-amount x field))) (iff (vl-msg-p err) err)) :rule-classes :rewrite)
Theorem:
(defthm return-type-of-vl-datatype-field-shift-amount.shift (b* (((mv ?err ?shift) (vl-datatype-field-shift-amount x field))) (implies (not err) (integerp shift))) :rule-classes :type-prescription)
Theorem:
(defthm vl-datatype-field-shift-amount-of-vl-datatype-fix-x (equal (vl-datatype-field-shift-amount (vl-datatype-fix x) field) (vl-datatype-field-shift-amount x field)))
Theorem:
(defthm vl-datatype-field-shift-amount-vl-datatype-equiv-congruence-on-x (implies (vl-datatype-equiv x x-equiv) (equal (vl-datatype-field-shift-amount x field) (vl-datatype-field-shift-amount x-equiv field))) :rule-classes :congruence)
Theorem:
(defthm vl-datatype-field-shift-amount-of-str-fix-field (equal (vl-datatype-field-shift-amount x (str-fix field)) (vl-datatype-field-shift-amount x field)))
Theorem:
(defthm vl-datatype-field-shift-amount-streqv-congruence-on-field (implies (streqv field field-equiv) (equal (vl-datatype-field-shift-amount x field) (vl-datatype-field-shift-amount x field-equiv))) :rule-classes :congruence)