Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 93fba7b

Browse files
committed
[AArch64][SVE] Asm: Support for TBL instruction.
Support for SVE's TBL instruction for programmable table lookup/permute using vector of element indices, e.g. tbl z0.d, { z1.d }, z2.d stores elements from z1, indexed by elements from z2, into z0. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336544 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent d77ac0d commit 93fba7b

File tree

4 files changed

+102
-0
lines changed

4 files changed

+102
-0
lines changed

lib/Target/AArch64/AArch64SVEInstrInfo.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,8 @@ let Predicates = [HasSVE] in {
539539
defm ADR_LSL_ZZZ_S : sve_int_bin_cons_misc_0_a_32_lsl<0b10, "adr">;
540540
defm ADR_LSL_ZZZ_D : sve_int_bin_cons_misc_0_a_64_lsl<0b11, "adr">;
541541

542+
defm TBL_ZZZ : sve_int_perm_tbl<"tbl">;
543+
542544
defm ZIP1_ZZZ : sve_int_perm_bin_perm_zz<0b000, "zip1">;
543545
defm ZIP2_ZZZ : sve_int_perm_bin_perm_zz<0b001, "zip2">;
544546
defm UZP1_ZZZ : sve_int_perm_bin_perm_zz<0b010, "uzp1">;

lib/Target/AArch64/SVEInstrFormats.td

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,39 @@ multiclass sve_int_perm_dup_i<string asm> {
571571
(!cast<Instruction>(NAME # _Q) ZPR128:$Zd, FPR128asZPR:$Qn, 0), 2>;
572572
}
573573

574+
class sve_int_perm_tbl<bits<2> sz8_64, string asm, ZPRRegOp zprty,
575+
RegisterOperand VecList>
576+
: I<(outs zprty:$Zd), (ins VecList:$Zn, zprty:$Zm),
577+
asm, "\t$Zd, $Zn, $Zm",
578+
"",
579+
[]>, Sched<[]> {
580+
bits<5> Zd;
581+
bits<5> Zm;
582+
bits<5> Zn;
583+
let Inst{31-24} = 0b00000101;
584+
let Inst{23-22} = sz8_64;
585+
let Inst{21} = 0b1;
586+
let Inst{20-16} = Zm;
587+
let Inst{15-10} = 0b001100;
588+
let Inst{9-5} = Zn;
589+
let Inst{4-0} = Zd;
590+
}
591+
592+
multiclass sve_int_perm_tbl<string asm> {
593+
def _B : sve_int_perm_tbl<0b00, asm, ZPR8, Z_b>;
594+
def _H : sve_int_perm_tbl<0b01, asm, ZPR16, Z_h>;
595+
def _S : sve_int_perm_tbl<0b10, asm, ZPR32, Z_s>;
596+
def _D : sve_int_perm_tbl<0b11, asm, ZPR64, Z_d>;
597+
598+
def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
599+
(!cast<Instruction>(NAME # _B) ZPR8:$Zd, ZPR8:$Zn, ZPR8:$Zm), 0>;
600+
def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
601+
(!cast<Instruction>(NAME # _H) ZPR16:$Zd, ZPR16:$Zn, ZPR16:$Zm), 0>;
602+
def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
603+
(!cast<Instruction>(NAME # _S) ZPR32:$Zd, ZPR32:$Zn, ZPR32:$Zm), 0>;
604+
def : InstAlias<asm # "\t$Zd, $Zn, $Zm",
605+
(!cast<Instruction>(NAME # _D) ZPR64:$Zd, ZPR64:$Zn, ZPR64:$Zm), 0>;
606+
}
574607

575608
//===----------------------------------------------------------------------===//
576609
// SVE Vector Select Group

test/MC/AArch64/SVE/tbl-diagnostics.s

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: not llvm-mc -triple=aarch64 -show-encoding -mattr=+sve 2>&1 < %s| FileCheck %s
2+
3+
tbl z0.h, z0.h, z0.b
4+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid element width
5+
// CHECK-NEXT: tbl z0.h, z0.h, z0.b
6+
// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
7+
8+
tbl { z0.h }, z0.h, z0.h
9+
// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: vector register expected
10+
// CHECK-NEXT: tbl { z0.h }, z0.h, z0.h
11+
// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:

test/MC/AArch64/SVE/tbl.s

Lines changed: 56 additions & 0 deletions
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+
tbl z31.b, z31.b, z31.b
11+
// CHECK-INST: tbl z31.b, { z31.b }, z31.b
12+
// CHECK-ENCODING: [0xff,0x33,0x3f,0x05]
13+
// CHECK-ERROR: instruction requires: sve
14+
// CHECK-UNKNOWN: ff 33 3f 05 <unknown>
15+
16+
tbl z31.h, z31.h, z31.h
17+
// CHECK-INST: tbl z31.h, { z31.h }, z31.h
18+
// CHECK-ENCODING: [0xff,0x33,0x7f,0x05]
19+
// CHECK-ERROR: instruction requires: sve
20+
// CHECK-UNKNOWN: ff 33 7f 05 <unknown>
21+
22+
tbl z31.s, z31.s, z31.s
23+
// CHECK-INST: tbl z31.s, { z31.s }, z31.s
24+
// CHECK-ENCODING: [0xff,0x33,0xbf,0x05]
25+
// CHECK-ERROR: instruction requires: sve
26+
// CHECK-UNKNOWN: ff 33 bf 05 <unknown>
27+
28+
tbl z31.d, z31.d, z31.d
29+
// CHECK-INST: tbl z31.d, { z31.d }, z31.d
30+
// CHECK-ENCODING: [0xff,0x33,0xff,0x05]
31+
// CHECK-ERROR: instruction requires: sve
32+
// CHECK-UNKNOWN: ff 33 ff 05 <unknown>
33+
34+
tbl z31.b, { z31.b }, z31.b
35+
// CHECK-INST: tbl z31.b, { z31.b }, z31.b
36+
// CHECK-ENCODING: [0xff,0x33,0x3f,0x05]
37+
// CHECK-ERROR: instruction requires: sve
38+
// CHECK-UNKNOWN: ff 33 3f 05 <unknown>
39+
40+
tbl z31.h, { z31.h }, z31.h
41+
// CHECK-INST: tbl z31.h, { z31.h }, z31.h
42+
// CHECK-ENCODING: [0xff,0x33,0x7f,0x05]
43+
// CHECK-ERROR: instruction requires: sve
44+
// CHECK-UNKNOWN: ff 33 7f 05 <unknown>
45+
46+
tbl z31.s, { z31.s }, z31.s
47+
// CHECK-INST: tbl z31.s, { z31.s }, z31.s
48+
// CHECK-ENCODING: [0xff,0x33,0xbf,0x05]
49+
// CHECK-ERROR: instruction requires: sve
50+
// CHECK-UNKNOWN: ff 33 bf 05 <unknown>
51+
52+
tbl z31.d, { z31.d }, z31.d
53+
// CHECK-INST: tbl z31.d, { z31.d }, z31.d
54+
// CHECK-ENCODING: [0xff,0x33,0xff,0x05]
55+
// CHECK-ERROR: instruction requires: sve
56+
// CHECK-UNKNOWN: ff 33 ff 05 <unknown>

0 commit comments

Comments
 (0)