Skip to content

Commit b6a84e7

Browse files
[AArch64] Add assembly/disassembly for FMOP4A (widening, 4-way) instructions (#113347)
The new instructions are described in https://developer.arm.com/documentation/ddi0602/2024-09/SME-Instructions
1 parent 872981b commit b6a84e7

File tree

4 files changed

+254
-0
lines changed

4 files changed

+254
-0
lines changed

llvm/lib/Target/AArch64/AArch64SMEInstrInfo.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,3 +1041,9 @@ let Predicates = [HasSME2, HasSVEBFSCALE] in {
10411041
defm BFMUL : sme2_bfmul_single<"bfmul">;
10421042
defm BFMUL : sme2_bfmul_multi<"bfmul">;
10431043
} //[HasSME2, HasSVEBFSCALE]
1044+
1045+
let Uses = [FPMR, FPCR] in {
1046+
let Predicates = [HasSME2p2, HasSMEF8F32] in {
1047+
defm FMOP4A : sme2_fmop4a_fp8_fp32_4way<"fmop4a">;
1048+
}
1049+
}

llvm/lib/Target/AArch64/SMEInstrFormats.td

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5382,3 +5382,38 @@ multiclass sme2_fmop4as_fp16_non_widening<bit S, string mnemonic> {
53825382
// Multiple vectors
53835383
def _M2Z2Z_H : sme2_fp16_quarter_tile_outer_product<1, 1, S, mnemonic, ZZ_h_mul_r_Lo, ZZ_h_mul_r_Hi>;
53845384
}
5385+
5386+
class sme2_fp8_fp32_quarter_tile_outer_product<bit M, bit N, string mnemonic, RegisterOperand zn_ty, RegisterOperand zm_ty>
5387+
: I<(outs TileOp32:$ZAda),
5388+
(ins TileOp32:$_ZAda, zn_ty:$Zn, zm_ty:$Zm),
5389+
mnemonic, "\t$ZAda, $Zn, $Zm",
5390+
"", []>, Sched<[]> {
5391+
bits<2> ZAda;
5392+
bits<3> Zn;
5393+
bits<3> Zm;
5394+
5395+
let Inst{31-21} = 0b10000000001;
5396+
let Inst{20} = M;
5397+
let Inst{19-17} = Zm;
5398+
let Inst{16-10} = 0b0000000;
5399+
let Inst{9} = N;
5400+
let Inst{8-6} = Zn;
5401+
let Inst{5-2} = 0b0000;
5402+
let Inst{1-0} = ZAda;
5403+
5404+
let Constraints = "$ZAda = $_ZAda";
5405+
}
5406+
5407+
multiclass sme2_fmop4a_fp8_fp32_4way<string mnemonic> {
5408+
// Single vectors
5409+
def _MZZ_BtoS : sme2_fp8_fp32_quarter_tile_outer_product<0, 0, mnemonic, ZPR8Mul2_Lo, ZPR8Mul2_Hi>;
5410+
5411+
// Multiple and single vectors
5412+
def _M2ZZ_BtoS : sme2_fp8_fp32_quarter_tile_outer_product<0, 1, mnemonic, ZZ_b_mul_r_Lo, ZPR8Mul2_Hi>;
5413+
5414+
// Single and multiple vectors
5415+
def _MZ2Z_BtoS : sme2_fp8_fp32_quarter_tile_outer_product<1, 0, mnemonic, ZPR8Mul2_Lo, ZZ_b_mul_r_Hi>;
5416+
5417+
// Multiple vectors
5418+
def _M2Z2Z_BtoS : sme2_fp8_fp32_quarter_tile_outer_product<1, 1, mnemonic, ZZ_b_mul_r_Lo, ZZ_b_mul_r_Hi>;
5419+
}
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
// RUN: not llvm-mc -triple=aarch64 -mattr=+sme2p2,+sme-f8f32 < %s 2>&1 | FileCheck %s
2+
3+
// Single vectors
4+
5+
fmop4a za0.d, z0.b, z16.b
6+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid matrix operand
7+
8+
fmop4a za4.s, z0.b, z16.b
9+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
10+
11+
fmop4a za0.s, z0.d, z16.b
12+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid restricted vector register, expected even register in z0.b..z14.b
13+
14+
fmop4a za0.s, z15.b, z16.b
15+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid restricted vector register, expected even register in z0.b..z14.b
16+
17+
fmop4a za0.s, z16.b, z16.b
18+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid restricted vector register, expected even register in z0.b..z14.b
19+
20+
fmop4a za0.s, z0.b, z16.s
21+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid restricted vector register, expected even register in z16.b..z30.b
22+
23+
fmop4a za0.s, z12.b, z17.b
24+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid restricted vector register, expected even register in z16.b..z30.b
25+
26+
fmop4a za0.s, z12.b, z14.b
27+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid restricted vector register, expected even register in z16.b..z30.b
28+
29+
fmop4a za0.s, z12.b, z31.b
30+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid restricted vector register, expected even register in z16.b..z30.b
31+
32+
// Single and multiple vectors
33+
34+
fmop4a za0.d, z0.b, {z16.b-z17.b}
35+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid matrix operand
36+
37+
fmop4a za4.s, z0.b, {z16.b-z17.b}
38+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
39+
40+
fmop4a za0.s, z0.d, {z16.b-z17.b}
41+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid restricted vector register, expected even register in z0.b..z14.b
42+
43+
fmop4a za0.s, z1.b, {z16.b-z17.b}
44+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid restricted vector register, expected even register in z0.b..z14.b
45+
46+
fmop4a za0.s, z16.b, {z16.b-z17.b}
47+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid restricted vector register, expected even register in z0.b..z14.b
48+
49+
fmop4a za0.s, z0.b, {z16.s-z17.s}
50+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
51+
52+
fmop4a za0.s, z0.b, {z17.b-z18.b}
53+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid vector list, expected list with 2 consecutive SVE vectors in the range z16-z30, where the first vector is a multiple of 2 and with matching element types
54+
55+
fmop4a za0.s, z0.b, {z16.b-z18.b}
56+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
57+
58+
fmop4a za0.s, z0.b, {z12.b-z13.b}
59+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid vector list, expected list with 2 consecutive SVE vectors in the range z16-z30, where the first vector is a multiple of 2 and with matching element types
60+
61+
// Multiple and single vectors
62+
63+
fmop4a za0.d, {z0.b-z1.b}, z16.b
64+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid matrix operand
65+
66+
fmop4a za4.s, {z0.b-z1.b}, z16.b
67+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
68+
69+
fmop4a za0.s, {z0.s-z1.b}, z16.b
70+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: mismatched register size suffix
71+
72+
fmop4a za0.s, {z1.b-z2.b}, z16.b
73+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid vector list, expected list with 2 consecutive SVE vectors in the range z0-z14, where the first vector is a multiple of 2 and with matching element types
74+
75+
fmop4a za0.s, {z0.b-z2.b}, z16.b
76+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
77+
78+
fmop4a za0.s, {z16.b-z17.b}, z16.b
79+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid vector list, expected list with 2 consecutive SVE vectors in the range z0-z14, where the first vector is a multiple of 2 and with matching element types
80+
81+
fmop4a za0.s, {z0.b-z1.b}, z16.d
82+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid restricted vector register, expected even register in z16.b..z30.b
83+
84+
fmop4a za0.s, {z0.b-z1.b}, z17.b
85+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid restricted vector register, expected even register in z16.b..z30.b
86+
87+
fmop4a za0.s, {z0.b-z1.b}, z12.b
88+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid restricted vector register, expected even register in z16.b..z30.b
89+
90+
// Multiple vectors
91+
92+
fmop4a za0.d, {z0.b-z1.b}, {z16.b-z17.b}
93+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid matrix operand
94+
95+
fmop4a za4.s, {z0.b-z1.b}, {z16.b-z17.b}
96+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
97+
98+
fmop4a za0.s, {z0.s-z1.s}, {z16.b-z17.b}
99+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
100+
101+
fmop4a za0.s, {z1.b-z2.b}, {z16.b-z17.b}
102+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid vector list, expected list with 2 consecutive SVE vectors in the range z0-z14, where the first vector is a multiple of 2 and with matching element types
103+
104+
fmop4a za0.s, {z0.b-z2.b}, {z16.b-z17.b}
105+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
106+
107+
fmop4a za0.s, {z18.b-z19.b}, {z16.b-z17.b}
108+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid vector list, expected list with 2 consecutive SVE vectors in the range z0-z14, where the first vector is a multiple of 2 and with matching element types
109+
110+
fmop4a za0.s, {z0.b-z1.b}, {z16.s-z17.s}
111+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
112+
113+
fmop4a za0.s, {z0.b-z1.b}, {z19.b-z20.b}
114+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid vector list, expected list with 2 consecutive SVE vectors in the range z16-z30, where the first vector is a multiple of 2 and with matching element types
115+
116+
fmop4a za0.s, {z0.b-z1.b}, {z18.b-z20.b}
117+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
118+
119+
fmop4a za0.s, {z0.b-z1.b}, {z10.b-z11.b}
120+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid vector list, expected list with 2 consecutive SVE vectors in the range z16-z30, where the first vector is a multiple of 2 and with matching element types
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
// RUN: llvm-mc -triple=aarch64 -show-encoding -mattr=+sme2p2,+sme-f8f32 < %s \
2+
// RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
3+
// RUN: not llvm-mc -triple=aarch64 -show-encoding < %s 2>&1 \
4+
// RUN: | FileCheck %s --check-prefix=CHECK-ERROR
5+
// RUN: llvm-mc -triple=aarch64 -filetype=obj -mattr=+sme2p2,+sme-f8f32 < %s \
6+
// RUN: | llvm-objdump -d --mattr=+sme2p2,+sme-f8f32 - | FileCheck %s --check-prefix=CHECK-INST
7+
// RUN: llvm-mc -triple=aarch64 -filetype=obj -mattr=+sme2p2,+sme-f8f32 < %s \
8+
// RUN: | llvm-objdump -d --mattr=-sme2p2 - | FileCheck %s --check-prefix=CHECK-UNKNOWN
9+
// Disassemble encoding and check the re-encoding (-show-encoding) matches.
10+
// RUN: llvm-mc -triple=aarch64 -show-encoding -mattr=+sme2p2,+sme-f8f32 < %s \
11+
// RUN: | sed '/.text/d' | sed 's/.*encoding: //g' \
12+
// RUN: | llvm-mc -triple=aarch64 -mattr=+sme2p2,+sme-f8f32 -disassemble -show-encoding \
13+
// RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
14+
15+
// Single vectors
16+
17+
fmop4a za0.s, z0.b, z16.b // 10000000-00100000-00000000-00000000
18+
// CHECK-INST: fmop4a za0.s, z0.b, z16.b
19+
// CHECK-ENCODING: [0x00,0x00,0x20,0x80]
20+
// CHECK-ERROR: instruction requires: sme2p2 sme-f8f32
21+
// CHECK-UNKNOWN: 80200000 <unknown>
22+
23+
fmop4a za1.s, z10.b, z20.b // 10000000-00100100-00000001-01000001
24+
// CHECK-INST: fmop4a za1.s, z10.b, z20.b
25+
// CHECK-ENCODING: [0x41,0x01,0x24,0x80]
26+
// CHECK-ERROR: instruction requires: sme2p2 sme-f8f32
27+
// CHECK-UNKNOWN: 80240141 <unknown>
28+
29+
fmop4a za3.s, z14.b, z30.b // 10000000-00101110-00000001-11000011
30+
// CHECK-INST: fmop4a za3.s, z14.b, z30.b
31+
// CHECK-ENCODING: [0xc3,0x01,0x2e,0x80]
32+
// CHECK-ERROR: instruction requires: sme2p2 sme-f8f32
33+
// CHECK-UNKNOWN: 802e01c3 <unknown>
34+
35+
// Single and multiple vectors
36+
37+
fmop4a za0.s, z0.b, {z16.b-z17.b} // 10000000-00110000-00000000-00000000
38+
// CHECK-INST: fmop4a za0.s, z0.b, { z16.b, z17.b }
39+
// CHECK-ENCODING: [0x00,0x00,0x30,0x80]
40+
// CHECK-ERROR: instruction requires: sme2p2 sme-f8f32
41+
// CHECK-UNKNOWN: 80300000 <unknown>
42+
43+
fmop4a za1.s, z10.b, {z20.b-z21.b} // 10000000-00110100-00000001-01000001
44+
// CHECK-INST: fmop4a za1.s, z10.b, { z20.b, z21.b }
45+
// CHECK-ENCODING: [0x41,0x01,0x34,0x80]
46+
// CHECK-ERROR: instruction requires: sme2p2 sme-f8f32
47+
// CHECK-UNKNOWN: 80340141 <unknown>
48+
49+
fmop4a za3.s, z14.b, {z30.b-z31.b} // 10000000-00111110-00000001-11000011
50+
// CHECK-INST: fmop4a za3.s, z14.b, { z30.b, z31.b }
51+
// CHECK-ENCODING: [0xc3,0x01,0x3e,0x80]
52+
// CHECK-ERROR: instruction requires: sme2p2 sme-f8f32
53+
// CHECK-UNKNOWN: 803e01c3 <unknown>
54+
55+
// Multiple and single vectors
56+
57+
fmop4a za0.s, {z0.b-z1.b}, z16.b // 10000000-00100000-00000010-00000000
58+
// CHECK-INST: fmop4a za0.s, { z0.b, z1.b }, z16.b
59+
// CHECK-ENCODING: [0x00,0x02,0x20,0x80]
60+
// CHECK-ERROR: instruction requires: sme2p2 sme-f8f32
61+
// CHECK-UNKNOWN: 80200200 <unknown>
62+
63+
fmop4a za1.s, {z10.b-z11.b}, z20.b // 10000000-00100100-00000011-01000001
64+
// CHECK-INST: fmop4a za1.s, { z10.b, z11.b }, z20.b
65+
// CHECK-ENCODING: [0x41,0x03,0x24,0x80]
66+
// CHECK-ERROR: instruction requires: sme2p2 sme-f8f32
67+
// CHECK-UNKNOWN: 80240341 <unknown>
68+
69+
fmop4a za3.s, {z14.b-z15.b}, z30.b // 10000000-00101110-00000011-11000011
70+
// CHECK-INST: fmop4a za3.s, { z14.b, z15.b }, z30.b
71+
// CHECK-ENCODING: [0xc3,0x03,0x2e,0x80]
72+
// CHECK-ERROR: instruction requires: sme2p2 sme-f8f32
73+
// CHECK-UNKNOWN: 802e03c3 <unknown>
74+
75+
// Multiple vectors
76+
77+
fmop4a za0.s, {z0.b-z1.b}, {z16.b-z17.b} // 10000000-00110000-00000010-00000000
78+
// CHECK-INST: fmop4a za0.s, { z0.b, z1.b }, { z16.b, z17.b }
79+
// CHECK-ENCODING: [0x00,0x02,0x30,0x80]
80+
// CHECK-ERROR: instruction requires: sme2p2 sme-f8f32
81+
// CHECK-UNKNOWN: 80300200 <unknown>
82+
83+
fmop4a za1.s, {z10.b-z11.b}, {z20.b-z21.b} // 10000000-00110100-00000011-01000001
84+
// CHECK-INST: fmop4a za1.s, { z10.b, z11.b }, { z20.b, z21.b }
85+
// CHECK-ENCODING: [0x41,0x03,0x34,0x80]
86+
// CHECK-ERROR: instruction requires: sme2p2 sme-f8f32
87+
// CHECK-UNKNOWN: 80340341 <unknown>
88+
89+
fmop4a za3.s, {z14.b-z15.b}, {z30.b-z31.b} // 10000000-00111110-00000011-11000011
90+
// CHECK-INST: fmop4a za3.s, { z14.b, z15.b }, { z30.b, z31.b }
91+
// CHECK-ENCODING: [0xc3,0x03,0x3e,0x80]
92+
// CHECK-ERROR: instruction requires: sme2p2 sme-f8f32
93+
// CHECK-UNKNOWN: 803e03c3 <unknown>

0 commit comments

Comments
 (0)