<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/121603>121603</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [RISC-V] attribute target arch=+zvkn doesn't add builtins
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          antonblanchard
      </td>
    </tr>
</table>

<pre>
    All of these fail when building with `-march=rv64gc`:

```
#include <riscv_vector.h>

__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);
}
```
with:
```
zvkned.c:6:9: error: call to undeclared function '__riscv_vaesz_vs_u32m1_u32m4'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
    6 |         return __riscv_vaesz_vs_u32m1_u32m4(pt, rk, vl);
      | ^
zvkned.c:6:9: error: returning 'int' from a function with incompatible result type 'vuint32m4_t' (aka '__rvv_uint32m4_t')
    6 |         return __riscv_vaesz_vs_u32m1_u32m4(pt, rk, vl);
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
zvkned.c:12:9: error: call to undeclared function '__riscv_vaesz_vs_u32m1_u32m4'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
 12 |         return __riscv_vaesz_vs_u32m1_u32m4(pt, rk, vl);
      | ^
zvkned.c:12:9: error: returning 'int' from a function with incompatible result type 'vuint32m4_t' (aka '__rvv_uint32m4_t')
   12 | return __riscv_vaesz_vs_u32m1_u32m4(pt, rk, vl);
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
zvkned.c:18:9: error: call to undeclared function '__riscv_vaesz_vs_u32m1_u32m4'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
 18 |         return __riscv_vaesz_vs_u32m1_u32m4(pt, rk, vl);
      | ^
zvkned.c:18:9: error: returning 'int' from a function with incompatible result type 'vuint32m4_t' (aka '__rvv_uint32m4_t')
   18 | return __riscv_vaesz_vs_u32m1_u32m4(pt, rk, vl);
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
zvkned.c:24:9: error: call to undeclared function '__riscv_vaesz_vs_u32m1_u32m4'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
 24 |         return __riscv_vaesz_vs_u32m1_u32m4(pt, rk, vl);
      | ^
zvkned.c:24:9: error: returning 'int' from a function with incompatible result type 'vuint32m4_t' (aka '__rvv_uint32m4_t')
   24 | return __riscv_vaesz_vs_u32m1_u32m4(pt, rk, vl);
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 errors generated.
```

It works with `-march=rv64gcv_zvkn`

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzUV01v4zYQ_TWjy8AGRUqydNDBH2sgpwJdoD0KFMVYbGjKIEcKNof-9kIfabzttg2KNl4LhE1Q5Bu-p0diRoZgTk7rEtIdpIdI9tR2vpSOOldb6VQrfRPVXfOl3FqL3SNSq4PGR2ksPrfaYd0b2xh3wmdDLULGVmfpVQvi4IcsOSnIGIgtsKllbGlsC1wYp2zfaASx9yaooRq0os6vWxCf5gVVJYm8qXvSVQU8B56T9CdNU58vgYDvBuB74LuX4ckB58CLpbHt0BtHgp-TipB0ICWDjoHn1-MXAr7H15G4IvRP40gwL7oiHOwMBZsdsC0uj9fUe4dVtexd6vBSDaHqJ4jxNwGez9Az3IwjdhPU4d8zVO-gyO-bom7ewVHcN8fTOygm3wvFq5M7HvTlSF-Nzl9trUBsMxDbAsQWtfedHztKWovUYe8araz0usHH3ikynUPgm7_f2QbEDh8-_4D7okDpGrSStMemQ9cRhv5y6TyhOV-sUYbegOdQcuwHhHS3-vl1zup1zupqDqSHRbMMYbPH_0S9GWKEg_TTP6k0RxrvUuAb4wj4Bh99d0b5Rmq6ZY1T3fkiydRWo9eht4T05aLHdVduGdcDz-WTXEQehuqrt7NZ_k_Kv77v-VqZmN-zgWL-Ifb5hki388_C-da-ye_aN_nH-ObPIt3QN_n34Bue3LNvePIhvvmGSLfzzcL5Fr7JZ_4BT9ppL0k36z9WNmz7QPjc-afwV0XRUE2VyjQ9akrRFKKQkS7jjUgLkReMR20Zy0ymac6yOIkVKzTjtVBZo4paxIIldWRKznjKYiZ4HKeMr1mSyCQXtWJ6kya1gITpszR2be1wXnf-FJkQel3GPM6YiKystQ1T6ce50884vR2z0vQQ-XJctKr7U4CEWRMovMGQITvVjD8-fN6vfoL0gL_nvzgnvviW845csel0cMA3hLJppqqRjAtR723ZEl3CmFHyI_DjyVDb12vVnYEfx4jL3-riu1-0IuDHaZ8B-HEhMpT8twAAAP__vve08A">