RISC-V: Enable -mtune=native and -mcpu=native
GCC now supports -mtune=native and -mcpu=native for RISC-V, detecting the host CPU.
GCC’s RISC-V backend now supports -mtune=native and -mcpu=native flags. This allows the compiler to automatically detect the host CPU’s architecture and tuning parameters by inspecting hwprobe or /proc/cpuinfo. The flags behave similarly to other architectures, overriding compiler defaults without affecting explicitly set -march or -mtune values.
In Details
This commit enhances the RISC-V target driver to support -mtune=native and -mcpu=native. It introduces logic to identify the running CPU based on mvendorid, marchid, and mimpid registers, querying hwprobe or /proc/cpuinfo when necessary. The implementation ensures these flags act as runtime CPU detectors, respecting explicit -march and -mtune settings and handling potential VLEN differences in multi-core systems.