[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Lightning] Re: Still problems.
From: |
Paolo Bonzini |
Subject: |
[Lightning] Re: Still problems. |
Date: |
Tue, 17 Jun 2008 09:34:30 +0200 |
User-agent: |
Thunderbird 2.0.0.14 (Macintosh/20080421) |
3) modified jit_shift_args to use nbargs instead.
#define jit_shift_args() \
((_jitl.nbargs >= 3 ? (void) (MOVQrr(_R10D, _RDX)) : (void) 0), \
(_jitl.nbargs >= 4 ? (void) (MOVQrr(_R11D, _RCX)) : (void) 0))
With this change, it moves the values as expected.
It turns out that with JIT_Rx mapped to RAX/R10/R11 there is no need for
jit_shift_args anymore. That's good!
I attach the patch I committed so that you can see what's going on.
Paolo
diff --git a/ChangeLog b/ChangeLog
index 1e05fe1..0d0f86a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2008-06-16 Paolo Bonzini <address@hidden>
+
+ * lightning/i386/core.h: Use jit_save in jit_replace. Move JIT_R
+ definition...
+ * lightning/i386/core-32.h: ... here; define jit_save so that
+ the core.h has no effect on the 32-bit backend.
+ * lightning/i386/core-64.h: Place JIT_R1/JIT_R2 in R10/R11,
+ place outgoing arguments in the right spot from the beginning,
+ define jit_save, fix jit_reg8/jit_reg16.
+
2008-06-15 Paolo Bonzini <address@hidden>
* lightning/i386/core-64.h: Rewrite argument passing to
diff --git a/lightning/i386/core-32.h b/lightning/i386/core-32.h
index 9775fc8..46b3516 100644
--- a/lightning/i386/core-32.h
+++ b/lightning/i386/core-32.h
@@ -36,6 +36,9 @@
#define JIT_CAN_16 1
#define JIT_AP _EBP
+
+#define JIT_R_NUM 3
+#define JIT_R(i) (_EAX + (i))
#define JIT_V_NUM 3
#define JIT_V(i) ((i) == 0 ? _EBX : _ESI + (i) - 1)
@@ -46,6 +49,9 @@ struct jit_local_state {
int alloca_slack;
};
+/* Whether a register is used for the user-accessible registers. */
+#define jit_save(reg) 1
+
#define jit_base_prolog() (_jitl.framesize = 20, _jitl.alloca_offset = 0, \
PUSHLr(_EBX), PUSHLr(_ESI), PUSHLr(_EDI), PUSHLr(_EBP), MOVLrr(_ESP, _EBP))
#define jit_base_ret(ofs) \
diff --git a/lightning/i386/core-64.h b/lightning/i386/core-64.h
index 173a229..5da7535 100644
--- a/lightning/i386/core-64.h
+++ b/lightning/i386/core-64.h
@@ -38,6 +38,8 @@
#define JIT_CAN_16 0
#define JIT_REXTMP _R9D
+#define JIT_R_NUM 3
+#define JIT_R(i) ((i) == 0 ? _EAX : _R9D + (i))
#define JIT_V_NUM 3
#define JIT_V(i) ((i) == 0 ? _EBX : _R11D + (i))
@@ -51,6 +53,9 @@ struct jit_local_state {
int alloca_slack;
};
+/* Whether a register in the "low" bank is used for the user-accessible
+ registers. */
+#define jit_save(reg) ((reg) == _EAX || (reg) == _EBX)
/* Keep the stack 16-byte aligned, the SSE hardware prefers it this way. */
#define jit_allocai_internal(amount, slack) \
@@ -128,19 +133,13 @@ struct jit_local_state {
/* Stack isn't used for arguments: */
#define jit_prepare_i(ni) (_jitl.argssize = (ni))
-#define jit_pusharg_i(rs) (--_jitl.argssize, MOVQrr(rs,
jit_arg_reg_temp[_jitl.argssize]))
-#define jit_finish(sub) (jit_shift_args(), \
- MOVQir((long) (sub), JIT_REXTMP), \
+#define jit_pusharg_i(rs) (--_jitl.argssize, MOVQrr(rs,
jit_arg_reg_order[_jitl.argssize]))
+#define jit_finish(sub) (MOVQir((long) (sub), JIT_REXTMP), \
CALLsr(JIT_REXTMP))
#define jit_reg_is_arg(reg) ((reg) == _ECX || (reg) == _EDX)
#define jit_finishr(reg) ((jit_reg_is_arg((reg)) ? MOVQrr(reg,
JIT_REXTMP) : (void)0), \
- jit_shift_args(), \
CALLsr(jit_reg_is_arg((reg)) ? JIT_REXTMP :
(reg)))
-#define jit_shift_args() \
- ((_jitl.argssize >= 3 ? (void) (MOVQrr(_R10D, _RDX)) : (void) 0), \
- (_jitl.argssize >= 4 ? (void) (MOVQrr(_R11D, _RCX)) : (void) 0))
-
#define jit_retval_l(rd) ((void)jit_movr_l ((rd), _EAX))
#define jit_arg_c()
(jit_arg_reg_order[_jitl.nextarg_geti++])
#define jit_arg_uc()
(jit_arg_reg_order[_jitl.nextarg_geti++])
@@ -152,7 +151,6 @@ struct jit_local_state {
#define jit_arg_ul()
(jit_arg_reg_order[_jitl.nextarg_geti++])
#define jit_arg_p()
(jit_arg_reg_order[_jitl.nextarg_geti++])
-static int jit_arg_reg_temp[] = { _EDI, _ESI, _R10D, _R11D, _R8D, _R9D };
static int jit_arg_reg_order[] = { _EDI, _ESI, _EDX, _ECX, _R8D, _R9D };
#define jit_negr_l(d, rs) jit_opi_((d), (rs), NEGQr(d), (XORQrr((d),
(d)), SUBQrr((rs), (d))) )
@@ -185,8 +183,8 @@ static int jit_arg_reg_order[] = { _EDI, _ESI, _EDX, _ECX,
_R8D, _R9D };
/* Used to implement ldc, stc, ... We have SIL and friends which simplify it
all. */
#define jit_check8(rs) 1
-#define jit_reg8(rs) (_rN(rs) | _AL )
-#define jit_reg16(rs) (_rN(rs) | _AX )
+#define jit_reg8(rs) (_rR(rs) | _AL )
+#define jit_reg16(rs) (_rR(rs) | _AX )
#define jit_movbrm(rs, dd, db, di, ds) MOVBrm(jit_reg8(rs), dd, db,
di, ds)
#define jit_ldi_c(d, is) (_u32P((long)(is)) ? MOVSBLmr((is), 0,
0, 0, (d)) : (jit_movi_l(JIT_REXTMP, is), jit_ldr_c(d, JIT_REXTMP)))
diff --git a/lightning/i386/core.h b/lightning/i386/core.h
index ad99d4d..64f8e80 100644
--- a/lightning/i386/core.h
+++ b/lightning/i386/core.h
@@ -38,9 +38,6 @@
#define JIT_SP _ESP
#define JIT_RET _EAX
-#define JIT_R_NUM 3
-#define JIT_R(i) (_EAX + (i))
-
/* 3-parameter operation */
#define jit_opr_(d, s1, s2, op1d, op2d)
\
@@ -64,7 +61,11 @@
/* 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_pushr_i(forced), MOVLrr(rs, forced), op,
jit_popr_i(forced)))
+ (rs == forced) ? op : \
+ jit_save (forced) \
+ ? (jit_pushr_i(forced), jit_movr_l(rs, forced), op, \
+ jit_popr_i(forced)) \
+ : (jit_movr_l(rs, forced), op))
/* For LT, LE, ... */
#define jit_replace8(d, cmp, op) \
- [Lightning] Re: Still problems.,
Paolo Bonzini <=