Skip to content

Commit

Permalink
Add gcc ARM flags -munaligned-access / -mno-unaligned-access
Browse files Browse the repository at this point in the history
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.

llvm-svn: 189175
  • Loading branch information
rengolin committed Aug 24, 2013
1 parent dbb77e6 commit a146a48
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
8 changes: 6 additions & 2 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand Down Expand Up @@ -987,6 +985,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>,
Expand Down
11 changes: 8 additions & 3 deletions clang/lib/Driver/Tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a146a48

Please sign in to comment.