[llvm] a706a5e - [Support] Define sys::getHostCPUName for RISC-V

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 8 10:08:44 PDT 2021


Author: Andreas Schwab
Date: 2021-10-08T10:08:39-07:00
New Revision: a706a5ef225125e4afd37c7709cf697514cd2187

URL: https://github.com/llvm/llvm-project/commit/a706a5ef225125e4afd37c7709cf697514cd2187
DIFF: https://github.com/llvm/llvm-project/commit/a706a5ef225125e4afd37c7709cf697514cd2187.diff

LOG: [Support] Define sys::getHostCPUName for RISC-V

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.

Reviewed By: craig.topper, MaskRay

Differential Revision: https://reviews.llvm.org/D105274

Added: 
    

Modified: 
    llvm/lib/Support/Host.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Support/Host.cpp b/llvm/lib/Support/Host.cpp
index 20de52cbc0c48..7b14616f6fea5 100644
--- a/llvm/lib/Support/Host.cpp
+++ b/llvm/lib/Support/Host.cpp
@@ -1356,6 +1356,16 @@ StringRef sys::getHostCPUName() {
     return "generic";
   }
 }
+#elif defined(__riscv)
+StringRef sys::getHostCPUName() {
+#if __riscv_xlen == 64
+  return "generic-rv64";
+#elif __riscv_xlen == 32
+  return "generic-rv32";
+#else
+#error "Unhandled value of __riscv_xlen"
+#endif
+}
 #else
 StringRef sys::getHostCPUName() { return "generic"; }
 namespace llvm {


        


More information about the llvm-commits mailing list