aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/SystemZ/SystemZRegisterInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Target/SystemZ/SystemZRegisterInfo.cpp')
-rw-r--r--llvm/lib/Target/SystemZ/SystemZRegisterInfo.cpp89
1 files changed, 65 insertions, 24 deletions
diff --git a/llvm/lib/Target/SystemZ/SystemZRegisterInfo.cpp b/llvm/lib/Target/SystemZ/SystemZRegisterInfo.cpp
index 5139cc39d2af..0062e39602f5 100644
--- a/llvm/lib/Target/SystemZ/SystemZRegisterInfo.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZRegisterInfo.cpp
@@ -9,21 +9,19 @@
#include "SystemZRegisterInfo.h"
#include "SystemZInstrInfo.h"
#include "SystemZSubtarget.h"
-#include "llvm/CodeGen/LiveIntervals.h"
#include "llvm/ADT/SmallSet.h"
+#include "llvm/CodeGen/LiveIntervals.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/TargetFrameLowering.h"
#include "llvm/CodeGen/VirtRegMap.h"
+#include "llvm/IR/DebugInfoMetadata.h"
using namespace llvm;
#define GET_REGINFO_TARGET_DESC
#include "SystemZGenRegisterInfo.inc"
-SystemZRegisterInfo::SystemZRegisterInfo()
- : SystemZGenRegisterInfo(SystemZ::R14D) {}
-
// Given that MO is a GRX32 operand, return either GR32 or GRH32 if MO
// somehow belongs in it. Otherwise, return GRX32.
static const TargetRegisterClass *getRC32(MachineOperand &MO,
@@ -191,7 +189,12 @@ bool SystemZRegisterInfo::getRegAllocationHints(
}
const MCPhysReg *
-SystemZRegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const {
+SystemZXPLINK64Registers::getCalleeSavedRegs(const MachineFunction *MF) const {
+ return CSR_SystemZ_XPLINK64_SaveList;
+}
+
+const MCPhysReg *
+SystemZELFRegisters::getCalleeSavedRegs(const MachineFunction *MF) const {
const SystemZSubtarget &Subtarget = MF->getSubtarget<SystemZSubtarget>();
if (MF->getFunction().getCallingConv() == CallingConv::GHC)
return CSR_SystemZ_NoRegs_SaveList;
@@ -202,11 +205,17 @@ SystemZRegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const {
MF->getFunction().getAttributes().hasAttrSomewhere(
Attribute::SwiftError))
return CSR_SystemZ_SwiftError_SaveList;
- return CSR_SystemZ_SaveList;
+ return CSR_SystemZ_ELF_SaveList;
}
const uint32_t *
-SystemZRegisterInfo::getCallPreservedMask(const MachineFunction &MF,
+SystemZXPLINK64Registers::getCallPreservedMask(const MachineFunction &MF,
+ CallingConv::ID CC) const {
+ return CSR_SystemZ_XPLINK64_RegMask;
+}
+
+const uint32_t *
+SystemZELFRegisters::getCallPreservedMask(const MachineFunction &MF,
CallingConv::ID CC) const {
const SystemZSubtarget &Subtarget = MF.getSubtarget<SystemZSubtarget>();
if (CC == CallingConv::GHC)
@@ -218,27 +227,46 @@ SystemZRegisterInfo::getCallPreservedMask(const MachineFunction &MF,
MF.getFunction().getAttributes().hasAttrSomewhere(
Attribute::SwiftError))
return CSR_SystemZ_SwiftError_RegMask;
- return CSR_SystemZ_RegMask;
+ return CSR_SystemZ_ELF_RegMask;
+}
+
+SystemZRegisterInfo::SystemZRegisterInfo(unsigned int RA)
+ : SystemZGenRegisterInfo(RA) {}
+
+const MCPhysReg *
+SystemZRegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const {
+
+ const SystemZSubtarget *Subtarget = &MF->getSubtarget<SystemZSubtarget>();
+ SystemZCallingConventionRegisters *Regs = Subtarget->getSpecialRegisters();
+
+ return Regs->getCalleeSavedRegs(MF);
+}
+
+const uint32_t *
+SystemZRegisterInfo::getCallPreservedMask(const MachineFunction &MF,
+ CallingConv::ID CC) const {
+
+ const SystemZSubtarget *Subtarget = &MF.getSubtarget<SystemZSubtarget>();
+ SystemZCallingConventionRegisters *Regs = Subtarget->getSpecialRegisters();
+ return Regs->getCallPreservedMask(MF, CC);
}
BitVector
SystemZRegisterInfo::getReservedRegs(const MachineFunction &MF) const {
BitVector Reserved(getNumRegs());
const SystemZFrameLowering *TFI = getFrameLowering(MF);
-
- if (TFI->hasFP(MF)) {
- // R11D is the frame pointer. Reserve all aliases.
- Reserved.set(SystemZ::R11D);
- Reserved.set(SystemZ::R11L);
- Reserved.set(SystemZ::R11H);
- Reserved.set(SystemZ::R10Q);
- }
-
- // R15D is the stack pointer. Reserve all aliases.
- Reserved.set(SystemZ::R15D);
- Reserved.set(SystemZ::R15L);
- Reserved.set(SystemZ::R15H);
- Reserved.set(SystemZ::R14Q);
+ const SystemZSubtarget *Subtarget = &MF.getSubtarget<SystemZSubtarget>();
+ SystemZCallingConventionRegisters *Regs = Subtarget->getSpecialRegisters();
+ if (TFI->hasFP(MF))
+ // The frame pointer. Reserve all aliases.
+ for (MCRegAliasIterator AI(Regs->getFramePointerRegister(), this, true);
+ AI.isValid(); ++AI)
+ Reserved.set(*AI);
+
+ // Reserve all aliases for the stack pointer.
+ for (MCRegAliasIterator AI(Regs->getStackPointerRegister(), this, true);
+ AI.isValid(); ++AI)
+ Reserved.set(*AI);
// A0 and A1 hold the thread pointer.
Reserved.set(SystemZ::A0);
@@ -273,7 +301,16 @@ SystemZRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator MI,
// Special handling of dbg_value instructions.
if (MI->isDebugValue()) {
MI->getOperand(FIOperandNum).ChangeToRegister(BasePtr, /*isDef*/ false);
- MI->getDebugOffset().ChangeToImmediate(Offset);
+ if (MI->isNonListDebugValue()) {
+ MI->getDebugOffset().ChangeToImmediate(Offset);
+ } else {
+ unsigned OpIdx = MI->getDebugOperandIndex(&MI->getOperand(FIOperandNum));
+ SmallVector<uint64_t, 3> Ops;
+ DIExpression::appendOffset(
+ Ops, TFI->getFrameIndexReference(MF, FrameIndex, BasePtr).getFixed());
+ MI->getDebugExpressionOp().setMetadata(
+ DIExpression::appendOpsToArg(MI->getDebugExpression(), Ops, OpIdx));
+ }
return;
}
@@ -410,7 +447,11 @@ bool SystemZRegisterInfo::shouldCoalesce(MachineInstr *MI,
Register
SystemZRegisterInfo::getFrameRegister(const MachineFunction &MF) const {
const SystemZFrameLowering *TFI = getFrameLowering(MF);
- return TFI->hasFP(MF) ? SystemZ::R11D : SystemZ::R15D;
+ const SystemZSubtarget *Subtarget = &MF.getSubtarget<SystemZSubtarget>();
+ SystemZCallingConventionRegisters *Regs = Subtarget->getSpecialRegisters();
+
+ return TFI->hasFP(MF) ? Regs->getFramePointerRegister()
+ : Regs->getStackPointerRegister();
}
const TargetRegisterClass *