diff options
author | Mike Pall <mike> | 2022-12-22 00:52:04 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2022-12-22 00:52:04 +0100 |
commit | a04480e311f93d3ceb2f92549cad3fffa38250ef (patch) | |
tree | a9e2102ac93d2e358d6fd8735cdb8949409f746d /src/lj_emit_arm64.h | |
parent | 8625eee71f16a3a780ec92bc303c17456efc7fb3 (diff) | |
parent | 8a5e398c52c7f8ca3e1a0e574cc2ba38224b759b (diff) | |
download | luajit-a04480e311f93d3ceb2f92549cad3fffa38250ef.tar.gz luajit-a04480e311f93d3ceb2f92549cad3fffa38250ef.tar.bz2 luajit-a04480e311f93d3ceb2f92549cad3fffa38250ef.zip |
Merge branch 'master' into v2.1
Diffstat (limited to 'src/lj_emit_arm64.h')
-rw-r--r-- | src/lj_emit_arm64.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/lj_emit_arm64.h b/src/lj_emit_arm64.h index c4b4c147..0ddba4a3 100644 --- a/src/lj_emit_arm64.h +++ b/src/lj_emit_arm64.h | |||
@@ -27,8 +27,8 @@ static uint64_t get_k64val(ASMState *as, IRRef ref) | |||
27 | /* Encode constant in K12 format for data processing instructions. */ | 27 | /* Encode constant in K12 format for data processing instructions. */ |
28 | static uint32_t emit_isk12(int64_t n) | 28 | static uint32_t emit_isk12(int64_t n) |
29 | { | 29 | { |
30 | uint64_t k = (n < 0) ? -n : n; | 30 | uint64_t k = n < 0 ? ~(uint64_t)n+1u : (uint64_t)n; |
31 | uint32_t m = (n < 0) ? 0x40000000 : 0; | 31 | uint32_t m = n < 0 ? 0x40000000 : 0; |
32 | if (k < 0x1000) { | 32 | if (k < 0x1000) { |
33 | return A64I_K12|m|A64F_U12(k); | 33 | return A64I_K12|m|A64F_U12(k); |
34 | } else if ((k & 0xfff000) == k) { | 34 | } else if ((k & 0xfff000) == k) { |
@@ -177,7 +177,7 @@ static int emit_kdelta(ASMState *as, Reg rd, uint64_t k, int lim) | |||
177 | emit_dm(as, A64I_MOVx, rd, r); | 177 | emit_dm(as, A64I_MOVx, rd, r); |
178 | return 1; | 178 | return 1; |
179 | } else { | 179 | } else { |
180 | uint32_t k12 = emit_isk12(delta < 0 ? -delta : delta); | 180 | uint32_t k12 = emit_isk12(delta < 0 ? (int64_t)(~(uint64_t)delta+1u) : delta); |
181 | if (k12) { | 181 | if (k12) { |
182 | emit_dn(as, (delta < 0 ? A64I_SUBx : A64I_ADDx)^k12, rd, r); | 182 | emit_dn(as, (delta < 0 ? A64I_SUBx : A64I_ADDx)^k12, rd, r); |
183 | return 1; | 183 | return 1; |
@@ -417,7 +417,8 @@ static void emit_addptr(ASMState *as, Reg r, int32_t ofs) | |||
417 | { | 417 | { |
418 | if (ofs) | 418 | if (ofs) |
419 | emit_opk(as, ofs < 0 ? A64I_SUBx : A64I_ADDx, r, r, | 419 | emit_opk(as, ofs < 0 ? A64I_SUBx : A64I_ADDx, r, r, |
420 | ofs < 0 ? -ofs : ofs, rset_exclude(RSET_GPR, r)); | 420 | ofs < 0 ? (int32_t)(~(uint32_t)ofs+1u) : ofs, |
421 | rset_exclude(RSET_GPR, r)); | ||
421 | } | 422 | } |
422 | 423 | ||
423 | #define emit_spsub(as, ofs) emit_addptr(as, RID_SP, -(ofs)) | 424 | #define emit_spsub(as, ofs) emit_addptr(as, RID_SP, -(ofs)) |