r175919 - Driver: Pass down the -march setting down to -cc1as on x86 too.

Benjamin Kramer benny.kra at googlemail.com
Fri Feb 22 12:55:17 PST 2013


Author: d0k
Date: Fri Feb 22 14:55:17 2013
New Revision: 175919

URL: http://llvm.org/viewvc/llvm-project?rev=175919&view=rev
Log:
Driver: Pass down the -march setting down to -cc1as on x86 too.

The assembler historically didn't make use of any target features, but this has
changed when support for old CPUs that don't support long nops was added.

Added:
    cfe/trunk/test/Driver/target-as.s
Modified:
    cfe/trunk/lib/Driver/Tools.cpp
    cfe/trunk/lib/Driver/Tools.h

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=175919&r1=175918&r2=175919&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Feb 22 14:55:17 2013
@@ -3325,6 +3325,15 @@ void ClangAs::AddARMTargetArgs(const Arg
     addFPMathArgs(D, A, Args, CmdArgs, getARMTargetCPU(Args, Triple));
 }
 
+void ClangAs::AddX86TargetArgs(const ArgList &Args,
+                               ArgStringList &CmdArgs) const {
+  // Set the CPU based on -march=.
+  if (const char *CPUName = getX86TargetCPU(Args, getToolChain().getTriple())) {
+    CmdArgs.push_back("-target-cpu");
+    CmdArgs.push_back(CPUName);
+  }
+}
+
 /// Add options related to the Objective-C runtime/ABI.
 ///
 /// Returns true if the runtime is non-fragile.
@@ -3500,6 +3509,11 @@ void ClangAs::ConstructJob(Compilation &
   case llvm::Triple::thumb:
     AddARMTargetArgs(Args, CmdArgs);
     break;
+
+  case llvm::Triple::x86:
+  case llvm::Triple::x86_64:
+    AddX86TargetArgs(Args, CmdArgs);
+    break;
   }
 
   // Ignore explicit -force_cpusubtype_ALL option.

Modified: cfe/trunk/lib/Driver/Tools.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.h?rev=175919&r1=175918&r2=175919&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.h (original)
+++ cfe/trunk/lib/Driver/Tools.h Fri Feb 22 14:55:17 2013
@@ -77,6 +77,7 @@ namespace tools {
   /// \brief Clang integrated assembler tool.
   class LLVM_LIBRARY_VISIBILITY ClangAs : public Tool {
     void AddARMTargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const;
+    void AddX86TargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const;
   public:
     ClangAs(const ToolChain &TC) : Tool("clang::as",
                                         "clang integrated assembler", TC) {}

Added: cfe/trunk/test/Driver/target-as.s
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/target-as.s?rev=175919&view=auto
==============================================================================
--- cfe/trunk/test/Driver/target-as.s (added)
+++ cfe/trunk/test/Driver/target-as.s Fri Feb 22 14:55:17 2013
@@ -0,0 +1,8 @@
+// REQUIRES: clang-driver
+
+// Make sure the -march is passed down to cc1as.
+// RUN: %clang -target i386-unknown-freebsd -### -c -integrated-as %s \
+// RUN: -march=geode 2>&1 | FileCheck -check-prefix=TARGET %s
+//
+// TARGET: "-cc1as"
+// TARGET: "-target-cpu" "geode"





More information about the cfe-commits mailing list