Address size of an instruction, in bytes.
This is based on AMD manual, Dec'17, Volume 3, Table 1-3, and AMD manual, Dec'17, Volume 2, Sections 4.7 and 4.8.
In 64-bit mode, the address size is 64 bits if there is no address override prefix, 32 bits if there is an address override prefix. In 32-bit mode, the address size is 32 bits if either (i) the default address size is 32 bits and there is no address override prefix, or (ii) the default address size is 16 bits and there is an eddress override prefix; otherwise, the address size is 16 bits. In 32-bit mode, the default address size is determined by the CS.D bit of the code segment: 32 bits if CS.D is 1, 16 bits if CS.D is 0.
The boolean argument of this function indicates whether there is an override prefix or not.
(defun select-address-size$inline (proc-mode p4? x86) (declare (xargs :stobjs (x86))) (declare (type (integer 0 4) proc-mode)) (declare (xargs :guard (and (booleanp p4?) (x86p x86)))) (case proc-mode (0 (if p4? 4 8)) (otherwise (b* (((the (unsigned-byte 16) cs-attr) (seg-hidden-attri 1 x86)) (cs.d (code-segment-descriptor-attributesbits->d cs-attr))) (if (= cs.d 1) (if p4? 2 4) (if p4? 4 2))))))
(defthm return-type-of-select-address-size (b* ((address-size (select-address-size$inline proc-mode p4? x86))) (member-equal address-size '(2 4 8))) :rule-classes :rewrite)
(defthm select-address-size-not-2-when-64-bit-modep (not (equal 2 (select-address-size 0 p4? x86))))