ARM64: Make use of tbz/tbnz and cbz/cbnz.

Contributed by Djordje Kovacevic and Stefan Pejic from RT-RK.com.
This commit is contained in:
Mike Pall
2016-11-29 19:30:40 +01:00
parent 6538c8a187
commit 3ad2bbf586
3 changed files with 91 additions and 17 deletions

View File

@@ -321,6 +321,25 @@ static void emit_branch(ASMState *as, A64Ins ai, MCode *target)
as->mcp = p;
}
static void emit_tnb(ASMState *as, A64Ins ai, Reg r, uint32_t bit, MCode *target)
{
MCode *p = as->mcp;
ptrdiff_t delta = target - (p - 1);
lua_assert(bit < 63 && ((delta + 0x2000) >> 14) == 0);
if (bit > 31) ai |= A64I_X;
*--p = ai | A64F_BIT(bit & 31) | A64F_S14((uint32_t)delta & 0x3fffu) | r;
as->mcp = p;
}
static void emit_cnb(ASMState *as, A64Ins ai, Reg r, MCode *target)
{
MCode *p = as->mcp;
ptrdiff_t delta = target - (p - 1);
lua_assert(((delta + 0x40000) >> 19) == 0);
*--p = ai | A64F_S19((uint32_t)delta & 0x7ffff) | r;
as->mcp = p;
}
#define emit_jmp(as, target) emit_branch(as, A64I_B, (target))
static void emit_call(ASMState *as, void *target)