[Support] Handle SPARC in sys::getHostCPUName
authorRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Wed, 27 Jul 2022 10:21:03 +0000 (12:21 +0200)
committerRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Wed, 27 Jul 2022 10:21:03 +0000 (12:21 +0200)
commit979ddfff37d7e3bf258c2e5cbdc272fcb44c15f0
tree8555e1bfb341b818d60dcb413ed37f386ca8a1f1
parentd3fc779e4295b0bf726008580ddd99c8e86c2c0c
[Support] Handle SPARC in sys::getHostCPUName

While working on D118450 <https://reviews.llvm.org/D118450>, I noticed that
`sys::getHostCPUName` lacks SPARC support.

This patch implements it.  The code is taken from/inspired by GCC's
`gcc/config/sparc/driver-sparc.cc`.  There's one caveat: since LLVM, unlike
GCC, doesn't support the SPARC-M7, -S7, and -M8 CPUs, I map all those to
the latest supported one (UltraSparc T4/`niagara4`).

Tested on `sparcv9-sun-solaris2.11` and `sparc64-unknown-linux-gnu` by
running `savcov --version` on

- Netra SPARC S7-2 (SPARC-S7, Solaris 11.4)
- SPARC T5-2 (SPARC T5, Solaris 11.4)
- SPARC Enterprise T5220 (UltraSPARC T2, Solaris 11.3)
- SPARC T5 (UltraSPARC T5, Debian sid)
- SPARC T3 (UltraSPARC T3, Debian sid)
- SPARC Enterprise T5220 (Debian sid)

Differential Revision: https://reviews.llvm.org/D130272
llvm/include/llvm/Support/Host.h
llvm/lib/Support/CMakeLists.txt
llvm/lib/Support/Host.cpp