[PATCH] D105274: Define sys::getHostCPUName for RISC-V
Andreas Schwab via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 1 05:21:56 PDT 2021
schwab created this revision.
schwab added a reviewer: LLVM.
schwab added a project: LLVM.
Herald added subscribers: vkmr, dexonsmith, luismarques, sameer.abuasal, s.egerton, Jim, PkmX, rogfer01, shiva0217, kito-cheng, simoncook, hiraditya, krytarowski.
schwab requested review of this revision.
Herald added a subscriber: llvm-commits.
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. Also define computeHostNumPhysicalCores that
works for Linux.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D105274
Files:
llvm/lib/Support/Host.cpp
Index: llvm/lib/Support/Host.cpp
===================================================================
--- llvm/lib/Support/Host.cpp
+++ llvm/lib/Support/Host.cpp
@@ -1318,6 +1318,14 @@
return "generic";
}
}
+#elif defined(__riscv)
+StringRef sys::getHostCPUName() {
+#if __riscv_xlen == 64
+ return "generic-rv64";
+#else
+ return "generic-rv32";
+#endif
+}
#else
StringRef sys::getHostCPUName() { return "generic"; }
namespace llvm {
@@ -1402,7 +1410,7 @@
}
return -1;
}
-#elif defined(__linux__) && defined(__s390x__)
+#elif defined(__linux__) && (defined(__s390x__) || defined(__riscv))
int computeHostNumPhysicalCores() { return sysconf(_SC_NPROCESSORS_ONLN); }
#elif defined(__APPLE__) && defined(__x86_64__)
#include <sys/param.h>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105274.355845.patch
Type: text/x-patch
Size: 760 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210701/f4f05950/attachment.bin>
More information about the llvm-commits
mailing list