@@ -6170,25 +6170,28 @@ bool Sema::CheckWebAssemblyBuiltinFunctionCall(const TargetInfo &TI,
6170
6170
6171
6171
void Sema::checkRVVTypeSupport(QualType Ty, SourceLocation Loc, Decl *D) {
6172
6172
const TargetInfo &TI = Context.getTargetInfo();
6173
+
6174
+ ASTContext::BuiltinVectorTypeInfo Info =
6175
+ Context.getBuiltinVectorTypeInfo(Ty->castAs<BuiltinType>());
6176
+ unsigned EltSize = Context.getTypeSize(Info.ElementType);
6177
+ unsigned MinElts = Info.EC.getKnownMinValue();
6178
+
6173
6179
// (ELEN, LMUL) pairs of (8, mf8), (16, mf4), (32, mf2), (64, m1) requires at
6174
6180
// least zve64x
6175
- if ((Ty->isRVVType(/* Bitwidth */ 64, /* IsFloat */ false) ||
6176
- Ty->isRVVType(/* ElementCount */ 1)) &&
6181
+ if (((EltSize == 64 && Info.ElementType->isIntegerType()) || MinElts == 1) &&
6177
6182
!TI.hasFeature("zve64x"))
6178
6183
Diag(Loc, diag::err_riscv_type_requires_extension, D) << Ty << "zve64x";
6179
- if (Ty->isRVVType(/* Bitwidth */ 16, /* IsFloat */ true ) &&
6180
- !TI.hasFeature("zvfh") && !TI.hasFeature(" zvfhmin"))
6184
+ if (Info.ElementType->isFloat16Type() && !TI.hasFeature("zvfh" ) &&
6185
+ !TI.hasFeature("zvfhmin"))
6181
6186
Diag(Loc, diag::err_riscv_type_requires_extension, D)
6182
6187
<< Ty << "zvfh or zvfhmin";
6183
- // Check if enabled zvfbfmin for BFloat16
6184
- if (Ty->isRVVType(/* Bitwidth */ 16, /* IsFloat */ false,
6185
- /* IsBFloat */ true) &&
6188
+ if (Info.ElementType->isBFloat16Type() &&
6186
6189
!TI.hasFeature("experimental-zvfbfmin"))
6187
6190
Diag(Loc, diag::err_riscv_type_requires_extension, D) << Ty << "zvfbfmin";
6188
- if (Ty->isRVVType(/* Bitwidth */ 32, /* IsFloat */ true ) &&
6191
+ if (Info.ElementType->isSpecificBuiltinType(BuiltinType::Float ) &&
6189
6192
!TI.hasFeature("zve32f"))
6190
6193
Diag(Loc, diag::err_riscv_type_requires_extension, D) << Ty << "zve32f";
6191
- if (Ty->isRVVType(/* Bitwidth */ 64, /* IsFloat */ true ) &&
6194
+ if (Info.ElementType->isSpecificBuiltinType(BuiltinType::Double ) &&
6192
6195
!TI.hasFeature("zve64d"))
6193
6196
Diag(Loc, diag::err_riscv_type_requires_extension, D) << Ty << "zve64d";
6194
6197
// Given that caller already checked isRVVType() before calling this function,
0 commit comments