[PATCH] [PATCH] Allow case-insensitive values for -mcpu for ARM and AArch64 targets in line with GCC.

Gabor Ballabas gaborb at inf.u-szeged.hu
Mon May 4 09:30:40 PDT 2015


Hi richard.barton.arm, kristof.beyls,

GCC allows case-insensitive values for -mcpu, -march and -mtune options.
This patch implements the same behaviour for the -mcpu option.
I also plan to do the same for -march and -mtune, I just wanted to keep them separate.

I am not sure about how to test it though. There are hundreds of tests for -mcpu
in the test/Driver directory. Should I duplicate all of them in the existing test files
with upper-case -mcpu arguments, or should I create a separate test file for them?
Or maybe just have some of them duplicated?
I'm looking forward to some guidance here.

Thanks,
Gabor Ballabas

REPOSITORY
  rL LLVM

http://reviews.llvm.org/D9476

Files:
  lib/Driver/ToolChains.cpp
  lib/Driver/Tools.cpp

Index: lib/Driver/ToolChains.cpp
===================================================================
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -126,7 +126,7 @@
 }
 
 static const char *GetArmArchForMCpu(StringRef Value) {
-  return llvm::StringSwitch<const char *>(Value)
+  return llvm::StringSwitch<const char *>(Value.lower())
     .Cases("arm9e", "arm946e-s", "arm966e-s", "arm968e-s", "arm926ej-s","armv5")
     .Cases("arm10e", "arm10tdmi", "armv5")
     .Cases("arm1020t", "arm1020e", "arm1022e", "arm1026ej-s", "armv5")
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -895,7 +895,7 @@
   if ((A = Args.getLastArg(options::OPT_mtune_EQ))) {
     CPU = A->getValue();
   } else if ((A = Args.getLastArg(options::OPT_mcpu_EQ))) {
-    StringRef Mcpu = A->getValue();
+    StringRef Mcpu = StringRef(A->getValue()).lower();
     CPU = Mcpu.split("+").first;
   }
 
@@ -1826,7 +1826,7 @@
                                const ArgList &Args,
                                std::vector<const char *> &Features) {
   StringRef CPU;
-  if (!DecodeAArch64Mcpu(D, Mcpu, CPU, Features))
+  if (!DecodeAArch64Mcpu(D, Mcpu.lower(), CPU, Features))
     return false;
 
   return true;
@@ -1852,7 +1852,7 @@
                                     std::vector<const char *> &Features) {
   StringRef CPU;
   std::vector<const char *> DecodedFeature;
-  if (!DecodeAArch64Mcpu(D, Mcpu, CPU, DecodedFeature))
+  if (!DecodeAArch64Mcpu(D, Mcpu.lower(), CPU, DecodedFeature))
     return false;
 
   return getAArch64MicroArchFeaturesFromMtune(D, CPU, Args, Features);
@@ -5613,7 +5613,7 @@
   // FIXME: Warn on inconsistent use of -mcpu and -march.
   // If we have -mcpu=, use that.
   if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
-    StringRef MCPU = A->getValue();
+    StringRef MCPU = StringRef(A->getValue()).lower();
     // Handle -mcpu=native.
     if (MCPU == "native")
       return llvm::sys::getHostCPUName();
@@ -7482,7 +7482,7 @@
     // march from being picked in the absence of a cpu flag.
     Arg *A;
     if ((A = Args.getLastArg(options::OPT_mcpu_EQ)) &&
-      StringRef(A->getValue()) == "krait")
+      StringRef(A->getValue()).lower() == "krait")
         CmdArgs.push_back("-march=armv7-a");
     else
       Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9476.24885.patch
Type: text/x-patch
Size: 2403 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150504/d3302a40/attachment.bin>


More information about the cfe-commits mailing list