sdardis updated this revision to Diff 76824.
sdardis added a comment.

Rebase and ping


https://reviews.llvm.org/D21072

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/MSVCToolChain.cpp
  lib/Driver/MinGWToolChain.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  test/Driver/mips-integrated-as.s

Index: test/Driver/mips-integrated-as.s
===================================================================
--- test/Driver/mips-integrated-as.s
+++ test/Driver/mips-integrated-as.s
@@ -1,3 +1,5 @@
+// RUN: %clang -target mips-linux-gnu -### -c %s 2>&1 | \
+// RUN:   FileCheck -check-prefix=ABI-O32 %s
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
 // RUN:   FileCheck -check-prefix=ABI-O32 %s
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mabi=32 2>&1 | \
@@ -293,3 +295,13 @@
 // IMG-SINGLEFLOAT-EXPLICIT-FPXX: "-target-feature" "+single-float"
 // IMG-SINGLEFLOAT-EXPLICIT-FPXX: "-target-feature" "+fpxx"
 // IMG-SINGLEFLOAT-EXPLICIT-FPXX: "-target-feature" "+nooddspreg"
+
+// RUN: %clang -target mips-linux-gnu -### -c %s -mips64 -mabi=n32 2>&1 | \
+// RUN:   FileCheck -check-prefix=GAS %s
+// RUN: %clang -target mips64-linux-gnu -### -c %s -mabi=n32 2>&1 | \
+// RUN:   FileCheck -check-prefix=GAS %s
+// RUN: %clang -target mips-linux-gnu -### -c %s -mips64 -mabi=64 2>&1 | \
+// RUN:   FileCheck -check-prefix=GAS %s
+// RUN: %clang -target mips64-linux-gnu -### -c %s 2>&1 | \
+// RUN:   FileCheck -check-prefix=GAS %s
+// GAS-NOT: -cc1as
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -4552,7 +4552,7 @@
   // Decide whether to use verbose asm. Verbose assembly is the default on
   // toolchains which have the integrated assembler on by default.
   bool IsIntegratedAssemblerDefault =
-      getToolChain().IsIntegratedAssemblerDefault();
+      getToolChain().IsIntegratedAssemblerDefault(Args);
   if (Args.hasFlag(options::OPT_fverbose_asm, options::OPT_fno_verbose_asm,
                    IsIntegratedAssemblerDefault) ||
       Args.hasArg(options::OPT_dA))
Index: lib/Driver/ToolChains.h
===================================================================
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -221,7 +221,8 @@
   bool isPICDefault() const override;
   bool isPIEDefault() const override;
   bool isPICDefaultForced() const override;
-  bool IsIntegratedAssemblerDefault() const override;
+  bool
+  IsIntegratedAssemblerDefault(const llvm::opt::ArgList &Args) const override;
   llvm::opt::DerivedArgList *
   TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
                 Action::OffloadKind DeviceOffloadKind) const override;
@@ -339,7 +340,8 @@
     // expected to use /usr/include/Block.h.
     return true;
   }
-  bool IsIntegratedAssemblerDefault() const override {
+  bool
+  IsIntegratedAssemblerDefault(const llvm::opt::ArgList &Args) const override {
     // Default integrated assembler to on for Apple's MachO targets.
     return true;
   }
@@ -657,7 +659,10 @@
   Solaris(const Driver &D, const llvm::Triple &Triple,
           const llvm::opt::ArgList &Args);
 
-  bool IsIntegratedAssemblerDefault() const override { return true; }
+  bool
+  IsIntegratedAssemblerDefault(const llvm::opt::ArgList &Args) const override {
+    return true;
+  }
 
   void AddClangCXXStdlibIncludeArgs(
       const llvm::opt::ArgList &DriverArgs,
@@ -675,7 +680,8 @@
   MinGW(const Driver &D, const llvm::Triple &Triple,
         const llvm::opt::ArgList &Args);
 
-  bool IsIntegratedAssemblerDefault() const override;
+  bool
+  IsIntegratedAssemblerDefault(const llvm::opt::ArgList &Args) const override;
   bool IsUnwindTablesDefault() const override;
   bool isPICDefault() const override;
   bool isPIEDefault() const override;
@@ -943,7 +949,10 @@
       const llvm::opt::ArgList &DriverArgs,
       llvm::opt::ArgStringList &CC1Args) const override {}
 
-  bool IsIntegratedAssemblerDefault() const override { return true; }
+  bool
+  IsIntegratedAssemblerDefault(const llvm::opt::ArgList &Args) const override {
+    return true;
+  }
 };
 
 class LLVM_LIBRARY_VISIBILITY HexagonToolChain : public Linux {
@@ -966,7 +975,8 @@
   CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
 
   StringRef GetGCCLibAndIncVersion() const { return GCCLibAndIncVersion.Text; }
-  bool IsIntegratedAssemblerDefault() const override {
+  bool
+  IsIntegratedAssemblerDefault(const llvm::opt::ArgList &Args) const override {
     return true;
   }
 
@@ -991,7 +1001,10 @@
   AMDGPUToolChain(const Driver &D, const llvm::Triple &Triple,
             const llvm::opt::ArgList &Args);
   unsigned GetDefaultDwarfVersion() const override { return 2; }
-  bool IsIntegratedAssemblerDefault() const override { return true; }
+  bool
+  IsIntegratedAssemblerDefault(const llvm::opt::ArgList &Args) const override {
+    return true;
+  }
 };
 
 class LLVM_LIBRARY_VISIBILITY NaClToolChain : public Generic_ELF {
@@ -1009,7 +1022,8 @@
   void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
                            llvm::opt::ArgStringList &CmdArgs) const override;
 
-  bool IsIntegratedAssemblerDefault() const override {
+  bool
+  IsIntegratedAssemblerDefault(const llvm::opt::ArgList &Args) const override {
     return getTriple().getArch() == llvm::Triple::mipsel;
   }
 
@@ -1036,7 +1050,7 @@
 
   bool isPIEDefault() const override { return true; }
   bool HasNativeLLVMSupport() const override { return true; }
-  bool IsIntegratedAssemblerDefault() const override { return true; }
+  bool IsIntegratedAssemblerDefault(const llvm::opt::ArgList &Args) const override { return true; }
   llvm::DebuggerKind getDefaultDebuggerTuning() const override {
     return llvm::DebuggerKind::GDB;
   }
@@ -1083,7 +1097,8 @@
   TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
                 Action::OffloadKind DeviceOffloadKind) const override;
 
-  bool IsIntegratedAssemblerDefault() const override;
+  bool
+  IsIntegratedAssemblerDefault(const llvm::opt::ArgList &Args) const override;
   bool IsUnwindTablesDefault() const override;
   bool isPICDefault() const override;
   bool isPIEDefault() const override;
@@ -1130,7 +1145,10 @@
   CrossWindowsToolChain(const Driver &D, const llvm::Triple &T,
                         const llvm::opt::ArgList &Args);
 
-  bool IsIntegratedAssemblerDefault() const override { return true; }
+  bool
+  IsIntegratedAssemblerDefault(const llvm::opt::ArgList &Args) const override {
+    return true;
+  }
   bool IsUnwindTablesDefault() const override;
   bool isPICDefault() const override;
   bool isPIEDefault() const override;
@@ -1225,7 +1243,8 @@
   bool isPICDefault() const override;
   bool isPIEDefault() const override;
   bool isPICDefaultForced() const override;
-  bool IsIntegratedAssemblerDefault() const override;
+  bool
+  IsIntegratedAssemblerDefault(const llvm::opt::ArgList &Args) const override;
   bool hasBlocksRuntime() const override;
   bool SupportsObjCGC() const override;
   bool SupportsProfiling() const override;
Index: lib/Driver/ToolChains.cpp
===================================================================
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -2805,8 +2805,10 @@
   return getArch() == llvm::Triple::x86_64 && getTriple().isOSWindows();
 }
 
-bool Generic_GCC::IsIntegratedAssemblerDefault() const {
-  switch (getTriple().getArch()) {
+bool Generic_GCC::IsIntegratedAssemblerDefault(const ArgList &Args) const {
+  llvm::Triple Triple = getTriple();
+
+  switch (Triple.getArch()) {
   case llvm::Triple::x86:
   case llvm::Triple::x86_64:
   case llvm::Triple::aarch64:
@@ -2821,16 +2823,36 @@
   case llvm::Triple::ppc64:
   case llvm::Triple::ppc64le:
   case llvm::Triple::systemz:
+    return true;
   case llvm::Triple::mips:
-  case llvm::Triple::mipsel:
+  case llvm::Triple::mipsel: {
+    // Convert a GNU style Mips ABI name to the name
+    // accepted by LLVM Mips backend.
+    llvm::StringRef ABIName = Args.getLastArgValue(options::OPT_mabi_EQ);
+    ABIName = llvm::StringSwitch<llvm::StringRef>(ABIName)
+                  .Case("32", "o32")
+                  .Case("64", "n64")
+                  .Default(ABIName);
+    llvm::Triple ABITriple;
+    std::tie(ABITriple, ABIName) = getTriple().getABIVariant(ABIName);
+    if (ABITriple.getArch() != llvm::Triple::UnknownArch)
+      Triple = ABITriple;
+    if (Triple.getEnvironment() == llvm::Triple::ABIN32 ||
+        Triple.getEnvironment() == llvm::Triple::ABI64 ||
+        Triple.getEnvironment() == llvm::Triple::GNUABIN32 ||
+        Triple.getEnvironment() == llvm::Triple::GNUABI64 ||
+        Triple.getEnvironment() == llvm::Triple::AndroidABI64)
+      return false;
     return true;
+  }
   case llvm::Triple::mips64:
-  case llvm::Triple::mips64el:
+  case llvm::Triple::mips64el: {
     // Enabled for Debian mips64/mips64el only. Other targets are unable to
     // distinguish N32 from N64.
     if (getTriple().getEnvironment() == llvm::Triple::GNUABI64)
       return true;
     return false;
+  }
   default:
     return false;
   }
@@ -5239,7 +5261,9 @@
 
 bool WebAssembly::isPICDefaultForced() const { return false; }
 
-bool WebAssembly::IsIntegratedAssemblerDefault() const { return true; }
+bool WebAssembly::IsIntegratedAssemblerDefault(const ArgList &Args) const {
+  return true;
+}
 
 // TODO: Support Objective C stuff.
 bool WebAssembly::SupportsObjCGC() const { return false; }
Index: lib/Driver/ToolChain.cpp
===================================================================
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -84,7 +84,7 @@
 bool ToolChain::useIntegratedAs() const {
   return Args.hasFlag(options::OPT_fintegrated_as,
                       options::OPT_fno_integrated_as,
-                      IsIntegratedAssemblerDefault());
+                      IsIntegratedAssemblerDefault(Args));
 }
 
 const SanitizerArgs& ToolChain::getSanitizerArgs() const {
Index: lib/Driver/MinGWToolChain.cpp
===================================================================
--- lib/Driver/MinGWToolChain.cpp
+++ lib/Driver/MinGWToolChain.cpp
@@ -96,7 +96,9 @@
   getFilePaths().push_back(Base + Arch + "/sys-root/mingw/lib");
 }
 
-bool MinGW::IsIntegratedAssemblerDefault() const { return true; }
+bool MinGW::IsIntegratedAssemblerDefault(const ArgList &Args) const {
+  return true;
+}
 
 Tool *MinGW::getTool(Action::ActionClass AC) const {
   switch (AC) {
Index: lib/Driver/MSVCToolChain.cpp
===================================================================
--- lib/Driver/MSVCToolChain.cpp
+++ lib/Driver/MSVCToolChain.cpp
@@ -65,7 +65,7 @@
   return nullptr;
 }
 
-bool MSVCToolChain::IsIntegratedAssemblerDefault() const {
+bool MSVCToolChain::IsIntegratedAssemblerDefault(const ArgList &Args) const {
   return true;
 }
 
Index: include/clang/Driver/ToolChain.h
===================================================================
--- include/clang/Driver/ToolChain.h
+++ include/clang/Driver/ToolChain.h
@@ -245,7 +245,10 @@
 
   /// IsIntegratedAssemblerDefault - Does this tool chain enable -integrated-as
   /// by default.
-  virtual bool IsIntegratedAssemblerDefault() const { return false; }
+  virtual bool
+  IsIntegratedAssemblerDefault(const llvm::opt::ArgList &Args) const {
+    return false;
+  }
 
   /// \brief Check if the toolchain should use the integrated assembler.
   virtual bool useIntegratedAs() const;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to