Skip to content

Commit 2a8960e

Browse files
authored
[RISCV] Add Andes XAndesVDot (Andes Vector Dot Product) extension. (#139849)
The spec can be found at: https://github.com/andestech/andes-v5-isa/releases/tag/ast-v5_4_0-release. This patch only supports assembler. Intrinsics support will be added in a later patch.
1 parent 520773b commit 2a8960e

File tree

10 files changed

+105
-1
lines changed

10 files changed

+105
-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
@@ -157,6 +157,7 @@
157157
// CHECK-NEXT: svpbmt 1.0 'Svpbmt' (Page-Based Memory Types)
158158
// CHECK-NEXT: svvptc 1.0 'Svvptc' (Obviating Memory-Management Instructions after Marking PTEs Valid)
159159
// CHECK-NEXT: xandesperf 5.0 'XAndesPerf' (Andes Performance Extension)
160+
// CHECK-NEXT: xandesvdot 5.0 'XAndesVDot' (Andes Vector Dot Product Extension)
160161
// CHECK-NEXT: xandesvpackfph 5.0 'XAndesVPackFPH' (Andes Vector Packed FP16 Extension)
161162
// CHECK-NEXT: xcvalu 1.0 'XCValu' (CORE-V ALU Operations)
162163
// CHECK-NEXT: xcvbi 1.0 'XCVbi' (CORE-V Immediate Branching)

llvm/docs/RISCVUsage.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,9 @@ The current vendor extensions supported are:
511511
``XAndesVPackFPH``
512512
LLVM implements `version 5.0.0 of the Andes Vector Packed FP16 Extension specification <https://github.com/andestech/andes-v5-isa/releases/download/ast-v5_4_0-release/AndeStar_V5_ISA_Spec_UM165-v1.5.08-20250317.pdf>`__ by Andes Technology. All instructions are prefixed with `nds.` as described in the specification.
513513

514+
``XAndesVDot``
515+
LLVM implements `version 5.0.0 of the Andes Vector Dot Product Extension specification <https://github.com/andestech/andes-v5-isa/releases/download/ast-v5_4_0-release/AndeStar_V5_ISA_Spec_UM165-v1.5.08-20250317.pdf>`__ by Andes Technology. All instructions are prefixed with `nds.` as described in the specification.
516+
514517
Experimental C Intrinsics
515518
=========================
516519

llvm/docs/ReleaseNotes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ Changes to the RISC-V Backend
186186
* Adds assembler support for the Andes `XAndesperf` (Andes Performance extension).
187187
* `-mcpu=sifive-p870` was added.
188188
* Adds assembler support for the Andes `XAndesvpackfph` (Andes Vector Packed FP16 extension).
189+
* Adds assembler support for the Andes `XAndesvdot` (Andes Vector Dot Product extension).
189190

190191
Changes to the WebAssembly Backend
191192
----------------------------------

llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,8 @@ static constexpr FeatureBitset XTHeadGroup = {
728728
RISCV::FeatureVendorXTHeadVdot};
729729

730730
static constexpr FeatureBitset XAndesGroup = {
731-
RISCV::FeatureVendorXAndesPerf, RISCV::FeatureVendorXAndesVPackFPH};
731+
RISCV::FeatureVendorXAndesPerf, RISCV::FeatureVendorXAndesVPackFPH,
732+
RISCV::FeatureVendorXAndesVDot};
732733

733734
static constexpr DecoderListEntry DecoderList32[]{
734735
// Vendor Extensions

llvm/lib/Target/RISCV/RISCVFeatures.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,6 +1526,14 @@ def HasVendorXAndesVPackFPH
15261526
AssemblerPredicate<(all_of FeatureVendorXAndesVPackFPH),
15271527
"'XAndesVPackFPH' (Andes Vector Packed FP16 Extension)">;
15281528

1529+
def FeatureVendorXAndesVDot
1530+
: RISCVExtension<5, 0, "Andes Vector Dot Product Extension",
1531+
[FeatureStdExtZve32x]>;
1532+
def HasVendorXAndesVDot
1533+
: Predicate<"Subtarget->hasVendorXAndesVDot()">,
1534+
AssemblerPredicate<(all_of FeatureVendorXAndesVDot),
1535+
"'XAndesVDot' (Andes Vector Dot Product Extension)">;
1536+
15291537
//===----------------------------------------------------------------------===//
15301538
// LLVM specific features and extensions
15311539
//===----------------------------------------------------------------------===//

llvm/lib/Target/RISCV/RISCVInstrInfoXAndes.td

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,29 @@ class NDSRVInstVFPMAD<bits<6> funct6, string opcodestr>
338338
let RVVConstraint = VMConstraint;
339339
}
340340

341+
class NDSRVInstVD4DOT<bits<6> funct6, string opcodestr>
342+
: RVInst<(outs VR:$vd), (ins VR:$vs1, VR:$vs2, VMaskOp:$vm),
343+
opcodestr # "." # "vv", "$vd, $vs1, $vs2$vm", [], InstFormatR>,
344+
SchedBinaryMC<"WriteVIMulAddV", "ReadVIMulAddV", "ReadVIMulAddV"> {
345+
bits<5> vs2;
346+
bits<5> vs1;
347+
bits<5> vd;
348+
bit vm;
349+
350+
let Inst{31-26} = funct6;
351+
let Inst{25} = vm;
352+
let Inst{24-20} = vs2;
353+
let Inst{19-15} = vs1;
354+
let Inst{14-12} = 0b100;
355+
let Inst{11-7} = vd;
356+
let Inst{6-0} = OPC_CUSTOM_2.Value;
357+
let hasSideEffects = 0;
358+
let mayLoad = 0;
359+
let mayStore = 0;
360+
361+
let RVVConstraint = VMConstraint;
362+
}
363+
341364
//===----------------------------------------------------------------------===//
342365
// XAndesPerf
343366
//===----------------------------------------------------------------------===//
@@ -398,6 +421,16 @@ let Predicates = [HasVendorXAndesVPackFPH],
398421
def NDS_VFPMADT_VF : NDSRVInstVFPMAD<0b000010, "nds.vfpmadt">;
399422
def NDS_VFPMADB_VF : NDSRVInstVFPMAD<0b000011, "nds.vfpmadb">;
400423
}
424+
425+
//===----------------------------------------------------------------------===//
426+
// XAndesVDot
427+
//===----------------------------------------------------------------------===//
428+
429+
let Predicates = [HasVendorXAndesVDot], Uses = [VL, VTYPE] in {
430+
def NDS_VD4DOTS_VV : NDSRVInstVD4DOT<0b000100, "nds.vd4dots">;
431+
def NDS_VD4DOTU_VV : NDSRVInstVD4DOT<0b000111, "nds.vd4dotu">;
432+
def NDS_VD4DOTSU_VV : NDSRVInstVD4DOT<0b000101, "nds.vd4dotsu">;
433+
}
401434
} // DecoderNamespace = "XAndes"
402435

403436
// Patterns

llvm/test/CodeGen/RISCV/attributes.ll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
; RUN: llc -mtriple=riscv32 -mattr=+experimental-xqcisls %s -o - | FileCheck --check-prefix=RV32XQCISLS %s
105105
; RUN: llc -mtriple=riscv32 -mattr=+experimental-xqcisync %s -o - | FileCheck --check-prefix=RV32XQCISYNC %s
106106
; RUN: llc -mtriple=riscv32 -mattr=+xandesperf %s -o - | FileCheck --check-prefix=RV32XANDESPERF %s
107+
; RUN: llc -mtriple=riscv32 -mattr=+xandesvdot %s -o - | FileCheck --check-prefix=RV32XANDESVDOT %s
107108
; RUN: llc -mtriple=riscv32 -mattr=+xandesvpackfph %s -o - | FileCheck --check-prefix=RV32XANDESVPACKFPH %s
108109
; RUN: llc -mtriple=riscv32 -mattr=+zaamo %s -o - | FileCheck --check-prefix=RV32ZAAMO %s
109110
; RUN: llc -mtriple=riscv32 -mattr=+zalrsc %s -o - | FileCheck --check-prefix=RV32ZALRSC %s
@@ -255,6 +256,7 @@
255256
; RUN: llc -mtriple=riscv64 -mattr=+xtheadsync %s -o - | FileCheck --check-prefix=RV64XTHEADSYNC %s
256257
; RUN: llc -mtriple=riscv64 -mattr=+xtheadvdot %s -o - | FileCheck --check-prefixes=CHECK,RV64XTHEADVDOT %s
257258
; RUN: llc -mtriple=riscv64 -mattr=+xandesperf %s -o - | FileCheck --check-prefix=RV64XANDESPERF %s
259+
; RUN: llc -mtriple=riscv64 -mattr=+xandesvdot %s -o - | FileCheck --check-prefix=RV64XANDESVDOT %s
258260
; RUN: llc -mtriple=riscv64 -mattr=+xandesvpackfph %s -o - | FileCheck --check-prefix=RV64XANDESVPACKFPH %s
259261
; RUN: llc -mtriple=riscv64 -mattr=+za64rs %s -o - | FileCheck --check-prefixes=CHECK,RV64ZA64RS %s
260262
; RUN: llc -mtriple=riscv64 -mattr=+za128rs %s -o - | FileCheck --check-prefixes=CHECK,RV64ZA128RS %s
@@ -449,6 +451,7 @@
449451
; RV32XQCISLS: .attribute 5, "rv32i2p1_xqcisls0p2"
450452
; RV32XQCISYNC: attribute 5, "rv32i2p1_zca1p0_xqcisync0p3"
451453
; RV32XANDESPERF: .attribute 5, "rv32i2p1_xandesperf5p0"
454+
; RV32XANDESVDOT: .attribute 5, "rv32i2p1_zicsr2p0_zve32x1p0_zvl32b1p0_xandesvdot5p0"
452455
; RV32XANDESVPACKFPH: .attribute 5, "rv32i2p1_f2p2_zicsr2p0_zve32f1p0_zve32x1p0_zvfhmin1p0_zvl32b1p0_xandesvpackfph5p0"
453456
; RV32ZAAMO: .attribute 5, "rv32i2p1_zaamo1p0"
454457
; RV32ZALRSC: .attribute 5, "rv32i2p1_zalrsc1p0"
@@ -601,6 +604,7 @@
601604
; RV64XTHEADSYNC: .attribute 5, "rv64i2p1_xtheadsync1p0"
602605
; RV64XTHEADVDOT: .attribute 5, "rv64i2p1_f2p2_d2p2_v1p0_zicsr2p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0_xtheadvdot1p0"
603606
; RV64XANDESPERF: .attribute 5, "rv64i2p1_xandesperf5p0"
607+
; RV64XANDESVDOT: .attribute 5, "rv64i2p1_zicsr2p0_zve32x1p0_zvl32b1p0_xandesvdot5p0"
604608
; RV64XANDESVPACKFPH: .attribute 5, "rv64i2p1_f2p2_zicsr2p0_zve32f1p0_zve32x1p0_zvfhmin1p0_zvl32b1p0_xandesvpackfph5p0"
605609
; RV64ZTSO: .attribute 5, "rv64i2p1_ztso1p0"
606610
; RV64ZAAMO: .attribute 5, "rv64i2p1_zaamo1p0"

llvm/test/CodeGen/RISCV/features-info.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@
171171
; CHECK-NEXT: ventana-veyron - Ventana Veyron-Series processors.
172172
; CHECK-NEXT: vxrm-pipeline-flush - VXRM writes causes pipeline flush.
173173
; CHECK-NEXT: xandesperf - 'XAndesPerf' (Andes Performance Extension).
174+
; CHECK-NEXT: xandesvdot - 'XAndesVDot' (Andes Vector Dot Product Extension).
174175
; CHECK-NEXT: xandesvpackfph - 'XAndesVPackFPH' (Andes Vector Packed FP16 Extension).
175176
; CHECK-NEXT: xcvalu - 'XCValu' (CORE-V ALU Operations).
176177
; CHECK-NEXT: xcvbi - 'XCVbi' (CORE-V Immediate Branching).

llvm/test/MC/RISCV/xandesvdot-valid.s

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# XAndesVDot - Andes Vector Dot Product Extension
2+
# RUN: llvm-mc %s -triple=riscv32 -mattr=+xandesvdot -show-encoding \
3+
# RUN: | FileCheck -check-prefixes=CHECK-ASM %s
4+
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+xandesvdot < %s \
5+
# RUN: | llvm-objdump --mattr=+xandesvdot -M no-aliases -d -r - \
6+
# RUN: | FileCheck -check-prefixes=CHECK-OBJ %s
7+
# RUN: not llvm-mc -triple=riscv32 -show-encoding %s 2>&1 \
8+
# RUN: | FileCheck %s --check-prefix=CHECK-ERROR
9+
# RUN: llvm-mc %s -triple=riscv64 -mattr=+xandesvdot -show-encoding \
10+
# RUN: | FileCheck -check-prefixes=CHECK-ASM %s
11+
# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+xandesvdot < %s \
12+
# RUN: | llvm-objdump --mattr=+xandesvdot -M no-aliases -d -r - \
13+
# RUN: | FileCheck -check-prefixes=CHECK-OBJ %s
14+
# RUN: not llvm-mc -triple=riscv64 -show-encoding %s 2>&1 \
15+
# RUN: | FileCheck %s --check-prefix=CHECK-ERROR
16+
17+
# CHECK-OBJ: nds.vd4dots.vv v8, v10, v12
18+
# CHECK-ASM: nds.vd4dots.vv v8, v10, v12
19+
# CHECK-ASM: encoding: [0x5b,0x44,0xc5,0x12]
20+
# CHECK-ERROR: instruction requires the following: 'XAndesVDot' (Andes Vector Dot Product Extension){{$}}
21+
nds.vd4dots.vv v8, v10, v12
22+
23+
# CHECK-OBJ: nds.vd4dots.vv v8, v10, v12, v0.t
24+
# CHECK-ASM: nds.vd4dots.vv v8, v10, v12, v0.t
25+
# CHECK-ASM: encoding: [0x5b,0x44,0xc5,0x10]
26+
# CHECK-ERROR: instruction requires the following: 'XAndesVDot' (Andes Vector Dot Product Extension){{$}}
27+
nds.vd4dots.vv v8, v10, v12, v0.t
28+
29+
# CHECK-OBJ: nds.vd4dotu.vv v8, v10, v12
30+
# CHECK-ASM: nds.vd4dotu.vv v8, v10, v12
31+
# CHECK-ASM: encoding: [0x5b,0x44,0xc5,0x1e]
32+
# CHECK-ERROR: instruction requires the following: 'XAndesVDot' (Andes Vector Dot Product Extension){{$}}
33+
nds.vd4dotu.vv v8, v10, v12
34+
35+
# CHECK-OBJ: nds.vd4dotu.vv v8, v10, v12, v0.t
36+
# CHECK-ASM: nds.vd4dotu.vv v8, v10, v12, v0.t
37+
# CHECK-ASM: encoding: [0x5b,0x44,0xc5,0x1c]
38+
# CHECK-ERROR: instruction requires the following: 'XAndesVDot' (Andes Vector Dot Product Extension){{$}}
39+
nds.vd4dotu.vv v8, v10, v12, v0.t
40+
41+
# CHECK-OBJ: nds.vd4dotsu.vv v8, v10, v12
42+
# CHECK-ASM: nds.vd4dotsu.vv v8, v10, v12
43+
# CHECK-ASM: encoding: [0x5b,0x44,0xc5,0x16]
44+
# CHECK-ERROR: instruction requires the following: 'XAndesVDot' (Andes Vector Dot Product Extension){{$}}
45+
nds.vd4dotsu.vv v8, v10, v12
46+
47+
# CHECK-OBJ: nds.vd4dotsu.vv v8, v10, v12, v0.t
48+
# CHECK-ASM: nds.vd4dotsu.vv v8, v10, v12, v0.t
49+
# CHECK-ASM: encoding: [0x5b,0x44,0xc5,0x14]
50+
# CHECK-ERROR: instruction requires the following: 'XAndesVDot' (Andes Vector Dot Product Extension){{$}}
51+
nds.vd4dotsu.vv v8, v10, v12, v0.t

llvm/unittests/TargetParser/RISCVISAInfoTest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,7 @@ R"(All available -march extensions for RISC-V
11281128
svpbmt 1.0
11291129
svvptc 1.0
11301130
xandesperf 5.0
1131+
xandesvdot 5.0
11311132
xandesvpackfph 5.0
11321133
xcvalu 1.0
11331134
xcvbi 1.0

0 commit comments

Comments
 (0)