================ @@ -2002,6 +2003,76 @@ bool sys::getHostCPUFeatures(StringMap<bool> &Features) { return true; } +#elif defined(__linux__) && defined(__riscv) +// struct riscv_hwprobe +struct RISCVHwProbe { + int64_t Key; + uint64_t Value; +}; +bool sys::getHostCPUFeatures(StringMap<bool> &Features) { + RISCVHwProbe Query[]{{/*RISCV_HWPROBE_KEY_BASE_BEHAVIOR=*/3, 0}, + {/*RISCV_HWPROBE_KEY_IMA_EXT_0=*/4, 0}}; + int Ret = syscall(/*__NR_riscv_hwprobe=*/258, /*pairs=*/Query, ---------------- dtcxzyw wrote:
Currently `sys::getHostCPUFeatures` has three callers: + clang -> `riscv::getRISCVTargetFeatures` + llvm-tools -> `codegen::getFeaturesStr` + JIT users -> `JITTargetMachineBuilder::detectHost` I don't think there are any opportunities to reuse the result. BTW, https://github.com/llvm/llvm-project/pull/85790 may benefit from the vDSO symbol, but it implements caching itself. I didn't use the glibc call `__riscv_hwprobe` since `sys/hwprobe.h` was unavailable on my RV board :( https://github.com/llvm/llvm-project/pull/94352 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits