Fix error in LDR instruction emit on ARM64

Load from literal both supports positive and negative offset. This
patch fix error where offset is negative but without mask, e.g.:
emit_loadk64().

Change-Id: I9f8403fc3c4011106696eb9e3c980f149fbda9f6
This commit is contained in:
Zhongwei Yao 2016-12-07 10:36:35 +00:00
parent d2e7ce5714
commit 6e1b915563
3 changed files with 4 additions and 4 deletions

View File

@ -689,7 +689,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

@ -308,7 +308,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 - 1); ptrdiff_t delta = target - (p - 1);
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((uint32_t)delta) | cond;
as->mcp = p; as->mcp = p;
} }
@ -336,7 +336,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 - 1); ptrdiff_t delta = target - (p - 1);
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((uint32_t)delta) | r;
as->mcp = p; as->mcp = p;
} }

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) (((x)&0x7ffff) << 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)