From dbb77e60dc8b6dedd98804cd1667d2d295e306b6 Mon Sep 17 00:00:00 2001 From: Renato Golin Date: Sat, 24 Aug 2013 14:44:35 +0000 Subject: [PATCH] Add the -ffixed-r9 flag for ARM. This patch adds the -ffixed-r9 flag to clang to instruct llvm to globally preserve the contents of r9. The flag is added to the newly created ARM specific group. While at it, also place marm / mno-thumb in that group. Patch by Jeroen Hofstee. llvm-svn: 189174 --- clang/include/clang/Driver/Options.td | 5 ++++- clang/lib/Driver/Tools.cpp | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 33a14a4b1bff..24759ceffed5 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -72,6 +72,7 @@ def clang_i_Group : OptionGroup<"">, Group; def m_Group : OptionGroup<"">, Group; def m_x86_Features_Group : OptionGroup<"">, Group; def m_hexagon_Features_Group : OptionGroup<"">, Group; +def m_arm_Features_Group : OptionGroup<"">, Group; def opencl_Group : OptionGroup<"">; def u_Group : OptionGroup<"">; def mips_CPUs_Group : OptionGroup<"">, @@ -986,8 +987,10 @@ def mno_rtm : Flag<["-"], "mno-rtm">, Group; def mno_prfchw : Flag<["-"], "mno-prfchw">, Group; def mno_rdseed : Flag<["-"], "mno-rdseed">, Group; -def mno_thumb : Flag<["-"], "mno-thumb">, Group; +def mno_thumb : Flag<["-"], "mno-thumb">, Group; def marm : Flag<["-"], "marm">, Alias; +def ffixed_r9 : Flag<["-"], "ffixed-r9">, Group, + HelpText<"Reserve the r9 register (ARM only)">; def mno_warn_nonportable_cfstrings : Flag<["-"], "mno-warn-nonportable-cfstrings">, Group; def mno_omit_leaf_frame_pointer : Flag<["-"], "mno-omit-leaf-frame-pointer">, Group; diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index 25be6b48b660..71cbcb292f7b 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -795,6 +795,14 @@ void Clang::AddARMTargetArgs(const ArgList &Args, options::OPT_mno_implicit_float, true)) CmdArgs.push_back("-no-implicit-float"); + + // llvm does not support reserving registers in general. There is support + // for reserving r9 on ARM though (defined as a platform-specific register + // in ARM EABI). + if (Args.hasArg(options::OPT_ffixed_r9)) { + CmdArgs.push_back("-backend-option"); + CmdArgs.push_back("-arm-reserve-r9"); + } } // Translate MIPS CPU name alias option to CPU name.