r212858 - [Driver] clang::driver::getARMCPUForMArch() moved to llvm::Triple::getARMCPUForArch().

Argyrios Kyrtzidis akyrtzi at gmail.com
Fri Jul 11 16:47:48 PDT 2014


Author: akirtzidis
Date: Fri Jul 11 18:47:48 2014
New Revision: 212858

URL: http://llvm.org/viewvc/llvm-project?rev=212858&view=rev
Log:
[Driver] clang::driver::getARMCPUForMArch() moved to llvm::Triple::getARMCPUForArch().

Depends on llvm r212846.
Suggested by Eric Christopher.

Removed:
    cfe/trunk/unittests/Driver/UtilsTest.cpp
Modified:
    cfe/trunk/include/clang/Driver/Util.h
    cfe/trunk/lib/Driver/Tools.cpp
    cfe/trunk/unittests/Driver/CMakeLists.txt

Modified: cfe/trunk/include/clang/Driver/Util.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Util.h?rev=212858&r1=212857&r2=212858&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Util.h (original)
+++ cfe/trunk/include/clang/Driver/Util.h Fri Jul 11 18:47:48 2014
@@ -13,10 +13,6 @@
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/DenseMap.h"
 
-namespace llvm {
-  class Triple;
-}
-
 namespace clang {
 class DiagnosticsEngine;
 
@@ -30,9 +26,6 @@ namespace driver {
   /// ActionList - Type used for lists of actions.
   typedef SmallVector<Action*, 3> ActionList;
 
-/// Get the (LLVM) name of the minimum ARM CPU for the arch we are targeting.
-const char* getARMCPUForMArch(StringRef MArch, const llvm::Triple &Triple);
-
 } // end namespace driver
 } // end namespace clang
 

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=212858&r1=212857&r2=212858&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Jul 11 18:47:48 2014
@@ -5044,6 +5044,7 @@ void hexagon::Link::ConstructJob(Compila
 }
 // Hexagon tools end.
 
+/// Get the (LLVM) name of the minimum ARM CPU for the arch we are targeting.
 const char *arm::getARMCPUForMArch(const ArgList &Args,
                                    const llvm::Triple &Triple) {
   StringRef MArch;
@@ -5065,89 +5066,7 @@ const char *arm::getARMCPUForMArch(const
     }
   }
 
-  return driver::getARMCPUForMArch(MArch, Triple);
-}
-
-/// Get the (LLVM) name of the minimum ARM CPU for the arch we are targeting.
-//
-// FIXME: tblgen this.
-const char *driver::getARMCPUForMArch(StringRef MArch,
-                                      const llvm::Triple &Triple) {
-  switch (Triple.getOS()) {
-  case llvm::Triple::NetBSD:
-    if (MArch == "armv6")
-      return "arm1176jzf-s";
-    break;
-  case llvm::Triple::Win32:
-    // FIXME: this is invalid for WindowsCE
-    return "cortex-a9";
-  default:
-    break;
-  }
-
-  const char *result = nullptr;
-  size_t offset = StringRef::npos;
-  if (MArch.startswith("arm"))
-    offset = 3;
-  if (MArch.startswith("thumb"))
-    offset = 5;
-  if (offset != StringRef::npos && MArch.substr(offset, 2) == "eb")
-    offset += 2;
-  if (offset != StringRef::npos)
-    result = llvm::StringSwitch<const char *>(MArch.substr(offset))
-      .Cases("v2", "v2a", "arm2")
-      .Case("v3", "arm6")
-      .Case("v3m", "arm7m")
-      .Case("v4", "strongarm")
-      .Case("v4t", "arm7tdmi")
-      .Cases("v5", "v5t", "arm10tdmi")
-      .Cases("v5e", "v5te", "arm1022e")
-      .Case("v5tej", "arm926ej-s")
-      .Cases("v6", "v6k", "arm1136jf-s")
-      .Case("v6j", "arm1136j-s")
-      .Cases("v6z", "v6zk", "arm1176jzf-s")
-      .Case("v6t2", "arm1156t2-s")
-      .Cases("v6m", "v6-m", "cortex-m0")
-      .Cases("v7", "v7a", "v7-a", "v7l", "v7-l", "cortex-a8")
-      .Cases("v7s", "v7-s", "swift")
-      .Cases("v7r", "v7-r", "cortex-r4")
-      .Cases("v7m", "v7-m", "cortex-m3")
-      .Cases("v7em", "v7e-m", "cortex-m4")
-      .Cases("v8", "v8a", "v8-a", "cortex-a53")
-      .Default(nullptr);
-  else
-    result = llvm::StringSwitch<const char *>(MArch)
-      .Case("ep9312", "ep9312")
-      .Case("iwmmxt", "iwmmxt")
-      .Case("xscale", "xscale")
-      .Default(nullptr);
-
-  if (result)
-    return result;
-
-  // If all else failed, return the most base CPU with thumb interworking
-  // supported by LLVM.
-  // FIXME: Should warn once that we're falling back.
-  switch (Triple.getOS()) {
-  case llvm::Triple::NetBSD:
-    switch (Triple.getEnvironment()) {
-    case llvm::Triple::GNUEABIHF:
-    case llvm::Triple::GNUEABI:
-    case llvm::Triple::EABIHF:
-    case llvm::Triple::EABI:
-      return "arm926ej-s";
-    default:
-      return "strongarm";
-    }
-  default:
-    switch (Triple.getEnvironment()) {
-    case llvm::Triple::EABIHF:
-    case llvm::Triple::GNUEABIHF:
-      return "arm1176jzf-s";
-    default:
-      return "arm7tdmi";
-    }
-  }
+  return Triple.getARMCPUForArch(MArch);
 }
 
 /// getARMTargetCPU - Get the (LLVM) name of the ARM cpu we are targeting.

Modified: cfe/trunk/unittests/Driver/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Driver/CMakeLists.txt?rev=212858&r1=212857&r2=212858&view=diff
==============================================================================
--- cfe/trunk/unittests/Driver/CMakeLists.txt (original)
+++ cfe/trunk/unittests/Driver/CMakeLists.txt Fri Jul 11 18:47:48 2014
@@ -4,7 +4,6 @@ set(LLVM_LINK_COMPONENTS
 
 add_clang_unittest(ClangDriverTests
   MultilibTest.cpp
-  UtilsTest.cpp
   )
 
 target_link_libraries(ClangDriverTests

Removed: cfe/trunk/unittests/Driver/UtilsTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Driver/UtilsTest.cpp?rev=212857&view=auto
==============================================================================
--- cfe/trunk/unittests/Driver/UtilsTest.cpp (original)
+++ cfe/trunk/unittests/Driver/UtilsTest.cpp (removed)
@@ -1,31 +0,0 @@
-//===- unittests/Driver/UtilsTest.cpp --- Utils tests ---------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// Unit tests for Driver/Util API.
-//
-//===----------------------------------------------------------------------===//
-
-#include "clang/Driver/Util.h"
-#include "clang/Basic/LLVM.h"
-#include "llvm/ADT/Triple.h"
-#include "gtest/gtest.h"
-
-using namespace clang::driver;
-using namespace clang;
-
-TEST(UtilsTest, getARMCPUForMArch) {
-  {
-    llvm::Triple Triple("armv7s-apple-ios7");
-    EXPECT_STREQ("swift", getARMCPUForMArch(Triple.getArchName(), Triple));
-  }
-  {
-    llvm::Triple Triple("armv7-apple-ios7");
-    EXPECT_STREQ("cortex-a8", getARMCPUForMArch(Triple.getArchName(), Triple));
-  }
-}





More information about the cfe-commits mailing list