(vex-decode-and-execute proc-mode start-rip temp-rip prefixes rex-byte vex-prefixes x86) → x86
Reference: Intel Vol. 2A, Section 2.3: Intel Advanced Vector Extensions (Intel AVX)
Function:
(defun vex-decode-and-execute (proc-mode start-rip temp-rip prefixes rex-byte vex-prefixes x86) (declare (xargs :stobjs (x86))) (declare (type (integer 0 4) proc-mode) (type (signed-byte 48) start-rip) (type (signed-byte 48) temp-rip) (type (unsigned-byte 52) prefixes) (type (unsigned-byte 8) rex-byte) (type (unsigned-byte 24) vex-prefixes)) (declare (xargs :guard (and (prefixes-p prefixes) (vex-prefixes-byte0-p vex-prefixes)))) (let ((__function__ 'vex-decode-and-execute)) (declare (ignorable __function__)) (b* ((ctx 'vex-decode-and-execute) ((when (not (equal rex-byte 0))) (!!fault-fresh :ud :vex-prefixes vex-prefixes :rex rex-byte)) ((when (equal (the (unsigned-byte 8) (prefixes->lck prefixes)) 240)) (!!fault-fresh :ud :vex-prefixes vex-prefixes :lock-prefix)) ((when (equal (the (unsigned-byte 8) (prefixes->rep prefixes)) 242)) (!!fault-fresh :ud :vex-prefixes vex-prefixes :f2-prefix)) ((when (equal (the (unsigned-byte 8) (prefixes->rep prefixes)) 243)) (!!fault-fresh :ud :vex-prefixes vex-prefixes :f3-prefix)) ((when (equal (the (unsigned-byte 8) (prefixes->opr prefixes)) 102)) (!!fault-fresh :ud :vex-prefixes vex-prefixes :66-prefix)) (vex2-prefix? (equal (vex-prefixes->byte0 vex-prefixes) 197)) (vex3-prefix? (equal (vex-prefixes->byte0 vex-prefixes) 196)) (vex-byte1 (vex-prefixes->byte1 vex-prefixes)) ((mv vex3-0f-map? vex3-0f38-map? vex3-0f3a-map?) (if vex3-prefix? (mv (equal (vex3-byte1->m-mmmm vex-byte1) 1) (equal (vex3-byte1->m-mmmm vex-byte1) 2) (equal (vex3-byte1->m-mmmm vex-byte1) 3)) (mv nil nil nil))) ((when (and vex3-prefix? (not (or vex3-0f-map? vex3-0f38-map? vex3-0f3a-map?)))) (!!fault-fresh :ud :vex-prefixes vex-prefixes :m-mmmm vex-byte1)) ((mv flg0 (the (unsigned-byte 8) byte2/next-byte) x86) (rme08 proc-mode temp-rip 1 :x x86)) ((when flg0) (!!ms-fresh :vex-byte2/next-byte-read-error flg0)) ((mv flg1 temp-rip) (add-to-*ip proc-mode temp-rip 1 x86)) ((when flg1) (!!ms-fresh :increment-error flg1)) (vex-prefixes (if vex3-prefix? (!vex-prefixes->byte2 byte2/next-byte vex-prefixes) vex-prefixes)) ((mv flg2 (the (unsigned-byte 8) next-byte) x86) (if vex3-prefix? (rme08 proc-mode temp-rip 1 :x x86) (mv nil 0 x86))) ((when flg2) (!!ms-fresh :next-byte-read-error flg2)) ((mv flg3 temp-rip) (if vex3-prefix? (add-to-*ip proc-mode temp-rip 1 x86) (mv nil temp-rip))) ((when flg3) (!!ms-fresh :increment-error flg3)) (opcode (the (unsigned-byte 8) (if vex3-prefix? next-byte byte2/next-byte))) (modr/m? (vex-opcode-modr/m-p vex-prefixes opcode)) ((mv flg4 (the (unsigned-byte 8) modr/m) x86) (if modr/m? (rme08 proc-mode temp-rip 1 :x x86) (mv nil 0 x86))) ((when flg4) (!!ms-fresh :modr/m-byte-read-error flg4)) ((mv flg5 temp-rip) (if modr/m? (add-to-*ip proc-mode temp-rip 1 x86) (mv nil temp-rip))) ((when flg5) (!!ms-fresh :increment-error flg5)) (sib? (and modr/m? (b* ((p4? (eql 103 (the (unsigned-byte 8) (prefixes->adr prefixes)))) (16-bit-addressp (eql 2 (select-address-size proc-mode p4? x86)))) (x86-decode-sib-p modr/m 16-bit-addressp)))) ((mv flg6 (the (unsigned-byte 8) sib) x86) (if sib? (rme08 proc-mode temp-rip 1 :x x86) (mv nil 0 x86))) ((when flg6) (!!ms-fresh :sib-byte-read-error flg6)) ((mv flg7 temp-rip) (if sib? (add-to-*ip proc-mode temp-rip 1 x86) (mv nil temp-rip))) ((when flg7) (!!ms-fresh :increment-error flg7))) (cond ((mbe :logic (vex-prefixes-map-p 15 vex-prefixes) :exec (or vex2-prefix? (and vex3-prefix? vex3-0f-map?))) (vex-0f-execute proc-mode start-rip temp-rip prefixes rex-byte vex-prefixes opcode modr/m sib x86)) ((mbe :logic (vex-prefixes-map-p 3896 vex-prefixes) :exec (and vex3-prefix? vex3-0f38-map?)) (vex-0f38-execute proc-mode start-rip temp-rip prefixes rex-byte vex-prefixes opcode modr/m sib x86)) ((mbe :logic (vex-prefixes-map-p 3898 vex-prefixes) :exec (and vex3-prefix? vex3-0f3a-map?)) (vex-0f3a-execute proc-mode start-rip temp-rip prefixes rex-byte vex-prefixes opcode modr/m sib x86)) (t (!!ms-fresh :illegal-value-of-vex-m-mmmm))))))
Theorem:
(defthm x86p-of-vex-decode-and-execute (implies (x86p x86) (b* ((x86 (vex-decode-and-execute proc-mode start-rip temp-rip prefixes rex-byte vex-prefixes x86))) (x86p x86))) :rule-classes :rewrite)