• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • Proof-automation
    • ACL2
    • Macro-libraries
    • 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
          • Instructions
            • Two-byte-opcodes
            • One-byte-opcodes
            • Fp-opcodes
            • Instruction-semantic-functions
              • Sar-spec
              • Shr-spec
              • Sal/shl-spec
              • Rol-spec
              • Ror-spec
              • Rcl-spec
              • Rcr-spec
              • Simd-sub-spec
              • Simd-add-spec
              • Imul-spec
              • Mul-spec
              • Idiv-spec
              • Div-spec
              • Shrd-spec
              • Shld-spec
              • Gpr-arith/logic-spec
              • Shrx-spec
              • Shlx-spec
              • Sarx-spec
              • Floating-point-specifications
                • Floating-point-converts
                • Floating-point-arithmetic-specifications
                • Basic-floating-point-utilities
                • Floating-point-comparison-specifications
                  • Sse-cmp
                    • Sse-cmp-special
                    • Sp-sse-cmp
                    • Dp-sse-cmp
              • X86-illegal-instruction
              • Implemented-opcodes
              • Opcode-maps
              • X86-general-protection
              • X86-device-not-available
              • X86-step-unimplemented
              • Privileged-opcodes
              • Three-byte-opcodes
            • 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
    • Floating-point-comparison-specifications

    Sse-cmp

    Signature
    (sse-cmp operation op1 op2 mxcsr exp-width frac-width) 
      → 
    (mv * * *)
    Arguments
    op1 — Guard (natp op1).
    op2 — Guard (natp op2).
    exp-width — Guard (posp exp-width).
    frac-width — Guard (posp frac-width).

    Definitions and Theorems

    Function: sse-cmp

    (defun sse-cmp (operation op1 op2 mxcsr exp-width frac-width)
     (declare (type (integer 0 38) operation)
              (type (unsigned-byte 32) mxcsr))
     (declare (xargs :guard (and (natp op1)
                                 (natp op2)
                                 (posp exp-width)
                                 (posp frac-width))))
     (let ((__function__ 'sse-cmp))
      (declare (ignorable __function__))
      (b* ((mxcsr (mbe :logic (loghead 32 mxcsr)
                       :exec mxcsr))
           ((mv kind1 sign1 exp1 ?implicit1 frac1)
            (fp-decode op1 exp-width frac-width))
           ((mv kind2 sign2 exp2 ?implicit2 frac2)
            (fp-decode op2 exp-width frac-width))
           (daz (equal (mxcsrbits->daz mxcsr) 1))
           ((mv kind1 exp1 frac1)
            (sse-daz kind1 exp1 frac1 daz))
           ((mv kind2 exp2 frac2)
            (sse-daz kind2 exp2 frac2 daz))
           ((mv special-ok result invalid)
            (sse-cmp-special kind1 sign1 kind2
                             sign2 exp-width frac-width operation))
           (mxcsr (if invalid (!mxcsrbits->ie 1 mxcsr)
                    mxcsr))
           (im (equal (mxcsrbits->im mxcsr) 1))
           ((when (and invalid (not im)))
            (mv 'invalid-operand-exception-is-not-masked
                0 mxcsr))
           (de (denormal-exception kind1 kind2))
           (mxcsr (if de (!mxcsrbits->de 1 mxcsr) mxcsr))
           (dm (equal (mxcsrbits->dm mxcsr) 1))
           ((when (and de (not dm)))
            (mv 'denormal-operand-exception-is-not-masked
                0 mxcsr)))
       (if special-ok (mv nil result mxcsr)
        (b*
         ((bias
           (nfix
            (ec-call (rtl::bias (list nil (1+ frac-width) exp-width)))))
          (rat1 (fp-to-rat sign1
                           exp1 frac1 bias exp-width frac-width))
          (rat2 (fp-to-rat sign2
                           exp2 frac2 bias exp-width frac-width))
          (cmp-result (case operation
                        (0 (= rat1 rat2))
                        (1 (< rat1 rat2))
                        (2 (<= rat1 rat2))
                        (3 nil)
                        (4 (not (= rat1 rat2)))
                        (5 (not (< rat1 rat2)))
                        (6 (not (<= rat1 rat2)))
                        (7 t)
                        (otherwise nil)))
          (result
               (if (or (int= operation 8)
                       (int= operation 9))
                   (cond ((> rat1 rat2) 0)
                         ((< rat1 rat2) 1)
                         (t 4))
                 (if cmp-result (1- (ash 1 (+ 1 exp-width frac-width)))
                   0))))
         (mv nil result mxcsr))))))

    Theorem: integerp-result-sse-cmp

    (defthm integerp-result-sse-cmp
      (integerp (mv-nth 1
                        (sse-cmp operation
                                 op1 op2 mxcsr exp-width frac-width)))
      :rule-classes :type-prescription)

    Theorem: n32p-mxcsr-sse-cmp

    (defthm n32p-mxcsr-sse-cmp
     (unsigned-byte-p
          32
          (mv-nth 2
                  (sse-cmp operation
                           op1 op2 mxcsr exp-width frac-width)))
     :rule-classes
     (:rewrite
      (:type-prescription
          :corollary
          (natp (mv-nth 2
                        (sse-cmp operation
                                 op1 op2 mxcsr exp-width frac-width)))
          :hints
          (("Goal" :in-theory '(unsigned-byte-p integer-range-p natp))))
      (:linear
       :corollary
       (and (<= 0
                (mv-nth 2
                        (sse-cmp operation
                                 op1 op2 mxcsr exp-width frac-width)))
            (< (mv-nth 2
                       (sse-cmp operation
                                op1 op2 mxcsr exp-width frac-width))
               4294967296))
       :hints
       (("Goal"
            :in-theory '(unsigned-byte-p integer-range-p (:e expt)))))))