1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-14 15:40:19 +02:00

bv-{f32,f64}-{ref,set!} operate on raw f64 values

* module/language/tree-il/compile-cps.scm (convert): Box results of
  bv-f32-ref and bv-f64-ref.  Unbox the argument to bv-f32-set! and
  bv-f64-set!.

* libguile/vm-engine.c (bv-f32-ref, bv-f64-ref): Results are raw.
  (bv-f32-set!, bv-f64-set!): Take unboxed arguments.

* module/system/vm/assembler.scm (emit-scm->f64, emit-f64->scm):
  Export.

* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/effects-analysis.scm: Add support for scm->f64 and
  f64->scm.

* module/language/cps/slot-allocation.scm (compute-var-representations):
  Add cases for primops returning raw values.

* module/language/cps/types.scm (bv-f32-ref, bv-f32-set!)
  (bv-f64-ref, bv-f64-set!): Deal in &f64 values instead of reals.
This commit is contained in:
Andy Wingo 2015-11-11 10:17:08 +01:00
parent 608753982f
commit b1ac8d68b5
7 changed files with 68 additions and 18 deletions

View file

@ -3032,14 +3032,22 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
i = SCM_I_INUM (idx); \
float_ptr = (type *) (SCM_BYTEVECTOR_CONTENTS (bv) + i); \
\
SYNC_IP (); \
if (SCM_LIKELY (SCM_I_INUMP (idx) \
&& (i >= 0) \
&& (i + size <= SCM_BYTEVECTOR_LENGTH (bv)) \
&& (ALIGNED_P (float_ptr, type)))) \
RETURN (scm_from_double (*float_ptr)); \
{ \
SP_SET_F64 (dst, *float_ptr); \
NEXT (1); \
} \
else \
RETURN (scm_bytevector_ ## fn_stem ## _native_ref (bv, idx)); \
{ \
SCM val; \
SYNC_IP (); \
val = scm_bytevector_ ## fn_stem ## _native_ref (bv, idx); \
SP_SET_F64 (dst, scm_to_double (val)); \
NEXT (1); \
} \
} while (0)
VM_DEFINE_OP (116, bv_u8_ref, "bv-u8-ref", OP1 (X8_S8_S8_S8) | OP_DST)
@ -3157,13 +3165,14 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
do { \
scm_t_uint8 dst, idx, src; \
scm_t_signed_bits i; \
SCM bv, scm_idx, val; \
SCM bv, scm_idx; \
double val; \
type *float_ptr; \
\
UNPACK_8_8_8 (op, dst, idx, src); \
bv = SP_REF (dst); \
scm_idx = SP_REF (idx); \
val = SP_REF (src); \
bv = SP_REF (dst); \
scm_idx = SP_REF (idx); \
val = SP_REF_F64 (src); \
VM_VALIDATE_BYTEVECTOR (bv, "bv-" #stem "-set!"); \
i = SCM_I_INUM (scm_idx); \
float_ptr = (type *) (SCM_BYTEVECTOR_CONTENTS (bv) + i); \
@ -3172,11 +3181,12 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
&& (i >= 0) \
&& (i + size <= SCM_BYTEVECTOR_LENGTH (bv)) \
&& (ALIGNED_P (float_ptr, type)))) \
*float_ptr = scm_to_double (val); \
*float_ptr = val; \
else \
{ \
SCM boxed = scm_from_double (val); \
SYNC_IP (); \
scm_bytevector_ ## fn_stem ## _native_set_x (bv, scm_idx, val); \
scm_bytevector_ ## fn_stem ## _native_set_x (bv, scm_idx, boxed); \
} \
NEXT (1); \
} while (0)