Skip to content
24 changes: 14 additions & 10 deletions llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,27 +62,30 @@ ARMBaseRegisterInfo::ARMBaseRegisterInfo()
const MCPhysReg*
ARMBaseRegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const {
const ARMSubtarget &STI = MF->getSubtarget<ARMSubtarget>();
bool UseSplitPush = STI.splitFramePushPop(*MF);
ARMSubtarget::PushPopSplitVariation PushPopSplit =
STI.getPushPopSplitVariation(*MF);
const Function &F = MF->getFunction();

if (F.getCallingConv() == CallingConv::GHC) {
// GHC set of callee saved regs is empty as all those regs are
// used for passing STG regs around
return CSR_NoRegs_SaveList;
} else if (STI.splitFramePointerPush(*MF)) {
} else if (PushPopSplit == ARMSubtarget::SplitR11WindowsSEH) {
return CSR_Win_SplitFP_SaveList;
} else if (F.getCallingConv() == CallingConv::CFGuard_Check) {
return CSR_Win_AAPCS_CFGuard_Check_SaveList;
} else if (F.getCallingConv() == CallingConv::SwiftTail) {
return STI.isTargetDarwin()
? CSR_iOS_SwiftTail_SaveList
: (UseSplitPush ? CSR_ATPCS_SplitPush_SwiftTail_SaveList
: CSR_AAPCS_SwiftTail_SaveList);
return STI.isTargetDarwin() ? CSR_iOS_SwiftTail_SaveList
: (PushPopSplit == ARMSubtarget::SplitR7
? CSR_ATPCS_SplitPush_SwiftTail_SaveList
: CSR_AAPCS_SwiftTail_SaveList);
} else if (F.hasFnAttribute("interrupt")) {
if (STI.isMClass()) {
// M-class CPUs have hardware which saves the registers needed to allow a
// function conforming to the AAPCS to function as a handler.
return UseSplitPush ? CSR_ATPCS_SplitPush_SaveList : CSR_AAPCS_SaveList;
return PushPopSplit == ARMSubtarget::SplitR7
? CSR_ATPCS_SplitPush_SaveList
: CSR_AAPCS_SaveList;
} else if (F.getFnAttribute("interrupt").getValueAsString() == "FIQ") {
// Fast interrupt mode gives the handler a private copy of R8-R14, so less
// need to be saved to restore user-mode state.
Expand All @@ -99,8 +102,9 @@ ARMBaseRegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const {
if (STI.isTargetDarwin())
return CSR_iOS_SwiftError_SaveList;

return UseSplitPush ? CSR_ATPCS_SplitPush_SwiftError_SaveList :
CSR_AAPCS_SwiftError_SaveList;
return PushPopSplit == ARMSubtarget::SplitR7
? CSR_ATPCS_SplitPush_SwiftError_SaveList
: CSR_AAPCS_SwiftError_SaveList;
}

if (STI.isTargetDarwin() && F.getCallingConv() == CallingConv::CXX_FAST_TLS)
Expand All @@ -111,7 +115,7 @@ ARMBaseRegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const {
if (STI.isTargetDarwin())
return CSR_iOS_SaveList;

if (UseSplitPush)
if (PushPopSplit == ARMSubtarget::SplitR7)
return STI.createAAPCSFrameChain() ? CSR_AAPCS_SplitPush_SaveList
: CSR_ATPCS_SplitPush_SaveList;

Expand Down
75 changes: 0 additions & 75 deletions llvm/lib/Target/ARM/ARMBaseRegisterInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,81 +41,6 @@ namespace ARMRI {

} // end namespace ARMRI

/// isARMArea1Register - Returns true if the register is a low register (r0-r7)
/// or a stack/pc register that we should push/pop.
static inline bool isARMArea1Register(unsigned Reg, bool SplitFramePushPop) {
using namespace ARM;

switch (Reg) {
case R0: case R1: case R2: case R3:
case R4: case R5: case R6: case R7:
case LR: case SP: case PC:
return true;
case R8: case R9: case R10: case R11: case R12:
// For iOS we want r7 and lr to be next to each other.
return !SplitFramePushPop;
default:
return false;
}
}

static inline bool isARMArea2Register(unsigned Reg, bool SplitFramePushPop) {
using namespace ARM;

switch (Reg) {
case R8: case R9: case R10: case R11: case R12:
// iOS has this second area.
return SplitFramePushPop;
default:
return false;
}
}

static inline bool isSplitFPArea1Register(unsigned Reg,
bool SplitFramePushPop) {
using namespace ARM;

switch (Reg) {
case R0: case R1: case R2: case R3:
case R4: case R5: case R6: case R7:
case R8: case R9: case R10: case R12:
case SP: case PC:
return true;
default:
return false;
}
}

static inline bool isSplitFPArea2Register(unsigned Reg,
bool SplitFramePushPop) {
using namespace ARM;

switch (Reg) {
case R11: case LR:
return true;
default:
return false;
}
}

static inline bool isARMArea3Register(unsigned Reg, bool SplitFramePushPop) {
using namespace ARM;

switch (Reg) {
case D15: case D14: case D13: case D12:
case D11: case D10: case D9: case D8:
case D7: case D6: case D5: case D4:
case D3: case D2: case D1: case D0:
case D31: case D30: case D29: case D28:
case D27: case D26: case D25: case D24:
case D23: case D22: case D21: case D20:
case D19: case D18: case D17: case D16:
return true;
default:
return false;
}
}

static inline bool isCalleeSavedRegister(unsigned Reg,
const MCPhysReg *CSRegs) {
for (unsigned i = 0; CSRegs[i]; ++i)
Expand Down
Loading