Skip to content

Commit ce0368e

Browse files
authored
[AArch64] Add assembly/disassembly for PMLAL/PMULL instructions (#113564)
This patch adds assembly/disassembly for the following SVE_AES2 instructions - PMLAL - PMULL - In accordance with: https://developer.arm.com/documentation/ddi0602/latest/
1 parent b1ede8f commit ce0368e

File tree

6 files changed

+184
-0
lines changed

6 files changed

+184
-0
lines changed

llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3928,6 +3928,10 @@ let Predicates = [HasSVEAES2, HasSVE2p1orSSVE_AES] in {
39283928
def AESD_4ZZI_B : sve_crypto_binary_multi4<0b0100, "aesd">;
39293929
def AESEMC_4ZZI_B : sve_crypto_binary_multi4<0b1000, "aesemc">;
39303930
def AESDMIC_4ZZI_B : sve_crypto_binary_multi4<0b1100, "aesdimc">;
3931+
3932+
// SVE_AES2 multi-vector polynomial multiply
3933+
def PMLAL_2ZZZ_Q : sve_crypto_pmlal_multi<"pmlal">;
3934+
def PMULL_2ZZZ_Q : sve_crypto_pmull_multi<"pmull">;
39313935
} // End HasSVEAES2, HasSVE2p1orSSVE_AES
39323936

39333937
//===----------------------------------------------------------------------===//

llvm/lib/Target/AArch64/SVEInstrFormats.td

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8879,6 +8879,46 @@ class sve_crypto_binary_multi4<bits<4> opc, string asm>
88798879
let hasSideEffects = 0;
88808880
}
88818881

8882+
class sve_crypto_pmlal_multi<string asm>
8883+
: I<(outs ZZ_q_mul_r:$Zda),
8884+
(ins ZZ_q_mul_r:$_Zda, ZPR64:$Zn, ZPR64:$Zm),
8885+
asm,
8886+
"\t$Zda, $Zn, $Zm",
8887+
"",
8888+
[]>, Sched<[]> {
8889+
bits<5> Zm;
8890+
bits<5> Zn;
8891+
bits<4> Zda;
8892+
let Inst{31-21} = 0b01000101001;
8893+
let Inst{20-16} = Zm;
8894+
let Inst{15-10} = 0b111111;
8895+
let Inst{9-5} = Zn;
8896+
let Inst{4-1} = Zda;
8897+
let Inst{0} = 0b0;
8898+
8899+
let Constraints = "$Zda = $_Zda";
8900+
let hasSideEffects = 0;
8901+
}
8902+
8903+
class sve_crypto_pmull_multi<string asm>
8904+
: I<(outs ZZ_q_mul_r:$Zd),
8905+
(ins ZPR64:$Zn, ZPR64:$Zm),
8906+
asm,
8907+
"\t$Zd, $Zn, $Zm",
8908+
"",
8909+
[]>, Sched<[]> {
8910+
bits<5> Zm;
8911+
bits<5> Zn;
8912+
bits<4> Zd;
8913+
let Inst{31-21} = 0b01000101001;
8914+
let Inst{20-16} = Zm;
8915+
let Inst{15-10} = 0b111110;
8916+
let Inst{9-5} = Zn;
8917+
let Inst{4-1} = Zd;
8918+
let Inst{0} = 0b0;
8919+
let hasSideEffects = 0;
8920+
}
8921+
88828922
//===----------------------------------------------------------------------===//
88838923
// SVE BFloat16 Group
88848924
//===----------------------------------------------------------------------===//
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// RUN: not llvm-mc -triple=aarch64 -show-encoding -mattr=+sve2p1,+sve-aes2 2>&1 < %s | FileCheck %s
2+
3+
// --------------------------------------------------------------------------//
4+
// Invalid vector list
5+
6+
pmlal {z0.q-z2.q}, z0.d, z0.d
7+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
8+
// CHECK-NEXT: pmlal {z0.q-z2.q}, z0.d, z0.d
9+
// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
10+
11+
pmlal {z0.q-z0.q}, z0.d, z0.d
12+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid number of vectors
13+
// CHECK-NEXT: pmlal {z0.q-z0.q}, z0.d, z0.d
14+
// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
15+
16+
pmlal {z1.q-z2.q}, z0.d, z0.d
17+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid vector list, expected list with 2 consecutive SVE vectors, where the first vector is a multiple of 2 and with matching element types
18+
// CHECK-NEXT: pmlal {z1.q-z2.q}, z0.d, z0.d
19+
// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
20+
21+
pmlal {z0.d-z1.d}, z0.d, z0.d
22+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
23+
// CHECK-NEXT: pmlal {z0.d-z1.d}, z0.d, z0.d
24+
// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
25+
26+
// --------------------------------------------------------------------------//
27+
// Invalid single source vectors
28+
29+
pmlal {z0.q-z1.q}, z0.s, z0.d
30+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid element width
31+
// CHECK-NEXT: pmlal {z0.q-z1.q}, z0.s, z0.d
32+
// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
33+
34+
pmlal {z0.q-z1.q}, z0.d, z0.s
35+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid element width
36+
// CHECK-NEXT: pmlal {z0.q-z1.q}, z0.d, z0.s
37+
// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:

llvm/test/MC/AArch64/SVE2p1/pmlal.s

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// RUN: llvm-mc -triple=aarch64 -show-encoding -mattr=+sve-aes2,+sve2p1 < %s \
2+
// RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
3+
// RUN: llvm-mc -triple=aarch64 -show-encoding -mattr=+sve-aes2,+ssve-aes < %s \
4+
// RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
5+
// RUN: not llvm-mc -triple=aarch64 -show-encoding < %s 2>&1 \
6+
// RUN: | FileCheck %s --check-prefix=CHECK-ERROR
7+
// RUN: llvm-mc -triple=aarch64 -filetype=obj -mattr=+sve-aes2,+sve2p1 < %s \
8+
// RUN: | llvm-objdump -d --mattr=+sve-aes2,+sve2p1 - | FileCheck %s --check-prefix=CHECK-INST
9+
// RUN: llvm-mc -triple=aarch64 -filetype=obj -mattr=+sve-aes2,+sve2p1 < %s \
10+
// RUN: | llvm-objdump -d --mattr=-sve-aes2 - | FileCheck %s --check-prefix=CHECK-UNKNOWN
11+
// Disassemble encoding and check the re-encoding (-show-encoding) matches.
12+
// RUN: llvm-mc -triple=aarch64 -show-encoding -mattr=+sve-aes2,+sve2p1 < %s \
13+
// RUN: | sed '/.text/d' | sed 's/.*encoding: //g' \
14+
// RUN: | llvm-mc -triple=aarch64 -mattr=+sve-aes2,+sve2p1 -disassemble -show-encoding \
15+
// RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
16+
17+
pmlal {z0.q-z1.q}, z0.d, z0.d // 01000101-00100000-11111100-00000000
18+
// CHECK-INST: pmlal { z0.q, z1.q }, z0.d, z0.d
19+
// CHECK-ENCODING: [0x00,0xfc,0x20,0x45]
20+
// CHECK-ERROR: instruction requires: sve2p1 or ssve-aes sve-aes2
21+
// CHECK-UNKNOWN: 4520fc00 <unknown>
22+
23+
pmlal {z22.q-z23.q}, z13.d, z8.d // 01000101-00101000-11111101-10110110
24+
// CHECK-INST: pmlal { z22.q, z23.q }, z13.d, z8.d
25+
// CHECK-ENCODING: [0xb6,0xfd,0x28,0x45]
26+
// CHECK-ERROR: instruction requires: sve2p1 or ssve-aes sve-aes2
27+
// CHECK-UNKNOWN: 4528fdb6 <unknown>
28+
29+
pmlal {z30.q-z31.q}, z31.d, z31.d // 01000101-00111111-11111111-11111110
30+
// CHECK-INST: pmlal { z30.q, z31.q }, z31.d, z31.d
31+
// CHECK-ENCODING: [0xfe,0xff,0x3f,0x45]
32+
// CHECK-ERROR: instruction requires: sve2p1 or ssve-aes sve-aes2
33+
// CHECK-UNKNOWN: 453ffffe <unknown>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// RUN: not llvm-mc -triple=aarch64 -show-encoding -mattr=+sve2p1,+sve-aes2 2>&1 < %s | FileCheck %s
2+
3+
// --------------------------------------------------------------------------//
4+
// Invalid vector list
5+
6+
pmull {z0.q-z2.q}, z0.d, z0.d
7+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
8+
// CHECK-NEXT: pmull {z0.q-z2.q}, z0.d, z0.d
9+
// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
10+
11+
pmull {z0.q-z0.q}, z0.d, z0.d
12+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid number of vectors
13+
// CHECK-NEXT: pmull {z0.q-z0.q}, z0.d, z0.d
14+
// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
15+
16+
pmull {z1.q-z2.q}, z0.d, z0.d
17+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: Invalid vector list, expected list with 2 consecutive SVE vectors, where the first vector is a multiple of 2 and with matching element types
18+
// CHECK-NEXT: pmull {z1.q-z2.q}, z0.d, z0.d
19+
// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
20+
21+
pmull {z0.d-z1.d}, z0.d, z0.d
22+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
23+
// CHECK-NEXT: pmull {z0.d-z1.d}, z0.d, z0.d
24+
// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
25+
26+
// --------------------------------------------------------------------------//
27+
// Invalid single source vectors
28+
29+
pmull {z0.q-z1.q}, z0.s, z0.d
30+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid element width
31+
// CHECK-NEXT: pmull {z0.q-z1.q}, z0.s, z0.d
32+
// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
33+
34+
pmull {z0.q-z1.q}, z0.d, z0.s
35+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid element width
36+
// CHECK-NEXT: pmull {z0.q-z1.q}, z0.d, z0.s
37+
// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:

llvm/test/MC/AArch64/SVE2p1/pmull.s

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// RUN: llvm-mc -triple=aarch64 -show-encoding -mattr=+sve-aes2,+sve2p1 < %s \
2+
// RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
3+
// RUN: llvm-mc -triple=aarch64 -show-encoding -mattr=+sve-aes2,+ssve-aes < %s \
4+
// RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
5+
// RUN: not llvm-mc -triple=aarch64 -show-encoding < %s 2>&1 \
6+
// RUN: | FileCheck %s --check-prefix=CHECK-ERROR
7+
// RUN: llvm-mc -triple=aarch64 -filetype=obj -mattr=+sve-aes2,+sve2p1 < %s \
8+
// RUN: | llvm-objdump -d --mattr=+sve-aes2,+sve2p1 - | FileCheck %s --check-prefix=CHECK-INST
9+
// RUN: llvm-mc -triple=aarch64 -filetype=obj -mattr=+sve-aes2,+sve2p1 < %s \
10+
// RUN: | llvm-objdump -d --mattr=-sve-aes2 - | FileCheck %s --check-prefix=CHECK-UNKNOWN
11+
// Disassemble encoding and check the re-encoding (-show-encoding) matches.
12+
// RUN: llvm-mc -triple=aarch64 -show-encoding -mattr=+sve-aes2,+sve2p1 < %s \
13+
// RUN: | sed '/.text/d' | sed 's/.*encoding: //g' \
14+
// RUN: | llvm-mc -triple=aarch64 -mattr=+sve-aes2,+sve2p1 -disassemble -show-encoding \
15+
// RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
16+
17+
pmull {z0.q-z1.q}, z0.d, z0.d // 01000101-00100000-11111000-00000000
18+
// CHECK-INST: pmull { z0.q, z1.q }, z0.d, z0.d
19+
// CHECK-ENCODING: [0x00,0xf8,0x20,0x45]
20+
// CHECK-ERROR: instruction requires: sve2p1 or ssve-aes sve-aes2
21+
// CHECK-UNKNOWN: 4520f800 <unknown>
22+
23+
pmull {z22.q-z23.q}, z13.d, z8.d // 01000101-00101000-11111001-10110110
24+
// CHECK-INST: pmull { z22.q, z23.q }, z13.d, z8.d
25+
// CHECK-ENCODING: [0xb6,0xf9,0x28,0x45]
26+
// CHECK-ERROR: instruction requires: sve2p1 or ssve-aes sve-aes2
27+
// CHECK-UNKNOWN: 4528f9b6 <unknown>
28+
29+
pmull {z30.q-z31.q}, z31.d, z31.d // 01000101-00111111-11111011-11111110
30+
// CHECK-INST: pmull { z30.q, z31.q }, z31.d, z31.d
31+
// CHECK-ENCODING: [0xfe,0xfb,0x3f,0x45]
32+
// CHECK-ERROR: instruction requires: sve2p1 or ssve-aes sve-aes2
33+
// CHECK-UNKNOWN: 453ffbfe <unknown>

0 commit comments

Comments
 (0)