[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 08/437: fixes to sparc floating point
From: |
Andy Wingo |
Subject: |
[Guile-commits] 08/437: fixes to sparc floating point |
Date: |
Mon, 2 Jul 2018 05:13:34 -0400 (EDT) |
wingo pushed a commit to branch lightning
in repository guile.
commit 7101c65e25b35d966e8f13012268908069d539c7
Author: Paolo Bonzini <address@hidden>
Date: Wed Nov 10 11:39:55 2004 +0000
fixes to sparc floating point
2004-11-09 Paolo Bonzini <address@hidden>
* lightning/sparc/fp.h: Fix fp-to-integer conversions.
* lightning/ppc/testfp.c: Test fp-to-integer conversions
of integer numbers.
* lightning/ppc/testfp.ok: Adjust for the above.
git-archimport-id: address@hidden/lightning--stable--1.2--patch-8
---
ChangeLog | 7 +++
lightning/sparc/fp.h | 117 +++++++++++++++++++++++++++++++++++++--------------
tests/testfp.c | 4 ++
tests/testfp.ok | 4 ++
4 files changed, 101 insertions(+), 31 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 2c69db7..3cccbd1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2004-11-09 Paolo Bonzini <address@hidden>
+
+ * lightning/sparc/fp.h: Fix fp-to-integer conversions.
+ * lightning/ppc/testfp.c: Test fp-to-integer conversions
+ of integer numbers.
+ * lightning/ppc/testfp.ok: Adjust for the above.
+
2004-11-08 Paolo Bonzini <address@hidden>
* lightning/ppc/testfp.c: Always flush code before
diff --git a/lightning/sparc/fp.h b/lightning/sparc/fp.h
index 5632ac8..f22578d 100644
--- a/lightning/sparc/fp.h
+++ b/lightning/sparc/fp.h
@@ -35,6 +35,8 @@
#ifndef __lightning_asm_fp_h
#define __lightning_asm_fp_h
+#include <float.h>
+
#define JIT_FPR_NUM 6
#define JIT_FPR(i) (30-(i)*2)
#define JIT_FPTMP 18
@@ -88,37 +90,90 @@
#define jit_stxr_f(d1, d2, rs) STFrx((rs), (d1), (d2))
#define jit_stxr_d(d1, d2, rs) STDFrx((rs), (d1), (d2))
-#define jit_do_round(mode, rd, freg, macro) ( \
- _1(_jit.x.pc + 3), \
- SETHIir(_HI(mode << 29), JIT_BIG), \
- NOP(), \
- STFSRm(_Ro(7), 8), /* store fsr */ \
- LDmr(_Ro(7), 8, rd), \
- XORrrr(rd, JIT_BIG, JIT_BIG), /* adjust mode */ \
- STrm(JIT_BIG, _Ro(7), 8), \
- LDFSRm(_Ro(7), 8), /* load fsr */ \
- macro, /* truncate */ \
- STrm(rd, _Ro(7), 8), /* load old fsr */ \
- LDFSRm(_Ro(7), 8), \
- STFrm(JIT_FPTMP, _Ro(7), 8), /* store truncated value */ \
- LDmr(_Ro(7), 8, rd)) /* load it into rd */
-
-#define jit_do_round_no_fsr(macro1, macro2) ( \
- _1(_jit.x.pc + 3), \
- macro1, \
- NOP(), \
- macro2)
-
-#define jit_extr_i_d(rd, rs) jit_do_round_no_fsr (NOP(),
(STrm((rs), _Ro(7), 8), LDFmr(_Ro(7), 8, (rd)), FITODrr((rd), (rd))))
-#define jit_extr_i_f(rd, rs) jit_do_round_no_fsr (NOP(),
(STrm((rs), _Ro(7), 8), LDFmr(_Ro(7), 8, (rd)), FITOSrr((rd), (rd))))
-#define jit_roundr_d_i(rd, rs) jit_do_round_no_fsr (FDTOIrr((rs),
JIT_FPTMP), (STFrm(JIT_FPTMP, _Ro(7), 8), LDmr(_Ro(7), 8, (rd))))
-#define jit_roundr_f_i(rd, rs) jit_do_round_no_fsr (FSTOIrr((rs),
JIT_FPTMP), (STFrm(JIT_FPTMP, _Ro(7), 8), LDmr(_Ro(7), 8, (rd))))
-#define jit_floorr_d_i(rd, rs) jit_do_round(3, (rd), (rs),
FDTOIrr((rs), JIT_FPTMP))
-#define jit_ceilr_d_i(rd, rs) jit_do_round(2, (rd), (rs),
FDTOIrr((rs), JIT_FPTMP))
-#define jit_truncr_d_i(rd, rs) jit_do_round(1, (rd), (rs),
FDTOIrr((rs), JIT_FPTMP))
-#define jit_floorr_f_i(rd, rs) jit_do_round(3, (rd), (rs),
FSTOIrr((rs), JIT_FPTMP))
-#define jit_ceilr_f_i(rd, rs) jit_do_round(2, (rd), (rs),
FSTOIrr((rs), JIT_FPTMP))
-#define jit_truncr_f_i(rd, rs) jit_do_round(1, (rd), (rs),
FSTOIrr((rs), JIT_FPTMP))
+#define jit_truncr_f_i(rd, rs) ( \
+ _1(_jit.x.pc + 3), \
+ FSTOIrr((rs), JIT_FPTMP), \
+ NOP(), \
+ STFrm(JIT_FPTMP, _Ro(7), 8), \
+ LDmr(_Ro(7), 8, (rd)))
+
+#define jit_truncr_d_i(rd, rs) ( \
+ _1(_jit.x.pc + 3), \
+ FDTOIrr((rs), JIT_FPTMP), \
+ NOP(), \
+ STFrm(JIT_FPTMP, _Ro(7), 8), \
+ LDmr(_Ro(7), 8, (rd)))
+
+#define jit_extr_i_d(rd, rs) (_1 (_jit.x.pc + 3), NOP(), NOP(),
STrm((rs), _Ro(7), 8), LDFmr(_Ro(7), 8, (rd)), FITODrr((rd), (rd)))
+#define jit_extr_i_f(rd, rs) (_1 (_jit.x.pc + 3), NOP(), NOP(),
STrm((rs), _Ro(7), 8), LDFmr(_Ro(7), 8, (rd)), FITOSrr((rd), (rd)))
+
+#define jit_do_round_f(rd, rs, fixup, mode) do { \
+ jit_movi_f (JIT_FPTMP, fixup); \
+ _1(_jit.x.pc + 4); \
+ SETHIir(_HI(mode << 29), JIT_BIG); \
+ NOP(); \
+ NOP(); \
+ STFSRm(_Ro(7), 8); /* store fsr */ \
+ LDmr(_Ro(7), 8, rd); \
+ XORrrr(rd, JIT_BIG, JIT_BIG); /* adjust mode */ \
+ STrm(JIT_BIG, _Ro(7), 12); \
+ LDFSRm(_Ro(7), 12); /* load fsr */ \
+ FADDSrrr ((rs), JIT_FPTMP, JIT_FPTMP); \
+ LDFSRm(_Ro(7), 8); \
+ FSTOIrr(JIT_FPTMP, JIT_FPTMP); \
+ STFrm(JIT_FPTMP, _Ro(7), 8); \
+ LDmr(_Ro(7), 8, (rd)); \
+ ADDCCrrr ((rd), (rd), 0); \
+ SUBXrrr ((rd), 0, (rd)); \
+ } while (0);
+
+#define jit_do_round_d(rd, rs, fixup, mode) do { \
+ jit_movi_d (JIT_FPTMP, fixup); \
+ _1(_jit.x.pc + 4); \
+ SETHIir(_HI(mode << 29), JIT_BIG); \
+ NOP(); \
+ NOP(); \
+ STFSRm(_Ro(7), 8); /* store fsr */ \
+ LDmr(_Ro(7), 8, rd); \
+ XORrrr(rd, JIT_BIG, JIT_BIG); /* adjust mode */ \
+ STrm(JIT_BIG, _Ro(7), 12); \
+ LDFSRm(_Ro(7), 12); /* load fsr */ \
+ FADDDrrr ((rs), JIT_FPTMP, JIT_FPTMP); \
+ LDFSRm(_Ro(7), 8); \
+ FDTOIrr(JIT_FPTMP, JIT_FPTMP); \
+ STFrm(JIT_FPTMP, _Ro(7), 8); \
+ LDmr(_Ro(7), 8, (rd)); \
+ ADDCCrrr ((rd), (rd), 0); \
+ SUBXrrr ((rd), 0, (rd)); \
+ } while (0);
+
+#define jit_roundr_f_i(rd, rs) do { \
+ jit_movi_f (JIT_FPTMP, 0.5); \
+ FADDSrrr ((rs), JIT_FPTMP, JIT_FPTMP); \
+ jit_truncr_f_i ((rd), JIT_FPTMP); \
+ ADDCCrrr ((rd), (rd), 0); \
+ SUBXrrr ((rd), 0, (rd)); \
+ } while (0)
+
+#define jit_roundr_d_i(rd, rs) do { \
+ jit_movi_d (JIT_FPTMP, 0.5); \
+ FADDDrrr ((rs), JIT_FPTMP, JIT_FPTMP); \
+ jit_truncr_d_i ((rd), JIT_FPTMP); \
+ ADDCCrrr ((rd), (rd), 0); \
+ SUBXrrr ((rd), 0, (rd)); \
+ } while (0)
+
+#define jit_ceilr_f_i(rd, rs) \
+ jit_do_round_f ((rd), (rs), 1.0f - FLT_EPSILON, 3)
+
+#define jit_ceilr_d_i(rd, rs) \
+ jit_do_round_d ((rd), (rs), 1.0 - DBL_EPSILON, 3)
+
+#define jit_floorr_f_i(rd, rs) \
+ jit_do_round_f ((rd), (rs), FLT_EPSILON, 2)
+
+#define jit_floorr_d_i(rd, rs) \
+ jit_do_round_d ((rd), (rs), DBL_EPSILON, 2)
#define jit_ltr_d(d, s1, s2) (FCMPDrr ((s1), (s2)), FBLi(_jit.x.pc
+ 3), MOVir (1, (d)), MOVir (0, (d)))
#define jit_ltr_f(d, s1, s2) (FCMPSrr ((s1), (s2)), FBLi(_jit.x.pc
+ 3), MOVir (1, (d)), MOVir (0, (d)))
diff --git a/tests/testfp.c b/tests/testfp.c
index a260440..b9792be 100644
--- a/tests/testfp.c
+++ b/tests/testfp.c
@@ -108,6 +108,7 @@ main()
#endif
#ifndef LIGHTNING_CROSS
int_test("trunc", code, -2.6, -2.4, 0, 2.4, 2.6);
+ int_test("trunc", code, -3, -2, 0, 2, 3);
#endif
jit_set_ip(codeBuffer);
@@ -122,6 +123,7 @@ main()
#endif
#ifndef LIGHTNING_CROSS
int_test("ceil", code, -2.6, -2.4, 0, 2.4, 2.6);
+ int_test("ceil", code, -3, -2, 0, 2, 3);
#endif
jit_set_ip(codeBuffer);
@@ -136,6 +138,7 @@ main()
#endif
#ifndef LIGHTNING_CROSS
int_test("floor", code, -2.6, -2.4, 0, 2.4, 2.6);
+ int_test("floor", code, -3, -2, 0, 2, 3);
#endif
jit_set_ip(codeBuffer);
@@ -150,6 +153,7 @@ main()
#endif
#ifndef LIGHTNING_CROSS
int_test("round", code, -2.6, -2.4, 0, 2.4, 2.6);
+ int_test("round", code, -3, -2, 0, 2, 3);
#endif
#if 0 && defined JIT_TRANSCENDENTAL
diff --git a/tests/testfp.ok b/tests/testfp.ok
index e23a31d..6205c85 100644
--- a/tests/testfp.ok
+++ b/tests/testfp.ok
@@ -1,6 +1,10 @@
compare -1 -1 0 1 1
nans 0 2 2 1 2
trunc -2 -2 0 2 2
+trunc -3 -2 0 2 3
ceil -2 -2 0 3 3
+ceil -3 -2 0 2 3
floor -3 -3 0 2 2
+floor -3 -2 0 2 3
+round -3 -2 0 2 3
round -3 -2 0 2 3
- [Guile-commits] 12/437: remove unused variable., (continued)
- [Guile-commits] 12/437: remove unused variable., Andy Wingo, 2018/07/02
- [Guile-commits] 11/437: include sys/mman.h under Linux/i386, Andy Wingo, 2018/07/02
- [Guile-commits] 13/437: add JC/JNC, Andy Wingo, 2018/07/02
- [Guile-commits] 15/437: fix heading in ppc/fp.h and sparc/fp.h, Andy Wingo, 2018/07/02
- [Guile-commits] 19/437: fix mprotect for i386, Andy Wingo, 2018/07/02
- [Guile-commits] 06/437: fix ppc tests, Andy Wingo, 2018/07/02
- [Guile-commits] 17/437: fix PPC jit_ldxi_* with big displacement, Andy Wingo, 2018/07/02
- [Guile-commits] 22/437: one more tweak to fix distribution, Andy Wingo, 2018/07/02
- [Guile-commits] 18/437: don't use __func__ nor __FUNCTION__ if not compiling with GNU C., Andy Wingo, 2018/07/02
- [Guile-commits] 26/437: fix i386 syntax error, Andy Wingo, 2018/07/02
- [Guile-commits] 08/437: fixes to sparc floating point,
Andy Wingo <=
- [Guile-commits] 10/437: add more autotools-generated files, Andy Wingo, 2018/07/02
- [Guile-commits] 23/437: fix `make dist' bug and prepare for releasing 1.2a, Andy Wingo, 2018/07/02
- [Guile-commits] 27/437: Fix assertion failures in i386 movs and movz opcodes, Andy Wingo, 2018/07/02
- [Guile-commits] 21/437: clarify bundling documentation and improve autoconf macro, Andy Wingo, 2018/07/02
- [Guile-commits] 32/437: fix powerpc jit_bms, Andy Wingo, 2018/07/02
- [Guile-commits] 24/437: bump version, add ldxi test case, Andy Wingo, 2018/07/02
- [Guile-commits] 30/437: added ret test and clarified JIT_RET documentation, Andy Wingo, 2018/07/02
- [Guile-commits] 20/437: fix PPC modi, Andy Wingo, 2018/07/02
- [Guile-commits] 35/437: remove pushr/popr from testsuite, Andy Wingo, 2018/07/02
- [Guile-commits] 31/437: prepare for automatic variables support, Andy Wingo, 2018/07/02