r212260 - [Driver][Mips] Check MIPS CPU name provided to the Clang driver.

Simon Atanasyan simon at atanasyan.com
Thu Jul 3 01:31:23 PDT 2014


Author: atanasyan
Date: Thu Jul  3 03:31:23 2014
New Revision: 212260

URL: http://llvm.org/viewvc/llvm-project?rev=212260&view=rev
Log:
[Driver][Mips] Check MIPS CPU name provided to the Clang driver.

Modified:
    cfe/trunk/lib/Basic/Targets.cpp
    cfe/trunk/test/Driver/mips-abi.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=212260&r1=212259&r2=212260&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Jul  3 03:31:23 2014
@@ -5305,8 +5305,17 @@ public:
 
   StringRef getABI() const override { return ABI; }
   bool setCPU(const std::string &Name) override {
+    bool IsMips32 = getTriple().getArch() == llvm::Triple::mips ||
+                    getTriple().getArch() == llvm::Triple::mipsel;
     CPU = Name;
-    return true;
+    return llvm::StringSwitch<bool>(Name)
+        .Case("mips32", IsMips32)
+        .Case("mips32r2", IsMips32)
+        .Case("mips32r6", IsMips32)
+        .Case("mips64", true)
+        .Case("mips64r2", true)
+        .Case("mips64r6", true)
+        .Default(false);
   }
   const std::string& getCPU() const { return CPU; }
   void getDefaultFeatures(llvm::StringMap<bool> &Features) const override {

Modified: cfe/trunk/test/Driver/mips-abi.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-abi.c?rev=212260&r1=212259&r2=212260&view=diff
==============================================================================
--- cfe/trunk/test/Driver/mips-abi.c (original)
+++ cfe/trunk/test/Driver/mips-abi.c Thu Jul  3 03:31:23 2014
@@ -85,3 +85,13 @@
 // RUN:   | FileCheck -check-prefix=MIPS-ARCH-64R2 %s
 // MIPS-ARCH-64R2: "-target-cpu" "mips64r2"
 // MIPS-ARCH-64R2: "-target-abi" "n64"
+//
+// RUN: not %clang -target mips64-linux-gnu -c %s \
+// RUN:        -march=mips32 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-ARCH-6432 %s
+// MIPS-ARCH-6432: error: unknown target CPU 'mips32'
+//
+// RUN: not %clang -target mips-linux-gnu -c %s \
+// RUN:        -march=unknown 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-ARCH-UNKNOWN %s
+// MIPS-ARCH-UNKNOWN: error: unknown target CPU 'unknown'





More information about the cfe-commits mailing list