From 997a97f0f5b4937073eebf0dd73d443e8845d590 Mon Sep 17 00:00:00 2001 From: Bob Wilson Date: Fri, 7 Oct 2011 00:37:57 +0000 Subject: [PATCH] Use StringSwitch. Thanks for Chandler for the suggestion. llvm-svn: 141344 --- clang/lib/Driver/ToolChains.cpp | 61 +++++++++++---------------------- 1 file changed, 20 insertions(+), 41 deletions(-) diff --git a/clang/lib/Driver/ToolChains.cpp b/clang/lib/Driver/ToolChains.cpp index 4b8c5ca1e3fc..63f827fa6144 100644 --- a/clang/lib/Driver/ToolChains.cpp +++ b/clang/lib/Driver/ToolChains.cpp @@ -27,6 +27,7 @@ #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FileSystem.h" @@ -117,51 +118,29 @@ bool Darwin::hasBlocksRuntime() const { return !isMacosxVersionLT(10, 6); } -// FIXME: Can we tablegen this? static const char *GetArmArchForMArch(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 == "armv7a" || Value == "armv7-a" || - Value == "armv7r" || Value == "armv7-r" || - Value == "armv7m" || Value == "armv7-m") - return "armv7"; - - return 0; + return llvm::StringSwitch(Value) + .Case("armv6k", "armv6") + .Case("armv5tej", "armv5") + .Case("xscale", "xscale") + .Case("armv4t", "armv4t") + .Case("armv7", "armv7") + .Cases("armv7a", "armv7-a", "armv7") + .Cases("armv7r", "armv7-r", "armv7") + .Cases("armv7m", "armv7-m", "armv7") + .Default(0); } -// FIXME: Can we tablegen this? static const char *GetArmArchForMCpu(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" || - Value == "cortex-m0" ) - return "armv6"; - - if (Value == "cortex-a8" || Value == "cortex-r4" || Value == "cortex-m3" || - Value == "cortex-a9") - return "armv7"; - - return 0; + return llvm::StringSwitch(Value) + .Cases("arm9e", "arm946e-s", "arm966e-s", "arm968e-s", "arm926ej-s","armv5") + .Cases("arm10e", "arm10tdmi", "armv5") + .Cases("arm1020t", "arm1020e", "arm1022e", "arm1026ej-s", "armv5") + .Case("xscale", "xscale") + .Cases("arm1136j-s", "arm1136jf-s", "arm1176jz-s", + "arm1176jzf-s", "cortex-m0", "armv6") + .Cases("cortex-a8", "cortex-r4", "cortex-m3", "cortex-a9", "armv7") + .Default(0); } StringRef Darwin::getDarwinArchName(const ArgList &Args) const {