Skip to content

Commit a7ec090

Browse files
committedJan 10, 2018
[AArch64][SVE] Asm: Add support for (mov|dup) of scalar
Summary: This patch adds support for 'dup' (Scalar -> SVE) and its corresponding 'mov' alias. Reviewers: fhahn, rengolin, evandro, echristo Reviewed By: fhahn Subscribers: aemerson, javed.absar, tschuett, kristof.beyls, llvm-commits Differential Revision: https://reviews.llvm.org/D41822 llvm-svn: 322172
1 parent e3591f3 commit a7ec090

File tree

6 files changed

+187
-0
lines changed

6 files changed

+187
-0
lines changed
 

‎llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td

+2
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@ let Predicates = [HasSVE] in {
2323

2424
defm ZIP1_PPP : sve_int_perm_bin_perm_pp<0b000, "zip1">;
2525
defm ZIP2_PPP : sve_int_perm_bin_perm_pp<0b001, "zip2">;
26+
27+
defm DUP_ZR : sve_int_perm_dup_r<"dup">;
2628
}

‎llvm/lib/Target/AArch64/SVEInstrFormats.td

+35
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,41 @@
1111
//
1212
//===----------------------------------------------------------------------===//
1313

14+
//===----------------------------------------------------------------------===//
15+
// SVE Permute - Cross Lane Group
16+
//===----------------------------------------------------------------------===//
17+
18+
class sve_int_perm_dup_r<bits<2> sz8_64, string asm, ZPRRegOp zprty,
19+
RegisterClass srcRegType>
20+
: I<(outs zprty:$Zd), (ins srcRegType:$Rn),
21+
asm, "\t$Zd, $Rn",
22+
"",
23+
[]>, Sched<[]> {
24+
bits<5> Rn;
25+
bits<5> Zd;
26+
let Inst{31-24} = 0b00000101;
27+
let Inst{23-22} = sz8_64;
28+
let Inst{21-10} = 0b100000001110;
29+
let Inst{9-5} = Rn;
30+
let Inst{4-0} = Zd;
31+
}
32+
33+
multiclass sve_int_perm_dup_r<string asm> {
34+
def _B : sve_int_perm_dup_r<0b00, asm, ZPR8, GPR32sp>;
35+
def _H : sve_int_perm_dup_r<0b01, asm, ZPR16, GPR32sp>;
36+
def _S : sve_int_perm_dup_r<0b10, asm, ZPR32, GPR32sp>;
37+
def _D : sve_int_perm_dup_r<0b11, asm, ZPR64, GPR64sp>;
38+
39+
def : InstAlias<"mov $Zd, $Rn",
40+
(!cast<Instruction>(NAME # _B) ZPR8:$Zd, GPR32sp:$Rn), 1>;
41+
def : InstAlias<"mov $Zd, $Rn",
42+
(!cast<Instruction>(NAME # _H) ZPR16:$Zd, GPR32sp:$Rn), 1>;
43+
def : InstAlias<"mov $Zd, $Rn",
44+
(!cast<Instruction>(NAME # _S) ZPR32:$Zd, GPR32sp:$Rn), 1>;
45+
def : InstAlias<"mov $Zd, $Rn",
46+
(!cast<Instruction>(NAME # _D) ZPR64:$Zd, GPR64sp:$Rn), 1>;
47+
}
48+
1449
//===----------------------------------------------------------------------===//
1550
// SVE Integer Arithmetic - Unpredicated Group.
1651
//===----------------------------------------------------------------------===//
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: not llvm-mc -triple=aarch64 -show-encoding -mattr=+sve 2>&1 < %s| FileCheck %s
2+
3+
// input should be a 64bit scalar register
4+
dup z0.d, w0
5+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
6+
// CHECK-NEXT: dup z0.d, w0
7+
// CHECK-NOT: [[@LINE-3]]:{{[0-9]+}}:
8+
9+
// wzr is not a valid operand to dup
10+
dup z0.s, wzr
11+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
12+
// CHECK-NEXT: dup z0.s, wzr
13+
// CHECK-NOT: [[@LINE-3]]:{{[0-9]+}}:
14+
15+
// xzr is not a valid operand to dup
16+
dup z0.d, xzr
17+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
18+
// CHECK-NEXT: dup z0.d, xzr
19+
// CHECK-NOT: [[@LINE-3]]:{{[0-9]+}}:

‎llvm/test/MC/AArch64/SVE/dup.s

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// RUN: llvm-mc -triple=aarch64 -show-encoding -mattr=+sve < %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=+sve < %s \
6+
// RUN: | llvm-objdump -d -mattr=+sve - | FileCheck %s --check-prefix=CHECK-INST
7+
// RUN: llvm-mc -triple=aarch64 -filetype=obj -mattr=+sve < %s \
8+
// RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN
9+
10+
dup z0.b, w0
11+
// CHECK-INST: mov z0.b, w0
12+
// CHECK-ENCODING: [0x00,0x38,0x20,0x05]
13+
// CHECK-ERROR: instruction requires: sve
14+
// CHECK-UNKNOWN: 00 38 20 05 <unknown>
15+
16+
dup z0.h, w0
17+
// CHECK-INST: mov z0.h, w0
18+
// CHECK-ENCODING: [0x00,0x38,0x60,0x05]
19+
// CHECK-ERROR: instruction requires: sve
20+
// CHECK-UNKNOWN: 00 38 60 05 <unknown>
21+
22+
dup z0.s, w0
23+
// CHECK-INST: mov z0.s, w0
24+
// CHECK-ENCODING: [0x00,0x38,0xa0,0x05]
25+
// CHECK-ERROR: instruction requires: sve
26+
// CHECK-UNKNOWN: 00 38 a0 05 <unknown>
27+
28+
dup z0.d, x0
29+
// CHECK-INST: mov z0.d, x0
30+
// CHECK-ENCODING: [0x00,0x38,0xe0,0x05]
31+
// CHECK-ERROR: instruction requires: sve
32+
// CHECK-UNKNOWN: 00 38 e0 05 <unknown>
33+
34+
dup z31.h, wsp
35+
// CHECK-INST: mov z31.h, wsp
36+
// CHECK-ENCODING: [0xff,0x3b,0x60,0x05]
37+
// CHECK-ERROR: instruction requires: sve
38+
// CHECK-UNKNOWN: ff 3b 60 05 <unknown>
39+
40+
dup z31.s, wsp
41+
// CHECK-INST: mov z31.s, wsp
42+
// CHECK-ENCODING: [0xff,0x3b,0xa0,0x05]
43+
// CHECK-ERROR: instruction requires: sve
44+
// CHECK-UNKNOWN: ff 3b a0 05 <unknown>
45+
46+
dup z31.d, sp
47+
// CHECK-INST: mov z31.d, sp
48+
// CHECK-ENCODING: [0xff,0x3b,0xe0,0x05]
49+
// CHECK-ERROR: instruction requires: sve
50+
// CHECK-UNKNOWN: ff 3b e0 05 <unknown>
51+
52+
dup z31.b, wsp
53+
// CHECK-INST: mov z31.b, wsp
54+
// CHECK-ENCODING: [0xff,0x3b,0x20,0x05]
55+
// CHECK-ERROR: instruction requires: sve
56+
// CHECK-UNKNOWN: ff 3b 20 05 <unknown>
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: not llvm-mc -triple=aarch64 -show-encoding -mattr=+sve 2>&1 < %s| FileCheck %s
2+
3+
// input should be a 64bit scalar register
4+
mov z0.d, w0
5+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
6+
// CHECK-NEXT: mov z0.d, w0
7+
// CHECK-NOT: [[@LINE-3]]:{{[0-9]+}}:
8+
9+
// wzr is not a valid operand to mov
10+
mov z0.s, wzr
11+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
12+
// CHECK-NEXT: mov z0.s, wzr
13+
// CHECK-NOT: [[@LINE-3]]:{{[0-9]+}}:
14+
15+
// xzr is not a valid operand to mov
16+
mov z0.d, xzr
17+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid operand for instruction
18+
// CHECK-NEXT: mov z0.d, xzr
19+
// CHECK-NOT: [[@LINE-3]]:{{[0-9]+}}:

‎llvm/test/MC/AArch64/SVE/mov.s

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// RUN: llvm-mc -triple=aarch64 -show-encoding -mattr=+sve < %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=+sve < %s \
6+
// RUN: | llvm-objdump -d -mattr=+sve - | FileCheck %s --check-prefix=CHECK-INST
7+
// RUN: llvm-mc -triple=aarch64 -filetype=obj -mattr=+sve < %s \
8+
// RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN
9+
10+
mov z0.b, w0
11+
// CHECK-INST: mov z0.b, w0
12+
// CHECK-ENCODING: [0x00,0x38,0x20,0x05]
13+
// CHECK-ERROR: instruction requires: sve
14+
// CHECK-UNKNOWN: 00 38 20 05 <unknown>
15+
16+
mov z0.h, w0
17+
// CHECK-INST: mov z0.h, w0
18+
// CHECK-ENCODING: [0x00,0x38,0x60,0x05]
19+
// CHECK-ERROR: instruction requires: sve
20+
// CHECK-UNKNOWN: 00 38 60 05 <unknown>
21+
22+
mov z0.s, w0
23+
// CHECK-INST: mov z0.s, w0
24+
// CHECK-ENCODING: [0x00,0x38,0xa0,0x05]
25+
// CHECK-ERROR: instruction requires: sve
26+
// CHECK-UNKNOWN: 00 38 a0 05 <unknown>
27+
28+
mov z0.d, x0
29+
// CHECK-INST: mov z0.d, x0
30+
// CHECK-ENCODING: [0x00,0x38,0xe0,0x05]
31+
// CHECK-ERROR: instruction requires: sve
32+
// CHECK-UNKNOWN: 00 38 e0 05 <unknown>
33+
34+
mov z31.h, wsp
35+
// CHECK-INST: mov z31.h, wsp
36+
// CHECK-ENCODING: [0xff,0x3b,0x60,0x05]
37+
// CHECK-ERROR: instruction requires: sve
38+
// CHECK-UNKNOWN: ff 3b 60 05 <unknown>
39+
40+
mov z31.s, wsp
41+
// CHECK-INST: mov z31.s, wsp
42+
// CHECK-ENCODING: [0xff,0x3b,0xa0,0x05]
43+
// CHECK-ERROR: instruction requires: sve
44+
// CHECK-UNKNOWN: ff 3b a0 05 <unknown>
45+
46+
mov z31.d, sp
47+
// CHECK-INST: mov z31.d, sp
48+
// CHECK-ENCODING: [0xff,0x3b,0xe0,0x05]
49+
// CHECK-ERROR: instruction requires: sve
50+
// CHECK-UNKNOWN: ff 3b e0 05 <unknown>
51+
52+
mov z31.b, wsp
53+
// CHECK-INST: mov z31.b, wsp
54+
// CHECK-ENCODING: [0xff,0x3b,0x20,0x05]
55+
// CHECK-ERROR: instruction requires: sve
56+
// CHECK-UNKNOWN: ff 3b 20 05 <unknown>

0 commit comments

Comments
 (0)
Please sign in to comment.