Lines Matching +full:ref2 +full:-

1 //===- HexagonGenInsert.cpp -----------------------------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
51 VRegIndexCutoff("insert-vreg-cutoff", cl::init(~0U), cl::Hidden,
53 // The distance cutoff is selected based on the precheckin-perf results:
56 VRegDistCutoff("insert-dist-cutoff", cl::init(30U), cl::Hidden,
62 MaxORLSize("insert-max-orl", cl::init(4096), cl::Hidden,
64 static cl::opt<unsigned> MaxIFMSize("insert-max-ifmap", cl::init(1024),
68 static cl::opt<bool> OptTiming("insert-timing", cl::Hidden,
71 OptTimingDetail("insert-timing-detail", cl::Hidden,
75 static cl::opt<bool> OptSelectAll0("insert-all0", cl::init(false), cl::Hidden);
76 static cl::opt<bool> OptSelectHas0("insert-has0", cl::init(false), cl::Hidden);
79 static cl::opt<bool> OptConst("insert-const", cl::init(false), cl::Hidden);
156 // A.BitVector::test(B) <=> A-B != {} in includes()
210 // by a potentially expensive comparison function, or obtained by a proce-
218 return F->second; in operator []()
231 // - 0 < 1 < ref
232 // - ref1 < ref2, if ord(ref1.Reg) < ord(ref2.Reg),
233 // or ord(ref1.Reg) == ord(ref2.Reg), and ref1.Pos < ref2.Pos.
329 // - the ordering of the register numbers, and in operator ()()
330 // - the ordering of register cells. in operator ()()
332 // - cell(R1) < cell(R2), or in operator ()()
333 // - cell(R1) == cell(R2), and index(R1) < index(R2). in operator ()()
363 // - return false, if at the same time Bit2 exceeds VR2, or in operator ()()
364 // - return true, otherwise. in operator ()()
410 unsigned idx(iterator It) const { return It-begin(); } in idx()
563 using IFMapType = DenseMap<unsigned, IFListType>; // vreg -> IFListType
598 if (!CMS->BT.reached(&B)) in buildOrderingMF()
640 const BitTracker::RegisterCell &RC = CMS->lookup(VR); in isConstant()
652 const BitTracker::RegisterCell &RC = CMS->lookup(VR); in isSmallConstant()
666 // For 32-bit registers, consider: Rd = #s16. in isSmallConstant()
670 // For 64-bit registers, it's Rdd = #s8 or Rdd = combine(#s8,#s8) in isSmallConstant()
676 const TargetRegisterClass *DstRC = MRI->getRegClass(DstR); in isValidInsertForm()
677 const TargetRegisterClass *SrcRC = MRI->getRegClass(SrcR); in isValidInsertForm()
678 const TargetRegisterClass *InsRC = MRI->getRegClass(InsR); in isValidInsertForm()
679 // Only integet (32-/64-bit) register classes. in isValidInsertForm()
687 // A 64-bit register can only be generated from other 64-bit registers. in isValidInsertForm()
690 // Otherwise, the L and S cannot span 32-bit word boundary. in isValidInsertForm()
697 const BitTracker::RegisterCell &RC = CMS->lookup(VR); in findSelfReference()
707 BitTracker::RegisterCell RC = CMS->lookup(VR); in findNonSelfReference()
718 for (const MachineOperand &MO : MI->operands()) { in getInstrDefs()
730 for (const MachineOperand &MO : MI->operands()) { in getInstrUses()
747 unsigned FromN = FromB->getNumber(), ToN = ToB->getNumber(); in distance()
751 return F->second; in distance()
756 for (const MachineBasicBlock *PB : ToB->predecessors()) { in distance()
760 if (PB == FromB || RPO.lookup(PB->getNumber()) >= ToRPO) in distance()
762 unsigned D = PB->size() + distance(FromB, PB, RPO, M); in distance()
775 const MachineBasicBlock *FB = FromI->getParent(), *TB = ToI->getParent(); in distance()
778 unsigned D1 = std::distance(TB->begin(), ToI); in distance()
780 unsigned D3 = std::distance(FromI, FB->end()); in distance()
796 const BitTracker::RegisterCell &RC = CMS->lookup(VR); in findRecordInsertForms()
813 // the corresponding register cells. This means that the range of regis- in findRecordInsertForms()
819 for (L = 0; L < W-S; ++L) { in findRecordInsertForms()
839 // Record the final register range. If this range is non-empty, then in findRecordInsertForms()
840 // L=W-S. in findRecordInsertForms()
841 assert(B == E || L == W-S); in findRecordInsertForms()
865 int FDi = -1, LDi = -1; // First/last different bit. in findRecordInsertForms()
866 const BitTracker::RegisterCell &AC = CMS->lookup(SrcR); in findRecordInsertForms()
871 if (FDi == -1) in findRecordInsertForms()
875 if (FDi == -1) in findRecordInsertForms()
880 uint16_t MinL = LD-FD+1; in findRecordInsertForms()
885 RSListType &LL = F->second; in findRecordInsertForms()
890 // given the extra length EL=L-MinL, the prefix must start between in findRecordInsertForms()
891 // max(0,FD-EL) and FD. in findRecordInsertForms()
894 uint16_t EL = L-MinL; in findRecordInsertForms()
895 uint16_t LowS = (EL < FD) ? FD-EL : 0; in findRecordInsertForms()
923 if (!CMS->BT.reached(B)) in collectInBlock()
941 // Do not collect registers that are known to be compile-time cons- in collectInBlock()
966 for (auto *DTN : children<MachineDomTreeNode*>(MDT->getNode(B))) { in collectInBlock()
967 MachineBasicBlock *SB = DTN->getBlock(); in collectInBlock()
987 // Breadth-first search. in findRemovableRegisters()
988 unsigned OtherS = 1-S; in findRemovableRegisters()
1003 // in case of zero-extending loads, or refs to R.) in findRemovableRegisters()
1007 const MachineInstr *DefI = MRI->getVRegDef(R); in findRemovableRegisters()
1012 if (DefI->isPHI()) in findRemovableRegisters()
1018 // The register VR is added to the list as a side-effect of the algorithm, in findRemovableRegisters()
1021 // IF, and obviously VR (or its replacement) will not become dead by apply- in findRemovableRegisters()
1040 if (I->second.empty()) in pruneEmptyLists()
1050 IFListType &LL = F->second; in pruneCoveredSets()
1052 // First, examine the IF candidates for register VR whose removable-regis- in pruneCoveredSets()
1053 // ter sets are empty. This means that a given candidate will not help eli- in pruneCoveredSets()
1054 // minate any registers, but since "insert" is not a constant-extendable in pruneCoveredSets()
1055 // instruction, using such a candidate may reduce code size if the defini- in pruneCoveredSets()
1056 // tion of VR is constant-extended. in pruneCoveredSets()
1057 // If there exists a candidate with a non-empty set, the ones with empty in pruneCoveredSets()
1059 MachineInstr *DefVR = MRI->getVRegDef(VR); in pruneCoveredSets()
1060 bool DefEx = HII->isConstExtended(*DefVR); in pruneCoveredSets()
1069 // The definition of VR is not constant-extended, or there is a candidate in pruneCoveredSets()
1070 // with a non-empty set. Remove all candidates with empty sets. in pruneCoveredSets()
1071 auto IsEmpty = [] (const IFRecordWithRegSet &IR) -> bool { in pruneCoveredSets()
1076 // The definition of VR is constant-extended, and all candidates have in pruneCoveredSets()
1077 // empty removable-register sets. Pick the maximum candidate, and remove in pruneCoveredSets()
1079 // is only so that the candidate that will remain on the list is selec- in pruneCoveredSets()
1136 IFListType &LL = F->second; in pruneUsesTooFar()
1138 const MachineInstr *DefV = MRI->getVRegDef(VR); in pruneUsesTooFar()
1140 for (unsigned i = LL.size(); i > 0; --i) { in pruneUsesTooFar()
1141 unsigned SR = LL[i-1].first.SrcR, IR = LL[i-1].first.InsR; in pruneUsesTooFar()
1142 const MachineInstr *DefS = MRI->getVRegDef(SR); in pruneUsesTooFar()
1143 const MachineInstr *DefI = MRI->getVRegDef(IR); in pruneUsesTooFar()
1150 LL.erase(LL.begin()+(i-1)); in pruneUsesTooFar()
1157 IFListType &LL = F->second; in pruneRegCopies()
1159 auto IsCopy = [] (const IFRecordWithRegSet &IR) -> bool { in pruneRegCopies()
1180 RPO[I->getNumber()] = RPON++; in pruneCandidates()
1197 // First, compare the number of zeros in the associated potentially remova-
1200 // Second, compare "averages", i.e. use-count per size. The lower wins.
1253 unsigned UC = F->second; in stats()
1266 // For each potentially removable register R, record the number of regis- in selectCandidates()
1273 const IFListType &LL = I->second; in selectCandidates()
1289 use_iterator E = MRI->use_nodbg_end(); in selectCandidates()
1290 for (use_iterator I = MRI->use_nodbg_begin(R); I != E; ++I) in selectCandidates()
1291 UIs.insert(I->getParent()); in selectCandidates()
1296 UseC[R] = (C > D) ? C-D : 0; // doz in selectCandidates()
1310 IFListType &LL = I->second; in selectCandidates()
1314 // element found is adequate, we will put it back on the list, other- in selectCandidates()
1325 // are the use operands in the definition of I->first. Accept/reject a in selectCandidates()
1329 const MachineInstr *DefI = MRI->getVRegDef(I->first); in selectCandidates()
1362 const IFListType &LL = I->second; in selectCandidates()
1367 IFListType &LL = I->second; in selectCandidates()
1384 const TargetRegisterClass *RC = MRI->getRegClass(VR); in generateInserts()
1385 Register NewVR = MRI->createVirtualRegister(RC); in generateInserts()
1389 // We can generate the "insert" instructions using potentially stale re- in generateInserts()
1393 MachineInstr *MI = MRI->getVRegDef(I.first); in generateInserts()
1394 MachineBasicBlock &B = *MI->getParent(); in generateInserts()
1395 DebugLoc DL = MI->getDebugLoc(); in generateInserts()
1397 bool R32 = MRI->getRegClass(NewR) == &Hexagon::IntRegsRegClass; in generateInserts()
1398 const MCInstrDesc &D = R32 ? HII->get(Hexagon::S2_insert) in generateInserts()
1399 : HII->get(Hexagon::S2_insertp); in generateInserts()
1403 if (R32 && MRI->getRegClass(IF.InsR) == &Hexagon::DoubleRegsRegClass) { in generateInserts()
1407 Off -= 32; in generateInserts()
1413 if (MI->isPHI()) in generateInserts()
1422 MRI->clearKillFlags(IF.SrcR); in generateInserts()
1423 MRI->clearKillFlags(IF.InsR); in generateInserts()
1427 MachineInstr *DefI = MRI->getVRegDef(I.first); in generateInserts()
1428 MRI->replaceRegWith(I.first, RegMap[I.first]); in generateInserts()
1429 DefI->eraseFromParent(); in generateInserts()
1441 MachineBasicBlock *B = N->getBlock(); in removeDeadCode()
1447 unsigned Opc = MI->getOpcode(); in removeDeadCode()
1448 // Do not touch lifetime markers. This is why the target-independent DCE in removeDeadCode()
1454 if (MI->isInlineAsm() || !MI->isSafeToMove(nullptr, Store)) in removeDeadCode()
1459 for (const MachineOperand &MO : MI->operands()) { in removeDeadCode()
1463 if (!R.isVirtual() || !MRI->use_nodbg_empty(R)) { in removeDeadCode()
1472 B->erase(MI); in removeDeadCode()
1474 MRI->markUsesInDebugValueAsUndef(Reg); in removeDeadCode()
1507 Changed = removeDeadCode(MDT->getRootNode()); in runOnMachineFunction()
1523 dbgs() << printReg(VR, HRI) << " -> " << Pos << "\n"; in runOnMachineFunction()
1528 MachineBasicBlock *RootB = MDT->getRoot(); in runOnMachineFunction()
1581 unsigned Idx = Register::virtReg2Index(I->first); in runOnMachineFunction()
1604 //===----------------------------------------------------------------------===//
1606 //===----------------------------------------------------------------------===//