Skip to content

Commit ec062f5

Browse files
authored
[X86][MC] Error out for CMPCCXADD on 32 bit targets. (#88672)
This resolves issue #88501.
1 parent 48324f0 commit ec062f5

File tree

6 files changed

+21
-15
lines changed

6 files changed

+21
-15
lines changed

llvm/lib/Target/X86/X86InstrAsmAlias.td

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,17 @@ def : InstAlias<"invlpgb\t{%rax, %edx|rax, edx}", (INVLPGB64)>, Requires<[In64Bi
5151

5252
// CMPCCXADD Instructions Alias
5353
multiclass CMPCCXADD_Aliases<string Cond, int CC> {
54-
def : InstAlias<"cmp"#Cond#"xadd"#"\t{$src3, $dst, $dstsrc2|$dstsrc2, $dst, $src3}",
55-
(CMPCCXADDmr32 GR32:$dst, i32mem:$dstsrc2, GR32:$src3, CC), 0>;
56-
def : InstAlias<"cmp"#Cond#"xadd"#"\t{$src3, $dst, $dstsrc2|$dstsrc2, $dst, $src3}",
57-
(CMPCCXADDmr64 GR64:$dst, i64mem:$dstsrc2, GR64:$src3, CC), 0>;
58-
59-
def : InstAlias<"cmp"#Cond#"xadd"#"\t{$src3, $dst, $dstsrc2|$dstsrc2, $dst, $src3}",
60-
(CMPCCXADDmr32_EVEX GR32:$dst, i32mem:$dstsrc2, GR32:$src3, CC), 0>;
61-
def : InstAlias<"cmp"#Cond#"xadd"#"\t{$src3, $dst, $dstsrc2|$dstsrc2, $dst, $src3}",
62-
(CMPCCXADDmr64_EVEX GR64:$dst, i64mem:$dstsrc2, GR64:$src3, CC), 0>;
54+
let Predicates = [In64BitMode] in {
55+
def : InstAlias<"cmp"#Cond#"xadd"#"\t{$src3, $dst, $dstsrc2|$dstsrc2, $dst, $src3}",
56+
(CMPCCXADDmr32 GR32:$dst, i32mem:$dstsrc2, GR32:$src3, CC), 0>;
57+
def : InstAlias<"cmp"#Cond#"xadd"#"\t{$src3, $dst, $dstsrc2|$dstsrc2, $dst, $src3}",
58+
(CMPCCXADDmr64 GR64:$dst, i64mem:$dstsrc2, GR64:$src3, CC), 0>;
59+
60+
def : InstAlias<"cmp"#Cond#"xadd"#"\t{$src3, $dst, $dstsrc2|$dstsrc2, $dst, $src3}",
61+
(CMPCCXADDmr32_EVEX GR32:$dst, i32mem:$dstsrc2, GR32:$src3, CC), 0>;
62+
def : InstAlias<"cmp"#Cond#"xadd"#"\t{$src3, $dst, $dstsrc2|$dstsrc2, $dst, $src3}",
63+
(CMPCCXADDmr64_EVEX GR64:$dst, i64mem:$dstsrc2, GR64:$src3, CC), 0>;
64+
}
6365
}
6466

6567
// CCMP Instructions Alias

llvm/test/MC/X86/apx/cmpccxadd-att.s

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
# ERROR-COUNT-60: error:
55
# ERROR-NOT: error:
6-
# CHECK: {evex} cmpnbexadd %ecx, %edx, 123(%rax,%rbx,4)
7-
# CHECK: encoding: [0x62,0xf2,0x75,0x08,0xe7,0x54,0x98,0x7b]
8-
{evex} cmpnbexadd %ecx, %edx, 123(%rax,%rbx,4)
6+
# CHECK: {evex} cmpnbexadd %ecx, %edx, 123(%eax,%ebx,4)
7+
# CHECK: encoding: [0x67,0x62,0xf2,0x75,0x08,0xe7,0x54,0x98,0x7b]
8+
{evex} cmpnbexadd %ecx, %edx, 123(%eax,%ebx,4)
99

1010
# CHECK: {evex} cmpnbexadd %r9, %r15, 123(%rax,%rbx,4)
1111
# CHECK: encoding: [0x62,0x72,0xb5,0x08,0xe7,0x7c,0x98,0x7b]

llvm/test/MC/X86/cmpccxadd-att-64.s renamed to llvm/test/MC/X86/cmpccxadd-att.s

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
// RUN: llvm-mc -triple x86_64 --show-encoding %s | FileCheck %s
2+
// RUN: not llvm-mc -triple i386 -show-encoding %s 2>&1 | FileCheck %s --check-prefix=ERROR
3+
4+
// ERROR-COUNT-193: error:
5+
// ERROR-NOT: error:
26

37
// CHECK: cmpbexadd %eax, %ecx, 268435456(%rbp,%r14,8)
48
// CHECK: encoding: [0xc4,0xa2,0x79,0xe6,0x8c,0xf5,0x00,0x00,0x00,0x10]
@@ -20,9 +24,9 @@
2024
// CHECK: encoding: [0xc4,0xe2,0x79,0xe6,0x89,0xfc,0x01,0x00,0x00]
2125
cmpbexadd %eax, %ecx, 508(%rcx)
2226

23-
// CHECK: cmpbexadd %eax, %ecx, -512(%rdx)
24-
// CHECK: encoding: [0xc4,0xe2,0x79,0xe6,0x8a,0x00,0xfe,0xff,0xff]
25-
cmpbexadd %eax, %ecx, -512(%rdx)
27+
// CHECK: cmpbexadd %eax, %ecx, -512(%edx)
28+
// CHECK: encoding: [0x67,0xc4,0xe2,0x79,0xe6,0x8a,0x00,0xfe,0xff,0xff]
29+
cmpbexadd %eax, %ecx, -512(%edx)
2630

2731
// CHECK: cmpbexadd %r10, %r9, 268435456(%rbp,%r14,8)
2832
// CHECK: encoding: [0xc4,0x22,0xa9,0xe6,0x8c,0xf5,0x00,0x00,0x00,0x10]

0 commit comments

Comments
 (0)