Lines Matching defs:Def
218 // Test whether Def is safe and profitable to rematerialize.
219 static bool ShouldRematerialize(const MachineInstr &Def, AliasAnalysis &AA,
221 return Def.isAsCheapAsAMove() && TII->isTriviallyReMaterializable(Def, &AA);
232 if (MachineInstr *Def = MRI.getUniqueVRegDef(Reg))
233 return Def;
235 // MRI doesn't know what the Def is. Try asking LIS.
238 return LIS.getInstructionFromIndex(ValNo->def);
243 // Test whether Reg, as defined at Def, has exactly one use. This is a
246 static bool HasOneUse(unsigned Reg, MachineInstr *Def,
256 LIS.getInstructionIndex(*Def).getRegSlot());
271 // Test whether it's safe to move Def to just before Insert.
276 static bool IsSafeToMove(const MachineInstr *Def, const MachineInstr *Insert,
279 assert(Def->getParent() == Insert->getParent());
282 for (const MachineOperand &MO : Def->operands()) {
304 // Ask LiveIntervals whether moving this virtual register use or def to
309 // since the operand will be moving along with the def.
312 (MO.isDef() || Def->definesRegister(Reg)) ?
313 LI.getVNInfoAt(LIS.getInstructionIndex(*Def).getRegSlot()) :
314 LI.getVNInfoBefore(LIS.getInstructionIndex(*Def));
322 Query(*Def, AA, Read, Write, Effects, StackPointer);
329 // Scan through the intervening instructions between Def and Insert.
330 MachineBasicBlock::const_iterator D(Def), I(Insert);
432 /// A single-use def in the same block with no intervening memory or register
433 def down and nest it with the current instruction.
435 MachineInstr *Def,
440 DEBUG(dbgs() << "Move for single use: "; Def->dump());
442 MBB.splice(Insert, &MBB, Def);
443 LIS.handleMove(*Def);
451 // just our one def and use so that we can stackify it.
453 Def->getOperand(0).setReg(NewReg);
461 LI.removeSegment(LIS.getInstructionIndex(*Def).getRegSlot(),
467 DEBUG(dbgs() << " - Replaced register: "; Def->dump());
470 ImposeStackOrdering(Def);
471 return Def;
477 unsigned Reg, MachineOperand &Op, MachineInstr &Def, MachineBasicBlock &MBB,
481 DEBUG(dbgs() << "Rematerializing cheap def: "; Def.dump());
485 TII->reMaterialize(MBB, Insert, NewReg, 0, Def, *TRI);
500 IsDead = !LI.liveAt(LIS.getInstructionIndex(Def).getDeadSlot());
506 SlotIndex Idx = LIS.getInstructionIndex(Def).getRegSlot();
509 LIS.RemoveMachineInstrFromMaps(Def);
510 Def.eraseFromParent();
516 /// A multiple-use def in the same block with no intervening memory or register
517 /// dependencies; move the def down, nest it with the current instruction, and
521 /// Reg = INST ... // Def
528 /// DefReg = INST ... // Def (to become the new Insert)
537 unsigned Reg, MachineOperand &Op, MachineInstr *Def, MachineBasicBlock &MBB,
540 DEBUG(dbgs() << "Move and tee for multi-use:"; Def->dump());
542 // Move Def into place.
543 MBB.splice(Insert, &MBB, Def);
544 LIS.handleMove(*Def);
550 MachineOperand &DefMO = Def->getOperand(0);
558 SlotIndex DefIdx = LIS.getInstructionIndex(*Def).getRegSlot();
560 // Tell LiveIntervals we moved the original vreg def from Def to Tee.
565 ValNo->def = TeeIdx;
573 ImposeStackOrdering(Def);
576 DEBUG(dbgs() << " - Replaced register: "; Def->dump());
578 return Def;
754 MachineInstr *Def = GetVRegDef(Reg, Insert, MRI, LIS);
755 if (!Def)
758 // Don't nest an INLINE_ASM def into anything, because we don't have
760 if (Def->getOpcode() == TargetOpcode::INLINEASM)
765 if (Def->getOpcode() == WebAssembly::ARGUMENT_I32 ||
766 Def->getOpcode() == WebAssembly::ARGUMENT_I64 ||
767 Def->getOpcode() == WebAssembly::ARGUMENT_F32 ||
768 Def->getOpcode() == WebAssembly::ARGUMENT_F64)
773 // For moving, we require the def to be in the same block as the use;
777 bool SameBlock = Def->getParent() == &MBB;
778 bool CanMove = SameBlock && IsSafeToMove(Def, Insert, AA, LIS, MRI) &&
780 if (CanMove && HasOneUse(Reg, Def, MRI, MDT, LIS)) {
781 Insert = MoveForSingleUse(Reg, Op, Def, MBB, Insert, LIS, MFI, MRI);
782 } else if (ShouldRematerialize(*Def, AA, TII)) {
784 RematerializeCheapDef(Reg, Op, *Def, MBB, Insert->getIterator(),
788 Insert = MoveAndTeeForMultiUse(Reg, Op, Def, MBB, Insert, LIS, MFI,
817 // that it never looks like a use-before-def.