Skip to content

[X86][MC] Add assembly alias for CCMP, CTEST, SETZUCC, CMPCCXADD #102284

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
Aug 13, 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
34 changes: 28 additions & 6 deletions llvm/lib/Target/X86/X86InstrAsmAlias.td
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,31 @@ def : InstAlias<"ccmp"#Cond#"{q} $dcf\t{$src2, $src1|$src1, $src2}",
defm : CCMP_Aliases<"o" , 0>;
defm : CCMP_Aliases<"no", 1>;
defm : CCMP_Aliases<"b" , 2>;
defm : CCMP_Aliases<"c" , 2>;
defm : CCMP_Aliases<"nae", 2>;
defm : CCMP_Aliases<"nb", 3>;
defm : CCMP_Aliases<"nc", 3>;
defm : CCMP_Aliases<"ae", 3>;
defm : CCMP_Aliases<"e" , 4>;
defm : CCMP_Aliases<"z" , 4>;
defm : CCMP_Aliases<"ne", 5>;
defm : CCMP_Aliases<"nz", 5>;
defm : CCMP_Aliases<"be", 6>;
defm : CCMP_Aliases<"na", 6>;
defm : CCMP_Aliases<"nbe", 7>;
defm : CCMP_Aliases<"a" , 7>;
defm : CCMP_Aliases<"s" , 8>;
defm : CCMP_Aliases<"ns", 9>;
defm : CCMP_Aliases<"t" , 10>;
defm : CCMP_Aliases<"f", 11>;
defm : CCMP_Aliases<"l" , 12>;
defm : CCMP_Aliases<"nge",12>;
defm : CCMP_Aliases<"nl", 13>;
defm : CCMP_Aliases<"ge", 13>;
defm : CCMP_Aliases<"le", 14>;
defm : CCMP_Aliases<"ng", 14>;
defm : CCMP_Aliases<"g" , 15>;
defm : CCMP_Aliases<"nle",15>;

// CTEST Instructions Alias
multiclass CTEST_Aliases<string Cond, int CC> {
Expand Down Expand Up @@ -186,19 +198,31 @@ def : InstAlias<"ctest"#Cond#"{q} $dcf\t{$src2, $src1|$src1, $src2}",
defm : CTEST_Aliases<"o" , 0>;
defm : CTEST_Aliases<"no", 1>;
defm : CTEST_Aliases<"b" , 2>;
defm : CTEST_Aliases<"c" , 2>;
defm : CTEST_Aliases<"nae", 2>;
defm : CTEST_Aliases<"nb", 3>;
defm : CTEST_Aliases<"nc", 3>;
defm : CTEST_Aliases<"ae", 3>;
defm : CTEST_Aliases<"e" , 4>;
defm : CTEST_Aliases<"z" , 4>;
defm : CTEST_Aliases<"ne", 5>;
defm : CTEST_Aliases<"nz", 5>;
defm : CTEST_Aliases<"be", 6>;
defm : CTEST_Aliases<"na", 6>;
defm : CTEST_Aliases<"nbe", 7>;
defm : CTEST_Aliases<"a" , 7>;
defm : CTEST_Aliases<"s" , 8>;
defm : CTEST_Aliases<"ns", 9>;
defm : CTEST_Aliases<"t" , 10>;
defm : CTEST_Aliases<"f", 11>;
defm : CTEST_Aliases<"l" , 12>;
defm : CTEST_Aliases<"nge",12>;
defm : CTEST_Aliases<"nl", 13>;
defm : CTEST_Aliases<"ge", 13>;
defm : CTEST_Aliases<"le", 14>;
defm : CTEST_Aliases<"ng", 14>;
defm : CTEST_Aliases<"g" , 15>;
defm : CTEST_Aliases<"nle",15>;

//===----------------------------------------------------------------------===//
// Assembler Mnemonic Aliases
Expand All @@ -208,24 +232,18 @@ defm : CMPCCXADD_Aliases<"o" , 0>;
defm : CMPCCXADD_Aliases<"no", 1>;
defm : CMPCCXADD_Aliases<"b" , 2>;
defm : CMPCCXADD_Aliases<"ae", 3>;
defm : CMPCCXADD_Aliases<"nb", 3>;
defm : CMPCCXADD_Aliases<"e" , 4>;
defm : CMPCCXADD_Aliases<"z" , 4>;
defm : CMPCCXADD_Aliases<"ne", 5>;
defm : CMPCCXADD_Aliases<"nz", 5>;
defm : CMPCCXADD_Aliases<"be", 6>;
defm : CMPCCXADD_Aliases<"nbe", 7>;
defm : CMPCCXADD_Aliases<"a", 7>;
defm : CMPCCXADD_Aliases<"s" , 8>;
defm : CMPCCXADD_Aliases<"ns", 9>;
defm : CMPCCXADD_Aliases<"p" , 10>;
defm : CMPCCXADD_Aliases<"np", 11>;
defm : CMPCCXADD_Aliases<"l" , 12>;
defm : CMPCCXADD_Aliases<"ge", 13>;
defm : CMPCCXADD_Aliases<"nl", 13>;
defm : CMPCCXADD_Aliases<"le", 14>;
defm : CMPCCXADD_Aliases<"g", 15>;
defm : CMPCCXADD_Aliases<"nle",15>;


def : MnemonicAlias<"call", "callw", "att">, Requires<[In16BitMode]>;
Expand Down Expand Up @@ -403,6 +421,7 @@ multiclass IntegerCondCodeMnemonicAlias<string Prefix, string Suffix,

// Aliases for set<CC>
defm : IntegerCondCodeMnemonicAlias<"set", "">;
defm : IntegerCondCodeMnemonicAlias<"setzu", "">;
// Aliases for j<CC>
defm : IntegerCondCodeMnemonicAlias<"j", "">;
// Aliases for cmov<CC>{w,l,q}
Expand All @@ -418,6 +437,9 @@ defm : IntegerCondCodeMnemonicAlias<"cfcmov", "l", "att">;
defm : IntegerCondCodeMnemonicAlias<"cfcmov", "q", "att">;
// No size suffix for intel-style asm.
defm : IntegerCondCodeMnemonicAlias<"cfcmov", "", "intel">;

// Aliases for cmp<CC>xadd
defm : IntegerCondCodeMnemonicAlias<"cmp", "xadd", "">;
//===----------------------------------------------------------------------===//
// Assembler Instruction Aliases
//===----------------------------------------------------------------------===//
Expand Down
41 changes: 40 additions & 1 deletion llvm/test/MC/X86/apx/ccmp-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-454: error:
# ERROR-COUNT-466: error:
# ERROR-NOT: error:
## Condition flags

Expand Down Expand Up @@ -1376,3 +1376,42 @@
# CHECK: ccmptq {dfv=} %r9, %r15
# CHECK: encoding: [0x62,0x54,0x84,0x0a,0x39,0xcf]
{evex} cmpq %r9, %r15

## Condition Code Aliases

# CHECK: ccmpbl {dfv=of} %ecx, %edx
# CHECK: encoding: [0x62,0xf4,0x44,0x02,0x39,0xca]
ccmpcl {dfv=of} %ecx, %edx
# CHECK: ccmpbl {dfv=of} %ecx, %edx
# CHECK: encoding: [0x62,0xf4,0x44,0x02,0x39,0xca]
ccmpnael {dfv=of} %ecx, %edx
# CHECK: ccmpael {dfv=of} %ecx, %edx
# CHECK: encoding: [0x62,0xf4,0x44,0x03,0x39,0xca]
ccmpnbl {dfv=of} %ecx, %edx
# CHECK: ccmpael {dfv=of} %ecx, %edx
# CHECK: encoding: [0x62,0xf4,0x44,0x03,0x39,0xca]
ccmpncl {dfv=of} %ecx, %edx
# CHECK: ccmpel {dfv=of} %ecx, %edx
# CHECK: encoding: [0x62,0xf4,0x44,0x04,0x39,0xca]
ccmpzl {dfv=of} %ecx, %edx
# CHECK: ccmpnel {dfv=of} %ecx, %edx
# CHECK: encoding: [0x62,0xf4,0x44,0x05,0x39,0xca]
ccmpnzl {dfv=of} %ecx, %edx
# CHECK: ccmpal {dfv=of} %ecx, %edx
# CHECK: encoding: [0x62,0xf4,0x44,0x07,0x39,0xca]
ccmpnbel {dfv=of} %ecx, %edx
# CHECK: ccmpll {dfv=of} %ecx, %edx
# CHECK: encoding: [0x62,0xf4,0x44,0x0c,0x39,0xca]
ccmpngel {dfv=of} %ecx, %edx
# CHECK: ccmpgel {dfv=of} %ecx, %edx
# CHECK: encoding: [0x62,0xf4,0x44,0x0d,0x39,0xca]
ccmpnll {dfv=of} %ecx, %edx
# CHECK: ccmplel {dfv=of} %ecx, %edx
# CHECK: encoding: [0x62,0xf4,0x44,0x0e,0x39,0xca]
ccmpngl {dfv=of} %ecx, %edx
# CHECK: ccmpgl {dfv=of} %ecx, %edx
# CHECK: encoding: [0x62,0xf4,0x44,0x0f,0x39,0xca]
ccmpnlel {dfv=of} %ecx, %edx
# CHECK: ccmpbel {dfv=of} %ecx, %edx
# CHECK: encoding: [0x62,0xf4,0x44,0x06,0x39,0xca]
ccmpnal {dfv=of} %ecx, %edx
39 changes: 39 additions & 0 deletions llvm/test/MC/X86/apx/ccmp-intel.s
Original file line number Diff line number Diff line change
Expand Up @@ -1373,3 +1373,42 @@
# CHECK: ccmpt {dfv=} r15, r9
# CHECK: encoding: [0x62,0x54,0x84,0x0a,0x39,0xcf]
{evex} cmp r15, r9

## Condition Code Aliases

# CHECK: ccmpb {dfv=of} edx, ecx
# CHECK: encoding: [0x62,0xf4,0x44,0x02,0x39,0xca]
ccmpc {dfv=of} edx, ecx
# CHECK: ccmpb {dfv=of} edx, ecx
# CHECK: encoding: [0x62,0xf4,0x44,0x02,0x39,0xca]
ccmpnae {dfv=of} edx, ecx
# CHECK: ccmpae {dfv=of} edx, ecx
# CHECK: encoding: [0x62,0xf4,0x44,0x03,0x39,0xca]
ccmpnb {dfv=of} edx, ecx
# CHECK: ccmpae {dfv=of} edx, ecx
# CHECK: encoding: [0x62,0xf4,0x44,0x03,0x39,0xca]
ccmpnc {dfv=of} edx, ecx
# CHECK: ccmpe {dfv=of} edx, ecx
# CHECK: encoding: [0x62,0xf4,0x44,0x04,0x39,0xca]
ccmpz {dfv=of} edx, ecx
# CHECK: ccmpne {dfv=of} edx, ecx
# CHECK: encoding: [0x62,0xf4,0x44,0x05,0x39,0xca]
ccmpnz {dfv=of} edx, ecx
# CHECK: ccmpa {dfv=of} edx, ecx
# CHECK: encoding: [0x62,0xf4,0x44,0x07,0x39,0xca]
ccmpnbe {dfv=of} edx, ecx
# CHECK: ccmpl {dfv=of} edx, ecx
# CHECK: encoding: [0x62,0xf4,0x44,0x0c,0x39,0xca]
ccmpnge {dfv=of} edx, ecx
# CHECK: ccmpge {dfv=of} edx, ecx
# CHECK: encoding: [0x62,0xf4,0x44,0x0d,0x39,0xca]
ccmpnl {dfv=of} edx, ecx
# CHECK: ccmple {dfv=of} edx, ecx
# CHECK: encoding: [0x62,0xf4,0x44,0x0e,0x39,0xca]
ccmpng {dfv=of} edx, ecx
# CHECK: ccmpg {dfv=of} edx, ecx
# CHECK: encoding: [0x62,0xf4,0x44,0x0f,0x39,0xca]
ccmpnle {dfv=of} edx, ecx
# CHECK: ccmpbe {dfv=of} edx, ecx
# CHECK: encoding: [0x62,0xf4,0x44,0x06,0x39,0xca]
ccmpna {dfv=of} edx, ecx
41 changes: 40 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-276: error:
# ERROR-COUNT-288: 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 Down Expand Up @@ -835,3 +835,42 @@
# CHECK: ctesttq {dfv=} %r9, %r15
# CHECK: encoding: [0x62,0x54,0x84,0x0a,0x85,0xcf]
{evex} testq %r9, %r15

## Condition Code Aliases

# CHECK: ctestbl {dfv=of} %ecx, %edx
# CHECK: encoding: [0x62,0xf4,0x44,0x02,0x85,0xca]
ctestcl {dfv=of} %ecx, %edx
# CHECK: ctestbl {dfv=of} %ecx, %edx
# CHECK: encoding: [0x62,0xf4,0x44,0x02,0x85,0xca]
ctestnael {dfv=of} %ecx, %edx
# CHECK: ctestael {dfv=of} %ecx, %edx
# CHECK: encoding: [0x62,0xf4,0x44,0x03,0x85,0xca]
ctestnbl {dfv=of} %ecx, %edx
# CHECK: ctestael {dfv=of} %ecx, %edx
# CHECK: encoding: [0x62,0xf4,0x44,0x03,0x85,0xca]
ctestncl {dfv=of} %ecx, %edx
# CHECK: ctestel {dfv=of} %ecx, %edx
# CHECK: encoding: [0x62,0xf4,0x44,0x04,0x85,0xca]
ctestzl {dfv=of} %ecx, %edx
# CHECK: ctestnel {dfv=of} %ecx, %edx
# CHECK: encoding: [0x62,0xf4,0x44,0x05,0x85,0xca]
ctestnzl {dfv=of} %ecx, %edx
# CHECK: ctestal {dfv=of} %ecx, %edx
# CHECK: encoding: [0x62,0xf4,0x44,0x07,0x85,0xca]
ctestnbel {dfv=of} %ecx, %edx
# CHECK: ctestll {dfv=of} %ecx, %edx
# CHECK: encoding: [0x62,0xf4,0x44,0x0c,0x85,0xca]
ctestngel {dfv=of} %ecx, %edx
# CHECK: ctestgel {dfv=of} %ecx, %edx
# CHECK: encoding: [0x62,0xf4,0x44,0x0d,0x85,0xca]
ctestnll {dfv=of} %ecx, %edx
# CHECK: ctestlel {dfv=of} %ecx, %edx
# CHECK: encoding: [0x62,0xf4,0x44,0x0e,0x85,0xca]
ctestngl {dfv=of} %ecx, %edx
# CHECK: ctestgl {dfv=of} %ecx, %edx
# CHECK: encoding: [0x62,0xf4,0x44,0x0f,0x85,0xca]
ctestnlel {dfv=of} %ecx, %edx
# CHECK: ctestbel {dfv=of} %ecx, %edx
# CHECK: encoding: [0x62,0xf4,0x44,0x06,0x85,0xca]
ctestnal {dfv=of} %ecx, %edx
39 changes: 39 additions & 0 deletions llvm/test/MC/X86/apx/ctest-intel.s
Original file line number Diff line number Diff line change
Expand Up @@ -831,3 +831,42 @@
# CHECK: ctestt {dfv=} r15, r9
# CHECK: encoding: [0x62,0x54,0x84,0x0a,0x85,0xcf]
{evex} test r15, r9

## Condition Code Aliases

# CHECK: ctestb {dfv=of} edx, ecx
# CHECK: encoding: [0x62,0xf4,0x44,0x02,0x85,0xca]
ctestc {dfv=of} edx, ecx
# CHECK: ctestb {dfv=of} edx, ecx
# CHECK: encoding: [0x62,0xf4,0x44,0x02,0x85,0xca]
ctestnae {dfv=of} edx, ecx
# CHECK: ctestae {dfv=of} edx, ecx
# CHECK: encoding: [0x62,0xf4,0x44,0x03,0x85,0xca]
ctestnb {dfv=of} edx, ecx
# CHECK: ctestae {dfv=of} edx, ecx
# CHECK: encoding: [0x62,0xf4,0x44,0x03,0x85,0xca]
ctestnc {dfv=of} edx, ecx
# CHECK: cteste {dfv=of} edx, ecx
# CHECK: encoding: [0x62,0xf4,0x44,0x04,0x85,0xca]
ctestz {dfv=of} edx, ecx
# CHECK: ctestne {dfv=of} edx, ecx
# CHECK: encoding: [0x62,0xf4,0x44,0x05,0x85,0xca]
ctestnz {dfv=of} edx, ecx
# CHECK: ctesta {dfv=of} edx, ecx
# CHECK: encoding: [0x62,0xf4,0x44,0x07,0x85,0xca]
ctestnbe {dfv=of} edx, ecx
# CHECK: ctestl {dfv=of} edx, ecx
# CHECK: encoding: [0x62,0xf4,0x44,0x0c,0x85,0xca]
ctestnge {dfv=of} edx, ecx
# CHECK: ctestge {dfv=of} edx, ecx
# CHECK: encoding: [0x62,0xf4,0x44,0x0d,0x85,0xca]
ctestnl {dfv=of} edx, ecx
# CHECK: ctestle {dfv=of} edx, ecx
# CHECK: encoding: [0x62,0xf4,0x44,0x0e,0x85,0xca]
ctestng {dfv=of} edx, ecx
# CHECK: ctestg {dfv=of} edx, ecx
# CHECK: encoding: [0x62,0xf4,0x44,0x0f,0x85,0xca]
ctestnle {dfv=of} edx, ecx
# CHECK: ctestbe {dfv=of} edx, ecx
# CHECK: encoding: [0x62,0xf4,0x44,0x06,0x85,0xca]
ctestna {dfv=of} edx, ecx
46 changes: 45 additions & 1 deletion llvm/test/MC/X86/apx/setzucc-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-32: error:
# ERROR-COUNT-46: error:
# ERROR-NOT: error:
# CHECK: setzuo %al
# CHECK: encoding: [0x62,0xf4,0x7f,0x18,0x40,0xc0]
Expand Down Expand Up @@ -99,3 +99,47 @@
# CHECK: setzug (%rax)
# CHECK: encoding: [0x62,0xf4,0x7f,0x18,0x4f,0x00]
setzug (%rax)

# Alias tests:
# CHECK: setzub %al
# CHECK: encoding: [0x62,0xf4,0x7f,0x18,0x42,0xc0]
setzunae %al
# CHECK: setzub %al
# CHECK: encoding: [0x62,0xf4,0x7f,0x18,0x42,0xc0]
setzuc %al
# CHECK: setzuae %al
# CHECK: encoding: [0x62,0xf4,0x7f,0x18,0x43,0xc0]
setzunb %al
# CHECK: setzuae %al
# CHECK: encoding: [0x62,0xf4,0x7f,0x18,0x43,0xc0]
setzunc %al
# CHECK: setzue %al
# CHECK: encoding: [0x62,0xf4,0x7f,0x18,0x44,0xc0]
setzuz %al
# CHECK: setzune %al
# CHECK: encoding: [0x62,0xf4,0x7f,0x18,0x45,0xc0]
setzunz %al
# CHECK: setzube %al
# CHECK: encoding: [0x62,0xf4,0x7f,0x18,0x46,0xc0]
setzuna %al
# CHECK: setzua %al
# CHECK: encoding: [0x62,0xf4,0x7f,0x18,0x47,0xc0]
setzunbe %al
# CHECK: setzup %al
# CHECK: encoding: [0x62,0xf4,0x7f,0x18,0x4a,0xc0]
setzupe %al
# CHECK: setzunp %al
# CHECK: encoding: [0x62,0xf4,0x7f,0x18,0x4b,0xc0]
setzupo %al
# CHECK: setzul %al
# CHECK: encoding: [0x62,0xf4,0x7f,0x18,0x4c,0xc0]
setzunge %al
# CHECK: setzuge %al
# CHECK: encoding: [0x62,0xf4,0x7f,0x18,0x4d,0xc0]
setzunl %al
# CHECK: setzule %al
# CHECK: encoding: [0x62,0xf4,0x7f,0x18,0x4e,0xc0]
setzung %al
# CHECK: setzug %al
# CHECK: encoding: [0x62,0xf4,0x7f,0x18,0x4f,0xc0]
setzunle %al
Loading
Loading