r179981 - [Mips] Convert a GNU style Mips ABI name to the name accepted by LLVM

Simon Atanasyan simon at atanasyan.com
Sun Apr 21 06:30:10 PDT 2013


Author: atanasyan
Date: Sun Apr 21 08:30:10 2013
New Revision: 179981

URL: http://llvm.org/viewvc/llvm-project?rev=179981&view=rev
Log:
[Mips] Convert a GNU style Mips ABI name to the name accepted by LLVM
Mips backend.

Added:
    cfe/trunk/test/Driver/mips-abi.c
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=179981&r1=179980&r2=179981&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Sun Apr 21 08:30:10 2013
@@ -853,8 +853,15 @@ static void getMipsCPUAndABI(const ArgLi
       CPUName = A->getValue();
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ))
+  if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ)) {
     ABIName = A->getValue();
+    // Convert a GNU style Mips ABI name to the name
+    // accepted by LLVM Mips backend.
+    ABIName = llvm::StringSwitch<llvm::StringRef>(ABIName)
+      .Case("32", "o32")
+      .Case("64", "n64")
+      .Default(ABIName);
+  }
 
   // Setup default CPU and ABI names.
   if (CPUName.empty() && ABIName.empty()) {

Added: cfe/trunk/test/Driver/mips-abi.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-abi.c?rev=179981&view=auto
==============================================================================
--- cfe/trunk/test/Driver/mips-abi.c (added)
+++ cfe/trunk/test/Driver/mips-abi.c Sun Apr 21 08:30:10 2013
@@ -0,0 +1,36 @@
+// Check passing Mips ABI options to the backend.
+//
+// RUN: %clang -target mips-linux-gnu -### -c %s \
+// RUN:        -mabi=32 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-ABI-32 %s
+// MIPS-ABI-32: "-target-abi" "o32"
+//
+// RUN: %clang -target mips-linux-gnu -### -c %s \
+// RUN:        -mabi=o32 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-ABI-O32 %s
+// MIPS-ABI-O32: "-target-abi" "o32"
+//
+// RUN: %clang -target mips-linux-gnu -### -c %s \
+// RUN:        -mabi=n32 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-ABI-N32 %s
+// MIPS-ABI-N32: "-target-abi" "n32"
+//
+// RUN: %clang -target mips64-linux-gnu -### -c %s \
+// RUN:        -mabi=64 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-ABI-64 %s
+// MIPS-ABI-64: "-target-abi" "n64"
+//
+// RUN: %clang -target mips64-linux-gnu -### -c %s \
+// RUN:        -mabi=n64 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-ABI-N64 %s
+// MIPS-ABI-N64: "-target-abi" "n64"
+//
+// RUN: %clang -target mips64-linux-gnu -### -c %s \
+// RUN:        -mabi=o64 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-ABI-O64 %s
+// MIPS-ABI-O64: "-target-abi" "o64"
+//
+// RUN: %clang -target mips-linux-gnu -### -c %s \
+// RUN:        -mabi=eabi 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-ABI-EABI %s
+// MIPS-ABI-EABI: "-target-abi" "eabi"





More information about the cfe-commits mailing list