Lines Matching refs:Iter

386 void LinearScan::addSpillFill(IterationState &Iter) {  in addSpillFill()  argument
401 assert(!Iter.Cur->getLiveRange().isEmpty()); in addSpillFill()
402 InstNumberT Start = Iter.Cur->getLiveRange().getStart(); in addSpillFill()
403 InstNumberT End = Iter.Cur->getLiveRange().getEnd(); in addSpillFill()
404 CfgNode *Node = Func->getVMetadata()->getLocalUseNode(Iter.Cur); in addSpillFill()
425 Iter.RegMask[RegAlias] = false; in addSpillFill()
434 const RegNumT RegNum = *RegNumBVIter(Iter.RegMask).begin(); in addSpillFill()
435 Iter.Cur->setRegNumTmp(RegNum); in addSpillFill()
436 Variable *Preg = Target->getPhysicalRegister(RegNum, Iter.Cur->getType()); in addSpillFill()
439 Variable *SpillLoc = Func->makeVariable(Iter.Cur->getType()); in addSpillFill()
510 void LinearScan::findRegisterPreference(IterationState &Iter) { in findRegisterPreference() argument
511 Iter.Prefer = nullptr; in findRegisterPreference()
512 Iter.PreferReg = RegNumT(); in findRegisterPreference()
513 Iter.AllowOverlap = false; in findRegisterPreference()
519 const Inst *DefInst = VMetadata->getFirstDefinitionSingleBlock(Iter.Cur); in findRegisterPreference()
523 assert(DefInst->getDest() == Iter.Cur); in findRegisterPreference()
525 DefInst->isVarAssign() && !VMetadata->isMultiDef(Iter.Cur); in findRegisterPreference()
535 const int SrcReg = (Iter.RegMask & Aliases).find_first(); in findRegisterPreference()
539 if (FindOverlap && IsSingleDefAssign && !Iter.Free[SrcReg]) { in findRegisterPreference()
542 Iter.AllowOverlap = !overlapsDefs(Func, Iter.Cur, SrcVar); in findRegisterPreference()
544 if (Iter.AllowOverlap || Iter.Free[SrcReg]) { in findRegisterPreference()
545 Iter.Prefer = SrcVar; in findRegisterPreference()
546 Iter.PreferReg = RegNumT::fromInt(SrcReg); in findRegisterPreference()
556 if (BuildDefs::dump() && Verbose && Iter.Prefer) { in findRegisterPreference()
559 Iter.Prefer->dump(Func); in findRegisterPreference()
560 Str << " R=" << Iter.PreferReg << " LIVE=" << Iter.Prefer->getLiveRange() in findRegisterPreference()
561 << " Overlap=" << Iter.AllowOverlap << "\n"; in findRegisterPreference()
567 void LinearScan::filterFreeWithInactiveRanges(IterationState &Iter) { in filterFreeWithInactiveRanges() argument
569 if (!Item->rangeOverlaps(Iter.Cur)) in filterFreeWithInactiveRanges()
576 Iter.Free[RegAlias] = false; in filterFreeWithInactiveRanges()
577 Iter.FreeUnfiltered[RegAlias] = false; in filterFreeWithInactiveRanges()
580 if (Iter.AllowOverlap && Item != Iter.Prefer && in filterFreeWithInactiveRanges()
581 RegAlias == Iter.PreferReg && overlapsDefs(Func, Iter.Cur, Item)) { in filterFreeWithInactiveRanges()
582 Iter.AllowOverlap = false; in filterFreeWithInactiveRanges()
594 void LinearScan::filterFreeWithPrecoloredRanges(IterationState &Iter) { in filterFreeWithPrecoloredRanges() argument
599 if (Iter.Cur->rangeEndsBefore(Item)) in filterFreeWithPrecoloredRanges()
601 if (!Item->rangeOverlaps(Iter.Cur)) in filterFreeWithPrecoloredRanges()
606 Iter.Weights[RegAlias].setWeight(RegWeight::Inf); in filterFreeWithPrecoloredRanges()
607 Iter.Free[RegAlias] = false; in filterFreeWithPrecoloredRanges()
608 Iter.FreeUnfiltered[RegAlias] = false; in filterFreeWithPrecoloredRanges()
609 Iter.PrecoloredUnhandledMask[RegAlias] = true; in filterFreeWithPrecoloredRanges()
612 if (Iter.AllowOverlap && RegAlias == Iter.PreferReg) { in filterFreeWithPrecoloredRanges()
613 Iter.AllowOverlap = false; in filterFreeWithPrecoloredRanges()
636 void LinearScan::allocatePreferredRegister(IterationState &Iter) { in allocatePreferredRegister() argument
637 Iter.Cur->setRegNumTmp(Iter.PreferReg); in allocatePreferredRegister()
638 dumpLiveRangeTrace("Preferring ", Iter.Cur); in allocatePreferredRegister()
639 const auto &Aliases = *RegAliases[Iter.PreferReg]; in allocatePreferredRegister()
644 Active.push_back(Iter.Cur); in allocatePreferredRegister()
647 void LinearScan::allocateFreeRegister(IterationState &Iter, bool Filtered) { in allocateFreeRegister() argument
649 *RegNumBVIter(Filtered ? Iter.Free : Iter.FreeUnfiltered).begin(); in allocateFreeRegister()
650 Iter.Cur->setRegNumTmp(RegNum); in allocateFreeRegister()
652 dumpLiveRangeTrace("Allocating Y ", Iter.Cur); in allocateFreeRegister()
654 dumpLiveRangeTrace("Allocating X ", Iter.Cur); in allocateFreeRegister()
660 Active.push_back(Iter.Cur); in allocateFreeRegister()
663 void LinearScan::handleNoFreeRegisters(IterationState &Iter) { in handleNoFreeRegisters() argument
666 assert(Item->rangeOverlaps(Iter.Cur)); in handleNoFreeRegisters()
674 Iter.Weights[RegAlias].addWeight(W); in handleNoFreeRegisters()
679 if (!Item->rangeOverlaps(Iter.Cur)) in handleNoFreeRegisters()
685 Iter.Weights[RegAlias].addWeight(W); in handleNoFreeRegisters()
690 int32_t MinWeightIndex = findMinWeightIndex(Iter.RegMask, Iter.Weights); in handleNoFreeRegisters()
693 Iter.Cur->getWeight(Func) <= Iter.Weights[MinWeightIndex]) { in handleNoFreeRegisters()
694 if (!Iter.Cur->mustHaveReg()) { in handleNoFreeRegisters()
697 Handled.push_back(Iter.Cur); in handleNoFreeRegisters()
703 addSpillFill(Iter); in handleNoFreeRegisters()
704 Handled.push_back(Iter.Cur); in handleNoFreeRegisters()
710 if (Iter.FreeUnfiltered.any()) { in handleNoFreeRegisters()
713 allocateFreeRegister(Iter, NotFiltered); in handleNoFreeRegisters()
720 MinWeightIndex = findMinWeightIndex(Iter.RegMaskUnfiltered, Iter.Weights); in handleNoFreeRegisters()
722 if (Iter.Cur->getWeight(Func) <= Iter.Weights[MinWeightIndex]) { in handleNoFreeRegisters()
723 dumpLiveRangeTrace("Failing ", Iter.Cur); in handleNoFreeRegisters()
727 Iter.Cur->getName()); in handleNoFreeRegisters()
728 Handled.push_back(Iter.Cur); in handleNoFreeRegisters()
765 if (Aliases[Item->getRegNumTmp()] && Item->rangeOverlaps(Iter.Cur)) { in handleNoFreeRegisters()
773 Iter.Cur->setRegNumTmp(RegNumT::fromInt(MinWeightIndex)); in handleNoFreeRegisters()
778 Active.push_back(Iter.Cur); in handleNoFreeRegisters()
779 dumpLiveRangeTrace("Allocating Z ", Iter.Cur); in handleNoFreeRegisters()
869 IterationState Iter; in scan() local
870 Iter.Weights.reserve(NumRegisters); in scan()
871 Iter.PrecoloredUnhandledMask.reserve(NumRegisters); in scan()
874 Iter.Cur = Unhandled.back(); in scan()
876 dumpLiveRangeTrace("\nConsidering ", Iter.Cur); in scan()
878 assert(Target->getAllRegistersForVariable(Iter.Cur).any()); in scan()
880 assert(Target->getRegistersForVariable(Iter.Cur).any()); in scan()
881 Iter.RegMask = RegMaskFull & Target->getRegistersForVariable(Iter.Cur); in scan()
882 Iter.RegMaskUnfiltered = in scan()
883 RegMaskFull & Target->getAllRegistersForVariable(Iter.Cur); in scan()
884 KillsRange.trim(Iter.Cur->getLiveRange().getStart()); in scan()
890 if (Iter.Cur->hasReg()) { in scan()
891 allocatePrecoloredRegister(Iter.Cur); in scan()
895 handleActiveRangeExpiredOrInactive(Iter.Cur); in scan()
896 handleInactiveRangeExpiredOrReactivated(Iter.Cur); in scan()
899 Iter.Free = Iter.RegMask; in scan()
900 Iter.FreeUnfiltered = Iter.RegMaskUnfiltered; in scan()
901 for (SizeT i = 0; i < Iter.RegMask.size(); ++i) { in scan()
903 Iter.Free[i] = false; in scan()
904 Iter.FreeUnfiltered[i] = false; in scan()
908 findRegisterPreference(Iter); in scan()
909 filterFreeWithInactiveRanges(Iter); in scan()
913 if (Iter.AllowOverlap) { in scan()
914 const auto &Aliases = *RegAliases[Iter.PreferReg]; in scan()
917 if (Item != Iter.Prefer && Aliases[RegNum] && in scan()
918 overlapsDefs(Func, Iter.Cur, Item)) { in scan()
919 Iter.AllowOverlap = false; in scan()
925 Iter.Weights.resize(Iter.RegMask.size()); in scan()
926 std::fill(Iter.Weights.begin(), Iter.Weights.end(), RegWeight()); in scan()
928 Iter.PrecoloredUnhandledMask.resize(Iter.RegMask.size()); in scan()
929 Iter.PrecoloredUnhandledMask.reset(); in scan()
931 filterFreeWithPrecoloredRanges(Iter); in scan()
936 if (Iter.Cur->getLiveRange().overlaps(KillsRange, UseTrimmed)) { in scan()
937 Iter.Free.reset(KillsMask); in scan()
938 Iter.FreeUnfiltered.reset(KillsMask); in scan()
940 Iter.Weights[i].setWeight(RegWeight::Inf); in scan()
941 if (Iter.PreferReg == i) in scan()
942 Iter.AllowOverlap = false; in scan()
949 for (RegNumT i : RegNumBVIter(Iter.RegMaskUnfiltered)) { in scan()
950 Str << Target->getRegName(i, Iter.Cur->getType()) << "(U=" << RegUses[i] in scan()
951 << ",F=" << Iter.Free[i] << ",P=" << Iter.PrecoloredUnhandledMask[i] in scan()
957 if (Iter.Prefer && (Iter.AllowOverlap || Iter.Free[Iter.PreferReg])) { in scan()
960 allocatePreferredRegister(Iter); in scan()
961 } else if (Iter.Free.any()) { in scan()
964 allocateFreeRegister(Iter, Filtered); in scan()
968 handleNoFreeRegisters(Iter); in scan()