[clang] dacbddf - [RISCV] Move isValidCPUName to RISCVTargetInfo. NFC

Craig Topper via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 11 10:02:02 PDT 2022


Author: Craig Topper
Date: 2022-08-11T10:01:56-07:00
New Revision: dacbddf56205f90e33d39575fc9d8455458d851e

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

LOG: [RISCV] Move isValidCPUName to RISCVTargetInfo. NFC

Instead of having separate implementations for RV32 and RV64,
use the triple to control the Is64Bit parameter.

Do the same for isValidTuneCPUName, fillValidCPUList, and
fillValidTuneCPUList.

Added: 
    

Modified: 
    clang/lib/Basic/Targets/RISCV.cpp
    clang/lib/Basic/Targets/RISCV.h

Removed: 
    


################################################################################
diff  --git a/clang/lib/Basic/Targets/RISCV.cpp b/clang/lib/Basic/Targets/RISCV.cpp
index 7e6c0620385a1..d1a9741eb568e 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -285,44 +285,25 @@ bool RISCVTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
   return true;
 }
 
-bool RISCV32TargetInfo::isValidCPUName(StringRef Name) const {
-  return llvm::RISCV::checkCPUKind(llvm::RISCV::parseCPUKind(Name),
-                                   /*Is64Bit=*/false);
+bool RISCVTargetInfo::isValidCPUName(StringRef Name) const {
+  bool Is64Bit = getTriple().isArch64Bit();
+  return llvm::RISCV::checkCPUKind(llvm::RISCV::parseCPUKind(Name), Is64Bit);
 }
 
-void RISCV32TargetInfo::fillValidCPUList(
+void RISCVTargetInfo::fillValidCPUList(
     SmallVectorImpl<StringRef> &Values) const {
-  llvm::RISCV::fillValidCPUArchList(Values, false);
+  bool Is64Bit = getTriple().isArch64Bit();
+  llvm::RISCV::fillValidCPUArchList(Values, Is64Bit);
 }
 
-bool RISCV32TargetInfo::isValidTuneCPUName(StringRef Name) const {
+bool RISCVTargetInfo::isValidTuneCPUName(StringRef Name) const {
+  bool Is64Bit = getTriple().isArch64Bit();
   return llvm::RISCV::checkTuneCPUKind(
-      llvm::RISCV::parseTuneCPUKind(Name, false),
-      /*Is64Bit=*/false);
+      llvm::RISCV::parseTuneCPUKind(Name, Is64Bit), Is64Bit);
 }
 
-void RISCV32TargetInfo::fillValidTuneCPUList(
+void RISCVTargetInfo::fillValidTuneCPUList(
     SmallVectorImpl<StringRef> &Values) const {
-  llvm::RISCV::fillValidTuneCPUArchList(Values, false);
-}
-
-bool RISCV64TargetInfo::isValidCPUName(StringRef Name) const {
-  return llvm::RISCV::checkCPUKind(llvm::RISCV::parseCPUKind(Name),
-                                   /*Is64Bit=*/true);
-}
-
-void RISCV64TargetInfo::fillValidCPUList(
-    SmallVectorImpl<StringRef> &Values) const {
-  llvm::RISCV::fillValidCPUArchList(Values, true);
-}
-
-bool RISCV64TargetInfo::isValidTuneCPUName(StringRef Name) const {
-  return llvm::RISCV::checkTuneCPUKind(
-      llvm::RISCV::parseTuneCPUKind(Name, true),
-      /*Is64Bit=*/true);
-}
-
-void RISCV64TargetInfo::fillValidTuneCPUList(
-    SmallVectorImpl<StringRef> &Values) const {
-  llvm::RISCV::fillValidTuneCPUArchList(Values, true);
+  bool Is64Bit = getTriple().isArch64Bit();
+  llvm::RISCV::fillValidTuneCPUArchList(Values, Is64Bit);
 }

diff  --git a/clang/lib/Basic/Targets/RISCV.h b/clang/lib/Basic/Targets/RISCV.h
index 7817e6e81e26a..21c5e7ab795b2 100644
--- a/clang/lib/Basic/Targets/RISCV.h
+++ b/clang/lib/Basic/Targets/RISCV.h
@@ -100,6 +100,11 @@ class RISCVTargetInfo : public TargetInfo {
   bool useFP16ConversionIntrinsics() const override {
     return false;
   }
+
+  bool isValidCPUName(StringRef Name) const override;
+  void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
+  bool isValidTuneCPUName(StringRef Name) const override;
+  void fillValidTuneCPUList(SmallVectorImpl<StringRef> &Values) const override;
 };
 class LLVM_LIBRARY_VISIBILITY RISCV32TargetInfo : public RISCVTargetInfo {
 public:
@@ -119,11 +124,6 @@ class LLVM_LIBRARY_VISIBILITY RISCV32TargetInfo : public RISCVTargetInfo {
     return false;
   }
 
-  bool isValidCPUName(StringRef Name) const override;
-  void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
-  bool isValidTuneCPUName(StringRef Name) const override;
-  void fillValidTuneCPUList(SmallVectorImpl<StringRef> &Values) const override;
-
   void setMaxAtomicWidth() override {
     MaxAtomicPromoteWidth = 128;
 
@@ -148,11 +148,6 @@ class LLVM_LIBRARY_VISIBILITY RISCV64TargetInfo : public RISCVTargetInfo {
     return false;
   }
 
-  bool isValidCPUName(StringRef Name) const override;
-  void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
-  bool isValidTuneCPUName(StringRef Name) const override;
-  void fillValidTuneCPUList(SmallVectorImpl<StringRef> &Values) const override;
-
   void setMaxAtomicWidth() override {
     MaxAtomicPromoteWidth = 128;
 


        


More information about the cfe-commits mailing list