diff options
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/LiveIntervalAnalysis.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/MachineInstr.cpp | 26 | ||||
-rw-r--r-- | lib/CodeGen/PostRASchedulerList.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/PreAllocSplitting.cpp | 4 | ||||
-rw-r--r-- | lib/CodeGen/RegAllocLocal.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/RegAllocSimple.cpp | 4 | ||||
-rw-r--r-- | lib/CodeGen/RegisterScavenging.cpp | 6 | ||||
-rw-r--r-- | lib/CodeGen/Spiller.cpp | 4 |
8 files changed, 28 insertions, 22 deletions
diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp index cb08fe759f..3bc05a9b9a 100644 --- a/lib/CodeGen/LiveIntervalAnalysis.cpp +++ b/lib/CodeGen/LiveIntervalAnalysis.cpp @@ -469,7 +469,7 @@ void LiveIntervals::handleVirtualRegisterDef(MachineBasicBlock *mbb, // must be due to phi elimination or two addr elimination. If this is // the result of two address elimination, then the vreg is one of the // def-and-use register operand. - if (mi->isRegReDefinedByTwoAddr(MOIdx)) { + if (mi->isRegTiedToUseOperand(MOIdx)) { // If this is a two-address definition, then we have already processed // the live range. The only problem is that we didn't realize there // are actually two values in the live interval. Because of this we diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp index ade8683ec7..d3b2e9a91c 100644 --- a/lib/CodeGen/MachineInstr.cpp +++ b/lib/CodeGen/MachineInstr.cpp @@ -690,12 +690,14 @@ int MachineInstr::findFirstPredOperandIdx() const { return -1; } -/// isRegReDefinedByTwoAddr - Given the index of a register operand, -/// check if the register def is a re-definition due to two addr elimination. -bool MachineInstr::isRegReDefinedByTwoAddr(unsigned DefIdx) const{ +/// isRegTiedToUseOperand - Given the index of a register def operand, +/// check if the register def is tied to a source operand, due to either +/// two-address elimination or inline assembly constraints. Returns the +/// first tied use operand index by reference is UseOpIdx is not null. +bool MachineInstr::isRegTiedToUseOperand(unsigned DefOpIdx, unsigned *UseOpIdx){ if (getOpcode() == TargetInstrInfo::INLINEASM) { - assert(DefIdx >= 2); - const MachineOperand &MO = getOperand(DefIdx); + assert(DefOpIdx >= 2); + const MachineOperand &MO = getOperand(DefOpIdx); if (!MO.isReg() || !MO.isDef()) return false; // Determine the actual operand no corresponding to this index. @@ -705,7 +707,7 @@ bool MachineInstr::isRegReDefinedByTwoAddr(unsigned DefIdx) const{ assert(FMO.isImm()); // Skip over this def. i += InlineAsm::getNumOperandRegisters(FMO.getImm()) + 1; - if (i > DefIdx) + if (i > DefOpIdx) break; ++DefNo; } @@ -717,18 +719,24 @@ bool MachineInstr::isRegReDefinedByTwoAddr(unsigned DefIdx) const{ continue; unsigned Idx; if (InlineAsm::isUseOperandTiedToDef(FMO.getImm(), Idx) && - Idx == DefNo) + Idx == DefNo) { + if (UseOpIdx) + *UseOpIdx = (unsigned)i + 1; return true; + } } } - assert(getOperand(DefIdx).isDef() && "DefIdx is not a def!"); + assert(getOperand(DefOpIdx).isDef() && "DefOpIdx is not a def!"); const TargetInstrDesc &TID = getDesc(); for (unsigned i = 0, e = TID.getNumOperands(); i != e; ++i) { const MachineOperand &MO = getOperand(i); if (MO.isReg() && MO.isUse() && - TID.getOperandConstraint(i, TOI::TIED_TO) == (int)DefIdx) + TID.getOperandConstraint(i, TOI::TIED_TO) == (int)DefOpIdx) { + if (UseOpIdx) + *UseOpIdx = (unsigned)i; return true; + } } return false; } diff --git a/lib/CodeGen/PostRASchedulerList.cpp b/lib/CodeGen/PostRASchedulerList.cpp index 311ad28110..f4e958c107 100644 --- a/lib/CodeGen/PostRASchedulerList.cpp +++ b/lib/CodeGen/PostRASchedulerList.cpp @@ -500,7 +500,7 @@ void SchedulePostRATDList::ScanInstruction(MachineInstr *MI, if (Reg == 0) continue; if (!MO.isDef()) continue; // Ignore two-addr defs. - if (MI->isRegReDefinedByTwoAddr(i)) continue; + if (MI->isRegTiedToUseOperand(i)) continue; DefIndices[Reg] = Count; KillIndices[Reg] = ~0u; diff --git a/lib/CodeGen/PreAllocSplitting.cpp b/lib/CodeGen/PreAllocSplitting.cpp index d9775f9f0d..c4bda4862e 100644 --- a/lib/CodeGen/PreAllocSplitting.cpp +++ b/lib/CodeGen/PreAllocSplitting.cpp @@ -803,7 +803,7 @@ void PreAllocSplitting::RenumberValno(VNInfo* VN) { MachineInstr* MI = LIs->getInstructionFromIndex(*KI); unsigned DefIdx = MI->findRegisterDefOperandIdx(CurrLI->reg); if (DefIdx == ~0U) continue; - if (MI->isRegReDefinedByTwoAddr(DefIdx)) { + if (MI->isRegTiedToUseOperand(DefIdx)) { VNInfo* NextVN = CurrLI->findDefinedVNInfo(LiveIntervals::getDefIndex(*KI)); if (NextVN == OldVN) continue; @@ -1214,7 +1214,7 @@ unsigned PreAllocSplitting::getNumberOfNonSpills( NonSpills++; int DefIdx = (*UI)->findRegisterDefOperandIdx(Reg); - if (DefIdx != -1 && (*UI)->isRegReDefinedByTwoAddr(DefIdx)) + if (DefIdx != -1 && (*UI)->isRegTiedToUseOperand(DefIdx)) FeedsTwoAddr = true; } diff --git a/lib/CodeGen/RegAllocLocal.cpp b/lib/CodeGen/RegAllocLocal.cpp index b965dc9f0f..14346e90ed 100644 --- a/lib/CodeGen/RegAllocLocal.cpp +++ b/lib/CodeGen/RegAllocLocal.cpp @@ -633,7 +633,7 @@ void RALocal::ComputeLocalLiveness(MachineBasicBlock& MBB) { // Check if this is a two address instruction. If so, then // the def does not kill the use. if (last->second.first == I && - I->isRegReDefinedByTwoAddr(i)) + I->isRegTiedToUseOperand(i)) continue; MachineOperand& lastUD = diff --git a/lib/CodeGen/RegAllocSimple.cpp b/lib/CodeGen/RegAllocSimple.cpp index 5e5290ce3e..447e54cf79 100644 --- a/lib/CodeGen/RegAllocSimple.cpp +++ b/lib/CodeGen/RegAllocSimple.cpp @@ -204,8 +204,8 @@ void RegAllocSimple::AllocateBasicBlock(MachineBasicBlock &MBB) { unsigned physReg = Virt2PhysRegMap[virtualReg]; if (physReg == 0) { if (MO.isDef()) { - int TiedOp = Desc.findTiedToSrcOperand(i); - if (TiedOp == -1) { + unsigned TiedOp; + if (!MI->isRegTiedToUseOperand(i, &TiedOp)) { physReg = getFreeReg(virtualReg); } else { // must be same register number as the source operand that is diff --git a/lib/CodeGen/RegisterScavenging.cpp b/lib/CodeGen/RegisterScavenging.cpp index 9447ff2c41..944468ea11 100644 --- a/lib/CodeGen/RegisterScavenging.cpp +++ b/lib/CodeGen/RegisterScavenging.cpp @@ -188,7 +188,6 @@ void RegScavenger::forward() { MachineInstr *MI = MBBI; DistanceMap.insert(std::make_pair(MI, CurrDist++)); - const TargetInstrDesc &TID = MI->getDesc(); if (MI == ScavengeRestore) { ScavengedReg = 0; @@ -256,7 +255,7 @@ void RegScavenger::forward() { } // Skip two-address destination operand. - if (TID.findTiedToSrcOperand(Idx) != -1) { + if (MI->isRegTiedToUseOperand(Idx)) { assert(isUsed(Reg) && "Using an undefined register!"); continue; } @@ -284,7 +283,6 @@ void RegScavenger::backward() { MachineInstr *MI = MBBI; DistanceMap.erase(MI); --CurrDist; - const TargetInstrDesc &TID = MI->getDesc(); // Separate register operands into 3 classes: uses, defs, earlyclobbers. SmallVector<std::pair<const MachineOperand*,unsigned>, 4> UseMOs; @@ -313,7 +311,7 @@ void RegScavenger::backward() { ? DefMOs[i].second : EarlyClobberMOs[i-NumDefs].second; // Skip two-address destination operand. - if (TID.findTiedToSrcOperand(Idx) != -1) + if (MI->isRegTiedToUseOperand(Idx)) continue; unsigned Reg = MO.getReg(); diff --git a/lib/CodeGen/Spiller.cpp b/lib/CodeGen/Spiller.cpp index 7b2a32f1c7..354ff0a649 100644 --- a/lib/CodeGen/Spiller.cpp +++ b/lib/CodeGen/Spiller.cpp @@ -1589,8 +1589,8 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM, // If this def is part of a two-address operand, make sure to execute // the store from the correct physical register. unsigned PhysReg; - int TiedOp = MI.getDesc().findTiedToSrcOperand(i); - if (TiedOp != -1) { + unsigned TiedOp; + if (MI.isRegTiedToUseOperand(i, &TiedOp)) { PhysReg = MI.getOperand(TiedOp).getReg(); if (SubIdx) { unsigned SuperReg = findSuperReg(RC, PhysReg, SubIdx, TRI); |