[PATCH] D52290: [driver][mips] Adjust target triple accordingly to provided ABI name
Simon Atanasyan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 26 03:19:10 PDT 2018
atanasyan updated this revision to Diff 167091.
atanasyan edited the summary of this revision.
atanasyan added a comment.
Always adjust target triple (explicitly and implicitly provided) accordingly to ABI name.
Repository:
rC Clang
https://reviews.llvm.org/D52290
Files:
lib/Driver/Driver.cpp
test/Driver/mips-abi.c
Index: test/Driver/mips-abi.c
===================================================================
--- test/Driver/mips-abi.c
+++ test/Driver/mips-abi.c
@@ -162,3 +162,28 @@
// RUN: -march=unknown 2>&1 \
// RUN: | FileCheck -check-prefix=MIPS-ARCH-UNKNOWN %s
// MIPS-ARCH-UNKNOWN: error: unknown target CPU 'unknown'
+
+// Check adjusting of target triple accordingly to `-mabi` option.
+// RUN: %clang -target mips64-linux-gnu -mabi=32 -### %s 2>&1 \
+// RUN: | FileCheck -check-prefix=TARGET-O32 %s
+// TARGET-O32: "-triple" "mips-unknown-linux-gnu"
+// TARGET-O32: "-target-cpu" "mips32r2"
+// TARGET-O32: "-target-abi" "o32"
+// TARGET-O32: ld{{.*}}"
+// TARGET-O32: "-m" "elf32btsmip"
+
+// RUN: %clang -target mips-linux-gnu -mabi=n32 -### %s 2>&1 \
+// RUN: | FileCheck -check-prefix=TARGET-N32 %s
+// TARGET-N32: "-triple" "mips64-unknown-linux-gnu"
+// TARGET-N32: "-target-cpu" "mips64r2"
+// TARGET-N32: "-target-abi" "n32"
+// TARGET-N32: ld{{.*}}"
+// TARGET-N32: "-m" "elf32btsmipn32"
+
+// RUN: %clang -target mips-linux-gnu -mabi=64 -### %s 2>&1 \
+// RUN: | FileCheck -check-prefix=TARGET-N64 %s
+// TARGET-N64: "-triple" "mips64-unknown-linux-gnu"
+// TARGET-N64: "-target-cpu" "mips64r2"
+// TARGET-N64: "-target-abi" "n64"
+// TARGET-N64: ld{{.*}}"
+// TARGET-N64: "-m" "elf64btsmip"
Index: lib/Driver/Driver.cpp
===================================================================
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -481,6 +481,16 @@
Target.setVendorName("intel");
}
+ // If target is MIPS adjust the target triple
+ // accordingly to provided ABI name.
+ A = Args.getLastArg(options::OPT_mabi_EQ);
+ if (A && Target.isMIPS())
+ Target = llvm::StringSwitch<llvm::Triple>(A->getValue())
+ .Case("32", Target.get32BitArchVariant())
+ .Case("n32", Target.get64BitArchVariant())
+ .Case("64", Target.get64BitArchVariant())
+ .Default(Target);
+
return Target;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52290.167091.patch
Type: text/x-patch
Size: 2002 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180926/3e73e79a/attachment.bin>
More information about the cfe-commits
mailing list