Skip to content

Commit eb77061

Browse files
authored
[RISCV] Add assembler support for Zvqdotq. (#132118)
Based on the 0.0.1 spec here https://github.com/riscv/riscv-dot-product/releases/tag/v0.0.1
1 parent cebc4a1 commit eb77061

File tree

12 files changed

+165
-1
lines changed

12 files changed

+165
-1
lines changed

clang/test/Driver/print-supported-extensions-riscv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@
190190
// CHECK-NEXT: zalasr 0.1 'Zalasr' (Load-Acquire and Store-Release Instructions)
191191
// CHECK-NEXT: zvbc32e 0.7 'Zvbc32e' (Vector Carryless Multiplication with 32-bits elements)
192192
// CHECK-NEXT: zvkgs 0.7 'Zvkgs' (Vector-Scalar GCM instructions for Cryptography)
193+
// CHECK-NEXT: zvqdotq 0.0 'Zvqdotq' (Vector quad widening 4D Dot Product)
193194
// CHECK-NEXT: sdext 1.0 'Sdext' (External debugger)
194195
// CHECK-NEXT: sdtrig 1.0 'Sdtrig' (Debugger triggers)
195196
// CHECK-NEXT: smctr 1.0 'Smctr' (Control Transfer Records Machine Level)

clang/test/Preprocessor/riscv-target-features.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@
202202
// CHECK-NOT: __riscv_zvfbfmin {{.*$}}
203203
// CHECK-NOT: __riscv_zvfbfwma {{.*$}}
204204
// CHECK-NOT: __riscv_zvkgs {{.*$}}
205+
// CHECK-NOT: __riscv_zvqdotq {{.*$}}
205206

206207
// RUN: %clang --target=riscv32-unknown-linux-gnu \
207208
// RUN: -march=rv32ia -E -dM %s \
@@ -1761,6 +1762,14 @@
17611762
// RUN: -o - | FileCheck --check-prefix=CHECK-ZVKGS-EXT %s
17621763
// CHECK-ZVKGS-EXT: __riscv_zvkgs 7000{{$}}
17631764

1765+
// RUN: %clang --target=riscv32 -menable-experimental-extensions \
1766+
// RUN: -march=rv32i_zve32x_zvqdotq0p0 -E -dM %s \
1767+
// RUN: -o - | FileCheck --check-prefix=CHECK-ZVqdotq-EXT %s
1768+
// RUN: %clang --target=riscv64 -menable-experimental-extensions \
1769+
// RUN: -march=rv64i_zve32x_zvqdotq0p0 -E -dM %s \
1770+
// RUN: -o - | FileCheck --check-prefix=CHECK-ZVqdotq-EXT %s
1771+
// CHECK-ZVqdotq-EXT: __riscv_zvqdotq 0{{$}}
1772+
17641773
// RUN: %clang -target riscv32 -menable-experimental-extensions \
17651774
// RUN: -march=rv32izicfiss1p0 -E -dM %s \
17661775
// RUN: -o - | FileCheck --check-prefix=CHECK-ZICFISS-EXT %s

llvm/docs/RISCVUsage.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,9 @@ The primary goal of experimental support is to assist in the process of ratifica
337337
``experimental-svukte``
338338
LLVM implements the `0.3 draft specification <https://github.com/riscv/riscv-isa-manual/pull/1564>`__.
339339

340+
``experimental-zvqdotq``
341+
LLVM implements the `0.0.1 draft specification <https://github.com/riscv/riscv-dot-product/releases/tag/v0.0.1>`__.
342+
340343
To use an experimental extension from `clang`, you must add `-menable-experimental-extensions` to the command line, and specify the exact version of the experimental extension you are using. To use an experimental extension with LLVM's internal developer tools (e.g. `llc`, `llvm-objdump`, `llvm-mc`), you must prefix the extension name with `experimental-`. Note that you don't need to specify the version with internal tools, and shouldn't include the `experimental-` prefix with `clang`.
341344

342345
Vendor Extensions

llvm/docs/ReleaseNotes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ Changes to the RISC-V Backend
134134
extension.
135135
* Adds assembler support for the 'Zclsd` (Compressed Load/Store Pair Instructions)
136136
extension.
137+
* Adds experimental assembler support for Zvqdotq.
137138

138139
Changes to the WebAssembly Backend
139140
----------------------------------

llvm/lib/Target/RISCV/RISCVFeatures.td

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,16 @@ def FeatureStdExtZvksc
820820
def FeatureStdExtZvksg
821821
: RISCVExtension<1, 0, "shorthand for 'Zvks' and 'Zvkg'",
822822
[FeatureStdExtZvks, FeatureStdExtZvkg]>;
823+
824+
// Vector quad widening dot product
825+
826+
def FeatureStdExtZvqdotq
827+
: RISCVExperimentalExtension<0, 0, "Vector quad widening 4D Dot Product",
828+
[FeatureStdExtZve32x]>;
829+
def HasStdExtZvqdotq : Predicate<"Subtarget->hasStdExtZvqdotq()">,
830+
AssemblerPredicate<(all_of FeatureStdExtZvqdotq),
831+
"'Zvqdotq' (Vector quad widening 4D Dot Product)">;
832+
823833
// Vector instruction predicates
824834

825835
def HasVInstructions : Predicate<"Subtarget->hasVInstructions()">,

llvm/lib/Target/RISCV/RISCVInstrInfo.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,6 +2138,7 @@ include "RISCVInstrInfoZk.td"
21382138
// Vector
21392139
include "RISCVInstrInfoV.td"
21402140
include "RISCVInstrInfoZvk.td"
2141+
include "RISCVInstrInfoZvqdotq.td"
21412142

21422143
// Integer
21432144
include "RISCVInstrInfoZimop.td"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//===-- RISCVInstrInfoZvqdot.td - 'Zvqdotq' instructions ---*- tablegen -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file describes the RISC-V instructions from the standard 'Zvqdotq'
10+
// extension.
11+
// This version is still experimental as the 'Zvqdotq' extension hasn't been
12+
// ratified yet.
13+
//
14+
//===----------------------------------------------------------------------===//
15+
16+
//===----------------------------------------------------------------------===//
17+
// Instructions
18+
//===----------------------------------------------------------------------===//
19+
20+
let Predicates = [HasStdExtZvqdotq] in {
21+
def VQDOT_VV : VALUVV<0b101100, OPMVV, "vqdot.vv">;
22+
def VQDOT_VX : VALUVX<0b101100, OPMVX, "vqdot.vx">;
23+
def VQDOTU_VV : VALUVV<0b101000, OPMVV, "vqdotu.vv">;
24+
def VQDOTU_VX : VALUVX<0b101000, OPMVX, "vqdotu.vx">;
25+
def VQDOTSU_VV : VALUVV<0b101010, OPMVV, "vqdotsu.vv">;
26+
def VQDOTSU_VX : VALUVX<0b101010, OPMVX, "vqdotsu.vx">;
27+
def VQDOTUS_VX : VALUVX<0b101110, OPMVX, "vqdotus.vx">;
28+
} // Predicates = [HasStdExtZvqdotq]

llvm/test/CodeGen/RISCV/attributes.ll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@
127127
; RUN: llc -mtriple=riscv32 -mattr=+zve64x -mattr=+zvksg %s -o - | FileCheck --check-prefix=RV32ZVKSG %s
128128
; RUN: llc -mtriple=riscv32 -mattr=+zve32x -mattr=+zvksh %s -o - | FileCheck --check-prefix=RV32ZVKSH %s
129129
; RUN: llc -mtriple=riscv32 -mattr=+zve32x -mattr=+zvkt %s -o - | FileCheck --check-prefix=RV32ZVKT %s
130+
; RUN: llc -mtriple=riscv32 -mattr=+zve32x -mattr=+experimental-zvqdotq %s -o - | FileCheck --check-prefix=RV32ZVQDOTQ %s
130131
; RUN: llc -mtriple=riscv32 -mattr=+zvfh %s -o - | FileCheck --check-prefix=RV32ZVFH %s
131132
; RUN: llc -mtriple=riscv32 -mattr=+zicond %s -o - | FileCheck --check-prefix=RV32ZICOND %s
132133
; RUN: llc -mtriple=riscv32 -mattr=+zilsd %s -o - | FileCheck --check-prefix=RV32ZILSD %s
@@ -279,6 +280,7 @@
279280
; RUN: llc -mtriple=riscv64 -mattr=+zve32x -mattr=+zvksg %s -o - | FileCheck --check-prefix=RV64ZVKSG %s
280281
; RUN: llc -mtriple=riscv64 -mattr=+zve32x -mattr=+zvksh %s -o - | FileCheck --check-prefix=RV64ZVKSH %s
281282
; RUN: llc -mtriple=riscv64 -mattr=+zve32x -mattr=+zvkt %s -o - | FileCheck --check-prefix=RV64ZVKT %s
283+
; RUN: llc -mtriple=riscv64 -mattr=+zve32x -mattr=+experimental-zvqdotq %s -o - | FileCheck --check-prefix=RV64ZVQDOTQ %s
282284
; RUN: llc -mtriple=riscv64 -mattr=+zvfh %s -o - | FileCheck --check-prefix=RV64ZVFH %s
283285
; RUN: llc -mtriple=riscv64 -mattr=+zicond %s -o - | FileCheck --check-prefix=RV64ZICOND %s
284286
; RUN: llc -mtriple=riscv64 -mattr=+zimop %s -o - | FileCheck --check-prefix=RV64ZIMOP %s
@@ -455,6 +457,7 @@
455457
; RV32ZVKSG: .attribute 5, "rv32i2p1_zicsr2p0_zve32x1p0_zve64x1p0_zvkb1p0_zvkg1p0_zvks1p0_zvksed1p0_zvksg1p0_zvksh1p0_zvkt1p0_zvl32b1p0_zvl64b1p0"
456458
; RV32ZVKSH: .attribute 5, "rv32i2p1_zicsr2p0_zve32x1p0_zvksh1p0_zvl32b1p0"
457459
; RV32ZVKT: .attribute 5, "rv32i2p1_zicsr2p0_zve32x1p0_zvkt1p0_zvl32b1p0"
460+
; RV32ZVQDOTQ: .attribute 5, "rv32i2p1_zicsr2p0_zve32x1p0_zvl32b1p0_zvqdotq0p0"
458461
; RV32ZVFH: .attribute 5, "rv32i2p1_f2p2_zicsr2p0_zfhmin1p0_zve32f1p0_zve32x1p0_zvfh1p0_zvfhmin1p0_zvl32b1p0"
459462
; RV32ZICOND: .attribute 5, "rv32i2p1_zicond1p0"
460463
; RV32ZILSD: .attribute 5, "rv32i2p1_zilsd1p0"
@@ -604,6 +607,7 @@
604607
; RV64ZVKSG: .attribute 5, "rv64i2p1_zicsr2p0_zve32x1p0_zvkb1p0_zvkg1p0_zvks1p0_zvksed1p0_zvksg1p0_zvksh1p0_zvkt1p0_zvl32b1p0"
605608
; RV64ZVKSH: .attribute 5, "rv64i2p1_zicsr2p0_zve32x1p0_zvksh1p0_zvl32b1p0"
606609
; RV64ZVKT: .attribute 5, "rv64i2p1_zicsr2p0_zve32x1p0_zvkt1p0_zvl32b1p0"
610+
; RV64ZVQDOTQ: .attribute 5, "rv64i2p1_zicsr2p0_zve32x1p0_zvl32b1p0_zvqdotq0p0"
607611
; RV64ZVFH: .attribute 5, "rv64i2p1_f2p2_zicsr2p0_zfhmin1p0_zve32f1p0_zve32x1p0_zvfh1p0_zvfhmin1p0_zvl32b1p0"
608612
; RV64ZICOND: .attribute 5, "rv64i2p1_zicond1p0"
609613
; RV64ZIMOP: .attribute 5, "rv64i2p1_zimop1p0"

llvm/test/MC/RISCV/attribute-arch.s

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@
174174
.attribute arch, "rv32i_zvkt1p0"
175175
# CHECK: attribute 5, "rv32i2p1_zvkt1p0"
176176

177+
.attribute arch, "rv32i_zvqdotq0p0"
178+
# CHECK: attribute 5, "rv32i2p1_zicsr2p0_zve32x1p0_zvl32b1p0_zvqdotq0p0"
179+
177180
.attribute arch, "rv32izbs1p0"
178181
# CHECK: attribute 5, "rv32i2p1_zbs1p0"
179182

@@ -484,4 +487,4 @@
484487
# CHECK: attribute 5, "rv32i2p1_p0p14"
485488

486489
.attribute arch, "rv64i_p0p14"
487-
# CHECK: attribute 5, "rv64i2p1_p0p14"
490+
# CHECK: attribute 5, "rv64i2p1_p0p14"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# RUN: not llvm-mc -triple=riscv64 --mattr=+experimental-zvqdotq %s 2>&1 \
2+
# RUN: | FileCheck %s --check-prefix=CHECK-ERROR
3+
4+
vqdot.vv v0, v2, v4, v0.t
5+
# CHECK-ERROR: the destination vector register group cannot overlap the mask register
6+
# CHECK-ERROR-LABEL: vqdot.vv v0, v2, v4, v0.t
7+
8+
vqdot.vx v0, v2, a0, v0.t
9+
# CHECK-ERROR: the destination vector register group cannot overlap the mask register
10+
# CHECK-ERROR-LABEL: vqdot.vx v0, v2, a0, v0.t

llvm/test/MC/RISCV/rvv/zvqdotq.s

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+experimental-zvqdotq %s \
2+
# RUN: | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
3+
# RUN: not llvm-mc -triple=riscv64 -show-encoding %s 2>&1 \
4+
# RUN: | FileCheck %s --check-prefix=CHECK-ERROR
5+
# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-zvqdotq %s \
6+
# RUN: | llvm-objdump -d --mattr=+experimental-zvqdotq - \
7+
# RUN: | FileCheck %s --check-prefix=CHECK-INST
8+
# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+experimental-zvqdotq %s \
9+
# RUN: | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN
10+
11+
vqdot.vv v8, v4, v20, v0.t
12+
# CHECK-INST: vqdot.vv v8, v4, v20, v0.t
13+
# CHECK-ENCODING: [0x57,0x24,0x4a,0xb0]
14+
# CHECK-ERROR: instruction requires the following: 'Zvqdotq' (Vector quad widening 4D Dot Product){{$}}
15+
# CHECK-UNKNOWN: b04a2457 <unknown>
16+
17+
vqdot.vv v8, v4, v20
18+
# CHECK-INST: vqdot.vv v8, v4, v20
19+
# CHECK-ENCODING: [0x57,0x24,0x4a,0xb2]
20+
# CHECK-ERROR: instruction requires the following: 'Zvqdotq' (Vector quad widening 4D Dot Product){{$}}
21+
# CHECK-UNKNOWN: b24a2457 <unknown>
22+
23+
vqdotu.vv v8, v4, v20, v0.t
24+
# CHECK-INST: vqdotu.vv v8, v4, v20, v0.t
25+
# CHECK-ENCODING: [0x57,0x24,0x4a,0xa0]
26+
# CHECK-ERROR: instruction requires the following: 'Zvqdotq' (Vector quad widening 4D Dot Product){{$}}
27+
# CHECK-UNKNOWN: a04a2457 <unknown>
28+
29+
vqdotu.vv v8, v4, v20
30+
# CHECK-INST: vqdotu.vv v8, v4, v20
31+
# CHECK-ENCODING: [0x57,0x24,0x4a,0xa2]
32+
# CHECK-ERROR: instruction requires the following: 'Zvqdotq' (Vector quad widening 4D Dot Product){{$}}
33+
# CHECK-UNKNOWN: a24a2457 <unknown>
34+
35+
vqdotsu.vv v8, v4, v20, v0.t
36+
# CHECK-INST: vqdotsu.vv v8, v4, v20, v0.t
37+
# CHECK-ENCODING: [0x57,0x24,0x4a,0xa8]
38+
# CHECK-ERROR: instruction requires the following: 'Zvqdotq' (Vector quad widening 4D Dot Product){{$}}
39+
# CHECK-UNKNOWN: a84a2457 <unknown>
40+
41+
vqdotsu.vv v8, v4, v20
42+
# CHECK-INST: vqdotsu.vv v8, v4, v20
43+
# CHECK-ENCODING: [0x57,0x24,0x4a,0xaa]
44+
# CHECK-ERROR: instruction requires the following: 'Zvqdotq' (Vector quad widening 4D Dot Product){{$}}
45+
# CHECK-UNKNOWN: aa4a2457 <unknown>
46+
47+
vqdot.vx v8, v4, s4, v0.t
48+
# CHECK-INST: vqdot.vx v8, v4, s4, v0.t
49+
# CHECK-ENCODING: [0x57,0x64,0x4a,0xb0]
50+
# CHECK-ERROR: instruction requires the following: 'Zvqdotq' (Vector quad widening 4D Dot Product){{$}}
51+
# CHECK-UNKNOWN: b04a6457 <unknown>
52+
53+
vqdot.vx v8, v4, s4
54+
# CHECK-INST: vqdot.vx v8, v4, s4
55+
# CHECK-ENCODING: [0x57,0x64,0x4a,0xb2]
56+
# CHECK-ERROR: instruction requires the following: 'Zvqdotq' (Vector quad widening 4D Dot Product){{$}}
57+
# CHECK-UNKNOWN: b24a6457 <unknown>
58+
59+
vqdotu.vx v8, v4, s4, v0.t
60+
# CHECK-INST: vqdotu.vx v8, v4, s4, v0.t
61+
# CHECK-ENCODING: [0x57,0x64,0x4a,0xa0]
62+
# CHECK-ERROR: instruction requires the following: 'Zvqdotq' (Vector quad widening 4D Dot Product){{$}}
63+
# CHECK-UNKNOWN: a04a6457 <unknown>
64+
65+
vqdotu.vx v8, v4, s4
66+
# CHECK-INST: vqdotu.vx v8, v4, s4
67+
# CHECK-ENCODING: [0x57,0x64,0x4a,0xa2]
68+
# CHECK-ERROR: instruction requires the following: 'Zvqdotq' (Vector quad widening 4D Dot Product){{$}}
69+
# CHECK-UNKNOWN: a24a6457 <unknown>
70+
71+
vqdotsu.vx v8, v4, s4, v0.t
72+
# CHECK-INST: vqdotsu.vx v8, v4, s4, v0.t
73+
# CHECK-ENCODING: [0x57,0x64,0x4a,0xa8]
74+
# CHECK-ERROR: instruction requires the following: 'Zvqdotq' (Vector quad widening 4D Dot Product){{$}}
75+
# CHECK-UNKNOWN: a84a6457 <unknown>
76+
77+
vqdotsu.vx v8, v4, s4
78+
# CHECK-INST: vqdotsu.vx v8, v4, s4
79+
# CHECK-ENCODING: [0x57,0x64,0x4a,0xaa]
80+
# CHECK-ERROR: instruction requires the following: 'Zvqdotq' (Vector quad widening 4D Dot Product){{$}}
81+
# CHECK-UNKNOWN: aa4a6457 <unknown>
82+
83+
vqdotus.vx v8, v4, s4, v0.t
84+
# CHECK-INST: vqdotus.vx v8, v4, s4, v0.t
85+
# CHECK-ENCODING: [0x57,0x64,0x4a,0xb8]
86+
# CHECK-ERROR: instruction requires the following: 'Zvqdotq' (Vector quad widening 4D Dot Product){{$}}
87+
# CHECK-UNKNOWN: b84a6457 <unknown>
88+
89+
vqdotus.vx v8, v4, s4
90+
# CHECK-INST: vqdotus.vx v8, v4, s4
91+
# CHECK-ENCODING: [0x57,0x64,0x4a,0xba]
92+
# CHECK-ERROR: instruction requires the following: 'Zvqdotq' (Vector quad widening 4D Dot Product){{$}}
93+
# CHECK-UNKNOWN: ba4a6457 <unknown>

llvm/unittests/TargetParser/RISCVISAInfoTest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,7 @@ Experimental extensions
11361136
zalasr 0.1
11371137
zvbc32e 0.7
11381138
zvkgs 0.7
1139+
zvqdotq 0.0
11391140
sdext 1.0
11401141
sdtrig 1.0
11411142
smctr 1.0

0 commit comments

Comments
 (0)