Files
clang-p2996/clang/test/Preprocessor/has_builtin_cpuid.c
Pengcheng Wang 875b10f7d0 [RISCV] Support __builtin_cpu_is
We have defined `__riscv_cpu_model` variable in #101449. It contains
`mvendorid`, `marchid` and `mimpid` fields which are read via system
call `sys_riscv_hwprobe`.

We can support `__builtin_cpu_is` via comparing values in compiler's
CPU definitions and `__riscv_cpu_model`.

This depends on #116202.

Reviewers: lenary, BeMg, kito-cheng, preames, lukel97

Reviewed By: lenary

Pull Request: https://github.com/llvm/llvm-project/pull/116231
2024-11-22 22:58:54 +08:00

31 lines
962 B
C

// RUN: %clang_cc1 -fsyntax-only -triple arm64-- -DARM -verify %s
// RUN: %clang_cc1 -fsyntax-only -triple x86_64-- -DX86 -verify %s
// RUN: %clang_cc1 -fsyntax-only -triple powerpc64-unknown-linux-gnu -DPPC \
// RUN: -verify %s
// RUN: %clang_cc1 -fsyntax-only -triple riscv32-unknown-linux-gnu -DRISCV \
// RUN: -verify %s
// RUN: %clang_cc1 -fsyntax-only -triple riscv64-unknown-linux-gnu -DRISCV \
// RUN: -verify %s
// expected-no-diagnostics
#if __has_builtin(__builtin_cpu_is)
# if defined(ARM)
# error "ARM shouldn't have __builtin_cpu_is"
# endif
#endif
#if __has_builtin(__builtin_cpu_init)
# if defined(ARM) || defined(PPC)
# error "ARM/PPC shouldn't have __builtin_cpu_init"
# endif
#else
# ifdef RISCV
# error "RISCV should have __builtin_cpu_init"
# endif
#endif
#if !__has_builtin(__builtin_cpu_supports)
# if defined(ARM) || defined(X86) || defined(RISCV)
# error "ARM/X86/RISCV should have __builtin_cpu_supports"
# endif
#endif