Skip to content

Commit 721e751

Browse files
committed
[RISCV] Implement MC support for Zvfofp8min extension
This patch adds MC support for Zvfofp8min https://github.com/aswaterman/riscv-misc/blob/main/isa/zvfofp8min.adoc.
1 parent 200a9a8 commit 721e751

File tree

15 files changed

+107
-9
lines changed

15 files changed

+107
-9
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@
216216
// CHECK-NEXT: zalasr 0.1 'Zalasr' (Load-Acquire and Store-Release Instructions)
217217
// CHECK-NEXT: zvbc32e 0.7 'Zvbc32e' (Vector Carryless Multiplication with 32-bits elements)
218218
// CHECK-NEXT: zvfbfa 0.1 'Zvfbfa' (Additional BF16 vector compute support)
219+
// CHECK-NEXT: zvfofp8min 0.21 'Zvfofp8min' (Vector OFP8 Converts)
219220
// CHECK-NEXT: zvkgs 0.7 'Zvkgs' (Vector-Scalar GCM instructions for Cryptography)
220221
// CHECK-NEXT: zvqdotq 0.0 'Zvqdotq' (Vector quad widening 4D Dot Product)
221222
// CHECK-NEXT: svukte 0.3 'Svukte' (Address-Independent Latency of User-Mode Faults to Supervisor Addresses)

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@
178178
// CHECK-NOT: __riscv_ztso {{.*$}}
179179
// CHECK-NOT: __riscv_zvbc32e {{.*$}}
180180
// CHECK-NOT: __riscv_zvfbfa {{.*$}}
181+
// CHECK-NOT: __riscv_zvfofp8min {{.*$}}
181182
// CHECK-NOT: __riscv_zvfbfmin {{.*$}}
182183
// CHECK-NOT: __riscv_zvfbfwma {{.*$}}
183184
// CHECK-NOT: __riscv_zvkgs {{.*$}}
@@ -1560,6 +1561,14 @@
15601561
// RUN: -o - | FileCheck --check-prefix=CHECK-ZVFBFA-EXT %s
15611562
// CHECK-ZVFBFA-EXT: __riscv_zvfbfa 1000{{$}}
15621563

1564+
// RUN: %clang --target=riscv32 -menable-experimental-extensions \
1565+
// RUN: -march=rv32ifzvfofp8min0p21 -E -dM %s \
1566+
// RUN: -o - | FileCheck --check-prefix=CHECK-ZVFOFP8MIN-EXT %s
1567+
// RUN: %clang --target=riscv64 -menable-experimental-extensions \
1568+
// RUN: -march=rv64ifzvfofp8min0p21 -E -dM %s \
1569+
// RUN: -o - | FileCheck --check-prefix=CHECK-ZVFOFP8MIN-EXT %s
1570+
// CHECK-ZVFOFP8MIN-EXT: __riscv_zvfofp8min 21000{{$}}
1571+
15631572
// RUN: %clang --target=riscv32 -menable-experimental-extensions \
15641573
// RUN: -march=rv32i_zve32x_zvbc32e0p7 -E -dM %s \
15651574
// RUN: -o - | FileCheck --check-prefix=CHECK-ZVBC32E-EXT %s

llvm/docs/RISCVUsage.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ on support follow.
236236
``Zvfbfwma`` Supported
237237
``Zvfh`` Supported
238238
``Zvfhmin`` Supported
239+
``Zvfofp8min`` Assembly Support
239240
``Zvkb`` Supported
240241
``Zvkg`` Supported (`See note <#riscv-vector-crypto-note>`__)
241242
``Zvkn`` Supported (`See note <#riscv-vector-crypto-note>`__)

llvm/docs/ReleaseNotes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ Changes to the RISC-V Backend
120120
using `$x` with an architecture string suffix is not yet supported.
121121
* Ssctr and Smctr extensions are no longer experimental.
122122
* Add support for Zvfbfa (Additional BF16 vector compute support)
123+
* Add support for Zvfofp8min (OFP8 conversion extension)
123124

124125
Changes to the WebAssembly Backend
125126
----------------------------------

llvm/lib/Target/RISCV/RISCVFeatures.td

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -689,9 +689,6 @@ def HasStdExtZvfbfa : Predicate<"Subtarget->hasStdExtZvfbfa()">,
689689

690690
def FeatureStdExtZvfbfmin
691691
: RISCVExtension<1, 0, "Vector BF16 Converts", [FeatureStdExtZve32f]>;
692-
def HasStdExtZvfbfmin : Predicate<"Subtarget->hasStdExtZvfbfmin()">,
693-
AssemblerPredicate<(all_of FeatureStdExtZvfbfmin),
694-
"'Zvfbfmin' (Vector BF16 Converts)">;
695692

696693
def FeatureStdExtZvfbfwma
697694
: RISCVExtension<1, 0, "Vector BF16 widening mul-add",
@@ -717,6 +714,22 @@ def HasStdExtZfhOrZvfh
717714
"'Zfh' (Half-Precision Floating-Point) or "
718715
"'Zvfh' (Vector Half-Precision Floating-Point)">;
719716

717+
def FeatureStdExtZvfofp8min
718+
: RISCVExperimentalExtension<0, 21,
719+
"Vector OFP8 Converts", [FeatureStdExtZve32f]>;
720+
def HasStdExtZvfofp8min
721+
: Predicate<"Subtarget->hasStdExtZvfofp8min()">,
722+
AssemblerPredicate<(all_of FeatureStdExtZvfofp8min),
723+
"'Zvfofp8min' (Vector OFP8 Converts)">;
724+
725+
def HasStdExtZvfbfminOrZvfofp8min
726+
: Predicate<"Subtarget->hasStdExtZvfbfmin() ||"
727+
"Subtarget->hasStdExtZvfofp8min()">,
728+
AssemblerPredicate<(any_of FeatureStdExtZvfbfmin,
729+
FeatureStdExtZvfofp8min),
730+
"'Zvfbfmin' (Vector BF16 Converts) or "
731+
"'Zvfofp8min' (Vector OFP8 Converts)">;
732+
720733
// Vector Cryptography and Bitmanip Extensions
721734

722735
def FeatureStdExtZvkb

llvm/lib/Target/RISCV/RISCVInstrInfo.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2349,6 +2349,7 @@ include "RISCVInstrInfoZk.td"
23492349
include "RISCVInstrInfoV.td"
23502350
include "RISCVInstrInfoZvk.td"
23512351
include "RISCVInstrInfoZvqdotq.td"
2352+
include "RISCVInstrInfoZvfofp8min.td"
23522353

23532354
// Packed SIMD
23542355
include "RISCVInstrInfoP.td"

llvm/lib/Target/RISCV/RISCVInstrInfoZvfbf.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
// Instructions
1818
//===----------------------------------------------------------------------===//
1919

20-
let Predicates = [HasStdExtZvfbfmin], Constraints = "@earlyclobber $vd",
20+
let Predicates = [HasStdExtZvfbfminOrZvfofp8min],
21+
Constraints = "@earlyclobber $vd",
2122
mayRaiseFPException = true in {
2223
let RVVConstraint = WidenCvt, DestEEW = EEWSEWx2 in
2324
defm VFWCVTBF16_F_F_V : VWCVTF_FV_VS2<"vfwcvtbf16.f.f.v", 0b010010, 0b01101>;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//===- RISCVInstrInfoZvfofp8min.td - 'Zvfofp8min' ----------*- 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 'Zvfofp8min'
10+
// extension, providing vector conversion instructions for OFP8.
11+
// This version is still experimental as the 'Zvfofp8min' extension hasn't been
12+
// ratified yet.
13+
//
14+
//===----------------------------------------------------------------------===//
15+
16+
//===----------------------------------------------------------------------===//
17+
// Instructions
18+
//===----------------------------------------------------------------------===//
19+
20+
let Predicates = [HasStdExtZvfofp8min], Constraints = "@earlyclobber $vd",
21+
mayRaiseFPException = true, Uses = [FRM, VL, VTYPE] in {
22+
defm VFNCVTBF16_SAT_F_F_W
23+
: VNCVTF_FV_VS2<"vfncvtbf16.sat.f.f.w", 0b010010, 0b11111>;
24+
defm VFNCVT_F_F_Q : VNCVTF_FV_VS2<"vfncvt.f.f.q", 0b010010, 0b11001>;
25+
defm VFNCVT_SAT_F_F_Q : VNCVTF_FV_VS2<"vfncvt.sat.f.f.q", 0b010010, 0b11011>;
26+
}

llvm/lib/TargetParser/RISCVTargetParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ namespace RISCVVType {
153153
//
154154
// Bits | Name | Description
155155
// -----+------------+------------------------------------------------
156-
// 8 | altfmt | Alternative format for bf16
156+
// 8 | altfmt | Alternative format for bf16/ofp8
157157
// 7 | vma | Vector mask agnostic
158158
// 6 | vta | Vector tail agnostic
159159
// 5:3 | vsew[2:0] | Standard element width (SEW) setting

llvm/test/CodeGen/RISCV/attributes.ll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@
162162
; RUN: llc -mtriple=riscv32 -mattr=+experimental-zvfbfa %s -o - | FileCheck --check-prefixes=CHECK,RV32ZVFBFA %s
163163
; RUN: llc -mtriple=riscv32 -mattr=+zvfbfmin %s -o - | FileCheck --check-prefixes=CHECK,RV32ZVFBFMIN %s
164164
; RUN: llc -mtriple=riscv32 -mattr=+zvfbfwma %s -o - | FileCheck --check-prefixes=CHECK,RV32ZVFBFWMA %s
165+
; RUN: llc -mtriple=riscv32 -mattr=+experimental-zvfofp8min %s -o - | FileCheck --check-prefixes=CHECK,RV32ZVFOFP8MIN %s
165166
; RUN: llc -mtriple=riscv32 -mattr=+zacas %s -o - | FileCheck --check-prefix=RV32ZACAS %s
166167
; RUN: llc -mtriple=riscv32 -mattr=+experimental-zalasr %s -o - | FileCheck --check-prefix=RV32ZALASR %s
167168
; RUN: llc -mtriple=riscv32 -mattr=+zama16b %s -o - | FileCheck --check-prefixes=CHECK,RV32ZAMA16B %s
@@ -327,6 +328,7 @@
327328
; RUN: llc -mtriple=riscv64 -mattr=+experimental-zvfbfa %s -o - | FileCheck --check-prefixes=CHECK,RV64ZVFBFA %s
328329
; RUN: llc -mtriple=riscv64 -mattr=+zvfbfmin %s -o - | FileCheck --check-prefixes=CHECK,RV64ZVFBFMIN %s
329330
; RUN: llc -mtriple=riscv64 -mattr=+zvfbfwma %s -o - | FileCheck --check-prefixes=CHECK,RV64ZVFBFWMA %s
331+
; RUN: llc -mtriple=riscv64 -mattr=+experimental-zvfofp8min %s -o - | FileCheck --check-prefixes=CHECK,RV64ZVFOFP8MIN %s
330332
; RUN: llc -mtriple=riscv64 -mattr=+zacas %s -o - | FileCheck --check-prefix=RV64ZACAS %s
331333
; RUN: llc -mtriple=riscv64 -mattr=+experimental-zalasr %s -o - | FileCheck --check-prefix=RV64ZALASR %s
332334
; RUN: llc -mtriple=riscv64 -mattr=+experimental-zicfilp %s -o - | FileCheck --check-prefix=RV64ZICFILP %s
@@ -522,6 +524,7 @@
522524
; RV32ZVFBFA: .attribute 5, "rv32i2p1_f2p2_zicsr2p0_zfbfmin1p0_zve32f1p0_zve32x1p0_zvfbfa0p1_zvl32b1p0"
523525
; RV32ZVFBFMIN: .attribute 5, "rv32i2p1_f2p2_zicsr2p0_zve32f1p0_zve32x1p0_zvfbfmin1p0_zvl32b1p0"
524526
; RV32ZVFBFWMA: .attribute 5, "rv32i2p1_f2p2_zicsr2p0_zfbfmin1p0_zve32f1p0_zve32x1p0_zvfbfmin1p0_zvfbfwma1p0_zvl32b1p0"
527+
; RV32ZVFOFP8MIN: .attribute 5, "rv32i2p1_f2p2_zicsr2p0_zve32f1p0_zve32x1p0_zvfofp8min0p21_zvl32b1p0"
525528
; RV32ZACAS: .attribute 5, "rv32i2p1_zaamo1p0_zacas1p0"
526529
; RV32ZALASR: .attribute 5, "rv32i2p1_zalasr0p1"
527530
; RV32ZAMA16B: .attribute 5, "rv32i2p1_zama16b1p0"
@@ -685,6 +688,7 @@
685688
; RV64ZVFBFA: .attribute 5, "rv64i2p1_f2p2_zicsr2p0_zfbfmin1p0_zve32f1p0_zve32x1p0_zvfbfa0p1_zvl32b1p0"
686689
; RV64ZVFBFMIN: .attribute 5, "rv64i2p1_f2p2_zicsr2p0_zve32f1p0_zve32x1p0_zvfbfmin1p0_zvl32b1p0"
687690
; RV64ZVFBFWMA: .attribute 5, "rv64i2p1_f2p2_zicsr2p0_zfbfmin1p0_zve32f1p0_zve32x1p0_zvfbfmin1p0_zvfbfwma1p0_zvl32b1p0"
691+
; RV64ZVFOFP8MIN: .attribute 5, "rv64i2p1_f2p2_zicsr2p0_zve32f1p0_zve32x1p0_zvfofp8min0p21_zvl32b1p0"
688692
; RV64ZACAS: .attribute 5, "rv64i2p1_zaamo1p0_zacas1p0"
689693
; RV64ZALASR: .attribute 5, "rv64i2p1_zalasr0p1"
690694
; RV64ZALASRA: .attribute 5, "rv64i2p1_a2p1_zaamo1p0_zalasr0p1_zalrsc1p0"

0 commit comments

Comments
 (0)