Hello,
In commit [1] mstrict-align is added as a cc1 option for ARM.
"Force all memory accesses to be aligned. (ARM only)"
GCC has this flag, but only for powerpc, which states:
"On System V.4 and embedded PowerPC systems do not (do)
assume that unaligned memory references are handled by
the system. "
On ARM gcc supports the -munaligned-access / -mno-unaligned-access,
flags, which I am looking for:
"Enables (or disables) reading and writing of 16- and 32- bit
values from addresses that are not 16- or 32- bit aligned.
By default unaligned access is disabled for all pre-ARMv6
and all ARMv6-M architectures, and enabled for all other
architectures. If unaligned access is not enabled then
words in packed data structures will be accessed a byte
at a time."
I am not sure if there are subtle differences between these.
Attached patch assumes they are exactly the same and adds
the gcc flags while preserving the cc1 as well.
This patch depends on the -ffixed-r9 patch for creating the
ARM specific group.
Regards,
Jeroen
[1] http://llvm.org/viewvc/llvm-project?view=revision&revision=167619
[2]
http://gcc.gnu.org/onlinedocs/gcc-4.8.1/gcc/RS_002f6000-and-PowerPC-Options.html#RS_002f6000-and-PowerPC-Options
[3] http://gcc.gnu.org/onlinedocs/gcc-4.8.1/gcc/ARM-Options.html#ARM-Options
commit 93d539712a3de0a25162970f79d2c188d1815a49
Author: Jeroen Hofstee <[email protected]>
Date: Fri Aug 16 19:43:54 2013 +0200
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.
diff --git include/clang/Driver/Options.td include/clang/Driver/Options.td
index 4594139..338c897 100644
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -942,8 +942,6 @@ def mstackrealign : Flag<["-"], "mstackrealign">, Group<m_Group>, Flags<[CC1Opti
HelpText<"Force realign the stack at entry to every function">;
def mstack_alignment : Joined<["-"], "mstack-alignment=">, Group<m_Group>, Flags<[CC1Option]>,
HelpText<"Set the stack alignment">;
-def mstrict_align : Flag<["-"], "mstrict-align">, Group<m_Group>, Flags<[CC1Option]>,
- HelpText<"Force all memory accesses to be aligned (ARM only)">;
def mmmx : Flag<["-"], "mmmx">, Group<m_x86_Features_Group>;
def mno_3dnowa : Flag<["-"], "mno-3dnowa">, Group<m_x86_Features_Group>;
def mno_3dnow : Flag<["-"], "mno-3dnow">, Group<m_x86_Features_Group>;
@@ -983,6 +981,12 @@ def mno_rtm : Flag<["-"], "mno-rtm">, Group<m_x86_Features_Group>;
def mno_prfchw : Flag<["-"], "mno-prfchw">, Group<m_x86_Features_Group>;
def mno_rdseed : Flag<["-"], "mno-rdseed">, Group<m_x86_Features_Group>;
+def munaligned_access : Flag<["-"], "munaligned-access">, Group<m_arm_Features_Group>,
+ HelpText<"Allow memory accesses to be unaligned (ARM only)">;
+def mno_unaligned_access : Flag<["-"], "mno-unaligned-access">, Group<m_arm_Features_Group>,
+ HelpText<"Force all memory accesses to be aligned (ARM only)">;
+def mstrict_align : Flag<["-"], "mstrict-align">, Alias<mno_unaligned_access>, 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<m_arm_Features_Group>;
def marm : Flag<["-"], "marm">, Alias<mno_thumb>;
def ffixed_r9 : Flag<["-"], "ffixed-r9">, Group<m_arm_Features_Group>,
diff --git lib/Driver/Tools.cpp lib/Driver/Tools.cpp
index 3c8300e..529d226 100644
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2945,9 +2945,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
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits