Bug 518061 - NJ merge: add ExprFilter::insLoad(). r=graydon.

This commit is contained in:
Nicholas Nethercote 2009-09-22 17:21:59 +10:00
parent 2a166fa683
commit 401cfd7471
3 changed files with 19 additions and 3 deletions

View File

@ -827,6 +827,19 @@ namespace nanojit
return out->insBranch(v, c, t);
}
LIns* ExprFilter::insLoad(LOpcode op, LIns* base, int32_t off) {
if (base->isconstp() && !isS8(off)) {
// if the effective address is constant, then transform:
// ld const[bigconst] => ld (const+bigconst)[0]
// note: we don't do this optimization for <8bit field offsets,
// under the assumption that we're more likely to CSE-match the
// constant base address if we dont const-fold small offsets.
uintptr_t p = (uintptr_t)base->constvalp() + off;
return out->insLoad(op, insImmPtr((void*)p), 0);
}
return out->insLoad(op, base, off);
}
LIns* LirWriter::ins_eq0(LIns* oprnd1)
{
return ins2i(LIR_eq, oprnd1, 0);

View File

@ -1273,6 +1273,7 @@ namespace nanojit
LIns* ins3(LOpcode v, LIns* a, LIns* b, LIns* c);
LIns* insGuard(LOpcode, LIns *cond, LIns *);
LIns* insBranch(LOpcode, LIns *cond, LIns *target);
LIns* insLoad(LOpcode op, LInsp base, int32_t off);
};
// @todo, this could be replaced by a generic HashMap or HashSet, if we had one
@ -1441,9 +1442,6 @@ namespace nanojit
LInsp pos() {
return _i;
}
void setpos(LIns *i) {
_i = i;
}
};
class Assembler;

View File

@ -56,6 +56,11 @@ namespace nanojit
continue;
NanoAssertMsg(!isFree(r), "Coding error; register is both free and active! " );
if (ins->isop(LIR_param) && ins->paramKind()==1 && r == Assembler::savedRegs[ins->paramArg()]) {
// dont print callee-saved regs that arent used
continue;
}
s += VMPI_strlen(s);
const char* rname = ins->isQuad() ? fpn(r) : gpn(r);
VMPI_sprintf(s, " %s(%s)", rname, names->formatRef(ins));