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");
191 assert(Dst && Src &&
"Unknown operands");
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)
323 MDNode *HeapAllocMarker) {
324 bool HasPreInstrSymbol = PreInstrSymbol !=
nullptr;
325 bool HasPostInstrSymbol = PostInstrSymbol !=
nullptr;
326 bool HasHeapAllocMarker = HeapAllocMarker !=
nullptr;
328 MMOs.
size() + HasPreInstrSymbol + HasPostInstrSymbol + HasHeapAllocMarker;
331 if (NumPointers <= 0) {
340 else if (NumPointers > 1 || HasHeapAllocMarker) {
342 MMOs, PreInstrSymbol, PostInstrSymbol, HeapAllocMarker));
347 if (HasPreInstrSymbol)
348 Info.set<EIIK_PreInstrSymbol>(PreInstrSymbol);
349 else if (HasPostInstrSymbol)
350 Info.set<EIIK_PostInstrSymbol>(PostInstrSymbol);
352 Info.set<EIIK_MMO>(MMOs[0]);
388 "Invalid machine functions when cloning memory refrences!");
412 return std::equal(LHSPointees.begin(), LHSPointees.end(),
413 RHSPointees.begin());
423 if (MIs.
size() == 1) {
439 "Invalid machine functions when cloning memory references!");
444 "Invalid machine functions when cloning memory references!");
473 if (!Symbol && Info.is<EIIK_PreInstrSymbol>()) {
488 if (!Symbol && Info.is<EIIK_PostInstrSymbol>()) {
513 "Invalid machine functions when cloning instruction symbols!");
530 dyn_cast<OverflowingBinaryOperator>(&I)) {
531 if (
OB->hasNoSignedWrap())
532 MIFlags |= MachineInstr::MIFlag::NoSWrap;
533 if (
OB->hasNoUnsignedWrap())
534 MIFlags |= MachineInstr::MIFlag::NoUWrap;
540 MIFlags |= MachineInstr::MIFlag::IsExact;
546 MIFlags |= MachineInstr::MIFlag::FmNoNans;
548 MIFlags |= MachineInstr::MIFlag::FmNoInfs;
550 MIFlags |= MachineInstr::MIFlag::FmNsz;
552 MIFlags |= MachineInstr::MIFlag::FmArcp;
554 MIFlags |= MachineInstr::MIFlag::FmContract;
556 MIFlags |= MachineInstr::MIFlag::FmAfn;
558 MIFlags |= MachineInstr::MIFlag::FmReassoc;
571 if (MII->getDesc().getFlags() &
Mask) {
579 if (!MII->isBundledWithSucc())
596 assert(Other.
isBundle() &&
"Expected that both instructions are bundles.");
601 while (I1->isBundledWithSucc() && I2->isBundledWithSucc()) {
604 if (!I1->isIdenticalTo(*I2, Check))
609 if (I1->isBundledWithSucc() || I2->isBundledWithSucc())
678 assert(MF &&
"Not embedded in a function!");
684 if (!MO.isReg() || !MO.isDef())
737 assert(!Pred->isBundledWithSucc() &&
"Inconsistent bundle flags");
746 assert(!Succ->isBundledWithPred() &&
"Inconsistent bundle flags");
755 assert(Pred->isBundledWithSucc() &&
"Inconsistent bundle flags");
764 assert(Succ->isBundledWithPred() &&
"Inconsistent bundle flags");
784 unsigned *GroupNo)
const {
801 if (i + NumOps > OpIdx) {
835 assert(
getMF() &&
"Can't have an MF reference here!");
878 CurRC = OpndIt->getParent()->getRegClassConstraintEffectForVRegImpl(
879 OpndIt.getOperandNo(),
Reg, CurRC,
TII,
TRI);
882 for (
unsigned i = 0,
e = NumOperands; i <
e && CurRC; ++i)
883 CurRC = getRegClassConstraintEffectForVRegImpl(i, Reg, CurRC, TII, TRI);
890 assert(CurRC &&
"Invalid initial register class");
905 "Cannot get register constraints for non-register operand");
906 assert(CurRC &&
"Invalid initial register class");
922 while (I->isBundledWithSucc()) {
952 if (MOReg == Reg || (TRI && Reg && MOReg && TRI->
regsOverlap(MOReg, Reg)))
953 if (!isKill || MO.
isKill())
965 bool PartDef =
false;
966 bool FullDef =
false;
984 return std::make_pair(Use || (PartDef && !FullDef), PartDef || FullDef);
1004 bool Found = (MOReg ==
Reg);
1011 if (Found && (!isDead || MO.
isDead()))
1053 assert(DefMO.
isDef() &&
"DefIdx must be a def operand");
1054 assert(UseMO.
isUse() &&
"UseIdx must be a use operand");
1055 assert(!DefMO.
isTied() &&
"Def is already tied to another use");
1056 assert(!UseMO.
isTied() &&
"Use is already tied to another def");
1058 if (DefIdx < TiedMax)
1059 UseMO.TiedTo = DefIdx + 1;
1069 DefMO.TiedTo = std::min(UseIdx + 1, TiedMax);
1080 if (MO.TiedTo < TiedMax)
1081 return MO.TiedTo - 1;
1091 if (UseMO.
isReg() && UseMO.
isUse() && UseMO.TiedTo == OpIdx + 1)
1100 unsigned OpIdxGroup = ~0u;
1105 assert(FlagMO.
isImm() &&
"Invalid tied operand on inline asm");
1106 unsigned CurGroup = GroupIdx.
size();
1110 if (OpIdx > i && OpIdx < i + NumOps)
1111 OpIdxGroup = CurGroup;
1117 unsigned Delta = i - GroupIdx[TiedGroup];
1120 if (OpIdxGroup == CurGroup)
1121 return OpIdx - Delta;
1124 if (OpIdxGroup == TiedGroup)
1125 return OpIdx + Delta;
1134 if (MO.isReg() && MO.isUse())
1135 MO.setIsKill(
false);
1144 ToReg = RegInfo.
getSubReg(ToReg, SubIdx);
1146 if (!MO.isReg() || MO.getReg() != FromReg)
1148 MO.substPhysReg(ToReg, RegInfo);
1152 if (!MO.isReg() || MO.getReg() != FromReg)
1154 MO.substVirtReg(ToReg, SubIdx, RegInfo);
1231 int64_t MinOffset = std::min(OffsetA, OffsetB);
1233 uint64_t WidthA = MMOa->
getSize();
1234 uint64_t WidthB = MMOb->
getSize();
1240 bool SameVal = (ValA && ValB && (ValA == ValB));
1244 if (PSVa && ValB && !PSVa->
mayAlias(&MFI))
1246 if (PSVb && ValA && !PSVb->
mayAlias(&MFI))
1248 if (PSVa && PSVb && (PSVa == PSVb))
1253 if (!KnownWidthA || !KnownWidthB)
1255 int64_t MaxOffset =
std::max(OffsetA, OffsetB);
1256 int64_t LowWidth = (MinOffset == OffsetA) ? WidthA : WidthB;
1257 return (MinOffset + LowWidth > MaxOffset);
1266 assert((OffsetA >= 0) &&
"Negative MachineMemOperand offset");
1267 assert((OffsetB >= 0) &&
"Negative MachineMemOperand offset");
1269 int64_t OverlapA = KnownWidthA ? WidthA + OffsetA - MinOffset
1271 int64_t OverlapB = KnownWidthB ? WidthB + OffsetB - MinOffset
1322 if (!MMO->isUnordered())
1327 if (MMO->isStore())
return false;
1328 if (MMO->isInvariant() && MMO->isDereferenceable())
1333 if (PSV->isConstant(&MFI))
1336 if (
const Value *V = MMO->getValue()) {
1359 "It's illegal to have a PHI without source operands");
1388 if (!MO.isReg() || MO.isUse())
1412 if (!Operand.isReg() || Operand.isDef())
1417 if (ExpectedTiedIdx != TiedIdx)
1433 if (!OpInfo.isGenericType())
1436 if (PrintedTypes[OpInfo.getGenericTypeIndex()])
1443 PrintedTypes.
set(OpInfo.getGenericTypeIndex());
1447 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 1455 bool SkipDebugLoc,
bool AddNewLine,
1457 const Module *M =
nullptr;
1469 print(OS, MST, IsStandalone, SkipOpers, SkipDebugLoc, AddNewLine, TII);
1473 bool IsStandalone,
bool SkipOpers,
bool SkipDebugLoc,
1487 auto getTiedOperandIdx = [&](
unsigned OpIdx) {
1488 if (!ShouldPrintRegisterTies)
1495 unsigned StartOp = 0;
1499 while (StartOp < e) {
1508 unsigned TiedOperandIdx = getTiedOperandIdx(StartOp);
1509 MO.
print(OS, MST, TypeToPrint, StartOp,
false, IsStandalone,
1510 ShouldPrintRegisterTies, TiedOperandIdx, TRI, IntrinsicInfo);
1518 OS <<
"frame-setup ";
1520 OS <<
"frame-destroy ";
1542 OS <<
"nofpexcept ";
1554 bool FirstOp =
true;
1555 unsigned AsmDescOp = ~0u;
1556 unsigned AsmOpCount = 0;
1563 unsigned TiedOperandIdx = getTiedOperandIdx(OpIdx);
1564 getOperand(OpIdx).
print(OS, MST, TypeToPrint, OpIdx,
true, IsStandalone,
1565 ShouldPrintRegisterTies, TiedOperandIdx, TRI,
1571 OS <<
" [sideeffect]";
1575 OS <<
" [maystore]";
1577 OS <<
" [isconvergent]";
1579 OS <<
" [alignstack]";
1581 OS <<
" [attdialect]";
1583 OS <<
" [inteldialect]";
1592 if (FirstOp) FirstOp =
false;
else OS <<
",";
1598 if (DIV && !DIV->getName().empty())
1599 OS <<
"!\"" << DIV->getName() <<
'\"';
1602 unsigned TiedOperandIdx = getTiedOperandIdx(i);
1603 MO.
print(OS, MST, TypeToPrint, i,
true, IsStandalone,
1604 ShouldPrintRegisterTies, TiedOperandIdx, TRI, IntrinsicInfo);
1609 if (DIL && !DIL->getName().empty())
1610 OS <<
"\"" << DIL->getName() <<
'\"';
1613 unsigned TiedOperandIdx = getTiedOperandIdx(i);
1614 MO.
print(OS, MST, TypeToPrint, i,
true, IsStandalone,
1615 ShouldPrintRegisterTies, TiedOperandIdx, TRI, IntrinsicInfo);
1617 }
else if (i == AsmDescOp && MO.
isImm()) {
1619 OS <<
'$' << AsmOpCount++;
1637 OS <<
":RC" << RCID;
1663 default: OS <<
":?";
break;
1667 unsigned TiedTo = 0;
1669 OS <<
" tiedto:$" << TiedTo;
1677 unsigned TiedOperandIdx = getTiedOperandIdx(i);
1681 MO.
print(OS, MST, TypeToPrint, i,
true, IsStandalone,
1682 ShouldPrintRegisterTies, TiedOperandIdx, TRI, IntrinsicInfo);
1693 OS <<
" pre-instr-symbol ";
1701 OS <<
" post-instr-symbol ";
1709 OS <<
" heap-alloc-marker ";
1713 if (!SkipDebugLoc) {
1717 OS <<
" debug-location ";
1718 DL->printAsOperand(OS, MST);
1725 std::unique_ptr<LLVMContext> CtxPtr;
1731 CtxPtr = std::make_unique<LLVMContext>();
1732 Context = CtxPtr.get();
1736 bool NeedComma =
false;
1740 Op->print(OS, MST, SSNs, *Context, MFI, TII);
1748 bool HaveSemi =
false;
1767 OS <<
" line no:" << DV->getLine();
1768 if (
auto *InlinedAt = debugLoc->getInlinedAt()) {
1770 if (InlinedAtDL && MF) {
1771 OS <<
" inlined @[ ";
1772 InlinedAtDL.
print(OS);
1787 bool AddIfNotFound) {
1789 bool hasAliases = isPhysReg &&
1808 if (Reg == IncomingReg) {
1829 while (!DeadOps.
empty()) {
1830 unsigned OpIdx = DeadOps.
back();
1841 if (!Found && AddIfNotFound) {
1856 if (!MO.isReg() || !MO.isUse() || !MO.isKill())
1859 if ((RegInfo && RegInfo->
regsOverlap(Reg, OpReg)) || Reg == OpReg)
1860 MO.setIsKill(
false);
1866 bool AddIfNotFound) {
1868 bool hasAliases = isPhysReg &&
1883 }
else if (hasAliases && MO.
isDead() &&
1894 while (!DeadOps.
empty()) {
1895 unsigned OpIdx = DeadOps.
back();
1906 if (Found || !AddIfNotFound)
1919 if (!MO.isReg() || !MO.isDef() || MO.getReg() !=
Reg)
1921 MO.setIsDead(
false);
1927 if (!MO.isReg() || !MO.isDef() || MO.getReg() != Reg || MO.getSubReg() == 0)
1929 MO.setIsUndef(IsUndef);
1941 if (MO.isReg() && MO.getReg() == Reg && MO.isDef() &&
1942 MO.getSubReg() == 0)
1953 bool HasRegMask =
false;
1955 if (MO.isRegMask()) {
1959 if (!MO.isReg() || !MO.isDef())
continue;
1994 unsigned LocCookie = 0;
1995 const MDNode *LocMD =
nullptr;
2001 mdconst::dyn_extract<ConstantInt>(LocMD->
getOperand(0))) {
2002 LocCookie = CI->getZExtValue();
2018 assert(isa<DILocalVariable>(Variable) &&
"not a variable");
2019 assert(cast<DIExpression>(Expr)->isValid() &&
"not an expression");
2020 assert(cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(DL) &&
2021 "Expected inlined-at fields to agree");
2034 assert(isa<DILocalVariable>(Variable) &&
"not a variable");
2035 assert(cast<DIExpression>(Expr)->isValid() &&
"not an expression");
2036 assert(cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(DL) &&
2037 "Expected inlined-at fields to agree");
2039 return BuildMI(MF, DL, MCID, IsIndirect, MO.
getReg(), Variable, Expr);
2076 "Expected inlined-at fields to agree");
2092 .addFrameIndex(FrameIndex)
2114 if (!DI->isDebugValue())
2116 if (DI->getOperand(0).isReg() &&
2130 auto *MRI = getRegInfo();
2132 auto *DI = MO.getParent();
2133 if (!DI->isDebugValue())
2135 if (DI->getOperand(0).isReg() &&
2136 DI->getOperand(0).getReg() == DefReg){
2142 for (
auto *DBI : DbgValues)
2143 DBI->getOperand(0).setReg(Reg);
2151 for (
auto A : Accesses)
2153 cast<FixedStackPseudoSourceValue>(A->getPseudoValue())
2155 Size += A->getSize();
static bool isReg(const MCInst &MI, unsigned OpNo)
void changeDebugValuesDefReg(Register Reg)
Find all DBG_VALUEs that point to the register def in this instruction and point them to Reg instead...
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.
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 isDebugLabel() const
bool isEntryValue() const
Check if the expression consists of exactly one entry value operand.
void collectDebugValues(SmallVectorImpl< MachineInstr *> &DbgValues)
Scan instructions immediately following MI and collect any matching DBG_VALUEs.
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
Wrapper class representing physical registers. Should be passed by value.
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.
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
virtual bool areMemAccessesTriviallyDisjoint(const MachineInstr &MIa, const MachineInstr &MIb) const
Sometimes, it is possible for the target to tell, even without aliasing information, that two MIs access different memory addresses.
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. ...
static const DIExpression * computeExprForSpill(const MachineInstr &MI)
Compute the new DIExpression to use with a DBG_VALUE for a spill slot.
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
void setHeapAllocMarker(MachineFunction &MF, MDNode *MD)
Set a marker on instructions that denotes where we should create and emit heap alloc site labels...
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.
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
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.
bool addRegisterDead(Register Reg, const TargetRegisterInfo *RegInfo, bool AddIfNotFound=false)
We have determined MI defined a register without a use.
int findRegisterDefOperandIdx(Register 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...
unsigned getSubReg() const
bool isValid() const
isValid - Returns true until all the operands have been visited.
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)
bool mayAlias(AAResults *AA, const MachineInstr &Other, bool UseTBAA) const
Returns true if this instruction's memory access aliases the memory access of Other.
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.
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...
void clearRegisterDeads(Register Reg)
Clear all dead flags on operands defining register Reg.
const TargetRegisterClass * getRegClass(unsigned i) const
Returns the register class associated with the enumeration value.
static DIExpression * prepend(const DIExpression *Expr, uint8_t Flags, int64_t Offset=0)
Prepend DIExpr with a deref and offset operation and optionally turn it into a stack value or/and an ...
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
void substituteRegister(Register FromReg, Register ToReg, unsigned SubIdx, const TargetRegisterInfo &RegInfo)
Replace all occurrences of FromReg with ToReg:SubIdx, properly composing subreg indices where necessa...
std::pair< bool, bool > readsWritesVirtualRegister(Register Reg, SmallVectorImpl< unsigned > *Ops=nullptr) const
Return a pair of bools (reads, writes) indicating if this instruction reads or writes Reg...
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.
virtual 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 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.
void eraseFromParentAndMarkDBGValuesForRemoval()
Unlink 'this' from the containing basic block and delete it.
Optional< unsigned > getFoldedRestoreSize(const TargetInstrInfo *TII) const
Return a valid size if the instruction is a folded restore instruction.
bool regsOverlap(Register regA, Register regB) const
Returns true if the two registers are equal or alias each other.
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 TargetRegisterClass * getRegClassConstraintEffectForVReg(Register 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.
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
void copyImplicitOps(MachineFunction &MF, const MachineInstr &MI)
Copy implicit register operands from specified instruction to this instruction.
bool mayRaiseFPException() const
Return true if this instruction could possibly raise a floating-point exception.
void setRegisterDefReadUndef(Register Reg, bool IsUndef=true)
Mark all subregister defs of register Reg with the undef flag.
bool addRegisterKilled(Register IncomingReg, const TargetRegisterInfo *RegInfo, bool AddIfNotFound=false)
We have determined MI kills a register.
Optional< unsigned > getRestoreSize(const TargetInstrInfo *TII) const
Return a valid size if the instruction is a restore instruction.
Register getSubReg(MCRegister Reg, unsigned Idx) const
Returns the physical register number of sub-register "Index" for physical register RegNo...
bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
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.
bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
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 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 dropMemRefs(MachineFunction &MF)
Clear this MachineInstr's memory reference descriptor list.
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 isIdenticalTo(const MachineOperand &Other) const
Returns true if this operand is identical to the specified operand except for liveness related flags ...
virtual unsigned isStoreToStackSlotPostFE(const MachineInstr &MI, int &FrameIndex) const
Check for post-frame ptr elimination stack locations as well.
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 ...
Optional< unsigned > getSpillSize(const TargetInstrInfo *TII) const
Return a valid size if the instruction is a spill instruction.
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
void cloneInstrSymbols(MachineFunction &MF, const MachineInstr &MI)
Clone another MachineInstr's pre- and post- instruction symbols and replace ours with it...
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.
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
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
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.
bool hasRegisterImplicitUseOperand(Register Reg) const
Returns true if the MachineInstr has an implicit-use operand of exactly the given register (not consi...
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 isSuperRegister(MCRegister RegA, MCRegister RegB) const
Returns true if RegB is a super-register of RegA.
bool allowReciprocal() const
MDNode * getHeapAllocMarker() const
Helper to extract a heap alloc marker if one has been added.
self_iterator getIterator()
bool isPredicable() const
Return true if this instruction has a predicate operand that controls execution.
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. ...
static MachineOperand CreateReg(Register 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)
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.
Optional< unsigned > getFoldedSpillSize(const TargetInstrInfo *TII) const
Return a valid size if the instruction is a folded spill instruction.
static uint16_t copyFlagsFromInstruction(const Instruction &I)
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.
MachineOperand * findRegisterDefOperand(Register Reg, bool isDead=false, bool Overlap=false, const TargetRegisterInfo *TRI=nullptr)
Wrapper for findRegisterDefOperandIdx, it returns a pointer to the MachineOperand rather than an inde...
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.
virtual bool hasLoadFromStackSlot(const MachineInstr &MI, SmallVectorImpl< const MachineMemOperand *> &Accesses) const
If the specified machine instruction has a load from a stack slot, return true along with the FrameIn...
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 addOperand(MachineFunction &MF, const MachineOperand &Op)
Add the specified operand to the instruction.
Align max(MaybeAlign Lhs, Align Rhs)
mmo_iterator memoperands_begin() const
Access to memory operands of the instruction.
void setFlags(unsigned flags)
void print(raw_ostream &os, const TargetRegisterInfo *TRI=nullptr, const TargetIntrinsicInfo *IntrinsicInfo=nullptr) const
Print the MachineOperand to os.
iterator_range< use_iterator > use_operands(unsigned Reg) const
bool isDereferenceableInvariantLoad(AAResults *AA) const
Return true if this load instruction never traps and points to a memory location whose value doesn't ...
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)
static bool clobbersPhysReg(const uint32_t *RegMask, unsigned PhysReg)
clobbersPhysReg - Returns true if this RegMask clobbers PhysReg.
bool isSubRegister(MCRegister RegA, MCRegister RegB) const
Returns true if RegB is a sub-register of RegA.
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)
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.
int findRegisterUseOperandIdx(Register 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...
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.
static unsigned getSpillSlotSize(MMOList &Accesses, const MachineFrameInfo &MFI)
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.
const TargetRegisterClass * getCommonSubClass(const TargetRegisterClass *A, const TargetRegisterClass *B) const
Find the largest common subclass of A and B.
Representation of each machine instruction.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
virtual bool hasStoreToStackSlot(const MachineInstr &MI, SmallVectorImpl< const MachineMemOperand *> &Accesses) const
If the specified machine instruction has a store to a stack slot, return true along with the FrameInd...
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"))
virtual unsigned isLoadFromStackSlotPostFE(const MachineInstr &MI, int &FrameIndex) const
Check for post-frame ptr elimination stack locations as well.
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...
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...
void setPhysRegsDeadExcept(ArrayRef< Register > UsedRegs, const TargetRegisterInfo &TRI)
Mark every physreg used by this instruction as dead except those in the UsedRegs list.
bool isLoadFoldBarrier() const
Returns true if it is illegal to fold a load across this instruction.
const Module * getModule() const
bool isDebugEntryValue() const
A DBG_VALUE is an entry value iff its debug expression contains the DW_OP_LLVM_entry_value operation...
MachineInstr::ExtraInfo * createMIExtraInfo(ArrayRef< MachineMemOperand *> MMOs, MCSymbol *PreInstrSymbol=nullptr, MCSymbol *PostInstrSymbol=nullptr, MDNode *HeapAllocMarker=nullptr)
Allocate and construct an extra info structure for a MachineInstr.
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.
bool isSafeToMove(AAResults *AA, bool &SawStore) const
Return true if it is safe to move 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 addRegisterDefined(Register Reg, const TargetRegisterInfo *RegInfo=nullptr)
We have determined MI defines a register.
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.
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
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 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...
Register getReg() const
getReg - Returns the register number.
unsigned getNumOperands() const
Return number of MDNode operands.
const MachineOperand & getOperand(unsigned i) const
void clearRegisterKills(Register Reg, const TargetRegisterInfo *RegInfo)
Clear all kill flags affecting Reg.
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.
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
bool getFlag(MIFlag Flag) const
Return whether an MI flag is set.
MachineOperand * allocateOperandArray(OperandCapacity Cap)
Allocate an array of MachineOperands.
const MDNode * getMetadata() const
bool isSpillSlotObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a spill slot.
Wrapper class representing virtual and physical registers.
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.