Skip to content

Commit 8ba4dfb

Browse files
committed
[AArch64][NFC] Switch to LiveRegUnits
1 parent 3c3e0e5 commit 8ba4dfb

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

llvm/lib/Target/AArch64/AArch64FrameLowering.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@
197197
#include "llvm/ADT/SmallVector.h"
198198
#include "llvm/ADT/Statistic.h"
199199
#include "llvm/CodeGen/LivePhysRegs.h"
200+
#include "llvm/CodeGen/LiveRegUnits.h"
200201
#include "llvm/CodeGen/MachineBasicBlock.h"
201202
#include "llvm/CodeGen/MachineFrameInfo.h"
202203
#include "llvm/CodeGen/MachineFunction.h"
@@ -988,7 +989,7 @@ void AArch64FrameLowering::emitZeroCallUsedRegs(BitVector RegsToZero,
988989
}
989990
}
990991

991-
static void getLiveRegsForEntryMBB(LivePhysRegs &LiveRegs,
992+
static void getLiveRegsForEntryMBB(LiveRegUnits &LiveRegs,
992993
const MachineBasicBlock &MBB) {
993994
const MachineFunction *MF = MBB.getParent();
994995
LiveRegs.addLiveIns(MBB);
@@ -1018,16 +1019,18 @@ static Register findScratchNonCalleeSaveRegister(MachineBasicBlock *MBB) {
10181019

10191020
const AArch64Subtarget &Subtarget = MF->getSubtarget<AArch64Subtarget>();
10201021
const AArch64RegisterInfo &TRI = *Subtarget.getRegisterInfo();
1021-
LivePhysRegs LiveRegs(TRI);
1022+
LiveRegUnits LiveRegs(TRI);
10221023
getLiveRegsForEntryMBB(LiveRegs, *MBB);
10231024

10241025
// Prefer X9 since it was historically used for the prologue scratch reg.
1025-
const MachineRegisterInfo &MRI = MF->getRegInfo();
1026-
if (LiveRegs.available(MRI, AArch64::X9))
1026+
if (LiveRegs.available(AArch64::X9))
10271027
return AArch64::X9;
10281028

1029-
for (unsigned Reg : AArch64::GPR64RegClass) {
1030-
if (LiveRegs.available(MRI, Reg))
1029+
BitVector Allocatable =
1030+
TRI.getAllocatableSet(*MF, TRI.getRegClass(AArch64::GPR64RegClassID));
1031+
1032+
for (unsigned Reg : Allocatable.set_bits()) {
1033+
if (LiveRegs.available(Reg))
10311034
return Reg;
10321035
}
10331036
return AArch64::NoRegister;
@@ -1043,14 +1046,11 @@ bool AArch64FrameLowering::canUseAsPrologue(
10431046
const AArch64FunctionInfo *AFI = MF->getInfo<AArch64FunctionInfo>();
10441047

10451048
if (AFI->hasSwiftAsyncContext()) {
1046-
const AArch64RegisterInfo &TRI = *Subtarget.getRegisterInfo();
1047-
const MachineRegisterInfo &MRI = MF->getRegInfo();
1048-
LivePhysRegs LiveRegs(TRI);
1049+
LiveRegUnits LiveRegs(*RegInfo);
10491050
getLiveRegsForEntryMBB(LiveRegs, MBB);
10501051
// The StoreSwiftAsyncContext clobbers X16 and X17. Make sure they are
10511052
// available.
1052-
if (!LiveRegs.available(MRI, AArch64::X16) ||
1053-
!LiveRegs.available(MRI, AArch64::X17))
1053+
if (!LiveRegs.available(AArch64::X16) || !LiveRegs.available(AArch64::X17))
10541054
return false;
10551055
}
10561056

@@ -1603,7 +1603,7 @@ static void emitDefineCFAWithFP(MachineFunction &MF, MachineBasicBlock &MBB,
16031603
/// Collect live registers from the end of \p MI's parent up to (including) \p
16041604
/// MI in \p LiveRegs.
16051605
static void getLivePhysRegsUpTo(MachineInstr &MI, const TargetRegisterInfo &TRI,
1606-
LivePhysRegs &LiveRegs) {
1606+
LiveRegUnits &LiveRegs) {
16071607

16081608
MachineBasicBlock &MBB = *MI.getParent();
16091609
LiveRegs.addLiveOuts(MBB);
@@ -1641,7 +1641,7 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF,
16411641
NonFrameStart->getFlag(MachineInstr::FrameSetup))
16421642
++NonFrameStart;
16431643

1644-
LivePhysRegs LiveRegs(*TRI);
1644+
LiveRegUnits LiveRegs(*TRI);
16451645
if (NonFrameStart != MBB.end()) {
16461646
getLivePhysRegsUpTo(*NonFrameStart, *TRI, LiveRegs);
16471647
// Ignore registers used for stack management for now.
@@ -1659,7 +1659,7 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF,
16591659
make_range(MBB.instr_begin(), NonFrameStart->getIterator())) {
16601660
for (auto &Op : MI.operands())
16611661
if (Op.isReg() && Op.isDef())
1662-
assert(!LiveRegs.contains(Op.getReg()) &&
1662+
assert(LiveRegs.available(Op.getReg()) &&
16631663
"live register clobbered by inserted prologue instructions");
16641664
}
16651665
});
@@ -4014,7 +4014,7 @@ MachineBasicBlock::iterator tryMergeAdjacentSTG(MachineBasicBlock::iterator II,
40144014
// FIXME : This approach of bailing out from merge is conservative in
40154015
// some ways like even if stg loops are not present after merge the
40164016
// insert list, this liveness check is done (which is not needed).
4017-
LivePhysRegs LiveRegs(*(MBB->getParent()->getSubtarget().getRegisterInfo()));
4017+
LiveRegUnits LiveRegs(*(MBB->getParent()->getSubtarget().getRegisterInfo()));
40184018
LiveRegs.addLiveOuts(*MBB);
40194019
for (auto I = MBB->rbegin();; ++I) {
40204020
MachineInstr &MI = *I;
@@ -4023,7 +4023,7 @@ MachineBasicBlock::iterator tryMergeAdjacentSTG(MachineBasicBlock::iterator II,
40234023
LiveRegs.stepBackward(*I);
40244024
}
40254025
InsertI++;
4026-
if (LiveRegs.contains(AArch64::NZCV))
4026+
if (!LiveRegs.available(AArch64::NZCV))
40274027
return InsertI;
40284028

40294029
llvm::stable_sort(Instrs,

0 commit comments

Comments
 (0)