diff options
author | Mike Pall <mike> | 2011-10-22 02:02:51 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2011-10-22 02:02:51 +0200 |
commit | fee957b22d063bab22b1b71221088a5d5d745e7d (patch) | |
tree | 18fd4363f3bffafbf29f943473ce8363f7b40cc3 /src | |
parent | 2e5c0870bcde0fee3cb8fd31de27d30beaa9617e (diff) | |
download | luajit-fee957b22d063bab22b1b71221088a5d5d745e7d.tar.gz luajit-fee957b22d063bab22b1b71221088a5d5d745e7d.tar.bz2 luajit-fee957b22d063bab22b1b71221088a5d5d745e7d.zip |
FFI: Cleanup/fix 64 bit arithmetic in assembler backend.
Diffstat (limited to 'src')
-rw-r--r-- | src/lj_asm_arm.h | 46 | ||||
-rw-r--r-- | src/lj_asm_x86.h | 18 |
2 files changed, 31 insertions, 33 deletions
diff --git a/src/lj_asm_arm.h b/src/lj_asm_arm.h index 20c5d40a..27f1d6c1 100644 --- a/src/lj_asm_arm.h +++ b/src/lj_asm_arm.h | |||
@@ -932,12 +932,18 @@ static void asm_cnew(ASMState *as, IRIns *ir) | |||
932 | const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_mem_newgco]; | 932 | const CCallInfo *ci = &lj_ir_callinfo[IRCALL_lj_mem_newgco]; |
933 | IRRef args[2]; | 933 | IRRef args[2]; |
934 | RegSet allow = (RSET_GPR & ~RSET_SCRATCH); | 934 | RegSet allow = (RSET_GPR & ~RSET_SCRATCH); |
935 | RegSet drop = RSET_SCRATCH; | ||
935 | lua_assert(sz != CTSIZE_INVALID); | 936 | lua_assert(sz != CTSIZE_INVALID); |
936 | 937 | ||
937 | args[0] = ASMREF_L; /* lua_State *L */ | 938 | args[0] = ASMREF_L; /* lua_State *L */ |
938 | args[1] = ASMREF_TMP1; /* MSize size */ | 939 | args[1] = ASMREF_TMP1; /* MSize size */ |
939 | as->gcsteps++; | 940 | as->gcsteps++; |
940 | asm_setupresult(as, ir, ci); /* GCcdata * */ | 941 | |
942 | if (ra_hasreg(ir->r)) | ||
943 | rset_clear(drop, ir->r); /* Dest reg handled below. */ | ||
944 | ra_evictset(as, drop); | ||
945 | if (ra_used(ir)) | ||
946 | ra_destreg(as, ir, RID_RET); /* GCcdata * */ | ||
941 | 947 | ||
942 | /* Initialize immutable cdata object. */ | 948 | /* Initialize immutable cdata object. */ |
943 | if (ir->o == IR_CNEWI) { | 949 | if (ir->o == IR_CNEWI) { |
@@ -1360,42 +1366,28 @@ static void asm_hiop(ASMState *as, IRIns *ir) | |||
1360 | asm_fpcomp(as, ir-1); | 1366 | asm_fpcomp(as, ir-1); |
1361 | return; | 1367 | return; |
1362 | } else if ((ir-1)->o == IR_MIN || (ir-1)->o == IR_MAX) { | 1368 | } else if ((ir-1)->o == IR_MIN || (ir-1)->o == IR_MAX) { |
1363 | if (uselo || usehi || !(as->flags & JIT_F_OPT_DCE)) { | 1369 | as->curins--; /* Always skip the loword min/max. */ |
1364 | as->curins--; /* Always skip the loword min/max. */ | 1370 | if (uselo || usehi) |
1365 | asm_fpmin_max(as, ir-1, (ir-1)->o == IR_MIN ? CC_HI : CC_LO); | 1371 | asm_fpmin_max(as, ir-1, (ir-1)->o == IR_MIN ? CC_HI : CC_LO); |
1366 | } | ||
1367 | return; | 1372 | return; |
1368 | } | 1373 | } |
1369 | if (!usehi && (as->flags & JIT_F_OPT_DCE)) | 1374 | if (!usehi) return; /* Skip unused hiword op for all remaining ops. */ |
1370 | return; /* Skip unused hiword op for all remaining ops. */ | ||
1371 | switch ((ir-1)->o) { | 1375 | switch ((ir-1)->o) { |
1372 | #if LJ_HASFFI | 1376 | #if LJ_HASFFI |
1373 | case IR_ADD: | 1377 | case IR_ADD: |
1374 | if (uselo) { | 1378 | as->curins--; |
1375 | as->curins--; | 1379 | asm_intop(as, ir, ARMI_ADC); |
1376 | asm_intop(as, ir, ARMI_ADC); | 1380 | asm_intop(as, ir-1, ARMI_ADD|ARMI_S); |
1377 | asm_intop(as, ir-1, ARMI_ADD|ARMI_S); | ||
1378 | } else { | ||
1379 | asm_intop(as, ir, ARMI_ADD); | ||
1380 | } | ||
1381 | break; | 1381 | break; |
1382 | case IR_SUB: | 1382 | case IR_SUB: |
1383 | if (uselo) { | 1383 | as->curins--; |
1384 | as->curins--; | 1384 | asm_intop(as, ir, ARMI_SBC); |
1385 | asm_intop(as, ir, ARMI_SBC); | 1385 | asm_intop(as, ir-1, ARMI_SUB|ARMI_S); |
1386 | asm_intop(as, ir-1, ARMI_SUB|ARMI_S); | ||
1387 | } else { | ||
1388 | asm_intop(as, ir, ARMI_SUB); | ||
1389 | } | ||
1390 | break; | 1386 | break; |
1391 | case IR_NEG: | 1387 | case IR_NEG: |
1392 | if (uselo) { | 1388 | as->curins--; |
1393 | as->curins--; | 1389 | asm_intneg(as, ir, ARMI_RSC); |
1394 | asm_intneg(as, ir, ARMI_RSC); | 1390 | asm_intneg(as, ir-1, ARMI_RSB|ARMI_S); |
1395 | asm_intneg(as, ir-1, ARMI_RSB|ARMI_S); | ||
1396 | } else { | ||
1397 | asm_intneg(as, ir, ARMI_RSB); | ||
1398 | } | ||
1399 | break; | 1391 | break; |
1400 | #endif | 1392 | #endif |
1401 | case IR_SLOAD: case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: | 1393 | case IR_SLOAD: case IR_ALOAD: case IR_HLOAD: case IR_ULOAD: case IR_VLOAD: |
diff --git a/src/lj_asm_x86.h b/src/lj_asm_x86.h index 45afdc88..6767e0c7 100644 --- a/src/lj_asm_x86.h +++ b/src/lj_asm_x86.h | |||
@@ -2160,19 +2160,25 @@ static void asm_hiop(ASMState *as, IRIns *ir) | |||
2160 | if (!usehi) return; /* Skip unused hiword op for all remaining ops. */ | 2160 | if (!usehi) return; /* Skip unused hiword op for all remaining ops. */ |
2161 | switch ((ir-1)->o) { | 2161 | switch ((ir-1)->o) { |
2162 | case IR_ADD: | 2162 | case IR_ADD: |
2163 | asm_intarith(as, ir, uselo ? XOg_ADC : XOg_ADD); | 2163 | as->flagmcp = NULL; |
2164 | as->curins--; | ||
2165 | asm_intarith(as, ir, XOg_ADC); | ||
2166 | asm_intarith(as, ir-1, XOg_ADD); | ||
2164 | break; | 2167 | break; |
2165 | case IR_SUB: | 2168 | case IR_SUB: |
2166 | asm_intarith(as, ir, uselo ? XOg_SBB : XOg_SUB); | 2169 | as->flagmcp = NULL; |
2170 | as->curins--; | ||
2171 | asm_intarith(as, ir, XOg_SBB); | ||
2172 | asm_intarith(as, ir-1, XOg_SUB); | ||
2167 | break; | 2173 | break; |
2168 | case IR_NEG: { | 2174 | case IR_NEG: { |
2169 | Reg dest = ra_dest(as, ir, RSET_GPR); | 2175 | Reg dest = ra_dest(as, ir, RSET_GPR); |
2170 | emit_rr(as, XO_GROUP3, XOg_NEG, dest); | 2176 | emit_rr(as, XO_GROUP3, XOg_NEG, dest); |
2171 | if (uselo) { | 2177 | emit_i8(as, 0); |
2172 | emit_i8(as, 0); | 2178 | emit_rr(as, XO_ARITHi8, XOg_ADC, dest); |
2173 | emit_rr(as, XO_ARITHi8, XOg_ADC, dest); | ||
2174 | } | ||
2175 | ra_left(as, dest, ir->op1); | 2179 | ra_left(as, dest, ir->op1); |
2180 | as->curins--; | ||
2181 | asm_neg_not(as, ir-1, XOg_NEG); | ||
2176 | break; | 2182 | break; |
2177 | } | 2183 | } |
2178 | case IR_CALLN: | 2184 | case IR_CALLN: |