• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
      • X86isa
        • Program-execution
        • Sdm-instruction-set-summary
        • Tlb
        • Running-linux
        • Introduction
        • Asmtest
        • X86isa-build-instructions
        • Publications
        • Contributors
        • Machine
          • X86isa-state
          • Syscalls
          • Cpuid
          • Linear-memory
          • Rflag-specifications
          • Characterizing-undefined-behavior
          • Top-level-memory
          • App-view
          • X86-decoder
          • Physical-memory
          • Decoding-and-spec-utils
            • Read-operands-and-write-results
            • Effective-address-computations
            • Select-operand-size
            • Instruction-pointer-operations
            • Stack-pointer-operations
            • Select-segment-register
            • Prefix-modrm-sib-decoding
            • Select-address-size
            • Rex-byte-from-vex-prefixes
              • Check-instruction-length
              • Error-objects
              • Rip-guard-okp
              • Sib-decoding
            • Instructions
            • Register-readers-and-writers
            • X86-modes
            • Segmentation
            • Other-non-deterministic-computations
            • Environment
            • Paging
          • Implemented-opcodes
          • To-do
          • Proof-utilities
          • Peripherals
          • Model-validation
          • Modelcalls
          • Concrete-simulation-examples
          • Utils
          • Debugging-code-proofs
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Decoding-and-spec-utils

    Rex-byte-from-vex-prefixes

    Calculate a REX byte from a VEX prefix.

    Signature
    (rex-byte-from-vex-prefixes vex-prefixes) → rex-byte
    Arguments
    vex-prefixes — Guard (vex-prefixes-p vex-prefixes).
    Returns
    rex-byte — Type (unsigned-byte-p 8 rex-byte).

    The VEX prefix (see Intel manual Volume 2 Section 2.3.5 of Dec 2023) provides an encoding of the REX byte. Since some of the functions in our model depend on the REX byte (e.g. x86-operand-from-modr/m-and-sib-bytes), here we introduce a function to build a REX byte from its encoding in the VEX prefix. We do that for both the 2-byte form and the 3-byte form of the VEX prefix; see vex->r, vex->x, vex->b, and vex->w. See Figure 2-9 in Intel manual Volume 2 of Dec 2023. Note that the R, X, B bits are encoded negated, while the W is encoded directly (not negated).

    Definitions and Theorems

    Function: rex-byte-from-vex-prefixes

    (defun rex-byte-from-vex-prefixes (vex-prefixes)
      (declare (xargs :guard (vex-prefixes-p vex-prefixes)))
      (declare (xargs :guard (vex-prefixes-byte0-p vex-prefixes)))
      (let ((__function__ 'rex-byte-from-vex-prefixes))
        (declare (ignorable __function__))
        (b* ((vex.w (vex->w vex-prefixes))
             (vex.r (vex->r vex-prefixes))
             (vex.x (vex->x vex-prefixes))
             (vex.b (vex->b vex-prefixes))
             (rex-byte (+ 64 (if (= vex.w 0) 0 8)
                          (if (= vex.r 1) 0 4)
                          (if (= vex.x 1) 0 2)
                          (if (= vex.b 1) 0 1))))
          rex-byte)))

    Theorem: return-type-of-rex-byte-from-vex-prefixes

    (defthm return-type-of-rex-byte-from-vex-prefixes
      (b* ((rex-byte (rex-byte-from-vex-prefixes vex-prefixes)))
        (unsigned-byte-p 8 rex-byte))
      :rule-classes :rewrite)

    Theorem: unsigned-byte-p-of-rex-byte-from-vex-prefixes

    (defthm unsigned-byte-p-of-rex-byte-from-vex-prefixes
     (unsigned-byte-p 8
                      (rex-byte-from-vex-prefixes vex-prefixes))
     :rule-classes
     (:rewrite
      (:type-prescription
          :corollary (natp (rex-byte-from-vex-prefixes vex-prefixes))
          :hints
          (("Goal" :in-theory '(unsigned-byte-p integer-range-p natp))))
      (:linear
       :corollary (and (<= 0
                           (rex-byte-from-vex-prefixes vex-prefixes))
                       (< (rex-byte-from-vex-prefixes vex-prefixes)
                          256))
       :hints
       (("Goal"
            :in-theory '(unsigned-byte-p integer-range-p (:e expt)))))))