forked from OSchip/llvm-project
[Target] Use range-based for loops (NFC)
This commit is contained in:
parent
b23669123a
commit
dd2ad7fa47
|
@ -543,9 +543,8 @@ HexagonTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
|
|||
// The Glue is necessary since all emitted instructions must be
|
||||
// stuck together.
|
||||
if (!CLI.IsTailCall) {
|
||||
for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i) {
|
||||
Chain = DAG.getCopyToReg(Chain, dl, RegsToPass[i].first,
|
||||
RegsToPass[i].second, Glue);
|
||||
for (const auto &R : RegsToPass) {
|
||||
Chain = DAG.getCopyToReg(Chain, dl, R.first, R.second, Glue);
|
||||
Glue = Chain.getValue(1);
|
||||
}
|
||||
} else {
|
||||
|
@ -560,9 +559,8 @@ HexagonTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
|
|||
//
|
||||
// Do not flag preceding copytoreg stuff together with the following stuff.
|
||||
Glue = SDValue();
|
||||
for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i) {
|
||||
Chain = DAG.getCopyToReg(Chain, dl, RegsToPass[i].first,
|
||||
RegsToPass[i].second, Glue);
|
||||
for (const auto &R : RegsToPass) {
|
||||
Chain = DAG.getCopyToReg(Chain, dl, R.first, R.second, Glue);
|
||||
Glue = Chain.getValue(1);
|
||||
}
|
||||
Glue = SDValue();
|
||||
|
@ -589,10 +587,8 @@ HexagonTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
|
|||
|
||||
// Add argument registers to the end of the list so that they are
|
||||
// known live into the call.
|
||||
for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i) {
|
||||
Ops.push_back(DAG.getRegister(RegsToPass[i].first,
|
||||
RegsToPass[i].second.getValueType()));
|
||||
}
|
||||
for (const auto &R : RegsToPass)
|
||||
Ops.push_back(DAG.getRegister(R.first, R.second.getValueType()));
|
||||
|
||||
const uint32_t *Mask = HRI.getCallPreservedMask(MF, CallConv);
|
||||
assert(Mask && "Missing call preserved mask for calling convention");
|
||||
|
@ -2204,8 +2200,7 @@ HexagonTargetLowering::LowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG)
|
|||
// Express the shuffle mask in terms of bytes.
|
||||
SmallVector<int,8> ByteMask;
|
||||
unsigned ElemBytes = VecTy.getVectorElementType().getSizeInBits() / 8;
|
||||
for (unsigned i = 0, e = Mask.size(); i != e; ++i) {
|
||||
int M = Mask[i];
|
||||
for (int M : Mask) {
|
||||
if (M < 0) {
|
||||
for (unsigned j = 0; j != ElemBytes; ++j)
|
||||
ByteMask.push_back(-1);
|
||||
|
|
|
@ -3486,9 +3486,9 @@ int HexagonInstrInfo::getDuplexOpcode(const MachineInstr &MI,
|
|||
if (Iter != DupMap.end())
|
||||
return Iter->second;
|
||||
} else { // Conversion to Tiny core.
|
||||
for (auto Iter = DupMap.begin(), End = DupMap.end(); Iter != End; ++Iter)
|
||||
if (Iter->second == OpNum)
|
||||
return Iter->first;
|
||||
for (const auto &Iter : DupMap)
|
||||
if (Iter.second == OpNum)
|
||||
return Iter.first;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -578,8 +578,7 @@ void HexagonSplitDoubleRegs::collectIndRegs(LoopRegMap &IRM) {
|
|||
append_range(WorkQ, *WorkQ[i]);
|
||||
|
||||
USet Rs;
|
||||
for (unsigned i = 0, n = WorkQ.size(); i < n; ++i) {
|
||||
MachineLoop *L = WorkQ[i];
|
||||
for (MachineLoop *L : WorkQ) {
|
||||
Rs.clear();
|
||||
collectIndRegsForLoop(L, Rs);
|
||||
if (!Rs.empty())
|
||||
|
|
|
@ -659,8 +659,7 @@ void HexagonVectorLoopCarriedReuse::findLoopCarriedDeps() {
|
|||
delete D;
|
||||
}
|
||||
LLVM_DEBUG(dbgs() << "Found " << Dependences.size() << " dependences\n");
|
||||
LLVM_DEBUG(for (size_t i = 0; i < Dependences.size();
|
||||
++i) { dbgs() << *Dependences[i] << "\n"; });
|
||||
LLVM_DEBUG(for (const DepChain *D : Dependences) dbgs() << *D << "\n";);
|
||||
}
|
||||
|
||||
Pass *llvm::createHexagonVectorLoopCarriedReuseLegacyPass() {
|
||||
|
|
|
@ -81,10 +81,9 @@ void HexagonMCShuffler::copyTo(MCInst &MCB) {
|
|||
MCB.addOperand(MCOperand::createImm(BundleFlags));
|
||||
MCB.setLoc(Loc);
|
||||
// Copy the results into the bundle.
|
||||
for (HexagonShuffler::iterator I = begin(); I != end(); ++I) {
|
||||
|
||||
MCInst const &MI = I->getDesc();
|
||||
MCInst const *Extender = I->getExtender();
|
||||
for (auto &I : *this) {
|
||||
MCInst const &MI = I.getDesc();
|
||||
MCInst const *Extender = I.getExtender();
|
||||
if (Extender)
|
||||
MCB.addOperand(MCOperand::createInst(Extender));
|
||||
MCB.addOperand(MCOperand::createInst(&MI));
|
||||
|
|
|
@ -330,10 +330,10 @@ bool HexagonShuffler::ValidResourceUsage(HexagonPacketSummary const &Summary) {
|
|||
// create vector of hvx instructions to check
|
||||
HVXInstsT hvxInsts;
|
||||
hvxInsts.clear();
|
||||
for (const_iterator I = cbegin(); I != cend(); ++I) {
|
||||
for (const auto &I : *this) {
|
||||
struct CVIUnits inst;
|
||||
inst.Units = I->CVI.getUnits();
|
||||
inst.Lanes = I->CVI.getLanes();
|
||||
inst.Units = I.CVI.getUnits();
|
||||
inst.Lanes = I.CVI.getLanes();
|
||||
if (inst.Units == 0)
|
||||
continue; // not an hvx inst or an hvx inst that doesn't uses any pipes
|
||||
hvxInsts.push_back(inst);
|
||||
|
|
|
@ -412,9 +412,8 @@ bool LanaiMemAluCombiner::runOnMachineFunction(MachineFunction &MF) {
|
|||
|
||||
TII = MF.getSubtarget<LanaiSubtarget>().getInstrInfo();
|
||||
bool Modified = false;
|
||||
for (MfIterator MFI = MF.begin(); MFI != MF.end(); ++MFI) {
|
||||
Modified |= combineMemAluInBasicBlock(&*MFI);
|
||||
}
|
||||
for (MachineBasicBlock &MBB : MF)
|
||||
Modified |= combineMemAluInBasicBlock(&MBB);
|
||||
return Modified;
|
||||
}
|
||||
} // namespace
|
||||
|
|
|
@ -25,8 +25,8 @@ void MipsAnalyzeImmediate::AddInstr(InstSeqLs &SeqLs, const Inst &I) {
|
|||
return;
|
||||
}
|
||||
|
||||
for (InstSeqLs::iterator Iter = SeqLs.begin(); Iter != SeqLs.end(); ++Iter)
|
||||
Iter->push_back(I);
|
||||
for (auto &S : SeqLs)
|
||||
S.push_back(I);
|
||||
}
|
||||
|
||||
void MipsAnalyzeImmediate::GetInstSeqLsADDiu(uint64_t Imm, unsigned RemSize,
|
||||
|
|
|
@ -604,9 +604,9 @@ MipsConstantIslands::CPEntry
|
|||
std::vector<CPEntry> &CPEs = CPEntries[CPI];
|
||||
// Number of entries per constpool index should be small, just do a
|
||||
// linear search.
|
||||
for (unsigned i = 0, e = CPEs.size(); i != e; ++i) {
|
||||
if (CPEs[i].CPEMI == CPEMI)
|
||||
return &CPEs[i];
|
||||
for (CPEntry &CPE : CPEs) {
|
||||
if (CPE.CPEMI == CPEMI)
|
||||
return &CPE;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -1052,27 +1052,27 @@ int MipsConstantIslands::findInRangeCPEntry(CPUser& U, unsigned UserOffset)
|
|||
// No. Look for previously created clones of the CPE that are in range.
|
||||
unsigned CPI = CPEMI->getOperand(1).getIndex();
|
||||
std::vector<CPEntry> &CPEs = CPEntries[CPI];
|
||||
for (unsigned i = 0, e = CPEs.size(); i != e; ++i) {
|
||||
for (CPEntry &CPE : CPEs) {
|
||||
// We already tried this one
|
||||
if (CPEs[i].CPEMI == CPEMI)
|
||||
if (CPE.CPEMI == CPEMI)
|
||||
continue;
|
||||
// Removing CPEs can leave empty entries, skip
|
||||
if (CPEs[i].CPEMI == nullptr)
|
||||
if (CPE.CPEMI == nullptr)
|
||||
continue;
|
||||
if (isCPEntryInRange(UserMI, UserOffset, CPEs[i].CPEMI, U.getMaxDisp(),
|
||||
U.NegOk)) {
|
||||
LLVM_DEBUG(dbgs() << "Replacing CPE#" << CPI << " with CPE#"
|
||||
<< CPEs[i].CPI << "\n");
|
||||
if (isCPEntryInRange(UserMI, UserOffset, CPE.CPEMI, U.getMaxDisp(),
|
||||
U.NegOk)) {
|
||||
LLVM_DEBUG(dbgs() << "Replacing CPE#" << CPI << " with CPE#" << CPE.CPI
|
||||
<< "\n");
|
||||
// Point the CPUser node to the replacement
|
||||
U.CPEMI = CPEs[i].CPEMI;
|
||||
U.CPEMI = CPE.CPEMI;
|
||||
// Change the CPI in the instruction operand to refer to the clone.
|
||||
for (MachineOperand &MO : UserMI->operands())
|
||||
if (MO.isCPI()) {
|
||||
MO.setIndex(CPEs[i].CPI);
|
||||
MO.setIndex(CPE.CPI);
|
||||
break;
|
||||
}
|
||||
// Adjust the refcount of the clone...
|
||||
CPEs[i].RefCount++;
|
||||
CPE.RefCount++;
|
||||
// ...and the original. If we didn't remove the old entry, none of the
|
||||
// addresses changed, so we don't need another pass.
|
||||
return decrementCPEReferenceCount(CPI, CPEMI) ? 2 : 1;
|
||||
|
@ -1108,27 +1108,27 @@ int MipsConstantIslands::findLongFormInRangeCPEntry
|
|||
// No. Look for previously created clones of the CPE that are in range.
|
||||
unsigned CPI = CPEMI->getOperand(1).getIndex();
|
||||
std::vector<CPEntry> &CPEs = CPEntries[CPI];
|
||||
for (unsigned i = 0, e = CPEs.size(); i != e; ++i) {
|
||||
for (CPEntry &CPE : CPEs) {
|
||||
// We already tried this one
|
||||
if (CPEs[i].CPEMI == CPEMI)
|
||||
if (CPE.CPEMI == CPEMI)
|
||||
continue;
|
||||
// Removing CPEs can leave empty entries, skip
|
||||
if (CPEs[i].CPEMI == nullptr)
|
||||
if (CPE.CPEMI == nullptr)
|
||||
continue;
|
||||
if (isCPEntryInRange(UserMI, UserOffset, CPEs[i].CPEMI,
|
||||
U.getLongFormMaxDisp(), U.NegOk)) {
|
||||
LLVM_DEBUG(dbgs() << "Replacing CPE#" << CPI << " with CPE#"
|
||||
<< CPEs[i].CPI << "\n");
|
||||
if (isCPEntryInRange(UserMI, UserOffset, CPE.CPEMI, U.getLongFormMaxDisp(),
|
||||
U.NegOk)) {
|
||||
LLVM_DEBUG(dbgs() << "Replacing CPE#" << CPI << " with CPE#" << CPE.CPI
|
||||
<< "\n");
|
||||
// Point the CPUser node to the replacement
|
||||
U.CPEMI = CPEs[i].CPEMI;
|
||||
U.CPEMI = CPE.CPEMI;
|
||||
// Change the CPI in the instruction operand to refer to the clone.
|
||||
for (MachineOperand &MO : UserMI->operands())
|
||||
if (MO.isCPI()) {
|
||||
MO.setIndex(CPEs[i].CPI);
|
||||
MO.setIndex(CPE.CPI);
|
||||
break;
|
||||
}
|
||||
// Adjust the refcount of the clone...
|
||||
CPEs[i].RefCount++;
|
||||
CPE.RefCount++;
|
||||
// ...and the original. If we didn't remove the old entry, none of the
|
||||
// addresses changed, so we don't need another pass.
|
||||
return decrementCPEReferenceCount(CPI, CPEMI) ? 2 : 1;
|
||||
|
@ -1435,15 +1435,14 @@ void MipsConstantIslands::removeDeadCPEMI(MachineInstr *CPEMI) {
|
|||
/// are zero.
|
||||
bool MipsConstantIslands::removeUnusedCPEntries() {
|
||||
unsigned MadeChange = false;
|
||||
for (unsigned i = 0, e = CPEntries.size(); i != e; ++i) {
|
||||
std::vector<CPEntry> &CPEs = CPEntries[i];
|
||||
for (unsigned j = 0, ee = CPEs.size(); j != ee; ++j) {
|
||||
if (CPEs[j].RefCount == 0 && CPEs[j].CPEMI) {
|
||||
removeDeadCPEMI(CPEs[j].CPEMI);
|
||||
CPEs[j].CPEMI = nullptr;
|
||||
MadeChange = true;
|
||||
}
|
||||
for (std::vector<CPEntry> &CPEs : CPEntries) {
|
||||
for (CPEntry &CPE : CPEs) {
|
||||
if (CPE.RefCount == 0 && CPE.CPEMI) {
|
||||
removeDeadCPEMI(CPE.CPEMI);
|
||||
CPE.CPEMI = nullptr;
|
||||
MadeChange = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return MadeChange;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue