Skip to content

Commit

Permalink
quaviver: add fallbacks when short-float or long-float unavailable
Browse files Browse the repository at this point in the history
  • Loading branch information
yitzchak committed Aug 1, 2024
1 parent 94e3f32 commit e424f30
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 0 deletions.
8 changes: 8 additions & 0 deletions code/bits-float-form.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
(storage-size 'short-float))))
(coerce (ffi:slot (ffi:foreign-value u) 'value) 'short-float)))

#-quaviver/short-float
(defmethod bits-float-form ((float-type (eql 'short-float)) value)
(bits-float-form 'single-float value))

(defmethod bits-float-form ((float-type (eql 'single-float)) value)
#+abcl
`(system:make-single-float ,value)
Expand Down Expand Up @@ -137,3 +141,7 @@
(ffi:get-slot-value ,m 'long-float/uint128 'u)
,n))
(ffi:get-slot-value ,m 'long-float/uint128 'f)))))

#-quaviver/long-float
(defmethod bits-float-form ((float-type (eql 'long-float)) value)
(bits-float-form 'double-float value))
8 changes: 8 additions & 0 deletions code/bits-float.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
(defmethod bits-float ((float-type (eql 'short-float)) value)
(%bits-float short-float value))

#-quaviver/short-float
(defmethod bits-float ((float-type (eql 'short-float)) value)
(%bits-float single-float value))

(defmethod bits-float ((float-type (eql 'single-float)) value)
(%bits-float single-float value))

Expand All @@ -16,3 +20,7 @@
#+quaviver/long-float
(defmethod bits-float ((float-type (eql 'long-float)) value)
(%bits-float long-float value))

#-quaviver/long-float
(defmethod bits-float ((float-type (eql 'long-float)) value)
(%bits-float double-float value))
8 changes: 8 additions & 0 deletions code/float-bits-form.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
,(- (storage-size 'short-float)
(storage-size 'single-float)))))

#-quaviver/short-float
(defmethod float-bits-form ((float-type (eql 'short-float)) value)
(float-bits-form 'single-float value))

(defmethod float-bits-form ((float-type (eql 'single-float)) value)
#+abcl
`(system:single-float-bits ,value)
Expand Down Expand Up @@ -115,3 +119,7 @@
(logior (ffi:deref-array ,n '(:array :uint64-t 2) 0)
(ash (ffi:deref-array ,n '(:array :uint64-t 2) 1)
64)))))))

#-quaviver/long-float
(defmethod float-bits-form ((float-type (eql 'long-float)) value)
(float-bits-form 'double-float value))
8 changes: 8 additions & 0 deletions code/float-internal-integer-form.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@
(defmethod float-internal-integer-form ((float-type (eql 'short-float)) value)
`(float-internal-integer/short-float ,value))

#-quaviver/short-float
(defmethod float-internal-integer-form ((float-type (eql 'short-float)) value)
`(float-internal-integer/single-float ,value))

(defmethod float-internal-integer-form ((float-type (eql 'single-float)) value)
`(float-internal-integer/single-float ,value))

Expand All @@ -82,6 +86,10 @@
(defmethod float-internal-integer-form ((float-type (eql 'long-float)) value)
`(float-internal-integer/long-float ,value))

#-quaviver/long-float
(defmethod float-internal-integer-form ((float-type (eql 'long-float)) value)
`(float-internal-integer/double-float ,value))

(defmethod float-internal-integer-form (float-type value)
(declare (ignore float-type))
`(integer-decode-float ,value))
10 changes: 10 additions & 0 deletions code/integer-float.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,13 @@
(client (float-type (eql 'long-float)) (base (eql 2)) significand exponent sign)
(declare (ignore client))
(internal-integer-float/long-float significand exponent sign))

#-quaviver/short-float
(defmethod integer-float
(client (float-type (eql 'short-float)) base significand exponent sign)
(integer-float client 'single-float base significand exponent sign))

#-quaviver/long-float
(defmethod integer-float
(client (float-type (eql 'long-float)) base significand exponent sign)
(integer-float client 'double-float base significand exponent sign))
8 changes: 8 additions & 0 deletions code/internal-integer-float-form.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@
(defmethod internal-integer-float-form ((float-type (eql 'short-float)) significand exponent sign)
`(internal-integer-float/short-float ,significand ,exponent ,sign))

#-quaviver/short-float
(defmethod internal-integer-float-form ((float-type (eql 'short-float)) significand exponent sign)
`(internal-integer-float/single-float ,significand ,exponent ,sign))

(defmethod internal-integer-float-form ((float-type (eql 'single-float)) significand exponent sign)
`(internal-integer-float/single-float ,significand ,exponent ,sign))

Expand All @@ -109,3 +113,7 @@
#+quaviver/long-float
(defmethod internal-integer-float-form ((float-type (eql 'long-float)) significand exponent sign)
`(internal-integer-float/long-float ,significand ,exponent ,sign))

#-quaviver/long-float
(defmethod internal-integer-float-form ((float-type (eql 'long-float)) significand exponent sign)
`(internal-integer-float/double-float ,significand ,exponent ,sign))

0 comments on commit e424f30

Please sign in to comment.