50 if (
getReg() == Reg)
return;
60 SmallContents.RegNo =
Reg;
66 SmallContents.RegNo =
Reg;
92 assert(
isReg() &&
"Wrong MachineOperand accessor");
93 assert((!Val || !
isDebug()) &&
"Marking a debug operation as def");
113 assert((!
isReg() || !
isTied()) &&
"Cannot change a tied operand into an imm");
116 if (
isReg() && isOnRegUseList())
120 MF->getRegInfo().removeRegOperandFromUseList(
this);
130 bool isKill,
bool isDead,
bool isUndef,
136 RegInfo = &MF->getRegInfo();
139 bool WasReg =
isReg();
140 if (RegInfo && WasReg)
145 SmallContents.RegNo =
Reg;
146 SubReg_TargetFlags = 0;
152 IsInternalRead =
false;
153 IsEarlyClobber =
false;
156 Contents.Reg.Prev = 0;
272 bool NeedComma =
false;
274 if (NeedComma) OS <<
',';
276 OS <<
"earlyclobber,";
291 if (NeedComma) OS <<
',';
296 if (NeedComma) OS <<
',';
301 if (NeedComma) OS <<
',';
306 if (NeedComma) OS <<
',';
311 if (NeedComma) OS <<
',';
320 case MachineOperand::MO_Immediate:
323 case MachineOperand::MO_CImmediate:
324 getCImm()->getValue().print(OS, false);
326 case MachineOperand::MO_FPImmediate:
327 if (getFPImm()->getType()->isFloatTy())
328 OS << getFPImm()->getValueAPF().convertToFloat();
330 OS << getFPImm()->getValueAPF().convertToDouble();
332 case MachineOperand::MO_MachineBasicBlock:
333 OS << "<BB#" << getMBB()->getNumber() << ">";
335 case MachineOperand::MO_FrameIndex:
336 OS << "<fi#" << getIndex() << '>
';
338 case MachineOperand::MO_ConstantPoolIndex:
339 OS << "<cp#" << getIndex();
340 if (getOffset()) OS << "+" << getOffset();
343 case MachineOperand::MO_TargetIndex:
344 OS << "<ti#" << getIndex();
345 if (getOffset()) OS << "+" << getOffset();
348 case MachineOperand::MO_JumpTableIndex:
349 OS << "<jt#" << getIndex() << '>
';
351 case MachineOperand::MO_GlobalAddress:
353 WriteAsOperand(OS, getGlobal(), /*PrintType=*/false);
354 if (getOffset()) OS << "+" << getOffset();
357 case MachineOperand::MO_ExternalSymbol:
358 OS << "<es:" << getSymbolName();
359 if (getOffset()) OS << "+" << getOffset();
362 case MachineOperand::MO_BlockAddress:
364 WriteAsOperand(OS, getBlockAddress(), /*PrintType=*/false);
365 if (getOffset()) OS << "+" << getOffset();
368 case MachineOperand::MO_RegisterMask:
371 case MachineOperand::MO_Metadata:
373 WriteAsOperand(OS, getMetadata(), /*PrintType=*/false);
376 case MachineOperand::MO_MCSymbol:
377 OS << "<MCSym=" << *getMCSymbol() << '>
';
381 if (unsigned TF = getTargetFlags())
382 OS << "[TF=" << TF << ']
';
385 //===----------------------------------------------------------------------===//
386 // MachineMemOperand Implementation
387 //===----------------------------------------------------------------------===//
391 unsigned MachinePointerInfo::getAddrSpace() const {
392 if (V == 0) return 0;
393 return cast<PointerType>(V->getType())->getAddressSpace();
398 MachinePointerInfo MachinePointerInfo::getConstantPool() {
399 return MachinePointerInfo(PseudoSourceValue::getConstantPool());
404 MachinePointerInfo MachinePointerInfo::getFixedStack(int FI, int64_t offset) {
405 return MachinePointerInfo(PseudoSourceValue::getFixedStack(FI), offset);
408 MachinePointerInfo MachinePointerInfo::getJumpTable() {
409 return MachinePointerInfo(PseudoSourceValue::getJumpTable());
412 MachinePointerInfo MachinePointerInfo::getGOT() {
413 return MachinePointerInfo(PseudoSourceValue::getGOT());
416 MachinePointerInfo MachinePointerInfo::getStack(int64_t Offset) {
417 return MachinePointerInfo(PseudoSourceValue::getStack(), Offset);
420 MachineMemOperand::MachineMemOperand(MachinePointerInfo ptrinfo, unsigned f,
421 uint64_t s, unsigned int a,
422 const MDNode *TBAAInfo,
423 const MDNode *Ranges)
424 : PtrInfo(ptrinfo), Size(s),
425 Flags((f & ((1 << MOMaxBits) - 1)) | ((Log2_32(a) + 1) << MOMaxBits)),
426 TBAAInfo(TBAAInfo), Ranges(Ranges) {
427 assert((PtrInfo.V == 0 || isa<PointerType>(PtrInfo.V->getType())) &&
428 "invalid pointer value");
429 assert(getBaseAlignment() == a && "Alignment is not a power of 2!");
430 assert((isLoad() || isStore()) && "Not a load/store!");
435 void MachineMemOperand::Profile(FoldingSetNodeID &ID) const {
436 ID.AddInteger(getOffset());
438 ID.AddPointer(getValue());
439 ID.AddInteger(Flags);
442 void MachineMemOperand::refineAlignment(const MachineMemOperand *MMO) {
443 // The Value and Offset may differ due to CSE. But the flags and size
444 // should be the same.
445 assert(MMO->getFlags() == getFlags() && "Flags mismatch!");
446 assert(MMO->getSize() == getSize() && "Size mismatch!");
448 if (MMO->getBaseAlignment() >= getBaseAlignment()) {
449 // Update the alignment value.
450 Flags = (Flags & ((1 << MOMaxBits) - 1)) |
451 ((Log2_32(MMO->getBaseAlignment()) + 1) << MOMaxBits);
452 // Also update the base and offset, because the new alignment may
453 // not be applicable with the old ones.
454 PtrInfo = MMO->PtrInfo;
460 uint64_t MachineMemOperand::getAlignment() const {
461 return MinAlign(getBaseAlignment(), getOffset());
464 raw_ostream &llvm::operator<<(raw_ostream &OS, const MachineMemOperand &MMO) {
465 assert((MMO.isLoad() || MMO.isStore()) &&
466 "SV has to be a load, store or both.");
468 if (MMO.isVolatile())
477 // Print the address information.
482 WriteAsOperand(OS, MMO.getValue(), /*PrintType=*/false);
484 // If the alignment of the memory reference itself differs from the alignment
485 // of the base pointer, print the base alignment explicitly, next to the base
487 if (MMO.getBaseAlignment() != MMO.getAlignment())
488 OS << "(align=" << MMO.getBaseAlignment() << ")";
490 if (MMO.getOffset() != 0)
491 OS << "+" << MMO.getOffset();
494 // Print the alignment of the reference.
495 if (MMO.getBaseAlignment() != MMO.getAlignment() ||
496 MMO.getBaseAlignment() != MMO.getSize())
497 OS << "(align=" << MMO.getAlignment() << ")";
500 if (const MDNode *TBAAInfo = MMO.getTBAAInfo()) {
502 if (TBAAInfo->getNumOperands() > 0)
503 WriteAsOperand(OS, TBAAInfo->getOperand(0), /*PrintType=*/false);
509 // Print nontemporal info.
510 if (MMO.isNonTemporal())
511 OS << "(nontemporal)";
516 //===----------------------------------------------------------------------===//
517 // MachineInstr Implementation
518 //===----------------------------------------------------------------------===//
520 void MachineInstr::addImplicitDefUseOperands(MachineFunction &MF) {
521 if (MCID->ImplicitDefs)
522 for (const uint16_t *ImpDefs = MCID->getImplicitDefs(); *ImpDefs; ++ImpDefs)
523 addOperand(MF, MachineOperand::CreateReg(*ImpDefs, true, true));
524 if (MCID->ImplicitUses)
525 for (const uint16_t *ImpUses = MCID->getImplicitUses(); *ImpUses; ++ImpUses)
526 addOperand(MF, MachineOperand::CreateReg(*ImpUses, false, true));
532 MachineInstr::MachineInstr(MachineFunction &MF, const MCInstrDesc &tid,
533 const DebugLoc dl, bool NoImp)
534 : MCID(&tid), Parent(0), Operands(0), NumOperands(0),
535 Flags(0), AsmPrinterFlags(0),
536 NumMemRefs(0), MemRefs(0), debugLoc(dl) {
537 // Reserve space for the expected number of operands.
538 if (unsigned NumOps = MCID->getNumOperands() +
539 MCID->getNumImplicitDefs() + MCID->getNumImplicitUses()) {
540 CapOperands = OperandCapacity::get(NumOps);
541 Operands = MF.allocateOperandArray(CapOperands);
545 addImplicitDefUseOperands(MF);
550 MachineInstr::MachineInstr(MachineFunction &MF, const MachineInstr &MI)
551 : MCID(&MI.getDesc()), Parent(0), Operands(0), NumOperands(0),
552 Flags(0), AsmPrinterFlags(0),
553 NumMemRefs(MI.NumMemRefs), MemRefs(MI.MemRefs),
554 debugLoc(MI.getDebugLoc()) {
555 CapOperands = OperandCapacity::get(MI.getNumOperands());
556 Operands = MF.allocateOperandArray(CapOperands);
559 for (unsigned i = 0; i != MI.getNumOperands(); ++i)
560 addOperand(MF, MI.getOperand(i));
562 // Copy all the sensible flags.
569 MachineRegisterInfo *MachineInstr::getRegInfo() {
570 if (MachineBasicBlock *MBB = getParent())
571 return &MBB->getParent()->getRegInfo();
578 void MachineInstr::RemoveRegOperandsFromUseLists(MachineRegisterInfo &MRI) {
579 for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
580 if (Operands[i].isReg())
581 MRI.removeRegOperandFromUseList(&Operands[i]);
587 void MachineInstr::AddRegOperandsToUseLists(MachineRegisterInfo &MRI) {
588 for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
589 if (Operands[i].isReg())
590 MRI.addRegOperandToUseList(&Operands[i]);
593 void MachineInstr::addOperand(const MachineOperand &Op) {
594 MachineBasicBlock *MBB = getParent();
595 assert(MBB && "Use MachineInstrBuilder to add operands to dangling instrs");
596 MachineFunction *MF = MBB->getParent();
597 assert(MF && "Use MachineInstrBuilder to add operands to dangling instrs");
603 static void moveOperands(MachineOperand *Dst, MachineOperand *Src,
604 unsigned NumOps, MachineRegisterInfo *MRI) {
606 return MRI->moveOperands(Dst, Src, NumOps);
608 // Here it would be convenient to call memmove, so that isn't allowed because
611 for (
unsigned i = 0; i != NumOps; ++i)
614 for (
unsigned i = NumOps; i ; --i)
623 assert(MCID &&
"Cannot add operands before providing an instr descriptor");
626 if (&Op >= Operands && &Op < Operands + NumOperands) {
631 return addOperand(MF, CopyOp);
641 unsigned OpNo = getNumOperands();
643 if (!isImpReg && !isInlineAsm()) {
644 while (OpNo && Operands[OpNo-1].
isReg() && Operands[OpNo-1].
isImplicit()) {
646 assert(!Operands[OpNo].
isTied() &&
"Cannot move tied operands");
655 assert((isImpReg || Op.
isRegMask() || MCID->isVariadic() ||
656 OpNo < MCID->getNumOperands() || isMetaDataOp) &&
657 "Trying to add an operand to a machine instr that is already done!");
664 OperandCapacity OldCap = CapOperands;
666 if (!OldOperands || OldCap.getSize() == getNumOperands()) {
667 CapOperands = OldOperands ? OldCap.getNext() : OldCap.get(1);
675 if (OpNo != NumOperands)
676 moveOperands(Operands + OpNo + 1, OldOperands + OpNo, NumOperands - OpNo,
681 if (OldOperands != Operands && OldOperands)
686 NewMO->ParentMI =
this;
689 if (NewMO->
isReg()) {
691 NewMO->Contents.
Reg.Prev = 0;
702 if (NewMO->
isUse()) {
703 int DefIdx = MCID->getOperandConstraint(OpNo,
MCOI::TIED_TO);
705 tieOperands(DefIdx, OpNo);
718 assert(OpNo < getNumOperands() &&
"Invalid operand number");
719 untieRegOperand(OpNo);
723 for (
unsigned i = OpNo + 1, e = getNumOperands(); i != e; ++i)
724 if (Operands[i].
isReg())
725 assert(!Operands[i].
isTied() &&
"Cannot move tied operands");
729 if (MRI && Operands[OpNo].
isReg())
736 if (
unsigned N = NumOperands - 1 - OpNo)
747 unsigned OldNumMemRefs = NumMemRefs;
749 unsigned NewNum = NumMemRefs + 1;
752 std::copy(OldMemRefs, OldMemRefs + OldNumMemRefs, NewMemRefs);
753 NewMemRefs[NewNum - 1] = MO;
754 setMemRefs(NewMemRefs, NewMemRefs + NewNum);
757 bool MachineInstr::hasPropertyInBundle(
unsigned Mask, QueryType
Type)
const {
758 assert(!isBundledWithPred() &&
"Must be called on bundle header");
760 if (
MII->getDesc().getFlags() & Mask) {
761 if (Type == AnyInBundle)
764 if (Type == AllInBundle && !
MII->isBundle())
768 if (!
MII->isBundledWithSucc())
769 return Type == AllInBundle;
787 while (++I1 != E1 && I1->isInsideBundle()) {
789 if (I2 == E2 || !I2->isInsideBundle() || !I1->isIdenticalTo(I2, Check))
795 for (
unsigned i = 0, e = getNumOperands(); i != e; ++i) {
808 if (Check == IgnoreDefs)
810 else if (Check == IgnoreVRegDefs) {
818 if (Check == CheckKillDead && MO.
isDead() != OMO.
isDead())
824 if (Check == CheckKillDead && MO.
isKill() != OMO.
isKill())
837 assert(
getParent() &&
"Not embedded in a basic block!");
842 assert(
getParent() &&
"Not embedded in a basic block!");
847 assert(
getParent() &&
"Not embedded in a basic block!");
852 assert(
getParent() &&
"Not embedded in a basic block!");
859 unsigned NumOperands = MCID->getNumOperands();
860 if (!MCID->isVariadic())
863 for (
unsigned i = NumOperands, e = getNumOperands(); i != e; ++i) {
872 assert(!isBundledWithPred() &&
"MI is already bundled with its predecessor");
873 setFlag(BundledPred);
876 assert(!Pred->isBundledWithSucc() &&
"Inconsistent bundle flags");
877 Pred->setFlag(BundledSucc);
881 assert(!isBundledWithSucc() &&
"MI is already bundled with its successor");
882 setFlag(BundledSucc);
885 assert(!Succ->isBundledWithPred() &&
"Inconsistent bundle flags");
886 Succ->setFlag(BundledPred);
890 assert(isBundledWithPred() &&
"MI isn't bundled with its predecessor");
891 clearFlag(BundledPred);
894 assert(Pred->isBundledWithSucc() &&
"Inconsistent bundle flags");
895 Pred->clearFlag(BundledSucc);
899 assert(isBundledWithSucc() &&
"MI isn't bundled with its successor");
900 clearFlag(BundledSucc);
903 assert(Succ->isBundledWithPred() &&
"Inconsistent bundle flags");
904 Succ->clearFlag(BundledPred);
909 unsigned ExtraInfo = getOperand(InlineAsm::MIOp_ExtraInfo).getImm();
910 if (ExtraInfo & InlineAsm::Extra_IsAlignStack)
917 assert(isInlineAsm() &&
"getInlineAsmDialect() only works for inline asms!");
918 unsigned ExtraInfo = getOperand(InlineAsm::MIOp_ExtraInfo).getImm();
923 unsigned *GroupNo)
const {
924 assert(isInlineAsm() &&
"Expected an inline asm instruction");
925 assert(OpIdx < getNumOperands() &&
"OpIdx out of range");
928 if (OpIdx < InlineAsm::MIOp_FirstOperand)
933 for (
unsigned i = InlineAsm::MIOp_FirstOperand, e = getNumOperands(); i < e;
940 if (i + NumOps > OpIdx) {
954 assert(
getParent() &&
"Can't have an MBB reference here!");
960 return TII->
getRegClass(getDesc(), OpIdx, TRI, MF);
962 if (!getOperand(OpIdx).
isReg())
967 if (getOperand(OpIdx).
isUse() && isRegTiedToDefOperand(OpIdx, &DefIdx))
971 int FlagIdx = findInlineAsmFlagIdx(OpIdx);
975 unsigned Flag = getOperand(FlagIdx).getImm();
992 while (I->isBundledWithSucc())
1002 for (
unsigned i = 0, e = getNumOperands(); i != e; ++i) {
1006 unsigned MOReg = MO.
getReg();
1014 if (!isKill || MO.
isKill())
1023 std::pair<bool,bool>
1026 bool PartDef =
false;
1027 bool FullDef =
false;
1030 for (
unsigned i = 0, e = getNumOperands(); i != e; ++i) {
1045 return std::make_pair(Use || (PartDef && !FullDef), PartDef || FullDef);
1056 for (
unsigned i = 0, e = getNumOperands(); i != e; ++i) {
1064 unsigned MOReg = MO.
getReg();
1065 bool Found = (MOReg ==
Reg);
1066 if (!Found && TRI && isPhys &&
1073 if (Found && (!isDead || MO.
isDead()))
1089 for (
unsigned i = 0, e = getNumOperands(); i != e; ++i)
1115 assert(DefMO.
isDef() &&
"DefIdx must be a def operand");
1116 assert(UseMO.
isUse() &&
"UseIdx must be a use operand");
1117 assert(!DefMO.
isTied() &&
"Def is already tied to another use");
1118 assert(!UseMO.
isTied() &&
"Use is already tied to another def");
1120 if (DefIdx < TiedMax)
1121 UseMO.TiedTo = DefIdx + 1;
1126 assert(isInlineAsm() &&
"DefIdx out of range");
1131 DefMO.TiedTo = std::min(UseIdx + 1, TiedMax);
1139 assert(MO.
isTied() &&
"Operand isn't tied");
1142 if (MO.TiedTo < TiedMax)
1143 return MO.TiedTo - 1;
1146 if (!isInlineAsm()) {
1151 for (
unsigned i = TiedMax - 1, e = getNumOperands(); i != e; ++i) {
1153 if (UseMO.
isReg() && UseMO.
isUse() && UseMO.TiedTo == OpIdx + 1)
1162 unsigned OpIdxGroup = ~0u;
1164 for (
unsigned i = InlineAsm::MIOp_FirstOperand, e = getNumOperands(); i < e;
1167 assert(FlagMO.
isImm() &&
"Invalid tied operand on inline asm");
1168 unsigned CurGroup = GroupIdx.
size();
1172 if (OpIdx > i && OpIdx < i + NumOps)
1173 OpIdxGroup = CurGroup;
1179 unsigned Delta = i - GroupIdx[TiedGroup];
1182 if (OpIdxGroup == CurGroup)
1183 return OpIdx - Delta;
1186 if (OpIdxGroup == TiedGroup)
1187 return OpIdx + Delta;
1195 for (
unsigned i = 0, e = getNumOperands(); i != e; ++i) {
1208 ToReg = RegInfo.
getSubReg(ToReg, SubIdx);
1209 for (
unsigned i = 0, e = getNumOperands(); i != e; ++i) {
1216 for (
unsigned i = 0, e = getNumOperands(); i != e; ++i) {
1236 if (mayStore() || isCall() ||
1237 (mayLoad() && hasOrderedMemoryRef())) {
1242 if (isLabel() || isDebugValue() ||
1243 isTerminator() || hasUnmodeledSideEffects())
1251 if (mayLoad() && !isInvariantLoad(AA))
1268 !hasUnmodeledSideEffects())
1273 if (memoperands_empty())
1277 for (
mmo_iterator I = memoperands_begin(), E = memoperands_end();
I != E; ++
I)
1278 if (!(*I)->isUnordered())
1296 if (memoperands_empty())
1302 E = memoperands_end();
I != E; ++
I) {
1303 if ((*I)->isVolatile())
return false;
1304 if ((*I)->isStore())
return false;
1305 if ((*I)->isInvariant())
return true;
1307 if (
const Value *V = (*I)->getValue()) {
1310 if (PSV->isConstant(MFI))
1315 (*I)->getTBAAInfo())))
1333 assert(getNumOperands() >= 3 &&
1334 "It's illegal to have a PHI without source operands");
1336 unsigned Reg = getOperand(1).getReg();
1337 for (
unsigned i = 3, e = getNumOperands(); i < e; i += 2)
1338 if (getOperand(i).
getReg() != Reg)
1346 if (isInlineAsm()) {
1347 unsigned ExtraInfo = getOperand(InlineAsm::MIOp_ExtraInfo).getImm();
1348 if (ExtraInfo & InlineAsm::Extra_HasSideEffects)
1358 for (
unsigned i = 0, e = getNumOperands(); i < e; ++i) {
1381 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1382 dbgs() <<
" " << *
this;
1391 assert((!Scope || Scope.isScope()) &&
1392 "Scope of a DebugLoc should be null or a DIScope.");
1395 CommentOS << Scope.getFilename();
1397 CommentOS <<
"<unknown>";
1398 CommentOS <<
':' << DL.
getLine();
1400 CommentOS <<
':' << DL.
getCol();
1403 CommentOS <<
" @[ ";
1411 bool SkipOpers)
const {
1427 unsigned StartOp = 0, e = getNumOperands();
1428 for (; StartOp < e && getOperand(StartOp).isReg() &&
1429 getOperand(StartOp).isDef() &&
1430 !getOperand(StartOp).isImplicit();
1432 if (StartOp != 0) OS <<
", ";
1433 getOperand(StartOp).print(OS, TM);
1434 unsigned Reg = getOperand(StartOp).getReg();
1452 bool OmittedAnyCallClobbers =
false;
1453 bool FirstOp =
true;
1454 unsigned AsmDescOp = ~0u;
1455 unsigned AsmOpCount = 0;
1457 if (isInlineAsm() && e >= InlineAsm::MIOp_FirstOperand) {
1460 getOperand(InlineAsm::MIOp_AsmString).print(OS, TM);
1463 unsigned ExtraInfo = getOperand(InlineAsm::MIOp_ExtraInfo).getImm();
1464 if (ExtraInfo & InlineAsm::Extra_HasSideEffects)
1465 OS <<
" [sideeffect]";
1466 if (ExtraInfo & InlineAsm::Extra_MayLoad)
1468 if (ExtraInfo & InlineAsm::Extra_MayStore)
1469 OS <<
" [maystore]";
1470 if (ExtraInfo & InlineAsm::Extra_IsAlignStack)
1471 OS <<
" [alignstack]";
1473 OS <<
" [attdialect]";
1475 OS <<
" [inteldialect]";
1477 StartOp = AsmDescOp = InlineAsm::MIOp_FirstOperand;
1482 for (
unsigned i = StartOp, e = getNumOperands(); i != e; ++i) {
1492 if (MF && isCall() &&
1498 bool HasAliasLive =
false;
1501 unsigned AliasReg = *AI;
1503 HasAliasLive =
true;
1507 if (!HasAliasLive) {
1508 OmittedAnyCallClobbers =
true;
1515 if (FirstOp) FirstOp =
false;
else OS <<
",";
1517 if (i < getDesc().NumOperands) {
1528 OS <<
"!\"" << MDS->getString() <<
'\"';
1531 }
else if (TM && (isInsertSubreg() || isRegSequence()) && MO.
isImm()) {
1533 }
else if (i == AsmDescOp && MO.
isImm()) {
1535 OS <<
'$' << AsmOpCount++;
1536 unsigned Flag = MO.
getImm();
1538 case InlineAsm::Kind_RegUse: OS <<
":[reguse";
break;
1539 case InlineAsm::Kind_RegDef: OS <<
":[regdef";
break;
1540 case InlineAsm::Kind_RegDefEarlyClobber: OS <<
":[regdef-ec";
break;
1541 case InlineAsm::Kind_Clobber: OS <<
":[clobber";
break;
1542 case InlineAsm::Kind_Imm: OS <<
":[imm";
break;
1543 case InlineAsm::Kind_Mem: OS <<
":[mem";
break;
1552 OS <<
":RC" << RCID;
1555 unsigned TiedTo = 0;
1557 OS <<
" tiedto:$" << TiedTo;
1568 if (OmittedAnyCallClobbers) {
1569 if (!FirstOp) OS <<
",";
1573 bool HaveSemi =
false;
1574 const unsigned PrintableFlags = FrameSetup;
1575 if (
Flags & PrintableFlags) {
1576 if (!HaveSemi) OS <<
";"; HaveSemi =
true;
1579 if (
Flags & FrameSetup)
1583 if (!memoperands_empty()) {
1584 if (!HaveSemi) OS <<
";"; HaveSemi =
true;
1587 for (
mmo_iterator i = memoperands_begin(), e = memoperands_end();
1596 if (MRI && !VirtRegs.
empty()) {
1597 if (!HaveSemi) OS <<
";"; HaveSemi =
true;
1598 for (
unsigned i = 0; i != VirtRegs.
size(); ++i) {
1600 OS <<
" " << RC->
getName() <<
':' << PrintReg(VirtRegs[i]);
1601 for (
unsigned j = i+1; j != VirtRegs.
size();) {
1606 if (VirtRegs[i] != VirtRegs[j])
1607 OS <<
"," << PrintReg(VirtRegs[j]);
1614 if (isDebugValue() && getOperand(e - 1).isMetadata()) {
1615 if (!HaveSemi) OS <<
";"; HaveSemi =
true;
1621 OS <<
" inlined @[ ";
1626 }
else if (!debugLoc.isUnknown() && MF) {
1627 if (!HaveSemi) OS <<
";"; HaveSemi =
true;
1637 bool AddIfNotFound) {
1639 bool hasAliases = isPhysReg &&
1643 for (
unsigned i = 0, e = getNumOperands(); i != e; ++i) {
1651 if (Reg == IncomingReg) {
1656 if (isPhysReg && isRegTiedToDefOperand(i))
1662 }
else if (hasAliases && MO.
isKill() &&
1673 while (!DeadOps.
empty()) {
1674 unsigned OpIdx = DeadOps.
back();
1676 RemoveOperand(OpIdx);
1678 getOperand(OpIdx).setIsKill(
false);
1684 if (!Found && AddIfNotFound) {
1698 for (
unsigned i = 0, e = getNumOperands(); i != e; ++i) {
1702 unsigned OpReg = MO.
getReg();
1703 if (OpReg == Reg || (RegInfo && RegInfo->
isSuperRegister(Reg, OpReg)))
1710 bool AddIfNotFound) {
1712 bool hasAliases = isPhysReg &&
1716 for (
unsigned i = 0, e = getNumOperands(); i != e; ++i) {
1720 unsigned MOReg = MO.
getReg();
1727 }
else if (hasAliases && MO.
isDead() &&
1738 while (!DeadOps.
empty()) {
1739 unsigned OpIdx = DeadOps.
back();
1741 RemoveOperand(OpIdx);
1743 getOperand(OpIdx).setIsDead(
false);
1749 if (Found || !AddIfNotFound)
1763 MachineOperand *MO = findRegisterDefOperand(Reg,
false, RegInfo);
1767 for (
unsigned i = 0, e = getNumOperands(); i != e; ++i) {
1781 bool HasRegMask =
false;
1782 for (
unsigned i = 0, e = getNumOperands(); i != e; ++i) {
1807 addRegisterDefined(*
I, &TRI);
1829 unsigned LocCookie = 0;
1831 for (
unsigned i = getNumOperands(); i != 0; --i) {
1844 return MF->getMMI().getModule()->getContext().emitError(LocCookie, Msg);
static bool Check(DecodeStatus &Out, DecodeStatus In)
int strcmp(const char *s1, const char *s2);
void push_back(const T &Elt)
const MachineFunction * getParent() const
MachineInstr * getParent()
const GlobalValue * getGlobal() const
virtual bool pointsToConstantMemory(const Location &Loc, bool OrLocal=false)
LLVMContext & getContext() const
instr_iterator instr_end()
void removeRegOperandFromUseList(MachineOperand *MO)
Remove MO from its use-def list.
struct llvm::MachineOperand::@32::@33 Reg
const ConstantFP * getFPImm() const
void ChangeToRegister(unsigned Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isDebug=false)
MachineBasicBlock * getMBB() const
bool addRegisterDead(unsigned Reg, const TargetRegisterInfo *RegInfo, bool AddIfNotFound=false)
unsigned getNumOperands() const
getNumOperands - Return number of MDNode operands.
void setIsDef(bool Val=true)
Change a def to a use, or a use to a def.
static bool isVirtualRegister(unsigned Reg)
bool hasOrderedMemoryRef() const
MDNode * getInlinedAt() const
getInlinedAt - If this variable is inlined then return inline location.
const MCInstrDesc & getDesc() const
const char * getSymbolName() const
MDNode - a tuple of other values.
void setIsDead(bool Val=true)
const Function * getFunction() const
bool isSubRegister(unsigned RegA, unsigned RegB) const
Returns true if RegB is a sub-register of RegA.
const MDNode * getMetadata() const
Instructions::iterator instr_iterator
void substVirtReg(unsigned Reg, unsigned SubIdx, const TargetRegisterInfo &)
bool isMetadata() const
isMetadata - Tests if this is a MO_Metadata operand.
Target-dependent index+offset operand.
void setPhysRegsDeadExcept(ArrayRef< unsigned > UsedRegs, const TargetRegisterInfo &TRI)
static bool isUseOperandTiedToDef(unsigned Flag, unsigned &Idx)
bool allDefsAreDead() const
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const char *reason, bool gen_crash_diag=true)
Address of indexed Jump Table for switch.
Value * getOperand(unsigned i) const LLVM_READONLY
getOperand - Return specified operand.
bool isUnknown() const
isUnknown - Return true if this is an unknown location.
unsigned getBundleSize() const
const HexagonInstrInfo * TII
const char * getName() const
static MachineOperand CreateReg(unsigned Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false)
INITIALIZE_PASS(DeadMachineInstructionElim,"dead-mi-elimination","Remove dead machine instructions", false, false) bool DeadMachineInstructionElim bool SawStore
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
#define llvm_unreachable(msg)
const TargetRegisterClass * getRegClass(unsigned i) const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
const TargetRegisterClass * getRegClass(unsigned Reg) const
Abstract Stack Frame Information.
unsigned getNumOperands() const
bool isPredicable() const
Return true if this instruction has a predicate operand that controls execution. It may be set to 'al...
uint64_t getZExtValue() const
Return the zero extended value.
void setIsEarlyClobber(bool Val=true)
void unbundleFromPred()
Break bundle above this instruction.
void RemoveOperand(unsigned i)
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
hash_code hash_value(const APFloat &Arg)
void addMemOperand(MachineFunction &MF, MachineMemOperand *MO)
Address of indexed Constant in Constant Pool.
void clearRegisterKills(unsigned Reg, const TargetRegisterInfo *RegInfo)
void ChangeToImmediate(int64_t ImmVal)
const MachineBasicBlock * getParent() const
MCSymbol reference (for debug/eh info)
bool isEarlyClobber() const
unsigned findTiedOperandIdx(unsigned OpIdx) const
unsigned getTargetFlags() const
bool regsOverlap(unsigned regA, unsigned regB) const
static void printDebugLoc(DebugLoc DL, const MachineFunction *MF, raw_ostream &CommentOS)
Metadata reference (for debug info)
bool isOptionalDef() const
const char * getName(unsigned Opcode) const
getName - Returns the name for the instructions with the given opcode.
hash_code hash_combine(const T1 &arg1, const T2 &arg2, const T3 &arg3, const T4 &arg4, const T5 &arg5, const T6 &arg6)
const MachineOperand & getOperand(unsigned i) const
unsigned getSubReg(unsigned Reg, unsigned Idx) const
Returns the physical register number of sub-register "Index" for physical register RegNo...
Abstract Stack Frame Index.
union llvm::MachineOperand::@32::@34::@35 Val
static unsigned getNumOperandRegisters(unsigned Flag)
unsigned getNumExplicitOperands() const
ItTy next(ItTy it, Dist n)
Immediate >64bit operand.
void substPhysReg(unsigned Reg, const TargetRegisterInfo &)
bool hasUnmodeledSideEffects() const
static unsigned getKind(unsigned Flags)
int64_t getOffset() const
MDNode * getInlinedAt(const LLVMContext &Ctx) const
std::pair< bool, bool > readsWritesVirtualRegister(unsigned Reg, SmallVectorImpl< unsigned > *Ops=0) const
Floating-point immediate operand.
bool isInvariantLoad(AliasAnalysis *AA) const
Location - A description of a memory location.
unsigned getSubReg() const
static unsigned getHashValue(const MachineInstr *const &MI)
iterator erase(iterator I)
void emitError(StringRef Msg) const
DIScope - A base class for various scopes.
void setIsKill(bool Val=true)
bool isRegMask() const
isRegMask - Tests if this is a MO_RegisterMask operand.
virtual const TargetInstrInfo * getInstrInfo() const
int findInlineAsmFlagIdx(unsigned OpIdx, unsigned *GroupNo=0) const
MachineInstr * removeFromBundle()
MDNode * getScope(const LLVMContext &Ctx) const
Class for constant integers.
void substituteRegister(unsigned FromReg, unsigned ToReg, unsigned SubIdx, const TargetRegisterInfo &RegInfo)
void addOperand(MachineFunction &MF, const MachineOperand &Op)
bool isIdenticalTo(const MachineInstr *Other, MICheckType Check=CheckDefs) const
const uint32_t * getRegMask() const
int findRegisterUseOperandIdx(unsigned Reg, bool isKill=false, const TargetRegisterInfo *TRI=NULL) const
void print(raw_ostream &OS, const TargetMachine *TM=0, bool SkipOpers=false) const
raw_ostream & dbgs()
dbgs - Return a circular-buffered debug stream.
friend hash_code hash_value(const MachineOperand &MO)
MachineOperand hash_value overload.
static bool clobbersPhysReg(const uint32_t *RegMask, unsigned PhysReg)
const ConstantInt * getCImm() const
const TargetRegisterClass * getRegClassConstraint(unsigned OpIdx, const TargetInstrInfo *TII, const TargetRegisterInfo *TRI) const
const char * getSubRegIndexName(unsigned SubIdx) const
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
bool isSafeToMove(const TargetInstrInfo *TII, AliasAnalysis *AA, bool &SawStore) const
int findFirstPredOperandIdx() const
An opaque object representing a hash code.
static bool hasRegClassConstraint(unsigned Flag, unsigned &RC)
bool isSuperRegister(unsigned RegA, unsigned RegB) const
Returns true if RegB is a super-register of RegA.
MachineOperandType getType() const
static bool isPhysicalRegister(unsigned Reg)
void copyImplicitOps(MachineFunction &MF, const MachineInstr *MI)
MachineRegisterInfo & getRegInfo()
static void moveOperands(MachineOperand *Dst, MachineOperand *Src, unsigned NumOps, MachineRegisterInfo *MRI)
void print(raw_ostream &os, const TargetMachine *TM=0) const
void setReg(unsigned Reg)
void setSubReg(unsigned subReg)
MCSymbol * getMCSymbol() const
int findRegisterDefOperandIdx(unsigned Reg, bool isDead=false, bool Overlap=false, const TargetRegisterInfo *TRI=NULL) const
static DebugLoc getFromDILocation(MDNode *N)
getFromDILocation - Translate the DILocation quad into a DebugLoc.
const TargetMachine & getTarget() const
virtual const TargetRegisterInfo * getRegisterInfo() const
Mask of preserved registers.
MachineInstr * removeFromParent()
unsigned getReg() const
getReg - Returns the register number.
void unbundleFromSucc()
Break bundle below this instruction.
unsigned isConstantValuePHI() const
LLVM Value Representation.
void deallocateOperandArray(OperandCapacity Cap, MachineOperand *Array)
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction. Note that variadic (isVari...
Address of a basic block.
const MCOperandInfo * OpInfo
void addRegisterDefined(unsigned Reg, const TargetRegisterInfo *RegInfo=0)
unsigned getLineNumber() const
const Target & getTarget() const
bool addRegisterKilled(unsigned IncomingReg, const TargetRegisterInfo *RegInfo, bool AddIfNotFound=false)
const BlockAddress * getBlockAddress() const
unsigned composeSubRegIndices(unsigned a, unsigned b) const
const TargetRegisterClass * getRegClass(const MCInstrDesc &TID, unsigned OpNum, const TargetRegisterInfo *TRI, const MachineFunction &MF) const
const MCRegisterInfo & MRI
bool isStackAligningInlineAsm() const
bool isIdenticalTo(const MachineOperand &Other) const
MachineInstr::mmo_iterator allocateMemRefsArray(unsigned long Num)
virtual const TargetRegisterClass * getPointerRegClass(const MachineFunction &MF, unsigned Kind=0) const
InlineAsm::AsmDialect getInlineAsmDialect() const
MachineBasicBlock reference.
MachineOperand * allocateOperandArray(OperandCapacity Cap)
DebugLoc getDebugLoc() const
bool isInternalRead() const
bool use_empty(unsigned RegNo) const
Address of a global value.
void tieOperands(unsigned DefIdx, unsigned UseIdx)
Name of external global symbol.
void addRegOperandToUseList(MachineOperand *MO)
Add MO to the linked list of operands for its register.