Writing user rflags (CF, PF, AF, ZF, SF, and OF), including undefined ones, to the x86 state
(write-user-rflags user-flags-vector undefined-mask x86) → x86
We set the undefined flags, which are indicated by
Function:
(defun write-user-rflags$inline (user-flags-vector undefined-mask x86) (declare (xargs :stobjs (x86))) (declare (type (unsigned-byte 32) user-flags-vector) (type (unsigned-byte 32) undefined-mask)) (b* ((user-flags-vector (mbe :logic (n32 user-flags-vector) :exec user-flags-vector)) (undefined-mask (mbe :logic (n32 undefined-mask) :exec undefined-mask)) ((the (unsigned-byte 32) input-rflags) (mbe :logic (n32 (rflags x86)) :exec (rflags x86)))) (mbe :logic (b* ((x86 (if (equal (rflagsbits->cf undefined-mask) 1) (!flgi-undefined :cf x86) (!flgi :cf (rflagsbits->cf user-flags-vector) x86))) (x86 (if (equal (rflagsbits->pf undefined-mask) 1) (!flgi-undefined :pf x86) (!flgi :pf (rflagsbits->pf user-flags-vector) x86))) (x86 (if (equal (rflagsbits->af undefined-mask) 1) (!flgi-undefined :af x86) (!flgi :af (rflagsbits->af user-flags-vector) x86))) (x86 (if (equal (rflagsbits->zf undefined-mask) 1) (!flgi-undefined :zf x86) (!flgi :zf (rflagsbits->zf user-flags-vector) x86))) (x86 (if (equal (rflagsbits->sf undefined-mask) 1) (!flgi-undefined :sf x86) (!flgi :sf (rflagsbits->sf user-flags-vector) x86))) (x86 (if (equal (rflagsbits->of undefined-mask) 1) (!flgi-undefined :of x86) (!flgi :of (rflagsbits->of user-flags-vector) x86)))) x86) :exec (if (eql undefined-mask 0) (b* ((x86 (!flgi :cf (rflagsbits->cf user-flags-vector) x86)) (x86 (!flgi :pf (rflagsbits->pf user-flags-vector) x86)) (x86 (!flgi :af (rflagsbits->af user-flags-vector) x86)) (x86 (!flgi :zf (rflagsbits->zf user-flags-vector) x86)) (x86 (!flgi :sf (rflagsbits->sf user-flags-vector) x86)) (x86 (!flgi :of (rflagsbits->of user-flags-vector) x86))) x86) (b* ((x86 (if (equal (rflagsbits->cf undefined-mask) 1) (!flgi-undefined :cf x86) (!flgi :cf (rflagsbits->cf user-flags-vector) x86))) (x86 (if (equal (rflagsbits->pf undefined-mask) 1) (!flgi-undefined :pf x86) (!flgi :pf (rflagsbits->pf user-flags-vector) x86))) (x86 (if (equal (rflagsbits->af undefined-mask) 1) (!flgi-undefined :af x86) (!flgi :af (rflagsbits->af user-flags-vector) x86))) (x86 (if (equal (rflagsbits->zf undefined-mask) 1) (!flgi-undefined :zf x86) (!flgi :zf (rflagsbits->zf user-flags-vector) x86))) (x86 (if (equal (rflagsbits->sf undefined-mask) 1) (!flgi-undefined :sf x86) (!flgi :sf (rflagsbits->sf user-flags-vector) x86))) (x86 (if (equal (rflagsbits->of undefined-mask) 1) (!flgi-undefined :of x86) (!flgi :of (rflagsbits->of user-flags-vector) x86)))) x86)))))
Theorem:
(defthm x86p-of-write-user-rflags (implies (x86p x86) (b* ((x86 (write-user-rflags$inline user-flags-vector undefined-mask x86))) (x86p x86))) :rule-classes :rewrite)
Theorem:
(defthm xr-write-user-rflags (implies (and (not (equal fld :rflags)) (not (equal fld :undef))) (equal (xr fld index (write-user-rflags flags mask x86)) (xr fld index x86))))
Theorem:
(defthm xr-write-user-rflags-no-mask (implies (not (equal fld :rflags)) (equal (xr fld index (write-user-rflags flags 0 x86)) (xr fld index x86))))
Theorem:
(defthm rflags-and-write-user-rflags-no-mask (equal (write-user-rflags user-flags-vector 0 x86) (b* ((x86 (!flgi :cf (rflagsbits->cf user-flags-vector) x86)) (x86 (!flgi :pf (rflagsbits->pf user-flags-vector) x86)) (x86 (!flgi :af (rflagsbits->af user-flags-vector) x86)) (x86 (!flgi :zf (rflagsbits->zf user-flags-vector) x86)) (x86 (!flgi :sf (rflagsbits->sf user-flags-vector) x86)) (x86 (!flgi :of (rflagsbits->of user-flags-vector) x86))) x86)))