40 #include "llvm/Config/llvm-config.h" 94 TRI = MF->getSubtarget().getRegisterInfo();
95 MRI = &MF->getRegInfo();
96 IntrinsicInfo = MF->getTarget().getIntrinsicInfo();
97 TII = MF->getSubtarget().getInstrInfo();
117 : MCID(&tid), debugLoc(std::move(dl)) {
123 CapOperands = OperandCapacity::get(NumOps);
134 : MCID(&MI.
getDesc()), NumMemRefs(MI.NumMemRefs), MemRefs(MI.MemRefs),
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");
234 "Trying to add an operand to a machine instr that is already done!");
241 OperandCapacity OldCap = CapOperands;
244 CapOperands = OldOperands ? OldCap.getNext() : OldCap.get(1);
252 if (OpNo != NumOperands)
253 moveOperands(Operands + OpNo + 1, OldOperands + OpNo, NumOperands - OpNo,
258 if (OldOperands != Operands && OldOperands)
263 NewMO->ParentMI =
this;
266 if (NewMO->
isReg()) {
268 NewMO->Contents.
Reg.Prev =
nullptr;
279 if (NewMO->
isUse()) {
301 if (Operands[i].
isReg())
302 assert(!Operands[i].isTied() &&
"Cannot move tied operands");
306 if (MRI && Operands[OpNo].
isReg())
313 if (
unsigned N = NumOperands - 1 - OpNo)
324 unsigned OldNumMemRefs = NumMemRefs;
326 unsigned NewNum = NumMemRefs + 1;
329 std::copy(OldMemRefs, OldMemRefs + OldNumMemRefs, NewMemRefs);
330 NewMemRefs[NewNum - 1] = MO;
339 if ((E1 - I1) != (E2 - I2))
341 for (; I1 != E1; ++I1, ++I2) {
348 std::pair<MachineInstr::mmo_iterator, unsigned>
354 return std::make_pair(
nullptr, 0);
361 return std::make_pair(MemRefs, NumMemRefs);
365 size_t CombinedNumMemRefs = NumMemRefs + Other.NumMemRefs;
370 if (CombinedNumMemRefs != uint8_t(CombinedNumMemRefs))
371 return std::make_pair(
nullptr, 0);
382 return std::make_pair(MemBegin, CombinedNumMemRefs);
394 if (MII->getDesc().getFlags() &
Mask) {
402 if (!MII->isBundledWithSucc())
419 assert(Other.
isBundle() &&
"Expected that both instructions are bundles.");
424 while (I1->isBundledWithSucc() && I2->isBundledWithSucc()) {
427 if (!I1->isIdenticalTo(*I2, Check))
432 if (I1->isBundledWithSucc() || I2->isBundledWithSucc())
501 assert(MF &&
"Not embedded in a function!");
507 if (!MO.isReg() || !MO.isDef())
509 unsigned Reg = MO.getReg();
560 assert(!Pred->isBundledWithSucc() &&
"Inconsistent bundle flags");
569 assert(!Succ->isBundledWithPred() &&
"Inconsistent bundle flags");
578 assert(Pred->isBundledWithSucc() &&
"Inconsistent bundle flags");
587 assert(Succ->isBundledWithPred() &&
"Inconsistent bundle flags");
607 unsigned *GroupNo)
const {
624 if (i + NumOps > OpIdx) {
654 assert(
getMF() &&
"Can't have an MF reference here!");
697 CurRC = OpndIt->getParent()->getRegClassConstraintEffectForVRegImpl(
698 OpndIt.getOperandNo(),
Reg, CurRC,
TII,
TRI);
701 for (
unsigned i = 0, e = NumOperands; i < e && CurRC; ++i)
702 CurRC = getRegClassConstraintEffectForVRegImpl(i, Reg, CurRC, TII, TRI);
709 assert(CurRC &&
"Invalid initial register class");
724 "Cannot get register constraints for non-register operand");
725 assert(CurRC &&
"Invalid initial register class");
741 while (I->isBundledWithSucc()) {
768 unsigned MOReg = MO.
getReg();
774 if (!isKill || MO.
isKill())
786 bool PartDef =
false;
787 bool FullDef =
false;
805 return std::make_pair(Use || (PartDef && !FullDef), PartDef || FullDef);
824 unsigned MOReg = MO.
getReg();
825 bool Found = (MOReg ==
Reg);
826 if (!Found && TRI && isPhys &&
833 if (Found && (!isDead || MO.
isDead()))
875 assert(DefMO.
isDef() &&
"DefIdx must be a def operand");
876 assert(UseMO.
isUse() &&
"UseIdx must be a use operand");
877 assert(!DefMO.
isTied() &&
"Def is already tied to another use");
878 assert(!UseMO.
isTied() &&
"Use is already tied to another def");
880 if (DefIdx < TiedMax)
881 UseMO.TiedTo = DefIdx + 1;
891 DefMO.TiedTo = std::min(UseIdx + 1, TiedMax);
902 if (MO.TiedTo < TiedMax)
903 return MO.TiedTo - 1;
911 for (
unsigned i = TiedMax - 1, e =
getNumOperands(); i != e; ++i) {
913 if (UseMO.
isReg() && UseMO.
isUse() && UseMO.TiedTo == OpIdx + 1)
922 unsigned OpIdxGroup = ~0u;
927 assert(FlagMO.
isImm() &&
"Invalid tied operand on inline asm");
928 unsigned CurGroup = GroupIdx.
size();
932 if (OpIdx > i && OpIdx < i + NumOps)
933 OpIdxGroup = CurGroup;
939 unsigned Delta = i - GroupIdx[TiedGroup];
942 if (OpIdxGroup == CurGroup)
943 return OpIdx - Delta;
946 if (OpIdxGroup == TiedGroup)
947 return OpIdx + Delta;
956 if (MO.isReg() && MO.isUse())
966 ToReg = RegInfo.
getSubReg(ToReg, SubIdx);
968 if (!MO.isReg() || MO.getReg() != FromReg)
970 MO.substPhysReg(ToReg, RegInfo);
974 if (!MO.isReg() || MO.getReg() != FromReg)
976 MO.substVirtReg(ToReg, SubIdx, RegInfo);
1054 int64_t MinOffset = std::min(OffsetA, OffsetB);
1055 int64_t WidthA = MMOa->
getSize();
1056 int64_t WidthB = MMOb->
getSize();
1059 bool SameVal = (ValA && ValB && (ValA == ValB));
1063 if (PSVa && ValB && !PSVa->
mayAlias(&MFI))
1065 if (PSVb && ValA && !PSVb->
mayAlias(&MFI))
1067 if (PSVa && PSVb && (PSVa == PSVb))
1072 int64_t MaxOffset =
std::max(OffsetA, OffsetB);
1073 int64_t LowWidth = (MinOffset == OffsetA) ? WidthA : WidthB;
1074 return (MinOffset + LowWidth > MaxOffset);
1083 assert((OffsetA >= 0) &&
"Negative MachineMemOperand offset");
1084 assert((OffsetB >= 0) &&
"Negative MachineMemOperand offset");
1086 int64_t Overlapa = WidthA + OffsetA - MinOffset;
1087 int64_t Overlapb = WidthB + OffsetB - MinOffset;
1137 if (MMO->isVolatile())
return false;
1138 if (MMO->isStore())
return false;
1139 if (MMO->isInvariant() && MMO->isDereferenceable())
1144 if (PSV->isConstant(&MFI))
1147 if (
const Value *V = MMO->getValue()) {
1170 "It's illegal to have a PHI without source operands");
1199 if (!MO.isReg() || MO.isUse())
1223 if (!Operand.isReg() || Operand.isDef())
1228 if (ExpectedTiedIdx != TiedIdx)
1244 if (!OpInfo.isGenericType())
1247 if (PrintedTypes[OpInfo.getGenericTypeIndex()])
1254 PrintedTypes.
set(OpInfo.getGenericTypeIndex());
1258 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 1266 bool SkipDebugLoc,
bool AddNewLine,
1268 const Module *M =
nullptr;
1280 print(OS, MST, IsStandalone, SkipOpers, SkipDebugLoc, TII);
1284 bool IsStandalone,
bool SkipOpers,
bool SkipDebugLoc,
1298 auto getTiedOperandIdx = [&](
unsigned OpIdx) {
1299 if (!ShouldPrintRegisterTies)
1306 unsigned StartOp = 0;
1310 while (StartOp < e) {
1319 unsigned TiedOperandIdx = getTiedOperandIdx(StartOp);
1320 MO.
print(OS, MST, TypeToPrint,
false, IsStandalone,
1321 ShouldPrintRegisterTies, TiedOperandIdx, TRI, IntrinsicInfo);
1329 OS <<
"frame-setup ";
1331 OS <<
"frame-destroy ";
1357 bool FirstOp =
true;
1358 unsigned AsmDescOp = ~0u;
1359 unsigned AsmOpCount = 0;
1366 unsigned TiedOperandIdx = getTiedOperandIdx(OpIdx);
1368 ShouldPrintRegisterTies, TiedOperandIdx, TRI,
1374 OS <<
" [sideeffect]";
1378 OS <<
" [maystore]";
1380 OS <<
" [isconvergent]";
1382 OS <<
" [alignstack]";
1384 OS <<
" [attdialect]";
1386 OS <<
" [inteldialect]";
1395 if (FirstOp) FirstOp =
false;
else OS <<
",";
1401 if (DIV && !DIV->getName().empty())
1402 OS <<
"!\"" << DIV->getName() <<
'\"';
1405 unsigned TiedOperandIdx = getTiedOperandIdx(i);
1406 MO.
print(OS, MST, TypeToPrint,
true, IsStandalone,
1407 ShouldPrintRegisterTies, TiedOperandIdx, TRI, IntrinsicInfo);
1412 if (DIL && !DIL->getName().empty())
1413 OS <<
"\"" << DIL->getName() <<
'\"';
1416 unsigned TiedOperandIdx = getTiedOperandIdx(i);
1417 MO.
print(OS, MST, TypeToPrint,
true, IsStandalone,
1418 ShouldPrintRegisterTies, TiedOperandIdx, TRI, IntrinsicInfo);
1420 }
else if (i == AsmDescOp && MO.
isImm()) {
1422 OS <<
'$' << AsmOpCount++;
1440 OS <<
":RC" << RCID;
1466 default: OS <<
":?";
break;
1470 unsigned TiedTo = 0;
1472 OS <<
" tiedto:$" << TiedTo;
1480 unsigned TiedOperandIdx = getTiedOperandIdx(i);
1484 MO.
print(OS, MST, TypeToPrint,
true, IsStandalone,
1485 ShouldPrintRegisterTies, TiedOperandIdx, TRI, IntrinsicInfo);
1489 if (!SkipDebugLoc) {
1493 OS <<
" debug-location ";
1494 DL->printAsOperand(OS, MST);
1501 std::unique_ptr<LLVMContext> CtxPtr;
1507 CtxPtr = llvm::make_unique<LLVMContext>();
1508 Context = CtxPtr.get();
1512 bool NeedComma =
false;
1516 Op->print(OS, MST, SSNs, *Context, MFI, TII);
1524 bool HaveSemi =
false;
1543 OS <<
" line no:" << DV->getLine();
1544 if (
auto *InlinedAt = debugLoc->getInlinedAt()) {
1546 if (InlinedAtDL && MF) {
1547 OS <<
" inlined @[ ";
1548 InlinedAtDL.
print(OS);
1563 bool AddIfNotFound) {
1565 bool hasAliases = isPhysReg &&
1580 unsigned Reg = MO.
getReg();
1584 if (Reg == IncomingReg) {
1595 }
else if (hasAliases && MO.
isKill() &&
1606 while (!DeadOps.
empty()) {
1607 unsigned OpIdx = DeadOps.
back();
1617 if (!Found && AddIfNotFound) {
1632 if (!MO.isReg() || !MO.isUse() || !MO.isKill())
1634 unsigned OpReg = MO.getReg();
1635 if ((RegInfo && RegInfo->
regsOverlap(Reg, OpReg)) || Reg == OpReg)
1636 MO.setIsKill(
false);
1642 bool AddIfNotFound) {
1644 bool hasAliases = isPhysReg &&
1652 unsigned MOReg = MO.
getReg();
1659 }
else if (hasAliases && MO.
isDead() &&
1670 while (!DeadOps.
empty()) {
1671 unsigned OpIdx = DeadOps.
back();
1681 if (Found || !AddIfNotFound)
1694 if (!MO.isReg() || !MO.isDef() || MO.getReg() !=
Reg)
1696 MO.setIsDead(
false);
1702 if (!MO.isReg() || !MO.isDef() || MO.getReg() != Reg || MO.getSubReg() == 0)
1704 MO.setIsUndef(IsUndef);
1716 if (MO.isReg() && MO.getReg() == Reg && MO.isDef() &&
1717 MO.getSubReg() == 0)
1728 bool HasRegMask =
false;
1730 if (MO.isRegMask()) {
1734 if (!MO.isReg() || !MO.isDef())
continue;
1735 unsigned Reg = MO.getReg();
1758 if (MO.isReg() && MO.isDef() &&
1769 unsigned LocCookie = 0;
1770 const MDNode *LocMD =
nullptr;
1776 mdconst::dyn_extract<ConstantInt>(LocMD->
getOperand(0))) {
1777 LocCookie = CI->getZExtValue();
1791 unsigned Reg,
const MDNode *Variable,
1793 assert(isa<DILocalVariable>(Variable) &&
"not a variable");
1794 assert(cast<DIExpression>(Expr)->isValid() &&
"not an expression");
1795 assert(cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(DL) &&
1796 "Expected inlined-at fields to agree");
1809 assert(isa<DILocalVariable>(Variable) &&
"not a variable");
1810 assert(cast<DIExpression>(Expr)->isValid() &&
"not an expression");
1811 assert(cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(DL) &&
1812 "Expected inlined-at fields to agree");
1814 return BuildMI(MF, DL, MCID, IsIndirect, MO.
getReg(), Variable, Expr);
1827 bool IsIndirect,
unsigned Reg,
1851 "Expected inlined-at fields to agree");
1867 .addFrameIndex(FrameIndex)
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...
void push_back(const T &Elt)
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
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.
Compute iterated dominance frontiers using a linear time algorithm.
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...
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...
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
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
Manage lifetime of a slot tracker for printing IR.
iterator_range< mmo_iterator > memoperands()
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
Access to explicit operands of the instruction.
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.
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.
static bool hasIdenticalMMOs(const MachineInstr &MI1, const MachineInstr &MI2)
Check to see if the MMOs pointed to by the two MemRefs arrays are identical.
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.
hash_code hash_value(const APFloat &Arg)
See friend declarations above.
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...
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.
void clearRegisterKills(unsigned Reg, const TargetRegisterInfo *RegInfo)
Clear all kill flags affecting Reg.
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 ...
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...
struct llvm::MachineOperand::@149::@151 Reg
instr_iterator erase_instr(MachineInstr *I)
Remove an instruction from the instruction list and delete it.
unsigned const MachineRegisterInfo * MRI
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.
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...
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.
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...
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.
#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.
void eraseFromBundle()
Unlink 'this' form its basic block and delete it.
void setIsKill(bool Val=true)
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.
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.
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.
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.
static void printSubRegIdx(raw_ostream &OS, uint64_t Index, const TargetRegisterInfo *TRI)
Print a subreg index operand.
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.
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
std::pair< mmo_iterator, unsigned > mergeMemRefsWith(const MachineInstr &Other)
Return a set of memrefs (begin iterator, size) which conservatively describe the memory behavior of b...
This file provides utility analysis objects describing memory locations.
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.
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 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.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
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 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...
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
OutputIt copy(R &&Range, OutputIt Out)
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...
MachineInstr::mmo_iterator allocateMemRefsArray(unsigned long Num)
allocateMemRefsArray - Allocate an array to hold MachineMemOperand pointers.
void setMemRefs(mmo_iterator NewMemRefs, mmo_iterator NewMemRefsEnd)
Assign this MachineInstr's memory reference descriptor list.
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
const MCPhysReg * ImplicitUses
mmo_iterator memoperands_end() const
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.