r270691 - Revert "[AArch64] Using new TargetParser in Clang"

Renato Golin via cfe-commits cfe-commits at lists.llvm.org
Wed May 25 05:36:33 PDT 2016


Author: rengolin
Date: Wed May 25 07:36:31 2016
New Revision: 270691

URL: http://llvm.org/viewvc/llvm-project?rev=270691&view=rev
Log:
Revert "[AArch64] Using new TargetParser in Clang"

This reverts commit r270688 and r270689. The issue is not a random order, but a
different order for some targets and others (prob. Linux vs Darwin). Reverting until
we have a better fix.

Modified:
    cfe/trunk/lib/Basic/Targets.cpp
    cfe/trunk/lib/Driver/Tools.cpp
    cfe/trunk/test/Preprocessor/aarch64-target-features.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=270691&r1=270690&r2=270691&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed May 25 07:36:31 2016
@@ -5665,10 +5665,14 @@ public:
   }
 
   bool setCPU(const std::string &Name) override {
-    if (Name == "generic" || llvm::AArch64::parseCPUArch(Name) != llvm::ARM::AK_INVALID)
-      return true;
-
-    return false;
+    bool CPUKnown = llvm::StringSwitch<bool>(Name)
+                        .Case("generic", true)
+                        .Cases("cortex-a53", "cortex-a57", "cortex-a72",
+                               "cortex-a35", "exynos-m1", true)
+                        .Case("cyclone", true)
+                        .Case("kryo", true)
+                        .Default(false);
+    return CPUKnown;
   }
 
   void getTargetDefines(const LangOptions &Opts,

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=270691&r1=270690&r2=270691&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed May 25 07:36:31 2016
@@ -2262,9 +2262,22 @@ static bool DecodeAArch64Features(const
   text.split(Split, StringRef("+"), -1, false);
 
   for (StringRef Feature : Split) {
-    const char *FeatureName = llvm::AArch64::getArchExtFeature(Feature);
-    if (FeatureName)
-      Features.push_back(FeatureName);
+    const char *result = llvm::StringSwitch<const char *>(Feature)
+                             .Case("fp", "+fp-armv8")
+                             .Case("simd", "+neon")
+                             .Case("crc", "+crc")
+                             .Case("crypto", "+crypto")
+                             .Case("fp16", "+fullfp16")
+                             .Case("profile", "+spe")
+                             .Case("nofp", "-fp-armv8")
+                             .Case("nosimd", "-neon")
+                             .Case("nocrc", "-crc")
+                             .Case("nocrypto", "-crypto")
+                             .Case("nofp16", "-fullfp16")
+                             .Case("noprofile", "-spe")
+                             .Default(nullptr);
+    if (result)
+      Features.push_back(result);
     else if (Feature == "neon" || Feature == "noneon")
       D.Diag(diag::err_drv_no_neon_modifier);
     else
@@ -2279,16 +2292,20 @@ static bool DecodeAArch64Mcpu(const Driv
                               std::vector<const char *> &Features) {
   std::pair<StringRef, StringRef> Split = Mcpu.split("+");
   CPU = Split.first;
-
-  if (CPU == "generic") {
+  if (CPU == "cortex-a53" || CPU == "cortex-a57" ||
+      CPU == "cortex-a72" || CPU == "cortex-a35" || CPU == "exynos-m1" ||
+      CPU == "kryo") {
+    Features.push_back("+neon");
+    Features.push_back("+crc");
+    Features.push_back("+crypto");
+  } else if (CPU == "cyclone") {
+    Features.push_back("+neon");
+    Features.push_back("+crypto");
+  } else if (CPU == "generic") {
     Features.push_back("+neon");
   } else {
-    unsigned ArchKind = llvm::AArch64::parseCPUArch(CPU);
-    unsigned Extersion = llvm::AArch64::getDefaultExtensions(CPU,ArchKind);
-
-    if (!llvm::AArch64::getExtensionFeatures(Extersion,Features))
-      return false;
-   }
+    return false;
+  }
 
   if (Split.second.size() && !DecodeAArch64Features(D, Split.second, Features))
     return false;
@@ -2300,13 +2317,20 @@ static bool
 getAArch64ArchFeaturesFromMarch(const Driver &D, StringRef March,
                                 const ArgList &Args,
                                 std::vector<const char *> &Features) {
-  unsigned ArchKind;
   std::string MarchLowerCase = March.lower();
   std::pair<StringRef, StringRef> Split = StringRef(MarchLowerCase).split("+");
 
-  ArchKind = llvm::AArch64::parseArch(Split.first);
-  if (ArchKind == llvm::ARM::AK_INVALID || !llvm::AArch64::getArchFeatures(ArchKind, Features) ||
-     (Split.second.size() && !DecodeAArch64Features(D, Split.second, Features)))
+  if (Split.first == "armv8-a" || Split.first == "armv8a") {
+    // ok, no additional features.
+  } else if (Split.first == "armv8.1-a" || Split.first == "armv8.1a") {
+    Features.push_back("+v8.1a");
+  } else if (Split.first == "armv8.2-a" || Split.first == "armv8.2a" ) {
+    Features.push_back("+v8.2a");
+  } else {
+    return false;
+  }
+
+  if (Split.second.size() && !DecodeAArch64Features(D, Split.second, Features))
     return false;
 
   return true;

Modified: cfe/trunk/test/Preprocessor/aarch64-target-features.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/aarch64-target-features.c?rev=270691&r1=270690&r2=270691&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/aarch64-target-features.c (original)
+++ cfe/trunk/test/Preprocessor/aarch64-target-features.c Wed May 25 07:36:31 2016
@@ -94,10 +94,7 @@
 // RUN: %clang -target aarch64 -mcpu=cortex-a72 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-A72 %s
 // RUN: %clang -target aarch64 -mcpu=exynos-m1 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-M1 %s
 // RUN: %clang -target aarch64 -mcpu=kryo -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-MCPU-KRYO %s
-// CHECK-MCPU-CYCLONE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon"
-// CHECK-MCPU-CYCLONE-DAG: "-target-feature" "+crypto"
-// CHECK-MCPU-CYCLONE-DAG: "-target-feature" "+zcm"
-// CHECK-MCPU-CYCLONE-DAG: "-target-feature" "+zcz"
+// CHECK-MCPU-CYCLONE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crypto" "-target-feature" "+zcm" "-target-feature" "+zcz"
 // CHECK-MCPU-A35: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-A53: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-A57: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto"




More information about the cfe-commits mailing list