diff options
author | Mike Pall <mike> | 2021-06-04 13:51:56 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2021-06-04 13:51:56 +0200 |
commit | 4216bdfb2a18b213d226da26361417c537c36743 (patch) | |
tree | 12d07e6337b3533d3bfcb640ff07fbf04a5ce008 | |
parent | 52449e2a1e664f6fd1db965c2471a5d2a55fb7c5 (diff) | |
download | luajit-4216bdfb2a18b213d226da26361417c537c36743.tar.gz luajit-4216bdfb2a18b213d226da26361417c537c36743.tar.bz2 luajit-4216bdfb2a18b213d226da26361417c537c36743.zip |
DynASM/ARM64: Fix LSL/BFI* encoding with variable shifts.
Thanks to Dmitry Stogov.
-rw-r--r-- | dynasm/dasm_arm64.lua | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/dynasm/dasm_arm64.lua b/dynasm/dasm_arm64.lua index 609d6630..cb82dc4a 100644 --- a/dynasm/dasm_arm64.lua +++ b/dynasm/dasm_arm64.lua | |||
@@ -640,10 +640,10 @@ end | |||
640 | local function alias_bfiz(p) | 640 | local function alias_bfiz(p) |
641 | parse_reg(p[1], 0) | 641 | parse_reg(p[1], 0) |
642 | if parse_reg_type == "w" then | 642 | if parse_reg_type == "w" then |
643 | p[3] = "#-("..p[3]:sub(2)..")%32" | 643 | p[3] = "#(32-("..p[3]:sub(2).."))%32" |
644 | p[4] = "#("..p[4]:sub(2)..")-1" | 644 | p[4] = "#("..p[4]:sub(2)..")-1" |
645 | else | 645 | else |
646 | p[3] = "#-("..p[3]:sub(2)..")%64" | 646 | p[3] = "#(64-("..p[3]:sub(2).."))%64" |
647 | p[4] = "#("..p[4]:sub(2)..")-1" | 647 | p[4] = "#("..p[4]:sub(2)..")-1" |
648 | end | 648 | end |
649 | end | 649 | end |
@@ -652,10 +652,10 @@ local alias_lslimm = op_alias("ubfm_4", function(p) | |||
652 | parse_reg(p[1], 0) | 652 | parse_reg(p[1], 0) |
653 | local sh = p[3]:sub(2) | 653 | local sh = p[3]:sub(2) |
654 | if parse_reg_type == "w" then | 654 | if parse_reg_type == "w" then |
655 | p[3] = "#-("..sh..")%32" | 655 | p[3] = "#(32-("..sh.."))%32" |
656 | p[4] = "#31-("..sh..")" | 656 | p[4] = "#31-("..sh..")" |
657 | else | 657 | else |
658 | p[3] = "#-("..sh..")%64" | 658 | p[3] = "#(64-("..sh.."))%64" |
659 | p[4] = "#63-("..sh..")" | 659 | p[4] = "#63-("..sh..")" |
660 | end | 660 | end |
661 | end) | 661 | end) |
@@ -1001,8 +1001,8 @@ function op_template(params, template, nparams) | |||
1001 | if not params then return template:gsub("%x%x%x%x%x%x%x%x", "") end | 1001 | if not params then return template:gsub("%x%x%x%x%x%x%x%x", "") end |
1002 | 1002 | ||
1003 | -- Limit number of section buffer positions used by a single dasm_put(). | 1003 | -- Limit number of section buffer positions used by a single dasm_put(). |
1004 | -- A single opcode needs a maximum of 3 positions. | 1004 | -- A single opcode needs a maximum of 4 positions. |
1005 | if secpos+3 > maxsecpos then wflush() end | 1005 | if secpos+4 > maxsecpos then wflush() end |
1006 | local pos = wpos() | 1006 | local pos = wpos() |
1007 | local lpos, apos, spos = #actlist, #actargs, secpos | 1007 | local lpos, apos, spos = #actlist, #actargs, secpos |
1008 | 1008 | ||
@@ -1014,9 +1014,11 @@ function op_template(params, template, nparams) | |||
1014 | actlist[lpos+1] = nil | 1014 | actlist[lpos+1] = nil |
1015 | actlist[lpos+2] = nil | 1015 | actlist[lpos+2] = nil |
1016 | actlist[lpos+3] = nil | 1016 | actlist[lpos+3] = nil |
1017 | actlist[lpos+4] = nil | ||
1017 | actargs[apos+1] = nil | 1018 | actargs[apos+1] = nil |
1018 | actargs[apos+2] = nil | 1019 | actargs[apos+2] = nil |
1019 | actargs[apos+3] = nil | 1020 | actargs[apos+3] = nil |
1021 | actargs[apos+4] = nil | ||
1020 | end | 1022 | end |
1021 | error(err, 0) | 1023 | error(err, 0) |
1022 | end | 1024 | end |