[llvm] ef9421d - [LoongArch] Remove useless 'invalid' and 'none' feature and arch names. NFC

Weining Lu via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 18 01:53:09 PDT 2023


Author: Weining Lu
Date: 2023-07-18T16:51:23+08:00
New Revision: ef9421dcf15fcd21ba121670ac0c7c7af15bc80f

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

LOG: [LoongArch] Remove useless 'invalid' and 'none' feature and arch names. NFC

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
    llvm/include/llvm/TargetParser/LoongArchTargetParser.def
    llvm/include/llvm/TargetParser/LoongArchTargetParser.h
    llvm/lib/TargetParser/LoongArchTargetParser.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp b/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
index fe880f796cc024..856ad58f3bd9db 100644
--- a/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
@@ -127,10 +127,8 @@ void loongarch::getLoongArchTargetFeatures(const Driver &D,
                                            const ArgList &Args,
                                            std::vector<StringRef> &Features) {
   StringRef ArchName;
-  llvm::LoongArch::ArchKind ArchKind = llvm::LoongArch::ArchKind::AK_INVALID;
   if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) {
-    ArchKind = llvm::LoongArch::parseArch(A->getValue());
-    if (ArchKind == llvm::LoongArch::ArchKind::AK_INVALID) {
+    if (!llvm::LoongArch::isValidArchName(A->getValue())) {
       D.Diag(clang::diag::err_drv_invalid_arch_name) << A->getAsString(Args);
       return;
     }

diff  --git a/llvm/include/llvm/TargetParser/LoongArchTargetParser.def b/llvm/include/llvm/TargetParser/LoongArchTargetParser.def
index 5245d750d3ef04..b20d124953f882 100644
--- a/llvm/include/llvm/TargetParser/LoongArchTargetParser.def
+++ b/llvm/include/llvm/TargetParser/LoongArchTargetParser.def
@@ -2,8 +2,6 @@
 #define LOONGARCH_FEATURE(NAME, KIND)
 #endif
 
-LOONGARCH_FEATURE("invalid", FK_INVALID)
-LOONGARCH_FEATURE("none", FK_NONE)
 LOONGARCH_FEATURE("+64bit", FK_64BIT)
 LOONGARCH_FEATURE("+f", FK_FP32)
 LOONGARCH_FEATURE("+d", FK_FP64)
@@ -19,7 +17,6 @@ LOONGARCH_FEATURE("+ual", FK_UAL)
 #define LOONGARCH_ARCH(NAME, KIND, FEATURES)
 #endif
 
-LOONGARCH_ARCH("invalid", AK_INVALID, FK_INVALID)
 LOONGARCH_ARCH("loongarch64", AK_LOONGARCH64, FK_64BIT | FK_FP32 | FK_FP64 | FK_UAL)
 LOONGARCH_ARCH("la464", AK_LA464, FK_64BIT | FK_FP32 | FK_FP64 | FK_LSX | FK_LASX | FK_UAL)
 

diff  --git a/llvm/include/llvm/TargetParser/LoongArchTargetParser.h b/llvm/include/llvm/TargetParser/LoongArchTargetParser.h
index ff325a76d1356d..2aa65ec070ec38 100644
--- a/llvm/include/llvm/TargetParser/LoongArchTargetParser.h
+++ b/llvm/include/llvm/TargetParser/LoongArchTargetParser.h
@@ -23,9 +23,6 @@ class StringRef;
 namespace LoongArch {
 
 enum FeatureKind : uint32_t {
-  FK_INVALID = 0,
-  FK_NONE = 1,
-
   // 64-bit ISA is available.
   FK_64BIT = 1 << 1,
 
@@ -67,7 +64,7 @@ struct ArchInfo {
   uint32_t Features;
 };
 
-ArchKind parseArch(StringRef Arch);
+bool isValidArchName(StringRef Arch);
 bool getArchFeatures(StringRef Arch, std::vector<StringRef> &Features);
 
 } // namespace LoongArch

diff  --git a/llvm/lib/TargetParser/LoongArchTargetParser.cpp b/llvm/lib/TargetParser/LoongArchTargetParser.cpp
index faa8c314fc0096..18b04600dbc660 100644
--- a/llvm/lib/TargetParser/LoongArchTargetParser.cpp
+++ b/llvm/lib/TargetParser/LoongArchTargetParser.cpp
@@ -1,4 +1,4 @@
-//==-- LoongArch64TargetParser - Parser for LoongArch64 features --*- C++ -*-=//
+//===-- LoongArchTargetParser - Parser for LoongArch features --*- C++ -*-====//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -27,12 +27,11 @@ const ArchInfo AllArchs[] = {
 #include "llvm/TargetParser/LoongArchTargetParser.def"
 };
 
-LoongArch::ArchKind LoongArch::parseArch(StringRef Arch) {
+bool LoongArch::isValidArchName(StringRef Arch) {
   for (const auto A : AllArchs)
     if (A.Name == Arch)
-      return A.Kind;
-
-  return LoongArch::ArchKind::AK_INVALID;
+      return true;
+  return false;
 }
 
 bool LoongArch::getArchFeatures(StringRef Arch,
@@ -40,7 +39,7 @@ bool LoongArch::getArchFeatures(StringRef Arch,
   for (const auto A : AllArchs) {
     if (A.Name == Arch) {
       for (const auto F : AllFeatures)
-        if ((A.Features & F.Kind) == F.Kind && F.Kind != FK_INVALID)
+        if ((A.Features & F.Kind) == F.Kind)
           Features.push_back(F.Name);
       return true;
     }


        


More information about the llvm-commits mailing list