Skip to content

Commit 6c39e3f

Browse files
authored
[clang][RISCV] Reorder sema check for RVV type (llvm#83553)
Currently using the command `clang -cc1 -triple riscv64` to compile the code below: ``` #include <riscv_vector.h> void foo() { vfloat64m1_t f64m1; } ``` would get the error message "RISC-V type 'vfloat64m1_t' ... requires the 'zve64x' extension" which is supposed to be "RISC-V type 'vfloat64m1_t' ... requires the 'zve64d' extension".
1 parent 0207270 commit 6c39e3f

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

clang/lib/Sema/SemaChecking.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6391,10 +6391,14 @@ void Sema::checkRVVTypeSupport(QualType Ty, SourceLocation Loc, Decl *D) {
63916391
unsigned EltSize = Context.getTypeSize(Info.ElementType);
63926392
unsigned MinElts = Info.EC.getKnownMinValue();
63936393

6394+
if (Info.ElementType->isSpecificBuiltinType(BuiltinType::Double) &&
6395+
!TI.hasFeature("zve64d"))
6396+
Diag(Loc, diag::err_riscv_type_requires_extension, D) << Ty << "zve64d";
63946397
// (ELEN, LMUL) pairs of (8, mf8), (16, mf4), (32, mf2), (64, m1) requires at
63956398
// least zve64x
6396-
if (((EltSize == 64 && Info.ElementType->isIntegerType()) || MinElts == 1) &&
6397-
!TI.hasFeature("zve64x"))
6399+
else if (((EltSize == 64 && Info.ElementType->isIntegerType()) ||
6400+
MinElts == 1) &&
6401+
!TI.hasFeature("zve64x"))
63986402
Diag(Loc, diag::err_riscv_type_requires_extension, D) << Ty << "zve64x";
63996403
else if (Info.ElementType->isFloat16Type() && !TI.hasFeature("zvfh") &&
64006404
!TI.hasFeature("zvfhmin"))
@@ -6406,9 +6410,6 @@ void Sema::checkRVVTypeSupport(QualType Ty, SourceLocation Loc, Decl *D) {
64066410
else if (Info.ElementType->isSpecificBuiltinType(BuiltinType::Float) &&
64076411
!TI.hasFeature("zve32f"))
64086412
Diag(Loc, diag::err_riscv_type_requires_extension, D) << Ty << "zve32f";
6409-
else if (Info.ElementType->isSpecificBuiltinType(BuiltinType::Double) &&
6410-
!TI.hasFeature("zve64d"))
6411-
Diag(Loc, diag::err_riscv_type_requires_extension, D) << Ty << "zve64d";
64126413
// Given that caller already checked isRVVType() before calling this function,
64136414
// if we don't have at least zve32x supported, then we need to emit error.
64146415
else if (!TI.hasFeature("zve32x"))

clang/test/Sema/riscv-vector-float64-check.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \
2-
// RUN: -target-feature +zve64f -target-feature +zfh \
1+
// RUN: %clang_cc1 -triple riscv64 -target-feature +zve32x \
32
// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify
43
// REQUIRES: riscv-registered-target
54
#include <riscv_vector.h>

0 commit comments

Comments
 (0)