From baa97663c28dcec238a3fc4ecdb8e5c30a1ff8cc Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Fri, 11 Jul 2014 23:47:48 +0000 Subject: [PATCH] [Driver] clang::driver::getARMCPUForMArch() moved to llvm::Triple::getARMCPUForArch(). Depends on llvm r212846. Suggested by Eric Christopher. llvm-svn: 212858 --- clang/include/clang/Driver/Util.h | 7 --- clang/lib/Driver/Tools.cpp | 85 +---------------------------------- clang/unittests/Driver/CMakeLists.txt | 1 - clang/unittests/Driver/UtilsTest.cpp | 31 ------------- 4 files changed, 2 insertions(+), 122 deletions(-) delete mode 100644 clang/unittests/Driver/UtilsTest.cpp diff --git a/clang/include/clang/Driver/Util.h b/clang/include/clang/Driver/Util.h index c671ca4..b24b990 100644 --- a/clang/include/clang/Driver/Util.h +++ b/clang/include/clang/Driver/Util.h @@ -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 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 diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index ebac93c..bc64d5c 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -5044,6 +5044,7 @@ void hexagon::Link::ConstructJob(Compilation &C, const JobAction &JA, } // 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 ArgList &Args, } } - 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(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(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. diff --git a/clang/unittests/Driver/CMakeLists.txt b/clang/unittests/Driver/CMakeLists.txt index 106f070..8cc963b 100644 --- a/clang/unittests/Driver/CMakeLists.txt +++ b/clang/unittests/Driver/CMakeLists.txt @@ -4,7 +4,6 @@ set(LLVM_LINK_COMPONENTS add_clang_unittest(ClangDriverTests MultilibTest.cpp - UtilsTest.cpp ) target_link_libraries(ClangDriverTests diff --git a/clang/unittests/Driver/UtilsTest.cpp b/clang/unittests/Driver/UtilsTest.cpp deleted file mode 100644 index 308e8d8..0000000 --- a/clang/unittests/Driver/UtilsTest.cpp +++ /dev/null @@ -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)); - } -} -- 2.7.4