Skip to content

Commit b07a5ca

Browse files
committed
[RISCV] Add assembler support for Zvma
1 parent 92e0560 commit b07a5ca

File tree

6 files changed

+44
-0
lines changed

6 files changed

+44
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@
192192
// CHECK-NEXT: zalasr 0.1 'Zalasr' (Load-Acquire and Store-Release Instructions)
193193
// CHECK-NEXT: zvbc32e 0.7 'Zvbc32e' (Vector Carryless Multiplication with 32-bits elements)
194194
// CHECK-NEXT: zvkgs 0.7 'Zvkgs' (Vector-Scalar GCM instructions for Cryptography)
195+
// CHECK-NEXT: zvma 0.0 'Zvma' (High-throughput Matrix-multiplication Computation)
195196
// CHECK-NEXT: zvqdotq 0.0 'Zvqdotq' (Vector quad widening 4D Dot Product)
196197
// CHECK-NEXT: smctr 1.0 'Smctr' (Control Transfer Records Machine Level)
197198
// CHECK-NEXT: ssctr 1.0 'Ssctr' (Control Transfer Records Supervisor Level)

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@
203203
// CHECK-NOT: __riscv_zvfbfwma {{.*$}}
204204
// CHECK-NOT: __riscv_zvkgs {{.*$}}
205205
// CHECK-NOT: __riscv_zvqdotq {{.*$}}
206+
// CHECK-NOT: __riscv_zvma {{.*$}}
206207

207208
// RUN: %clang --target=riscv32-unknown-linux-gnu \
208209
// RUN: -march=rv32ia -E -dM %s \
@@ -1770,6 +1771,14 @@
17701771
// RUN: -o - | FileCheck --check-prefix=CHECK-ZVQDOTQ-EXT %s
17711772
// CHECK-ZVQDOTQ-EXT: __riscv_zvqdotq 0{{$}}
17721773

1774+
// RUN: %clang --target=riscv32 -menable-experimental-extensions \
1775+
// RUN: -march=rv32i_zve32x_zvma0p0 -E -dM %s \
1776+
// RUN: -o - | FileCheck --check-prefix=CHECK-ZVMA-EXT %s
1777+
// RUN: %clang --target=riscv64 -menable-experimental-extensions \
1778+
// RUN: -march=rv64i_zve32x_zvma0p0 -E -dM %s \
1779+
// RUN: -o - | FileCheck --check-prefix=CHECK-ZVMA-EXT %s
1780+
// CHECK-ZVMA-EXT: __riscv_zvma 0111{{$}}
1781+
17731782
// RUN: %clang -target riscv32 -menable-experimental-extensions \
17741783
// RUN: -march=rv32izicfiss1p0 -E -dM %s \
17751784
// 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
@@ -340,6 +340,9 @@ The primary goal of experimental support is to assist in the process of ratifica
340340
``experimental-zvqdotq``
341341
LLVM implements the `0.0.1 draft specification <https://github.com/riscv/riscv-dot-product/releases/tag/v0.0.1>`__.
342342

343+
``experimental-zvma``
344+
LLVM implements the `SiFive proposal specification <https://lists.riscv.org/g/tech-attached-matrix-extension/topic/sifive_proposal_for_risc_v/110189555>`__.
345+
343346
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`.
344347

345348
Vendor Extensions

llvm/lib/Target/RISCV/RISCVFeatures.td

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,15 @@ def HasStdExtZvqdotq : Predicate<"Subtarget->hasStdExtZvqdotq()">,
830830
AssemblerPredicate<(all_of FeatureStdExtZvqdotq),
831831
"'Zvqdotq' (Vector quad widening 4D Dot Product)">;
832832

833+
// High-throughput Matrix-multiplication Computation
834+
835+
def FeatureStdExtZvma
836+
: RISCVExperimentalExtension<0, 0, "High-throughput Matrix-multiplication Computation",
837+
[FeatureStdExtZve32x]>;
838+
def HasStdExtZvma : Predicate<"Subtarget->hasStdExtZvma()">,
839+
AssemblerPredicate<(all_of FeatureStdExtZvma),
840+
"'Zvma' (High-throughput Matrix-multiplication Computation)">;
841+
833842
// Vector instruction predicates
834843

835844
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
@@ -2139,6 +2139,7 @@ include "RISCVInstrInfoZk.td"
21392139
include "RISCVInstrInfoV.td"
21402140
include "RISCVInstrInfoZvk.td"
21412141
include "RISCVInstrInfoZvqdotq.td"
2142+
include "RISCVInstrInfoZvma.td"
21422143

21432144
// Integer
21442145
include "RISCVInstrInfoZimop.td"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class VSetT<bits<5> func5, dag outs, dag ins, string opcodestr, string argstr>
2+
: RVInst<outs, ins, opcodestr, argstr, [], InstFormatOther> {
3+
bits<5> rs1;
4+
bits<5> rd;
5+
6+
let Inst{31} = 1;
7+
let Inst{30-25} = 0b000010;
8+
let Inst{24-20} = func5;
9+
let Inst{19-15} = rs1;
10+
let Inst{14-12} = 0b111;
11+
let Inst{11-7} = rd;
12+
let Inst{6-0} = 0x57;
13+
}
14+
15+
let Predicates = [HasStdExtZvma] in {
16+
let hasSideEffects = 1, mayLoad = 0, mayStore = 0 in {
17+
def VSETTN : VSetT<0b00000, (outs GPR:$rd), (ins GPR:$rs1), "vsettn", "$rd, %rs1">;
18+
def VSETTM : VSetT<0b00001, (outs GPR:$rd), (ins GPR:$rs1), "vsettm", "$rd, %rs1">;
19+
def VSETTK : VSetT<0b00010, (outs GPR:$rd), (ins GPR:$rs1), "vsettk", "$rd, %rs1">;
20+
} // hasSideEffects = 1, mayLoad = 0, mayStore = 0
21+
} // Predicates = [HasStdExtZvma]

0 commit comments

Comments
 (0)