40 #include "llvm/Config/llvm-config.h" 95 TRI = MF->getSubtarget().getRegisterInfo();
96 MRI = &MF->getRegInfo();
97 IntrinsicInfo = MF->getTarget().getIntrinsicInfo();
98 TII = MF->getSubtarget().getInstrInfo();
118 : MCID(&tid), debugLoc(std::move(dl)) {
124 CapOperands = OperandCapacity::get(NumOps);
154 return &MBB->getParent()->getRegInfo();
178 assert(MBB &&
"Use MachineInstrBuilder to add operands to dangling instrs");
180 assert(MF &&
"Use MachineInstrBuilder to add operands to dangling instrs");
200 assert(MCID &&
"Cannot add operands before providing an instr descriptor");
203 if (&Op >= Operands && &Op < Operands + NumOperands) {
221 while (OpNo && Operands[OpNo-1].
isReg() && Operands[OpNo-1].isImplicit()) {
223 assert(!Operands[OpNo].isTied() &&
"Cannot move tied operands");
235 "Trying to add an operand to a machine instr that is already done!");
242 OperandCapacity OldCap = CapOperands;
245 CapOperands = OldOperands ? OldCap.getNext() : OldCap.get(1);
253 if (OpNo != NumOperands)
254 moveOperands(Operands + OpNo + 1, OldOperands + OpNo, NumOperands - OpNo,
259 if (OldOperands != Operands && OldOperands)
264 NewMO->ParentMI =
this;
267 if (NewMO->
isReg()) {
269 NewMO->Contents.
Reg.Prev =
nullptr;
280 if (NewMO->
isUse()) {
302 if (Operands[i].
isReg())
303 assert(!Operands[i].isTied() &&
"Cannot move tied operands");
307 if (MRI && Operands[OpNo].
isReg())
314 if (
unsigned N = NumOperands - 1 - OpNo)
338 Info.set<EIIK_OutOfLine>(
351 Info.set<EIIK_MMO>(MMOs[0]);
356 Info.set<EIIK_OutOfLine>(
374 "Invalid machine functions when cloning memory refrences!");
397 return std::equal(LHSPointees.begin(), LHSPointees.end(),
398 RHSPointees.begin());
408 if (MIs.
size() == 1) {
424 "Invalid machine functions when cloning memory references!");
429 "Invalid machine functions when cloning memory references!");
454 if (OldSymbol == Symbol)
456 if (OldSymbol && !Symbol) {
459 if (Info.is<EIIK_PreInstrSymbol>()) {
466 "Should never have only a single symbol allocated out-of-line!");
472 }
else if (!Info || Info.is<EIIK_PreInstrSymbol>()) {
474 Info.set<EIIK_PreInstrSymbol>(
Symbol);
480 Info.set<EIIK_OutOfLine>(
486 if (OldSymbol == Symbol)
488 if (OldSymbol && !Symbol) {
491 if (Info.is<EIIK_PostInstrSymbol>()) {
498 "Should never have only a single symbol allocated out-of-line!");
504 }
else if (!Info || Info.is<EIIK_PostInstrSymbol>()) {
506 Info.set<EIIK_PostInstrSymbol>(
Symbol);
512 Info.set<EIIK_OutOfLine>(
525 dyn_cast<OverflowingBinaryOperator>(&I)) {
526 if (
OB->hasNoSignedWrap())
527 setFlag(MachineInstr::MIFlag::NoSWrap);
528 if (
OB->hasNoUnsignedWrap())
529 setFlag(MachineInstr::MIFlag::NoUWrap);
535 setFlag(MachineInstr::MIFlag::IsExact);
541 setFlag(MachineInstr::MIFlag::FmNoNans);
543 setFlag(MachineInstr::MIFlag::FmNoInfs);
545 setFlag(MachineInstr::MIFlag::FmNsz);
547 setFlag(MachineInstr::MIFlag::FmArcp);
549 setFlag(MachineInstr::MIFlag::FmContract);
551 setFlag(MachineInstr::MIFlag::FmAfn);
553 setFlag(MachineInstr::MIFlag::FmReassoc);
560 if (MII->getDesc().getFlags() &
Mask) {
568 if (!MII->isBundledWithSucc())
585 assert(Other.
isBundle() &&
"Expected that both instructions are bundles.");
590 while (I1->isBundledWithSucc() && I2->isBundledWithSucc()) {
593 if (!I1->isIdenticalTo(*I2, Check))
598 if (I1->isBundledWithSucc() || I2->isBundledWithSucc())
667 assert(MF &&
"Not embedded in a function!");
673 if (!MO.isReg() || !MO.isDef())
675 unsigned Reg = MO.getReg();
726 assert(!Pred->isBundledWithSucc() &&
"Inconsistent bundle flags");
735 assert(!Succ->isBundledWithPred() &&
"Inconsistent bundle flags");
744 assert(Pred->isBundledWithSucc() &&
"Inconsistent bundle flags");
753 assert(Succ->isBundledWithPred() &&
"Inconsistent bundle flags");
773 unsigned *GroupNo)
const {
790 if (i + NumOps > OpIdx) {
820 assert(
getMF() &&
"Can't have an MF reference here!");
863 CurRC = OpndIt->getParent()->getRegClassConstraintEffectForVRegImpl(
864 OpndIt.getOperandNo(),
Reg, CurRC,
TII,
TRI);
867 for (
unsigned i = 0, e = NumOperands; i < e && CurRC; ++i)
868 CurRC = getRegClassConstraintEffectForVRegImpl(i, Reg, CurRC, TII, TRI);
875 assert(CurRC &&
"Invalid initial register class");
890 "Cannot get register constraints for non-register operand");
891 assert(CurRC &&
"Invalid initial register class");
907 while (I->isBundledWithSucc()) {
934 unsigned MOReg = MO.
getReg();
937 if (MOReg == Reg || (TRI && Reg && MOReg && TRI->
regsOverlap(MOReg, Reg)))
938 if (!isKill || MO.
isKill())
950 bool PartDef =
false;
951 bool FullDef =
false;
969 return std::make_pair(Use || (PartDef && !FullDef), PartDef || FullDef);
988 unsigned MOReg = MO.
getReg();
989 bool Found = (MOReg ==
Reg);
990 if (!Found && TRI && isPhys &&
997 if (Found && (!isDead || MO.
isDead()))
1039 assert(DefMO.
isDef() &&
"DefIdx must be a def operand");
1040 assert(UseMO.
isUse() &&
"UseIdx must be a use operand");
1041 assert(!DefMO.
isTied() &&
"Def is already tied to another use");
1042 assert(!UseMO.
isTied() &&
"Use is already tied to another def");
1044 if (DefIdx < TiedMax)
1045 UseMO.TiedTo = DefIdx + 1;
1055 DefMO.TiedTo = std::min(UseIdx + 1, TiedMax);
1066 if (MO.TiedTo < TiedMax)
1067 return MO.TiedTo - 1;
1075 for (
unsigned i = TiedMax - 1, e =
getNumOperands(); i != e; ++i) {
1077 if (UseMO.
isReg() && UseMO.
isUse() && UseMO.TiedTo == OpIdx + 1)
1086 unsigned OpIdxGroup = ~0u;
1091 assert(FlagMO.
isImm() &&
"Invalid tied operand on inline asm");
1092 unsigned CurGroup = GroupIdx.
size();
1096 if (OpIdx > i && OpIdx < i + NumOps)
1097 OpIdxGroup = CurGroup;
1103 unsigned Delta = i - GroupIdx[TiedGroup];
1106 if (OpIdxGroup == CurGroup)
1107 return OpIdx - Delta;
1110 if (OpIdxGroup == TiedGroup)
1111 return OpIdx + Delta;
1120 if (MO.isReg() && MO.isUse())
1121 MO.setIsKill(
false);
1130 ToReg = RegInfo.
getSubReg(ToReg, SubIdx);
1132 if (!MO.isReg() || MO.getReg() != FromReg)
1134 MO.substPhysReg(ToReg, RegInfo);
1138 if (!MO.isReg() || MO.getReg() != FromReg)
1140 MO.substVirtReg(ToReg, SubIdx, RegInfo);
1217 int64_t MinOffset = std::min(OffsetA, OffsetB);
1219 uint64_t WidthA = MMOa->
getSize();
1220 uint64_t WidthB = MMOb->
getSize();
1226 bool SameVal = (ValA && ValB && (ValA == ValB));
1230 if (PSVa && ValB && !PSVa->
mayAlias(&MFI))
1232 if (PSVb && ValA && !PSVb->
mayAlias(&MFI))
1234 if (PSVa && PSVb && (PSVa == PSVb))
1239 if (!KnownWidthA || !KnownWidthB)
1241 int64_t MaxOffset =
std::max(OffsetA, OffsetB);
1242 int64_t LowWidth = (MinOffset == OffsetA) ? WidthA : WidthB;
1243 return (MinOffset + LowWidth > MaxOffset);
1252 assert((OffsetA >= 0) &&
"Negative MachineMemOperand offset");
1253 assert((OffsetB >= 0) &&
"Negative MachineMemOperand offset");
1255 int64_t OverlapA = KnownWidthA ? WidthA + OffsetA - MinOffset
1257 int64_t OverlapB = KnownWidthB ? WidthB + OffsetB - MinOffset
1308 if (MMO->isVolatile())
return false;
1309 if (MMO->isStore())
return false;
1310 if (MMO->isInvariant() && MMO->isDereferenceable())
1315 if (PSV->isConstant(&MFI))
1318 if (
const Value *V = MMO->getValue()) {
1341 "It's illegal to have a PHI without source operands");
1370 if (!MO.isReg() || MO.isUse())
1394 if (!Operand.isReg() || Operand.isDef())
1399 if (ExpectedTiedIdx != TiedIdx)
1415 if (!OpInfo.isGenericType())
1418 if (PrintedTypes[OpInfo.getGenericTypeIndex()])
1425 PrintedTypes.
set(OpInfo.getGenericTypeIndex());
1429 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 1437 bool SkipDebugLoc,
bool AddNewLine,
1439 const Module *M =
nullptr;
1451 print(OS, MST, IsStandalone, SkipOpers, SkipDebugLoc, TII);
1455 bool IsStandalone,
bool SkipOpers,
bool SkipDebugLoc,
1469 auto getTiedOperandIdx = [&](
unsigned OpIdx) {
1470 if (!ShouldPrintRegisterTies)
1477 unsigned StartOp = 0;
1481 while (StartOp < e) {
1490 unsigned TiedOperandIdx = getTiedOperandIdx(StartOp);
1491 MO.
print(OS, MST, TypeToPrint,
false, IsStandalone,
1492 ShouldPrintRegisterTies, TiedOperandIdx, TRI, IntrinsicInfo);
1500 OS <<
"frame-setup ";
1502 OS <<
"frame-destroy ";
1534 bool FirstOp =
true;
1535 unsigned AsmDescOp = ~0u;
1536 unsigned AsmOpCount = 0;
1543 unsigned TiedOperandIdx = getTiedOperandIdx(OpIdx);
1545 ShouldPrintRegisterTies, TiedOperandIdx, TRI,
1551 OS <<
" [sideeffect]";
1555 OS <<
" [maystore]";
1557 OS <<
" [isconvergent]";
1559 OS <<
" [alignstack]";
1561 OS <<
" [attdialect]";
1563 OS <<
" [inteldialect]";
1572 if (FirstOp) FirstOp =
false;
else OS <<
",";
1578 if (DIV && !DIV->getName().empty())
1579 OS <<
"!\"" << DIV->getName() <<
'\"';
1582 unsigned TiedOperandIdx = getTiedOperandIdx(i);
1583 MO.
print(OS, MST, TypeToPrint,
true, IsStandalone,
1584 ShouldPrintRegisterTies, TiedOperandIdx, TRI, IntrinsicInfo);
1589 if (DIL && !DIL->getName().empty())
1590 OS <<
"\"" << DIL->getName() <<
'\"';
1593 unsigned TiedOperandIdx = getTiedOperandIdx(i);
1594 MO.
print(OS, MST, TypeToPrint,
true, IsStandalone,
1595 ShouldPrintRegisterTies, TiedOperandIdx, TRI, IntrinsicInfo);
1597 }
else if (i == AsmDescOp && MO.
isImm()) {
1599 OS <<
'$' << AsmOpCount++;
1617 OS <<
":RC" << RCID;
1643 default: OS <<
":?";
break;
1647 unsigned TiedTo = 0;
1649 OS <<
" tiedto:$" << TiedTo;
1657 unsigned TiedOperandIdx = getTiedOperandIdx(i);
1661 MO.
print(OS, MST, TypeToPrint,
true, IsStandalone,
1662 ShouldPrintRegisterTies, TiedOperandIdx, TRI, IntrinsicInfo);
1673 OS <<
" pre-instr-symbol ";
1681 OS <<
" post-instr-symbol ";
1685 if (!SkipDebugLoc) {
1689 OS <<
" debug-location ";
1690 DL->printAsOperand(OS, MST);
1697 std::unique_ptr<LLVMContext> CtxPtr;
1703 CtxPtr = llvm::make_unique<LLVMContext>();
1704 Context = CtxPtr.get();
1708 bool NeedComma =
false;
1712 Op->print(OS, MST, SSNs, *Context, MFI, TII);
1720 bool HaveSemi =
false;
1739 OS <<
" line no:" << DV->getLine();
1740 if (
auto *InlinedAt = debugLoc->getInlinedAt()) {
1742 if (InlinedAtDL && MF) {
1743 OS <<
" inlined @[ ";
1744 InlinedAtDL.
print(OS);
1759 bool AddIfNotFound) {
1761 bool hasAliases = isPhysReg &&
1776 unsigned Reg = MO.
getReg();
1780 if (Reg == IncomingReg) {
1791 }
else if (hasAliases && MO.
isKill() &&
1802 while (!DeadOps.
empty()) {
1803 unsigned OpIdx = DeadOps.
back();
1814 if (!Found && AddIfNotFound) {
1829 if (!MO.isReg() || !MO.isUse() || !MO.isKill())
1831 unsigned OpReg = MO.getReg();
1832 if ((RegInfo && RegInfo->
regsOverlap(Reg, OpReg)) || Reg == OpReg)
1833 MO.setIsKill(
false);
1839 bool AddIfNotFound) {
1841 bool hasAliases = isPhysReg &&
1849 unsigned MOReg = MO.
getReg();
1856 }
else if (hasAliases && MO.
isDead() &&
1867 while (!DeadOps.
empty()) {
1868 unsigned OpIdx = DeadOps.
back();
1879 if (Found || !AddIfNotFound)
1892 if (!MO.isReg() || !MO.isDef() || MO.getReg() !=
Reg)
1894 MO.setIsDead(
false);
1900 if (!MO.isReg() || !MO.isDef() || MO.getReg() != Reg || MO.getSubReg() == 0)
1902 MO.setIsUndef(IsUndef);
1914 if (MO.isReg() && MO.getReg() == Reg && MO.isDef() &&
1915 MO.getSubReg() == 0)
1926 bool HasRegMask =
false;
1928 if (MO.isRegMask()) {
1932 if (!MO.isReg() || !MO.isDef())
continue;
1933 unsigned Reg = MO.getReg();
1956 if (MO.isReg() && MO.isDef() &&
1967 unsigned LocCookie = 0;
1968 const MDNode *LocMD =
nullptr;
1974 mdconst::dyn_extract<ConstantInt>(LocMD->
getOperand(0))) {
1975 LocCookie = CI->getZExtValue();
1989 unsigned Reg,
const MDNode *Variable,
1991 assert(isa<DILocalVariable>(Variable) &&
"not a variable");
1992 assert(cast<DIExpression>(Expr)->isValid() &&
"not an expression");
1993 assert(cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(DL) &&
1994 "Expected inlined-at fields to agree");
2007 assert(isa<DILocalVariable>(Variable) &&
"not a variable");
2008 assert(cast<DIExpression>(Expr)->isValid() &&
"not an expression");
2009 assert(cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(DL) &&
2010 "Expected inlined-at fields to agree");
2012 return BuildMI(MF, DL, MCID, IsIndirect, MO.
getReg(), Variable, Expr);
2025 bool IsIndirect,
unsigned Reg,
2049 "Expected inlined-at fields to agree");
2065 .addFrameIndex(FrameIndex)
2087 if (!DI->isDebugValue())
2089 if (DI->getOperand(0).isReg() &&
2101 for (
auto *DBI : DbgValues)
2102 DBI->getOperand(0).setReg(Reg);
static bool isReg(const MCInst &MI, unsigned OpNo)
bool isRegMask() const
isRegMask - Tests if this is a MO_RegisterMask operand.
static bool Check(DecodeStatus &Out, DecodeStatus In)
unsigned getNumImplicitUses() const
Return the number of implicit uses this instruction has.
const TargetRegisterClass * getCommonSubClass(const TargetRegisterClass *A, const TargetRegisterClass *B, const MVT::SimpleValueType SVT=MVT::SimpleValueType::Any) const
Find the largest common subclass of A and B.
void bundleWithPred()
Bundle this instruction with its predecessor.
const MachineInstrBuilder & addMetadata(const MDNode *MD) const
bool isUnordered() const
Returns true if this memory operation doesn't have any ordering constraints other than normal aliasin...
LLT getTypeToPrint(unsigned OpIdx, SmallBitVector &PrintedTypes, const MachineRegisterInfo &MRI) const
Debugging supportDetermine the generic type to be printed (if needed) on uses and defs...
const MachineInstrBuilder & add(const MachineOperand &MO) const
bool hasRegisterImplicitUseOperand(unsigned Reg) const
Returns true if the MachineInstr has an implicit-use operand of exactly the given register (not consi...
bool isDebugLabel() const
void collectDebugValues(SmallVectorImpl< MachineInstr *> &DbgValues)
Scan instructions following MI and collect any matching DBG_VALUEs.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
int findFirstPredOperandIdx() const
Find the index of the first operand in the operand list that is used to represent the predicate...
bool isCall(QueryType Type=AnyInBundle) const
void emitError(StringRef Msg) const
Emit an error referring to the source location of this instruction.
This is a 'bitvector' (really, a variable-sized bit array), optimized for the case when the array is ...
unsigned getNumImplicitDefs() const
Return the number of implicit defs this instruct has.
void removeRegOperandFromUseList(MachineOperand *MO)
Remove MO from its use-def list.
const MachineFunction * getMF() const
Return the function that contains the basic block that this instruction belongs to.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
MachineOperand * findRegisterDefOperand(unsigned Reg, bool isDead=false, const TargetRegisterInfo *TRI=nullptr)
Wrapper for findRegisterDefOperandIdx, it returns a pointer to the MachineOperand rather than an inde...
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
A Module instance is used to store all the information related to an LLVM module. ...
void setRegisterDefReadUndef(unsigned Reg, bool IsUndef=true)
Mark all subregister defs of register Reg with the undef flag.
static const DIExpression * computeExprForSpill(const MachineInstr &MI)
Compute the new DIExpression to use with a DBG_VALUE for a spill slot.
bool addRegisterDead(unsigned Reg, const TargetRegisterInfo *RegInfo, bool AddIfNotFound=false)
We have determined MI defined a register without a use.
virtual bool mayAlias(const MachineFrameInfo *) const
Return true if the memory pointed to by this PseudoSourceValue can ever alias an LLVM IR Value...
static const MachineFunction * getMFIfAvailable(const MachineInstr &MI)
bool isCFIInstruction() const
bool isBundledWithPred() const
Return true if this instruction is part of a bundle, and it is not the first instruction in the bundl...
void push_back(const T &Elt)
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
const MCPhysReg * getImplicitUses() const
Return a list of registers that are potentially read by any instance of this machine instruction...
Describe properties that are true of each instruction in the target description file.
unsigned getReg() const
getReg - Returns the register number.
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
unsigned getSubReg() const
The two locations do not alias at all.
LLT getType(unsigned Reg) const
Get the low-level type of Reg or LLT{} if Reg is not a generic (target independent) virtual register...
uint64_t getSize() const
Return the size in bytes of the memory reference.
bool isMetadata() const
isMetadata - Tests if this is a MO_Metadata operand.
uint16_t mergeFlagsWith(const MachineInstr &Other) const
Return the MIFlags which represent both MachineInstrs.
unsigned const TargetRegisterInfo * TRI
void setIsDead(bool Val=true)
MachineModuleInfo & getMMI() const
const MDOperand & getOperand(unsigned I) const
Manage lifetime of a slot tracker for printing IR.
void reserve(size_type N)
iterator_range< mop_iterator > operands()
void print(raw_ostream &OS) const
prints source location /path/to/file.exe:line:col @[inlined at]
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
void setPhysRegsDeadExcept(ArrayRef< unsigned > UsedRegs, const TargetRegisterInfo &TRI)
Mark every physreg used by this instruction as dead except those in the UsedRegs list.
static bool isImmKind(unsigned Flag)
static bool isUseOperandTiedToDef(unsigned Flag, unsigned &Idx)
isUseOperandTiedToDef - Return true if the flag of the inline asm operand indicates it is an use oper...
const TargetRegisterClass * getRegClass(unsigned i) const
Returns the register class associated with the enumeration value.
static DIExpression * prepend(const DIExpression *Expr, bool DerefBefore, int64_t Offset=0, bool DerefAfter=false, bool StackValue=false)
Prepend DIExpr with a deref and offset operation and optionally turn it into a stack value...
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, bool isRenamable=false)
const char * getRegClassName(const TargetRegisterClass *Class) const
Returns the name of the register class.
void clearKillInfo()
Clears kill flags on all operands.
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
The main low level interface to the alias analysis implementation.
AAMDNodes getAAInfo() const
Return the AA tags for the memory reference.
static void tryToGetTargetInfo(const MachineInstr &MI, const TargetRegisterInfo *&TRI, const MachineRegisterInfo *&MRI, const TargetIntrinsicInfo *&IntrinsicInfo, const TargetInstrInfo *&TII)
A description of a memory reference used in the backend.
MachineInstr * buildDbgValueForSpill(MachineBasicBlock &BB, MachineBasicBlock::iterator I, const MachineInstr &Orig, int FrameIndex)
Clone a DBG_VALUE whose value has been spilled to FrameIndex.
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
const HexagonInstrInfo * TII
const TargetRegisterClass * getRegClassConstraint(unsigned OpIdx, const TargetInstrInfo *TII, const TargetRegisterInfo *TRI) const
Compute the static register class constraint for operand OpIdx.
unsigned getNumOperands() const
Retuns the total number of operands.
const TargetRegisterClass * getRegClass(const MCInstrDesc &MCID, unsigned OpNum, const TargetRegisterInfo *TRI, const MachineFunction &MF) const
Given a machine instruction descriptor, returns the register class constraint for OpNum...
bool isBundledWithSucc() const
Return true if this instruction is part of a bundle, and it is not the last instruction in the bundle...
LLVMContext & getContext() const
Get the global data context.
A Use represents the edge between a Value definition and its users.
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
bool isSubRegister(unsigned RegA, unsigned RegB) const
Returns true if RegB is a sub-register of RegA.
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly...
bool isTerminator(QueryType Type=AnyInBundle) const
Returns true if this instruction part of the terminator for a basic block.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
void bundleWithSucc()
Bundle this instruction with its successor.
MachineInstr * remove_instr(MachineInstr *I)
Remove the possibly bundled instruction from the instruction list without deleting it...
virtual const TargetRegisterClass * getSubClassWithSubReg(const TargetRegisterClass *RC, unsigned Idx) const
Returns the largest legal sub-class of RC that supports the sub-register index Idx.
const TargetRegisterClass * getRegClassConstraintEffect(unsigned OpIdx, const TargetRegisterClass *CurRC, const TargetInstrInfo *TII, const TargetRegisterInfo *TRI) const
Applies the constraints (def/use) implied by the OpIdx operand to the given CurRC.
MachineInstr::ExtraInfo * createMIExtraInfo(ArrayRef< MachineMemOperand *> MMOs, MCSymbol *PreInstrSymbol=nullptr, MCSymbol *PostInstrSymbol=nullptr)
Allocate and construct an extra info structure for a MachineInstr.
void eraseFromParentAndMarkDBGValuesForRemoval()
Unlink 'this' from the containing basic block and delete it.
void emitError(unsigned LocCookie, const Twine &ErrorStr)
emitError - Emit an error message to the currently installed error handler with optional location inf...
void setIsEarlyClobber(bool Val=true)
void unbundleFromPred()
Break bundle above this instruction.
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
bool isValid() const
isValid - Returns true until all the operands have been visited.
void copyImplicitOps(MachineFunction &MF, const MachineInstr &MI)
Copy implicit register operands from specified instruction to this instruction.
void changeDebugValuesDefReg(unsigned Reg)
Find all DBG_VALUEs immediately following this instruction that point to a register def in this instr...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
hash_code hash_value(const APFloat &Arg)
See friend declarations above.
bool allowContract() const
void untieRegOperand(unsigned OpIdx)
Break any tie involving OpIdx.
int findInlineAsmFlagIdx(unsigned OpIdx, unsigned *GroupNo=nullptr) const
Find the index of the flag word operand that corresponds to operand OpIdx on an inline asm instructio...
void setPostInstrSymbol(MachineFunction &MF, MCSymbol *Symbol)
Set a symbol that will be emitted just after the instruction itself.
virtual const TargetInstrInfo * getInstrInfo() const
bool isPredicate() const
Set if this is one of the operands that made up of the predicate operand that controls an isPredicabl...
void addMemOperand(MachineFunction &MF, MachineMemOperand *MO)
Add a MachineMemOperand to the machine instruction.
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
bool mayAlias(AliasAnalysis *AA, MachineInstr &Other, bool UseTBAA)
Returns true if this instruction's memory access aliases the memory access of Other.
virtual bool areMemAccessesTriviallyDisjoint(MachineInstr &MIa, MachineInstr &MIb, AliasAnalysis *AA=nullptr) const
Sometimes, it is possible for the target to tell, even without aliasing information, that two MIs access different memory addresses.
bool isDereferenceableInvariantLoad(AliasAnalysis *AA) const
Return true if this load instruction never traps and points to a memory location whose value doesn't ...
bool allDefsAreDead() const
Return true if all the defs of this instruction are dead.
MCSymbol * getPreInstrSymbol() const
Helper to extract a pre-instruction symbol if one has been added.
void clearRegisterKills(unsigned Reg, const TargetRegisterInfo *RegInfo)
Clear all kill flags affecting Reg.
void dropMemRefs(MachineFunction &MF)
Clear this MachineInstr's memory reference descriptor list.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
void ChangeToImmediate(int64_t ImmVal)
ChangeToImmediate - Replace this operand with a new immediate operand of the specified value...
Flag
These should be considered private to the implementation of the MCInstrDesc class.
TargetInstrInfo - Interface to description of machine instruction set.
AliasResult
The possible results of an alias query.
const Value * getValue() const
Return the base address of the memory access.
bool isSuperRegister(unsigned RegA, unsigned RegB) const
Returns true if RegB is a super-register of RegA.
bool isIdenticalTo(const MachineOperand &Other) const
Returns true if this operand is identical to the specified operand except for liveness related flags ...
struct llvm::MachineOperand::@164::@166 Reg
bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal=false)
Checks whether the given location points to constant memory, or if OrLocal is true whether it points ...
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
bool mayStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly modify memory.
const MCPhysReg * getImplicitDefs() const
Return a list of registers that are potentially written by any instance of this machine instruction...
instr_iterator erase_instr(MachineInstr *I)
Remove an instruction from the instruction list and delete it.
unsigned const MachineRegisterInfo * MRI
ArrayRef< MachineMemOperand * > memoperands() const
Access to memory operands of the instruction.
unsigned isConstantValuePHI() const
If the specified instruction is a PHI that always merges together the same virtual register...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
bool isVariadic() const
Return true if this instruction can have a variable number of operands.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
void clearRegisterDeads(unsigned Reg)
Clear all dead flags on operands defining register Reg.
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
This file contains the declarations for the subclasses of Constant, which represent the different fla...
bool isOperandSubregIdx(unsigned OpIdx) const
Return true if operand OpIdx is a subregister index.
const MCPhysReg * ImplicitDefs
unsigned getSubReg(unsigned Reg, unsigned Idx) const
Returns the physical register number of sub-register "Index" for physical register RegNo...
static unsigned getNumOperandRegisters(unsigned Flag)
getNumOperandRegisters - Extract the number of registers field from the inline asm operand flag...
A udiv or sdiv instruction, which can be marked as "exact", indicating that no bits are destroyed...
bool isValidLocationForIntrinsic(const DILocation *DL) const
Check that a location is valid for this variable.
void setFlag(MIFlag Flag)
Set a MI flag.
MCRegAliasIterator enumerates all registers aliasing Reg.
void clearFlag(MIFlag Flag)
clearFlag - Clear a MI flag.
This file declares a class to represent arbitrary precision floating point values and provide a varie...
bool hasOneMemOperand() const
Return true if this instruction has exactly one MachineMemOperand.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly...
static unsigned getMemoryConstraintID(unsigned Flag)
const PseudoSourceValue * getPseudoValue() const
const DILabel * getDebugLabel() const
Return the debug label referenced by this DBG_LABEL instruction.
Utility class for integer operators which may exhibit overflow - Add, Sub, Mul, and Shl...
static unsigned getKind(unsigned Flags)
bool isRegTiedToDefOperand(unsigned UseOpIdx, unsigned *DefOpIdx=nullptr) const
Return true if the use operand of the specified index is tied to a def operand.
virtual const TargetRegisterClass * getMatchingSuperRegClass(const TargetRegisterClass *A, const TargetRegisterClass *B, unsigned Idx) const
Return a subclass of the specified register class A so that each register in it has a sub-register of...
bool allowReciprocal() const
self_iterator getIterator()
bool isPredicable() const
Return true if this instruction has a predicate operand that controls execution.
std::pair< bool, bool > readsWritesVirtualRegister(unsigned Reg, SmallVectorImpl< unsigned > *Ops=nullptr) const
Return a pair of bools (reads, writes) indicating if this instruction reads or writes Reg...
void print(raw_ostream &OS, bool IsStandalone=true, bool SkipOpers=false, bool SkipDebugLoc=false, bool AddNewLine=true, const TargetInstrInfo *TII=nullptr) const
Print this MI to OS.
bool hasComplexRegisterTies() const
Return true when an instruction has tied register that can't be determined by the instruction's descr...
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
void incorporateFunction(const Function &F)
Incorporate the given function.
bool isStackAligningInlineAsm() const
static unsigned getHashValue(const MachineInstr *const &MI)
static bool isMemKind(unsigned Flag)
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
StringRef getName(unsigned Opcode) const
Returns the name for the instructions with the given opcode.
bool isDebugInstr() const
unsigned getBundleSize() const
Return the number of instructions inside the MI bundle, excluding the bundle header.
static void printSymbol(raw_ostream &OS, MCSymbol &Sym)
Print a MCSymbol as an operand.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned getNumExplicitOperands() const
Returns the number of non-implicit operands.
const DIExpression * getDebugExpression() const
Return the complex address expression referenced by this DBG_VALUE instruction.
MCSymbol * getPostInstrSymbol() const
Helper to extract a post-instruction symbol if one has been added.
void eraseFromBundle()
Unlink 'this' form its basic block and delete it.
void setIsKill(bool Val=true)
void copyIRFlags(const Instruction &I)
Copy all flags to MachineInst MIFlags.
TargetIntrinsicInfo - Interface to description of machine instruction set.
Representation for a specific memory location.
int getOperandConstraint(unsigned OpNum, MCOI::OperandConstraint Constraint) const
Returns the value of the specific constraint if it is set.
MachineInstr * removeFromBundle()
Unlink this instruction from its basic block and return it without deleting it.
void cloneMemRefs(MachineFunction &MF, const MachineInstr &MI)
Clone another MachineInstr's memory reference descriptor list and replace ours with it...
unsigned findTiedOperandIdx(unsigned OpIdx) const
Given the index of a tied register operand, find the operand it is tied to.
Iterator for intrusive lists based on ilist_node.
ConstMIBundleOperands - Iterate over all operands in a const bundle of machine instructions.
InlineAsm::AsmDialect getInlineAsmDialect() const
This is the shared class of boolean and integer constants.
void substituteRegister(unsigned FromReg, unsigned ToReg, unsigned SubIdx, const TargetRegisterInfo &RegInfo)
Replace all occurrences of FromReg with ToReg:SubIdx, properly composing subreg indices where necessa...
void addOperand(MachineFunction &MF, const MachineOperand &Op)
Add the specified operand to the instruction.
mmo_iterator memoperands_begin() const
Access to memory operands of the instruction.
bool regsOverlap(unsigned regA, unsigned regB) const
Returns true if the two registers are equal or alias each other.
void setFlags(unsigned flags)
void print(raw_ostream &os, const TargetRegisterInfo *TRI=nullptr, const TargetIntrinsicInfo *IntrinsicInfo=nullptr) const
Print the MachineOperand to os.
bool isDebugValue() const
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Utility class for floating point operations which can have information about relaxed accuracy require...
Module.h This file contains the declarations for the Module class.
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
bool hasOrderedMemoryRef() const
Return true if this instruction may have an ordered or volatile memory reference, or if the informati...
void updateDbgValueForSpill(MachineInstr &Orig, int FrameIndex)
Update a DBG_VALUE whose value has been spilled to FrameIndex.
unsigned getNumDefs() const
Return the number of MachineOperands that are register definitions.
bool isVariadic(QueryType Type=IgnoreBundle) const
Return true if this instruction can have a variable number of operands.
MachineInstr * remove(MachineInstr *I)
Remove the unbundled instruction from the instruction list without deleting it.
void setMetadata(const MDNode *MD)
const Function & getFunction() const
Return the LLVM function that this machine code represents.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
MCSymbol reference (for debug/eh info)
void addRegisterDefined(unsigned Reg, const TargetRegisterInfo *RegInfo=nullptr)
We have determined MI defines a register.
static bool clobbersPhysReg(const uint32_t *RegMask, unsigned PhysReg)
clobbersPhysReg - Returns true if this RegMask clobbers PhysReg.
bool hasProperty(unsigned MCFlag, QueryType Type=AnyInBundle) const
Return true if the instruction (or in the case of a bundle, the instructions inside the bundle) has t...
Special value supplied for machine level alias analysis.
static unsigned getReg(const void *D, unsigned RC, unsigned RegNo)
int findRegisterDefOperandIdx(unsigned Reg, bool isDead=false, bool Overlap=false, const TargetRegisterInfo *TRI=nullptr) const
Returns the operand index that is a def of the specified register or -1 if it is not found...
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
void addImplicitDefUseOperands(MachineFunction &MF)
Add all implicit def and use operands to this instruction.
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array...
static void printSubRegIdx(raw_ostream &OS, uint64_t Index, const TargetRegisterInfo *TRI)
Print a subreg index operand.
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
QueryType
API for querying MachineInstr properties.
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
static bool hasRegClassConstraint(unsigned Flag, unsigned &RC)
hasRegClassConstraint - Returns true if the flag contains a register class constraint.
Representation of each machine instruction.
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
static cl::opt< bool > UseTBAA("use-tbaa-in-sched-mi", cl::Hidden, cl::init(true), cl::desc("Enable use of TBAA during MI DAG construction"))
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
void setPreInstrSymbol(MachineFunction &MF, MCSymbol *Symbol)
Set a symbol that will be emitted just prior to the instruction itself.
static void moveOperands(MachineOperand *Dst, MachineOperand *Src, unsigned NumOps, MachineRegisterInfo *MRI)
Move NumOps MachineOperands from Src to Dst, with support for overlapping ranges. ...
LLVM_NODISCARD bool empty() const
This file provides utility analysis objects describing memory locations.
void cloneMergedMemRefs(MachineFunction &MF, ArrayRef< const MachineInstr *> MIs)
Clone the merge of multiple MachineInstrs' memory reference descriptors list and replace ours with it...
const TargetRegisterClass * getRegClassConstraintEffectForVReg(unsigned Reg, const TargetRegisterClass *CurRC, const TargetInstrInfo *TII, const TargetRegisterInfo *TRI, bool ExploreBundle=false) const
Applies the constraints (def/use) implied by this MI on Reg to the given CurRC.
iterator_range< pointee_iterator< WrappedIteratorT > > make_pointee_range(RangeT &&Range)
static bool hasIdenticalMMOs(ArrayRef< MachineMemOperand *> LHS, ArrayRef< MachineMemOperand *> RHS)
Check to see if the MMOs pointed to by the two MemRefs arrays are identical.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
void markUsesInDebugValueAsUndef(unsigned Reg) const
markUsesInDebugValueAsUndef - Mark every DBG_VALUE referencing the specified register as undefined wh...
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
bool isLoadFoldBarrier() const
Returns true if it is illegal to fold a load across this instruction.
const Module * getModule() const
MachineInstr * removeFromParent()
Unlink 'this' from the containing basic block, and return it without deleting it. ...
unsigned getNumExplicitDefs() const
Returns the number of non-implicit definitions.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
uint16_t getFlags() const
Return the MI flags bitvector.
bool mayLoad(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read memory.
bool memoperands_empty() const
Return true if we don't have any memory operands which described the memory access done by this instr...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool isIdenticalTo(const MachineInstr &Other, MICheckType Check=CheckDefs) const
Return true if this instruction is identical to Other.
void setMemRefs(MachineFunction &MF, ArrayRef< MachineMemOperand *> MemRefs)
Assign this MachineInstr's memory reference descriptor list.
void unbundleFromSucc()
Break bundle below this instruction.
Module * getParent()
Get the module that this global value is contained inside of...
int64_t getOffset() const
For normal values, this is a byte offset added to the base address.
LLVM Value Representation.
void deallocateOperandArray(OperandCapacity Cap, MachineOperand *Array)
Dellocate an array of MachineOperands and recycle the memory.
void moveOperands(MachineOperand *Dst, MachineOperand *Src, unsigned NumOps)
Move NumOps operands from Src to Dst, updating use-def lists as needed.
const DILocalVariable * getDebugVariable() const
Return the debug variable referenced by this DBG_VALUE instruction.
const MCOperandInfo * OpInfo
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
void ChangeToFrameIndex(int Idx)
Replace this operand with a frame index.
This class implements an extremely fast bulk output stream that can only output to a stream...
bool allowReassoc() const
Flag queries.
bool addRegisterKilled(unsigned IncomingReg, const TargetRegisterInfo *RegInfo, bool AddIfNotFound=false)
We have determined MI kills a register.
bool hasUnmodeledSideEffects() const
Return true if this instruction has side effects that are not modeled by mayLoad / mayStore...
Convenience struct for specifying and reasoning about fast-math flags.
StringRef - Represent a constant reference to a string, i.e.
void RemoveOperand(unsigned OpNo)
Erase an operand from an instruction, leaving it with one fewer operand than it started with...
unsigned getNumOperands() const
Return number of MDNode operands.
const MachineOperand & getOperand(unsigned i) const
bool isIndirectDebugValue() const
A DBG_VALUE is indirect iff the first operand is a register and the second operand is an immediate...
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
int findRegisterUseOperandIdx(unsigned Reg, bool isKill=false, const TargetRegisterInfo *TRI=nullptr) const
Returns the operand index that is a use of the specific register or -1 if it is not found...
bool getFlag(MIFlag Flag) const
Return whether an MI flag is set.
bool isSafeToMove(AliasAnalysis *AA, bool &SawStore) const
Return true if it is safe to move this instruction.
MachineOperand * allocateOperandArray(OperandCapacity Cap)
Allocate an array of MachineOperands.
const MDNode * getMetadata() const
bool empty() const
empty - Check if the array is empty.
const MCPhysReg * ImplicitUses
bool noSignedZeros() const
mmo_iterator memoperands_end() const
Access to memory operands of the instruction.
virtual const TargetRegisterClass * getPointerRegClass(const MachineFunction &MF, unsigned Kind=0) const
Returns a TargetRegisterClass used for pointer values.
Metadata reference (for debug info)
bool hasTrivialDestructor() const
Check whether this has a trivial destructor.
void tieOperands(unsigned DefIdx, unsigned UseIdx)
Add a tie between the register operands at DefIdx and UseIdx.
void addRegOperandToUseList(MachineOperand *MO)
Add MO to the linked list of operands for its register.