* [PATCH] i386: Correct adcx suffix in disassembler
@ 2024-01-07 20:07 H.J. Lu
2024-01-08 7:32 ` Jan Beulich
0 siblings, 1 reply; 3+ messages in thread
From: H.J. Lu @ 2024-01-07 20:07 UTC (permalink / raw)
To: binutils
Since 0x66 is the opcode prefix for adcx, it is wrong to use the 'S'
prefix:
'S' => print 'w', 'l' or 'q' if suffix_always is true
on adcx. Add
'L' => print 'l' or 'q' if suffix_always is true
replace S with L on adcx and adox.
gas/
PR binutils/31219
* testsuite/gas/i386/suffix.d: Updated.
* testsuite/gas/i386/x86-64-suffix.d: Likewise.
* testsuite/gas/i386/suffix.s: Add tests for adcx and adox.
* testsuite/gas/i386/x86-64-suffix.s: Likewise.
opcodes/
PR binutils/31219
* i386-dis.c: Add the 'L' suffix.
(prefix_table): Replace S with L on adcx and adox.
(putop): Handle the 'L' suffix.
---
gas/testsuite/gas/i386/suffix.d | 2 ++
gas/testsuite/gas/i386/suffix.s | 4 ++++
gas/testsuite/gas/i386/x86-64-suffix.d | 4 ++++
gas/testsuite/gas/i386/x86-64-suffix.s | 6 ++++++
opcodes/i386-dis.c | 17 +++++++++++++----
5 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/gas/testsuite/gas/i386/suffix.d b/gas/testsuite/gas/i386/suffix.d
index d76dca3decd..3d0282ada68 100644
--- a/gas/testsuite/gas/i386/suffix.d
+++ b/gas/testsuite/gas/i386/suffix.d
@@ -22,4 +22,6 @@ Disassembly of section .text:
[ ]*[a-f0-9]+: cf iretl
[ ]*[a-f0-9]+: 0f 07 sysretl
[ ]*[a-f0-9]+: 0f 07 sysretl
+[ ]*[a-f0-9]+: 66 0f 38 f6 d1 adcxl %ecx,%edx
+[ ]*[a-f0-9]+: f3 0f 38 f6 d1 adoxl %ecx,%edx
#pass
diff --git a/gas/testsuite/gas/i386/suffix.s b/gas/testsuite/gas/i386/suffix.s
index 7f2864d8ed4..4cd85d5274e 100644
--- a/gas/testsuite/gas/i386/suffix.s
+++ b/gas/testsuite/gas/i386/suffix.s
@@ -22,3 +22,7 @@ foo:
iret
sysretd
sysret
+
+ .att_syntax prefix
+ adcxl %ecx, %edx
+ adoxl %ecx, %edx
diff --git a/gas/testsuite/gas/i386/x86-64-suffix.d b/gas/testsuite/gas/i386/x86-64-suffix.d
index e8edfa47bec..928f4bc35ad 100644
--- a/gas/testsuite/gas/i386/x86-64-suffix.d
+++ b/gas/testsuite/gas/i386/x86-64-suffix.d
@@ -26,4 +26,8 @@ Disassembly of section .text:
[ ]*[a-f0-9]+: 0f 07 sysretl
[ ]*[a-f0-9]+: 48 89 e5 movq %rsp,%rbp
[ ]*[a-f0-9]+: 48 0f 07 sysretq
+[ ]*[a-f0-9]+: 66 0f 38 f6 d1 adcxl %ecx,%edx
+[ ]*[a-f0-9]+: f3 0f 38 f6 d1 adoxl %ecx,%edx
+[ ]*[a-f0-9]+: 66 48 0f 38 f6 d1 adcxq %rcx,%rdx
+[ ]*[a-f0-9]+: f3 48 0f 38 f6 d1 adoxq %rcx,%rdx
#pass
diff --git a/gas/testsuite/gas/i386/x86-64-suffix.s b/gas/testsuite/gas/i386/x86-64-suffix.s
index a226836215c..1f40cd63f5d 100644
--- a/gas/testsuite/gas/i386/x86-64-suffix.s
+++ b/gas/testsuite/gas/i386/x86-64-suffix.s
@@ -25,3 +25,9 @@ foo:
sysretd
mov rbp,rsp
sysretq
+
+ .att_syntax prefix
+ adcxl %ecx, %edx
+ adoxl %ecx, %edx
+ adcxq %rcx, %rdx
+ adoxq %rcx, %rdx
diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c
index 51bf7922694..7edae20c323 100644
--- a/opcodes/i386-dis.c
+++ b/opcodes/i386-dis.c
@@ -1778,7 +1778,7 @@ struct dis386 {
'I' unused.
'J' unused.
'K' => print 'd' or 'q' if rex prefix is present.
- 'L' unused.
+ 'L' => print 'l' or 'q' if suffix_always is true
'M' => print 'r' if intel_mnemonic is false.
'N' => print 'n' if instruction has no wait "prefix"
'O' => print 'd' or 'o' (or 'q' in Intel mode)
@@ -3654,8 +3654,8 @@ static const struct dis386 prefix_table[][4] = {
/* PREFIX_0F38F6 */
{
{ "wrssK", { M, Gdq }, 0 },
- { "adoxS", { VexGdq, Gdq, Edq}, 0 },
- { "adcxS", { VexGdq, Gdq, Edq}, 0 },
+ { "adoxL", { VexGdq, Gdq, Edq }, 0 },
+ { "adcxL", { VexGdq, Gdq, Edq }, 0 },
{ Bad_Opcode },
},
@@ -10602,7 +10602,16 @@ putop (instr_info *ins, const char *in_template, int sizeflag)
*ins->obufp++ = 'd';
break;
case 'L':
- abort ();
+ if (ins->intel_syntax)
+ break;
+ if (sizeflag & SUFFIX_ALWAYS)
+ {
+ if (ins->rex & REX_W)
+ *ins->obufp++ = 'q';
+ else
+ *ins->obufp++ = 'l';
+ }
+ break;
case 'M':
if (ins->intel_mnemonic != cond)
*ins->obufp++ = 'r';
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] i386: Correct adcx suffix in disassembler
2024-01-07 20:07 [PATCH] i386: Correct adcx suffix in disassembler H.J. Lu
@ 2024-01-08 7:32 ` Jan Beulich
2024-01-08 14:57 ` H.J. Lu
0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2024-01-08 7:32 UTC (permalink / raw)
To: H.J. Lu; +Cc: binutils
On 07.01.2024 21:07, H.J. Lu wrote:
> Since 0x66 is the opcode prefix for adcx, it is wrong to use the 'S'
> prefix:
>
> 'S' => print 'w', 'l' or 'q' if suffix_always is true
>
> on adcx. Add
>
> 'L' => print 'l' or 'q' if suffix_always is true
>
> replace S with L on adcx and adox.
Instead of consuming a precious single-character macro with just two
uses, did you consider re-using / adjusting an existing one? I'd
rather use a few of the single-character ones (several of which I
managed to free up) to replace frequently used multi-character ones.
Jan
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] i386: Correct adcx suffix in disassembler
2024-01-08 7:32 ` Jan Beulich
@ 2024-01-08 14:57 ` H.J. Lu
0 siblings, 0 replies; 3+ messages in thread
From: H.J. Lu @ 2024-01-08 14:57 UTC (permalink / raw)
To: Jan Beulich; +Cc: binutils
On Sun, Jan 7, 2024 at 11:32 PM Jan Beulich <jbeulich@suse.com> wrote:
>
> On 07.01.2024 21:07, H.J. Lu wrote:
> > Since 0x66 is the opcode prefix for adcx, it is wrong to use the 'S'
> > prefix:
> >
> > 'S' => print 'w', 'l' or 'q' if suffix_always is true
> >
> > on adcx. Add
> >
> > 'L' => print 'l' or 'q' if suffix_always is true
> >
> > replace S with L on adcx and adox.
>
> Instead of consuming a precious single-character macro with just two
> uses, did you consider re-using / adjusting an existing one? I'd
> rather use a few of the single-character ones (several of which I
> managed to free up) to replace frequently used multi-character ones.
>
> Jan
I did a quick check and couldn't find an easy way without 'L'.
--
H.J.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-01-08 14:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-07 20:07 [PATCH] i386: Correct adcx suffix in disassembler H.J. Lu
2024-01-08 7:32 ` Jan Beulich
2024-01-08 14:57 ` H.J. Lu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).