Skip to content

Commit 5c39b8d

Browse files
authored
[X86][MC] Support Enc/Dec for EGPR for promoted AMX-TILE instruction (#76210)
R16-R31 was added into GPRs in #70958, This patch supports the encoding/decoding for promoted AMX-TILE instruction in EVEX space. RFC: https://discourse.llvm.org/t/rfc-design-for-apx-feature-egpr-and-ndd-support/73031/4
1 parent 68f832f commit 5c39b8d

File tree

4 files changed

+106
-29
lines changed

4 files changed

+106
-29
lines changed

llvm/lib/Target/X86/X86InstrAMX.td

+39-29
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,45 @@
1414
//===----------------------------------------------------------------------===//
1515
// AMX instructions
1616

17-
let Predicates = [HasAMXTILE, In64BitMode] in {
18-
let SchedRW = [WriteSystem] in {
19-
let hasSideEffects = 1,
20-
Defs = [TMM0,TMM1,TMM2,TMM3,TMM4,TMM5,TMM6,TMM7] in
21-
def LDTILECFG : I <0x49, MRM0m, (outs), (ins opaquemem:$src),
22-
"ldtilecfg\t$src",
23-
[(int_x86_ldtilecfg addr:$src)]>, VEX, T8;
24-
let hasSideEffects = 1 in
25-
def STTILECFG : I <0x49, MRM0m, (outs), (ins opaquemem:$src),
26-
"sttilecfg\t$src",
27-
[(int_x86_sttilecfg addr:$src)]>, VEX, T8, PD;
28-
let mayLoad = 1 in
29-
def TILELOADD : I<0x4b, MRMSrcMemFSIB, (outs TILE:$dst),
30-
(ins sibmem:$src),
31-
"tileloadd\t{$src, $dst|$dst, $src}", []>,
32-
VEX, T8, XD;
33-
let mayLoad = 1 in
34-
def TILELOADDT1 : I<0x4b, MRMSrcMemFSIB, (outs TILE:$dst),
35-
(ins sibmem:$src),
36-
"tileloaddt1\t{$src, $dst|$dst, $src}", []>,
37-
VEX, T8, PD;
17+
multiclass AMX_TILE_COMMON<string Suffix, Predicate HasEGPR> {
18+
let Predicates = [HasAMXTILE, HasEGPR, In64BitMode] in {
19+
let hasSideEffects = 1,
20+
Defs = [TMM0,TMM1,TMM2,TMM3,TMM4,TMM5,TMM6,TMM7] in
21+
def LDTILECFG#Suffix : I<0x49, MRM0m, (outs), (ins opaquemem:$src),
22+
"ldtilecfg\t$src",
23+
[(int_x86_ldtilecfg addr:$src)]>,
24+
T8, PS;
25+
let hasSideEffects = 1 in
26+
def STTILECFG#Suffix : I<0x49, MRM0m, (outs), (ins opaquemem:$src),
27+
"sttilecfg\t$src",
28+
[(int_x86_sttilecfg addr:$src)]>,
29+
T8, PD;
30+
let mayLoad = 1 in
31+
def TILELOADD#Suffix : I<0x4b, MRMSrcMemFSIB, (outs TILE:$dst),
32+
(ins sibmem:$src),
33+
"tileloadd\t{$src, $dst|$dst, $src}", []>,
34+
T8, XD;
35+
let mayLoad = 1 in
36+
def TILELOADDT1#Suffix : I<0x4b, MRMSrcMemFSIB, (outs TILE:$dst),
37+
(ins sibmem:$src),
38+
"tileloaddt1\t{$src, $dst|$dst, $src}", []>,
39+
T8, PD;
40+
let mayStore = 1 in
41+
def TILESTORED#Suffix : I<0x4b, MRMDestMemFSIB, (outs),
42+
(ins sibmem:$dst, TILE:$src),
43+
"tilestored\t{$src, $dst|$dst, $src}", []>,
44+
T8, XS;
45+
}
46+
}
47+
48+
let SchedRW = [WriteSystem] in {
49+
defm "" : AMX_TILE_COMMON<"", NoEGPR>, VEX;
50+
defm "" : AMX_TILE_COMMON<"_EVEX", HasEGPR>, EVEX, NoCD8;
51+
52+
let Predicates = [HasAMXTILE, In64BitMode] in {
3853
let Defs = [TMM0,TMM1,TMM2,TMM3,TMM4,TMM5,TMM6,TMM7] in
3954
def TILERELEASE : I<0x49, MRM_C0, (outs), (ins),
40-
"tilerelease", [(int_x86_tilerelease)]>, VEX, T8;
41-
let mayStore = 1 in
42-
def TILESTORED : I<0x4b, MRMDestMemFSIB, (outs),
43-
(ins sibmem:$dst, TILE:$src),
44-
"tilestored\t{$src, $dst|$dst, $src}", []>,
45-
VEX, T8, XS;
55+
"tilerelease", [(int_x86_tilerelease)]>, VEX, T8, PS;
4656
def TILEZERO : I<0x49, MRMr0, (outs TILE:$dst), (ins),
4757
"tilezero\t$dst", []>,
4858
VEX, T8, XD;
@@ -82,8 +92,8 @@ let Predicates = [HasAMXTILE, In64BitMode] in {
8292
def PTILEZERO : PseudoI<(outs), (ins u8imm:$src),
8393
[(int_x86_tilezero timm:$src)]>;
8494
}
85-
} // SchedRW
86-
} // HasAMXTILE
95+
} // Predicates
96+
} // SchedRW
8797

8898
let Predicates = [HasAMXINT8, In64BitMode] in {
8999
let SchedRW = [WriteSystem] in {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# RUN: llvm-mc --disassemble %s -triple=x86_64 | FileCheck %s --check-prefixes=ATT
2+
# RUN: llvm-mc --disassemble %s -triple=x86_64 -x86-asm-syntax=intel --output-asm-variant=1 | FileCheck %s --check-prefixes=INTEL
3+
4+
# ATT: ldtilecfg 291(%r28,%r29,4)
5+
# INTEL: ldtilecfg [r28 + 4*r29 + 291]
6+
0x62,0x9a,0x78,0x08,0x49,0x84,0xac,0x23,0x01,0x00,0x00
7+
8+
# ATT: sttilecfg 291(%r28,%r29,4)
9+
# INTEL: sttilecfg [r28 + 4*r29 + 291]
10+
0x62,0x9a,0x79,0x08,0x49,0x84,0xac,0x23,0x01,0x00,0x00
11+
12+
# ATT: tileloadd 291(%r28,%r29,4), %tmm6
13+
# INTEL: tileloadd tmm6, [r28 + 4*r29 + 291]
14+
0x62,0x9a,0x7b,0x08,0x4b,0xb4,0xac,0x23,0x01,0x00,0x00
15+
16+
# ATT: tileloaddt1 291(%r28,%r29,4), %tmm6
17+
# INTEL: tileloaddt1 tmm6, [r28 + 4*r29 + 291]
18+
0x62,0x9a,0x79,0x08,0x4b,0xb4,0xac,0x23,0x01,0x00,0x00
19+
20+
# ATT: tilestored %tmm6, 291(%r28,%r29,4)
21+
# INTEL: tilestored [r28 + 4*r29 + 291], tmm6
22+
0x62,0x9a,0x7a,0x08,0x4b,0xb4,0xac,0x23,0x01,0x00,0x00

llvm/test/MC/X86/apx/amx-tile-att.s

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# 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-5: error:
5+
# ERROR-NOT: error:
6+
# CHECK: ldtilecfg 291(%r28,%r29,4)
7+
# CHECK: encoding: [0x62,0x9a,0x78,0x08,0x49,0x84,0xac,0x23,0x01,0x00,0x00]
8+
ldtilecfg 291(%r28,%r29,4)
9+
10+
# CHECK: sttilecfg 291(%r28,%r29,4)
11+
# CHECK: encoding: [0x62,0x9a,0x79,0x08,0x49,0x84,0xac,0x23,0x01,0x00,0x00]
12+
sttilecfg 291(%r28,%r29,4)
13+
14+
# CHECK: tileloadd 291(%r28,%r29,4), %tmm6
15+
# CHECK: encoding: [0x62,0x9a,0x7b,0x08,0x4b,0xb4,0xac,0x23,0x01,0x00,0x00]
16+
tileloadd 291(%r28,%r29,4), %tmm6
17+
18+
# CHECK: tileloaddt1 291(%r28,%r29,4), %tmm6
19+
# CHECK: encoding: [0x62,0x9a,0x79,0x08,0x4b,0xb4,0xac,0x23,0x01,0x00,0x00]
20+
tileloaddt1 291(%r28,%r29,4), %tmm6
21+
22+
# CHECK: tilestored %tmm6, 291(%r28,%r29,4)
23+
# CHECK: encoding: [0x62,0x9a,0x7a,0x08,0x4b,0xb4,0xac,0x23,0x01,0x00,0x00]
24+
tilestored %tmm6, 291(%r28,%r29,4)

llvm/test/MC/X86/apx/amx-tile-intel.s

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# RUN: llvm-mc -triple x86_64 -x86-asm-syntax=intel -output-asm-variant=1 --show-encoding %s | FileCheck %s
2+
3+
# CHECK: ldtilecfg [r28 + 4*r29 + 291]
4+
# CHECK: encoding: [0x62,0x9a,0x78,0x08,0x49,0x84,0xac,0x23,0x01,0x00,0x00]
5+
ldtilecfg [r28 + 4*r29 + 291]
6+
7+
# CHECK: sttilecfg [r28 + 4*r29 + 291]
8+
# CHECK: encoding: [0x62,0x9a,0x79,0x08,0x49,0x84,0xac,0x23,0x01,0x00,0x00]
9+
sttilecfg [r28 + 4*r29 + 291]
10+
11+
# CHECK: tileloadd tmm6, [r28 + 4*r29 + 291]
12+
# CHECK: encoding: [0x62,0x9a,0x7b,0x08,0x4b,0xb4,0xac,0x23,0x01,0x00,0x00]
13+
tileloadd tmm6, [r28 + 4*r29 + 291]
14+
15+
# CHECK: tileloaddt1 tmm6, [r28 + 4*r29 + 291]
16+
# CHECK: encoding: [0x62,0x9a,0x79,0x08,0x4b,0xb4,0xac,0x23,0x01,0x00,0x00]
17+
tileloaddt1 tmm6, [r28 + 4*r29 + 291]
18+
19+
# CHECK: tilestored [r28 + 4*r29 + 291], tmm6
20+
# CHECK: encoding: [0x62,0x9a,0x7a,0x08,0x4b,0xb4,0xac,0x23,0x01,0x00,0x00]
21+
tilestored [r28 + 4*r29 + 291], tmm6

0 commit comments

Comments
 (0)