218
218
#include " llvm/Analysis/ValueTracking.h"
219
219
#include " llvm/CodeGen/CFIInstBuilder.h"
220
220
#include " llvm/CodeGen/LivePhysRegs.h"
221
+ #include " llvm/CodeGen/LiveRegUnits.h"
221
222
#include " llvm/CodeGen/MachineBasicBlock.h"
222
223
#include " llvm/CodeGen/MachineFrameInfo.h"
223
224
#include " llvm/CodeGen/MachineFunction.h"
@@ -1002,7 +1003,7 @@ void AArch64FrameLowering::emitZeroCallUsedRegs(BitVector RegsToZero,
1002
1003
}
1003
1004
}
1004
1005
1005
- static void getLiveRegsForEntryMBB (LivePhysRegs &LiveRegs,
1006
+ static void getLiveRegsForEntryMBB (LiveRegUnits &LiveRegs,
1006
1007
const MachineBasicBlock &MBB) {
1007
1008
const MachineFunction *MF = MBB.getParent ();
1008
1009
LiveRegs.addLiveIns (MBB);
@@ -1035,16 +1036,18 @@ static Register findScratchNonCalleeSaveRegister(MachineBasicBlock *MBB) {
1035
1036
1036
1037
const AArch64Subtarget &Subtarget = MF->getSubtarget <AArch64Subtarget>();
1037
1038
const AArch64RegisterInfo &TRI = *Subtarget.getRegisterInfo ();
1038
- LivePhysRegs LiveRegs (TRI);
1039
+ LiveRegUnits LiveRegs (TRI);
1039
1040
getLiveRegsForEntryMBB (LiveRegs, *MBB);
1040
1041
1041
1042
// Prefer X9 since it was historically used for the prologue scratch reg.
1042
- const MachineRegisterInfo &MRI = MF->getRegInfo ();
1043
- if (LiveRegs.available (MRI, AArch64::X9))
1043
+ if (LiveRegs.available (AArch64::X9))
1044
1044
return AArch64::X9;
1045
1045
1046
- for (unsigned Reg : AArch64::GPR64RegClass) {
1047
- if (LiveRegs.available (MRI, Reg))
1046
+ BitVector Allocatable =
1047
+ TRI.getAllocatableSet (*MF, TRI.getRegClass (AArch64::GPR64RegClassID));
1048
+
1049
+ for (unsigned Reg : Allocatable.set_bits ()) {
1050
+ if (LiveRegs.available (Reg))
1048
1051
return Reg;
1049
1052
}
1050
1053
return AArch64::NoRegister;
@@ -1060,14 +1063,11 @@ bool AArch64FrameLowering::canUseAsPrologue(
1060
1063
const AArch64FunctionInfo *AFI = MF->getInfo <AArch64FunctionInfo>();
1061
1064
1062
1065
if (AFI->hasSwiftAsyncContext ()) {
1063
- const AArch64RegisterInfo &TRI = *Subtarget.getRegisterInfo ();
1064
- const MachineRegisterInfo &MRI = MF->getRegInfo ();
1065
- LivePhysRegs LiveRegs (TRI);
1066
+ LiveRegUnits LiveRegs (*RegInfo);
1066
1067
getLiveRegsForEntryMBB (LiveRegs, MBB);
1067
1068
// The StoreSwiftAsyncContext clobbers X16 and X17. Make sure they are
1068
1069
// available.
1069
- if (!LiveRegs.available (MRI, AArch64::X16) ||
1070
- !LiveRegs.available (MRI, AArch64::X17))
1070
+ if (!LiveRegs.available (AArch64::X16) || !LiveRegs.available (AArch64::X17))
1071
1071
return false ;
1072
1072
}
1073
1073
@@ -1668,8 +1668,8 @@ static void emitDefineCFAWithFP(MachineFunction &MF, MachineBasicBlock &MBB,
1668
1668
#ifndef NDEBUG
1669
1669
// / Collect live registers from the end of \p MI's parent up to (including) \p
1670
1670
// / MI in \p LiveRegs.
1671
- static void getLivePhysRegsUpTo (MachineInstr &MI, const TargetRegisterInfo &TRI,
1672
- LivePhysRegs &LiveRegs) {
1671
+ static void getLiveRegsUpTo (MachineInstr &MI, const TargetRegisterInfo &TRI,
1672
+ LiveRegUnits &LiveRegs) {
1673
1673
1674
1674
MachineBasicBlock &MBB = *MI.getParent ();
1675
1675
LiveRegs.addLiveOuts (MBB);
@@ -1706,9 +1706,9 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF,
1706
1706
NonFrameStart->getFlag (MachineInstr::FrameSetup))
1707
1707
++NonFrameStart;
1708
1708
1709
- LivePhysRegs LiveRegs (*TRI);
1709
+ LiveRegUnits LiveRegs (*TRI);
1710
1710
if (NonFrameStart != MBB.end ()) {
1711
- getLivePhysRegsUpTo (*NonFrameStart, *TRI, LiveRegs);
1711
+ getLiveRegsUpTo (*NonFrameStart, *TRI, LiveRegs);
1712
1712
// Ignore registers used for stack management for now.
1713
1713
LiveRegs.removeReg (AArch64::SP);
1714
1714
LiveRegs.removeReg (AArch64::X19);
@@ -1730,7 +1730,7 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF,
1730
1730
make_range (MBB.instr_begin (), NonFrameStart->getIterator ())) {
1731
1731
for (auto &Op : MI.operands ())
1732
1732
if (Op.isReg () && Op.isDef ())
1733
- assert (! LiveRegs.contains (Op.getReg ()) &&
1733
+ assert (LiveRegs.available (Op.getReg ()) &&
1734
1734
" live register clobbered by inserted prologue instructions" );
1735
1735
}
1736
1736
});
@@ -4840,7 +4840,7 @@ MachineBasicBlock::iterator tryMergeAdjacentSTG(MachineBasicBlock::iterator II,
4840
4840
// FIXME : This approach of bailing out from merge is conservative in
4841
4841
// some ways like even if stg loops are not present after merge the
4842
4842
// insert list, this liveness check is done (which is not needed).
4843
- LivePhysRegs LiveRegs (*(MBB->getParent ()->getSubtarget ().getRegisterInfo ()));
4843
+ LiveRegUnits LiveRegs (*(MBB->getParent ()->getSubtarget ().getRegisterInfo ()));
4844
4844
LiveRegs.addLiveOuts (*MBB);
4845
4845
for (auto I = MBB->rbegin ();; ++I) {
4846
4846
MachineInstr &MI = *I;
@@ -4849,7 +4849,7 @@ MachineBasicBlock::iterator tryMergeAdjacentSTG(MachineBasicBlock::iterator II,
4849
4849
LiveRegs.stepBackward (*I);
4850
4850
}
4851
4851
InsertI++;
4852
- if (LiveRegs.contains (AArch64::NZCV))
4852
+ if (! LiveRegs.available (AArch64::NZCV))
4853
4853
return InsertI;
4854
4854
4855
4855
llvm::stable_sort (Instrs,
0 commit comments