llvm-project/clang/test/Sema/zvk-target-attributes.c
Brandon Wu 9312d5beb3
[llvm][RISCV] Handle required features of intrinsic correctly (#143062)
Current approach generates intrinsic records when users specify
corresponding required features by using command line option.
However it's not able to handle features passed by using target
attributes correctly where each function might have different
features.
This patch resolves this by generating all of intrinsic records which
carry the required features in their function declaration using
attribute and check the required extensions in CheckBuiltinFunctionCall.

This should fix
[56592](https://github.com/llvm/llvm-project/issues/56592),
[134962](https://github.com/llvm/llvm-project/issues/134962) and
[121603](https://github.com/llvm/llvm-project/issues/121603)
2025-06-10 15:59:15 +08:00

36 lines
1004 B
C

// REQUIRES: riscv-registered-target
// RUN: %clang_cc1 -triple riscv64 -target-feature +zvknha %s -fsyntax-only -verify
#include <riscv_vector.h>
// expected-no-diagnostics
__attribute__((target("arch=+zvl128b")))
void test_zvk_features(vuint32m1_t vd, vuint32m1_t vs2, vuint32m1_t vs1, size_t vl) {
__riscv_vsha2ch_vv_u32m1(vd, vs2, vs1, vl);
}
__attribute__((target("arch=+v,+zvkn")))
vuint32m4_t testcase1(vuint32m4_t pt, vuint32m1_t rk, size_t vl)
{
return __riscv_vaesz_vs_u32m1_u32m4(pt, rk, vl);
}
__attribute__((target("arch=+v,+zvknc")))
vuint32m4_t testcase2(vuint32m4_t pt, vuint32m1_t rk, size_t vl)
{
return __riscv_vaesz_vs_u32m1_u32m4(pt, rk, vl);
}
__attribute__((target("arch=+v,+zvkned")))
vuint32m4_t testcase3(vuint32m4_t pt, vuint32m1_t rk, size_t vl)
{
return __riscv_vaesz_vs_u32m1_u32m4(pt, rk, vl);
}
__attribute__((target("arch=+v,+zvkng")))
vuint32m4_t testcase4(vuint32m4_t pt, vuint32m1_t rk, size_t vl)
{
return __riscv_vaesz_vs_u32m1_u32m4(pt, rk, vl);
}