ARM64: Fix code generation for S19 offsets.

Contributed by Zhongwei Yao.
This commit is contained in:
Mike Pall 2016-12-08 05:53:36 +01:00
parent 3975b6c9f4
commit 986854cbb2
3 changed files with 4 additions and 4 deletions

View File

@ -781,7 +781,7 @@ static void asm_href(ASMState *as, IRIns *ir, IROp merge)
emit_lso(as, A64I_LDRx, scr, dest, offsetof(Node, key)); emit_lso(as, A64I_LDRx, scr, dest, offsetof(Node, key));
} }
*l_loop = A64I_BCC | A64F_S19((as->mcp-l_loop) & 0x0007ffffu) | CC_NE; *l_loop = A64I_BCC | A64F_S19(as->mcp - l_loop) | CC_NE;
if (!isk && irt_isaddr(kt)) { if (!isk && irt_isaddr(kt)) {
Reg type = ra_allock(as, (int32_t)irt_toitype(kt), allow); Reg type = ra_allock(as, (int32_t)irt_toitype(kt), allow);
emit_dnm(as, A64I_ADDx | A64F_SH(A64SH_LSL, 47), tmp, key, type); emit_dnm(as, A64I_ADDx | A64F_SH(A64SH_LSL, 47), tmp, key, type);

View File

@ -313,7 +313,7 @@ static void emit_cond_branch(ASMState *as, A64CC cond, MCode *target)
MCode *p = --as->mcp; MCode *p = --as->mcp;
ptrdiff_t delta = target - p; ptrdiff_t delta = target - p;
lua_assert(((delta + 0x40000) >> 19) == 0); lua_assert(((delta + 0x40000) >> 19) == 0);
*p = A64I_BCC | A64F_S19((uint32_t)delta & 0x7ffff) | cond; *p = A64I_BCC | A64F_S19(delta) | cond;
} }
static void emit_branch(ASMState *as, A64Ins ai, MCode *target) static void emit_branch(ASMState *as, A64Ins ai, MCode *target)
@ -338,7 +338,7 @@ static void emit_cnb(ASMState *as, A64Ins ai, Reg r, MCode *target)
MCode *p = --as->mcp; MCode *p = --as->mcp;
ptrdiff_t delta = target - p; ptrdiff_t delta = target - p;
lua_assert(((delta + 0x40000) >> 19) == 0); lua_assert(((delta + 0x40000) >> 19) == 0);
*p = ai | A64F_S19((uint32_t)delta & 0x7ffff) | r; *p = ai | A64F_S19(delta) | r;
} }
#define emit_jmp(as, target) emit_branch(as, A64I_B, (target)) #define emit_jmp(as, target) emit_branch(as, A64I_B, (target))

View File

@ -126,7 +126,7 @@ static LJ_AINLINE uint32_t *exitstub_trace_addr_(uint32_t *p, uint32_t exitno)
#define A64F_U16(x) ((x) << 5) #define A64F_U16(x) ((x) << 5)
#define A64F_U12(x) ((x) << 10) #define A64F_U12(x) ((x) << 10)
#define A64F_S26(x) (x) #define A64F_S26(x) (x)
#define A64F_S19(x) ((x) << 5) #define A64F_S19(x) (((uint32_t)(x) & 0x7ffffu) << 5)
#define A64F_S14(x) ((x) << 5) #define A64F_S14(x) ((x) << 5)
#define A64F_S9(x) ((x) << 12) #define A64F_S9(x) ((x) << 12)
#define A64F_BIT(x) ((x) << 19) #define A64F_BIT(x) ((x) << 19)