(sar-spec-32 dst src input-rflags) → (mv * * *)
Function:
(defun sar-spec-32 (dst src input-rflags) (declare (type (unsigned-byte 32) dst) (type (unsigned-byte 6) src) (type (unsigned-byte 32) input-rflags)) (let ((__function__ 'sar-spec-32)) (declare (ignorable __function__)) (b* ((dst (mbe :logic (n-size 32 dst) :exec dst)) (src (mbe :logic (n-size 6 src) :exec src)) (input-rflags (mbe :logic (n32 input-rflags) :exec input-rflags)) (neg-src (the (signed-byte 33) (- src))) (raw-result-not-sign-extended (the (unsigned-byte 32) (ash (the (unsigned-byte 32) dst) (the (signed-byte 33) neg-src)))) (raw-result (if (eql (mbe :logic (logbit 31 dst) :exec (the (unsigned-byte 1) (ash (the (unsigned-byte 32) dst) -31))) 1) (loghead 32 (ash (mbe :logic (logext 32 dst) :exec (fast-logext 32 dst)) neg-src)) raw-result-not-sign-extended)) (result (mbe :logic (n-size 32 raw-result) :exec raw-result)) ((mv (the (unsigned-byte 32) output-rflags) (the (unsigned-byte 32) undefined-flags)) (case src (0 (mv input-rflags 0)) (1 (b* ((cf (mbe :logic (part-select dst :low 0 :width 1) :exec (the (unsigned-byte 1) (logand 1 (the (unsigned-byte 32) dst))))) (pf (general-pf-spec 32 result)) (zf (zf-spec result)) (sf (general-sf-spec 32 result)) (of 0) (output-rflags (mbe :logic (change-rflagsbits input-rflags :cf cf :pf pf :zf zf :sf sf :of of) :exec (the (unsigned-byte 32) (!rflagsbits->cf cf (!rflagsbits->pf pf (!rflagsbits->zf zf (!rflagsbits->sf sf (!rflagsbits->of of input-rflags)))))))) (undefined-flags (the (unsigned-byte 32) (!rflagsbits->af 1 0)))) (mv output-rflags undefined-flags))) (otherwise (b* ((cf (if (<= 32 src) (mbe :logic (part-select dst :low 31 :width 1) :exec (let* ((shft (the (signed-byte 32) -31))) (the (unsigned-byte 1) (ash (the (unsigned-byte 32) dst) (the (signed-byte 32) shft))))) (mbe :logic (part-select dst :low (1- src) :width 1) :exec (let* ((shft (the (signed-byte 32) (- 1 (the (unsigned-byte 32) src))))) (the (unsigned-byte 1) (logand 1 (the (unsigned-byte 32) (ash (the (unsigned-byte 32) dst) (the (signed-byte 32) shft))))))))) (pf (general-pf-spec 32 result)) (zf (zf-spec result)) (sf (general-sf-spec 32 result)) (output-rflags (mbe :logic (change-rflagsbits input-rflags :cf cf :pf pf :zf zf :sf sf) :exec (the (unsigned-byte 32) (!rflagsbits->cf cf (!rflagsbits->pf pf (!rflagsbits->zf zf (!rflagsbits->sf sf input-rflags))))))) (undefined-flags (mbe :logic (change-rflagsbits 0 :af 1 :of 1) :exec (the (unsigned-byte 32) (!rflagsbits->af 1 (!rflagsbits->of 1 0)))))) (mv output-rflags undefined-flags))))) (output-rflags (mbe :logic (n32 output-rflags) :exec output-rflags)) (undefined-flags (mbe :logic (n32 undefined-flags) :exec undefined-flags))) (mv result output-rflags undefined-flags))))
Theorem:
(defthm n32-mv-nth-0-sar-spec-32 (unsigned-byte-p 32 (mv-nth 0 (sar-spec-32 dst src input-rflags))) :rule-classes (:rewrite (:type-prescription :corollary (natp (mv-nth 0 (sar-spec-32 dst src input-rflags))) :hints (("Goal" :in-theory '(unsigned-byte-p integer-range-p natp)))) (:linear :corollary (and (<= 0 (mv-nth 0 (sar-spec-32 dst src input-rflags))) (< (mv-nth 0 (sar-spec-32 dst src input-rflags)) 4294967296)) :hints (("Goal" :in-theory '(unsigned-byte-p integer-range-p (:e expt)))))))
Theorem:
(defthm mv-nth-1-sar-spec-32 (unsigned-byte-p 32 (mv-nth 1 (sar-spec-32 dst src input-rflags))) :rule-classes (:rewrite (:type-prescription :corollary (natp (mv-nth 1 (sar-spec-32 dst src input-rflags))) :hints (("Goal" :in-theory '(unsigned-byte-p integer-range-p natp)))) (:linear :corollary (and (<= 0 (mv-nth 1 (sar-spec-32 dst src input-rflags))) (< (mv-nth 1 (sar-spec-32 dst src input-rflags)) 4294967296)) :hints (("Goal" :in-theory '(unsigned-byte-p integer-range-p (:e expt)))))))
Theorem:
(defthm mv-nth-2-sar-spec-32 (unsigned-byte-p 32 (mv-nth 2 (sar-spec-32 dst src input-rflags))) :rule-classes (:rewrite (:type-prescription :corollary (natp (mv-nth 2 (sar-spec-32 dst src input-rflags))) :hints (("Goal" :in-theory '(unsigned-byte-p integer-range-p natp)))) (:linear :corollary (and (<= 0 (mv-nth 2 (sar-spec-32 dst src input-rflags))) (< (mv-nth 2 (sar-spec-32 dst src input-rflags)) 4294967296)) :hints (("Goal" :in-theory '(unsigned-byte-p integer-range-p (:e expt)))))))