llvm.org GIT mirror llvm / 3c3b55e
Merging r226664: ------------------------------------------------------------------------ r226664 | tnorthover | 2015-01-21 07:43:31 -0800 (Wed, 21 Jan 2015) | 7 lines AArch64: add backend option to reserve x18 (platform register) AAPCS64 says that it's up to the platform to specify whether x18 is reserved, and a first step on that way is to add a flag controlling it. From: Andrew Turner <andrew@fubar.geek.nz> ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_36@227150 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 5 years ago
2 changed file(s) with 15 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
3232 #define GET_REGINFO_TARGET_DESC
3333 #include "AArch64GenRegisterInfo.inc"
3434
35 static cl::opt
36 ReserveX18("aarch64-reserve-x18", cl::Hidden,
37 cl::desc("Reserve X18, making it unavailable as GPR"));
38
3539 AArch64RegisterInfo::AArch64RegisterInfo(const AArch64InstrInfo *tii,
3640 const AArch64Subtarget *sti)
3741 : AArch64GenRegisterInfo(AArch64::LR), TII(tii), STI(sti) {}
97101 Reserved.set(AArch64::W29);
98102 }
99103
100 if (STI->isTargetDarwin()) {
104 if (STI->isTargetDarwin() || ReserveX18) {
101105 Reserved.set(AArch64::X18); // Platform register
102106 Reserved.set(AArch64::W18);
103107 }
124128 return true;
125129 case AArch64::X18:
126130 case AArch64::W18:
127 return STI->isTargetDarwin();
131 return STI->isTargetDarwin() || ReserveX18;
128132 case AArch64::FP:
129133 case AArch64::W29:
130134 return TFI->hasFP(MF) || STI->isTargetDarwin();
386390 case AArch64::GPR64commonRegClassID:
387391 return 32 - 1 // XZR/SP
388392 - (TFI->hasFP(MF) || STI->isTargetDarwin()) // FP
389 - STI->isTargetDarwin() // X18 reserved as platform register
393 - (STI->isTargetDarwin() || ReserveX18) // X18 reserved as platform register
390394 - hasBasePointer(MF); // X19
391395 case AArch64::FPR8RegClassID:
392396 case AArch64::FPR16RegClassID:
None ; RUN: llc -mtriple=arm64-apple-ios -o - %s | FileCheck %s --check-prefix=CHECK-DARWIN
0 ; RUN: llc -mtriple=arm64-apple-ios -o - %s | FileCheck %s --check-prefix=CHECK-RESERVE-X18
1 ; RUN: llc -mtriple=arm64-freebsd-gnu -aarch64-reserve-x18 -o - %s | FileCheck %s --check-prefix=CHECK-RESERVE-X18
12 ; RUN: llc -mtriple=arm64-linux-gnu -o - %s | FileCheck %s
23
34 ; x18 is reserved as a platform register on Darwin but not on other
1516 ; CHECK: ldr x18
1617 ; CHECK: str x18
1718
18 ; CHECK-DARWIN-NOT: ldr fp
19 ; CHECK-DARWIN-NOT: ldr x18
20 ; CHECK-DARWIN: Spill
21 ; CHECK-DARWIN-NOT: ldr fp
22 ; CHECK-DARWIN-NOT: ldr x18
23 ; CHECK-DARWIN: ret
19 ; CHECK-RESERVE-X18-NOT: ldr fp
20 ; CHECK-RESERVE-X18-NOT: ldr x18
21 ; CHECK-RESERVE-X18: Spill
22 ; CHECK-RESERVE-X18-NOT: ldr fp
23 ; CHECK-RESERVE-X18-NOT: ldr x18
24 ; CHECK-RESERVE-X18: ret
2425 ret void
2526 }