r232939 - Convert cascading if-else-if to switch. NFC
Scott Douglass
sdouglass at arm.com
Mon Mar 23 03:46:29 PDT 2015
Author: scott-0
Date: Mon Mar 23 05:46:28 2015
New Revision: 232939
URL: http://llvm.org/viewvc/llvm-project?rev=232939&view=rev
Log:
Convert cascading if-else-if to switch. NFC
Differential Revision: http://reviews.llvm.org/D8485
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=232939&r1=232938&r2=232939&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Mar 23 05:46:28 2015
@@ -7259,38 +7259,50 @@ void gnutools::Assemble::ConstructJob(Co
ArgStringList CmdArgs;
bool NeedsKPIC = false;
+ switch (getToolChain().getArch()) {
+ default:
+ break;
// Add --32/--64 to make sure we get the format we want.
// This is incomplete
- if (getToolChain().getArch() == llvm::Triple::x86) {
+ case llvm::Triple::x86:
CmdArgs.push_back("--32");
- } else if (getToolChain().getArch() == llvm::Triple::x86_64) {
+ break;
+ case llvm::Triple::x86_64:
if (getToolChain().getTriple().getEnvironment() == llvm::Triple::GNUX32)
CmdArgs.push_back("--x32");
else
CmdArgs.push_back("--64");
- } else if (getToolChain().getArch() == llvm::Triple::ppc) {
+ break;
+ case llvm::Triple::ppc:
CmdArgs.push_back("-a32");
CmdArgs.push_back("-mppc");
CmdArgs.push_back("-many");
- } else if (getToolChain().getArch() == llvm::Triple::ppc64) {
+ break;
+ case llvm::Triple::ppc64:
CmdArgs.push_back("-a64");
CmdArgs.push_back("-mppc64");
CmdArgs.push_back("-many");
- } else if (getToolChain().getArch() == llvm::Triple::ppc64le) {
+ break;
+ case llvm::Triple::ppc64le:
CmdArgs.push_back("-a64");
CmdArgs.push_back("-mppc64");
CmdArgs.push_back("-many");
CmdArgs.push_back("-mlittle-endian");
- } else if (getToolChain().getArch() == llvm::Triple::sparc) {
+ break;
+ case llvm::Triple::sparc:
CmdArgs.push_back("-32");
CmdArgs.push_back("-Av8plusa");
NeedsKPIC = true;
- } else if (getToolChain().getArch() == llvm::Triple::sparcv9) {
+ break;
+ case llvm::Triple::sparcv9:
CmdArgs.push_back("-64");
CmdArgs.push_back("-Av9a");
NeedsKPIC = true;
- } else if (getToolChain().getArch() == llvm::Triple::arm ||
- getToolChain().getArch() == llvm::Triple::armeb) {
+ break;
+ case llvm::Triple::arm:
+ case llvm::Triple::armeb:
+ case llvm::Triple::thumb:
+ case llvm::Triple::thumbeb: {
StringRef MArch = getToolChain().getArchName();
if (MArch == "armv7" || MArch == "armv7a" || MArch == "armv7-a")
CmdArgs.push_back("-mfpu=neon");
@@ -7314,10 +7326,12 @@ void gnutools::Assemble::ConstructJob(Co
else
Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
Args.AddLastArg(CmdArgs, options::OPT_mfpu_EQ);
- } else if (getToolChain().getArch() == llvm::Triple::mips ||
- getToolChain().getArch() == llvm::Triple::mipsel ||
- getToolChain().getArch() == llvm::Triple::mips64 ||
- getToolChain().getArch() == llvm::Triple::mips64el) {
+ break;
+ }
+ case llvm::Triple::mips:
+ case llvm::Triple::mipsel:
+ case llvm::Triple::mips64:
+ case llvm::Triple::mips64el: {
StringRef CPUName;
StringRef ABIName;
mips::getMipsCPUAndABI(Args, getToolChain().getTriple(), CPUName, ABIName);
@@ -7401,11 +7415,15 @@ void gnutools::Assemble::ConstructJob(Co
options::OPT_mno_odd_spreg);
NeedsKPIC = true;
- } else if (getToolChain().getArch() == llvm::Triple::systemz) {
+ break;
+ }
+ case llvm::Triple::systemz: {
// Always pass an -march option, since our default of z10 is later
// than the GNU assembler's default.
StringRef CPUName = getSystemZTargetCPU(Args);
CmdArgs.push_back(Args.MakeArgString("-march=" + CPUName));
+ break;
+ }
}
if (NeedsKPIC)
More information about the cfe-commits
mailing list