Simplify switch statement in ARM subtarget align access

This switch can be reduced to a simpler if/else statement.

Patch by Charlie Turner.

llvm-svn: 219299
This commit is contained in:
Renato Golin 2014-10-08 12:26:13 +00:00
parent 8068b643c4
commit 51dc3f4701
1 changed files with 24 additions and 30 deletions

View File

@ -292,37 +292,31 @@ void ARMSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
SupportsTailCall = !isThumb1Only();
}
switch (Align) {
case DefaultAlign:
// Assume pre-ARMv6 doesn't support unaligned accesses.
//
// ARMv6 may or may not support unaligned accesses depending on the
// SCTLR.U bit, which is architecture-specific. We assume ARMv6
// Darwin and NetBSD targets support unaligned accesses, and others don't.
//
// ARMv7 always has SCTLR.U set to 1, but it has a new SCTLR.A bit
// which raises an alignment fault on unaligned accesses. Linux
// defaults this bit to 0 and handles it as a system-wide (not
// per-process) setting. It is therefore safe to assume that ARMv7+
// Linux targets support unaligned accesses. The same goes for NaCl.
//
// The above behavior is consistent with GCC.
AllowsUnalignedMem =
(hasV7Ops() && (isTargetLinux() || isTargetNaCl() ||
isTargetNetBSD())) ||
(hasV6Ops() && (isTargetMachO() || isTargetNetBSD()));
// The one exception is cortex-m0, which despite being v6, does not
// support unaligned accesses. Rather than make the above boolean
// expression even more obtuse, just override the value here.
if (isThumb1Only() && isMClass())
AllowsUnalignedMem = false;
break;
case StrictAlign:
if (Align == DefaultAlign) {
// Assume pre-ARMv6 doesn't support unaligned accesses.
//
// ARMv6 may or may not support unaligned accesses depending on the
// SCTLR.U bit, which is architecture-specific. We assume ARMv6
// Darwin and NetBSD targets support unaligned accesses, and others don't.
//
// ARMv7 always has SCTLR.U set to 1, but it has a new SCTLR.A bit
// which raises an alignment fault on unaligned accesses. Linux
// defaults this bit to 0 and handles it as a system-wide (not
// per-process) setting. It is therefore safe to assume that ARMv7+
// Linux targets support unaligned accesses. The same goes for NaCl.
//
// The above behavior is consistent with GCC.
AllowsUnalignedMem =
(hasV7Ops() && (isTargetLinux() || isTargetNaCl() ||
isTargetNetBSD())) ||
(hasV6Ops() && (isTargetMachO() || isTargetNetBSD()));
// The one exception is cortex-m0, which despite being v6, does not
// support unaligned accesses. Rather than make the above boolean
// expression even more obtuse, just override the value here.
if (isThumb1Only() && isMClass())
AllowsUnalignedMem = false;
break;
case NoStrictAlign:
AllowsUnalignedMem = true;
break;
} else {
AllowsUnalignedMem = !(Align == StrictAlign);
}
switch (IT) {