Skip to content

Commit 7482d40

Browse files
committedJul 20, 2015
[ARM] Define subtarget feature "reserve-r9", which is used to decide
whether register r9 should be reserved. This change is needed because we cannot use a backend option to set cl::opt "arm-reserve-r9" when doing LTO. Out-of-tree projects currently using cl::opt option "-arm-reserve-r9" to reserve r9 should make changes to add subtarget feature "reserve-r9" to the IR. rdar://problem/21529937 Differential Revision: http://reviews.llvm.org/D11320 llvm-svn: 242737
1 parent 6b7fff9 commit 7482d40

File tree

5 files changed

+14
-15
lines changed

5 files changed

+14
-15
lines changed
 

‎llvm/lib/Target/ARM/ARM.td

+4
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ def FeatureLongCalls : SubtargetFeature<"long-calls", "GenLongCalls", "true",
154154
"Generate calls via indirect call "
155155
"instructions">;
156156

157+
def FeatureReserveR9 : SubtargetFeature<"reserve-r9", "ReserveR9", "true",
158+
"Reserve R9, making it unavailable as "
159+
"GPR">;
160+
157161
def FeatureNoMovt : SubtargetFeature<"no-movt", "NoMovt", "true",
158162
"Don't use movt/movw pairs for 32-bit "
159163
"imms">;

‎llvm/lib/Target/ARM/ARMSubtarget.cpp

+3-10
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ using namespace llvm;
3939
#define GET_SUBTARGETINFO_CTOR
4040
#include "ARMGenSubtargetInfo.inc"
4141

42-
static cl::opt<bool>
43-
ReserveR9("arm-reserve-r9", cl::Hidden,
44-
cl::desc("Reserve R9, making it unavailable as GPR"));
45-
4642
static cl::opt<bool>
4743
UseFusedMulOps("arm-use-mulops",
4844
cl::init(true), cl::Hidden);
@@ -144,7 +140,7 @@ void ARMSubtarget::initializeEnvironment() {
144140
UseSoftFloat = false;
145141
HasThumb2 = false;
146142
NoARM = false;
147-
IsR9Reserved = ReserveR9;
143+
ReserveR9 = false;
148144
NoMovt = false;
149145
SupportsTailCall = false;
150146
HasFP16 = false;
@@ -212,13 +208,10 @@ void ARMSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
212208
if (isTargetNaCl())
213209
stackAlignment = 16;
214210

215-
if (isTargetMachO()) {
216-
IsR9Reserved = ReserveR9 || !HasV6Ops;
211+
if (isTargetMachO())
217212
SupportsTailCall = !isTargetIOS() || !getTargetTriple().isOSVersionLT(5, 0);
218-
} else {
219-
IsR9Reserved = ReserveR9;
213+
else
220214
SupportsTailCall = !isThumb1Only();
221-
}
222215

223216
if (Align == DefaultAlign) {
224217
// Assume pre-ARMv6 doesn't support unaligned accesses.

‎llvm/lib/Target/ARM/ARMSubtarget.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ class ARMSubtarget : public ARMGenSubtargetInfo {
109109
/// NoARM - True if subtarget does not support ARM mode execution.
110110
bool NoARM;
111111

112-
/// IsR9Reserved - True if R9 is a not available as general purpose register.
113-
bool IsR9Reserved;
112+
/// ReserveR9 - True if R9 is not available as a general purpose register.
113+
bool ReserveR9;
114114

115115
/// NoMovt - True if MOVT / MOVW pairs are not used for materialization of
116116
/// 32-bit imms (including global addresses).
@@ -413,7 +413,9 @@ class ARMSubtarget : public ARMGenSubtargetInfo {
413413
return isThumb1Only() && isMClass();
414414
}
415415

416-
bool isR9Reserved() const { return IsR9Reserved; }
416+
bool isR9Reserved() const {
417+
return isTargetMachO() ? (ReserveR9 || !HasV6Ops) : ReserveR9;
418+
}
417419

418420
bool useMovt(const MachineFunction &MF) const;
419421

‎llvm/test/CodeGen/ARM/2007-03-13-InstrSched.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
; RUN: llc < %s -mtriple=arm-apple-darwin -relocation-model=pic \
33
; RUN: -mattr=+v6 | grep r9
44
; RUN: llc < %s -mtriple=arm-apple-darwin -relocation-model=pic \
5-
; RUN: -mattr=+v6 -arm-reserve-r9 -ifcvt-limit=0 -stats 2>&1 | grep asm-printer
5+
; RUN: -mattr=+v6,+reserve-r9 -ifcvt-limit=0 -stats 2>&1 | grep asm-printer
66
; | grep 35
77

88
define void @test(i32 %tmp56222, i32 %tmp36224, i32 %tmp46223, i32 %i.0196.0.ph, i32 %tmp8, i32* %tmp1011, i32** %tmp1, i32* %d2.1.out, i32* %d3.1.out, i32* %d0.1.out, i32* %d1.1.out) {

‎llvm/test/CodeGen/ARM/build-attributes.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
; RUN: llc < %s -mtriple=arm-none-linux-gnueabi -relocation-model=dynamic-no-pic | FileCheck %s --check-prefix=RELOC-OTHER
123123
; RUN: llc < %s -mtriple=arm-none-linux-gnueabi | FileCheck %s --check-prefix=RELOC-OTHER
124124
; RUN: llc < %s -mtriple=arm-none-linux-gnueabi | FileCheck %s --check-prefix=PCS-R9-USE
125-
; RUN: llc < %s -mtriple=arm-none-linux-gnueabi -arm-reserve-r9 | FileCheck %s --check-prefix=PCS-R9-RESERVE
125+
; RUN: llc < %s -mtriple=arm-none-linux-gnueabi -mattr=+reserve-r9 | FileCheck %s --check-prefix=PCS-R9-RESERVE
126126

127127
; ARMv8.1a (AArch32)
128128
; RUN: llc < %s -mtriple=armv8.1a-none-linux-gnueabi -arm-no-strict-align | FileCheck %s --check-prefix=NO-STRICT-ALIGN

0 commit comments

Comments
 (0)
Please sign in to comment.