[PATCH] D52418: [driver][mips] Enable integrated assembler for MIPS64 except N32 ABI selected

Simon Atanasyan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 24 07:21:44 PDT 2018


atanasyan created this revision.
atanasyan added reviewers: rsmith, rnk, zturner.
Herald added subscribers: jrtc27, arichardson, sdardis, srhines.

Enable integrated assembler for MIPS64 targets except N32 ABI explicitly selected by the `-mabi=n32` command line option or `mips64(el)-linux-gnuabin32` target triple.


Repository:
  rC Clang

https://reviews.llvm.org/D52418

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/mips-gnu-integrated-as.c


Index: test/Driver/mips-gnu-integrated-as.c
===================================================================
--- /dev/null
+++ test/Driver/mips-gnu-integrated-as.c
@@ -0,0 +1,27 @@
+# Check cases when MIPS cannot use the integrated assembler.
+
+# RUN: %clang -target mips-unknown-gnu -### -c %s 2>&1 \
+# RUN:   | FileCheck -check-prefix=INT %s
+# RUN: %clang -target mipsel-unknown-gnu -### -c %s 2>&1 \
+# RUN:   | FileCheck -check-prefix=INT %s
+# RUN: %clang -target mips64-unknown-gnu -### -c %s 2>&1 \
+# RUN:   | FileCheck -check-prefix=INT %s
+# RUN: %clang -target mips64el-unknown-gnu -### -c %s 2>&1 \
+# RUN:   | FileCheck -check-prefix=INT %s
+# RUN: %clang -target mips64-unknown-gnu -mabi=64 -### -c %s 2>&1 \
+# RUN:   | FileCheck -check-prefix=INT %s
+# RUN: %clang -target mips64el-unknown-gnu -mabi=64 -### -c %s 2>&1 \
+# RUN:   | FileCheck -check-prefix=INT %s
+
+# INT-NOT: "-no-integrated-as"
+
+# RUN: %clang -target mips64-linux-gnuabin32 -### -c %s 2>&1 \
+# RUN:   | FileCheck -check-prefix=EXT %s
+# RUN: %clang -target mips64el-linux-gnuabin32 -### -c %s 2>&1 \
+# RUN:   | FileCheck -check-prefix=EXT %s
+# RUN: %clang -target mips64-unknown-gnu -mabi=n32 -### -c %s 2>&1 \
+# RUN:   | FileCheck -check-prefix=EXT %s
+# RUN: %clang -target mips64el-unknown-gnu -mabi=n32 -### -c %s 2>&1 \
+# RUN:   | FileCheck -check-prefix=EXT %s
+
+# EXT: "-no-integrated-as"
Index: lib/Driver/ToolChains/Gnu.cpp
===================================================================
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -2408,15 +2408,9 @@
     return true;
   case llvm::Triple::mips64:
   case llvm::Triple::mips64el:
-    // Enabled for Debian, Android, FreeBSD and OpenBSD mips64/mipsel, as they
-    // can precisely identify the ABI in use (Debian) or only use N64 for MIPS64
-    // (Android). Other targets are unable to distinguish N32 from N64.
-    if (getTriple().getEnvironment() == llvm::Triple::GNUABI64 ||
-        getTriple().isAndroid() ||
-        getTriple().isOSFreeBSD() ||
-        getTriple().isOSOpenBSD())
-      return true;
-    return false;
+    // Do not use integrated assembler for N32 ABI only.
+    return !tools::mips::hasMipsAbiArg(getArgs(), "n32") &&
+           getTriple().getEnvironment() != llvm::Triple::GNUABIN32;
   default:
     return false;
   }
Index: include/clang/Driver/ToolChain.h
===================================================================
--- include/clang/Driver/ToolChain.h
+++ include/clang/Driver/ToolChain.h
@@ -156,6 +156,8 @@
 
   void setTripleEnvironment(llvm::Triple::EnvironmentType Env);
 
+  const llvm::opt::ArgList &getArgs() const { return Args; };
+
   virtual Tool *buildAssembler() const;
   virtual Tool *buildLinker() const;
   virtual Tool *getTool(Action::ActionClass AC) const;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52418.166664.patch
Type: text/x-patch
Size: 2818 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180924/9d7733e4/attachment-0001.bin>


More information about the cfe-commits mailing list