mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-01 15:11:24 +00:00
Simplify a bunch of isVirtualRegister() and isPhysicalRegister() logic.
These functions not longer assert when passed 0, but simply return false instead. No functional change intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123155 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
fdc8f2d260
commit
c9df025e33
@ -159,15 +159,15 @@ public:
|
||||
/// getRegUseDefListHead - Return the head pointer for the register use/def
|
||||
/// list for the specified virtual or physical register.
|
||||
MachineOperand *&getRegUseDefListHead(unsigned RegNo) {
|
||||
if (!RegNo || TargetRegisterInfo::isPhysicalRegister(RegNo))
|
||||
return PhysRegUseDefLists[RegNo];
|
||||
return VRegInfo[RegNo].second;
|
||||
if (TargetRegisterInfo::isVirtualRegister(RegNo))
|
||||
return VRegInfo[RegNo].second;
|
||||
return PhysRegUseDefLists[RegNo];
|
||||
}
|
||||
|
||||
MachineOperand *getRegUseDefListHead(unsigned RegNo) const {
|
||||
if (!RegNo || TargetRegisterInfo::isPhysicalRegister(RegNo))
|
||||
return PhysRegUseDefLists[RegNo];
|
||||
return VRegInfo[RegNo].second;
|
||||
if (TargetRegisterInfo::isVirtualRegister(RegNo))
|
||||
return VRegInfo[RegNo].second;
|
||||
return PhysRegUseDefLists[RegNo];
|
||||
}
|
||||
|
||||
/// getVRegDef - Return the machine instr that defines the specified virtual
|
||||
|
@ -33,7 +33,7 @@ AllocationOrder::AllocationOrder(unsigned VirtReg,
|
||||
Hint = HintPair.second;
|
||||
|
||||
// Translate to physreg, or 0 if not assigned yet.
|
||||
if (Hint && TargetRegisterInfo::isVirtualRegister(Hint))
|
||||
if (TargetRegisterInfo::isVirtualRegister(Hint))
|
||||
Hint = VRM.getPhys(Hint);
|
||||
|
||||
// The remaining allocation order may depend on the hint.
|
||||
|
@ -159,7 +159,7 @@ bool DeadMachineInstructionElim::runOnMachineFunction(MachineFunction &MF) {
|
||||
const MachineOperand &MO = MI->getOperand(i);
|
||||
if (MO.isReg() && MO.isDef()) {
|
||||
unsigned Reg = MO.getReg();
|
||||
if (Reg != 0 && TargetRegisterInfo::isPhysicalRegister(Reg)) {
|
||||
if (TargetRegisterInfo::isPhysicalRegister(Reg)) {
|
||||
LivePhysRegs.reset(Reg);
|
||||
// Check the subreg set, not the alias set, because a def
|
||||
// of a super-register may still be partially live after
|
||||
@ -176,7 +176,7 @@ bool DeadMachineInstructionElim::runOnMachineFunction(MachineFunction &MF) {
|
||||
const MachineOperand &MO = MI->getOperand(i);
|
||||
if (MO.isReg() && MO.isUse()) {
|
||||
unsigned Reg = MO.getReg();
|
||||
if (Reg != 0 && TargetRegisterInfo::isPhysicalRegister(Reg)) {
|
||||
if (TargetRegisterInfo::isPhysicalRegister(Reg)) {
|
||||
LivePhysRegs.set(Reg);
|
||||
for (const unsigned *AliasSet = TRI->getAliasSet(Reg);
|
||||
*AliasSet; ++AliasSet)
|
||||
|
@ -359,7 +359,7 @@ bool LDVImpl::handleDebugValue(MachineInstr *MI, SlotIndex Idx) {
|
||||
// If the location is a virtual register, make sure it is mapped.
|
||||
if (MI->getOperand(0).isReg()) {
|
||||
unsigned Reg = MI->getOperand(0).getReg();
|
||||
if (Reg && TargetRegisterInfo::isVirtualRegister(Reg))
|
||||
if (TargetRegisterInfo::isVirtualRegister(Reg))
|
||||
mapVirtReg(Reg, UV);
|
||||
}
|
||||
|
||||
|
@ -988,7 +988,7 @@ void LiveIntervals::rewriteImplicitOps(const LiveInterval &li,
|
||||
if (!MO.isReg())
|
||||
continue;
|
||||
unsigned Reg = MO.getReg();
|
||||
if (Reg == 0 || TargetRegisterInfo::isPhysicalRegister(Reg))
|
||||
if (!TargetRegisterInfo::isVirtualRegister(Reg))
|
||||
continue;
|
||||
if (!vrm.isReMaterialized(Reg))
|
||||
continue;
|
||||
@ -1022,7 +1022,7 @@ rewriteInstructionForSpills(const LiveInterval &li, const VNInfo *VNI,
|
||||
if (!mop.isReg())
|
||||
continue;
|
||||
unsigned Reg = mop.getReg();
|
||||
if (Reg == 0 || TargetRegisterInfo::isPhysicalRegister(Reg))
|
||||
if (!TargetRegisterInfo::isVirtualRegister(Reg))
|
||||
continue;
|
||||
if (Reg != li.reg)
|
||||
continue;
|
||||
|
@ -116,7 +116,7 @@ bool MachineCSE::PerformTrivialCoalescing(MachineInstr *MI,
|
||||
if (!MO.isReg() || !MO.isUse())
|
||||
continue;
|
||||
unsigned Reg = MO.getReg();
|
||||
if (!Reg || TargetRegisterInfo::isPhysicalRegister(Reg))
|
||||
if (!TargetRegisterInfo::isVirtualRegister(Reg))
|
||||
continue;
|
||||
if (!MRI->hasOneNonDBGUse(Reg))
|
||||
// Only coalesce single use copies. This ensure the copy will be
|
||||
@ -300,7 +300,7 @@ bool MachineCSE::isProfitableToCSE(unsigned CSReg, unsigned Reg,
|
||||
bool HasVRegUse = false;
|
||||
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
|
||||
const MachineOperand &MO = MI->getOperand(i);
|
||||
if (MO.isReg() && MO.isUse() && MO.getReg() &&
|
||||
if (MO.isReg() && MO.isUse() &&
|
||||
TargetRegisterInfo::isVirtualRegister(MO.getReg())) {
|
||||
HasVRegUse = true;
|
||||
break;
|
||||
|
@ -1326,7 +1326,7 @@ void MachineInstr::print(raw_ostream &OS, const TargetMachine *TM) const {
|
||||
if (StartOp != 0) OS << ", ";
|
||||
getOperand(StartOp).print(OS, TM);
|
||||
unsigned Reg = getOperand(StartOp).getReg();
|
||||
if (Reg && TargetRegisterInfo::isVirtualRegister(Reg))
|
||||
if (TargetRegisterInfo::isVirtualRegister(Reg))
|
||||
VirtRegs.push_back(Reg);
|
||||
}
|
||||
|
||||
@ -1360,8 +1360,7 @@ void MachineInstr::print(raw_ostream &OS, const TargetMachine *TM) const {
|
||||
for (unsigned i = StartOp, e = getNumOperands(); i != e; ++i) {
|
||||
const MachineOperand &MO = getOperand(i);
|
||||
|
||||
if (MO.isReg() && MO.getReg() &&
|
||||
TargetRegisterInfo::isVirtualRegister(MO.getReg()))
|
||||
if (MO.isReg() && TargetRegisterInfo::isVirtualRegister(MO.getReg()))
|
||||
VirtRegs.push_back(MO.getReg());
|
||||
|
||||
// Omit call-clobbered registers which aren't used anywhere. This makes
|
||||
@ -1371,7 +1370,7 @@ void MachineInstr::print(raw_ostream &OS, const TargetMachine *TM) const {
|
||||
if (MF && getDesc().isCall() &&
|
||||
MO.isReg() && MO.isImplicit() && MO.isDef()) {
|
||||
unsigned Reg = MO.getReg();
|
||||
if (Reg != 0 && TargetRegisterInfo::isPhysicalRegister(Reg)) {
|
||||
if (TargetRegisterInfo::isPhysicalRegister(Reg)) {
|
||||
const MachineRegisterInfo &MRI = MF->getRegInfo();
|
||||
if (MRI.use_empty(Reg) && !MRI.isLiveOut(Reg)) {
|
||||
bool HasAliasLive = false;
|
||||
@ -1620,8 +1619,7 @@ MachineInstrExpressionTrait::getHashValue(const MachineInstr* const &MI) {
|
||||
switch (MO.getType()) {
|
||||
default: break;
|
||||
case MachineOperand::MO_Register:
|
||||
if (MO.isDef() && MO.getReg() &&
|
||||
TargetRegisterInfo::isVirtualRegister(MO.getReg()))
|
||||
if (MO.isDef() && TargetRegisterInfo::isVirtualRegister(MO.getReg()))
|
||||
continue; // Skip virtual register defs.
|
||||
Key |= MO.getReg();
|
||||
break;
|
||||
|
@ -622,7 +622,7 @@ void MachineLICM::InitRegPressure(MachineBasicBlock *BB) {
|
||||
if (!MO.isReg() || MO.isImplicit())
|
||||
continue;
|
||||
unsigned Reg = MO.getReg();
|
||||
if (!Reg || TargetRegisterInfo::isPhysicalRegister(Reg))
|
||||
if (!TargetRegisterInfo::isVirtualRegister(Reg))
|
||||
continue;
|
||||
|
||||
bool isNew = RegSeen.insert(Reg);
|
||||
@ -655,7 +655,7 @@ void MachineLICM::UpdateRegPressure(const MachineInstr *MI) {
|
||||
if (!MO.isReg() || MO.isImplicit())
|
||||
continue;
|
||||
unsigned Reg = MO.getReg();
|
||||
if (!Reg || TargetRegisterInfo::isPhysicalRegister(Reg))
|
||||
if (!TargetRegisterInfo::isVirtualRegister(Reg))
|
||||
continue;
|
||||
|
||||
bool isNew = RegSeen.insert(Reg);
|
||||
@ -889,7 +889,7 @@ void MachineLICM::UpdateBackTraceRegPressure(const MachineInstr *MI) {
|
||||
if (!MO.isReg() || MO.isImplicit())
|
||||
continue;
|
||||
unsigned Reg = MO.getReg();
|
||||
if (!Reg || TargetRegisterInfo::isPhysicalRegister(Reg))
|
||||
if (!TargetRegisterInfo::isVirtualRegister(Reg))
|
||||
continue;
|
||||
|
||||
const TargetRegisterClass *RC = MRI->getRegClass(Reg);
|
||||
@ -952,7 +952,7 @@ bool MachineLICM::IsProfitableToHoist(MachineInstr &MI) {
|
||||
if (!MO.isReg() || MO.isImplicit())
|
||||
continue;
|
||||
unsigned Reg = MO.getReg();
|
||||
if (!Reg || TargetRegisterInfo::isPhysicalRegister(Reg))
|
||||
if (!TargetRegisterInfo::isVirtualRegister(Reg))
|
||||
continue;
|
||||
if (MO.isDef()) {
|
||||
if (HasHighOperandLatency(MI, i, Reg)) {
|
||||
|
@ -295,7 +295,7 @@ bool PeepholeOptimizer::FoldImmediate(MachineInstr *MI, MachineBasicBlock *MBB,
|
||||
if (!MO.isReg() || MO.isDef())
|
||||
continue;
|
||||
unsigned Reg = MO.getReg();
|
||||
if (!Reg || TargetRegisterInfo::isPhysicalRegister(Reg))
|
||||
if (!TargetRegisterInfo::isVirtualRegister(Reg))
|
||||
continue;
|
||||
if (ImmDefRegs.count(Reg) == 0)
|
||||
continue;
|
||||
|
@ -656,7 +656,8 @@ void RAFast::handleThroughOperands(MachineInstr *MI,
|
||||
MachineOperand &MO = MI->getOperand(i);
|
||||
if (!MO.isReg()) continue;
|
||||
unsigned Reg = MO.getReg();
|
||||
if (!Reg || TargetRegisterInfo::isPhysicalRegister(Reg)) continue;
|
||||
if (!TargetRegisterInfo::isVirtualRegister(Reg))
|
||||
continue;
|
||||
if (MO.isEarlyClobber() || MI->isRegTiedToDefOperand(i) ||
|
||||
(MO.getSubReg() && MI->readsVirtualRegister(Reg))) {
|
||||
if (ThroughRegs.insert(Reg))
|
||||
@ -688,7 +689,7 @@ void RAFast::handleThroughOperands(MachineInstr *MI,
|
||||
MachineOperand &MO = MI->getOperand(i);
|
||||
if (!MO.isReg()) continue;
|
||||
unsigned Reg = MO.getReg();
|
||||
if (!Reg || TargetRegisterInfo::isPhysicalRegister(Reg)) continue;
|
||||
if (!TargetRegisterInfo::isVirtualRegister(Reg)) continue;
|
||||
if (MO.isUse()) {
|
||||
unsigned DefIdx = 0;
|
||||
if (!MI->isRegTiedToDefOperand(i, &DefIdx)) continue;
|
||||
@ -794,7 +795,7 @@ void RAFast::AllocateBasicBlock() {
|
||||
MachineOperand &MO = MI->getOperand(i);
|
||||
if (!MO.isReg()) continue;
|
||||
unsigned Reg = MO.getReg();
|
||||
if (!Reg || TargetRegisterInfo::isPhysicalRegister(Reg)) continue;
|
||||
if (!TargetRegisterInfo::isVirtualRegister(Reg)) continue;
|
||||
LiveDbgValueMap[Reg] = MI;
|
||||
LiveRegMap::iterator LRI = LiveVirtRegs.find(Reg);
|
||||
if (LRI != LiveVirtRegs.end())
|
||||
@ -909,7 +910,7 @@ void RAFast::AllocateBasicBlock() {
|
||||
MachineOperand &MO = MI->getOperand(i);
|
||||
if (!MO.isReg()) continue;
|
||||
unsigned Reg = MO.getReg();
|
||||
if (!Reg || TargetRegisterInfo::isPhysicalRegister(Reg)) continue;
|
||||
if (!TargetRegisterInfo::isVirtualRegister(Reg)) continue;
|
||||
if (MO.isUse()) {
|
||||
LiveRegMap::iterator LRI = reloadVirtReg(MI, i, Reg, CopyDst);
|
||||
unsigned PhysReg = LRI->second.PhysReg;
|
||||
|
@ -1421,8 +1421,7 @@ unsigned RALinScan::getFreePhysReg(LiveInterval* cur,
|
||||
std::pair<unsigned, unsigned> Hint = mri_->getRegAllocationHint(cur->reg);
|
||||
// Resolve second part of the hint (if possible) given the current allocation.
|
||||
unsigned physReg = Hint.second;
|
||||
if (physReg &&
|
||||
TargetRegisterInfo::isVirtualRegister(physReg) && vrm_->hasPhys(physReg))
|
||||
if (TargetRegisterInfo::isVirtualRegister(physReg) && vrm_->hasPhys(physReg))
|
||||
physReg = vrm_->getPhys(physReg);
|
||||
|
||||
TargetRegisterClass::iterator I, E;
|
||||
|
@ -703,7 +703,7 @@ EmitMachineNode(SDNode *Node, bool IsClone, bool IsCloned,
|
||||
for (unsigned i = 0, e = F->getNumOperands(); i != e; ++i)
|
||||
if (RegisterSDNode *R = dyn_cast<RegisterSDNode>(F->getOperand(i))) {
|
||||
unsigned Reg = R->getReg();
|
||||
if (Reg != 0 && TargetRegisterInfo::isPhysicalRegister(Reg))
|
||||
if (TargetRegisterInfo::isPhysicalRegister(Reg))
|
||||
UsedRegs.push_back(Reg);
|
||||
}
|
||||
}
|
||||
|
@ -4070,7 +4070,7 @@ SelectionDAGBuilder::EmitFuncArgumentDbgValue(const Value *V, MDNode *Variable,
|
||||
|
||||
if (N.getNode() && N.getOpcode() == ISD::CopyFromReg) {
|
||||
Reg = cast<RegisterSDNode>(N.getOperand(1))->getReg();
|
||||
if (Reg && TargetRegisterInfo::isVirtualRegister(Reg)) {
|
||||
if (TargetRegisterInfo::isVirtualRegister(Reg)) {
|
||||
MachineRegisterInfo &RegInfo = MF.getRegInfo();
|
||||
unsigned PR = RegInfo.getLiveInPhysReg(Reg);
|
||||
if (PR)
|
||||
|
@ -350,7 +350,7 @@ void TailDuplicatePass::DuplicateInstruction(MachineInstr *MI,
|
||||
if (!MO.isReg())
|
||||
continue;
|
||||
unsigned Reg = MO.getReg();
|
||||
if (!Reg || TargetRegisterInfo::isPhysicalRegister(Reg))
|
||||
if (!TargetRegisterInfo::isVirtualRegister(Reg))
|
||||
continue;
|
||||
if (MO.isDef()) {
|
||||
const TargetRegisterClass *RC = MRI->getRegClass(Reg);
|
||||
|
@ -954,7 +954,7 @@ TryInstructionTransform(MachineBasicBlock::iterator &mi,
|
||||
if (LV) {
|
||||
for (unsigned i = 0, e = mi->getNumOperands(); i != e; ++i) {
|
||||
MachineOperand &MO = mi->getOperand(i);
|
||||
if (MO.isReg() && MO.getReg() != 0 &&
|
||||
if (MO.isReg() &&
|
||||
TargetRegisterInfo::isVirtualRegister(MO.getReg())) {
|
||||
if (MO.isUse()) {
|
||||
if (MO.isKill()) {
|
||||
|
@ -115,11 +115,10 @@ unsigned VirtRegMap::createSpillSlot(const TargetRegisterClass *RC) {
|
||||
unsigned VirtRegMap::getRegAllocPref(unsigned virtReg) {
|
||||
std::pair<unsigned, unsigned> Hint = MRI->getRegAllocationHint(virtReg);
|
||||
unsigned physReg = Hint.second;
|
||||
if (physReg &&
|
||||
TargetRegisterInfo::isVirtualRegister(physReg) && hasPhys(physReg))
|
||||
if (TargetRegisterInfo::isVirtualRegister(physReg) && hasPhys(physReg))
|
||||
physReg = getPhys(physReg);
|
||||
if (Hint.first == 0)
|
||||
return (physReg && TargetRegisterInfo::isPhysicalRegister(physReg))
|
||||
return (TargetRegisterInfo::isPhysicalRegister(physReg))
|
||||
? physReg : 0;
|
||||
return TRI->ResolveRegAllocHint(Hint.first, physReg, *MF);
|
||||
}
|
||||
|
@ -234,8 +234,7 @@ ARMBaseInstrInfo::convertToThreeAddress(MachineFunction::iterator &MFI,
|
||||
if (LV) {
|
||||
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
|
||||
MachineOperand &MO = MI->getOperand(i);
|
||||
if (MO.isReg() && MO.getReg() &&
|
||||
TargetRegisterInfo::isVirtualRegister(MO.getReg())) {
|
||||
if (MO.isReg() && TargetRegisterInfo::isVirtualRegister(MO.getReg())) {
|
||||
unsigned Reg = MO.getReg();
|
||||
|
||||
LiveVariables::VarInfo &VI = LV->getVarInfo(Reg);
|
||||
|
@ -517,7 +517,7 @@ ARMBaseRegisterInfo::UpdateRegAllocHint(unsigned Reg, unsigned NewReg,
|
||||
std::pair<unsigned, unsigned> Hint = MRI->getRegAllocationHint(Reg);
|
||||
if ((Hint.first == (unsigned)ARMRI::RegPairOdd ||
|
||||
Hint.first == (unsigned)ARMRI::RegPairEven) &&
|
||||
Hint.second && TargetRegisterInfo::isVirtualRegister(Hint.second)) {
|
||||
TargetRegisterInfo::isVirtualRegister(Hint.second)) {
|
||||
// If 'Reg' is one of the even / odd register pair and it's now changed
|
||||
// (e.g. coalesced) into a different register. The other register of the
|
||||
// pair allocation hint must be updated to reflect the relationship
|
||||
|
@ -1458,7 +1458,7 @@ bool MatchingStackOffset(SDValue Arg, unsigned Offset, ISD::ArgFlagsTy Flags,
|
||||
int FI = INT_MAX;
|
||||
if (Arg.getOpcode() == ISD::CopyFromReg) {
|
||||
unsigned VR = cast<RegisterSDNode>(Arg.getOperand(1))->getReg();
|
||||
if (!VR || TargetRegisterInfo::isPhysicalRegister(VR))
|
||||
if (!TargetRegisterInfo::isVirtualRegister(VR))
|
||||
return false;
|
||||
MachineInstr *Def = MRI->getVRegDef(VR);
|
||||
if (!Def)
|
||||
|
@ -2323,7 +2323,7 @@ bool MatchingStackOffset(SDValue Arg, unsigned Offset, ISD::ArgFlagsTy Flags,
|
||||
int FI = INT_MAX;
|
||||
if (Arg.getOpcode() == ISD::CopyFromReg) {
|
||||
unsigned VR = cast<RegisterSDNode>(Arg.getOperand(1))->getReg();
|
||||
if (!VR || TargetRegisterInfo::isPhysicalRegister(VR))
|
||||
if (!TargetRegisterInfo::isVirtualRegister(VR))
|
||||
return false;
|
||||
MachineInstr *Def = MRI->getVRegDef(VR);
|
||||
if (!Def)
|
||||
|
Loading…
Reference in New Issue
Block a user