mirror of
				https://github.com/c64scene-ar/llvm-6502.git
				synced 2025-10-30 16:17:05 +00:00 
			
		
		
		
	Use range-based for loops. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238093 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
		| @@ -185,9 +185,8 @@ RegUseTracker::SwapAndDropUse(size_t LUIdx, size_t LastLUIdx) { | |||||||
|  |  | ||||||
|   // Update RegUses. The data structure is not optimized for this purpose; |   // Update RegUses. The data structure is not optimized for this purpose; | ||||||
|   // we must iterate through it and update each of the bit vectors. |   // we must iterate through it and update each of the bit vectors. | ||||||
|   for (RegUsesTy::iterator I = RegUsesMap.begin(), E = RegUsesMap.end(); |   for (auto &I : RegUsesMap) { | ||||||
|        I != E; ++I) { |     SmallBitVector &UsedByIndices = I.second.UsedByIndices; | ||||||
|     SmallBitVector &UsedByIndices = I->second.UsedByIndices; |  | ||||||
|     if (LUIdx < UsedByIndices.size()) |     if (LUIdx < UsedByIndices.size()) | ||||||
|       UsedByIndices[LUIdx] = |       UsedByIndices[LUIdx] = | ||||||
|         LastLUIdx < UsedByIndices.size() ? UsedByIndices[LastLUIdx] : 0; |         LastLUIdx < UsedByIndices.size() ? UsedByIndices[LastLUIdx] : 0; | ||||||
| @@ -297,9 +296,8 @@ static void DoInitialMatch(const SCEV *S, Loop *L, | |||||||
|  |  | ||||||
|   // Look at add operands. |   // Look at add operands. | ||||||
|   if (const SCEVAddExpr *Add = dyn_cast<SCEVAddExpr>(S)) { |   if (const SCEVAddExpr *Add = dyn_cast<SCEVAddExpr>(S)) { | ||||||
|     for (SCEVAddExpr::op_iterator I = Add->op_begin(), E = Add->op_end(); |     for (const SCEV *S : Add->operands()) | ||||||
|          I != E; ++I) |       DoInitialMatch(S, L, Good, Bad, SE); | ||||||
|       DoInitialMatch(*I, L, Good, Bad, SE); |  | ||||||
|     return; |     return; | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -3847,10 +3845,8 @@ void LSRInstance::GenerateCrossUseConstantOffsets() { | |||||||
|           // If the new formula has a constant in a register, and adding the |           // If the new formula has a constant in a register, and adding the | ||||||
|           // constant value to the immediate would produce a value closer to |           // constant value to the immediate would produce a value closer to | ||||||
|           // zero than the immediate itself, then the formula isn't worthwhile. |           // zero than the immediate itself, then the formula isn't worthwhile. | ||||||
|           for (SmallVectorImpl<const SCEV *>::const_iterator |           for (const SCEV *J : NewF.BaseRegs) | ||||||
|                J = NewF.BaseRegs.begin(), JE = NewF.BaseRegs.end(); |             if (const SCEVConstant *C = dyn_cast<SCEVConstant>(J)) | ||||||
|                J != JE; ++J) |  | ||||||
|             if (const SCEVConstant *C = dyn_cast<SCEVConstant>(*J)) |  | ||||||
|               if ((C->getValue()->getValue() + NewF.BaseOffset).abs().slt( |               if ((C->getValue()->getValue() + NewF.BaseOffset).abs().slt( | ||||||
|                    std::abs(NewF.BaseOffset)) && |                    std::abs(NewF.BaseOffset)) && | ||||||
|                   (C->getValue()->getValue() + |                   (C->getValue()->getValue() + | ||||||
| @@ -3953,9 +3949,7 @@ void LSRInstance::FilterOutUndesirableDedicatedRegisters() { | |||||||
|       } |       } | ||||||
|       else { |       else { | ||||||
|         SmallVector<const SCEV *, 4> Key; |         SmallVector<const SCEV *, 4> Key; | ||||||
|         for (SmallVectorImpl<const SCEV *>::const_iterator J = F.BaseRegs.begin(), |         for (const SCEV *Reg : F.BaseRegs) { | ||||||
|                JE = F.BaseRegs.end(); J != JE; ++J) { |  | ||||||
|           const SCEV *Reg = *J; |  | ||||||
|           if (RegUses.isRegUsedByUsesOtherThan(Reg, LUIdx)) |           if (RegUses.isRegUsedByUsesOtherThan(Reg, LUIdx)) | ||||||
|             Key.push_back(Reg); |             Key.push_back(Reg); | ||||||
|         } |         } | ||||||
| @@ -4017,9 +4011,8 @@ static const size_t ComplexityLimit = UINT16_MAX; | |||||||
| /// isn't always sufficient. | /// isn't always sufficient. | ||||||
| size_t LSRInstance::EstimateSearchSpaceComplexity() const { | size_t LSRInstance::EstimateSearchSpaceComplexity() const { | ||||||
|   size_t Power = 1; |   size_t Power = 1; | ||||||
|   for (SmallVectorImpl<LSRUse>::const_iterator I = Uses.begin(), |   for (const LSRUse &I : Uses) { | ||||||
|        E = Uses.end(); I != E; ++I) { |     size_t FSize = I.Formulae.size(); | ||||||
|     size_t FSize = I->Formulae.size(); |  | ||||||
|     if (FSize >= ComplexityLimit) { |     if (FSize >= ComplexityLimit) { | ||||||
|       Power = ComplexityLimit; |       Power = ComplexityLimit; | ||||||
|       break; |       break; | ||||||
| @@ -4110,9 +4103,7 @@ void LSRInstance::NarrowSearchSpaceByCollapsingUnrolledCode() { | |||||||
|  |  | ||||||
|   for (size_t LUIdx = 0, NumUses = Uses.size(); LUIdx != NumUses; ++LUIdx) { |   for (size_t LUIdx = 0, NumUses = Uses.size(); LUIdx != NumUses; ++LUIdx) { | ||||||
|     LSRUse &LU = Uses[LUIdx]; |     LSRUse &LU = Uses[LUIdx]; | ||||||
|     for (SmallVectorImpl<Formula>::const_iterator I = LU.Formulae.begin(), |     for (const Formula &F : LU.Formulae) { | ||||||
|          E = LU.Formulae.end(); I != E; ++I) { |  | ||||||
|       const Formula &F = *I; |  | ||||||
|       if (F.BaseOffset == 0 || (F.Scale != 0 && F.Scale != 1)) |       if (F.BaseOffset == 0 || (F.Scale != 0 && F.Scale != 1)) | ||||||
|         continue; |         continue; | ||||||
|  |  | ||||||
| @@ -4129,9 +4120,7 @@ void LSRInstance::NarrowSearchSpaceByCollapsingUnrolledCode() { | |||||||
|       LUThatHas->AllFixupsOutsideLoop &= LU.AllFixupsOutsideLoop; |       LUThatHas->AllFixupsOutsideLoop &= LU.AllFixupsOutsideLoop; | ||||||
|  |  | ||||||
|       // Update the relocs to reference the new use. |       // Update the relocs to reference the new use. | ||||||
|       for (SmallVectorImpl<LSRFixup>::iterator I = Fixups.begin(), |       for (LSRFixup &Fixup : Fixups) { | ||||||
|            E = Fixups.end(); I != E; ++I) { |  | ||||||
|         LSRFixup &Fixup = *I; |  | ||||||
|         if (Fixup.LUIdx == LUIdx) { |         if (Fixup.LUIdx == LUIdx) { | ||||||
|           Fixup.LUIdx = LUThatHas - &Uses.front(); |           Fixup.LUIdx = LUThatHas - &Uses.front(); | ||||||
|           Fixup.Offset += F.BaseOffset; |           Fixup.Offset += F.BaseOffset; | ||||||
| @@ -4212,9 +4201,7 @@ void LSRInstance::NarrowSearchSpaceByPickingWinnerRegs() { | |||||||
|     // to be a good reuse register candidate. |     // to be a good reuse register candidate. | ||||||
|     const SCEV *Best = nullptr; |     const SCEV *Best = nullptr; | ||||||
|     unsigned BestNum = 0; |     unsigned BestNum = 0; | ||||||
|     for (RegUseTracker::const_iterator I = RegUses.begin(), E = RegUses.end(); |     for (const SCEV *Reg : RegUses) { | ||||||
|          I != E; ++I) { |  | ||||||
|       const SCEV *Reg = *I; |  | ||||||
|       if (Taken.count(Reg)) |       if (Taken.count(Reg)) | ||||||
|         continue; |         continue; | ||||||
|       if (!Best) |       if (!Best) | ||||||
| @@ -4302,17 +4289,12 @@ void LSRInstance::SolveRecurse(SmallVectorImpl<const Formula *> &Solution, | |||||||
|  |  | ||||||
|   SmallPtrSet<const SCEV *, 16> NewRegs; |   SmallPtrSet<const SCEV *, 16> NewRegs; | ||||||
|   Cost NewCost; |   Cost NewCost; | ||||||
|   for (SmallVectorImpl<Formula>::const_iterator I = LU.Formulae.begin(), |   for (const Formula &F : LU.Formulae) { | ||||||
|        E = LU.Formulae.end(); I != E; ++I) { |  | ||||||
|     const Formula &F = *I; |  | ||||||
|  |  | ||||||
|     // Ignore formulae which may not be ideal in terms of register reuse of |     // Ignore formulae which may not be ideal in terms of register reuse of | ||||||
|     // ReqRegs.  The formula should use all required registers before |     // ReqRegs.  The formula should use all required registers before | ||||||
|     // introducing new ones. |     // introducing new ones. | ||||||
|     int NumReqRegsToFind = std::min(F.getNumRegs(), ReqRegs.size()); |     int NumReqRegsToFind = std::min(F.getNumRegs(), ReqRegs.size()); | ||||||
|     for (SmallSetVector<const SCEV *, 4>::const_iterator J = ReqRegs.begin(), |     for (const SCEV *Reg : ReqRegs) { | ||||||
|          JE = ReqRegs.end(); J != JE; ++J) { |  | ||||||
|       const SCEV *Reg = *J; |  | ||||||
|       if ((F.ScaledReg && F.ScaledReg == Reg) || |       if ((F.ScaledReg && F.ScaledReg == Reg) || | ||||||
|           std::find(F.BaseRegs.begin(), F.BaseRegs.end(), Reg) != |           std::find(F.BaseRegs.begin(), F.BaseRegs.end(), Reg) != | ||||||
|           F.BaseRegs.end()) { |           F.BaseRegs.end()) { | ||||||
| @@ -4420,9 +4402,7 @@ LSRInstance::HoistInsertPosition(BasicBlock::iterator IP, | |||||||
|     bool AllDominate = true; |     bool AllDominate = true; | ||||||
|     Instruction *BetterPos = nullptr; |     Instruction *BetterPos = nullptr; | ||||||
|     Instruction *Tentative = IDom->getTerminator(); |     Instruction *Tentative = IDom->getTerminator(); | ||||||
|     for (SmallVectorImpl<Instruction *>::const_iterator I = Inputs.begin(), |     for (Instruction *Inst : Inputs) { | ||||||
|          E = Inputs.end(); I != E; ++I) { |  | ||||||
|       Instruction *Inst = *I; |  | ||||||
|       if (Inst == Tentative || !DT.dominates(Inst, Tentative)) { |       if (Inst == Tentative || !DT.dominates(Inst, Tentative)) { | ||||||
|         AllDominate = false; |         AllDominate = false; | ||||||
|         break; |         break; | ||||||
| @@ -4469,9 +4449,7 @@ LSRInstance::AdjustInsertPositionForExpand(BasicBlock::iterator LowestIP, | |||||||
|   } |   } | ||||||
|   // The expansion must also be dominated by the increment positions of any |   // The expansion must also be dominated by the increment positions of any | ||||||
|   // loops it for which it is using post-inc mode. |   // loops it for which it is using post-inc mode. | ||||||
|   for (PostIncLoopSet::const_iterator I = LF.PostIncLoops.begin(), |   for (const Loop *PIL : LF.PostIncLoops) { | ||||||
|        E = LF.PostIncLoops.end(); I != E; ++I) { |  | ||||||
|     const Loop *PIL = *I; |  | ||||||
|     if (PIL == L) continue; |     if (PIL == L) continue; | ||||||
|  |  | ||||||
|     // Be dominated by the loop exit. |     // Be dominated by the loop exit. | ||||||
| @@ -4546,9 +4524,7 @@ Value *LSRInstance::Expand(const LSRFixup &LF, | |||||||
|   SmallVector<const SCEV *, 8> Ops; |   SmallVector<const SCEV *, 8> Ops; | ||||||
|  |  | ||||||
|   // Expand the BaseRegs portion. |   // Expand the BaseRegs portion. | ||||||
|   for (SmallVectorImpl<const SCEV *>::const_iterator I = F.BaseRegs.begin(), |   for (const SCEV *Reg : F.BaseRegs) { | ||||||
|        E = F.BaseRegs.end(); I != E; ++I) { |  | ||||||
|     const SCEV *Reg = *I; |  | ||||||
|     assert(!Reg->isZero() && "Zero allocated in a base register!"); |     assert(!Reg->isZero() && "Zero allocated in a base register!"); | ||||||
|  |  | ||||||
|     // If we're expanding for a post-inc user, make the post-inc adjustment. |     // If we're expanding for a post-inc user, make the post-inc adjustment. | ||||||
| @@ -4829,25 +4805,20 @@ LSRInstance::ImplementSolution(const SmallVectorImpl<const Formula *> &Solution, | |||||||
|   Rewriter.setIVIncInsertPos(L, IVIncInsertPos); |   Rewriter.setIVIncInsertPos(L, IVIncInsertPos); | ||||||
|  |  | ||||||
|   // Mark phi nodes that terminate chains so the expander tries to reuse them. |   // Mark phi nodes that terminate chains so the expander tries to reuse them. | ||||||
|   for (SmallVectorImpl<IVChain>::const_iterator ChainI = IVChainVec.begin(), |   for (const IVChain &Chain : IVChainVec) { | ||||||
|          ChainE = IVChainVec.end(); ChainI != ChainE; ++ChainI) { |     if (PHINode *PN = dyn_cast<PHINode>(Chain.tailUserInst())) | ||||||
|     if (PHINode *PN = dyn_cast<PHINode>(ChainI->tailUserInst())) |  | ||||||
|       Rewriter.setChainedPhi(PN); |       Rewriter.setChainedPhi(PN); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // Expand the new value definitions and update the users. |   // Expand the new value definitions and update the users. | ||||||
|   for (SmallVectorImpl<LSRFixup>::const_iterator I = Fixups.begin(), |   for (const LSRFixup &Fixup : Fixups) { | ||||||
|        E = Fixups.end(); I != E; ++I) { |  | ||||||
|     const LSRFixup &Fixup = *I; |  | ||||||
|  |  | ||||||
|     Rewrite(Fixup, *Solution[Fixup.LUIdx], Rewriter, DeadInsts, P); |     Rewrite(Fixup, *Solution[Fixup.LUIdx], Rewriter, DeadInsts, P); | ||||||
|  |  | ||||||
|     Changed = true; |     Changed = true; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   for (SmallVectorImpl<IVChain>::const_iterator ChainI = IVChainVec.begin(), |   for (const IVChain &Chain : IVChainVec) { | ||||||
|          ChainE = IVChainVec.end(); ChainI != ChainE; ++ChainI) { |     GenerateIVChain(Chain, Rewriter, DeadInsts); | ||||||
|     GenerateIVChain(*ChainI, Rewriter, DeadInsts); |  | ||||||
|     Changed = true; |     Changed = true; | ||||||
|   } |   } | ||||||
|   // Clean up after ourselves. This must be done before deleting any |   // Clean up after ourselves. This must be done before deleting any | ||||||
| @@ -4874,10 +4845,9 @@ LSRInstance::LSRInstance(Loop *L, Pass *P) | |||||||
|   // If there's too much analysis to be done, bail early. We won't be able to |   // If there's too much analysis to be done, bail early. We won't be able to | ||||||
|   // model the problem anyway. |   // model the problem anyway. | ||||||
|   unsigned NumUsers = 0; |   unsigned NumUsers = 0; | ||||||
|   for (IVUsers::const_iterator UI = IU.begin(), E = IU.end(); UI != E; ++UI) { |   for (const IVStrideUse &U : IU) { | ||||||
|     if (++NumUsers > MaxIVUsers) { |     if (++NumUsers > MaxIVUsers) { | ||||||
|       DEBUG(dbgs() << "LSR skipping loop, too many IV Users in " << *L |       DEBUG(dbgs() << "LSR skipping loop, too many IV Users in " << U << "\n"); | ||||||
|             << "\n"); |  | ||||||
|       return; |       return; | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| @@ -4946,14 +4916,10 @@ LSRInstance::LSRInstance(Loop *L, Pass *P) | |||||||
|  |  | ||||||
| #ifndef NDEBUG | #ifndef NDEBUG | ||||||
|   // Formulae should be legal. |   // Formulae should be legal. | ||||||
|   for (SmallVectorImpl<LSRUse>::const_iterator I = Uses.begin(), E = Uses.end(); |   for (const LSRUse &LU : Uses) { | ||||||
|        I != E; ++I) { |     for (const Formula &F : LU.Formulae) | ||||||
|     const LSRUse &LU = *I; |  | ||||||
|     for (SmallVectorImpl<Formula>::const_iterator J = LU.Formulae.begin(), |  | ||||||
|                                                   JE = LU.Formulae.end(); |  | ||||||
|          J != JE; ++J) |  | ||||||
|       assert(isLegalUse(TTI, LU.MinOffset, LU.MaxOffset, LU.Kind, LU.AccessTy, |       assert(isLegalUse(TTI, LU.MinOffset, LU.MaxOffset, LU.Kind, LU.AccessTy, | ||||||
|                         *J) && "Illegal formula generated!"); |                         F) && "Illegal formula generated!"); | ||||||
|   }; |   }; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| @@ -4967,44 +4933,38 @@ void LSRInstance::print_factors_and_types(raw_ostream &OS) const { | |||||||
|   OS << "LSR has identified the following interesting factors and types: "; |   OS << "LSR has identified the following interesting factors and types: "; | ||||||
|   bool First = true; |   bool First = true; | ||||||
|  |  | ||||||
|   for (SmallSetVector<int64_t, 8>::const_iterator |   for (int64_t I : Factors) { | ||||||
|        I = Factors.begin(), E = Factors.end(); I != E; ++I) { |  | ||||||
|     if (!First) OS << ", "; |     if (!First) OS << ", "; | ||||||
|     First = false; |     First = false; | ||||||
|     OS << '*' << *I; |     OS << '*' << I; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   for (SmallSetVector<Type *, 4>::const_iterator |   for (Type *I : Types) { | ||||||
|        I = Types.begin(), E = Types.end(); I != E; ++I) { |  | ||||||
|     if (!First) OS << ", "; |     if (!First) OS << ", "; | ||||||
|     First = false; |     First = false; | ||||||
|     OS << '(' << **I << ')'; |     OS << '(' << *I << ')'; | ||||||
|   } |   } | ||||||
|   OS << '\n'; |   OS << '\n'; | ||||||
| } | } | ||||||
|  |  | ||||||
| void LSRInstance::print_fixups(raw_ostream &OS) const { | void LSRInstance::print_fixups(raw_ostream &OS) const { | ||||||
|   OS << "LSR is examining the following fixup sites:\n"; |   OS << "LSR is examining the following fixup sites:\n"; | ||||||
|   for (SmallVectorImpl<LSRFixup>::const_iterator I = Fixups.begin(), |   for (const LSRFixup &LF : Fixups) { | ||||||
|        E = Fixups.end(); I != E; ++I) { |  | ||||||
|     dbgs() << "  "; |     dbgs() << "  "; | ||||||
|     I->print(OS); |     LF.print(OS); | ||||||
|     OS << '\n'; |     OS << '\n'; | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
| void LSRInstance::print_uses(raw_ostream &OS) const { | void LSRInstance::print_uses(raw_ostream &OS) const { | ||||||
|   OS << "LSR is examining the following uses:\n"; |   OS << "LSR is examining the following uses:\n"; | ||||||
|   for (SmallVectorImpl<LSRUse>::const_iterator I = Uses.begin(), |   for (const LSRUse &LU : Uses) { | ||||||
|        E = Uses.end(); I != E; ++I) { |  | ||||||
|     const LSRUse &LU = *I; |  | ||||||
|     dbgs() << "  "; |     dbgs() << "  "; | ||||||
|     LU.print(OS); |     LU.print(OS); | ||||||
|     OS << '\n'; |     OS << '\n'; | ||||||
|     for (SmallVectorImpl<Formula>::const_iterator J = LU.Formulae.begin(), |     for (const Formula &F : LU.Formulae) { | ||||||
|          JE = LU.Formulae.end(); J != JE; ++J) { |  | ||||||
|       OS << "    "; |       OS << "    "; | ||||||
|       J->print(OS); |       F.print(OS); | ||||||
|       OS << '\n'; |       OS << '\n'; | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user