Skip to content

Commit 659ca50

Browse files
committed
[AArch32] Armv8.6a Matrix Mul Assembly Parsing Support
This patch upstreams support for the Armv8.6-a Matrix Multiplication Extension. A summary of the features can be found here: https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/arm-architecture-developments-armv8-6-a This patch includes: - Assembly support for AArch32 and Assembly Parsing D77872 has already added the MC representations of the instructions so that they can be used in code gen; this patch fills in the details needed to make assembly parsing work, and adds tests for asm and disasm This is part of a patch series, starting with BFloat16 support and the other components in the armv8.6a extension (in previous patches linked in phabricator) Based on work by: - Luke Geeson - Oliver Stannard - Luke Cheeseman Reviewers: t.p.northover, simon_tatham Reviewed By: simon_tatham Subscribers: simon_tatham, ostannard, kristof.beyls, hiraditya, danielkiss, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D77874
1 parent e714683 commit 659ca50

File tree

5 files changed

+241
-1
lines changed

5 files changed

+241
-1
lines changed

llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6465,7 +6465,9 @@ void ARMAsmParser::getMnemonicAcceptInfo(StringRef Mnemonic,
64656465
Mnemonic == "vfmat" || Mnemonic == "vfmab" ||
64666466
Mnemonic == "vdot" || Mnemonic == "vmmla" ||
64676467
Mnemonic == "sb" || Mnemonic == "ssbb" ||
6468-
Mnemonic == "pssbb" ||
6468+
Mnemonic == "pssbb" || Mnemonic == "vsmmla" ||
6469+
Mnemonic == "vummla" || Mnemonic == "vusmmla" ||
6470+
Mnemonic == "vusdot" || Mnemonic == "vsudot" ||
64696471
Mnemonic == "bfcsel" || Mnemonic == "wls" ||
64706472
Mnemonic == "dls" || Mnemonic == "le" || Mnemonic == "csel" ||
64716473
Mnemonic == "csinc" || Mnemonic == "csinv" || Mnemonic == "csneg" ||
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
// RUN: not llvm-mc -triple armv8a -show-encoding -mattr=+i8mm < %s 2>&1 | FileCheck %s
2+
// RUN: not llvm-mc -triple thumbv8a -show-encoding -mattr=+i8mm < %s 2>&1 | FileCheck %s
3+
4+
5+
// VSMMLA, VUMMLA, VUSMMLA
6+
7+
// Data type specifier must match instruction
8+
9+
vsmmla.u8 q0, q1, q2
10+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
11+
// CHECK-NEXT: vsmmla.u8 q0, q1, q2
12+
// CHECK-NEXT: {{^ \^}}
13+
14+
vummla.s8 q0, q1, q2
15+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
16+
// CHECK-NEXT: vummla.s8 q0, q1, q2
17+
// CHECK-NEXT: {{^ \^}}
18+
19+
vusmmla.u8 q0, q1, q2
20+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
21+
// CHECK-NEXT: vusmmla.u8 q0, q1, q2
22+
// CHECK-NEXT: {{^ \^}}
23+
24+
25+
// Incorrect register type
26+
27+
vsmmla.s8 d0, q1, q2
28+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: operand must be a register in range [q0, q15]
29+
// CHECK-NEXT: vsmmla.s8 d0, q1, q2
30+
// CHECK-NEXT: {{^ \^}}
31+
32+
vummla.u8 q0, d1, q2
33+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: operand must be a register in range [q0, q15]
34+
// CHECK-NEXT: vummla.u8 q0, d1, q2
35+
// CHECK-NEXT: {{^ \^}}
36+
37+
vusmmla.s8 q0, q1, d2
38+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: operand must be a register in range [q0, q15]
39+
// CHECK-NEXT: vusmmla.s8 q0, q1, d2
40+
// CHECK-NEXT: {{^ \^}}
41+
42+
43+
// VUSDOT (vector)
44+
45+
// Data type specifier must match instruction
46+
47+
vusdot.u8 q0, q1, q2
48+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
49+
// CHECK-NEXT: vusdot.u8 q0, q1, q2
50+
// CHECK-NEXT: {{^ \^}}
51+
52+
// Mis-matched register types
53+
54+
vusdot.s8 q0, d1, d2
55+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: operand must be a register in range [d0, d31]
56+
vusdot.s8 d0, q1, d2
57+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: operand must be a register in range [d0, d31]
58+
vusdot.s8 d0, d1, q2
59+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: operand must be a register in range [d0, d31]
60+
61+
62+
// VUSDOT, VSUDOT (by scalar)
63+
64+
// Data type specifier must match instruction
65+
66+
vusdot.u8 d0, d1, d2[0]
67+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
68+
// CHECK-NEXT: vusdot.u8 d0, d1, d2[0]
69+
// CHECK-NEXT: {{^ \^}}
70+
71+
vsudot.s8 d0, d1, d2[0]
72+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
73+
// CHECK-NEXT: vsudot.s8 d0, d1, d2[0]
74+
// CHECK-NEXT: {{^ \^}}
75+
76+
// Incorrect register types
77+
78+
vusdot.s8 q0, d1, d2[0]
79+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid instruction, any one of the following would fix this:
80+
// CHECK-NEXT: vusdot.s8 q0, d1, d2[0]
81+
// CHECK: [[@LINE-3]]:{{[0-9]+}}: note: operand must be a register in range [d0, d31]
82+
// CHECK-NEXT: vusdot.s8 q0, d1, d2[0]
83+
// CHECK-NEXT: {{^ \^}}
84+
// CHECK: [[@LINE-6]]:{{[0-9]+}}: note: operand must be a register in range [q0, q15]
85+
// CHECK-NEXT: vusdot.s8 q0, d1, d2[0]
86+
// CHECK-NEXT: {{^ \^}}
87+
88+
vusdot.s8 d0, q1, d2[0]
89+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid instruction, any one of the following would fix this:
90+
// CHECK-NEXT: vusdot.s8 d0, q1, d2[0]
91+
// CHECK: [[@LINE-3]]:{{[0-9]+}}: note: operand must be a register in range [d0, d31]
92+
// CHECK-NEXT: vusdot.s8 d0, q1, d2[0]
93+
// CHECK-NEXT: {{^ \^}}
94+
// CHECK: [[@LINE-6]]:{{[0-9]+}}: note: operand must be a register in range [q0, q15]
95+
// CHECK-NEXT: vusdot.s8 d0, q1, d2[0]
96+
// CHECK-NEXT: {{^ \^}}
97+
98+
vusdot.s8 q0, q1, q2[0]
99+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid instruction, any one of the following would fix this:
100+
// CHECK-NEXT: vusdot.s8 q0, q1, q2[0]
101+
// CHECK: [[@LINE-3]]:{{[0-9]+}}: note: operand must be a register in range [d0, d15]
102+
// CHECK-NEXT: vusdot.s8 q0, q1, q2[0]
103+
// CHECK-NEXT: {{^ \^}}
104+
// CHECK: [[@LINE-6]]:{{[0-9]+}}: note: too many operands for instruction
105+
// CHECK-NEXT: vusdot.s8 q0, q1, q2[0]
106+
// CHECK-NEXT: {{^ \^}}
107+
108+
// Out of range lane index
109+
110+
vusdot.s8 d0, d1, d2[2]
111+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
112+
vsudot.u8 q0, q1, d2[2]
113+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction

llvm/test/MC/ARM/armv8.6a-matmul.s

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// RUN: llvm-mc -triple armv8a -show-encoding -mattr=+i8mm < %s | FileCheck %s --check-prefix=ARM
2+
// RUN: llvm-mc -triple thumbv8a -show-encoding -mattr=+i8mm < %s | FileCheck %s --check-prefix=THUMB
3+
// RUN: not llvm-mc -triple armv8a -show-encoding -mattr=v8.5a < %s 2>&1 | FileCheck %s --check-prefix=NOMATMUL
4+
// RUN: not llvm-mc -triple thumbv8a -show-encoding -mattr=v8.5a < %s 2>&1 | FileCheck %s --check-prefix=NOMATMUL
5+
6+
vsmmla.s8 q0, q1, q2
7+
// ARM: vsmmla.s8 q0, q1, q2 @ encoding: [0x44,0x0c,0x22,0xfc]
8+
// THUMB: vsmmla.s8 q0, q1, q2 @ encoding: [0x22,0xfc,0x44,0x0c]
9+
// NOMATMUL: [[@LINE-3]]:{{[0-9]+}}: error: instruction requires: 8-bit integer matrix multiply
10+
11+
vummla.u8 q0, q1, q2
12+
// ARM: vummla.u8 q0, q1, q2 @ encoding: [0x54,0x0c,0x22,0xfc]
13+
// THUMB: vummla.u8 q0, q1, q2 @ encoding: [0x22,0xfc,0x54,0x0c]
14+
// NOMATMUL: [[@LINE-3]]:{{[0-9]+}}: error: instruction requires: 8-bit integer matrix multiply
15+
16+
vusmmla.s8 q0, q1, q2
17+
// ARM: vusmmla.s8 q0, q1, q2 @ encoding: [0x44,0x0c,0xa2,0xfc]
18+
// THUMB: vusmmla.s8 q0, q1, q2 @ encoding: [0xa2,0xfc,0x44,0x0c]
19+
// NOMATMUL: [[@LINE-3]]:{{[0-9]+}}: error: instruction requires: 8-bit integer matrix multiply
20+
21+
vusdot.s8 d0, d1, d2
22+
// ARM: vusdot.s8 d0, d1, d2 @ encoding: [0x02,0x0d,0xa1,0xfc]
23+
// THUMB: vusdot.s8 d0, d1, d2 @ encoding: [0xa1,0xfc,0x02,0x0d]
24+
// NOMATMUL: [[@LINE-3]]:{{[0-9]+}}: error: instruction requires: 8-bit integer matrix multiply
25+
26+
vusdot.s8 q0, q1, q2
27+
// ARM: vusdot.s8 q0, q1, q2 @ encoding: [0x44,0x0d,0xa2,0xfc]
28+
// THUMB: vusdot.s8 q0, q1, q2 @ encoding: [0xa2,0xfc,0x44,0x0d]
29+
// NOMATMUL: [[@LINE-3]]:{{[0-9]+}}: error: instruction requires: 8-bit integer matrix multiply
30+
31+
vusdot.s8 d0, d1, d2[0]
32+
// ARM: vusdot.s8 d0, d1, d2[0] @ encoding: [0x02,0x0d,0x81,0xfe]
33+
// THUMB: vusdot.s8 d0, d1, d2[0] @ encoding: [0x81,0xfe,0x02,0x0d]
34+
// NOMATMUL: [[@LINE-3]]:{{[0-9]+}}: error: instruction requires: 8-bit integer matrix multiply
35+
36+
vsudot.u8 d0, d1, d2[1]
37+
// ARM: vsudot.u8 d0, d1, d2[1] @ encoding: [0x32,0x0d,0x81,0xfe]
38+
// THUMB: vsudot.u8 d0, d1, d2[1] @ encoding: [0x81,0xfe,0x32,0x0d]
39+
// NOMATMUL: [[@LINE-3]]:{{[0-9]+}}: error: instruction requires: 8-bit integer matrix multiply
40+
41+
vusdot.s8 q0, q1, d2[0]
42+
// ARM: vusdot.s8 q0, q1, d2[0] @ encoding: [0x42,0x0d,0x82,0xfe]
43+
// THUMB: vusdot.s8 q0, q1, d2[0] @ encoding: [0x82,0xfe,0x42,0x0d]
44+
// NOMATMUL: [[@LINE-3]]:{{[0-9]+}}: error: instruction requires: 8-bit integer matrix multiply
45+
46+
vsudot.u8 q0, q1, d2[1]
47+
// ARM: vsudot.u8 q0, q1, d2[1] @ encoding: [0x72,0x0d,0x82,0xfe]
48+
// THUMB: vsudot.u8 q0, q1, d2[1] @ encoding: [0x82,0xfe,0x72,0x0d]
49+
// NOMATMUL: [[@LINE-3]]:{{[0-9]+}}: error: instruction requires: 8-bit integer matrix multiply
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# RUN: llvm-mc -triple=armv8 -mattr=+i8mm -disassemble < %s | FileCheck %s
2+
# RUN: not llvm-mc -triple=armv8 -mattr=+v8.4a -disassemble < %s 2>&1 | FileCheck %s --check-prefix=NOMATMUL
3+
4+
[0x44,0x0c,0x22,0xfc]
5+
# CHECK: vsmmla.s8 q0, q1, q2
6+
# NOMATMUL: :[[@LINE-2]]:{{[0-9]+}}: warning: invalid instruction encoding
7+
8+
[0x54,0x0c,0x22,0xfc]
9+
# CHECK: vummla.u8 q0, q1, q2
10+
# NOMATMUL: :[[@LINE-2]]:{{[0-9]+}}: warning: invalid instruction encoding
11+
12+
[0x44,0x0c,0xa2,0xfc]
13+
# CHECK: vusmmla.s8 q0, q1, q2
14+
# NOMATMUL: :[[@LINE-2]]:{{[0-9]+}}: warning: invalid instruction encoding
15+
16+
[0x02,0x0d,0xa1,0xfc]
17+
# CHECK: vusdot.s8 d0, d1, d2
18+
# NOMATMUL: :[[@LINE-2]]:{{[0-9]+}}: warning: invalid instruction encoding
19+
20+
[0x44,0x0d,0xa2,0xfc]
21+
# CHECK: vusdot.s8 q0, q1, q2
22+
# NOMATMUL: :[[@LINE-2]]:{{[0-9]+}}: warning: invalid instruction encoding
23+
24+
[0x02,0x0d,0x81,0xfe]
25+
# CHECK: vusdot.s8 d0, d1, d2[0]
26+
# NOMATMUL: :[[@LINE-2]]:{{[0-9]+}}: warning: invalid instruction encoding
27+
28+
[0x32,0x0d,0x81,0xfe]
29+
# CHECK: vsudot.u8 d0, d1, d2[1]
30+
# NOMATMUL: :[[@LINE-2]]:{{[0-9]+}}: warning: invalid instruction encoding
31+
32+
[0x42,0x0d,0x82,0xfe]
33+
# CHECK: vusdot.s8 q0, q1, d2[0]
34+
# NOMATMUL: :[[@LINE-2]]:{{[0-9]+}}: warning: invalid instruction encoding
35+
36+
[0x72,0x0d,0x82,0xfe]
37+
# CHECK: vsudot.u8 q0, q1, d2[1]
38+
# NOMATMUL: :[[@LINE-2]]:{{[0-9]+}}: warning: invalid instruction encoding
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# RUN: llvm-mc -triple=thumbv8a -mattr=+i8mm -disassemble < %s | FileCheck %s
2+
# RUN: not llvm-mc -triple=thumbv8a -mattr=+v8.4a -disassemble < %s 2>&1 | FileCheck %s --check-prefix=NOMATMUL
3+
4+
[0x22,0xfc,0x44,0x0c]
5+
# CHECK: vsmmla.s8 q0, q1, q2
6+
# NOMATMUL: :[[@LINE-2]]:{{[0-9]+}}: warning: invalid instruction encoding
7+
8+
[0x22,0xfc,0x54,0x0c]
9+
# CHECK: vummla.u8 q0, q1, q2
10+
# NOMATMUL: :[[@LINE-2]]:{{[0-9]+}}: warning: invalid instruction encoding
11+
12+
[0xa2,0xfc,0x44,0x0c]
13+
# CHECK: vusmmla.s8 q0, q1, q2
14+
# NOMATMUL: :[[@LINE-2]]:{{[0-9]+}}: warning: invalid instruction encoding
15+
16+
[0xa1,0xfc,0x02,0x0d]
17+
# CHECK: vusdot.s8 d0, d1, d2
18+
# NOMATMUL: :[[@LINE-2]]:{{[0-9]+}}: warning: invalid instruction encoding
19+
20+
[0xa2,0xfc,0x44,0x0d]
21+
# CHECK: vusdot.s8 q0, q1, q2
22+
# NOMATMUL: :[[@LINE-2]]:{{[0-9]+}}: warning: invalid instruction encoding
23+
24+
[0x81,0xfe,0x02,0x0d]
25+
# CHECK: vusdot.s8 d0, d1, d2[0]
26+
# NOMATMUL: :[[@LINE-2]]:{{[0-9]+}}: warning: invalid instruction encoding
27+
28+
[0x81,0xfe,0x32,0x0d]
29+
# CHECK: vsudot.u8 d0, d1, d2[1]
30+
# NOMATMUL: :[[@LINE-2]]:{{[0-9]+}}: warning: invalid instruction encoding
31+
32+
[0x82,0xfe,0x42,0x0d]
33+
# CHECK: vusdot.s8 q0, q1, d2[0]
34+
# NOMATMUL: :[[@LINE-2]]:{{[0-9]+}}: warning: invalid instruction encoding
35+
36+
[0x82,0xfe,0x72,0x0d]
37+
# CHECK: vsudot.u8 q0, q1, d2[1]
38+
# NOMATMUL: :[[@LINE-2]]:{{[0-9]+}}: warning: invalid instruction encoding

0 commit comments

Comments
 (0)