From 4368b2f937a74d95e211c3b11617c84d864f5d0c Mon Sep 17 00:00:00 2001 From: Oliver Stannard Date: Wed, 27 Jul 2016 08:54:13 +0000 Subject: [PATCH] [ARM] Pass -mimplcit-it= to integrated assembler Differential Revision: https://reviews.llvm.org/D22761 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@276851 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Driver/Options.td | 1 + lib/Driver/Tools.cpp | 21 +++++++++++++++++++++ test/Driver/arm-implicit-it.s | 24 ++++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 test/Driver/arm-implicit-it.s diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 552a161341..853fdcd7c7 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -1377,6 +1377,7 @@ def mwatchsimulator_version_min_EQ : Joined<["-"], "mwatchsimulator-version-min= def march_EQ : Joined<["-"], "march=">, Group; def masm_EQ : Joined<["-"], "masm=">, Group, Flags<[DriverOption]>; def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group; +def mimplicit_it_EQ : Joined<["-"], "mimplicit-it=">, Group; def mconstant_cfstrings : Flag<["-"], "mconstant-cfstrings">, Group; def mconsole : Joined<["-"], "mconsole">, Group, Flags<[DriverOption]>; def mwindows : Joined<["-"], "mwindows">, Group, Flags<[DriverOption]>; diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index e747149679..bd306dd677 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -2882,6 +2882,27 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, DefaultIncrementalLinkerCompatible)) CmdArgs.push_back("-mincremental-linker-compatible"); + switch (C.getDefaultToolChain().getArch()) { + case llvm::Triple::arm: + case llvm::Triple::armeb: + case llvm::Triple::thumb: + case llvm::Triple::thumbeb: + if (Arg *A = Args.getLastArg(options::OPT_mimplicit_it_EQ)) { + StringRef Value = A->getValue(); + if (Value == "always" || Value == "never" || Value == "arm" || + Value == "thumb") { + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back(Args.MakeArgString("-arm-implicit-it=" + Value)); + } else { + D.Diag(diag::err_drv_unsupported_option_argument) + << A->getOption().getName() << Value; + } + } + break; + default: + break; + } + // When passing -I arguments to the assembler we sometimes need to // unconditionally take the next argument. For example, when parsing // '-Wa,-I -Wa,foo' we need to accept the -Wa,foo arg after seeing the diff --git a/test/Driver/arm-implicit-it.s b/test/Driver/arm-implicit-it.s new file mode 100644 index 0000000000..48e4bdbe8c --- /dev/null +++ b/test/Driver/arm-implicit-it.s @@ -0,0 +1,24 @@ +// RUN: %clang -target armv7--none-eabi -### %s 2>&1 \ +// RUN: | FileCheck %s -check-prefix CHECK-DEFAULT + +// RUN: %clang -target armv7--none-eabi -mimplicit-it=arm -### %s 2>&1 \ +// RUN: | FileCheck %s -check-prefix CHECK-ARM + +// RUN: %clang -target armv7--none-eabi -mimplicit-it=thumb -### %s 2>&1 \ +// RUN: | FileCheck %s -check-prefix CHECK-THUMB + +// RUN: %clang -target armv7--none-eabi -mimplicit-it=never -### %s 2>&1 \ +// RUN: | FileCheck %s -check-prefix CHECK-NEVER + +// RUN: %clang -target armv7--none-eabi -mimplicit-it=always -### %s 2>&1 \ +// RUN: | FileCheck %s -check-prefix CHECK-ALWAYS + +// RUN: %clang -target armv7--none-eabi -mimplicit-it=thisisnotavalidoption -### %s 2>&1 \ +// RUN: | FileCheck %s -check-prefix CHECK-INVALID + +// CHECK-DEFAULT-NOT: "-arm-implicit-it +// CHECK-ARM: "-arm-implicit-it=arm" +// CHECK-THUMB: "-arm-implicit-it=thumb" +// CHECK-NEVER: "-arm-implicit-it=never" +// CHECK-ALWAYS: "-arm-implicit-it=always" +// CHECK-INVALID: error: unsupported argument 'thisisnotavalidoption' to option 'mimplicit-it=' -- 2.40.0