[PATCH] XCore target: add -march flag handling
robert lytton
robert at xmos.com
Tue Apr 29 06:13:31 PDT 2014
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"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3539.8916.patch
Type: text/x-patch
Size: 2581 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140429/a4fabe9a/attachment.bin>
More information about the cfe-commits
mailing list