Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 4fb2f33

Browse files
committed
[ARM] Define subtarget feature strict-align.
This commit defines subtarget feature strict-align and uses it instead of cl::opt -arm-strict-align to decide whether strict alignment should be forced. Also, remove the logic that was checking the OS and architecture as clang is now responsible for setting strict-align based on the command line options specified and the target architecute and OS. rdar://problem/21529937 http://reviews.llvm.org/D11470 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243493 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent db059db commit 4fb2f33

9 files changed

+74
-129
lines changed

lib/Target/ARM/ARM.td

+5
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ def FeatureAClass : SubtargetFeature<"aclass", "ARMProcClass", "AClass",
150150
def FeatureNaClTrap : SubtargetFeature<"nacl-trap", "UseNaClTrap", "true",
151151
"NaCl trap">;
152152

153+
def FeatureStrictAlign : SubtargetFeature<"strict-align",
154+
"StrictAlign", "true",
155+
"Disallow all unaligned memory "
156+
"access">;
157+
153158
def FeatureLongCalls : SubtargetFeature<"long-calls", "GenLongCalls", "true",
154159
"Generate calls via indirect call "
155160
"instructions">;

lib/Target/ARM/ARMSubtarget.cpp

+1-48
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,6 @@ static cl::opt<bool>
4343
UseFusedMulOps("arm-use-mulops",
4444
cl::init(true), cl::Hidden);
4545

46-
namespace {
47-
enum AlignMode {
48-
DefaultAlign,
49-
StrictAlign,
50-
NoStrictAlign
51-
};
52-
}
53-
54-
static cl::opt<AlignMode>
55-
Align(cl::desc("Load/store alignment support"),
56-
cl::Hidden, cl::init(DefaultAlign),
57-
cl::values(
58-
clEnumValN(DefaultAlign, "arm-default-align",
59-
"Generate unaligned accesses only on hardware/OS "
60-
"combinations that are known to support them"),
61-
clEnumValN(StrictAlign, "arm-strict-align",
62-
"Disallow all unaligned memory accesses"),
63-
clEnumValN(NoStrictAlign, "arm-no-strict-align",
64-
"Allow unaligned memory accesses"),
65-
clEnumValEnd));
66-
6746
enum ITMode {
6847
DefaultIT,
6948
RestrictedIT,
@@ -161,7 +140,7 @@ void ARMSubtarget::initializeEnvironment() {
161140
HasCrypto = false;
162141
HasCRC = false;
163142
HasZeroCycleZeroing = false;
164-
AllowsUnalignedMem = false;
143+
StrictAlign = false;
165144
Thumb2DSP = false;
166145
UseNaClTrap = false;
167146
GenLongCalls = false;
@@ -213,32 +192,6 @@ void ARMSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
213192
else
214193
SupportsTailCall = !isThumb1Only();
215194

216-
if (Align == DefaultAlign) {
217-
// Assume pre-ARMv6 doesn't support unaligned accesses.
218-
//
219-
// ARMv6 may or may not support unaligned accesses depending on the
220-
// SCTLR.U bit, which is architecture-specific. We assume ARMv6
221-
// Darwin and NetBSD targets support unaligned accesses, and others don't.
222-
//
223-
// ARMv7 always has SCTLR.U set to 1, but it has a new SCTLR.A bit
224-
// which raises an alignment fault on unaligned accesses. Linux
225-
// defaults this bit to 0 and handles it as a system-wide (not
226-
// per-process) setting. It is therefore safe to assume that ARMv7+
227-
// Linux targets support unaligned accesses. The same goes for NaCl.
228-
//
229-
// The above behavior is consistent with GCC.
230-
AllowsUnalignedMem =
231-
(hasV7Ops() && (isTargetLinux() || isTargetNaCl() ||
232-
isTargetNetBSD())) ||
233-
(hasV6Ops() && (isTargetMachO() || isTargetNetBSD()));
234-
} else {
235-
AllowsUnalignedMem = !(Align == StrictAlign);
236-
}
237-
238-
// No v6M core supports unaligned memory access (v6M ARM ARM A3.2)
239-
if (isV6M())
240-
AllowsUnalignedMem = false;
241-
242195
switch (IT) {
243196
case DefaultIT:
244197
RestrictIT = hasV8Ops();

lib/Target/ARM/ARMSubtarget.h

+3-7
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,10 @@ class ARMSubtarget : public ARMGenSubtargetInfo {
190190
/// particularly effective at zeroing a VFP register.
191191
bool HasZeroCycleZeroing;
192192

193-
/// AllowsUnalignedMem - If true, the subtarget allows unaligned memory
193+
/// StrictAlign - If true, the subtarget disallows unaligned memory
194194
/// accesses for some types. For details, see
195195
/// ARMTargetLowering::allowsMisalignedMemoryAccesses().
196-
bool AllowsUnalignedMem;
196+
bool StrictAlign;
197197

198198
/// RestrictIT - If true, the subtarget disallows generation of deprecated IT
199199
/// blocks to conform to ARMv8 rule.
@@ -409,10 +409,6 @@ class ARMSubtarget : public ARMGenSubtargetInfo {
409409
bool isRClass() const { return ARMProcClass == RClass; }
410410
bool isAClass() const { return ARMProcClass == AClass; }
411411

412-
bool isV6M() const {
413-
return isThumb1Only() && isMClass();
414-
}
415-
416412
bool isR9Reserved() const {
417413
return isTargetMachO() ? (ReserveR9 || !HasV6Ops) : ReserveR9;
418414
}
@@ -421,7 +417,7 @@ class ARMSubtarget : public ARMGenSubtargetInfo {
421417

422418
bool supportsTailCall() const { return SupportsTailCall; }
423419

424-
bool allowsUnalignedMem() const { return AllowsUnalignedMem; }
420+
bool allowsUnalignedMem() const { return !StrictAlign; }
425421

426422
bool restrictIT() const { return RestrictIT; }
427423

test/CodeGen/ARM/2011-10-26-memset-inline.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; Make sure short memsets on ARM lower to stores, even when optimizing for size.
2-
; RUN: llc -march=arm < %s | FileCheck %s -check-prefix=CHECK-GENERIC
2+
; RUN: llc -march=arm -mattr=+strict-align < %s | FileCheck %s -check-prefix=CHECK-GENERIC
33
; RUN: llc -march=arm -mcpu=cortex-a8 < %s | FileCheck %s -check-prefix=CHECK-UNALIGNED
44

55
target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:32:64-v128:32:128-a0:0:32-n32-S32"

0 commit comments

Comments
 (0)