-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[X86][MC] Support Enc/Dec for EGPR for promoted MOVDIR instruction #74713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
335b337
99d5246
638773b
dd2b302
855af26
3c27968
6304ca0
db9c6c0
af9a423
cac38eb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# RUN: llvm-mc --disassemble %s -triple=x86_64 | FileCheck %s --check-prefixes=ATT | ||
# RUN: llvm-mc --disassemble %s -triple=x86_64 -x86-asm-syntax=intel --output-asm-variant=1 | FileCheck %s --check-prefixes=INTEL | ||
|
||
# ATT: movdir64b 291(%r28d,%r29d,4), %r18d | ||
# INTEL: movdir64b r18d, zmmword ptr [r28d + 4*r29d + 291] | ||
0x67,0x62,0x8c,0x79,0x08,0xf8,0x94,0xac,0x23,0x01,0x00,0x00 | ||
|
||
# ATT: movdir64b 291(%r28,%r29,4), %r19 | ||
# INTEL: movdir64b r19, zmmword ptr [r28 + 4*r29 + 291] | ||
0x62,0x8c,0x79,0x08,0xf8,0x9c,0xac,0x23,0x01,0x00,0x00 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# RUN: llvm-mc --disassemble %s -triple=x86_64 | FileCheck %s --check-prefixes=ATT | ||
# RUN: llvm-mc --disassemble %s -triple=x86_64 -x86-asm-syntax=intel --output-asm-variant=1 | FileCheck %s --check-prefixes=INTEL | ||
|
||
# ATT: movdiri %r18d, 291(%r28,%r29,4) | ||
# INTEL: movdiri dword ptr [r28 + 4*r29 + 291], r18d | ||
0x62,0x8c,0x78,0x08,0xf9,0x94,0xac,0x23,0x01,0x00,0x00 | ||
|
||
# ATT: movdiri %r19, 291(%r28,%r29,4) | ||
# INTEL: movdiri qword ptr [r28 + 4*r29 + 291], r19 | ||
0x62,0x8c,0xf8,0x08,0xf9,0x9c,0xac,0x23,0x01,0x00,0x00 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# RUN: llvm-mc -triple x86_64 --show-encoding %s | FileCheck %s | ||
# RUN: not llvm-mc -triple i386 -show-encoding %s 2>&1 | FileCheck %s --check-prefix=ERROR | ||
|
||
# ERROR-COUNT-2: error: | ||
# ERROR-NOT: error: | ||
# CHECK: movdir64b 291(%r28d,%r29d,4), %r18d | ||
# CHECK: encoding: [0x67,0x62,0x8c,0x79,0x08,0xf8,0x94,0xac,0x23,0x01,0x00,0x00] | ||
movdir64b 291(%r28d,%r29d,4), %r18d | ||
|
||
# CHECK: movdir64b 291(%r28,%r29,4), %r19 | ||
# CHECK: encoding: [0x62,0x8c,0x79,0x08,0xf8,0x9c,0xac,0x23,0x01,0x00,0x00] | ||
movdir64b 291(%r28,%r29,4), %r19 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# RUN: llvm-mc -triple x86_64 -x86-asm-syntax=intel -output-asm-variant=1 --show-encoding %s | FileCheck %s | ||
|
||
# CHECK: movdir64b r18d, zmmword ptr [r28d + 4*r29d + 291] | ||
# CHECK: encoding: [0x67,0x62,0x8c,0x79,0x08,0xf8,0x94,0xac,0x23,0x01,0x00,0x00] | ||
movdir64b r18d, zmmword ptr [r28d + 4*r29d + 291] | ||
|
||
# CHECK: movdir64b r19, zmmword ptr [r28 + 4*r29 + 291] | ||
# CHECK: encoding: [0x62,0x8c,0x79,0x08,0xf8,0x9c,0xac,0x23,0x01,0x00,0x00] | ||
movdir64b r19, zmmword ptr [r28 + 4*r29 + 291] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# RUN: llvm-mc -triple x86_64 --show-encoding %s | FileCheck %s | ||
# RUN: not llvm-mc -triple i386 -show-encoding %s 2>&1 | FileCheck %s --check-prefix=ERROR | ||
|
||
# ERROR-COUNT-2: error: | ||
# ERROR-NOT: error: | ||
# CHECK: movdiri %r18d, 291(%r28,%r29,4) | ||
# CHECK: encoding: [0x62,0x8c,0x78,0x08,0xf9,0x94,0xac,0x23,0x01,0x00,0x00] | ||
movdiri %r18d, 291(%r28,%r29,4) | ||
|
||
# CHECK: movdiri %r19, 291(%r28,%r29,4) | ||
# CHECK: encoding: [0x62,0x8c,0xf8,0x08,0xf9,0x9c,0xac,0x23,0x01,0x00,0x00] | ||
movdiri %r19, 291(%r28,%r29,4) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# RUN: llvm-mc -triple x86_64 -x86-asm-syntax=intel -output-asm-variant=1 --show-encoding %s | FileCheck %s | ||
|
||
# CHECK: movdiri dword ptr [r28 + 4*r29 + 291], r18d | ||
# CHECK: encoding: [0x62,0x8c,0x78,0x08,0xf9,0x94,0xac,0x23,0x01,0x00,0x00] | ||
movdiri dword ptr [r28 + 4*r29 + 291], r18d | ||
|
||
# CHECK: movdiri qword ptr [r28 + 4*r29 + 291], r19 | ||
# CHECK: encoding: [0x62,0x8c,0xf8,0x08,0xf9,0x9c,0xac,0x23,0x01,0x00,0x00] | ||
movdiri qword ptr [r28 + 4*r29 + 291], r19 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -213,6 +213,8 @@ static inline bool inheritsFrom(InstructionContext child, | |
(WIG && inheritsFrom(child, IC_EVEX_W_OPSIZE)) || | ||
(VEX_LIG && inheritsFrom(child, IC_EVEX_L_OPSIZE)) || | ||
(VEX_LIG && inheritsFrom(child, IC_EVEX_L2_OPSIZE)); | ||
case IC_EVEX_OPSIZE_ADSIZE: | ||
return false; | ||
case IC_EVEX_K: | ||
return (VEX_LIG && WIG && inheritsFrom(child, IC_EVEX_L_W_K)) || | ||
(VEX_LIG && WIG && inheritsFrom(child, IC_EVEX_L2_W_K)) || | ||
|
@@ -885,7 +887,9 @@ void DisassemblerTables::emitContextTable(raw_ostream &o, unsigned &i) const { | |
for (unsigned index = 0; index < ATTR_max; ++index) { | ||
o.indent(i * 2); | ||
|
||
if ((index & ATTR_EVEX) || (index & ATTR_VEX) || (index & ATTR_VEXL)) { | ||
if ((index & ATTR_EVEX) && (index & ATTR_OPSIZE) && (index & ATTR_ADSIZE)) | ||
o << "IC_EVEX_OPSIZE_ADSIZE"; | ||
Comment on lines
+890
to
+891
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we still need this since we have special handing? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, we need new context for MOVDIR64B64_EVEX, otherwise it would have conflict with MOVDIR64B32_EVEX, their context would all be IC_EVEX_OPSIZE. And special handling is to make disassembler could add attribute ADSIZE to movdir64b so that it could match to IC_EVEX_OPSIZE_ADSIZE context. |
||
else if ((index & ATTR_EVEX) || (index & ATTR_VEX) || (index & ATTR_VEXL)) { | ||
if (index & ATTR_EVEX) | ||
o << "IC_EVEX"; | ||
else | ||
|
@@ -906,7 +910,7 @@ void DisassemblerTables::emitContextTable(raw_ostream &o, unsigned &i) const { | |
else if (index & ATTR_XS) | ||
o << "_XS"; | ||
|
||
if ((index & ATTR_EVEX)) { | ||
if (index & ATTR_EVEX) { | ||
if (index & ATTR_EVEXKZ) | ||
o << "_KZ"; | ||
else if (index & ATTR_EVEXK) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why
ATTR_ADSIZE
only matters to this instruction.I think either all APX instructions need special handling for address size override prefix or nothing to do here.
I also compared with existing instruction that has
ATTR_EVEX
andATTR_OPSIZE
, e.g.,We can decode correctly w/ and w/o address size override prefix without define a IC_EVEX_OPSIZE_ADSIZE, e.g.,
Does it still work with this patch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see the reason why you considering it. We used
AdSize32
to distinguish the source register size ofmovdir64b
, which is a special use of address size override prefix.But I think the introduction of
i512mem_GR32
was just used to solve the problem. Does it not work in this case? I think we should follow this way and see what's missing for the new case.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha! we have specail handling here https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp#L1326
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. I introduce a new IC context named IC_EVEX_OPSIZE_ADSIZE for promoted movdir64b and just want disassembler to recognize the ADSIZE for movdir64b. But though IC_EVEX_OPSIZE_ADSIZE is just for movdir64b but the logic for ADSIZE in EVEX for disassembler could affect other instructions using ADSIZE. I may just need to expand the special handling for promoted movdir64b.
@phoebewang Thank you for pointing, will update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IC_EVEX_OPSIZE_ADSIZE
is still needed as we addedIC_ADSIZE
,IC_64BIT_REXW_ADSIZE
. Dropping the change in X86Disassembler.cpp may solve the problem since we already specially handle it.@XinWang10 Please add test mentioned by Phoebe in a separate commit, like https://reviews.llvm.org/D122449
@phoebewang
i512mem_GR32
is added for decoding issue only? This surprised me...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i512mem_GR32 could also for encoding, I added to make all the reg used by this instruction have same size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KanRobert Test case will do. Thanks for info.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@phoebewang This version could be more correct :)