Raymond Toy pushed to branch master at cmucl / cmucl
Commits:
-
56f2d8fd
by Raymond Toy at 2024-09-09T20:36:09+00:00
-
c8020846
by Raymond Toy at 2024-09-09T20:36:12+00:00
2 changed files:
Changes:
... | ... | @@ -102,9 +102,11 @@ |
102 | 102 | ;; FPU and only use the SSE2 rounding control bits.
|
103 | 103 | (let* ((x87-modes (vm::x87-floating-point-modes))
|
104 | 104 | (sse-modes (vm::sse2-floating-point-modes))
|
105 | + (x87-exceptions (logand #x3f x87-modes))
|
|
106 | + (x87-enables (logand #x3f (ash x87-modes -16)))
|
|
105 | 107 | (final-mode (logior sse-modes
|
106 | - (ash (logand #x3f x87-modes) 7) ; control
|
|
107 | - (logand #x3f (ash x87-modes -16)))))
|
|
108 | + x87-exceptions
|
|
109 | + (ash x87-enables 7))))
|
|
108 | 110 | |
109 | 111 | final-mode))
|
110 | 112 | (defun (setf floating-point-modes) (new-mode)
|
... | ... | @@ -112,15 +114,17 @@ |
112 | 114 | ;; Set the floating point modes for both X87 and SSE2. This
|
113 | 115 | ;; include the rounding control bits.
|
114 | 116 | (let* ((rc (ldb float-rounding-mode new-mode))
|
117 | + (new-exceptions (logand #x3f new-mode))
|
|
118 | + (new-enables (logand #x3f (ash new-mode -7)))
|
|
115 | 119 | (x87-modes
|
116 | - (logior (ash (logand #x3f new-mode) 16)
|
|
120 | + (logior new-exceptions
|
|
117 | 121 | (ash rc 10)
|
118 | - (logand #x3f (ash new-mode -7))
|
|
122 | + (ash new-enables 16)
|
|
119 | 123 | ;; Set precision control to be 64-bit, always. We
|
120 | 124 | ;; don't use the x87 registers with sse2, so this
|
121 | 125 | ;; is ok and would be the correct setting if we
|
122 | 126 | ;; ever support long-floats.
|
123 | - (ash 3 8))))
|
|
127 | + (ash 3 (+ 8 16)))))
|
|
124 | 128 | (setf (vm::sse2-floating-point-modes) (ldb (byte 24 0) new-mode))
|
125 | 129 | (setf (vm::x87-floating-point-modes) (ldb (byte 24 0) x87-modes)))
|
126 | 130 | new-mode)
|
... | ... | @@ -1380,7 +1380,7 @@ |
1380 | 1380 | float-modes)
|
1381 | 1381 | |
1382 | 1382 | ;; Extract the control and status words from the FPU. The low 16 bits
|
1383 | -;; contain the control word, and the high 16 bits contain the status.
|
|
1383 | +;; contain the status word, and the high 16 bits contain the control.
|
|
1384 | 1384 | (define-vop (x87-floating-point-modes)
|
1385 | 1385 | (:results (res :scs (unsigned-reg)))
|
1386 | 1386 | (:result-types unsigned-num)
|
... | ... | @@ -1396,12 +1396,16 @@ |
1396 | 1396 | (inst byte #x66) ; operand size prefix
|
1397 | 1397 | (inst or sw-reg cw-stack)
|
1398 | 1398 | (inst xor sw-reg #x3f) ; invert exception mask
|
1399 | - (move res sw-reg)))
|
|
1399 | + (move res sw-reg)
|
|
1400 | + ;; Put status word in the low 16 bits and the control word in the
|
|
1401 | + ;; high 16 bits. This is to match the SSE2 mxcsr register that has
|
|
1402 | + ;; the status bits (sticky bits) in lowest part of the word.
|
|
1403 | + (inst rol res 16)))
|
|
1400 | 1404 | |
1401 | 1405 | ;; Set the control and status words from the FPU. The low 16 bits
|
1402 | -;; contain the control word, and the high 16 bits contain the status.
|
|
1406 | +;; contain the status word, and the high 16 bits contain the control.
|
|
1403 | 1407 | (define-vop (x87-set-floating-point-modes)
|
1404 | - (:args (new :scs (unsigned-reg) :to :result :target res))
|
|
1408 | + (:args (new-modes :scs (unsigned-reg) :to :result :target res))
|
|
1405 | 1409 | (:results (res :scs (unsigned-reg)))
|
1406 | 1410 | (:arg-types unsigned-num)
|
1407 | 1411 | (:result-types unsigned-num)
|
... | ... | @@ -1410,7 +1414,12 @@ |
1410 | 1414 | (:temporary (:sc unsigned-stack) cw-stack)
|
1411 | 1415 | (:temporary (:sc byte-reg :offset al-offset) sw-reg)
|
1412 | 1416 | (:temporary (:sc unsigned-reg :offset ecx-offset) old)
|
1417 | + (:temporary (:sc unsigned-reg) new)
|
|
1413 | 1418 | (:generator 6
|
1419 | + (move new new-modes)
|
|
1420 | + ;; Put the status word in the high 16 bits and the control word in
|
|
1421 | + ;; the low 16 bits.
|
|
1422 | + (inst rol new 16)
|
|
1414 | 1423 | (inst mov cw-stack new)
|
1415 | 1424 | (inst xor cw-stack #x3f) ; invert exception mask
|
1416 | 1425 | (inst fnstsw)
|
... | ... | @@ -1425,7 +1434,7 @@ |
1425 | 1434 | (inst fldenv (make-ea :dword :base esp-tn))
|
1426 | 1435 | (inst add esp-tn 28)
|
1427 | 1436 | DONE
|
1428 | - (move res new)))
|
|
1437 | + (move res new-modes)))
|
|
1429 | 1438 | |
1430 | 1439 | |
1431 | 1440 | (defun sse2-floating-point-modes ()
|