Hi friedgold,

The -march setting needs to be passed to the assembler and linker if it is 
specified.
A default of "-march=xs1b" is used if it is not specified - or would you prefer 
not to emit it?

http://reviews.llvm.org/D3539

Files:
  lib/Driver/Tools.cpp
  test/Driver/xcore-opts.c

Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -7616,6 +7616,12 @@
 /// XCore Tools
 // We pass assemble and link construction to the xcc tool.
 
+static const char *getXCoreMarch(const ArgList &Args) {
+  if (const Arg *A = Args.getLastArg(options::OPT_march_EQ))
+    return A->getValue();
+  return "xs1b";
+}
+
 void XCore::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
                                        const InputInfo &Output,
                                        const InputInfoList &Inputs,
@@ -7635,6 +7641,9 @@
     if (!A->getOption().matches(options::OPT_g0))
       CmdArgs.push_back("-g");
 
+  StringRef March = getXCoreMarch(Args);
+  CmdArgs.push_back(Args.MakeArgString("-march=" + March));
+
   if (Args.hasFlag(options::OPT_fverbose_asm, options::OPT_fno_verbose_asm,
                    false))
     CmdArgs.push_back("-fverbose-asm");
@@ -7670,6 +7679,9 @@
   if (Args.hasArg(options::OPT_v))
     CmdArgs.push_back("-v");
 
+  StringRef March = getXCoreMarch(Args);
+  CmdArgs.push_back(Args.MakeArgString("-march=" + March));
+
   ExceptionSettings EH = exceptionSettings(Args, getToolChain().getTriple());
   if (EH.ShouldUseExceptionTables)
     CmdArgs.push_back("-fexceptions");
Index: test/Driver/xcore-opts.c
===================================================================
--- test/Driver/xcore-opts.c
+++ test/Driver/xcore-opts.c
@@ -2,6 +2,7 @@
 // RUN: %clang -target xcore -x c++ %s -g -Wl,L1Arg,L2Arg -Wa,A1Arg,A2Arg 
-fverbose-asm -v -### -o %t.o 2>&1 | FileCheck %s
 // RUN: %clang -target xcore -x c++ %s -fexceptions -### -o %t.o 2>&1 | 
FileCheck -check-prefix CHECK-EXCEP %s
 // RUN: %clang -target xcore %s -g0 -### -o %t.o 2>&1 | FileCheck 
-check-prefix CHECK-G0 %s
+// RUN: %clang -target xcore %s -march=xs0a -### -o %t.o 2>&1 | FileCheck 
-check-prefix CHECK-MARCH %s
 
 // CHECK: "-nostdsysteminc"
 // CHECK: "-momit-leaf-frame-pointer"
@@ -13,10 +14,10 @@
 // CHECK: "-fno-common"
 // CHECK: xcc" "-o"
 // CHECK-EXCEP-NOT: "-fexceptions"
-// CHECK: "-c" "-v" "-g" "-fverbose-asm" "A1Arg" "A2Arg"
+// CHECK: "-c" "-v" "-g" "-march=xs1b" "-fverbose-asm" "A1Arg" "A2Arg"
 // CHECK: xcc" "-o"
 // CHECK-EXCEP-NOT: "-fexceptions"
-// CHECK: "-v"
+// CHECK: "-v" "-march=xs1b"
 // CHECK: "L1Arg" "L2Arg"
 
 // CHECK-EXCEP: "-fno-use-cxa-atexit"
@@ -32,3 +33,7 @@
 // CHECK-G0-NOT: "-g"
 // CHECK-G0: xcc"
 
+// CHECK-MARCH: xcc"
+// CHECK-MARCH: "-march=xs0a"
+// CHECK-MARCH: xcc"
+// CHECK-MARCH: "-march=xs0a"
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -7616,6 +7616,12 @@
 /// XCore Tools
 // We pass assemble and link construction to the xcc tool.
 
+static const char *getXCoreMarch(const ArgList &Args) {
+  if (const Arg *A = Args.getLastArg(options::OPT_march_EQ))
+    return A->getValue();
+  return "xs1b";
+}
+
 void XCore::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
                                        const InputInfo &Output,
                                        const InputInfoList &Inputs,
@@ -7635,6 +7641,9 @@
     if (!A->getOption().matches(options::OPT_g0))
       CmdArgs.push_back("-g");
 
+  StringRef March = getXCoreMarch(Args);
+  CmdArgs.push_back(Args.MakeArgString("-march=" + March));
+
   if (Args.hasFlag(options::OPT_fverbose_asm, options::OPT_fno_verbose_asm,
                    false))
     CmdArgs.push_back("-fverbose-asm");
@@ -7670,6 +7679,9 @@
   if (Args.hasArg(options::OPT_v))
     CmdArgs.push_back("-v");
 
+  StringRef March = getXCoreMarch(Args);
+  CmdArgs.push_back(Args.MakeArgString("-march=" + March));
+
   ExceptionSettings EH = exceptionSettings(Args, getToolChain().getTriple());
   if (EH.ShouldUseExceptionTables)
     CmdArgs.push_back("-fexceptions");
Index: test/Driver/xcore-opts.c
===================================================================
--- test/Driver/xcore-opts.c
+++ test/Driver/xcore-opts.c
@@ -2,6 +2,7 @@
 // RUN: %clang -target xcore -x c++ %s -g -Wl,L1Arg,L2Arg -Wa,A1Arg,A2Arg -fverbose-asm -v -### -o %t.o 2>&1 | FileCheck %s
 // RUN: %clang -target xcore -x c++ %s -fexceptions -### -o %t.o 2>&1 | FileCheck -check-prefix CHECK-EXCEP %s
 // RUN: %clang -target xcore %s -g0 -### -o %t.o 2>&1 | FileCheck -check-prefix CHECK-G0 %s
+// RUN: %clang -target xcore %s -march=xs0a -### -o %t.o 2>&1 | FileCheck -check-prefix CHECK-MARCH %s
 
 // CHECK: "-nostdsysteminc"
 // CHECK: "-momit-leaf-frame-pointer"
@@ -13,10 +14,10 @@
 // CHECK: "-fno-common"
 // CHECK: xcc" "-o"
 // CHECK-EXCEP-NOT: "-fexceptions"
-// CHECK: "-c" "-v" "-g" "-fverbose-asm" "A1Arg" "A2Arg"
+// CHECK: "-c" "-v" "-g" "-march=xs1b" "-fverbose-asm" "A1Arg" "A2Arg"
 // CHECK: xcc" "-o"
 // CHECK-EXCEP-NOT: "-fexceptions"
-// CHECK: "-v"
+// CHECK: "-v" "-march=xs1b"
 // CHECK: "L1Arg" "L2Arg"
 
 // CHECK-EXCEP: "-fno-use-cxa-atexit"
@@ -32,3 +33,7 @@
 // CHECK-G0-NOT: "-g"
 // CHECK-G0: xcc"
 
+// CHECK-MARCH: xcc"
+// CHECK-MARCH: "-march=xs0a"
+// CHECK-MARCH: xcc"
+// CHECK-MARCH: "-march=xs0a"
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to