[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 18/21: Add VM ops to pack and unpack raw f64 values.
From: |
Andy Wingo |
Subject: |
[Guile-commits] 18/21: Add VM ops to pack and unpack raw f64 values. |
Date: |
Wed, 28 Oct 2015 22:31:21 +0000 |
wingo pushed a commit to branch wip-2.1.2
in repository guile.
commit 5bbc47b06d9e236b8a2fa2d92cdc8234bc037838
Author: Andy Wingo <address@hidden>
Date: Wed Oct 28 17:58:30 2015 +0000
Add VM ops to pack and unpack raw f64 values.
* libguile/vm-engine.c (scm->f64, f64->scm): New ops.
---
libguile/vm-engine.c | 34 ++++++++++++++++++++++++++++++++--
1 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c
index 7919c46..75e1694 100644
--- a/libguile/vm-engine.c
+++ b/libguile/vm-engine.c
@@ -251,6 +251,9 @@
#define SP_REF(i) (sp[i].as_scm)
#define SP_SET(i,o) (sp[i].as_scm = o)
+#define SP_REF_F64(i) (sp[i].as_f64)
+#define SP_SET_F64(i,o) (sp[i].as_f64 = o)
+
#define VARIABLE_REF(v) SCM_VARIABLE_REF (v)
#define VARIABLE_SET(v,o) SCM_VARIABLE_SET (v, o)
#define VARIABLE_BOUNDP(v) (!scm_is_eq (VARIABLE_REF (v), SCM_UNDEFINED))
@@ -3216,8 +3219,35 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
VM_DEFINE_OP (135, bv_f64_set, "bv-f64-set!", OP1 (X8_S8_S8_S8))
BV_FLOAT_SET (f64, ieee_double, double, 8);
- VM_DEFINE_OP (136, unused_136, NULL, NOP)
- VM_DEFINE_OP (137, unused_137, NULL, NOP)
+ /* scm->f64 dst:12 src:12
+ *
+ * Unpack a raw double-precision floating-point value from SRC and
+ * place it in DST. Note that SRC can be any value on which
+ * scm_to_double can operate.
+ */
+ VM_DEFINE_OP (136, scm_to_f64, "scm->f64", OP1 (X8_S12_S12) | OP_DST)
+ {
+ scm_t_uint16 dst, src;
+ UNPACK_12_12 (op, dst, src);
+ SYNC_IP ();
+ SP_SET_F64 (dst, scm_to_double (SP_REF (src)));
+ NEXT (1);
+ }
+
+ /* f64->scm dst:12 src:12
+ *
+ * Pack a raw double-precision floating point value into an inexact
+ * number allocated on the heap.
+ */
+ VM_DEFINE_OP (137, f64_to_scm, "f64->scm", OP1 (X8_S12_S12) | OP_DST)
+ {
+ scm_t_uint16 dst, src;
+ UNPACK_12_12 (op, dst, src);
+ SYNC_IP ();
+ SP_SET (dst, scm_from_double (SP_REF_F64 (src)));
+ NEXT (1);
+ }
+
VM_DEFINE_OP (138, unused_138, NULL, NOP)
VM_DEFINE_OP (139, unused_139, NULL, NOP)
VM_DEFINE_OP (140, unused_140, NULL, NOP)
- [Guile-commits] 08/21: Don't emit redundant reset-frame before return, (continued)
- [Guile-commits] 08/21: Don't emit redundant reset-frame before return, Andy Wingo, 2015/10/28
- [Guile-commits] 07/21: return-values opcode resets the frame, Andy Wingo, 2015/10/28
- [Guile-commits] 11/21: rtl.test uses return-values, Andy Wingo, 2015/10/28
- [Guile-commits] 10/21: Always emit return-values, Andy Wingo, 2015/10/28
- [Guile-commits] 12/21: Remove use of return in disassembler.scm, Andy Wingo, 2015/10/28
- [Guile-commits] 04/21: CSE can run on first-order CPS, Andy Wingo, 2015/10/28
- [Guile-commits] 09/21: Replace return primcalls with $values, Andy Wingo, 2015/10/28
- [Guile-commits] 13/21: Remove return opcode, Andy Wingo, 2015/10/28
- [Guile-commits] 14/21: Treat tail $values as generating lazy allocations, Andy Wingo, 2015/10/28
- [Guile-commits] 17/21: Stack slots can hold a double, Andy Wingo, 2015/10/28
- [Guile-commits] 18/21: Add VM ops to pack and unpack raw f64 values.,
Andy Wingo <=
- [Guile-commits] 21/21: Scalar replacement for f64->scm, Andy Wingo, 2015/10/28
- [Guile-commits] 20/21: bv-f32-set!, bv-f64-set! take unboxed args, Andy Wingo, 2015/10/28
- [Guile-commits] 15/21: VM support for raw slots, Andy Wingo, 2015/10/28
- [Guile-commits] 19/21: bv-f32-ref and bv-f64-ref return raw f64 values, Andy Wingo, 2015/10/28
- [Guile-commits] 16/21: Reflection support for unboxed f64 slots, Andy Wingo, 2015/10/28