Raymond Toy pushed to branch issue-425-correctly-rounded-math-functions-single-float at cmucl / cmucl

Commits:

3 changed files:

Changes:

  • src/code/float-trap.lisp
    ... ... @@ -109,7 +109,6 @@
    109 109
     			       (ash x87-enables 7))))
    
    110 110
     
    
    111 111
           final-mode))
    
    112
    -
    
    113 112
       (defun (setf floating-point-modes) (new-mode)
    
    114 113
         (declare (type (unsigned-byte 32) new-mode))
    
    115 114
         ;; Set the floating point modes for both X87 and SSE2.  This
    

  • src/compiler/x86/float-sse2.lisp
    ... ... @@ -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)
    

  • src/compiler/x86/sse2-c-call.lisp
    ... ... @@ -36,12 +36,6 @@
    36 36
     		   :from :eval :to :result) edx)
    
    37 37
       (:temporary (:sc single-stack) temp-single)
    
    38 38
       (:temporary (:sc double-stack) temp-double)
    
    39
    -  #+core-math
    
    40
    -  (:temporary (:sc unsigned-stack) save-fpu-cw)
    
    41
    -  #+core-math
    
    42
    -  (:temporary (:sc unsigned-stack) fpu-cw)
    
    43
    -  #+core-math
    
    44
    -  (:temporary (:sc unsigned-reg :offset esi-offset) temp-cw)
    
    45 39
       (:node-var node)
    
    46 40
       (:vop-var vop)
    
    47 41
       (:save-p t)
    
    ... ... @@ -69,10 +63,7 @@
    69 63
     	 (inst movss xmm0-tn (ea-for-sf-stack temp-single)))
    
    70 64
     	(double-reg
    
    71 65
     	 (inst fstpd (ea-for-df-stack temp-double))
    
    72
    -	 (inst movsd xmm0-tn (ea-for-df-stack temp-double)))))
    
    73
    -    ;; Restore the x87 FPU control settings
    
    74
    -    #+(and nil core-math)
    
    75
    -    (inst fldcw save-fpu-cw)))
    
    66
    +	 (inst movsd xmm0-tn (ea-for-df-stack temp-double)))))))
    
    76 67
     
    
    77 68
     (define-vop (alloc-number-stack-space)
    
    78 69
       (:info amount)