Christoph Müllner <[email protected]> 於 2026年5月18日週一 下午8:18寫道: > > RISC-V C API pull request #183 specifies macros that let users > detect compiler support for intrinsic APIs independent of -march: > https://github.com/riscv-non-isa/riscv-c-api-doc/pull/183 > > Define __riscv_intrinsic_<extension> macros in the corresponding > RISC-V intrinsic headers. The macros describe compiler support for > an intrinsic API and do not depend on whether the related ISA > extension is enabled by -march. > > Derive scalar composite macros from their component macros so they > are only defined when all component intrinsic headers have been > included. > > gcc/ > * config/riscv/andes_vector.h: Define intrinsic detection macros. > * config/riscv/riscv_bitmanip.h: Likewise. > * config/riscv/riscv_crypto.h: Likewise. > * config/riscv/riscv_vector.h: Likewise. > * config/riscv/sifive_vector.h: Likewise. > * doc/extend.texi: Document RISC-V intrinsic detection macros. > > gcc/testsuite/ > * gcc.target/riscv/intrinsic-detection-bitmanip.c: New test. > * gcc.target/riscv/intrinsic-detection-crypto.c: New test. > * gcc.target/riscv/intrinsic-detection-scalar-reverse.c: New test. > * gcc.target/riscv/intrinsic-detection-scalar.c: New test. > * gcc.target/riscv/rvv/base/intrinsic-detection.c: New test. > > Signed-off-by: Christoph Müllner <[email protected]> > --- > gcc/config/riscv/andes_vector.h | 5 + > gcc/config/riscv/riscv_bitmanip.h | 27 +++++- > gcc/config/riscv/riscv_crypto.h | 25 +++++ > gcc/config/riscv/riscv_vector.h | 48 ++++++++++ > gcc/config/riscv/sifive_vector.h | 5 + > gcc/doc/extend.texi | 10 ++ > .../riscv/intrinsic-detection-bitmanip.c | 30 ++++++ > .../riscv/intrinsic-detection-crypto.c | 30 ++++++ > .../intrinsic-detection-scalar-reverse.c | 13 +++ > .../riscv/intrinsic-detection-scalar.c | 44 +++++++++ > .../riscv/rvv/base/intrinsic-detection.c | 91 +++++++++++++++++++ > 11 files changed, 327 insertions(+), 1 deletion(-) > create mode 100644 > gcc/testsuite/gcc.target/riscv/intrinsic-detection-bitmanip.c > create mode 100644 > gcc/testsuite/gcc.target/riscv/intrinsic-detection-crypto.c > create mode 100644 > gcc/testsuite/gcc.target/riscv/intrinsic-detection-scalar-reverse.c > create mode 100644 > gcc/testsuite/gcc.target/riscv/intrinsic-detection-scalar.c > create mode 100644 > gcc/testsuite/gcc.target/riscv/rvv/base/intrinsic-detection.c > > diff --git a/gcc/config/riscv/andes_vector.h b/gcc/config/riscv/andes_vector.h > index 712ca77c27c..94355aec271 100644 > --- a/gcc/config/riscv/andes_vector.h > +++ b/gcc/config/riscv/andes_vector.h > @@ -25,6 +25,11 @@ > #ifndef __ANDES_VECTOR_H > #define __ANDES_VECTOR_H > > +#define __riscv_intrinsic_xandesvbfhcvt 1 > +#define __riscv_intrinsic_xandesvdot 1 > +#define __riscv_intrinsic_xandesvpackfph 1 > +#define __riscv_intrinsic_xandesvsintload 1 > + > /* TODO: This should have a separate pragma to include only the Andes > vector intrinsics. For now, we are including riscv_vector.h. */ > #include <riscv_vector.h> > diff --git a/gcc/config/riscv/riscv_bitmanip.h > b/gcc/config/riscv/riscv_bitmanip.h > index ea0eb4fd6af..3cc9b7034d5 100644 > --- a/gcc/config/riscv/riscv_bitmanip.h > +++ b/gcc/config/riscv/riscv_bitmanip.h > @@ -27,6 +27,31 @@ > > #include <stdint.h> > > +#define __riscv_intrinsic_zbb 1 > +#define __riscv_intrinsic_zbc 1 > +#define __riscv_intrinsic_zbkb 1 > +#define __riscv_intrinsic_zbkc 1 > +#define __riscv_intrinsic_zbkx 1 > + > +#if !defined (__riscv_intrinsic_zkn) \ > + && defined (__riscv_intrinsic_zbkb) \ > + && defined (__riscv_intrinsic_zbkc) \ > + && defined (__riscv_intrinsic_zbkx) \ > + && defined (__riscv_intrinsic_zknd) \ > + && defined (__riscv_intrinsic_zkne) \ > + && defined (__riscv_intrinsic_zknh) > +#define __riscv_intrinsic_zkn 1 > +#endif
I was thinking why these if-defined statements were needed, but I realized it was because these macros are distributed in riscv_crypto.h and riscv_bitmanip.h soon. LGTM, thanks for the patch, I was plan to send one, but found you already send out :)
