Added LIR helpers for x64 code generation (bug 514532, r=edwsmith).

This commit is contained in:
David Anderson 2009-09-09 11:15:48 -07:00
parent 01362958c6
commit 22a1120a3e
2 changed files with 45 additions and 10 deletions

View File

@ -947,11 +947,43 @@ namespace nanojit
return ins2i(LIR_eq, oprnd1, 0);
}
LIns* LirWriter::ins_peq0(LIns* oprnd1)
{
return ins2(LIR_peq, oprnd1, insImmWord(0));
}
LIns* LirWriter::ins_i2p(LIns* intIns)
{
#ifdef NANOJIT_64BIT
return ins1(LIR_i2q, intIns);
#else
return intIns;
#endif
}
LIns* LirWriter::ins_u2p(LIns* uintIns)
{
#ifdef NANOJIT_64BIT
return ins1(LIR_u2q, uintIns);
#else
return uintIns;
#endif
}
LIns* LirWriter::qjoin(LInsp lo, LInsp hi)
{
return ins2(LIR_qjoin, lo, hi);
}
LIns* LirWriter::insImmWord(intptr_t value)
{
#ifdef NANOJIT_64BIT
return insImmq(value);
#else
return insImm(value);
#endif
}
LIns* LirWriter::insImmPtr(const void *ptr)
{
#ifdef NANOJIT_64BIT
@ -1631,19 +1663,16 @@ namespace nanojit
const char* name = names.get(ref)->name;
VMPI_strcat(buf, name);
}
else if (ref->isconstq()) {
#if defined NANOJIT_64BIT
VMPI_sprintf(buf, "#0x%lx", (nj_printf_ld)ref->imm64());
#else
formatImm(ref->imm64_1(), buf);
buf += VMPI_strlen(buf);
*buf++ = ':';
formatImm(ref->imm64_0(), buf);
#endif
}
else if (ref->isconstf()) {
VMPI_sprintf(buf, "%g", ref->imm64f());
}
else if (ref->isconstq()) {
int64_t c = ref->imm64();
if (c >= 10000 || c <= -10000)
VMPI_sprintf(buf, "#0x%llxLL", (long long unsigned int) c);
else
VMPI_sprintf(buf, "%dLL", (int)c);
}
else if (ref->isconst()) {
formatImm(ref->imm32(), buf);
}

View File

@ -966,11 +966,17 @@ namespace nanojit
LIns* ins_choose(LIns* cond, LIns* iftrue, LIns* iffalse);
// Inserts an integer comparison to 0
LIns* ins_eq0(LIns* oprnd1);
// Inserts a pointer comparison to 0
LIns* ins_peq0(LIns* oprnd1);
// Inserts a binary operation where the second operand is an
// integer immediate.
LIns* ins2i(LOpcode op, LIns *oprnd1, int32_t);
LIns* qjoin(LInsp lo, LInsp hi);
LIns* insImmPtr(const void *ptr);
LIns* insImmWord(intptr_t ptr);
// Sign or zero extend integers to native integers. On 32-bit this is a no-op.
LIns* ins_i2p(LIns* intIns);
LIns* ins_u2p(LIns* uintIns);
};