@@ -545,8 +545,10 @@ bool SemaRISCV::CheckLMUL(CallExpr *TheCall, unsigned ArgNum) {
545
545
<< Arg->getSourceRange ();
546
546
}
547
547
548
- static bool CheckInvalidVLENandLMUL (const TargetInfo &TI, CallExpr *TheCall,
549
- Sema &S, QualType Type, int EGW) {
548
+ static bool CheckInvalidVLENandLMUL (const TargetInfo &TI,
549
+ llvm::StringMap<bool > &FunctionFeatureMap,
550
+ CallExpr *TheCall, Sema &S, QualType Type,
551
+ int EGW) {
550
552
assert ((EGW == 128 || EGW == 256 ) && " EGW can only be 128 or 256 bits" );
551
553
552
554
// LMUL * VLEN >= EGW
@@ -567,7 +569,7 @@ static bool CheckInvalidVLENandLMUL(const TargetInfo &TI, CallExpr *TheCall,
567
569
// Vscale is VLEN/RVVBitsPerBlock.
568
570
unsigned MinRequiredVLEN = VScaleFactor * llvm::RISCV::RVVBitsPerBlock;
569
571
std::string RequiredExt = " zvl" + std::to_string (MinRequiredVLEN) + " b" ;
570
- if (!TI.hasFeature (RequiredExt))
572
+ if (!TI.hasFeature (RequiredExt) && !FunctionFeatureMap. lookup (RequiredExt) )
571
573
return S.Diag (TheCall->getBeginLoc (),
572
574
diag::err_riscv_type_requires_extension)
573
575
<< Type << RequiredExt;
@@ -579,6 +581,10 @@ bool SemaRISCV::CheckBuiltinFunctionCall(const TargetInfo &TI,
579
581
unsigned BuiltinID,
580
582
CallExpr *TheCall) {
581
583
ASTContext &Context = getASTContext ();
584
+ const FunctionDecl *FD = SemaRef.getCurFunctionDecl ();
585
+ llvm::StringMap<bool > FunctionFeatureMap;
586
+ Context.getFunctionFeatureMap (FunctionFeatureMap, FD);
587
+
582
588
// vmulh.vv, vmulh.vx, vmulhu.vv, vmulhu.vx, vmulhsu.vv, vmulhsu.vx,
583
589
// vsmul.vv, vsmul.vx are not included for EEW=64 in Zve64*.
584
590
switch (BuiltinID) {
@@ -635,10 +641,6 @@ bool SemaRISCV::CheckBuiltinFunctionCall(const TargetInfo &TI,
635
641
ASTContext::BuiltinVectorTypeInfo Info = Context.getBuiltinVectorTypeInfo (
636
642
TheCall->getType ()->castAs <BuiltinType>());
637
643
638
- const FunctionDecl *FD = SemaRef.getCurFunctionDecl ();
639
- llvm::StringMap<bool > FunctionFeatureMap;
640
- Context.getFunctionFeatureMap (FunctionFeatureMap, FD);
641
-
642
644
if (Context.getTypeSize (Info.ElementType ) == 64 && !TI.hasFeature (" v" ) &&
643
645
!FunctionFeatureMap.lookup (" v" ))
644
646
return Diag (TheCall->getBeginLoc (),
@@ -714,20 +716,24 @@ bool SemaRISCV::CheckBuiltinFunctionCall(const TargetInfo &TI,
714
716
case RISCVVector::BI__builtin_rvv_vsm4k_vi_tu: {
715
717
QualType Arg0Type = TheCall->getArg (0 )->getType ();
716
718
QualType Arg1Type = TheCall->getArg (1 )->getType ();
717
- return CheckInvalidVLENandLMUL (TI, TheCall, SemaRef, Arg0Type, 128 ) ||
718
- CheckInvalidVLENandLMUL (TI, TheCall, SemaRef, Arg1Type, 128 ) ||
719
+ return CheckInvalidVLENandLMUL (TI, FunctionFeatureMap, TheCall, SemaRef,
720
+ Arg0Type, 128 ) ||
721
+ CheckInvalidVLENandLMUL (TI, FunctionFeatureMap, TheCall, SemaRef,
722
+ Arg1Type, 128 ) ||
719
723
SemaRef.BuiltinConstantArgRange (TheCall, 2 , 0 , 31 );
720
724
}
721
725
case RISCVVector::BI__builtin_rvv_vsm3c_vi_tu:
722
726
case RISCVVector::BI__builtin_rvv_vsm3c_vi: {
723
727
QualType Arg0Type = TheCall->getArg (0 )->getType ();
724
- return CheckInvalidVLENandLMUL (TI, TheCall, SemaRef, Arg0Type, 256 ) ||
728
+ return CheckInvalidVLENandLMUL (TI, FunctionFeatureMap, TheCall, SemaRef,
729
+ Arg0Type, 256 ) ||
725
730
SemaRef.BuiltinConstantArgRange (TheCall, 2 , 0 , 31 );
726
731
}
727
732
case RISCVVector::BI__builtin_rvv_vaeskf1_vi:
728
733
case RISCVVector::BI__builtin_rvv_vsm4k_vi: {
729
734
QualType Arg0Type = TheCall->getArg (0 )->getType ();
730
- return CheckInvalidVLENandLMUL (TI, TheCall, SemaRef, Arg0Type, 128 ) ||
735
+ return CheckInvalidVLENandLMUL (TI, FunctionFeatureMap, TheCall, SemaRef,
736
+ Arg0Type, 128 ) ||
731
737
SemaRef.BuiltinConstantArgRange (TheCall, 1 , 0 , 31 );
732
738
}
733
739
case RISCVVector::BI__builtin_rvv_vaesdf_vv:
@@ -754,8 +760,10 @@ bool SemaRISCV::CheckBuiltinFunctionCall(const TargetInfo &TI,
754
760
case RISCVVector::BI__builtin_rvv_vsm4r_vs_tu: {
755
761
QualType Arg0Type = TheCall->getArg (0 )->getType ();
756
762
QualType Arg1Type = TheCall->getArg (1 )->getType ();
757
- return CheckInvalidVLENandLMUL (TI, TheCall, SemaRef, Arg0Type, 128 ) ||
758
- CheckInvalidVLENandLMUL (TI, TheCall, SemaRef, Arg1Type, 128 );
763
+ return CheckInvalidVLENandLMUL (TI, FunctionFeatureMap, TheCall, SemaRef,
764
+ Arg0Type, 128 ) ||
765
+ CheckInvalidVLENandLMUL (TI, FunctionFeatureMap, TheCall, SemaRef,
766
+ Arg1Type, 128 );
759
767
}
760
768
case RISCVVector::BI__builtin_rvv_vsha2ch_vv:
761
769
case RISCVVector::BI__builtin_rvv_vsha2cl_vv:
@@ -769,17 +777,18 @@ bool SemaRISCV::CheckBuiltinFunctionCall(const TargetInfo &TI,
769
777
ASTContext::BuiltinVectorTypeInfo Info =
770
778
Context.getBuiltinVectorTypeInfo (Arg0Type->castAs <BuiltinType>());
771
779
uint64_t ElemSize = Context.getTypeSize (Info.ElementType );
772
- if (ElemSize == 64 && !TI.hasFeature (" zvknhb" ))
780
+ if (ElemSize == 64 && !TI.hasFeature (" zvknhb" ) &&
781
+ !FunctionFeatureMap.lookup (" zvknhb" ))
773
782
return Diag (TheCall->getBeginLoc (),
774
783
diag::err_riscv_builtin_requires_extension)
775
784
<< /* IsExtension */ true << TheCall->getSourceRange () << " zvknhb" ;
776
785
777
- return CheckInvalidVLENandLMUL (TI, TheCall, SemaRef, Arg0Type ,
778
- ElemSize * 4 ) ||
779
- CheckInvalidVLENandLMUL (TI, TheCall, SemaRef, Arg1Type ,
780
- ElemSize * 4 ) ||
781
- CheckInvalidVLENandLMUL (TI, TheCall, SemaRef, Arg2Type ,
782
- ElemSize * 4 );
786
+ return CheckInvalidVLENandLMUL (TI, FunctionFeatureMap, TheCall, SemaRef ,
787
+ Arg0Type, ElemSize * 4 ) ||
788
+ CheckInvalidVLENandLMUL (TI, FunctionFeatureMap, TheCall, SemaRef ,
789
+ Arg1Type, ElemSize * 4 ) ||
790
+ CheckInvalidVLENandLMUL (TI, FunctionFeatureMap, TheCall, SemaRef ,
791
+ Arg2Type, ElemSize * 4 );
783
792
}
784
793
785
794
case RISCVVector::BI__builtin_rvv_sf_vc_i_se:
0 commit comments