forked from OSchip/llvm-project
[Driver] clang::driver::getARMCPUForMArch() moved to llvm::Triple::getARMCPUForArch().
Depends on llvm r212846. Suggested by Eric Christopher. llvm-svn: 212858
This commit is contained in:
parent
ae9d59e8c4
commit
baa97663c2
|
@ -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
|
||||
|
||||
|
|
|
@ -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<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.
|
||||
|
|
|
@ -4,7 +4,6 @@ set(LLVM_LINK_COMPONENTS
|
|||
|
||||
add_clang_unittest(ClangDriverTests
|
||||
MultilibTest.cpp
|
||||
UtilsTest.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(ClangDriverTests
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue