llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-backend-risc-v Author: Brandon Wu (4vtomat) <details> <summary>Changes</summary> zvknhb now implies zvknha so we dont need to check extensions manually in SemaRISCV, we can just use RequiredFeatures instead. --- Full diff: https://github.com/llvm/llvm-project/pull/186993.diff 3 Files Affected: - (modified) clang/include/clang/Basic/riscv_vector.td (+13-5) - (modified) clang/lib/Sema/SemaRISCV.cpp (-12) - (modified) clang/test/Sema/zvk-invalid-features.c (+10-5) ``````````diff diff --git a/clang/include/clang/Basic/riscv_vector.td b/clang/include/clang/Basic/riscv_vector.td index 6d45e6ca94cd1..5e4edbe01f1cd 100644 --- a/clang/include/clang/Basic/riscv_vector.td +++ b/clang/include/clang/Basic/riscv_vector.td @@ -2080,11 +2080,19 @@ let UnMaskedPolicyScheme = HasPolicyOperand, HasMasked = false in { defm vaesz : RVVOutBuiltinSetZvk<HasVV=0>; } - // zvknha and zvknhb has duplicated intrinsic but they don't imply each other, - // so we need to handle it manually in SemaRISCV.cpp. - defm vsha2ch : RVVOutOp2BuiltinSetVVZvk<"il">; - defm vsha2cl : RVVOutOp2BuiltinSetVVZvk<"il">; - defm vsha2ms : RVVOutOp2BuiltinSetVVZvk<"il">; + // zvknha + let RequiredFeatures = ["zvknha"] in { + defm vsha2ch : RVVOutOp2BuiltinSetVVZvk<"i">; + defm vsha2cl : RVVOutOp2BuiltinSetVVZvk<"i">; + defm vsha2ms : RVVOutOp2BuiltinSetVVZvk<"i">; + } + + // zvknhb + let RequiredFeatures = ["zvknhb"] in { + defm vsha2ch : RVVOutOp2BuiltinSetVVZvk<"l">; + defm vsha2cl : RVVOutOp2BuiltinSetVVZvk<"l">; + defm vsha2ms : RVVOutOp2BuiltinSetVVZvk<"l">; + } // zvksed let RequiredFeatures = ["zvksed"] in { diff --git a/clang/lib/Sema/SemaRISCV.cpp b/clang/lib/Sema/SemaRISCV.cpp index d5512f216ddb3..3cf5a0963b39c 100644 --- a/clang/lib/Sema/SemaRISCV.cpp +++ b/clang/lib/Sema/SemaRISCV.cpp @@ -839,18 +839,6 @@ bool SemaRISCV::CheckBuiltinFunctionCall(const TargetInfo &TI, ASTContext::BuiltinVectorTypeInfo Info = Context.getBuiltinVectorTypeInfo(Arg0Type->castAs<BuiltinType>()); uint64_t ElemSize = Context.getTypeSize(Info.ElementType); - if (ElemSize == 64 && !TI.hasFeature("zvknhb") && - !FunctionFeatureMap.lookup("zvknhb")) - return Diag(TheCall->getBeginLoc(), - diag::err_riscv_builtin_requires_extension) - << /* IsExtension */ true << TheCall->getSourceRange() << "zvknhb"; - // If ElemSize is 32, check at least zvknha or zvknhb is enabled. - if (!TI.hasFeature("zvknha") && !FunctionFeatureMap.lookup("zvknha") && - !TI.hasFeature("zvknhb") && !FunctionFeatureMap.lookup("zvknhb")) - return Diag(TheCall->getBeginLoc(), - diag::err_riscv_builtin_requires_extension) - << /* IsExtension */ true << TheCall->getSourceRange() - << "zvknha or zvknhb"; return CheckInvalidVLENandLMUL(TI, FunctionFeatureMap, TheCall, SemaRef, Arg0Type, ElemSize * 4) || diff --git a/clang/test/Sema/zvk-invalid-features.c b/clang/test/Sema/zvk-invalid-features.c index 4b666b4480f73..4c51e1547f828 100644 --- a/clang/test/Sema/zvk-invalid-features.c +++ b/clang/test/Sema/zvk-invalid-features.c @@ -3,7 +3,7 @@ #include <riscv_vector.h> -void test_zvk_features(vuint32m4_t vd, vuint32m4_t vs2, vuint32m4_t vs1, vuint64m1_t vs2_64, vuint64m1_t vs1_64, size_t vl) { +void test_zvk_features(vuint32m4_t vd, vuint32m4_t vs2, vuint32m4_t vs1, vuint64m1_t vd_64, vuint64m1_t vs2_64, vuint64m1_t vs1_64, size_t vl) { // zvbb __riscv_vbrev(vs2, vl); // expected-error {{builtin requires at least one of the following extensions: zvbb}} __riscv_vclz(vs2, vl); // expected-error {{builtin requires at least one of the following extensions: zvbb}} @@ -35,10 +35,15 @@ void test_zvk_features(vuint32m4_t vd, vuint32m4_t vs2, vuint32m4_t vs1, vuint64 __riscv_vaeskf2(vd, vs2, 0, vl); // expected-error {{builtin requires at least one of the following extensions: zvkned}} __riscv_vaesz(vd, vs2, vl); // expected-error {{builtin requires at least one of the following extensions: zvkned}} - // zvknha or zvknhb - __riscv_vsha2ch(vd, vs2, vs1, vl); // expected-error {{builtin requires at least one of the following extensions: zvknha or zvknhb}} - __riscv_vsha2cl(vd, vs2, vs1, vl); // expected-error {{builtin requires at least one of the following extensions: zvknha or zvknhb}} - __riscv_vsha2ms(vd, vs2, vs1, vl); // expected-error {{builtin requires at least one of the following extensions: zvknha or zvknhb}} + // zvknha + __riscv_vsha2ch(vd, vs2, vs1, vl); // expected-error {{builtin requires at least one of the following extensions: zvknha}} + __riscv_vsha2cl(vd, vs2, vs1, vl); // expected-error {{builtin requires at least one of the following extensions: zvknha}} + __riscv_vsha2ms(vd, vs2, vs1, vl); // expected-error {{builtin requires at least one of the following extensions: zvknha}} + + // zvknhb + __riscv_vsha2ch(vd_64, vs2_64, vs1_64, vl); // expected-error {{builtin requires at least one of the following extensions: zvknhb}} + __riscv_vsha2cl(vd_64, vs2_64, vs1_64, vl); // expected-error {{builtin requires at least one of the following extensions: zvknhb}} + __riscv_vsha2ms(vd_64, vs2_64, vs1_64, vl); // expected-error {{builtin requires at least one of the following extensions: zvknhb}} //zvksed __riscv_vsm4k(vs2, 0, vl); // expected-error {{builtin requires at least one of the following extensions: zvksed}} `````````` </details> https://github.com/llvm/llvm-project/pull/186993 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
