Skip to content

Commit d9e875d

Browse files
authored
[X86][MC] Support encoding/decoding for APX variant LZCNT/TZCNT/POPCNT instructions (#79954)
Two variants: promoted legacy, NF (no flags update). The syntax of NF instructions is aligned with GNU binutils. https://sourceware.org/pipermail/binutils/2023-September/129545.html
1 parent f96e85b commit d9e875d

File tree

12 files changed

+434
-82
lines changed

12 files changed

+434
-82
lines changed

llvm/lib/Target/X86/X86InstrMisc.td

Lines changed: 36 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,67 +1159,51 @@ let Predicates = [HasRDSEED], Defs = [EFLAGS], SchedRW = [WriteSystem] in {
11591159
//===----------------------------------------------------------------------===//
11601160
// LZCNT Instruction
11611161
//
1162+
multiclass Lzcnt<bits<8> o, string m, SDPatternOperator node, X86TypeInfo t,
1163+
SchedWrite schedrr, SchedWrite schedrm, string suffix = ""> {
1164+
def rr#suffix : ITy<o, MRMSrcReg, t, (outs t.RegClass:$dst),
1165+
(ins t.RegClass:$src1), m, unaryop_ndd_args,
1166+
[(set t.RegClass:$dst, (node t.RegClass:$src1)),
1167+
(implicit EFLAGS)]>,
1168+
TB, Sched<[schedrr]>;
1169+
def rm#suffix : ITy<o, MRMSrcMem, t, (outs t.RegClass:$dst),
1170+
(ins t.MemOperand:$src1), m, unaryop_ndd_args,
1171+
[(set t.RegClass:$dst, (node (t.LoadNode addr:$src1))),
1172+
(implicit EFLAGS)]>,
1173+
TB, Sched<[schedrm]>;
1174+
}
1175+
11621176
let Predicates = [HasLZCNT], Defs = [EFLAGS] in {
1163-
def LZCNT16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
1164-
"lzcnt{w}\t{$src, $dst|$dst, $src}",
1165-
[(set GR16:$dst, (ctlz GR16:$src)), (implicit EFLAGS)]>,
1166-
TB, XS, OpSize16, Sched<[WriteLZCNT]>;
1167-
def LZCNT16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
1168-
"lzcnt{w}\t{$src, $dst|$dst, $src}",
1169-
[(set GR16:$dst, (ctlz (loadi16 addr:$src))),
1170-
(implicit EFLAGS)]>, TB, XS, OpSize16, Sched<[WriteLZCNTLd]>;
1171-
1172-
def LZCNT32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
1173-
"lzcnt{l}\t{$src, $dst|$dst, $src}",
1174-
[(set GR32:$dst, (ctlz GR32:$src)), (implicit EFLAGS)]>,
1175-
TB, XS, OpSize32, Sched<[WriteLZCNT]>;
1176-
def LZCNT32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
1177-
"lzcnt{l}\t{$src, $dst|$dst, $src}",
1178-
[(set GR32:$dst, (ctlz (loadi32 addr:$src))),
1179-
(implicit EFLAGS)]>, TB, XS, OpSize32, Sched<[WriteLZCNTLd]>;
1180-
1181-
def LZCNT64rr : RI<0xBD, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
1182-
"lzcnt{q}\t{$src, $dst|$dst, $src}",
1183-
[(set GR64:$dst, (ctlz GR64:$src)), (implicit EFLAGS)]>,
1184-
TB, XS, Sched<[WriteLZCNT]>;
1185-
def LZCNT64rm : RI<0xBD, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
1186-
"lzcnt{q}\t{$src, $dst|$dst, $src}",
1187-
[(set GR64:$dst, (ctlz (loadi64 addr:$src))),
1188-
(implicit EFLAGS)]>, TB, XS, Sched<[WriteLZCNTLd]>;
1177+
defm LZCNT16 : Lzcnt<0xBD, "lzcnt", ctlz, Xi16, WriteLZCNT, WriteLZCNTLd>, OpSize16, XS;
1178+
defm LZCNT32 : Lzcnt<0xBD, "lzcnt", ctlz, Xi32, WriteLZCNT, WriteLZCNTLd>, OpSize32, XS;
1179+
defm LZCNT64 : Lzcnt<0xBD, "lzcnt", ctlz, Xi64, WriteLZCNT, WriteLZCNTLd>, XS;
1180+
1181+
defm LZCNT16 : Lzcnt<0xF5, "lzcnt", null_frag, Xi16, WriteLZCNT, WriteLZCNTLd, "_EVEX">, PL, PD;
1182+
defm LZCNT32 : Lzcnt<0xF5, "lzcnt", null_frag, Xi32, WriteLZCNT, WriteLZCNTLd, "_EVEX">, PL;
1183+
defm LZCNT64 : Lzcnt<0xF5, "lzcnt", null_frag, Xi64, WriteLZCNT, WriteLZCNTLd, "_EVEX">, PL;
11891184
}
11901185

1186+
defm LZCNT16 : Lzcnt<0xF5, "lzcnt", null_frag, Xi16, WriteLZCNT, WriteLZCNTLd, "_NF">, NF, PD;
1187+
defm LZCNT32 : Lzcnt<0xF5, "lzcnt", null_frag, Xi32, WriteLZCNT, WriteLZCNTLd, "_NF">, NF;
1188+
defm LZCNT64 : Lzcnt<0xF5, "lzcnt", null_frag, Xi64, WriteLZCNT, WriteLZCNTLd, "_NF">, NF;
1189+
11911190
//===----------------------------------------------------------------------===//
11921191
// BMI Instructions
11931192
//
11941193
let Predicates = [HasBMI], Defs = [EFLAGS] in {
1195-
def TZCNT16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
1196-
"tzcnt{w}\t{$src, $dst|$dst, $src}",
1197-
[(set GR16:$dst, (cttz GR16:$src)), (implicit EFLAGS)]>,
1198-
TB, XS, OpSize16, Sched<[WriteTZCNT]>;
1199-
def TZCNT16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
1200-
"tzcnt{w}\t{$src, $dst|$dst, $src}",
1201-
[(set GR16:$dst, (cttz (loadi16 addr:$src))),
1202-
(implicit EFLAGS)]>, TB, XS, OpSize16, Sched<[WriteTZCNTLd]>;
1203-
1204-
def TZCNT32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
1205-
"tzcnt{l}\t{$src, $dst|$dst, $src}",
1206-
[(set GR32:$dst, (cttz GR32:$src)), (implicit EFLAGS)]>,
1207-
TB, XS, OpSize32, Sched<[WriteTZCNT]>;
1208-
def TZCNT32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
1209-
"tzcnt{l}\t{$src, $dst|$dst, $src}",
1210-
[(set GR32:$dst, (cttz (loadi32 addr:$src))),
1211-
(implicit EFLAGS)]>, TB, XS, OpSize32, Sched<[WriteTZCNTLd]>;
1212-
1213-
def TZCNT64rr : RI<0xBC, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
1214-
"tzcnt{q}\t{$src, $dst|$dst, $src}",
1215-
[(set GR64:$dst, (cttz GR64:$src)), (implicit EFLAGS)]>,
1216-
TB, XS, Sched<[WriteTZCNT]>;
1217-
def TZCNT64rm : RI<0xBC, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
1218-
"tzcnt{q}\t{$src, $dst|$dst, $src}",
1219-
[(set GR64:$dst, (cttz (loadi64 addr:$src))),
1220-
(implicit EFLAGS)]>, TB, XS, Sched<[WriteTZCNTLd]>;
1194+
defm TZCNT16 : Lzcnt<0xBC, "tzcnt", cttz, Xi16, WriteTZCNT, WriteTZCNTLd>, OpSize16, XS;
1195+
defm TZCNT32 : Lzcnt<0xBC, "tzcnt", cttz, Xi32, WriteTZCNT, WriteTZCNTLd>, OpSize32, XS;
1196+
defm TZCNT64 : Lzcnt<0xBC, "tzcnt", cttz, Xi64, WriteTZCNT, WriteTZCNTLd>, XS;
1197+
1198+
defm TZCNT16 : Lzcnt<0xF4, "tzcnt", null_frag, Xi16, WriteTZCNT, WriteTZCNTLd, "_EVEX">, PL, PD;
1199+
defm TZCNT32 : Lzcnt<0xF4, "tzcnt", null_frag, Xi32, WriteTZCNT, WriteTZCNTLd, "_EVEX">, PL;
1200+
defm TZCNT64 : Lzcnt<0xF4, "tzcnt", null_frag, Xi64, WriteTZCNT, WriteTZCNTLd, "_EVEX">, PL;
12211201
}
12221202

1203+
defm TZCNT16 : Lzcnt<0xF4, "tzcnt", null_frag, Xi16, WriteTZCNT, WriteTZCNTLd, "_NF">, NF, PD;
1204+
defm TZCNT32 : Lzcnt<0xF4, "tzcnt", null_frag, Xi32, WriteTZCNT, WriteTZCNTLd, "_NF">, NF;
1205+
defm TZCNT64 : Lzcnt<0xF4, "tzcnt", null_frag, Xi64, WriteTZCNT, WriteTZCNTLd, "_NF">, NF;
1206+
12231207
multiclass Bls<string m, Format RegMRM, Format MemMRM, X86TypeInfo t, string Suffix = ""> {
12241208
let SchedRW = [WriteBLS] in {
12251209
def rr#Suffix : UnaryOpR<0xF3, RegMRM, m, unaryop_ndd_args, t,

llvm/lib/Target/X86/X86InstrSSE.td

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5757,38 +5757,19 @@ defm VTESTPDY : avx_bittest<0x0F, "vtestpd", VR256, f256mem, loadv4f64, v4f64,
57575757
//===----------------------------------------------------------------------===//
57585758

57595759
let Defs = [EFLAGS], Predicates = [HasPOPCNT] in {
5760-
def POPCNT16rr : I<0xB8, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
5761-
"popcnt{w}\t{$src, $dst|$dst, $src}",
5762-
[(set GR16:$dst, (ctpop GR16:$src)), (implicit EFLAGS)]>,
5763-
Sched<[WritePOPCNT]>, OpSize16, TB, XS;
5764-
def POPCNT16rm : I<0xB8, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
5765-
"popcnt{w}\t{$src, $dst|$dst, $src}",
5766-
[(set GR16:$dst, (ctpop (loadi16 addr:$src))),
5767-
(implicit EFLAGS)]>,
5768-
Sched<[WritePOPCNT.Folded]>, OpSize16, TB, XS;
5769-
5770-
def POPCNT32rr : I<0xB8, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
5771-
"popcnt{l}\t{$src, $dst|$dst, $src}",
5772-
[(set GR32:$dst, (ctpop GR32:$src)), (implicit EFLAGS)]>,
5773-
Sched<[WritePOPCNT]>, OpSize32, TB, XS;
5774-
5775-
def POPCNT32rm : I<0xB8, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
5776-
"popcnt{l}\t{$src, $dst|$dst, $src}",
5777-
[(set GR32:$dst, (ctpop (loadi32 addr:$src))),
5778-
(implicit EFLAGS)]>,
5779-
Sched<[WritePOPCNT.Folded]>, OpSize32, TB, XS;
5780-
5781-
def POPCNT64rr : RI<0xB8, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
5782-
"popcnt{q}\t{$src, $dst|$dst, $src}",
5783-
[(set GR64:$dst, (ctpop GR64:$src)), (implicit EFLAGS)]>,
5784-
Sched<[WritePOPCNT]>, TB, XS;
5785-
def POPCNT64rm : RI<0xB8, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
5786-
"popcnt{q}\t{$src, $dst|$dst, $src}",
5787-
[(set GR64:$dst, (ctpop (loadi64 addr:$src))),
5788-
(implicit EFLAGS)]>,
5789-
Sched<[WritePOPCNT.Folded]>, TB, XS;
5760+
defm POPCNT16 : Lzcnt<0xB8, "popcnt", ctpop, Xi16, WritePOPCNT, WritePOPCNT.Folded>, OpSize16, XS;
5761+
defm POPCNT32 : Lzcnt<0xB8, "popcnt", ctpop, Xi32, WritePOPCNT, WritePOPCNT.Folded>, OpSize32, XS;
5762+
defm POPCNT64 : Lzcnt<0xB8, "popcnt", ctpop, Xi64, WritePOPCNT, WritePOPCNT.Folded>, XS;
5763+
5764+
defm POPCNT16 : Lzcnt<0x88, "popcnt", null_frag, Xi16, WritePOPCNT, WritePOPCNT.Folded, "_EVEX">, PL, PD;
5765+
defm POPCNT32 : Lzcnt<0x88, "popcnt", null_frag, Xi32, WritePOPCNT, WritePOPCNT.Folded, "_EVEX">, PL;
5766+
defm POPCNT64 : Lzcnt<0x88, "popcnt", null_frag, Xi64, WritePOPCNT, WritePOPCNT.Folded, "_EVEX">, PL;
57905767
}
57915768

5769+
defm POPCNT16 : Lzcnt<0x88, "popcnt", null_frag, Xi16, WritePOPCNT, WritePOPCNT.Folded, "_NF">, NF, PD;
5770+
defm POPCNT32 : Lzcnt<0x88, "popcnt", null_frag, Xi32, WritePOPCNT, WritePOPCNT.Folded, "_NF">, NF;
5771+
defm POPCNT64 : Lzcnt<0x88, "popcnt", null_frag, Xi64, WritePOPCNT, WritePOPCNT.Folded, "_NF">, NF;
5772+
57925773
// SS41I_unop_rm_int_v16 - SSE 4.1 unary operator whose type is v8i16.
57935774
multiclass SS41I_unop_rm_int_v16<bits<8> opc, string OpcodeStr,
57945775
SDNode OpNode, PatFrag ld_frag,
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# RUN: llvm-mc -triple x86_64 -disassemble %s | FileCheck %s --check-prefix=ATT
2+
# RUN: llvm-mc -triple x86_64 -disassemble -output-asm-variant=1 %s | FileCheck %s --check-prefix=INTEL
3+
4+
# ATT: {evex} lzcntw %dx, %ax
5+
# INTEL: {evex} lzcnt ax, dx
6+
0x62,0xf4,0x7d,0x08,0xf5,0xc2
7+
8+
# ATT: {nf} lzcntw %dx, %ax
9+
# INTEL: {nf} lzcnt ax, dx
10+
0x62,0xf4,0x7d,0x0c,0xf5,0xc2
11+
12+
# ATT: {evex} lzcntl %ecx, %edx
13+
# INTEL: {evex} lzcnt edx, ecx
14+
0x62,0xf4,0x7c,0x08,0xf5,0xd1
15+
16+
# ATT: {nf} lzcntl %ecx, %edx
17+
# INTEL: {nf} lzcnt edx, ecx
18+
0x62,0xf4,0x7c,0x0c,0xf5,0xd1
19+
20+
# ATT: {evex} lzcntq %r9, %r15
21+
# INTEL: {evex} lzcnt r15, r9
22+
0x62,0x54,0xfc,0x08,0xf5,0xf9
23+
24+
# ATT: {nf} lzcntq %r9, %r15
25+
# INTEL: {nf} lzcnt r15, r9
26+
0x62,0x54,0xfc,0x0c,0xf5,0xf9
27+
28+
# ATT: {evex} lzcntw 123(%r8,%rax,4), %dx
29+
# INTEL: {evex} lzcnt dx, word ptr [r8 + 4*rax + 123]
30+
0x62,0xd4,0x7d,0x08,0xf5,0x54,0x80,0x7b
31+
32+
# ATT: {nf} lzcntw 123(%r8,%rax,4), %dx
33+
# INTEL: {nf} lzcnt dx, word ptr [r8 + 4*rax + 123]
34+
0x62,0xd4,0x7d,0x0c,0xf5,0x54,0x80,0x7b
35+
36+
# ATT: {evex} lzcntl 123(%r8,%rax,4), %ecx
37+
# INTEL: {evex} lzcnt ecx, dword ptr [r8 + 4*rax + 123]
38+
0x62,0xd4,0x7c,0x08,0xf5,0x4c,0x80,0x7b
39+
40+
# ATT: {nf} lzcntl 123(%r8,%rax,4), %ecx
41+
# INTEL: {nf} lzcnt ecx, dword ptr [r8 + 4*rax + 123]
42+
0x62,0xd4,0x7c,0x0c,0xf5,0x4c,0x80,0x7b
43+
44+
# ATT: {evex} lzcntq 123(%r8,%rax,4), %r9
45+
# INTEL: {evex} lzcnt r9, qword ptr [r8 + 4*rax + 123]
46+
0x62,0x54,0xfc,0x08,0xf5,0x4c,0x80,0x7b
47+
48+
# ATT: {nf} lzcntq 123(%r8,%rax,4), %r9
49+
# INTEL: {nf} lzcnt r9, qword ptr [r8 + 4*rax + 123]
50+
0x62,0x54,0xfc,0x0c,0xf5,0x4c,0x80,0x7b
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# RUN: llvm-mc -triple x86_64 -disassemble %s | FileCheck %s --check-prefix=ATT
2+
# RUN: llvm-mc -triple x86_64 -disassemble -output-asm-variant=1 %s | FileCheck %s --check-prefix=INTEL
3+
4+
# ATT: {evex} popcntw %dx, %ax
5+
# INTEL: {evex} popcnt ax, dx
6+
0x62,0xf4,0x7d,0x08,0x88,0xc2
7+
8+
# ATT: {nf} popcntw %dx, %ax
9+
# INTEL: {nf} popcnt ax, dx
10+
0x62,0xf4,0x7d,0x0c,0x88,0xc2
11+
12+
# ATT: {evex} popcntl %ecx, %edx
13+
# INTEL: {evex} popcnt edx, ecx
14+
0x62,0xf4,0x7c,0x08,0x88,0xd1
15+
16+
# ATT: {nf} popcntl %ecx, %edx
17+
# INTEL: {nf} popcnt edx, ecx
18+
0x62,0xf4,0x7c,0x0c,0x88,0xd1
19+
20+
# ATT: {evex} popcntq %r9, %r15
21+
# INTEL: {evex} popcnt r15, r9
22+
0x62,0x54,0xfc,0x08,0x88,0xf9
23+
24+
# ATT: {nf} popcntq %r9, %r15
25+
# INTEL: {nf} popcnt r15, r9
26+
0x62,0x54,0xfc,0x0c,0x88,0xf9
27+
28+
# ATT: {evex} popcntw 123(%r8,%rax,4), %dx
29+
# INTEL: {evex} popcnt dx, word ptr [r8 + 4*rax + 123]
30+
0x62,0xd4,0x7d,0x08,0x88,0x54,0x80,0x7b
31+
32+
# ATT: {nf} popcntw 123(%r8,%rax,4), %dx
33+
# INTEL: {nf} popcnt dx, word ptr [r8 + 4*rax + 123]
34+
0x62,0xd4,0x7d,0x0c,0x88,0x54,0x80,0x7b
35+
36+
# ATT: {evex} popcntl 123(%r8,%rax,4), %ecx
37+
# INTEL: {evex} popcnt ecx, dword ptr [r8 + 4*rax + 123]
38+
0x62,0xd4,0x7c,0x08,0x88,0x4c,0x80,0x7b
39+
40+
# ATT: {nf} popcntl 123(%r8,%rax,4), %ecx
41+
# INTEL: {nf} popcnt ecx, dword ptr [r8 + 4*rax + 123]
42+
0x62,0xd4,0x7c,0x0c,0x88,0x4c,0x80,0x7b
43+
44+
# ATT: {evex} popcntq 123(%r8,%rax,4), %r9
45+
# INTEL: {evex} popcnt r9, qword ptr [r8 + 4*rax + 123]
46+
0x62,0x54,0xfc,0x08,0x88,0x4c,0x80,0x7b
47+
48+
# ATT: {nf} popcntq 123(%r8,%rax,4), %r9
49+
# INTEL: {nf} popcnt r9, qword ptr [r8 + 4*rax + 123]
50+
0x62,0x54,0xfc,0x0c,0x88,0x4c,0x80,0x7b
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# RUN: llvm-mc -triple x86_64 -disassemble %s | FileCheck %s --check-prefix=ATT
2+
# RUN: llvm-mc -triple x86_64 -disassemble -output-asm-variant=1 %s | FileCheck %s --check-prefix=INTEL
3+
4+
# ATT: {evex} tzcntw %dx, %ax
5+
# INTEL: {evex} tzcnt ax, dx
6+
0x62,0xf4,0x7d,0x08,0xf4,0xc2
7+
8+
# ATT: {nf} tzcntw %dx, %ax
9+
# INTEL: {nf} tzcnt ax, dx
10+
0x62,0xf4,0x7d,0x0c,0xf4,0xc2
11+
12+
# ATT: {evex} tzcntl %ecx, %edx
13+
# INTEL: {evex} tzcnt edx, ecx
14+
0x62,0xf4,0x7c,0x08,0xf4,0xd1
15+
16+
# ATT: {nf} tzcntl %ecx, %edx
17+
# INTEL: {nf} tzcnt edx, ecx
18+
0x62,0xf4,0x7c,0x0c,0xf4,0xd1
19+
20+
# ATT: {evex} tzcntq %r9, %r15
21+
# INTEL: {evex} tzcnt r15, r9
22+
0x62,0x54,0xfc,0x08,0xf4,0xf9
23+
24+
# ATT: {nf} tzcntq %r9, %r15
25+
# INTEL: {nf} tzcnt r15, r9
26+
0x62,0x54,0xfc,0x0c,0xf4,0xf9
27+
28+
# ATT: {evex} tzcntw 123(%r8,%rax,4), %dx
29+
# INTEL: {evex} tzcnt dx, word ptr [r8 + 4*rax + 123]
30+
0x62,0xd4,0x7d,0x08,0xf4,0x54,0x80,0x7b
31+
32+
# ATT: {nf} tzcntw 123(%r8,%rax,4), %dx
33+
# INTEL: {nf} tzcnt dx, word ptr [r8 + 4*rax + 123]
34+
0x62,0xd4,0x7d,0x0c,0xf4,0x54,0x80,0x7b
35+
36+
# ATT: {evex} tzcntl 123(%r8,%rax,4), %ecx
37+
# INTEL: {evex} tzcnt ecx, dword ptr [r8 + 4*rax + 123]
38+
0x62,0xd4,0x7c,0x08,0xf4,0x4c,0x80,0x7b
39+
40+
# ATT: {nf} tzcntl 123(%r8,%rax,4), %ecx
41+
# INTEL: {nf} tzcnt ecx, dword ptr [r8 + 4*rax + 123]
42+
0x62,0xd4,0x7c,0x0c,0xf4,0x4c,0x80,0x7b
43+
44+
# ATT: {evex} tzcntq 123(%r8,%rax,4), %r9
45+
# INTEL: {evex} tzcnt r9, qword ptr [r8 + 4*rax + 123]
46+
0x62,0x54,0xfc,0x08,0xf4,0x4c,0x80,0x7b
47+
48+
# ATT: {nf} tzcntq 123(%r8,%rax,4), %r9
49+
# INTEL: {nf} tzcnt r9, qword ptr [r8 + 4*rax + 123]
50+
0x62,0x54,0xfc,0x0c,0xf4,0x4c,0x80,0x7b

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# RUN: llvm-mc -triple x86_64 -show-encoding %s | FileCheck %s
2+
3+
# CHECK: {evex} lzcntw %dx, %ax
4+
# CHECK: encoding: [0x62,0xf4,0x7d,0x08,0xf5,0xc2]
5+
{evex} lzcntw %dx, %ax
6+
# CHECK: {nf} lzcntw %dx, %ax
7+
# CHECK: encoding: [0x62,0xf4,0x7d,0x0c,0xf5,0xc2]
8+
{nf} lzcntw %dx, %ax
9+
# CHECK: {evex} lzcntl %ecx, %edx
10+
# CHECK: encoding: [0x62,0xf4,0x7c,0x08,0xf5,0xd1]
11+
{evex} lzcntl %ecx, %edx
12+
# CHECK: {nf} lzcntl %ecx, %edx
13+
# CHECK: encoding: [0x62,0xf4,0x7c,0x0c,0xf5,0xd1]
14+
{nf} lzcntl %ecx, %edx
15+
# CHECK: {evex} lzcntq %r9, %r15
16+
# CHECK: encoding: [0x62,0x54,0xfc,0x08,0xf5,0xf9]
17+
{evex} lzcntq %r9, %r15
18+
# CHECK: {nf} lzcntq %r9, %r15
19+
# CHECK: encoding: [0x62,0x54,0xfc,0x0c,0xf5,0xf9]
20+
{nf} lzcntq %r9, %r15
21+
# CHECK: {evex} lzcntw 123(%r8,%rax,4), %dx
22+
# CHECK: encoding: [0x62,0xd4,0x7d,0x08,0xf5,0x54,0x80,0x7b]
23+
{evex} lzcntw 123(%r8,%rax,4), %dx
24+
# CHECK: {nf} lzcntw 123(%r8,%rax,4), %dx
25+
# CHECK: encoding: [0x62,0xd4,0x7d,0x0c,0xf5,0x54,0x80,0x7b]
26+
{nf} lzcntw 123(%r8,%rax,4), %dx
27+
# CHECK: {evex} lzcntl 123(%r8,%rax,4), %ecx
28+
# CHECK: encoding: [0x62,0xd4,0x7c,0x08,0xf5,0x4c,0x80,0x7b]
29+
{evex} lzcntl 123(%r8,%rax,4), %ecx
30+
# CHECK: {nf} lzcntl 123(%r8,%rax,4), %ecx
31+
# CHECK: encoding: [0x62,0xd4,0x7c,0x0c,0xf5,0x4c,0x80,0x7b]
32+
{nf} lzcntl 123(%r8,%rax,4), %ecx
33+
# CHECK: {evex} lzcntq 123(%r8,%rax,4), %r9
34+
# CHECK: encoding: [0x62,0x54,0xfc,0x08,0xf5,0x4c,0x80,0x7b]
35+
{evex} lzcntq 123(%r8,%rax,4), %r9
36+
# CHECK: {nf} lzcntq 123(%r8,%rax,4), %r9
37+
# CHECK: encoding: [0x62,0x54,0xfc,0x0c,0xf5,0x4c,0x80,0x7b]
38+
{nf} lzcntq 123(%r8,%rax,4), %r9

llvm/test/MC/X86/apx/lzcnt-intel.s

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# RUN: llvm-mc -triple x86_64 -show-encoding -x86-asm-syntax=intel -output-asm-variant=1 %s | FileCheck %s
2+
3+
# CHECK: {evex} lzcnt ax, dx
4+
# CHECK: encoding: [0x62,0xf4,0x7d,0x08,0xf5,0xc2]
5+
{evex} lzcnt ax, dx
6+
# CHECK: {nf} lzcnt ax, dx
7+
# CHECK: encoding: [0x62,0xf4,0x7d,0x0c,0xf5,0xc2]
8+
{nf} lzcnt ax, dx
9+
# CHECK: {evex} lzcnt edx, ecx
10+
# CHECK: encoding: [0x62,0xf4,0x7c,0x08,0xf5,0xd1]
11+
{evex} lzcnt edx, ecx
12+
# CHECK: {nf} lzcnt edx, ecx
13+
# CHECK: encoding: [0x62,0xf4,0x7c,0x0c,0xf5,0xd1]
14+
{nf} lzcnt edx, ecx
15+
# CHECK: {evex} lzcnt r15, r9
16+
# CHECK: encoding: [0x62,0x54,0xfc,0x08,0xf5,0xf9]
17+
{evex} lzcnt r15, r9
18+
# CHECK: {nf} lzcnt r15, r9
19+
# CHECK: encoding: [0x62,0x54,0xfc,0x0c,0xf5,0xf9]
20+
{nf} lzcnt r15, r9
21+
# CHECK: {evex} lzcnt dx, word ptr [r8 + 4*rax + 123]
22+
# CHECK: encoding: [0x62,0xd4,0x7d,0x08,0xf5,0x54,0x80,0x7b]
23+
{evex} lzcnt dx, word ptr [r8 + 4*rax + 123]
24+
# CHECK: {nf} lzcnt dx, word ptr [r8 + 4*rax + 123]
25+
# CHECK: encoding: [0x62,0xd4,0x7d,0x0c,0xf5,0x54,0x80,0x7b]
26+
{nf} lzcnt dx, word ptr [r8 + 4*rax + 123]
27+
# CHECK: {evex} lzcnt ecx, dword ptr [r8 + 4*rax + 123]
28+
# CHECK: encoding: [0x62,0xd4,0x7c,0x08,0xf5,0x4c,0x80,0x7b]
29+
{evex} lzcnt ecx, dword ptr [r8 + 4*rax + 123]
30+
# CHECK: {nf} lzcnt ecx, dword ptr [r8 + 4*rax + 123]
31+
# CHECK: encoding: [0x62,0xd4,0x7c,0x0c,0xf5,0x4c,0x80,0x7b]
32+
{nf} lzcnt ecx, dword ptr [r8 + 4*rax + 123]
33+
# CHECK: {evex} lzcnt r9, qword ptr [r8 + 4*rax + 123]
34+
# CHECK: encoding: [0x62,0x54,0xfc,0x08,0xf5,0x4c,0x80,0x7b]
35+
{evex} lzcnt r9, qword ptr [r8 + 4*rax + 123]
36+
# CHECK: {nf} lzcnt r9, qword ptr [r8 + 4*rax + 123]
37+
# CHECK: encoding: [0x62,0x54,0xfc,0x0c,0xf5,0x4c,0x80,0x7b]
38+
{nf} lzcnt r9, qword ptr [r8 + 4*rax + 123]

0 commit comments

Comments
 (0)