diff --git a/scheme/ikarus.boot.orig b/scheme/ikarus.boot.orig index 63fff55..c606bfd 100644 Binary files a/scheme/ikarus.boot.orig and b/scheme/ikarus.boot.orig differ diff --git a/scheme/ikarus.bytevectors.ss b/scheme/ikarus.bytevectors.ss index 52763a9..11b11fd 100644 --- a/scheme/ikarus.bytevectors.ss +++ b/scheme/ikarus.bytevectors.ss @@ -1037,7 +1037,7 @@ ($fx< i ($bytevector-length bv))) (case endianness [(little) ($bytevector-ieee-single-native-ref bv i)] - ;[(big) ($bytevector-ieee-single-nonnative-ref bv i)] + [(big) ($bytevector-ieee-single-nonnative-ref bv i)] [else (error 'bytevector-ieee-single-ref "invalid endianness" endianness)]) (error 'bytevector-ieee-single-ref "invalid index" i)) @@ -1068,7 +1068,7 @@ (if (flonum? x) (case endianness [(little) ($bytevector-ieee-single-native-set! bv i x)] - ; [(big) ($bytevector-ieee-single-nonnative-set! bv i x)] + [(big) ($bytevector-ieee-single-nonnative-set! bv i x)] [else (error 'bytevector-ieee-single-set! "invalid endianness" endianness)]) (error 'bytevector-ieee-single-set! "not a flonum" x)) diff --git a/scheme/pass-specify-rep-primops.ss b/scheme/pass-specify-rep-primops.ss index 6cb7a33..e7000dc 100644 --- a/scheme/pass-specify-rep-primops.ss +++ b/scheme/pass-specify-rep-primops.ss @@ -1499,6 +1499,22 @@ (prm 'int+ (T bv) (prm 'sra (T i) (K fixnum-shift))) (K (- disp-bytevector-data bytevector-tag))))]) +(define-primop $bytevector-ieee-single-nonnative-ref unsafe + [(V bv i) + (let ([bvoff (- disp-bytevector-data bytevector-tag)] + [floff (- disp-flonum-data vector-tag)]) + (with-tmp ([x (prm 'alloc (K (align flonum-size)) (K vector-tag))]) + (prm 'mset x (K (- vector-tag)) (K flonum-tag)) + (with-tmp ([t (prm 'int+ (T bv) (prm 'sra (T i) (K fixnum-shift)))]) + (with-tmp ([x0 (prm 'mref t (K bvoff))]) + (prm 'bswap! x0 x0) + (prm 'mset x (K floff) x0))) + (prm 'fl:load-single x (K floff)) + (prm 'fl:single->double) + (prm 'fl:store x (K floff)) + x))]) + + ;;; the following uses unsupported sse3 instructions ;(define-primop $bytevector-ieee-double-nonnative-set! unsafe ; [(E bv i x) @@ -1524,6 +1540,19 @@ (prm 'bswap! x0 x0) (prm 'mset t (K bvoff) x0))))]) +(define-primop $bytevector-ieee-single-nonnative-set! unsafe + [(E bv i x) + (let ([bvoff (- disp-bytevector-data bytevector-tag)] + [floff (- disp-flonum-data vector-tag)]) + (seq* + (prm 'fl:load (T x) (K floff)) + (prm 'fl:double->single) + (with-tmp ([t (prm 'int+ (T bv) + (prm 'sra (T i) (K fixnum-shift)))]) + (prm 'fl:store-single t (K bvoff)) + (with-tmp ([x0 (prm 'mref t (K bvoff))]) + (prm 'bswap! x0 x0) + (prm 'mset t (K bvoff) x0)))))]) /section) (section ;;; strings diff --git a/scheme/tests/bytevectors.ss b/scheme/tests/bytevectors.ss index 4408b53..8bffb9b 100644 --- a/scheme/tests/bytevectors.ss +++ b/scheme/tests/bytevectors.ss @@ -317,27 +317,24 @@ (bytevector-ieee-single-set! v 0 17.0 'little) (bytevector-ieee-single-ref v 0 'little))] -; [(lambda (x) (= x 17.0)) -; (let ([v (make-bytevector 8)]) -; (bytevector-ieee-single-set! v 0 17.0 'big) -; (bytevector-ieee-single-ref v 0 'big))] -; -; [(lambda (x) (= x 17.0)) -; (let ([v1 (make-bytevector 8)]) -; (bytevector-ieee-single-set! v1 0 17.0 'little) -; (let ([v2 (u8-list->bytevector -; (reverse (bytevector->u8-list v1)))]) -; (bytevector-ieee-single-ref v2 0 'big)))] -; -; [(lambda (x) (= x 17.0)) -; (let ([v1 (make-bytevector 8)]) -; (bytevector-ieee-single-set! v1 0 17.0 'big) -; (let ([v2 (u8-list->bytevector -; (reverse (bytevector->u8-list v1)))]) -; (bytevector-ieee-single-ref v2 0 'little)))] - - + [(lambda (x) (= x 17.0)) + (let ([v (make-bytevector 4)]) + (bytevector-ieee-single-set! v 0 17.0 'big) + (bytevector-ieee-single-ref v 0 'big))] + + [(lambda (x) (= x 17.0)) + (let ([v1 (make-bytevector 4)]) + (bytevector-ieee-single-set! v1 0 17.0 'little) + (let ([v2 (u8-list->bytevector + (reverse (bytevector->u8-list v1)))]) + (bytevector-ieee-single-ref v2 0 'big)))] + [(lambda (x) (= x 17.0)) + (let ([v1 (make-bytevector 4)]) + (bytevector-ieee-single-set! v1 0 17.0 'big) + (let ([v2 (u8-list->bytevector + (reverse (bytevector->u8-list v1)))]) + (bytevector-ieee-single-ref v2 0 'little)))] )) diff --git a/scheme/todo-r6rs.ss b/scheme/todo-r6rs.ss index 268dbf2..7c5fad2 100755 --- a/scheme/todo-r6rs.ss +++ b/scheme/todo-r6rs.ss @@ -379,10 +379,10 @@ [bytevector-ieee-double-native-set! C bv] [bytevector-ieee-double-ref C bv] [bytevector-ieee-double-set! C bv] - [bytevector-ieee-single-native-ref S bv] - [bytevector-ieee-single-native-set! S bv] - [bytevector-ieee-single-ref S bv] - [bytevector-ieee-single-set! S bv] + [bytevector-ieee-single-native-ref C bv] + [bytevector-ieee-single-native-set! C bv] + [bytevector-ieee-single-ref C bv] + [bytevector-ieee-single-set! C bv] [bytevector-length C bv] [bytevector-s16-native-ref C bv] [bytevector-s16-native-set! C bv]