This is an archive of the discontinued LLVM Phabricator instance.

Define sys::getHostCPUName for RISC-V
ClosedPublic

Authored by schwab on Jul 1 2021, 5:21 AM.

Details

Summary

The RISCV target doesn't define a "generic" cpu, only "generic-rv32" and
"generic-rv64". Define sys::getHostCPUName for RISC-V that returns the
correct cpu for the host.

Diff Detail

Event Timeline

schwab created this revision.Jul 1 2021, 5:21 AM
schwab requested review of this revision.Jul 1 2021, 5:21 AM
craig.topper added inline comments.Jul 1 2021, 9:48 AM
llvm/lib/Support/Host.cpp
1361

Should we check riscv_xlen == 32 here and leave some assert return "generic" if its not one of the 2 values. That would cover us better if riscv_xlen isn't defined for some reason

1452

Just curious why other linux platforms like x86 and power pc have a different solution?

schwab added inline comments.Jul 7 2021, 7:39 AM
llvm/lib/Support/Host.cpp
1361

What do you want to assert?

craig.topper added inline comments.Jul 7 2021, 9:12 AM
llvm/lib/Support/Host.cpp
1361

I was thinking something like

#if __riscv_xlen == 64
  return "generic-rv64";
#elsif __riscv_xlen == 32
  return "generic-rv32";
#else
  assert(false && "Couldn't determine xlen")
  return "generic";
schwab updated this revision to Diff 357468.Jul 9 2021, 3:27 AM

Added assert.

This revision is now accepted and ready to land.Jul 9 2021, 3:44 PM

Not sure if this wouldn't (eventually) be an issue also for RISC-V? https://reviews.llvm.org/rGcd53ded557c3

MaskRay requested changes to this revision.Jul 11 2021, 10:48 AM

Not sure if this wouldn't (eventually) be an issue also for RISC-V? https://reviews.llvm.org/rGcd53ded557c3

Yes, it needs to be fixed.

This revision now requires changes to proceed.Jul 11 2021, 10:48 AM
schwab updated this revision to Diff 357812.Jul 11 2021, 11:07 AM

Drop computeHostNumPhysicalCores change for now.

schwab edited the summary of this revision. (Show Details)Jul 11 2021, 11:09 AM
MaskRay added inline comments.Jul 11 2021, 11:29 AM
llvm/lib/Support/Host.cpp
1361

clang/gcc always define __riscv_xlen. Should be fine to use #error for the code path.

schwab updated this revision to Diff 360899.Jul 22 2021, 11:28 AM

Use #error.

MaskRay accepted this revision.Jul 23 2021, 8:42 AM
MaskRay added inline comments.
llvm/lib/Support/Host.cpp
1365

remove

the return value is unused due to #error.

This revision is now accepted and ready to land.Jul 23 2021, 8:42 AM
schwab updated this revision to Diff 364748.Aug 6 2021, 4:07 AM

Remove dead return.

MaskRay accepted this revision.Aug 9 2021, 12:07 PM
schwab added a comment.Oct 8 2021, 6:26 AM

What is the next step?

What is the next step?

Sorry, we didn't know you didn't have commit access. I can commit this for you. How would you like your name and email to appear in the git log?

Andreas Schwab <schwab@suse.de>

This revision was automatically updated to reflect the committed changes.

What is the next step?

Thanks. I pushed it on your behalf. A contributor who doesn't have commit access can ask a reviewer or others to push. Your account was registered in 2019 so we probably assumed that you have commit access :)