From 02ab7d3c0e1e5278ca0451dc846aedcf45e623cf Mon Sep 17 00:00:00 2001 From: Renato Golin Date: Sat, 24 Aug 2013 14:44:41 +0000 Subject: [PATCH] Add gcc ARM flags -munaligned-access / -mno-unaligned-access clang already had a mstrict-align which mentiones "Force all memory accesses to be aligned (ARM only)". On gcc arm this is controlled by -munaligned-access / -mno-unaligned-access. Add the gcc versions to the frontend and make -mstrict-align and alias to -mno-unaligned-access and only show it in clang -cc1 -help. Since the default value for unaligned accesses / strict alignment depends on the tripple, both the enable and disable flags are added. If both are set, the no-unaligned-access is used. Patch by Jeroen Hofstee. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189175 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Driver/Options.td | 8 ++++++-- lib/Driver/Tools.cpp | 11 ++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 24759ceffe..a9e2f53d2a 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -942,8 +942,6 @@ def mstackrealign : Flag<["-"], "mstackrealign">, Group, Flags<[CC1Opti HelpText<"Force realign the stack at entry to every function">; def mstack_alignment : Joined<["-"], "mstack-alignment=">, Group, Flags<[CC1Option]>, HelpText<"Set the stack alignment">; -def mstrict_align : Flag<["-"], "mstrict-align">, Group, Flags<[CC1Option]>, - HelpText<"Force all memory accesses to be aligned (ARM only)">; def mmmx : Flag<["-"], "mmmx">, Group; def mno_3dnowa : Flag<["-"], "mno-3dnowa">, Group; def mno_3dnow : Flag<["-"], "mno-3dnow">, Group; @@ -987,6 +985,12 @@ def mno_rtm : Flag<["-"], "mno-rtm">, Group; def mno_prfchw : Flag<["-"], "mno-prfchw">, Group; def mno_rdseed : Flag<["-"], "mno-rdseed">, Group; +def munaligned_access : Flag<["-"], "munaligned-access">, Group, + HelpText<"Allow memory accesses to be unaligned (ARM only)">; +def mno_unaligned_access : Flag<["-"], "mno-unaligned-access">, Group, + HelpText<"Force all memory accesses to be aligned (ARM only)">; +def mstrict_align : Flag<["-"], "mstrict-align">, Alias, Flags<[CC1Option,HelpHidden]>, + HelpText<"Force all memory accesses to be aligned (ARM only, same as mno-unaligned-access)">; def mno_thumb : Flag<["-"], "mno-thumb">, Group; def marm : Flag<["-"], "marm">, Alias; def ffixed_r9 : Flag<["-"], "ffixed-r9">, Group, diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 71cbcb292f..1d5b18f0c9 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -2941,9 +2941,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back(Args.MakeArgString("-mstack-alignment=" + alignment)); } // -mkernel implies -mstrict-align; don't add the redundant option. - if (Args.hasArg(options::OPT_mstrict_align) && !KernelOrKext) { - CmdArgs.push_back("-backend-option"); - CmdArgs.push_back("-arm-strict-align"); + if (!KernelOrKext) { + if (Args.hasArg(options::OPT_mno_unaligned_access)) { + CmdArgs.push_back("-backend-option"); + CmdArgs.push_back("-arm-strict-align"); + } else if (Args.hasArg(options::OPT_munaligned_access)) { + CmdArgs.push_back("-backend-option"); + CmdArgs.push_back("-arm-no-strict-align"); + } } // Forward -f options with positive and negative forms; we translate -- 2.40.0