[cfe-commits] r81020 - in /cfe/trunk: include/clang/Driver/Options.def lib/Driver/Tools.cpp
Daniel Dunbar
daniel at zuster.org
Fri Sep 4 11:35:32 PDT 2009
Author: ddunbar
Date: Fri Sep 4 13:35:31 2009
New Revision: 81020
URL: http://llvm.org/viewvc/llvm-project?rev=81020&view=rev
Log:
Implement darwin::Link::AddDarwinArch for ARM.
Modified:
cfe/trunk/include/clang/Driver/Options.def
cfe/trunk/lib/Driver/Tools.cpp
Modified: cfe/trunk/include/clang/Driver/Options.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.def?rev=81020&r1=81019&r2=81020&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.def (original)
+++ cfe/trunk/include/clang/Driver/Options.def Fri Sep 4 13:35:31 2009
@@ -508,6 +508,7 @@
OPTION("-march=", march_EQ, Joined, m_Group, INVALID, "d", 0, 0, 0)
OPTION("-mcmodel=", mcmodel_EQ, Joined, m_Group, INVALID, "d", 0, 0, 0)
OPTION("-mconstant-cfstrings", mconstant_cfstrings, Flag, clang_ignored_m_Group, INVALID, "", 0, 0, 0)
+OPTION("-mcpu=", mcpu_EQ, Joined, m_Group, INVALID, "d", 0, 0, 0)
OPTION("-mdynamic-no-pic", mdynamic_no_pic, Joined, m_Group, INVALID, "q", 0, 0, 0)
OPTION("-mfix-and-continue", mfix_and_continue, Flag, clang_ignored_m_Group, INVALID, "", 0, 0, 0)
OPTION("-miphoneos-version-min=", miphoneos_version_min_EQ, Joined, m_Group, INVALID, "", 0, 0, 0)
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=81020&r1=81019&r2=81020&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Sep 4 13:35:31 2009
@@ -1368,11 +1368,83 @@
return isMacosxVersionLT(A, B);
}
+// FIXME: Can we tablegen this?
+static const char *GetArmArchForMArch(llvm::StringRef Value) {
+ if (Value == "armv6k")
+ return "armv6";
+
+ if (Value == "armv5tej")
+ return "armv5";
+
+ if (Value == "xscale")
+ return "xscale";
+
+ if (Value == "armv4t")
+ return "armv4t";
+
+ if (Value == "armv7" || Value == "armv7-a" || Value == "armv7-r" ||
+ Value == "armv7-m" || Value == "armv7a" || Value == "armv7r" ||
+ Value == "armv7m")
+ return "armv7";
+
+ return 0;
+}
+
+// FIXME: Can we tablegen this?
+static const char *GetArmArchForMCpu(llvm::StringRef Value) {
+ if (Value == "arm10tdmi" || Value == "arm1020t" || Value == "arm9e" ||
+ Value == "arm946e-s" || Value == "arm966e-s" ||
+ Value == "arm968e-s" || Value == "arm10e" ||
+ Value == "arm1020e" || Value == "arm1022e" || Value == "arm926ej-s" ||
+ Value == "arm1026ej-s")
+ return "armv5";
+
+ if (Value == "xscale")
+ return "xscale";
+
+ if (Value == "arm1136j-s" || Value == "arm1136jf-s" ||
+ Value == "arm1176jz-s" || Value == "arm1176jzf-s")
+ return "armv6";
+
+ if (Value == "cortex-a8" || Value == "cortex-r4" || Value == "cortex-m3")
+ return "armv7";
+
+ return 0;
+}
+
void darwin::Link::AddDarwinArch(const ArgList &Args,
ArgStringList &CmdArgs) const {
// Derived from darwin_arch spec.
CmdArgs.push_back("-arch");
- CmdArgs.push_back(Args.MakeArgString(getToolChain().getArchName().c_str()));
+
+ switch (getToolChain().getTriple().getArch()) {
+ default:
+ CmdArgs.push_back(Args.MakeArgString(getToolChain().getArchName().c_str()));
+ break;
+
+ case llvm::Triple::arm: {
+ // FIXME: gcc isn't actually following this, it looks like the arch is
+ // getting forced somewhere else (translation?).
+
+ if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) {
+ if (const char *Arch = GetArmArchForMArch(A->getValue(Args))) {
+ CmdArgs.push_back(Arch);
+ return;
+ }
+ }
+
+ if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
+ if (const char *Arch = GetArmArchForMCpu(A->getValue(Args))) {
+ CmdArgs.push_back(Arch);
+ return;
+ }
+ }
+
+ CmdArgs.push_back("arm");
+ CmdArgs.push_back("-force_cpusubtype_ALL");
+ return;
+ }
+ }
}
void darwin::Link::AddDarwinSubArch(const ArgList &Args,
More information about the cfe-commits
mailing list