[cfe-commits] r140562 - /cfe/trunk/lib/Driver/Tools.cpp
Akira Hatanaka
ahatanak at gmail.com
Mon Sep 26 14:07:52 PDT 2011
Author: ahatanak
Date: Mon Sep 26 16:07:52 2011
New Revision: 140562
URL: http://llvm.org/viewvc/llvm-project?rev=140562&view=rev
Log:
Make necessary changes in AddMIPSTargetArgs for targeting Mips64. Enable use of
-mcpu.
Modified:
cfe/trunk/lib/Driver/Tools.cpp
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=140562&r1=140561&r2=140562&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Sep 26 16:07:52 2011
@@ -752,33 +752,69 @@
}
}
+// Get default architecture.
+static const char* getMipsArchFromCPU(StringRef CPUName) {
+ if (CPUName == "mips32r1" || CPUName == "4ke")
+ return "mips";
+
+ assert((CPUName == "mips64r1" || CPUName == "mips64r2") &&
+ "Unexpected cpu name.");
+
+ return "mips64";
+}
+
+// Get default target cpu.
+static const char* getMipsCPUFromArch(StringRef ArchName, const Driver &D) {
+ if (ArchName == "mips" || ArchName == "mipsel")
+ return "mips32r1";
+ else if (ArchName == "mips64" || ArchName == "mips64el")
+ return "mips64r1";
+ else
+ D.Diag(diag::err_drv_invalid_arch_name) << ArchName;
+
+ return 0;
+}
+
+// Get default ABI.
+static const char* getMipsABIFromArch(StringRef ArchName) {
+ if (ArchName == "mips" || ArchName == "mipsel")
+ return "o32";
+
+ assert((ArchName == "mips64" || ArchName == "mips64el") &&
+ "Unexpected arch name.");
+ return "n64";
+}
+
void Clang::AddMIPSTargetArgs(const ArgList &Args,
ArgStringList &CmdArgs) const {
const Driver &D = getToolChain().getDriver();
+ StringRef ArchName;
+ const char *CPUName;
+
+ // Set target cpu and architecture.
+ if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
+ CPUName = A->getValue(Args);
+ ArchName = getMipsArchFromCPU(CPUName);
+ }
+ else {
+ ArchName = Args.MakeArgString(getToolChain().getArchName());
+ CPUName = getMipsCPUFromArch(ArchName, D);
+ }
+
+ CmdArgs.push_back("-target-cpu");
+ CmdArgs.push_back(CPUName);
+
// Select the ABI to use.
const char *ABIName = 0;
- if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ)) {
+ if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ))
ABIName = A->getValue(Args);
- } else {
- ABIName = "o32";
- }
+ else
+ ABIName = getMipsABIFromArch(ArchName);
CmdArgs.push_back("-target-abi");
CmdArgs.push_back(ABIName);
- if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) {
- StringRef MArch = A->getValue(Args);
- CmdArgs.push_back("-target-cpu");
-
- if ((MArch == "r2000") || (MArch == "r3000"))
- CmdArgs.push_back("mips1");
- else if (MArch == "r6000")
- CmdArgs.push_back("mips2");
- else
- CmdArgs.push_back(Args.MakeArgString(MArch));
- }
-
// Select the float ABI as determined by -msoft-float, -mhard-float, and
StringRef FloatABI;
if (Arg *A = Args.getLastArg(options::OPT_msoft_float,
More information about the cfe-commits
mailing list