Skip to content

Commit e747223

Browse files
authored
[RISCV] Implement MC support for Zvfofp8min extension (#157014)
This patch adds MC support for Zvfofp8min https://github.com/aswaterman/riscv-misc/blob/main/isa/zvfofp8min.adoc.
1 parent adfa6a4 commit e747223

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
@@ -218,6 +218,7 @@
218218
// CHECK-NEXT: zalasr 0.1 'Zalasr' (Load-Acquire and Store-Release Instructions)
219219
// CHECK-NEXT: zvbc32e 0.7 'Zvbc32e' (Vector Carryless Multiplication with 32-bits elements)
220220
// CHECK-NEXT: zvfbfa 0.1 'Zvfbfa' (Additional BF16 vector compute support)
221+
// CHECK-NEXT: zvfofp8min 0.2 'Zvfofp8min' (Vector OFP8 Converts)
221222
// CHECK-NEXT: zvkgs 0.7 'Zvkgs' (Vector-Scalar GCM instructions for Cryptography)
222223
// CHECK-NEXT: zvqdotq 0.0 'Zvqdotq' (Vector quad widening 4D Dot Product)
223224
// 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
@@ -179,6 +179,7 @@
179179
// CHECK-NOT: __riscv_ztso {{.*$}}
180180
// CHECK-NOT: __riscv_zvbc32e {{.*$}}
181181
// CHECK-NOT: __riscv_zvfbfa {{.*$}}
182+
// CHECK-NOT: __riscv_zvfofp8min {{.*$}}
182183
// CHECK-NOT: __riscv_zvfbfmin {{.*$}}
183184
// CHECK-NOT: __riscv_zvfbfwma {{.*$}}
184185
// CHECK-NOT: __riscv_zvkgs {{.*$}}
@@ -1569,6 +1570,14 @@
15691570
// RUN: -o - | FileCheck --check-prefix=CHECK-ZVFBFA-EXT %s
15701571
// CHECK-ZVFBFA-EXT: __riscv_zvfbfa 1000{{$}}
15711572

1573+
// RUN: %clang --target=riscv32 -menable-experimental-extensions \
1574+
// RUN: -march=rv32ifzvfofp8min0p2 -E -dM %s \
1575+
// RUN: -o - | FileCheck --check-prefix=CHECK-ZVFOFP8MIN-EXT %s
1576+
// RUN: %clang --target=riscv64 -menable-experimental-extensions \
1577+
// RUN: -march=rv64ifzvfofp8min0p2 -E -dM %s \
1578+
// RUN: -o - | FileCheck --check-prefix=CHECK-ZVFOFP8MIN-EXT %s
1579+
// CHECK-ZVFOFP8MIN-EXT: __riscv_zvfofp8min 2000{{$}}
1580+
15721581
// RUN: %clang --target=riscv32 -menable-experimental-extensions \
15731582
// RUN: -march=rv32i_zve32x_zvbc32e0p7 -E -dM %s \
15741583
// 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
@@ -125,6 +125,7 @@ Changes to the RISC-V Backend
125125
* Ssctr and Smctr extensions are no longer experimental.
126126
* Add support for Zvfbfa (Additional BF16 vector compute support)
127127
* Adds experimental support for the 'Zibi` (Branch with Immediate) extension.
128+
* Add support for Zvfofp8min (OFP8 conversion extension)
128129

129130
Changes to the WebAssembly Backend
130131
----------------------------------

llvm/lib/Target/RISCV/RISCVFeatures.td

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

696696
def FeatureStdExtZvfbfmin
697697
: RISCVExtension<1, 0, "Vector BF16 Converts", [FeatureStdExtZve32f]>;
698-
def HasStdExtZvfbfmin : Predicate<"Subtarget->hasStdExtZvfbfmin()">,
699-
AssemblerPredicate<(all_of FeatureStdExtZvfbfmin),
700-
"'Zvfbfmin' (Vector BF16 Converts)">;
701698

702699
def FeatureStdExtZvfbfwma
703700
: RISCVExtension<1, 0, "Vector BF16 widening mul-add",
@@ -723,6 +720,22 @@ def HasStdExtZfhOrZvfh
723720
"'Zfh' (Half-Precision Floating-Point) or "
724721
"'Zvfh' (Vector Half-Precision Floating-Point)">;
725722

723+
def FeatureStdExtZvfofp8min
724+
: RISCVExperimentalExtension<0, 2,
725+
"Vector OFP8 Converts", [FeatureStdExtZve32f]>;
726+
def HasStdExtZvfofp8min
727+
: Predicate<"Subtarget->hasStdExtZvfofp8min()">,
728+
AssemblerPredicate<(all_of FeatureStdExtZvfofp8min),
729+
"'Zvfofp8min' (Vector OFP8 Converts)">;
730+
731+
def HasStdExtZvfbfminOrZvfofp8min
732+
: Predicate<"Subtarget->hasStdExtZvfbfmin() ||"
733+
"Subtarget->hasStdExtZvfofp8min()">,
734+
AssemblerPredicate<(any_of FeatureStdExtZvfbfmin,
735+
FeatureStdExtZvfofp8min),
736+
"'Zvfbfmin' (Vector BF16 Converts) or "
737+
"'Zvfofp8min' (Vector OFP8 Converts)">;
738+
726739
// Vector Cryptography and Bitmanip Extensions
727740

728741
def FeatureStdExtZvkb

llvm/lib/Target/RISCV/RISCVInstrInfo.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2344,6 +2344,7 @@ include "RISCVInstrInfoZk.td"
23442344
include "RISCVInstrInfoV.td"
23452345
include "RISCVInstrInfoZvk.td"
23462346
include "RISCVInstrInfoZvqdotq.td"
2347+
include "RISCVInstrInfoZvfofp8min.td"
23472348

23482349
// Packed SIMD
23492350
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
@@ -129,6 +129,7 @@
129129
; RUN: llc -mtriple=riscv32 -mattr=+experimental-zvfbfa %s -o - | FileCheck --check-prefixes=CHECK,RV32ZVFBFA %s
130130
; RUN: llc -mtriple=riscv32 -mattr=+zvfbfmin %s -o - | FileCheck --check-prefixes=CHECK,RV32ZVFBFMIN %s
131131
; RUN: llc -mtriple=riscv32 -mattr=+zvfbfwma %s -o - | FileCheck --check-prefixes=CHECK,RV32ZVFBFWMA %s
132+
; RUN: llc -mtriple=riscv32 -mattr=+experimental-zvfofp8min %s -o - | FileCheck --check-prefixes=CHECK,RV32ZVFOFP8MIN %s
132133
; RUN: llc -mtriple=riscv32 -mattr=+zacas %s -o - | FileCheck --check-prefix=RV32ZACAS %s
133134
; RUN: llc -mtriple=riscv32 -mattr=+experimental-zalasr %s -o - | FileCheck --check-prefix=RV32ZALASR %s
134135
; RUN: llc -mtriple=riscv32 -mattr=+zama16b %s -o - | FileCheck --check-prefixes=CHECK,RV32ZAMA16B %s
@@ -277,6 +278,7 @@
277278
; RUN: llc -mtriple=riscv64 -mattr=+experimental-zvfbfa %s -o - | FileCheck --check-prefixes=CHECK,RV64ZVFBFA %s
278279
; RUN: llc -mtriple=riscv64 -mattr=+zvfbfmin %s -o - | FileCheck --check-prefixes=CHECK,RV64ZVFBFMIN %s
279280
; RUN: llc -mtriple=riscv64 -mattr=+zvfbfwma %s -o - | FileCheck --check-prefixes=CHECK,RV64ZVFBFWMA %s
281+
; RUN: llc -mtriple=riscv64 -mattr=+experimental-zvfofp8min %s -o - | FileCheck --check-prefixes=CHECK,RV64ZVFOFP8MIN %s
280282
; RUN: llc -mtriple=riscv64 -mattr=+zacas %s -o - | FileCheck --check-prefix=RV64ZACAS %s
281283
; RUN: llc -mtriple=riscv64 -mattr=+experimental-zalasr %s -o - | FileCheck --check-prefix=RV64ZALASR %s
282284
; RUN: llc -mtriple=riscv64 -mattr=+experimental-zicfilp %s -o - | FileCheck --check-prefix=RV64ZICFILP %s
@@ -439,6 +441,7 @@
439441
; RV32ZVFBFA: .attribute 5, "rv32i2p1_f2p2_zicsr2p0_zfbfmin1p0_zve32f1p0_zve32x1p0_zvfbfa0p1_zvl32b1p0"
440442
; RV32ZVFBFMIN: .attribute 5, "rv32i2p1_f2p2_zicsr2p0_zve32f1p0_zve32x1p0_zvfbfmin1p0_zvl32b1p0"
441443
; RV32ZVFBFWMA: .attribute 5, "rv32i2p1_f2p2_zicsr2p0_zfbfmin1p0_zve32f1p0_zve32x1p0_zvfbfmin1p0_zvfbfwma1p0_zvl32b1p0"
444+
; RV32ZVFOFP8MIN: .attribute 5, "rv32i2p1_f2p2_zicsr2p0_zve32f1p0_zve32x1p0_zvfofp8min0p2_zvl32b1p0"
442445
; RV32ZACAS: .attribute 5, "rv32i2p1_zaamo1p0_zacas1p0"
443446
; RV32ZALASR: .attribute 5, "rv32i2p1_zalasr0p1"
444447
; RV32ZAMA16B: .attribute 5, "rv32i2p1_zama16b1p0"
@@ -585,6 +588,7 @@
585588
; RV64ZVFBFA: .attribute 5, "rv64i2p1_f2p2_zicsr2p0_zfbfmin1p0_zve32f1p0_zve32x1p0_zvfbfa0p1_zvl32b1p0"
586589
; RV64ZVFBFMIN: .attribute 5, "rv64i2p1_f2p2_zicsr2p0_zve32f1p0_zve32x1p0_zvfbfmin1p0_zvl32b1p0"
587590
; RV64ZVFBFWMA: .attribute 5, "rv64i2p1_f2p2_zicsr2p0_zfbfmin1p0_zve32f1p0_zve32x1p0_zvfbfmin1p0_zvfbfwma1p0_zvl32b1p0"
591+
; RV64ZVFOFP8MIN: .attribute 5, "rv64i2p1_f2p2_zicsr2p0_zve32f1p0_zve32x1p0_zvfofp8min0p2_zvl32b1p0"
588592
; RV64ZACAS: .attribute 5, "rv64i2p1_zaamo1p0_zacas1p0"
589593
; RV64ZALASR: .attribute 5, "rv64i2p1_zalasr0p1"
590594
; RV64ZALASRA: .attribute 5, "rv64i2p1_a2p1_zaamo1p0_zalasr0p1_zalrsc1p0"

0 commit comments

Comments
 (0)