Skip to content

Commit 2d739f9

Browse files
author
Anna Welker
committed
[ARM] Allocatable Global Register Variables for ARM
Provides support for using r6-r11 as globally scoped register variables. This requires a -ffixed-rN flag in order to reserve rN against general allocation. If for a given GRV declaration the corresponding flag is not found, or the the register in question is the target's FP, we fail with a diagnostic. Differential Revision: https://reviews.llvm.org/D68862
1 parent c0f6ad7 commit 2d739f9

26 files changed

+498
-29
lines changed

clang/docs/ClangCommandLineReference.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2430,10 +2430,31 @@ Enable XNACK (AMDGPU only)
24302430

24312431
ARM
24322432
---
2433+
2434+
.. option:: -ffixed-r6
2435+
2436+
Reserve the r6 register (ARM only)
2437+
2438+
.. option:: -ffixed-r7
2439+
2440+
Reserve the r7 register (ARM only)
2441+
2442+
.. option:: -ffixed-r8
2443+
2444+
Reserve the r8 register (ARM only)
2445+
24332446
.. option:: -ffixed-r9
24342447

24352448
Reserve the r9 register (ARM only)
24362449

2450+
.. option:: -ffixed-r10
2451+
2452+
Reserve the r10 register (ARM only)
2453+
2454+
.. option:: -ffixed-r11
2455+
2456+
Reserve the r11 register (ARM only)
2457+
24372458
.. option:: -mexecute-only, -mno-execute-only, -mpure-code
24382459

24392460
Disallow generation of data access to code sections (ARM only)

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,10 @@ def warn_drv_msp430_hwmult_no_device : Warning<"no MCU device specified, but "
464464
"specify a MSP430 device, or -mhwmult to set hardware multiply type "
465465
"explicitly.">, InGroup<InvalidCommandLineArgument>;
466466

467+
// Frame pointer reservation.
468+
def err_reserved_frame_pointer : Error<
469+
"'%0' has been specified but '%1' is used as the frame pointer for this target">;
470+
467471
def warn_drv_libstdcxx_not_found : Warning<
468472
"include path for libstdc++ headers not found; pass '-stdlib=libc++' on the "
469473
"command line to use the libc++ standard library instead">,

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,3 +1115,6 @@ def CrossTU : DiagGroup<"ctu">;
11151115
def CTADMaybeUnsupported : DiagGroup<"ctad-maybe-unsupported">;
11161116

11171117
def FortifySource : DiagGroup<"fortify-source">;
1118+
1119+
// Register reservation.
1120+
def FixedRegs : DiagGroup<"fixed-registers">;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7716,6 +7716,8 @@ let CategoryName = "Inline Assembly Issue" in {
77167716
def err_asm_unknown_register_name : Error<"unknown register name '%0' in asm">;
77177717
def err_asm_invalid_global_var_reg : Error<"register '%0' unsuitable for "
77187718
"global register variables on this target">;
7719+
def err_asm_missing_fixed_reg_opt : Error<"-ffixed-%0 is required for "
7720+
"global named register variable declaration">;
77197721
def err_asm_register_size_mismatch : Error<"size of register '%0' does not "
77207722
"match variable size">;
77217723
def err_asm_bad_register_type : Error<"bad type for named register variable">;

clang/include/clang/Basic/TargetInfo.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,12 @@ class TargetInfo : public virtual TransferrableTargetInfo,
938938
return true;
939939
}
940940

941+
/// Check if the register is reserved globally
942+
///
943+
/// This function returns true if the register passed in RegName is reserved
944+
/// using the corresponding -ffixed-RegName option.
945+
virtual bool isRegisterReservedGlobally(StringRef) const { return true; }
946+
941947
// validateOutputConstraint, validateInputConstraint - Checks that
942948
// a constraint is valid and provides information about it.
943949
// FIXME: These should return a real error instead of just true/false.

clang/include/clang/Driver/Options.td

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2266,8 +2266,9 @@ def mrestrict_it: Flag<["-"], "mrestrict-it">, Group<m_arm_Features_Group>,
22662266
def mno_restrict_it: Flag<["-"], "mno-restrict-it">, Group<m_arm_Features_Group>,
22672267
HelpText<"Allow generation of deprecated IT blocks for ARMv8. It is off by default for ARMv8 Thumb mode">;
22682268
def marm : Flag<["-"], "marm">, Alias<mno_thumb>;
2269-
def ffixed_r9 : Flag<["-"], "ffixed-r9">, Group<m_arm_Features_Group>,
2270-
HelpText<"Reserve the r9 register (ARM only)">;
2269+
foreach i = {6-11} in
2270+
def ffixed_r#i : Flag<["-"], "ffixed-r"#i>, Group<m_arm_Features_Group>,
2271+
HelpText<"Reserve the r"#i#" register (ARM only)">;
22712272
def mno_movt : Flag<["-"], "mno-movt">, Group<m_arm_Features_Group>,
22722273
HelpText<"Disallow use of movt/movw pairs (ARM only)">;
22732274
def mcrc : Flag<["-"], "mcrc">, Group<m_Group>,

clang/lib/Basic/Targets/ARM.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,38 @@ ArrayRef<TargetInfo::GCCRegAlias> ARMTargetInfo::getGCCRegAliases() const {
879879
return llvm::makeArrayRef(GCCRegAliases);
880880
}
881881

882+
bool ARMTargetInfo::validateGlobalRegisterVariable(
883+
StringRef RegName, unsigned RegSize, bool &HasSizeMismatch) const {
884+
bool isValid = llvm::StringSwitch<bool>(RegName)
885+
.Case("r6", true)
886+
.Case("r7", true)
887+
.Case("r8", true)
888+
.Case("r9", true)
889+
.Case("r10", true)
890+
.Case("r11", true)
891+
.Case("sp", true)
892+
.Default(false);
893+
HasSizeMismatch = false;
894+
return isValid;
895+
}
896+
897+
bool ARMTargetInfo::isRegisterReservedGlobally(StringRef RegName) const {
898+
// The "sp" register does not have a -ffixed-sp option,
899+
// so reserve it unconditionally.
900+
if (RegName.equals("sp"))
901+
return true;
902+
903+
// reserve rN (N:6-11) registers only if the corresponding
904+
// +reserve-rN feature is found
905+
const std::vector<std::string> &Features = getTargetOpts().Features;
906+
const std::string SearchFeature = "+reserve-" + RegName.str();
907+
for (const std::string &Feature : Features) {
908+
if (Feature.compare(SearchFeature) == 0)
909+
return true;
910+
}
911+
return false;
912+
}
913+
882914
bool ARMTargetInfo::validateAsmConstraint(
883915
const char *&Name, TargetInfo::ConstraintInfo &Info) const {
884916
switch (*Name) {

clang/lib/Basic/Targets/ARM.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ class LLVM_LIBRARY_VISIBILITY ARMTargetInfo : public TargetInfo {
161161

162162
ArrayRef<const char *> getGCCRegNames() const override;
163163
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
164+
bool validateGlobalRegisterVariable(StringRef RegName, unsigned RegSize,
165+
bool &HasSizeMismatch) const override;
166+
bool isRegisterReservedGlobally(StringRef RegName) const override;
164167
bool validateAsmConstraint(const char *&Name,
165168
TargetInfo::ConstraintInfo &Info) const override;
166169
std::string convertConstraint(const char *&Constraint) const override;

clang/lib/Driver/ToolChains/Arch/ARM.cpp

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -592,11 +592,39 @@ void arm::getARMTargetFeatures(const ToolChain &TC,
592592
Features.push_back("+strict-align");
593593
}
594594

595-
// llvm does not support reserving registers in general. There is support
596-
// for reserving r9 on ARM though (defined as a platform-specific register
597-
// in ARM EABI).
598-
if (Args.hasArg(options::OPT_ffixed_r9))
599-
Features.push_back("+reserve-r9");
595+
// Do not allow r9 reservation with -frwpi.
596+
if (Args.hasArg(options::OPT_ffixed_r9) && Args.hasArg(options::OPT_frwpi)) {
597+
Arg *A = Args.getLastArg(options::OPT_ffixed_r9);
598+
Arg *B = Args.getLastArg(options::OPT_frwpi);
599+
D.Diag(diag::err_opt_not_valid_with_opt)
600+
<< A->getAsString(Args) << B->getAsString(Args);
601+
}
602+
603+
// The compiler can still use a FP in certain circumstances,
604+
// even when frame pointer elimination is enabled. Thus we should
605+
// not allow to reserve a target's FP register.
606+
const llvm::opt::OptSpecifier RestrictFPOpt =
607+
(Triple.isOSDarwin() || (!Triple.isOSWindows() && Triple.isThumb()))
608+
? options::OPT_ffixed_r7
609+
: options::OPT_ffixed_r11;
610+
if (Args.hasArg(RestrictFPOpt)) {
611+
const std::string OptStr =
612+
Args.getLastArg(RestrictFPOpt)->getAsString(Args);
613+
const unsigned int SubStrIndex = strlen("ffixed-r");
614+
D.Diag(diag::err_reserved_frame_pointer)
615+
<< OptStr << OptStr.substr(SubStrIndex);
616+
}
617+
618+
// Reservation of general purpose registers.
619+
#define HANDLE_FFIXED_R(n) \
620+
if (Args.hasArg(options::OPT_ffixed_r##n)) \
621+
Features.push_back("+reserve-r" #n)
622+
HANDLE_FFIXED_R(6);
623+
HANDLE_FFIXED_R(7);
624+
HANDLE_FFIXED_R(8);
625+
HANDLE_FFIXED_R(9);
626+
HANDLE_FFIXED_R(10);
627+
HANDLE_FFIXED_R(11);
600628

601629
// The kext linker doesn't know how to deal with movw/movt.
602630
if (KernelOrKext || Args.hasArg(options::OPT_mno_movt))

clang/lib/Sema/SemaDecl.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7009,6 +7009,8 @@ NamedDecl *Sema::ActOnVariableDeclarator(
70097009
Diag(E->getExprLoc(), diag::err_asm_invalid_global_var_reg) << Label;
70107010
else if (HasSizeMismatch)
70117011
Diag(E->getExprLoc(), diag::err_asm_register_size_mismatch) << Label;
7012+
else if (!TI.isRegisterReservedGlobally(Label))
7013+
Diag(E->getExprLoc(), diag::err_asm_missing_fixed_reg_opt) << Label;
70127014
}
70137015

70147016
if (!R->isIntegralType(Context) && !R->isPointerType()) {
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// ## FP ARM + Thumb
2+
// RUN: %clang -target arm-arm-none-eabi -### -ffixed-r11 -c %s 2>&1 | FileCheck -check-prefix=CHECK-ERROR-R11 %s
3+
// RUN: %clang -target arm-arm-none-eabi -### -ffixed-r7 -c %s 2>&1 | FileCheck -check-prefix=CHECK-NO-ERROR %s
4+
5+
// RUN: %clang -target arm-arm-none-eabi -### -ffixed-r7 -mthumb -c %s 2>&1 | FileCheck -check-prefix=CHECK-ERROR-R7 %s
6+
// RUN: %clang -target arm-arm-none-eabi -### -ffixed-r11 -mthumb -c %s 2>&1 | FileCheck -check-prefix=CHECK-NO-ERROR %s
7+
8+
// RUN: %clang -target thumbv6m-none-eabi -### -ffixed-r7 -c %s 2>&1 | FileCheck -check-prefix=CHECK-ERROR-R7 %s
9+
// RUN: %clang -target thumbv6m-none-eabi -### -ffixed-r11 -c %s 2>&1 | FileCheck -check-prefix=CHECK-NO-ERROR %s
10+
11+
// ## FP Darwin (R7)
12+
// RUN: %clang -target armv6-apple-darwin9 -### -ffixed-r7 -c %s 2>&1 | FileCheck -check-prefix=CHECK-ERROR-R7 %s
13+
// RUN: %clang -target armv6-apple-darwin9 -### -ffixed-r11 -c %s 2>&1 | FileCheck -check-prefix=CHECK-NO-ERROR %s
14+
15+
// RUN: %clang -target armv6-apple-ios3 -### -ffixed-r7 -c %s 2>&1 | FileCheck -check-prefix=CHECK-ERROR-R7 %s
16+
// RUN: %clang -target armv6-apple-ios3 -### -ffixed-r11 -c %s 2>&1 | FileCheck -check-prefix=CHECK-NO-ERROR %s
17+
18+
// RUN: %clang -target armv7s-apple-darwin10 -### -ffixed-r7 -c %s 2>&1 | FileCheck -check-prefix=CHECK-ERROR-R7 %s
19+
// RUN: %clang -target armv7s-apple-darwin10 -### -ffixed-r11 -c %s 2>&1 | FileCheck -check-prefix=CHECK-NO-ERROR %s
20+
21+
// ## FP Windows (R11)
22+
// RUN: %clang -target armv7-windows -### -ffixed-r11 -c %s 2>&1 | FileCheck -check-prefix=CHECK-ERROR-R11 %s
23+
// RUN: %clang -target armv7-windows -### -ffixed-r7 -c %s 2>&1 | FileCheck -check-prefix=CHECK-NO-ERROR %s
24+
25+
// ## FRWPI (R9)
26+
// RUN: %clang -target arm-arm-none-eabi -### -frwpi -ffixed-r9 -c %s 2>&1 | FileCheck -check-prefix=CHECK-RESERVED-FRWPI-CONFLICT %s
27+
// RUN: %clang -target arm-arm-none-eabi -### -ffixed-r9 -c %s 2>&1 | FileCheck -check-prefix=CHECK-RESERVED-FRWPI-VALID %s
28+
// RUN: %clang -target arm-arm-none-eabi -### -frwpi -c %s 2>&1 | FileCheck -check-prefix=CHECK-RESERVED-FRWPI-VALID %s
29+
30+
// CHECK-ERROR-R11: error: '-ffixed-r11' has been specified but 'r11' is used as the frame pointer for this target
31+
// CHECK-ERROR-R7: error: '-ffixed-r7' has been specified but 'r7' is used as the frame pointer for this target
32+
// CHECK-NO-ERROR-NOT: may still be used as a frame pointer
33+
34+
// CHECK-RESERVED-FRWPI-CONFLICT: option '-ffixed-r9' cannot be specified with '-frwpi'
35+
// CHECK-RESERVED-FRWPI-VALID-NOT: option '-ffixed-r9' cannot be specified with '-frwpi'

clang/test/Sema/arm-global-regs.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %clang_cc1 -ffreestanding -fsyntax-only -target-feature +reserve-r9 -verify -triple arm-arm-none-eabi %s
2+
3+
// Check a small subset of valid and invalid global register variable declarations.
4+
// Also check that for global register variables without -ffixed-reg options it throws an error.
5+
6+
register unsigned arm_r3 __asm("r3"); //expected-error {{register 'r3' unsuitable for global register variables on this target}}
7+
8+
register unsigned arm_r12 __asm("r12"); //expected-error {{register 'r12' unsuitable for global register variables on this target}}
9+
10+
register unsigned arm_r5 __asm("r5"); //expected-error {{register 'r5' unsuitable for global register variables on this target}}
11+
12+
register unsigned arm_r9 __asm("r9");
13+
14+
register unsigned arm_r6 __asm("r6"); //expected-error {{-ffixed-r6 is required for global named register variable declaration}}
15+
16+
register unsigned arm_r7 __asm("r7"); //expected-error {{-ffixed-r7 is required for global named register variable declaration}}
17+
18+
register unsigned *parm_r7 __asm("r7"); //expected-error {{-ffixed-r7 is required for global named register variable declaration}}
19+
20+
register unsigned arm_sp __asm("sp");

llvm/lib/Target/ARM/ARM.td

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,11 @@ def FeatureExecuteOnly : SubtargetFeature<"execute-only",
391391
"Enable the generation of "
392392
"execute only code.">;
393393

394-
def FeatureReserveR9 : SubtargetFeature<"reserve-r9", "ReserveR9", "true",
395-
"Reserve R9, making it unavailable"
396-
" as GPR">;
394+
foreach i = {6-11} in
395+
def FeatureReserveR#i : SubtargetFeature<"reserve-r"#i,
396+
"ReservedGPRegisters["#i#"]", "true",
397+
"Reserve R"#i#", making it "
398+
"unavailable as a GPR">;
397399

398400
def FeatureNoMovt : SubtargetFeature<"no-movt", "NoMovt", "true",
399401
"Don't use movt/movw pairs for "

llvm/lib/Target/ARM/ARMAsmPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ void ARMAsmPrinter::emitAttributes() {
752752
if (STI.isRWPI())
753753
ATS.emitAttribute(ARMBuildAttrs::ABI_PCS_R9_use,
754754
ARMBuildAttrs::R9IsSB);
755-
else if (STI.isR9Reserved())
755+
else if (STI.isGPRegisterReserved(9))
756756
ATS.emitAttribute(ARMBuildAttrs::ABI_PCS_R9_use,
757757
ARMBuildAttrs::R9Reserved);
758758
else

llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,11 @@ getReservedRegs(const MachineFunction &MF) const {
198198
markSuperRegs(Reserved, getFramePointerReg(STI));
199199
if (hasBasePointer(MF))
200200
markSuperRegs(Reserved, BasePtr);
201-
// Some targets reserve R9.
202-
if (STI.isR9Reserved())
203-
markSuperRegs(Reserved, ARM::R9);
201+
for (size_t R = 0; R < ARM::GPRRegClass.getNumRegs(); ++R) {
202+
if (STI.isGPRegisterReserved(R)) {
203+
markSuperRegs(Reserved, ARM::R0 + R);
204+
}
205+
}
204206
// Reserve D16-D31 if the subtarget doesn't support them.
205207
if (!STI.hasD32()) {
206208
static_assert(ARM::D31 == ARM::D16 + 15, "Register list not consecutive!");
@@ -280,7 +282,7 @@ ARMBaseRegisterInfo::getRegPressureLimit(const TargetRegisterClass *RC,
280282
case ARM::GPRRegClassID: {
281283
bool HasFP = MF.getFrameInfo().isMaxCallFrameSizeComputed()
282284
? TFI->hasFP(MF) : true;
283-
return 10 - HasFP - (STI.isR9Reserved() ? 1 : 0);
285+
return 10 - HasFP - STI.getNumGPRegistersReserved();
284286
}
285287
case ARM::SPRRegClassID: // Currently not used as 'rep' register class.
286288
case ARM::DPRRegClassID:
@@ -380,6 +382,11 @@ bool ARMBaseRegisterInfo::hasBasePointer(const MachineFunction &MF) const {
380382
const MachineFrameInfo &MFI = MF.getFrameInfo();
381383
const ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
382384
const ARMFrameLowering *TFI = getFrameLowering(MF);
385+
const ARMSubtarget &STI = MF.getSubtarget<ARMSubtarget>();
386+
387+
// Disable base pointer R6 if -ffixed-r6 is used.
388+
if (STI.isGPRegisterReserved(BasePtr - ARM::R0))
389+
return false;
383390

384391
// If we have stack realignment and VLAs, we have no pointer to use to
385392
// access the stack. If we have stack realignment, and a large call frame,
@@ -416,6 +423,7 @@ bool ARMBaseRegisterInfo::hasBasePointer(const MachineFunction &MF) const {
416423
bool ARMBaseRegisterInfo::canRealignStack(const MachineFunction &MF) const {
417424
const MachineRegisterInfo *MRI = &MF.getRegInfo();
418425
const ARMFrameLowering *TFI = getFrameLowering(MF);
426+
const ARMSubtarget &STI = MF.getSubtarget<ARMSubtarget>();
419427
// We can't realign the stack if:
420428
// 1. Dynamic stack realignment is explicitly disabled,
421429
// 2. There are VLAs in the function and the base pointer is disabled.
@@ -425,6 +433,9 @@ bool ARMBaseRegisterInfo::canRealignStack(const MachineFunction &MF) const {
425433
// register allocation with frame pointer elimination, it is too late now.
426434
if (!MRI->canReserveReg(getFramePointerReg(MF.getSubtarget<ARMSubtarget>())))
427435
return false;
436+
// Disable base pointer R6 if -ffixed-r6 is used.
437+
if (STI.isGPRegisterReserved(BasePtr - ARM::R0))
438+
return false;
428439
// We may also need a base pointer if there are dynamic allocas or stack
429440
// pointer adjustments around calls.
430441
if (TFI->hasReservedCallFrame(MF))

llvm/lib/Target/ARM/ARMFrameLowering.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,6 +1704,19 @@ void ARMFrameLowering::determineCalleeSaves(MachineFunction &MF,
17041704
const MCPhysReg *CSRegs = RegInfo->getCalleeSavedRegs(&MF);
17051705
for (unsigned i = 0; CSRegs[i]; ++i) {
17061706
unsigned Reg = CSRegs[i];
1707+
if (STI.isRWPI() && Reg == ARM::R9) {
1708+
// Paranoid check for use of R9 with RWPI. Clobbering R9 with -frwpi will
1709+
// emit warnings about undefined behaviour but maybe theres's a valid use
1710+
// case so on that basis allow it to be pushed/popped in the
1711+
// prologue/epilogue.
1712+
} else if (Reg > ARM::R0 && ARM::GPRRegClass.contains(Reg) &&
1713+
STI.isGPRegisterReserved(Reg - ARM::R0)) {
1714+
LLVM_DEBUG(dbgs() << printReg(Reg, TRI) << " has been reserved and"
1715+
<< " should not be allocatable"
1716+
<< " or spillable.\n");
1717+
SavedRegs.reset(Reg);
1718+
continue;
1719+
}
17071720
bool Spilled = false;
17081721
if (SavedRegs.test(Reg)) {
17091722
Spilled = true;
@@ -1948,7 +1961,7 @@ void ARMFrameLowering::determineCalleeSaves(MachineFunction &MF,
19481961
LLVM_DEBUG(dbgs() << printReg(Reg, TRI)
19491962
<< " is saved low register, RegDeficit = "
19501963
<< RegDeficit << "\n");
1951-
} else {
1964+
} else if (!STI.isGPRegisterReserved(Reg - ARM::R0)) {
19521965
AvailableRegs.push_back(Reg);
19531966
LLVM_DEBUG(
19541967
dbgs()
@@ -1963,7 +1976,7 @@ void ARMFrameLowering::determineCalleeSaves(MachineFunction &MF,
19631976
--RegDeficit;
19641977
LLVM_DEBUG(dbgs() << "%r7 is saved low register, RegDeficit = "
19651978
<< RegDeficit << "\n");
1966-
} else {
1979+
} else if (!STI.isGPRegisterReserved(7)) {
19671980
AvailableRegs.push_back(ARM::R7);
19681981
LLVM_DEBUG(
19691982
dbgs()

llvm/lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5572,9 +5572,15 @@ SDValue ARMTargetLowering::LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const {
55725572
Register ARMTargetLowering::getRegisterByName(const char* RegName, EVT VT,
55735573
const MachineFunction &MF) const {
55745574
Register Reg = StringSwitch<unsigned>(RegName)
5575-
.Case("sp", ARM::SP)
5576-
.Default(0);
5577-
if (Reg)
5575+
.Case("r6", ARM::R6)
5576+
.Case("r7", ARM::R7)
5577+
.Case("r8", ARM::R8)
5578+
.Case("r9", ARM::R9)
5579+
.Case("r10", ARM::R10)
5580+
.Case("r11", ARM::R11)
5581+
.Case("sp", ARM::SP)
5582+
.Default(ARM::NoRegister);
5583+
if (Reg != ARM::NoRegister)
55785584
return Reg;
55795585
report_fatal_error(Twine("Invalid register name \""
55805586
+ StringRef(RegName) + "\"."));

0 commit comments

Comments
 (0)