aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2016-11-21 15:43:17 +0100
committerMike Pall <mike>2016-11-21 15:43:17 +0100
commita56654460d9ca636536c8204a358207a698e625b (patch)
treeec3d63c61cfcc4f6054f0abf87dd706a3c95e110 /src
parent2b77da35bc77e2d34062d9168884095d9145a993 (diff)
downloadluajit-a56654460d9ca636536c8204a358207a698e625b.tar.gz
luajit-a56654460d9ca636536c8204a358207a698e625b.tar.bz2
luajit-a56654460d9ca636536c8204a358207a698e625b.zip
Generalize deferred constant handling in backend to 64 bit.
Diffstat (limited to 'src')
-rw-r--r--src/lj_asm.c34
-rw-r--r--src/lj_emit_arm.h2
-rw-r--r--src/lj_emit_mips.h4
-rw-r--r--src/lj_emit_ppc.h2
4 files changed, 34 insertions, 8 deletions
diff --git a/src/lj_asm.c b/src/lj_asm.c
index 2cb5abea..f0a11ca8 100644
--- a/src/lj_asm.c
+++ b/src/lj_asm.c
@@ -91,7 +91,7 @@ typedef struct ASMState {
91 MCode *realign; /* Realign loop if not NULL. */ 91 MCode *realign; /* Realign loop if not NULL. */
92 92
93#ifdef RID_NUM_KREF 93#ifdef RID_NUM_KREF
94 int32_t krefk[RID_NUM_KREF]; 94 intptr_t krefk[RID_NUM_KREF];
95#endif 95#endif
96 IRRef1 phireg[RID_MAX]; /* PHI register references. */ 96 IRRef1 phireg[RID_MAX]; /* PHI register references. */
97 uint16_t parentmap[LJ_MAX_JSLOTS]; /* Parent instruction to RegSP map. */ 97 uint16_t parentmap[LJ_MAX_JSLOTS]; /* Parent instruction to RegSP map. */
@@ -144,7 +144,7 @@ static LJ_AINLINE void checkmclim(ASMState *as)
144#define ra_krefreg(ref) ((Reg)(RID_MIN_KREF + (Reg)(ref))) 144#define ra_krefreg(ref) ((Reg)(RID_MIN_KREF + (Reg)(ref)))
145#define ra_krefk(as, ref) (as->krefk[(ref)]) 145#define ra_krefk(as, ref) (as->krefk[(ref)])
146 146
147static LJ_AINLINE void ra_setkref(ASMState *as, Reg r, int32_t k) 147static LJ_AINLINE void ra_setkref(ASMState *as, Reg r, intptr_t k)
148{ 148{
149 IRRef ref = (IRRef)(r - RID_MIN_KREF); 149 IRRef ref = (IRRef)(r - RID_MIN_KREF);
150 as->krefk[ref] = k; 150 as->krefk[ref] = k;
@@ -324,7 +324,11 @@ static Reg ra_rematk(ASMState *as, IRRef ref)
324 lua_assert(!rset_test(as->freeset, r)); 324 lua_assert(!rset_test(as->freeset, r));
325 ra_free(as, r); 325 ra_free(as, r);
326 ra_modified(as, r); 326 ra_modified(as, r);
327#if LJ_64
328 emit_loadu64(as, r, ra_krefk(as, ref));
329#else
327 emit_loadi(as, r, ra_krefk(as, ref)); 330 emit_loadi(as, r, ra_krefk(as, ref));
331#endif
328 return r; 332 return r;
329 } 333 }
330 ir = IR(ref); 334 ir = IR(ref);
@@ -526,7 +530,7 @@ static void ra_evictk(ASMState *as)
526 530
527#ifdef RID_NUM_KREF 531#ifdef RID_NUM_KREF
528/* Allocate a register for a constant. */ 532/* Allocate a register for a constant. */
529static Reg ra_allock(ASMState *as, int32_t k, RegSet allow) 533static Reg ra_allock(ASMState *as, intptr_t k, RegSet allow)
530{ 534{
531 /* First try to find a register which already holds the same constant. */ 535 /* First try to find a register which already holds the same constant. */
532 RegSet pick, work = ~as->freeset & RSET_GPR; 536 RegSet pick, work = ~as->freeset & RSET_GPR;
@@ -535,9 +539,31 @@ static Reg ra_allock(ASMState *as, int32_t k, RegSet allow)
535 IRRef ref; 539 IRRef ref;
536 r = rset_pickbot(work); 540 r = rset_pickbot(work);
537 ref = regcost_ref(as->cost[r]); 541 ref = regcost_ref(as->cost[r]);
542#if LJ_64
543 if (ref < ASMREF_L) {
544 if (ra_iskref(ref)) {
545 if (k == ra_krefk(as, ref))
546 return r;
547 } else {
548 IRIns *ir = IR(ref);
549 if ((ir->o == IR_KINT64 && k == (int64_t)ir_kint64(ir)->u64) ||
550#if LJ_GC64
551 (ir->o == IR_KINT && k == ir->i) ||
552 (ir->o == IR_KGC && k == (intptr_t)ir_kgc(ir)) ||
553 ((ir->o == IR_KPTR || ir->o == IR_KKPTR) &&
554 k == (intptr_t)ir_kptr(ir))
555#else
556 (ir->o != IR_KINT64 && k == ir->i)
557#endif
558 )
559 return r;
560 }
561 }
562#else
538 if (ref < ASMREF_L && 563 if (ref < ASMREF_L &&
539 k == (ra_iskref(ref) ? ra_krefk(as, ref) : IR(ref)->i)) 564 k == (ra_iskref(ref) ? ra_krefk(as, ref) : IR(ref)->i))
540 return r; 565 return r;
566#endif
541 rset_clear(work, r); 567 rset_clear(work, r);
542 } 568 }
543 pick = as->freeset & allow; 569 pick = as->freeset & allow;
@@ -557,7 +583,7 @@ static Reg ra_allock(ASMState *as, int32_t k, RegSet allow)
557} 583}
558 584
559/* Allocate a specific register for a constant. */ 585/* Allocate a specific register for a constant. */
560static void ra_allockreg(ASMState *as, int32_t k, Reg r) 586static void ra_allockreg(ASMState *as, intptr_t k, Reg r)
561{ 587{
562 Reg kr = ra_allock(as, k, RID2RSET(r)); 588 Reg kr = ra_allock(as, k, RID2RSET(r));
563 if (kr != r) { 589 if (kr != r) {
diff --git a/src/lj_emit_arm.h b/src/lj_emit_arm.h
index 496b37a3..f7c93d84 100644
--- a/src/lj_emit_arm.h
+++ b/src/lj_emit_arm.h
@@ -207,7 +207,7 @@ static void emit_loadi(ASMState *as, Reg r, int32_t i)
207 207
208#define emit_loada(as, r, addr) emit_loadi(as, (r), i32ptr((addr))) 208#define emit_loada(as, r, addr) emit_loadi(as, (r), i32ptr((addr)))
209 209
210static Reg ra_allock(ASMState *as, int32_t k, RegSet allow); 210static Reg ra_allock(ASMState *as, intptr_t k, RegSet allow);
211 211
212/* Get/set from constant pointer. */ 212/* Get/set from constant pointer. */
213static void emit_lsptr(ASMState *as, ARMIns ai, Reg r, void *p) 213static void emit_lsptr(ASMState *as, ARMIns ai, Reg r, void *p)
diff --git a/src/lj_emit_mips.h b/src/lj_emit_mips.h
index d35f830b..93c35ea4 100644
--- a/src/lj_emit_mips.h
+++ b/src/lj_emit_mips.h
@@ -94,8 +94,8 @@ static void emit_loadi(ASMState *as, Reg r, int32_t i)
94 94
95#define emit_loada(as, r, addr) emit_loadi(as, (r), i32ptr((addr))) 95#define emit_loada(as, r, addr) emit_loadi(as, (r), i32ptr((addr)))
96 96
97static Reg ra_allock(ASMState *as, int32_t k, RegSet allow); 97static Reg ra_allock(ASMState *as, intptr_t k, RegSet allow);
98static void ra_allockreg(ASMState *as, int32_t k, Reg r); 98static void ra_allockreg(ASMState *as, intptr_t k, Reg r);
99 99
100/* Get/set from constant pointer. */ 100/* Get/set from constant pointer. */
101static void emit_lsptr(ASMState *as, MIPSIns mi, Reg r, void *p, RegSet allow) 101static void emit_lsptr(ASMState *as, MIPSIns mi, Reg r, void *p, RegSet allow)
diff --git a/src/lj_emit_ppc.h b/src/lj_emit_ppc.h
index 5163012a..34a6efb7 100644
--- a/src/lj_emit_ppc.h
+++ b/src/lj_emit_ppc.h
@@ -98,7 +98,7 @@ static void emit_loadi(ASMState *as, Reg r, int32_t i)
98 98
99#define emit_loada(as, r, addr) emit_loadi(as, (r), i32ptr((addr))) 99#define emit_loada(as, r, addr) emit_loadi(as, (r), i32ptr((addr)))
100 100
101static Reg ra_allock(ASMState *as, int32_t k, RegSet allow); 101static Reg ra_allock(ASMState *as, intptr_t k, RegSet allow);
102 102
103/* Get/set from constant pointer. */ 103/* Get/set from constant pointer. */
104static void emit_lsptr(ASMState *as, PPCIns pi, Reg r, void *p, RegSet allow) 104static void emit_lsptr(ASMState *as, PPCIns pi, Reg r, void *p, RegSet allow)