[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 97/437: fix x86 shifts
From: |
Andy Wingo |
Subject: |
[Guile-commits] 97/437: fix x86 shifts |
Date: |
Mon, 2 Jul 2018 05:13:53 -0400 (EDT) |
wingo pushed a commit to branch lightning
in repository guile.
commit 7179d226edc5d7c66083a912698150ec49c50714
Author: Paolo Bonzini <address@hidden>
Date: Sun Mar 1 17:59:41 2009 +0100
fix x86 shifts
2009-03-01 Paolo Bonzini <address@hidden>
* lightning/i386/core-64.h: Use Mike's macros for x86-64 too.
* lightning/i386/core.h: Remove jit_replace.
2009-02-27 Mike Spivey <address@hidden>
* lightning/i386/core.h: Rewrite shift-handling macros.
* lightning/fp-common.h: Fix jit_extr_{f_d,d_f}.
---
ChangeLog | 10 ++++++++++
lightning/fp-common.h | 4 ++--
lightning/i386/core-64.h | 7 ++++---
lightning/i386/core.h | 35 +++++++++++++++++++++++------------
4 files changed, 39 insertions(+), 17 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 95de9ec..1ca212a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-03-01 Paolo Bonzini <address@hidden>
+
+ * lightning/i386/core-64.h: Use Mike's macros for x86-64 too.
+ * lightning/i386/core.h: Remove jit_replace.
+
+ 2009-02-27 Mike Spivey <address@hidden>
+
+ * lightning/i386/core.h: Rewrite shift-handling macros.
+ * lightning/fp-common.h: Fix jit_extr_{f_d,d_f}.
+
2009-02-17 Mike Spivey <address@hidden>
* lightning/i386/core.h: Fix blunder in operand order.
diff --git a/lightning/fp-common.h b/lightning/fp-common.h
index 0847ceb..5dfe3cb 100644
--- a/lightning/fp-common.h
+++ b/lightning/fp-common.h
@@ -61,8 +61,8 @@
#define jit_abs_f(rd,rs) jit_abs_d(rd,rs)
#define jit_negr_f(rd,rs) jit_negr_d(rd,rs)
#define jit_sqrt_f(rd,rs) jit_sqrt_d(rd,rs)
-#define jit_extr_f_d(rs, rd)
-#define jit_extr_d_f(rs, rd)
+#define jit_extr_f_d(rs, rd) jit_movr_d(rd, rs)
+#define jit_extr_d_f(rs, rd) jit_movr_d(rd, rs)
#define jit_extr_i_f(rd, rs) jit_extr_i_d(rd, rs)
#define jit_roundr_f_i(rd, rs) jit_roundr_d_i(rd, rs)
#define jit_floorr_f_i(rd, rs) jit_floorr_d_i(rd, rs)
diff --git a/lightning/i386/core-64.h b/lightning/i386/core-64.h
index 5da7535..9cd48cb 100644
--- a/lightning/i386/core-64.h
+++ b/lightning/i386/core-64.h
@@ -114,9 +114,10 @@ struct jit_local_state {
#define jit_lshi_l(d, rs, is) ((is) <= 3 ? LEAQmr(0, 0, (rs), 1 << (is),
(d)) : jit_qop_small ((d), (rs), SHLQir((is), (d)) ))
#define jit_rshi_l(d, rs, is)
jit_qop_small ((d), (rs), SARQir((is), (d)) )
#define jit_rshi_ul(d, rs, is)
jit_qop_small ((d), (rs), SHRQir((is), (d)) )
-#define jit_lshr_l(d, r1, r2) jit_replace((r1), (r2), _ECX,
jit_qop_small ((d), (r1), SHLQrr(_CL, (d)) ))
-#define jit_rshr_l(d, r1, r2) jit_replace((r1), (r2), _ECX,
jit_qop_small ((d), (r1), SARQrr(_CL, (d)) ))
-#define jit_rshr_ul(d, r1, r2) jit_replace((r1), (r2), _ECX,
jit_qop_small ((d), (r1), SHRQrr(_CL, (d)) ))
+#define jit_lshr_l(d, r1, r2) jit_shift((d), (r1), (r2), SHLQrr)
+#define jit_rshr_l(d, r1, r2) jit_shift((d), (r1), (r2), SARQrr)
+#define jit_rshr_ul(d, r1, r2) jit_shift((d), (r1), (r2), SHRQrr)
+
/* Stack */
#define jit_pushr_i(rs) PUSHQr(rs)
diff --git a/lightning/i386/core.h b/lightning/i386/core.h
index 2f017f9..0442944 100644
--- a/lightning/i386/core.h
+++ b/lightning/i386/core.h
@@ -58,15 +58,6 @@
#define jit_opi_(d, rs, opdi, opdri) \
((rs == d) ? opdi : opdri)
-/* An operand is forced into a register */
-#define jit_replace(rd, rs, forced, op)
\
- ((rd == forced) ? JITSORRY("Register conflict for " # op) : \
- (rs == forced) ? op : \
- jit_save (forced) \
- ? (jit_pushr_i(forced), jit_movr_l(forced, rs), op, \
- jit_popr_i(forced)) \
- : (jit_movr_l(rs, forced), op))
-
/* For LT, LE, ... */
#define jit_replace8(d, cmp, op) \
(jit_check8(d) \
@@ -239,12 +230,32 @@
/* Shifts */
+#define jit_shift(d, s1, s2, m) \
+ ((d) == _ECX || (d) == (s2) \
+ ? ((s2) == _EAX \
+ ? jit_fixd(d, _EDX, jit_shift2(_EDX, s1, s2, m)) \
+ : jit_fixd(d, _EAX, jit_shift2(_EAX, s1, s2, m))) \
+ : jit_shift2(d, s1, s2, m))
+
+/* Shift operation, assuming d != s2 or ECX */
+#define jit_shift2(d, s1, s2, m) \
+ jit_op_(d, s1, jit_cfixs(s2, _ECX, m(_CL, d)))
+
+/* Substitute x for destination register d */
+#define jit_fixd(d, x, op) \
+ (jit_pushr_i(x), op, jit_movr_i(d, x), jit_popr_i(x))
+
+/* Conditionally substitute y for source register s */
+#define jit_cfixs(s, y, op) \
+ ((s) == (y) ? op : \
+ (jit_pushr_i(y), jit_movr_i(y, s), op, jit_popr_i(y)))
+
#define jit_lshi_i(d, rs, is) ((is) <= 3 ? LEALmr(0, 0, (rs), 1 << (is),
(d)) : jit_op_ ((d), (rs), SHLLir((is), (d)) ))
#define jit_rshi_i(d, rs, is)
jit_op_ ((d), (rs), SARLir((is), (d)) )
#define jit_rshi_ui(d, rs, is)
jit_op_ ((d), (rs), SHRLir((is), (d)) )
-#define jit_lshr_i(d, r1, r2) jit_replace((r1), (r2), _ECX,
jit_op_ ((d), (r1), SHLLrr(_CL, (d)) ))
-#define jit_rshr_i(d, r1, r2) jit_replace((r1), (r2), _ECX,
jit_op_ ((d), (r1), SARLrr(_CL, (d)) ))
-#define jit_rshr_ui(d, r1, r2) jit_replace((r1), (r2), _ECX,
jit_op_ ((d), (r1), SHRLrr(_CL, (d)) ))
+#define jit_lshr_i(d, r1, r2) jit_shift((d), (r1), (r2), SHLLrr)
+#define jit_rshr_i(d, r1, r2) jit_shift((d), (r1), (r2), SARLrr)
+#define jit_rshr_ui(d, r1, r2) jit_shift((d), (r1), (r2), SHRLrr)
/* Stack */
#define jit_retval_i(rd) ((void)jit_movr_i ((rd), _EAX))
- [Guile-commits] 71/437: add missing x86-64 memory operations, (continued)
- [Guile-commits] 71/437: add missing x86-64 memory operations, Andy Wingo, 2018/07/02
- [Guile-commits] 84/437: move x86-64 JIT_V1/JIT_V2 in R12/R13, Andy Wingo, 2018/07/02
- [Guile-commits] 83/437: detect 32-/64-bit variant of i386 back-end at include time (not configure time), Andy Wingo, 2018/07/02
- [Guile-commits] 86/437: fix x86-64 jit_movi_l (x, 0) and 16-byte stack alignment in the prolog, Andy Wingo, 2018/07/02
- [Guile-commits] 91/437: fix miscellaneous PPC-32 back-end bugs, Andy Wingo, 2018/07/02
- [Guile-commits] 103/437: fix two bugs in load/store for i386, Andy Wingo, 2018/07/02
- [Guile-commits] 100/437: fix jit_movbrm in the i386 backend, Andy Wingo, 2018/07/02
- [Guile-commits] 58/437: use CALLsr, not CALLLsr, Andy Wingo, 2018/07/02
- [Guile-commits] 60/437: don't use _VOID symbol, reserved by newlib (cygwin), Andy Wingo, 2018/07/02
- [Guile-commits] 96/437: fix blunder in operand order (i386), Andy Wingo, 2018/07/02
- [Guile-commits] 97/437: fix x86 shifts,
Andy Wingo <=
- [Guile-commits] 104/437: fix jit_extr_f_d and jit_extr_d_f for x86-64, Andy Wingo, 2018/07/02
- [Guile-commits] 107/437: fix -D_ASM_SAFETY compilation of beqr_d and bne_d, Andy Wingo, 2018/07/02
- [Guile-commits] 101/437: fix i386 jit_replace and x86_64 jit_movi_f, Andy Wingo, 2018/07/02
- [Guile-commits] 118/437: Account stack alignment on jit functions with odd number of arguments., Andy Wingo, 2018/07/02
- [Guile-commits] 03/437: big merge, Andy Wingo, 2018/07/02
- [Guile-commits] 111/437: Define extra SSE2 xmmN registers and set JIT_FPTMP to the topmost one., Andy Wingo, 2018/07/02
- [Guile-commits] 94/437: fix problems with i386 32-bit floating point branches, Andy Wingo, 2018/07/02
- [Guile-commits] 115/437: Change JIT_FPR_NUM to 7 to prevent clobber of JIT_FPR(7), Andy Wingo, 2018/07/02
- [Guile-commits] 112/437: Add safety check on number of integer and float arguments on x86_64., Andy Wingo, 2018/07/02
- [Guile-commits] 95/437: another fix to jit_fp_btest, Andy Wingo, 2018/07/02