Skip to content

[X86][MC] Support 'ctestX <reg>, <mem>' and 'ctextX <mem>, <reg>' as synonyms. #97985

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

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions llvm/lib/Target/X86/X86InstrAsmAlias.td
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ def : InstAlias<"ctest"#Cond#"{l} $dcf\t{$src2, $src1|$src1, $src2}",
(CTEST32mr i32mem:$src1, GR32:$src2, cflags:$dcf, CC), 0>;
def : InstAlias<"ctest"#Cond#"{q} $dcf\t{$src2, $src1|$src1, $src2}",
(CTEST64mr i64mem:$src1, GR64:$src2, cflags:$dcf, CC), 0>;
def : InstAlias<"ctest"#Cond#"{b} $dcf\t{$src1, $src2|$src2, $src1}",
(CTEST8mr i8mem:$src1, GR8:$src2, cflags:$dcf, CC), 0>;
def : InstAlias<"ctest"#Cond#"{w} $dcf\t{$src1, $src2|$src2, $src1}",
(CTEST16mr i16mem:$src1, GR16:$src2, cflags:$dcf, CC), 0>;
def : InstAlias<"ctest"#Cond#"{l} $dcf\t{$src1, $src2|$src2, $src1}",
(CTEST32mr i32mem:$src1, GR32:$src2, cflags:$dcf, CC), 0>;
def : InstAlias<"ctest"#Cond#"{q} $dcf\t{$src1, $src2|$src2, $src1}",
(CTEST64mr i64mem:$src1, GR64:$src2, cflags:$dcf, CC), 0>;
def : InstAlias<"ctest"#Cond#"{b} $dcf\t{$src2, $src1|$src1, $src2}",
(CTEST8ri GR8:$src1, i8imm:$src2, cflags:$dcf, CC), 0>;
def : InstAlias<"ctest"#Cond#"{w} $dcf\t{$src2, $src1|$src1, $src2}",
Expand Down
15 changes: 14 additions & 1 deletion llvm/test/MC/X86/apx/ctest-att.s
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 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-256: error:
# ERROR-COUNT-260: error:
# ERROR-NOT: error:
# CHECK: ctestbb {dfv=of} $123, 123(%r8,%rax,4)
# CHECK: encoding: [0x62,0xd4,0x44,0x02,0xf6,0x44,0x80,0x7b,0x7b]
Expand All @@ -27,6 +27,19 @@
# CHECK: ctestbq {dfv=of} %r9, 123(%r8,%rax,4)
# CHECK: encoding: [0x62,0x54,0xc4,0x02,0x85,0x4c,0x80,0x7b]
ctestbq {dfv=of} %r9, 123(%r8,%rax,4)
# Swap mr form
# CHECK: ctestbb {dfv=of} %bl, 123(%r8,%rax,4)
# CHECK: encoding: [0x62,0xd4,0x44,0x02,0x84,0x5c,0x80,0x7b]
ctestbb {dfv=of} 123(%r8,%rax,4), %bl
# CHECK: ctestbw {dfv=of} %dx, 123(%r8,%rax,4)
# CHECK: encoding: [0x62,0xd4,0x45,0x02,0x85,0x54,0x80,0x7b]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The swap form is quite magic, could you put it at the end of the test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I was intending to put them near the reverse forms above. From L18-29

ctestbw {dfv=of} 123(%r8,%rax,4), %dx
# CHECK: ctestbl {dfv=of} %ecx, 123(%r8,%rax,4)
# CHECK: encoding: [0x62,0xd4,0x44,0x02,0x85,0x4c,0x80,0x7b]
ctestbl {dfv=of} 123(%r8,%rax,4), %ecx
# CHECK: ctestbq {dfv=of} %r9, 123(%r8,%rax,4)
# CHECK: encoding: [0x62,0x54,0xc4,0x02,0x85,0x4c,0x80,0x7b]
ctestbq {dfv=of} 123(%r8,%rax,4), %r9
# CHECK: ctestbb {dfv=of} $123, %bl
# CHECK: encoding: [0x62,0xf4,0x44,0x02,0xf6,0xc3,0x7b]
ctestbb {dfv=of} $123, %bl
Expand Down
12 changes: 12 additions & 0 deletions llvm/test/MC/X86/apx/ctest-intel.s
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@
# CHECK: ctestb {dfv=of} qword ptr [r8 + 4*rax + 123], r9
# CHECK: encoding: [0x62,0x54,0xc4,0x02,0x85,0x4c,0x80,0x7b]
ctestb {dfv=of} qword ptr [r8 + 4*rax + 123], r9
# CHECK: ctestb {dfv=of} byte ptr [r8 + 4*rax + 123], bl
# CHECK: encoding: [0x62,0xd4,0x44,0x02,0x84,0x5c,0x80,0x7b]
ctestb {dfv=of} bl, byte ptr [r8 + 4*rax + 123]
# CHECK: ctestb {dfv=of} word ptr [r8 + 4*rax + 123], dx
# CHECK: encoding: [0x62,0xd4,0x45,0x02,0x85,0x54,0x80,0x7b]
ctestb {dfv=of} dx, word ptr [r8 + 4*rax + 123]
# CHECK: ctestb {dfv=of} dword ptr [r8 + 4*rax + 123], ecx
# CHECK: encoding: [0x62,0xd4,0x44,0x02,0x85,0x4c,0x80,0x7b]
ctestb {dfv=of} ecx, dword ptr [r8 + 4*rax + 123]
# CHECK: ctestb {dfv=of} qword ptr [r8 + 4*rax + 123], r9
# CHECK: encoding: [0x62,0x54,0xc4,0x02,0x85,0x4c,0x80,0x7b]
ctestb {dfv=of} r9, qword ptr [r8 + 4*rax + 123]
# CHECK: ctestb {dfv=of} bl, 123
# CHECK: encoding: [0x62,0xf4,0x44,0x02,0xf6,0xc3,0x7b]
ctestb {dfv=of} bl, 123
Expand Down
Loading