aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pall <mike>2011-05-31 21:50:14 +0200
committerMike Pall <mike>2011-05-31 21:50:14 +0200
commit2d0b32500ead55d9dc141e0328b9994db380fb18 (patch)
treeb981332700bf50763a8551359c4ec2a810c52a49
parent865ec114a7e9aedb5d728106883717167fd9d7c0 (diff)
downloadluajit-2d0b32500ead55d9dc141e0328b9994db380fb18.tar.gz
luajit-2d0b32500ead55d9dc141e0328b9994db380fb18.tar.bz2
luajit-2d0b32500ead55d9dc141e0328b9994db380fb18.zip
ARM: Tune rematerialization scheduler.
-rw-r--r--src/lj_asm.c50
1 files changed, 27 insertions, 23 deletions
diff --git a/src/lj_asm.c b/src/lj_asm.c
index f88b1a5b..0402bf7a 100644
--- a/src/lj_asm.c
+++ b/src/lj_asm.c
@@ -121,6 +121,24 @@ static LJ_NORET LJ_NOINLINE void asm_mclimit(ASMState *as)
121 lj_mcode_limiterr(as->J, (size_t)(as->mctop - as->mcp + 4*MCLIM_REDZONE)); 121 lj_mcode_limiterr(as->J, (size_t)(as->mctop - as->mcp + 4*MCLIM_REDZONE));
122} 122}
123 123
124#ifdef RID_NUM_KREF
125#define ra_iskref(ref) ((ref) < RID_NUM_KREF)
126#define ra_krefreg(ref) ((Reg)(RID_MIN_KREF + (Reg)(ref)))
127#define ra_krefk(as, ref) (as->krefk[(ref)])
128
129static LJ_AINLINE void ra_setkref(ASMState *as, Reg r, int32_t k)
130{
131 IRRef ref = (IRRef)(r - RID_MIN_KREF);
132 as->krefk[ref] = k;
133 as->cost[r] = REGCOST(ref, ref);
134}
135
136#else
137#define ra_iskref(ref) 0
138#define ra_krefreg(ref) RID_MIN_GPR
139#define ra_krefk(as, ref) 0
140#endif
141
124/* Arch-specific field offsets. */ 142/* Arch-specific field offsets. */
125static const uint8_t field_ofs[IRFL__MAX+1] = { 143static const uint8_t field_ofs[IRFL__MAX+1] = {
126#define FLOFS(name, ofs) (uint8_t)(ofs), 144#define FLOFS(name, ofs) (uint8_t)(ofs),
@@ -258,24 +276,6 @@ static void ra_dprintf(ASMState *as, const char *fmt, ...)
258 276
259#define ra_used(ir) (ra_hasreg((ir)->r) || ra_hasspill((ir)->s)) 277#define ra_used(ir) (ra_hasreg((ir)->r) || ra_hasspill((ir)->s))
260 278
261#ifdef RID_NUM_KREF
262#define ra_iskref(ref) ((ref) < RID_NUM_KREF)
263#define ra_krefreg(ref) ((Reg)(RID_MIN_KREF + (Reg)(ref)))
264#define ra_krefk(as, ref) (as->krefk[(ref)])
265
266static LJ_AINLINE void ra_setkref(ASMState *as, Reg r, int32_t k)
267{
268 IRRef ref = (IRRef)(r - RID_MIN_KREF);
269 as->krefk[ref] = k;
270 as->cost[r] = REGCOST(ref, ref);
271}
272
273#else
274#define ra_iskref(ref) 0
275#define ra_krefreg(ref) RID_MIN_GPR
276#define ra_krefk(as, ref) 0
277#endif
278
279/* Setup register allocator. */ 279/* Setup register allocator. */
280static void ra_setup(ASMState *as) 280static void ra_setup(ASMState *as)
281{ 281{
@@ -475,7 +475,7 @@ static void ra_evictk(ASMState *as)
475static Reg ra_allock(ASMState *as, int32_t k, RegSet allow) 475static Reg ra_allock(ASMState *as, int32_t k, RegSet allow)
476{ 476{
477 /* First try to find a register which already holds the same constant. */ 477 /* First try to find a register which already holds the same constant. */
478 RegSet work = ~as->freeset & RSET_GPR; 478 RegSet pick, work = ~as->freeset & RSET_GPR;
479 Reg r; 479 Reg r;
480 while (work) { 480 while (work) {
481 IRRef ref; 481 IRRef ref;
@@ -486,11 +486,15 @@ static Reg ra_allock(ASMState *as, int32_t k, RegSet allow)
486 return r; 486 return r;
487 rset_clear(work, r); 487 rset_clear(work, r);
488 } 488 }
489 work = as->freeset & allow; 489 pick = as->freeset & allow;
490 if (work) 490 if (pick) {
491 r = rset_picktop(work); 491 /* Constants should preferably get unmodified registers. */
492 else 492 if ((pick & ~as->modset))
493 pick &= ~as->modset;
494 r = rset_pickbot(pick); /* Reduce conflicts with inverse allocation. */
495 } else {
493 r = ra_evict(as, allow); 496 r = ra_evict(as, allow);
497 }
494 RA_DBGX((as, "allock $x $r", k, r)); 498 RA_DBGX((as, "allock $x $r", k, r));
495 ra_setkref(as, r, k); 499 ra_setkref(as, r, k);
496 rset_clear(as->freeset, r); 500 rset_clear(as->freeset, r);