[llvm] e3fef88 - [AArch64][SVE2] Add the SVE2.1 tbxq instruction
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 10 01:06:07 PST 2022
Author: David Sherwood
Date: 2022-11-10T09:05:59Z
New Revision: e3fef88a30a118d00562245138e65694c90d67cc
URL: https://github.com/llvm/llvm-project/commit/e3fef88a30a118d00562245138e65694c90d67cc
DIFF: https://github.com/llvm/llvm-project/commit/e3fef88a30a118d00562245138e65694c90d67cc.diff
LOG: [AArch64][SVE2] Add the SVE2.1 tbxq instruction
This patch adds the assembly/disassembly for the following instruction:
tbxq : Programmable table lookup within each quadword vector segment (merging)
The reference can be found here:
https://developer.arm.com/documentation/ddi0602/2022-09
Differential Revision: https://reviews.llvm.org/D137625
Added:
llvm/test/MC/AArch64/SVE2p1/tbxq-diagnostics.s
llvm/test/MC/AArch64/SVE2p1/tbxq.s
Modified:
llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
llvm/lib/Target/AArch64/SVEInstrFormats.td
Removed:
################################################################################
diff --git a/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td b/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
index 0abcbc3fb0a21..09ccb677ec02c 100644
--- a/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
+++ b/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
@@ -3554,7 +3554,7 @@ let Predicates = [HasSVE2] in {
let Predicates = [HasSVE2orSME] in {
// SVE2 table lookup (three sources)
defm TBL_ZZZZ : sve2_int_perm_tbl<"tbl", int_aarch64_sve_tbl2>;
- defm TBX_ZZZ : sve2_int_perm_tbx<"tbx", int_aarch64_sve_tbx>;
+ defm TBX_ZZZ : sve2_int_perm_tbx<"tbx", 0b01, int_aarch64_sve_tbx>;
// SVE2 integer compare scalar count and limit
defm WHILEGE_PWW : sve_int_while4_rr<0b000, "whilege", int_aarch64_sve_whilege>;
@@ -3793,4 +3793,6 @@ defm SMAXQV_VPZ : sve2p1_int_reduce_q<0b0100, "smaxqv">;
defm UMAXQV_VPZ : sve2p1_int_reduce_q<0b0101, "umaxqv">;
defm SMINQV_VPZ : sve2p1_int_reduce_q<0b0110, "sminqv">;
defm UMINQV_VPZ : sve2p1_int_reduce_q<0b0111, "uminqv">;
+
+defm TBXQ_ZZZ : sve2_int_perm_tbx<"tbxq", 0b10, null_frag>;
} // End HasSVE2p1_or_HasSME2p1
diff --git a/llvm/lib/Target/AArch64/SVEInstrFormats.td b/llvm/lib/Target/AArch64/SVEInstrFormats.td
index bf600f3d1982f..19b98357bf5e5 100644
--- a/llvm/lib/Target/AArch64/SVEInstrFormats.td
+++ b/llvm/lib/Target/AArch64/SVEInstrFormats.td
@@ -1355,7 +1355,7 @@ multiclass sve2_int_perm_tbl<string asm, SDPatternOperator op> {
nxv8i16:$Op3))>;
}
-class sve2_int_perm_tbx<bits<2> sz8_64, string asm, ZPRRegOp zprty>
+class sve2_int_perm_tbx<bits<2> sz8_64, bits<2> opc, string asm, ZPRRegOp zprty>
: I<(outs zprty:$Zd), (ins zprty:$_Zd, zprty:$Zn, zprty:$Zm),
asm, "\t$Zd, $Zn, $Zm",
"",
@@ -1367,18 +1367,20 @@ class sve2_int_perm_tbx<bits<2> sz8_64, string asm, ZPRRegOp zprty>
let Inst{23-22} = sz8_64;
let Inst{21} = 0b1;
let Inst{20-16} = Zm;
- let Inst{15-10} = 0b001011;
+ let Inst{15-13} = 0b001;
+ let Inst{12-11} = opc;
+ let Inst{10} = 0b1;
let Inst{9-5} = Zn;
let Inst{4-0} = Zd;
let Constraints = "$Zd = $_Zd";
}
-multiclass sve2_int_perm_tbx<string asm, SDPatternOperator op> {
- def _B : sve2_int_perm_tbx<0b00, asm, ZPR8>;
- def _H : sve2_int_perm_tbx<0b01, asm, ZPR16>;
- def _S : sve2_int_perm_tbx<0b10, asm, ZPR32>;
- def _D : sve2_int_perm_tbx<0b11, asm, ZPR64>;
+multiclass sve2_int_perm_tbx<string asm, bits<2> opc, SDPatternOperator op> {
+ def _B : sve2_int_perm_tbx<0b00, opc, asm, ZPR8>;
+ def _H : sve2_int_perm_tbx<0b01, opc, asm, ZPR16>;
+ def _S : sve2_int_perm_tbx<0b10, opc, asm, ZPR32>;
+ def _D : sve2_int_perm_tbx<0b11, opc, asm, ZPR64>;
def : SVE_3_Op_Pat<nxv16i8, op, nxv16i8, nxv16i8, nxv16i8, !cast<Instruction>(NAME # _B)>;
def : SVE_3_Op_Pat<nxv8i16, op, nxv8i16, nxv8i16, nxv8i16, !cast<Instruction>(NAME # _H)>;
diff --git a/llvm/test/MC/AArch64/SVE2p1/tbxq-diagnostics.s b/llvm/test/MC/AArch64/SVE2p1/tbxq-diagnostics.s
new file mode 100644
index 0000000000000..e3e7c53dae401
--- /dev/null
+++ b/llvm/test/MC/AArch64/SVE2p1/tbxq-diagnostics.s
@@ -0,0 +1,14 @@
+// RUN: not llvm-mc -triple=aarch64 -show-encoding -mattr=+sve2p1 2>&1 < %s | FileCheck %s
+
+// --------------------------------------------------------------------------//
+// Invalid vector suffix
+
+tbxq z0.b, z0.h, z0.h
+// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid
+// CHECK-NEXT: tbxq z0.b, z0.h, z0.h
+// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
+
+tbxq z23.d, z23.s, z13.s
+// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: invalid element width
+// CHECK-NEXT: tbxq z23.d, z23.s, z13.s
+// CHECK-NOT: [[@LINE-1]]:{{[0-9]+}}:
diff --git a/llvm/test/MC/AArch64/SVE2p1/tbxq.s b/llvm/test/MC/AArch64/SVE2p1/tbxq.s
new file mode 100644
index 0000000000000..b9a10a5dc24a9
--- /dev/null
+++ b/llvm/test/MC/AArch64/SVE2p1/tbxq.s
@@ -0,0 +1,115 @@
+// RUN: llvm-mc -triple=aarch64 -show-encoding -mattr=+sme2p1 < %s \
+// RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+// RUN: llvm-mc -triple=aarch64 -show-encoding -mattr=+sve2p1 < %s \
+// RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+// RUN: not llvm-mc -triple=aarch64 -show-encoding < %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-ERROR
+// RUN: llvm-mc -triple=aarch64 -filetype=obj -mattr=+sme2p1 < %s \
+// RUN: | llvm-objdump -d --no-print-imm-hex --mattr=+sme2p1 - | FileCheck %s --check-prefix=CHECK-INST
+// RUN: llvm-mc -triple=aarch64 -filetype=obj -mattr=+sme2p1 < %s \
+// RUN: | llvm-objdump -d --mattr=-sme2p1,-sve2p1 - | FileCheck %s --check-prefix=CHECK-UNKNOWN
+// RUN: llvm-mc -triple=aarch64 -show-encoding -mattr=+sme2p1 < %s \
+// RUN: | sed '/.text/d' | sed 's/.*encoding: //g' \
+// RUN: | llvm-mc -triple=aarch64 -mattr=+sme2p1 -disassemble -show-encoding \
+// RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+
+
+tbxq z0.h, z0.h, z0.h // 00000101-01100000-00110100-00000000
+// CHECK-INST: tbxq z0.h, z0.h, z0.h
+// CHECK-ENCODING: [0x00,0x34,0x60,0x05]
+// CHECK-ERROR: instruction requires: sme2p1 or sve2p1
+// CHECK-UNKNOWN: 05603400 <unknown>
+
+tbxq z21.h, z10.h, z21.h // 00000101-01110101-00110101-01010101
+// CHECK-INST: tbxq z21.h, z10.h, z21.h
+// CHECK-ENCODING: [0x55,0x35,0x75,0x05]
+// CHECK-ERROR: instruction requires: sme2p1 or sve2p1
+// CHECK-UNKNOWN: 05753555 <unknown>
+
+tbxq z23.h, z13.h, z8.h // 00000101-01101000-00110101-10110111
+// CHECK-INST: tbxq z23.h, z13.h, z8.h
+// CHECK-ENCODING: [0xb7,0x35,0x68,0x05]
+// CHECK-ERROR: instruction requires: sme2p1 or sve2p1
+// CHECK-UNKNOWN: 056835b7 <unknown>
+
+tbxq z31.h, z31.h, z31.h // 00000101-01111111-00110111-11111111
+// CHECK-INST: tbxq z31.h, z31.h, z31.h
+// CHECK-ENCODING: [0xff,0x37,0x7f,0x05]
+// CHECK-ERROR: instruction requires: sme2p1 or sve2p1
+// CHECK-UNKNOWN: 057f37ff <unknown>
+
+
+tbxq z0.s, z0.s, z0.s // 00000101-10100000-00110100-00000000
+// CHECK-INST: tbxq z0.s, z0.s, z0.s
+// CHECK-ENCODING: [0x00,0x34,0xa0,0x05]
+// CHECK-ERROR: instruction requires: sme2p1 or sve2p1
+// CHECK-UNKNOWN: 05a03400 <unknown>
+
+tbxq z21.s, z10.s, z21.s // 00000101-10110101-00110101-01010101
+// CHECK-INST: tbxq z21.s, z10.s, z21.s
+// CHECK-ENCODING: [0x55,0x35,0xb5,0x05]
+// CHECK-ERROR: instruction requires: sme2p1 or sve2p1
+// CHECK-UNKNOWN: 05b53555 <unknown>
+
+tbxq z23.s, z13.s, z8.s // 00000101-10101000-00110101-10110111
+// CHECK-INST: tbxq z23.s, z13.s, z8.s
+// CHECK-ENCODING: [0xb7,0x35,0xa8,0x05]
+// CHECK-ERROR: instruction requires: sme2p1 or sve2p1
+// CHECK-UNKNOWN: 05a835b7 <unknown>
+
+tbxq z31.s, z31.s, z31.s // 00000101-10111111-00110111-11111111
+// CHECK-INST: tbxq z31.s, z31.s, z31.s
+// CHECK-ENCODING: [0xff,0x37,0xbf,0x05]
+// CHECK-ERROR: instruction requires: sme2p1 or sve2p1
+// CHECK-UNKNOWN: 05bf37ff <unknown>
+
+
+tbxq z0.d, z0.d, z0.d // 00000101-11100000-00110100-00000000
+// CHECK-INST: tbxq z0.d, z0.d, z0.d
+// CHECK-ENCODING: [0x00,0x34,0xe0,0x05]
+// CHECK-ERROR: instruction requires: sme2p1 or sve2p1
+// CHECK-UNKNOWN: 05e03400 <unknown>
+
+tbxq z21.d, z10.d, z21.d // 00000101-11110101-00110101-01010101
+// CHECK-INST: tbxq z21.d, z10.d, z21.d
+// CHECK-ENCODING: [0x55,0x35,0xf5,0x05]
+// CHECK-ERROR: instruction requires: sme2p1 or sve2p1
+// CHECK-UNKNOWN: 05f53555 <unknown>
+
+tbxq z23.d, z13.d, z8.d // 00000101-11101000-00110101-10110111
+// CHECK-INST: tbxq z23.d, z13.d, z8.d
+// CHECK-ENCODING: [0xb7,0x35,0xe8,0x05]
+// CHECK-ERROR: instruction requires: sme2p1 or sve2p1
+// CHECK-UNKNOWN: 05e835b7 <unknown>
+
+tbxq z31.d, z31.d, z31.d // 00000101-11111111-00110111-11111111
+// CHECK-INST: tbxq z31.d, z31.d, z31.d
+// CHECK-ENCODING: [0xff,0x37,0xff,0x05]
+// CHECK-ERROR: instruction requires: sme2p1 or sve2p1
+// CHECK-UNKNOWN: 05ff37ff <unknown>
+
+
+tbxq z0.b, z0.b, z0.b // 00000101-00100000-00110100-00000000
+// CHECK-INST: tbxq z0.b, z0.b, z0.b
+// CHECK-ENCODING: [0x00,0x34,0x20,0x05]
+// CHECK-ERROR: instruction requires: sme2p1 or sve2p1
+// CHECK-UNKNOWN: 05203400 <unknown>
+
+tbxq z21.b, z10.b, z21.b // 00000101-00110101-00110101-01010101
+// CHECK-INST: tbxq z21.b, z10.b, z21.b
+// CHECK-ENCODING: [0x55,0x35,0x35,0x05]
+// CHECK-ERROR: instruction requires: sme2p1 or sve2p1
+// CHECK-UNKNOWN: 05353555 <unknown>
+
+tbxq z23.b, z13.b, z8.b // 00000101-00101000-00110101-10110111
+// CHECK-INST: tbxq z23.b, z13.b, z8.b
+// CHECK-ENCODING: [0xb7,0x35,0x28,0x05]
+// CHECK-ERROR: instruction requires: sme2p1 or sve2p1
+// CHECK-UNKNOWN: 052835b7 <unknown>
+
+tbxq z31.b, z31.b, z31.b // 00000101-00111111-00110111-11111111
+// CHECK-INST: tbxq z31.b, z31.b, z31.b
+// CHECK-ENCODING: [0xff,0x37,0x3f,0x05]
+// CHECK-ERROR: instruction requires: sme2p1 or sve2p1
+// CHECK-UNKNOWN: 053f37ff <unknown>
+
More information about the llvm-commits
mailing list