From: Krzysztof Parzyszek Date: Wed, 28 Feb 2018 20:31:55 +0000 (+0000) Subject: [Hexagon] Add -ffixed-r19 driver option and translate it to +reserved-r19 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ebeb737dbea833866a6cbfa66a9876083156baad;p=clang [Hexagon] Add -ffixed-r19 driver option and translate it to +reserved-r19 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326366 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 04ed098e89..464956f9fd 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -2496,6 +2496,8 @@ def mno_hexagon_hvx_double : Flag<[ "-" ], "mno-hvx-double">, Group, HelpText<"Disable Hexagon Double Vector eXtensions">; +def ffixed_r19: Flag<["-"], "ffixed-r19">, + HelpText<"Reserve the r19 register (Hexagon only)">; // X86 feature flags diff --git a/lib/Driver/ToolChains/Hexagon.cpp b/lib/Driver/ToolChains/Hexagon.cpp index 31281737c7..77193cd047 100644 --- a/lib/Driver/ToolChains/Hexagon.cpp +++ b/lib/Driver/ToolChains/Hexagon.cpp @@ -521,11 +521,15 @@ unsigned HexagonToolChain::getOptimizationLevel( void HexagonToolChain::addClangTargetOptions(const ArgList &DriverArgs, ArgStringList &CC1Args, Action::OffloadKind) const { - if (DriverArgs.hasArg(options::OPT_ffp_contract)) - return; - unsigned OptLevel = getOptimizationLevel(DriverArgs); - if (OptLevel >= 3) - CC1Args.push_back("-ffp-contract=fast"); + if (!DriverArgs.hasArg(options::OPT_ffp_contract)) { + unsigned OptLevel = getOptimizationLevel(DriverArgs); + if (OptLevel >= 3) + CC1Args.push_back("-ffp-contract=fast"); + } + if (DriverArgs.hasArg(options::OPT_ffixed_r19)) { + CC1Args.push_back("-target-feature"); + CC1Args.push_back("+reserved-r19"); + } } void HexagonToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs, diff --git a/test/Driver/hexagon-toolchain-elf.c b/test/Driver/hexagon-toolchain-elf.c index 7dc82f3519..8f4c320ce4 100644 --- a/test/Driver/hexagon-toolchain-elf.c +++ b/test/Driver/hexagon-toolchain-elf.c @@ -503,6 +503,16 @@ // CHECK060: "--noexecstack" "--trap" "--keep-locals" // CHECK060-NEXT: hexagon-link +// ----------------------------------------------------------------------------- +// ffixed-r19 +// ----------------------------------------------------------------------------- +// RUN: %clang -### -target hexagon-unknown-elf -ffixed-r19 %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK070 %s +// CHECK070: "-target-feature" "+reserved-r19" +// RUN: %clang -### -target hexagon-unknown-elf %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK071 %s +// CHECK071-NOT: "+reserved-r19" + // ----------------------------------------------------------------------------- // Misc Defaults // ----------------------------------------------------------------------------- @@ -510,6 +520,6 @@ // RUN: -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \ // RUN: -mcpu=hexagonv60 \ // RUN: %s 2>&1 \ -// RUN: | FileCheck -check-prefix=CHECK070 %s -// CHECK070: "-cc1" -// CHECK070: "-Wreturn-type" +// RUN: | FileCheck -check-prefix=CHECK080 %s +// CHECK080: "-cc1" +// CHECK080: "-Wreturn-type"