Home | History | Annotate | Download | only in CodeGen

Lines Matching defs:PhysReg

72       unsigned PhysReg;         // Currently held here.
77 : LastUse(nullptr), VirtReg(v), PhysReg(0), LastOpNum(0), Dirty(false){}
122 // Mark a physreg as used in this instruction.
123 void markRegUsedInInstr(unsigned PhysReg) {
124 for (MCRegUnitIterator Units(PhysReg, TRI); Units.isValid(); ++Units)
128 // Check if a physreg or any of its aliases are used in this instruction.
129 bool isRegUsedInInstr(unsigned PhysReg) const {
130 for (MCRegUnitIterator Units(PhysReg, TRI); Units.isValid(); ++Units)
181 void definePhysReg(MachineInstr &MI, unsigned PhysReg, RegState NewState);
182 unsigned calcSpillCost(unsigned PhysReg) const;
183 void assignVirtToPhysReg(LiveReg&, unsigned PhysReg);
190 LiveRegMap::iterator assignVirtToPhysReg(unsigned VReg, unsigned PhysReg);
198 bool setPhysReg(MachineInstr *MI, unsigned OpNum, unsigned PhysReg);
241 if (MO.getReg() == LR.PhysReg)
244 LR.LastUse->addRegisterKilled(LR.PhysReg, TRI, true);
251 assert(PhysRegState[LRI->PhysReg] == LRI->VirtReg &&
253 PhysRegState[LRI->PhysReg] = regFree;
282 assert(PhysRegState[LR.PhysReg] == LRI->VirtReg && "Broken RegState mapping");
285 // If this physreg is used by the instruction, we want to kill it on the
290 << " in " << PrintReg(LR.PhysReg, TRI));
294 TII->storeRegToStackSlot(*MBB, MI, LR.PhysReg, SpillKill, FI, RC, TRI);
346 /// Kill the physreg, marking it free.
349 unsigned PhysReg = MO.getReg();
350 assert(TargetRegisterInfo::isPhysicalRegister(PhysReg) &&
357 markRegUsedInInstr(PhysReg);
358 switch (PhysRegState[PhysReg]) {
362 PhysRegState[PhysReg] = regFree;
368 // The physreg was allocated to a virtual register. That means the value we
374 for (MCRegAliasIterator AI(PhysReg, TRI, false); AI.isValid(); ++AI) {
380 // Either PhysReg is a subregister of Alias and we mark the
381 // whole register as free, or PhysReg is the superregister of
383 // PhysReg.
384 // In the latter case, since PhysReg was disabled, this means that
389 assert((TRI->isSuperRegister(PhysReg, Alias) ||
390 TRI->isSuperRegister(Alias, PhysReg)) &&
394 if (TRI->isSuperRegister(PhysReg, Alias)) {
409 PhysRegState[PhysReg] = regFree;
413 /// definePhysReg - Mark PhysReg as reserved or free after spilling any
414 /// virtregs. This is very similar to defineVirtReg except the physreg is
416 void RAFast::definePhysReg(MachineInstr &MI, unsigned PhysReg,
418 markRegUsedInInstr(PhysReg);
419 switch (unsigned VirtReg = PhysRegState[PhysReg]) {
427 PhysRegState[PhysReg] = NewState;
432 PhysRegState[PhysReg] = NewState;
433 for (MCRegAliasIterator AI(PhysReg, TRI, false); AI.isValid(); ++AI) {
444 if (TRI->isSuperRegister(PhysReg, Alias))
452 // calcSpillCost - Return the cost of spilling clearing out PhysReg and
454 // Returns 0 when PhysReg is free or disabled with all aliases disabled - it
456 // Returns spillImpossible when PhysReg or an alias can't be spilled.
457 unsigned RAFast::calcSpillCost(unsigned PhysReg) const {
458 if (isRegUsedInInstr(PhysReg)) {
459 DEBUG(dbgs() << PrintReg(PhysReg, TRI) << " is already used in instr.\n");
462 switch (unsigned VirtReg = PhysRegState[PhysReg]) {
469 << PrintReg(PhysReg, TRI) << " is reserved already.\n");
479 DEBUG(dbgs() << PrintReg(PhysReg, TRI) << " is disabled.\n");
481 for (MCRegAliasIterator AI(PhysReg, TRI, false); AI.isValid(); ++AI) {
504 /// that PhysReg is the proper container for VirtReg now. The physical
507 void RAFast::assignVirtToPhysReg(LiveReg &LR, unsigned PhysReg) {
509 << PrintReg(PhysReg, TRI) << "\n");
510 PhysRegState[PhysReg] = LR.VirtReg;
511 assert(!LR.PhysReg && "Already assigned a physreg");
512 LR.PhysReg = PhysReg;
516 RAFast::assignVirtToPhysReg(unsigned VirtReg, unsigned PhysReg) {
519 assignVirtToPhysReg(*LRI, PhysReg);
556 unsigned PhysReg = *I;
557 if (PhysRegState[PhysReg] == regFree && !isRegUsedInInstr(PhysReg)) {
558 assignVirtToPhysReg(*LRI, PhysReg);
623 assert(LRI->PhysReg && "Register not assigned");
627 markRegUsedInInstr(LRI->PhysReg);
631 /// reloadVirtReg - Make sure VirtReg is available in a physreg and return it.
647 << PrintReg(LRI->PhysReg, TRI) << "\n");
648 TII->loadRegFromStackSlot(*MBB, MI, LRI->PhysReg, FrameIndex, RC, TRI);
675 assert(LRI->PhysReg && "Register not assigned");
678 markRegUsedInInstr(LRI->PhysReg);
682 // setPhysReg - Change operand OpNum in MI the refer the PhysReg, considering
685 bool RAFast::setPhysReg(MachineInstr *MI, unsigned OpNum, unsigned PhysReg) {
689 MO.setReg(PhysReg);
694 MO.setReg(PhysReg ? TRI->getSubReg(PhysReg, MO.getSubReg()) : 0);
700 MI->addRegisterKilled(PhysReg, TRI, true);
707 MI->addRegisterDefined(PhysReg, TRI);
713 // there are additional physreg defines.
731 // If any physreg defines collide with preallocated through registers,
759 unsigned PhysReg = LRI->PhysReg;
760 setPhysReg(MI, i, PhysReg);
768 PartialDefs.push_back(LRI->PhysReg);
782 unsigned PhysReg = LRI->PhysReg;
783 if (setPhysReg(MI, i, PhysReg))
814 if (MRI->isAllocatable(LI.PhysReg))
815 definePhysReg(*MII, LI.PhysReg, regReserved);
841 assert(I->PhysReg == Reg && "Bad inverse map");
852 assert(TargetRegisterInfo::isPhysicalRegister(i->PhysReg) &&
854 assert(PhysRegState[i->PhysReg] == i->VirtReg && "Bad inverse map");
870 setPhysReg(MI, i, LRI->PhysReg);
874 // We can't allocate a physreg for a DebugValue, sorry!
923 // Mark physreg uses and early clobbers as used.
992 unsigned PhysReg = LRI->PhysReg;
993 CopySrc = (CopySrc == Reg || CopySrc == PhysReg) ? PhysReg : 0;
994 if (setPhysReg(MI, i, PhysReg))
1008 // Look for physreg defs and tied uses.
1045 unsigned PhysReg = LRI->PhysReg;
1046 if (setPhysReg(MI, i, PhysReg)) {
1050 CopyDst = (CopyDst == Reg || CopyDst == PhysReg) ? PhysReg : 0;