]> granicus.if.org Git - clang/commitdiff
[Mips] Convert a GNU style Mips ABI name to the name accepted by LLVM
authorSimon Atanasyan <simon@atanasyan.com>
Sun, 21 Apr 2013 13:30:10 +0000 (13:30 +0000)
committerSimon Atanasyan <simon@atanasyan.com>
Sun, 21 Apr 2013 13:30:10 +0000 (13:30 +0000)
Mips backend.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179981 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Tools.cpp
test/Driver/mips-abi.c [new file with mode: 0644]

index 1ea7c43efc7c2a136512b28fa3b207523e0cf19f..119b7c76a4bda805ec981bd3e5953b72671a5e71 100644 (file)
@@ -853,8 +853,15 @@ static void getMipsCPUAndABI(const ArgList &Args,
       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()) {
diff --git a/test/Driver/mips-abi.c b/test/Driver/mips-abi.c
new file mode 100644 (file)
index 0000000..fd2b46f
--- /dev/null
@@ -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"