Home | History | Annotate | Download | only in CodeGen

Lines Matching defs:PhysReg

74       unsigned PhysReg;         // Currently held here.
79 : LastUse(nullptr), VirtReg(v), PhysReg(0), LastOpNum(0), Dirty(false){}
124 // Mark a physreg as used in this instruction.
125 void markRegUsedInInstr(unsigned PhysReg) {
126 for (MCRegUnitIterator Units(PhysReg, TRI); Units.isValid(); ++Units)
130 // Check if a physreg or any of its aliases are used in this instruction.
131 bool isRegUsedInInstr(unsigned PhysReg) const {
132 for (MCRegUnitIterator Units(PhysReg, TRI); Units.isValid(); ++Units)
178 void definePhysReg(MachineInstr *MI, unsigned PhysReg, RegState NewState);
179 unsigned calcSpillCost(unsigned PhysReg) const;
180 void assignVirtToPhysReg(LiveReg&, unsigned PhysReg);
187 LiveRegMap::iterator assignVirtToPhysReg(unsigned VReg, unsigned PhysReg);
195 bool setPhysReg(MachineInstr *MI, unsigned OpNum, unsigned PhysReg);
238 if (MO.getReg() == LR.PhysReg)
241 LR.LastUse->addRegisterKilled(LR.PhysReg, TRI, true);
248 assert(PhysRegState[LRI->PhysReg] == LRI->VirtReg &&
250 PhysRegState[LRI->PhysReg] = regFree;
279 assert(PhysRegState[LR.PhysReg] == LRI->VirtReg && "Broken RegState mapping");
282 // If this physreg is used by the instruction, we want to kill it on the
287 << " in " << PrintReg(LR.PhysReg, TRI));
291 TII->storeRegToStackSlot(*MBB, MI, LR.PhysReg, SpillKill, FI, RC, TRI);
343 /// Kill the physreg, marking it free.
346 unsigned PhysReg = MO.getReg();
347 assert(TargetRegisterInfo::isPhysicalRegister(PhysReg) &&
349 markRegUsedInInstr(PhysReg);
350 switch (PhysRegState[PhysReg]) {
354 PhysRegState[PhysReg] = regFree;
360 // The physreg was allocated to a virtual register. That means the value we
366 for (MCRegAliasIterator AI(PhysReg, TRI, false); AI.isValid(); ++AI) {
372 assert(TRI->isSuperRegister(PhysReg, Alias) &&
379 if (TRI->isSuperRegister(PhysReg, Alias)) {
393 PhysRegState[PhysReg] = regFree;
397 /// definePhysReg - Mark PhysReg as reserved or free after spilling any
398 /// virtregs. This is very similar to defineVirtReg except the physreg is
400 void RAFast::definePhysReg(MachineInstr *MI, unsigned PhysReg,
402 markRegUsedInInstr(PhysReg);
403 switch (unsigned VirtReg = PhysRegState[PhysReg]) {
411 PhysRegState[PhysReg] = NewState;
416 PhysRegState[PhysReg] = NewState;
417 for (MCRegAliasIterator AI(PhysReg, TRI, false); AI.isValid(); ++AI) {
428 if (TRI->isSuperRegister(PhysReg, Alias))
436 // calcSpillCost - Return the cost of spilling clearing out PhysReg and
438 // Returns 0 when PhysReg is free or disabled with all aliases disabled - it
440 PhysReg or an alias can't be spilled.
441 unsigned RAFast::calcSpillCost(unsigned PhysReg) const {
442 if (isRegUsedInInstr(PhysReg)) {
443 DEBUG(dbgs() << PrintReg(PhysReg, TRI) << " is already used in instr.\n");
446 switch (unsigned VirtReg = PhysRegState[PhysReg]) {
453 << PrintReg(PhysReg, TRI) << " is reserved already.\n");
463 DEBUG(dbgs() << PrintReg(PhysReg, TRI) << " is disabled.\n");
465 for (MCRegAliasIterator AI(PhysReg, TRI, false); AI.isValid(); ++AI) {
488 /// that PhysReg is the proper container for VirtReg now. The physical
491 void RAFast::assignVirtToPhysReg(LiveReg &LR, unsigned PhysReg) {
493 << PrintReg(PhysReg, TRI) << "\n");
494 PhysRegState[PhysReg] = LR.VirtReg;
495 assert(!LR.PhysReg && "Already assigned a physreg");
496 LR.PhysReg = PhysReg;
500 RAFast::assignVirtToPhysReg(unsigned VirtReg, unsigned PhysReg) {
503 assignVirtToPhysReg(*LRI, PhysReg);
540 unsigned PhysReg = *I;
541 if (PhysRegState[PhysReg] == regFree && !isRegUsedInInstr(PhysReg)) {
542 assignVirtToPhysReg(*LRI, PhysReg);
606 assert(LRI->PhysReg && "Register not assigned");
610 markRegUsedInInstr(LRI->PhysReg);
614 /// reloadVirtReg - Make sure VirtReg is available in a physreg and return it.
629 << PrintReg(LRI->PhysReg, TRI) << "\n");
630 TII->loadRegFromStackSlot(*MBB, MI, LRI->PhysReg, FrameIndex, RC, TRI);
657 assert(LRI->PhysReg && "Register not assigned");
660 markRegUsedInInstr(LRI->PhysReg);
664 // setPhysReg - Change operand OpNum in MI the refer the PhysReg, considering
667 bool RAFast::setPhysReg(MachineInstr *MI, unsigned OpNum, unsigned PhysReg) {
671 MO.setReg(PhysReg);
676 MO.setReg(PhysReg ? TRI->getSubReg(PhysReg, MO.getSubReg()) : 0);
682 MI->addRegisterKilled(PhysReg, TRI, true);
689 MI->addRegisterDefined(PhysReg, TRI);
695 // there are additional physreg defines.
713 // If any physreg defines collide with preallocated through registers,
741 unsigned PhysReg = LRI->PhysReg;
742 setPhysReg(MI, i, PhysReg);
750 PartialDefs.push_back(LRI->PhysReg);
764 unsigned PhysReg = LRI->PhysReg;
765 if (setPhysReg(MI, i, PhysReg))
824 assert(I->PhysReg == Reg && "Bad inverse map");
835 assert(TargetRegisterInfo::isPhysicalRegister(i->PhysReg) &&
837 assert(PhysRegState[i->PhysReg] == i->VirtReg && "Bad inverse map");
853 setPhysReg(MI, i, LRI->PhysReg);
857 // We can't allocate a physreg for a DebugValue, sorry!
900 // Mark physreg uses and early clobbers as used.
969 unsigned PhysReg = LRI->PhysReg;
970 CopySrc = (CopySrc == Reg || CopySrc == PhysReg) ? PhysReg : 0;
971 if (setPhysReg(MI, i, PhysReg))
989 // Look for physreg defs and tied uses.
1025 unsigned PhysReg = LRI->PhysReg;
1026 if (setPhysReg(MI, i, PhysReg)) {
1030 CopyDst = (CopyDst == Reg || CopyDst == PhysReg) ? PhysReg : 0;