This is an archive of the discontinued LLVM Phabricator instance.

[Support] Handle SPARC in sys::getHostCPUName
ClosedPublic

Authored by ro on Jul 21 2022, 7:25 AM.

Details

Summary

While working on 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 T5/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)

Diff Detail

Event Timeline

ro created this revision.Jul 21 2022, 7:25 AM
ro requested review of this revision.Jul 21 2022, 7:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 21 2022, 7:25 AM

Ping? It's been a week. Thanks.

LGTM, but I don't really know enough to review the Solaris-specific bits.

The code style looks good to me, but I cannot verify the list. @glaubitz should have sparc machines and perform some verification.

ro added a comment.Jul 26 2022, 12:51 PM

LGTM, but I don't really know enough to review the Solaris-specific bits.

They are taken straight from my 2011 GCC patch (and follow-ups) that introduced the code in gcc/config/sparc/driver-sparc.cc. I've just adapted them to match LLVM coding conventions as far as necessary.

The code style looks good to me, but I cannot verify the list. @glaubitz should have sparc machines and perform some verification.

Both lists are straight from driver-sparc.cc, with the noted exceptions of not emitting CPU types LLVM doesn't support (yet?). On the Linux/sparc64 side I've meanwhile set up a Debian 11 LDom on a SPARC Enterprise T5220, where the values also match. In addition, I've looked at current Linux kernel sources (arch/sparc/kernel/cpu.c, arch/sparc/include/asm/spitfire.h) and found three unhandled CPUs:

  • SPARC-M6: might be handled as niagara4; GCC knows nothing about this
  • SPARC-SN: never even heard of this
  • SPARC64-X: Fujitsu SPARC CPU, no idea how to handle this either

Unless someone else can chime in on those, I'd leave them alone.

MaskRay accepted this revision.Jul 26 2022, 12:54 PM
This revision is now accepted and ready to land.Jul 26 2022, 12:54 PM

The code style looks good to me, but I cannot verify the list. @glaubitz should have sparc machines and perform some verification.

@ro tested it on the same machines from the GCC compile farm that I would have used. So I think it's not necessary for me to test the changes as well. :-)

This revision was landed with ongoing or failed builds.Jul 27 2022, 3:22 AM
This revision was automatically updated to reflect the committed changes.