Raymond Toy pushed to branch issue-431-fix-set-floating-point-modes at cmucl / cmucl
Commits:
-
67432557
by Raymond Toy at 2025-09-02T15:52:58-07:00
-
5002a779
by Raymond Toy at 2025-09-02T16:12:27-07:00
6 changed files:
- src/code/x86-vm.lisp
- src/compiler/x86/float-sse2.lisp
- src/i18n/locale/cmucl-sse2.pot
- src/i18n/locale/cmucl-x86-vm.pot
- + tests/float-x86.lisp
- tests/float.lisp
Changes:
| ... | ... | @@ -733,3 +733,88 @@ |
| 733 | 733 | (multiple-value-bind (fop dst src)
|
| 734 | 734 | (get-fp-operation scp)
|
| 735 | 735 | (values fop (list dst src))))
|
| 736 | + |
|
| 737 | +;; See src/compiler/x86/float-sse2.lisp for a description of the x87
|
|
| 738 | +;; control and status words.
|
|
| 739 | + |
|
| 740 | +(defconstant x87-float-infinity-control-byte
|
|
| 741 | + (byte 1 (+ 12 16))
|
|
| 742 | + "The bit in the x87 FPU control word that controls the infinity mode.")
|
|
| 743 | + |
|
| 744 | +(defconstant x87-float-rounding-mode
|
|
| 745 | + (byte 2 (+ 10 16))
|
|
| 746 | + "The bits in the x87 FPU control word for the rounding mode.")
|
|
| 747 | + |
|
| 748 | +(defconstant x87-float-precision-control-byte
|
|
| 749 | + (byte 2 (+ 8 16))
|
|
| 750 | + "The bits in the x87 FPU contol word for the FP operation precision.")
|
|
| 751 | + |
|
| 752 | +(defconstant x87-float-traps-byte
|
|
| 753 | + (byte 6 16)
|
|
| 754 | + "The bits in the x87 FPU control word indicating the exceptions that
|
|
| 755 | + are enabled.")
|
|
| 756 | + |
|
| 757 | +(defconstant x87-float-precision-control-alist
|
|
| 758 | + `((:24-bits . 0)
|
|
| 759 | + (:reserved . 1)
|
|
| 760 | + (:53-bits . 2)
|
|
| 761 | + (:64-bits . 3))
|
|
| 762 | + "Alist for the x87 precison control. The car is the symbolic
|
|
| 763 | + precision and the cdr is the value for the precision control field.")
|
|
| 764 | + |
|
| 765 | +(defun print-fp-exceptions-enabled (enabled)
|
|
| 766 | + (format t "Precision enable: ~30T~A~%" (ldb (byte 1 5) enabled))
|
|
| 767 | + (format t "Underflow enable: ~30T~A~%" (ldb (byte 1 4) enabled))
|
|
| 768 | + (format t "Overflow enable: ~30T~A~%" (ldb (byte 1 3) enabled))
|
|
| 769 | + (format t "Divide-by-zero enable: ~30T~A~%" (ldb (byte 1 2) enabled))
|
|
| 770 | + (format t "Denormal op enable: ~30T~A~%" (ldb (byte 1 1) enabled))
|
|
| 771 | + (format t "Invalid op enable: ~30T~A~%" (ldb (byte 1 0) enabled)))
|
|
| 772 | + |
|
| 773 | +(defun print-fp-current-exceptions (current)
|
|
| 774 | + (format t "Precision flag: ~30T~A~%" (ldb (byte 1 5) current))
|
|
| 775 | + (format t "Underflow flag: ~30T~A~%" (ldb (byte 1 4) current))
|
|
| 776 | + (format t "Overflow flag: ~30T~A~%" (ldb (byte 1 3) current))
|
|
| 777 | + (format t "Divide-by-zero flag: ~30T~A~%" (ldb (byte 1 2) current))
|
|
| 778 | + (format t "Denormal op flag: ~30T~A~%" (ldb (byte 1 1) current))
|
|
| 779 | + (format t "Invalid op flag: ~30T~A~%" (ldb (byte 1 0) current)))
|
|
| 780 | + |
|
| 781 | +(defun print-sse2-fp-modes (&optional (sse-mode (sse2-floating-point-modes)))
|
|
| 782 | + "Print SSE2 floating modes word in a human-readable fashion."
|
|
| 783 | + ;; Note that Intel uses masks to disable the exception, but to match
|
|
| 784 | + ;; the rest of cmucl, these bits are represented as enable bits.
|
|
| 785 | + (format t "Flush-to-zero: ~30T~A~%" (ldb (byte 1 15) sse-mode))
|
|
| 786 | + (let ((rc (ldb float-rounding-mode sse-mode)))
|
|
| 787 | + (format t "Rounding control: ~30T#b~2,'0b ~S~%"
|
|
| 788 | + rc
|
|
| 789 | + (car (rassoc rc rounding-mode-alist))))
|
|
| 790 | + (print-fp-exceptions-enabled (ldb float-traps-byte sse-mode))
|
|
| 791 | + (print-fp-current-exceptions (ldb float-exceptions-byte sse-mode)))
|
|
| 792 | + |
|
| 793 | +(defun print-x87-fp-modes (&optional (x87-mode (x87-floating-point-modes)))
|
|
| 794 | + "Print X87 floating modes word in a human-readable fashion."
|
|
| 795 | + ;; Note that Intel uses masks to disable the exception, but to match
|
|
| 796 | + ;; the rest of cmucl, these bits are represented as enable bits.
|
|
| 797 | + (format t "Status word:~%")
|
|
| 798 | + (format t "FPU busy: ~30T~A~%" (ldb (byte 1 15) x87-mode))
|
|
| 799 | + (format t "Condition code C3: ~30T~A~%" (ldb (byte 1 14) x87-mode))
|
|
| 800 | + (format t "Top of stack: ~30T~D~%" (ldb (byte 3 11) x87-mode))
|
|
| 801 | + (format t "Condition code C2: ~30T~A~%" (ldb (byte 1 10) x87-mode))
|
|
| 802 | + (format t "Condition code C1: ~30T~A~%" (ldb (byte 1 9) x87-mode))
|
|
| 803 | + (format t "Condition code C0: ~30T~A~%" (ldb (byte 1 8) x87-mode))
|
|
| 804 | + (format t "Error summary: ~30T~A~%" (ldb (byte 1 7) x87-mode))
|
|
| 805 | + (format t "Stack fault: ~30T~A~%" (ldb (byte 1 6) x87-mode))
|
|
| 806 | + (print-fp-current-exceptions (ldb float-exceptions-byte x87-mode))
|
|
| 807 | + (format t "~%Control word:~%")
|
|
| 808 | + (format t "Reserved: ~30T#b~2,'0b~%" (ldb (byte 2 (+ 13 16)) x87-mode))
|
|
| 809 | + (format t "Infinity control: ~30T~A~%" (ldb x87-float-infinity-control-byte x87-mode))
|
|
| 810 | + (let ((rc (ldb x87-float-rounding-mode x87-mode)))
|
|
| 811 | + (format t "Rounding control: ~30T#b~2,'0b ~S~%"
|
|
| 812 | + rc
|
|
| 813 | + (car (rassoc rc rounding-mode-alist))))
|
|
| 814 | + (let ((pc (ldb x87-float-precision-control-byte x87-mode)))
|
|
| 815 | + (format t "Precision control: ~30T#b~2,'0b ~S~%"
|
|
| 816 | + pc
|
|
| 817 | + (car (rassoc pc x87-float-precision-control-alist))))
|
|
| 818 | + (format t "Reserved: ~30T#b~2,'0b~%" (ldb (byte 2 (+ 6 16)) x87-mode))
|
|
| 819 | + (print-fp-exceptions-enabled (ldb x87-float-traps-byte x87-mode)))
|
|
| 820 | + |
| ... | ... | @@ -1379,83 +1379,6 @@ |
| 1379 | 1379 | ;; 10 double precision (53 bits)
|
| 1380 | 1380 | ;; 11 double extended precision (64 bits)
|
| 1381 | 1381 | |
| 1382 | -(defconstant x87-float-infinity-control-byte
|
|
| 1383 | - (byte 1 (+ 12 16))
|
|
| 1384 | - "The bit in the x87 FPU control word that controls the infinity mode.")
|
|
| 1385 | -(defconstant x87-float-rounding-mode
|
|
| 1386 | - (byte 2 (+ 10 16))
|
|
| 1387 | - "The bits in the x87 FPU control word for the rounding mode.")
|
|
| 1388 | -(defconstant x87-float-precision-control-byte
|
|
| 1389 | - (byte 2 (+ 8 16))
|
|
| 1390 | - "The bits in the x87 FPU contol word for the FP operation precision.")
|
|
| 1391 | -(defconstant x87-float-traps-byte
|
|
| 1392 | - (byte 6 16)
|
|
| 1393 | - "The bits in the x87 FPU control word indicating the exceptions that
|
|
| 1394 | - are enabled.")
|
|
| 1395 | -(defconstant x87-float-precision-control-alist
|
|
| 1396 | - `((:24-bits . 0)
|
|
| 1397 | - (:reserved . 1)
|
|
| 1398 | - (:53-bits . 2)
|
|
| 1399 | - (:64-bits . 3))
|
|
| 1400 | - "Alist for the x87 precison control. The car is the symbolic
|
|
| 1401 | - precision and the cdr is the value for the precision control field.")
|
|
| 1402 | - |
|
| 1403 | -(defun print-fp-exceptions-enabled (enabled)
|
|
| 1404 | - (format t "Precision enable: ~30T~A~%" (ldb (byte 1 5) enabled))
|
|
| 1405 | - (format t "Underflow enable: ~30T~A~%" (ldb (byte 1 4) enabled))
|
|
| 1406 | - (format t "Overflow enable: ~30T~A~%" (ldb (byte 1 3) enabled))
|
|
| 1407 | - (format t "Divide-by-zero enable: ~30T~A~%" (ldb (byte 1 2) enabled))
|
|
| 1408 | - (format t "Denormal op enable: ~30T~A~%" (ldb (byte 1 1) enabled))
|
|
| 1409 | - (format t "Invalid op enable: ~30T~A~%" (ldb (byte 1 0) enabled)))
|
|
| 1410 | - |
|
| 1411 | -(defun print-fp-current-exceptions (current)
|
|
| 1412 | - (format t "Precision flag: ~30T~A~%" (ldb (byte 1 5) current))
|
|
| 1413 | - (format t "Underflow flag: ~30T~A~%" (ldb (byte 1 4) current))
|
|
| 1414 | - (format t "Overflow flag: ~30T~A~%" (ldb (byte 1 3) current))
|
|
| 1415 | - (format t "Divide-by-zero flag: ~30T~A~%" (ldb (byte 1 2) current))
|
|
| 1416 | - (format t "Denormal op flag: ~30T~A~%" (ldb (byte 1 1) current))
|
|
| 1417 | - (format t "Invalid op flag: ~30T~A~%" (ldb (byte 1 0) current)))
|
|
| 1418 | - |
|
| 1419 | -(defun print-sse2-fp-modes (&optional (sse-mode (sse2-floating-point-modes)))
|
|
| 1420 | - "Print SSE2 modes word in a readable fashion."
|
|
| 1421 | - ;; Note that Intel uses masks to disable the exception, but to match
|
|
| 1422 | - ;; the rest of cmucl, these bits are represented as enable bits.
|
|
| 1423 | - (format t "Flush-to-zero: ~30T~A~%" (ldb (byte 1 15) sse-mode))
|
|
| 1424 | - (let ((rc (ldb float-rounding-mode sse-mode)))
|
|
| 1425 | - (format t "Rounding control: ~30T#b~2,'0b ~S~%"
|
|
| 1426 | - rc
|
|
| 1427 | - (car (rassoc rc rounding-mode-alist))))
|
|
| 1428 | - (print-fp-exceptions-enabled (ldb float-traps-byte sse-mode))
|
|
| 1429 | - (print-fp-current-exceptions (ldb float-exceptions-byte sse-mode)))
|
|
| 1430 | - |
|
| 1431 | -(defun print-x87-fp-modes (&optional (x87-mode (x87-floating-point-modes)))
|
|
| 1432 | - "Print X87 floating modes word in a readable fashion."
|
|
| 1433 | - ;; Note that Intel uses masks to disable the exception, but to match
|
|
| 1434 | - ;; the rest of cmucl, these bits are represented as enable bits.
|
|
| 1435 | - (format t "Status word:~%")
|
|
| 1436 | - (format t "FPU busy: ~30T~A~%" (ldb (byte 1 15) x87-mode))
|
|
| 1437 | - (format t "Condition code C3: ~30T~A~%" (ldb (byte 1 14) x87-mode))
|
|
| 1438 | - (format t "Top of stack: ~30T~D~%" (ldb (byte 3 11) x87-mode))
|
|
| 1439 | - (format t "Condition code C2: ~30T~A~%" (ldb (byte 1 10) x87-mode))
|
|
| 1440 | - (format t "Condition code C1: ~30T~A~%" (ldb (byte 1 9) x87-mode))
|
|
| 1441 | - (format t "Condition code C0: ~30T~A~%" (ldb (byte 1 8) x87-mode))
|
|
| 1442 | - (format t "Error summary: ~30T~A~%" (ldb (byte 1 7) x87-mode))
|
|
| 1443 | - (format t "Stack fault: ~30T~A~%" (ldb (byte 1 6) x87-mode))
|
|
| 1444 | - (print-fp-current-exceptions (ldb float-exceptions-byte x87-mode))
|
|
| 1445 | - (format t "~%Control word:~%")
|
|
| 1446 | - (format t "Reserved: ~30T#b~2,'0b~%" (ldb (byte 2 (+ 13 16)) x87-mode))
|
|
| 1447 | - (format t "Infinity control: ~30T~A~%" (ldb x87-float-infinity-control-byte x87-mode))
|
|
| 1448 | - (let ((rc (ldb x87-float-rounding-mode x87-mode)))
|
|
| 1449 | - (format t "Rounding control: ~30T#b~2,'0b ~S~%"
|
|
| 1450 | - rc
|
|
| 1451 | - (car (rassoc rc rounding-mode-alist))))
|
|
| 1452 | - (let ((pc (ldb x87-float-precision-control-byte x87-mode)))
|
|
| 1453 | - (format t "Precision control: ~30T#b~2,'0b ~S~%"
|
|
| 1454 | - pc
|
|
| 1455 | - (car (rassoc pc x87-float-precision-control-alist))))
|
|
| 1456 | - (format t "Reserved: ~30T#b~2,'0b~%" (ldb (byte 2 (+ 6 16)) x87-mode))
|
|
| 1457 | - (print-fp-exceptions-enabled (ldb x87-float-traps-byte x87-mode)))
|
|
| 1458 | - |
|
| 1459 | 1382 | (defknown x87-floating-point-modes () float-modes (flushable))
|
| 1460 | 1383 | (defknown ((setf x87-floating-point-modes)) (float-modes)
|
| 1461 | 1384 | float-modes)
|
| ... | ... | @@ -86,38 +86,6 @@ msgstr "" |
| 86 | 86 | msgid "inline ftruncate"
|
| 87 | 87 | msgstr ""
|
| 88 | 88 | |
| 89 | -#: src/compiler/x86/float-sse2.lisp
|
|
| 90 | -msgid "The bit in the x87 FPU control word that controls the infinity mode."
|
|
| 91 | -msgstr ""
|
|
| 92 | - |
|
| 93 | -#: src/compiler/x86/float-sse2.lisp
|
|
| 94 | -msgid "The bits in the x87 FPU control word for the rounding mode."
|
|
| 95 | -msgstr ""
|
|
| 96 | - |
|
| 97 | -#: src/compiler/x86/float-sse2.lisp
|
|
| 98 | -msgid "The bits in the x87 FPU contol word for the FP operation precision."
|
|
| 99 | -msgstr ""
|
|
| 100 | - |
|
| 101 | -#: src/compiler/x86/float-sse2.lisp
|
|
| 102 | -msgid ""
|
|
| 103 | -"The bits in the x87 FPU control word indicating the exceptions that\n"
|
|
| 104 | -" are enabled."
|
|
| 105 | -msgstr ""
|
|
| 106 | - |
|
| 107 | -#: src/compiler/x86/float-sse2.lisp
|
|
| 108 | -msgid ""
|
|
| 109 | -"Alist for the x87 precison control. The car is the symbolic\n"
|
|
| 110 | -" precision and the cdr is the value for the precision control field."
|
|
| 111 | -msgstr ""
|
|
| 112 | - |
|
| 113 | -#: src/compiler/x86/float-sse2.lisp
|
|
| 114 | -msgid "Print SSE2 modes word in a readable fashion."
|
|
| 115 | -msgstr ""
|
|
| 116 | - |
|
| 117 | -#: src/compiler/x86/float-sse2.lisp
|
|
| 118 | -msgid "Print X87 floating modes word in a readable fashion."
|
|
| 119 | -msgstr ""
|
|
| 120 | - |
|
| 121 | 89 | #: src/compiler/x86/float-sse2.lisp
|
| 122 | 90 | msgid "inline complex single-float creation"
|
| 123 | 91 | msgstr ""
|
| ... | ... | @@ -77,6 +77,38 @@ msgstr "" |
| 77 | 77 | msgid "Thread safe push of val onto the list in the vector element."
|
| 78 | 78 | msgstr ""
|
| 79 | 79 | |
| 80 | +#: src/code/x86-vm.lisp
|
|
| 81 | +msgid "The bit in the x87 FPU control word that controls the infinity mode."
|
|
| 82 | +msgstr ""
|
|
| 83 | + |
|
| 84 | +#: src/code/x86-vm.lisp
|
|
| 85 | +msgid "The bits in the x87 FPU control word for the rounding mode."
|
|
| 86 | +msgstr ""
|
|
| 87 | + |
|
| 88 | +#: src/code/x86-vm.lisp
|
|
| 89 | +msgid "The bits in the x87 FPU contol word for the FP operation precision."
|
|
| 90 | +msgstr ""
|
|
| 91 | + |
|
| 92 | +#: src/code/x86-vm.lisp
|
|
| 93 | +msgid ""
|
|
| 94 | +"The bits in the x87 FPU control word indicating the exceptions that\n"
|
|
| 95 | +" are enabled."
|
|
| 96 | +msgstr ""
|
|
| 97 | + |
|
| 98 | +#: src/code/x86-vm.lisp
|
|
| 99 | +msgid ""
|
|
| 100 | +"Alist for the x87 precison control. The car is the symbolic\n"
|
|
| 101 | +" precision and the cdr is the value for the precision control field."
|
|
| 102 | +msgstr ""
|
|
| 103 | + |
|
| 104 | +#: src/code/x86-vm.lisp
|
|
| 105 | +msgid "Print SSE2 floating modes word in a human-readable fashion."
|
|
| 106 | +msgstr ""
|
|
| 107 | + |
|
| 108 | +#: src/code/x86-vm.lisp
|
|
| 109 | +msgid "Print X87 floating modes word in a human-readable fashion."
|
|
| 110 | +msgstr ""
|
|
| 111 | + |
|
| 80 | 112 | #: src/code/load.lisp
|
| 81 | 113 | msgid "Top-Level Form"
|
| 82 | 114 | msgstr ""
|
| 1 | +;; Tests of float functions
|
|
| 2 | + |
|
| 3 | +(defpackage :float-x86-tests
|
|
| 4 | + (:use :cl :lisp-unit))
|
|
| 5 | + |
|
| 6 | +(in-package "FLOAT-X86-TESTS")
|
|
| 7 | + |
|
| 8 | +(define-test set-floating-point-modes
|
|
| 9 | + (let ((old-x87-modes (x86::x87-floating-point-modes))
|
|
| 10 | + (old-sse2-modes (x86::sse2-floating-point-modes))
|
|
| 11 | + x87-modes sse2-modes)
|
|
| 12 | + (unwind-protect
|
|
| 13 | + (progn
|
|
| 14 | + ;; Set some new traps and rounding mode.
|
|
| 15 | + (ext:set-floating-point-modes :traps '(:underflow
|
|
| 16 | + :overflow
|
|
| 17 | + :invalid
|
|
| 18 | + :divide-by-zero)
|
|
| 19 | + :rounding-mode :zero)
|
|
| 20 | + ;; Save these new FP modes
|
|
| 21 | + (setf x87-modes (x86::x87-floating-point-modes))
|
|
| 22 | + (setf sse2-modes (x86::sse2-floating-point-modes)))
|
|
| 23 | + |
|
| 24 | + (setf (x86::x87-floating-point-modes) old-x87-modes)
|
|
| 25 | + (setf (x86::sse2-floating-point-modes) old-sse2-modes))
|
|
| 26 | + |
|
| 27 | + (let* ((x87-exceptions-enabled (ldb x86::x87-float-traps-byte x87-modes))
|
|
| 28 | + (x87-rc (ldb x86::x87-float-rounding-mode x87-modes))
|
|
| 29 | + (sse2-exceptions-enabled (ldb x86::float-traps-byte sse2-modes))
|
|
| 30 | + (sse2-rc (ldb x86::float-rounding-mode sse2-modes)))
|
|
| 31 | + (format t "*X87 FP mode words:~%")
|
|
| 32 | + (x86::print-x87-fp-modes x87-modes)
|
|
| 33 | + (format t "~%*SSE2 FP mode words:~%")
|
|
| 34 | + (x86::print-sse2-fp-modes sse2-modes)
|
|
| 35 | +
|
|
| 36 | + ;; Verify that we set the enabled exceptions
|
|
| 37 | + ;; correctly. First for sse2, then for x87.
|
|
| 38 | + (assert-false (logbitp 5 sse2-exceptions-enabled)) ; precision
|
|
| 39 | + (assert-true (logbitp 4 sse2-exceptions-enabled)) ; underflow
|
|
| 40 | + (assert-true (logbitp 3 sse2-exceptions-enabled)) ; overflow
|
|
| 41 | + (assert-true (logbitp 2 sse2-exceptions-enabled)) ; divide-by-zero
|
|
| 42 | + (assert-false (logbitp 1 sse2-exceptions-enabled)) ; denormal
|
|
| 43 | + (assert-true (logbitp 0 sse2-exceptions-enabled)) ; invalid
|
|
| 44 | +
|
|
| 45 | + (assert-false (logbitp 5 x87-exceptions-enabled)) ; precision
|
|
| 46 | + (assert-true (logbitp 4 x87-exceptions-enabled)) ; underflow
|
|
| 47 | + (assert-true (logbitp 3 x87-exceptions-enabled)) ; overflow
|
|
| 48 | + (assert-true (logbitp 2 x87-exceptions-enabled)) ; divide-by-zero
|
|
| 49 | + (assert-false (logbitp 1 x87-exceptions-enabled)) ; denormal
|
|
| 50 | + (assert-true (logbitp 0 x87-exceptions-enabled)) ; invalid
|
|
| 51 | + |
|
| 52 | + ;; Verify the rounding mode is set to zero
|
|
| 53 | + (assert-eql :zero (car (rassoc sse2-rc x86::rounding-mode-alist)))
|
|
| 54 | + (assert-eql :zero (car (rassoc x87-rc x86::rounding-mode-alist)))
|
|
| 55 | + |
|
| 56 | + ;; Verify precision for x87
|
|
| 57 | + (assert-eql :64-bits
|
|
| 58 | + (car (rassoc (ldb x86::x87-float-precision-control-byte x87-modes)
|
|
| 59 | + x86::x87-float-precision-control-alist))))
|
|
| 60 | + )
|
|
| 61 | + ) |
| ... | ... | @@ -342,49 +342,3 @@ |
| 342 | 342 | (x86::x87-floating-point-modes)))))
|
| 343 | 343 | (assert-true (typep new-mode 'x86::float-modes))
|
| 344 | 344 | (assert-equal new-mode (setf (x86::x87-floating-point-modes) new-mode)))) |
| 345 | - |
|
| 346 | -(define-test set-floating-point-modes
|
|
| 347 | - (let ((old-x87-modes (x86::x87-floating-point-modes))
|
|
| 348 | - (old-sse2-modes (x86::sse2-floating-point-modes)))
|
|
| 349 | - (unwind-protect
|
|
| 350 | - (progn
|
|
| 351 | - ;; Set some new traps and rounding mode
|
|
| 352 | - (ext:set-floating-point-modes :traps '(:underflow
|
|
| 353 | - :overflow
|
|
| 354 | - :invalid
|
|
| 355 | - :divide-by-zero)
|
|
| 356 | - :rounding-mode :zero)
|
|
| 357 | - (let* ((x87-modes (x86::x87-floating-point-modes))
|
|
| 358 | - (x87-exceptions-enabled (ldb x86::x87-float-traps-byte x87-modes))
|
|
| 359 | - (x87-rc (ldb x86::x87-float-rounding-mode x87-modes))
|
|
| 360 | - (sse2-modes (x86::sse2-floating-point-modes))
|
|
| 361 | - (sse2-exceptions-enabled (ldb x86::float-traps-byte sse2-modes))
|
|
| 362 | - (sse2-rc (ldb x86::float-rounding-mode sse2-modes)))
|
|
| 363 | - (x86::print-x87-fp-modes x87-modes)
|
|
| 364 | - ;; Verify that we set the enabled exceptions
|
|
| 365 | - ;; correctly. First for sse2, then for x87.
|
|
| 366 | - (assert-false (logbitp 5 sse2-exceptions-enabled)) ; precision
|
|
| 367 | - (assert-true (logbitp 4 sse2-exceptions-enabled)) ; underflow
|
|
| 368 | - (assert-true (logbitp 3 sse2-exceptions-enabled)) ; overflow
|
|
| 369 | - (assert-true (logbitp 2 sse2-exceptions-enabled)) ; divide-by-zero
|
|
| 370 | - (assert-false (logbitp 1 sse2-exceptions-enabled)) ; denormal
|
|
| 371 | - (assert-true (logbitp 0 sse2-exceptions-enabled)) ; invalid
|
|
| 372 | -
|
|
| 373 | - (assert-false (logbitp 5 x87-exceptions-enabled)) ; precision
|
|
| 374 | - (assert-true (logbitp 4 x87-exceptions-enabled)) ; underflow
|
|
| 375 | - (assert-true (logbitp 3 x87-exceptions-enabled)) ; overflow
|
|
| 376 | - (assert-true (logbitp 2 x87-exceptions-enabled)) ; divide-by-zero
|
|
| 377 | - (assert-false (logbitp 1 x87-exceptions-enabled)) ; denormal
|
|
| 378 | - (assert-true (logbitp 0 x87-exceptions-enabled)) ; invalid
|
|
| 379 | - |
|
| 380 | - ;; Verify the rounding mode is set to zero
|
|
| 381 | - (assert-eql :zero (car (rassoc sse2-rc x86::rounding-mode-alist)))
|
|
| 382 | - (assert-eql :zero (car (rassoc x87-rc x86::rounding-mode-alist)))
|
|
| 383 | - |
|
| 384 | - ;; Verify precision for x87
|
|
| 385 | - (assert-eql :64-bits
|
|
| 386 | - (car (rassoc (ldb x86::x87-float-precision-control-byte x87-modes)
|
|
| 387 | - x86::x87-float-precision-control-alist)))))
|
|
| 388 | - |
|
| 389 | - (setf (x86::x87-floating-point-modes) old-x87-modes)
|
|
| 390 | - (setf (x86::sse2-floating-point-modes) old-sse2-modes)))) |