27 :
User(ty,
Value::InstructionVal + it, Ops, NumOps), Parent(nullptr) {
32 assert(BB &&
"Instruction to insert before is not in a basic block!");
39 :
User(ty,
Value::InstructionVal + it, Ops, NumOps), Parent(nullptr) {
42 assert(InsertAtEnd &&
"Basic block to append to may not be NULL!");
47 assert(!Parent &&
"Instruction still linked in the program!");
102 assert((It == ParentBB->
end() || It->getParent() == ParentBB) &&
103 "It not in ParentBB");
104 return ParentBB->getInstList().
insert(It,
this);
125 "instructions without BB parents have no order");
126 assert(Parent ==
Other->Parent &&
"cross-BB instruction order comparison");
129 return Order <
Other->Order;
133 assert(!
getType()->isVoidTy() &&
"Instruction must define result");
136 if (
auto *PN = dyn_cast<PHINode>(
this)) {
139 }
else if (
auto *II = dyn_cast<InvokeInst>(
this)) {
140 InsertBB = II->getNormalDest();
142 }
else if (isa<CallBrInst>(
this)) {
154 if (InsertPt == InsertBB->
end())
164 cast<OverflowingBinaryOperator>(
this)->setHasNoUnsignedWrap(b);
168 cast<OverflowingBinaryOperator>(
this)->setHasNoSignedWrap(b);
172 cast<PossiblyExactOperator>(
this)->setIsExact(b);
176 return cast<OverflowingBinaryOperator>(
this)->hasNoUnsignedWrap();
180 return cast<OverflowingBinaryOperator>(
this)->hasNoSignedWrap();
184 return cast<Operator>(
this)->hasPoisonGeneratingFlags();
189 case Instruction::Add:
190 case Instruction::Sub:
191 case Instruction::Mul:
192 case Instruction::Shl:
193 cast<OverflowingBinaryOperator>(
this)->setHasNoUnsignedWrap(
false);
194 cast<OverflowingBinaryOperator>(
this)->setHasNoSignedWrap(
false);
197 case Instruction::UDiv:
198 case Instruction::SDiv:
199 case Instruction::AShr:
200 case Instruction::LShr:
201 cast<PossiblyExactOperator>(
this)->setIsExact(
false);
204 case Instruction::GetElementPtr:
205 cast<GetElementPtrInst>(
this)->setIsInBounds(
false);
208 if (isa<FPMathOperator>(
this)) {
231 auto *CB = dyn_cast<CallBase>(
this);
242 for (
unsigned ArgNo = 0; ArgNo < CB->arg_size(); ArgNo++)
243 CB->removeParamAttrs(ArgNo, UBImplyingAttributes);
244 CB->removeRetAttrs(UBImplyingAttributes);
252 unsigned KnownIDs[] = {LLVMContext::MD_annotation, LLVMContext::MD_range,
253 LLVMContext::MD_nonnull, LLVMContext::MD_align};
258 return cast<PossiblyExactOperator>(
this)->isExact();
262 assert(isa<FPMathOperator>(
this) &&
"setting fast-math flag on invalid op");
263 cast<FPMathOperator>(
this)->setFast(
B);
267 assert(isa<FPMathOperator>(
this) &&
"setting fast-math flag on invalid op");
268 cast<FPMathOperator>(
this)->setHasAllowReassoc(
B);
272 assert(isa<FPMathOperator>(
this) &&
"setting fast-math flag on invalid op");
273 cast<FPMathOperator>(
this)->setHasNoNaNs(
B);
277 assert(isa<FPMathOperator>(
this) &&
"setting fast-math flag on invalid op");
278 cast<FPMathOperator>(
this)->setHasNoInfs(
B);
282 assert(isa<FPMathOperator>(
this) &&
"setting fast-math flag on invalid op");
283 cast<FPMathOperator>(
this)->setHasNoSignedZeros(
B);
287 assert(isa<FPMathOperator>(
this) &&
"setting fast-math flag on invalid op");
288 cast<FPMathOperator>(
this)->setHasAllowReciprocal(
B);
292 assert(isa<FPMathOperator>(
this) &&
"setting fast-math flag on invalid op");
293 cast<FPMathOperator>(
this)->setHasAllowContract(
B);
297 assert(isa<FPMathOperator>(
this) &&
"setting fast-math flag on invalid op");
298 cast<FPMathOperator>(
this)->setHasApproxFunc(
B);
302 assert(isa<FPMathOperator>(
this) &&
"setting fast-math flag on invalid op");
303 cast<FPMathOperator>(
this)->setFastMathFlags(FMF);
307 assert(isa<FPMathOperator>(
this) &&
"copying fast-math flag on invalid op");
308 cast<FPMathOperator>(
this)->copyFastMathFlags(FMF);
312 assert(isa<FPMathOperator>(
this) &&
"getting fast-math flag on invalid op");
313 return cast<FPMathOperator>(
this)->isFast();
317 assert(isa<FPMathOperator>(
this) &&
"getting fast-math flag on invalid op");
318 return cast<FPMathOperator>(
this)->hasAllowReassoc();
322 assert(isa<FPMathOperator>(
this) &&
"getting fast-math flag on invalid op");
323 return cast<FPMathOperator>(
this)->hasNoNaNs();
327 assert(isa<FPMathOperator>(
this) &&
"getting fast-math flag on invalid op");
328 return cast<FPMathOperator>(
this)->hasNoInfs();
332 assert(isa<FPMathOperator>(
this) &&
"getting fast-math flag on invalid op");
333 return cast<FPMathOperator>(
this)->hasNoSignedZeros();
337 assert(isa<FPMathOperator>(
this) &&
"getting fast-math flag on invalid op");
338 return cast<FPMathOperator>(
this)->hasAllowReciprocal();
342 assert(isa<FPMathOperator>(
this) &&
"getting fast-math flag on invalid op");
343 return cast<FPMathOperator>(
this)->hasAllowContract();
347 assert(isa<FPMathOperator>(
this) &&
"getting fast-math flag on invalid op");
348 return cast<FPMathOperator>(
this)->hasApproxFunc();
352 assert(isa<FPMathOperator>(
this) &&
"getting fast-math flag on invalid op");
353 return cast<FPMathOperator>(
this)->getFastMathFlags();
362 if (IncludeWrapFlags && isa<OverflowingBinaryOperator>(
this)) {
363 if (
auto *OB = dyn_cast<OverflowingBinaryOperator>(V)) {
370 if (
auto *PE = dyn_cast<PossiblyExactOperator>(V))
371 if (isa<PossiblyExactOperator>(
this))
375 if (
auto *
FP = dyn_cast<FPMathOperator>(V))
376 if (isa<FPMathOperator>(
this))
379 if (
auto *SrcGEP = dyn_cast<GetElementPtrInst>(V))
380 if (
auto *DestGEP = dyn_cast<GetElementPtrInst>(
this))
381 DestGEP->setIsInBounds(SrcGEP->isInBounds() || DestGEP->isInBounds());
385 if (
auto *OB = dyn_cast<OverflowingBinaryOperator>(V)) {
386 if (isa<OverflowingBinaryOperator>(
this)) {
392 if (
auto *PE = dyn_cast<PossiblyExactOperator>(V))
393 if (isa<PossiblyExactOperator>(
this))
396 if (
auto *
FP = dyn_cast<FPMathOperator>(V)) {
397 if (isa<FPMathOperator>(
this)) {
399 FM &=
FP->getFastMathFlags();
404 if (
auto *SrcGEP = dyn_cast<GetElementPtrInst>(V))
405 if (
auto *DestGEP = dyn_cast<GetElementPtrInst>(
this))
406 DestGEP->setIsInBounds(SrcGEP->isInBounds() && DestGEP->isInBounds());
412 case Ret:
return "ret";
413 case Br:
return "br";
414 case Switch:
return "switch";
415 case IndirectBr:
return "indirectbr";
416 case Invoke:
return "invoke";
417 case Resume:
return "resume";
418 case Unreachable:
return "unreachable";
419 case CleanupRet:
return "cleanupret";
420 case CatchRet:
return "catchret";
421 case CatchPad:
return "catchpad";
422 case CatchSwitch:
return "catchswitch";
423 case CallBr:
return "callbr";
426 case FNeg:
return "fneg";
429 case Add:
return "add";
430 case FAdd:
return "fadd";
431 case Sub:
return "sub";
432 case FSub:
return "fsub";
433 case Mul:
return "mul";
434 case FMul:
return "fmul";
435 case UDiv:
return "udiv";
436 case SDiv:
return "sdiv";
437 case FDiv:
return "fdiv";
438 case URem:
return "urem";
439 case SRem:
return "srem";
440 case FRem:
return "frem";
443 case And:
return "and";
444 case Or :
return "or";
445 case Xor:
return "xor";
448 case Alloca:
return "alloca";
449 case Load:
return "load";
450 case Store:
return "store";
451 case AtomicCmpXchg:
return "cmpxchg";
452 case AtomicRMW:
return "atomicrmw";
453 case Fence:
return "fence";
454 case GetElementPtr:
return "getelementptr";
457 case Trunc:
return "trunc";
458 case ZExt:
return "zext";
459 case SExt:
return "sext";
460 case FPTrunc:
return "fptrunc";
461 case FPExt:
return "fpext";
462 case FPToUI:
return "fptoui";
463 case FPToSI:
return "fptosi";
464 case UIToFP:
return "uitofp";
465 case SIToFP:
return "sitofp";
466 case IntToPtr:
return "inttoptr";
467 case PtrToInt:
return "ptrtoint";
468 case BitCast:
return "bitcast";
469 case AddrSpaceCast:
return "addrspacecast";
472 case ICmp:
return "icmp";
473 case FCmp:
return "fcmp";
474 case PHI:
return "phi";
475 case Select:
return "select";
476 case Call:
return "call";
477 case Shl:
return "shl";
478 case LShr:
return "lshr";
479 case AShr:
return "ashr";
480 case VAArg:
return "va_arg";
481 case ExtractElement:
return "extractelement";
482 case InsertElement:
return "insertelement";
483 case ShuffleVector:
return "shufflevector";
484 case ExtractValue:
return "extractvalue";
485 case InsertValue:
return "insertvalue";
486 case LandingPad:
return "landingpad";
487 case CleanupPad:
return "cleanuppad";
488 case Freeze:
return "freeze";
490 default:
return "<Invalid operator> ";
497 bool IgnoreAlignment)
const {
500 "Can not compare special state of different instructions");
502 if (
const AllocaInst *AI = dyn_cast<AllocaInst>(I1))
503 return AI->getAllocatedType() == cast<AllocaInst>(I2)->getAllocatedType() &&
504 (AI->getAlign() == cast<AllocaInst>(I2)->getAlign() ||
506 if (
const LoadInst *LI = dyn_cast<LoadInst>(I1))
507 return LI->isVolatile() == cast<LoadInst>(I2)->isVolatile() &&
508 (LI->getAlign() == cast<LoadInst>(I2)->getAlign() ||
510 LI->getOrdering() == cast<LoadInst>(I2)->getOrdering() &&
511 LI->getSyncScopeID() == cast<LoadInst>(I2)->getSyncScopeID();
512 if (
const StoreInst *SI = dyn_cast<StoreInst>(I1))
513 return SI->isVolatile() == cast<StoreInst>(I2)->isVolatile() &&
514 (SI->getAlign() == cast<StoreInst>(I2)->getAlign() ||
516 SI->getOrdering() == cast<StoreInst>(I2)->getOrdering() &&
517 SI->getSyncScopeID() == cast<StoreInst>(I2)->getSyncScopeID();
518 if (
const CmpInst *CI = dyn_cast<CmpInst>(I1))
519 return CI->getPredicate() == cast<CmpInst>(I2)->getPredicate();
520 if (
const CallInst *CI = dyn_cast<CallInst>(I1))
521 return CI->isTailCall() == cast<CallInst>(I2)->isTailCall() &&
522 CI->getCallingConv() == cast<CallInst>(I2)->getCallingConv() &&
523 CI->getAttributes() == cast<CallInst>(I2)->getAttributes() &&
524 CI->hasIdenticalOperandBundleSchema(*cast<CallInst>(I2));
525 if (
const InvokeInst *CI = dyn_cast<InvokeInst>(I1))
526 return CI->getCallingConv() == cast<InvokeInst>(I2)->getCallingConv() &&
527 CI->getAttributes() == cast<InvokeInst>(I2)->getAttributes() &&
528 CI->hasIdenticalOperandBundleSchema(*cast<InvokeInst>(I2));
529 if (
const CallBrInst *CI = dyn_cast<CallBrInst>(I1))
530 return CI->getCallingConv() == cast<CallBrInst>(I2)->getCallingConv() &&
531 CI->getAttributes() == cast<CallBrInst>(I2)->getAttributes() &&
532 CI->hasIdenticalOperandBundleSchema(*cast<CallBrInst>(I2));
534 return IVI->getIndices() == cast<InsertValueInst>(I2)->getIndices();
536 return EVI->getIndices() == cast<ExtractValueInst>(I2)->getIndices();
537 if (
const FenceInst *FI = dyn_cast<FenceInst>(I1))
538 return FI->getOrdering() == cast<FenceInst>(I2)->getOrdering() &&
539 FI->getSyncScopeID() == cast<FenceInst>(I2)->getSyncScopeID();
541 return CXI->isVolatile() == cast<AtomicCmpXchgInst>(I2)->isVolatile() &&
542 CXI->isWeak() == cast<AtomicCmpXchgInst>(I2)->isWeak() &&
543 CXI->getSuccessOrdering() ==
544 cast<AtomicCmpXchgInst>(I2)->getSuccessOrdering() &&
545 CXI->getFailureOrdering() ==
546 cast<AtomicCmpXchgInst>(I2)->getFailureOrdering() &&
547 CXI->getSyncScopeID() ==
548 cast<AtomicCmpXchgInst>(I2)->getSyncScopeID();
550 return RMWI->getOperation() == cast<AtomicRMWInst>(I2)->getOperation() &&
551 RMWI->isVolatile() == cast<AtomicRMWInst>(I2)->isVolatile() &&
552 RMWI->getOrdering() == cast<AtomicRMWInst>(I2)->getOrdering() &&
553 RMWI->getSyncScopeID() == cast<AtomicRMWInst>(I2)->getSyncScopeID();
555 return SVI->getShuffleMask() ==
556 cast<ShuffleVectorInst>(I2)->getShuffleMask();
558 return GEP->getSourceElementType() ==
559 cast<GetElementPtrInst>(I2)->getSourceElementType();
585 if (
const PHINode *thisPHI = dyn_cast<PHINode>(
this)) {
586 const PHINode *otherPHI = cast<PHINode>(
I);
587 return std::equal(thisPHI->block_begin(), thisPHI->block_end(),
597 unsigned flags)
const {
604 getType()->getScalarType() !=
I->getType()->getScalarType() :
613 I->getOperand(i)->getType()->getScalarType() :
625 const PHINode *PN = dyn_cast<PHINode>(
I);
627 if (
I->getParent() != BB)
640 default:
return false;
641 case Instruction::VAArg:
642 case Instruction::Load:
643 case Instruction::Fence:
644 case Instruction::AtomicCmpXchg:
645 case Instruction::AtomicRMW:
646 case Instruction::CatchPad:
647 case Instruction::CatchRet:
649 case Instruction::Call:
650 case Instruction::Invoke:
651 case Instruction::CallBr:
652 return !cast<CallBase>(
this)->onlyWritesMemory();
653 case Instruction::Store:
654 return !cast<StoreInst>(
this)->isUnordered();
660 default:
return false;
661 case Instruction::Fence:
662 case Instruction::Store:
663 case Instruction::VAArg:
664 case Instruction::AtomicCmpXchg:
665 case Instruction::AtomicRMW:
666 case Instruction::CatchPad:
667 case Instruction::CatchRet:
669 case Instruction::Call:
670 case Instruction::Invoke:
671 case Instruction::CallBr:
672 return !cast<CallBase>(
this)->onlyReadsMemory();
673 case Instruction::Load:
674 return !cast<LoadInst>(
this)->isUnordered();
682 case Instruction::AtomicCmpXchg:
683 case Instruction::AtomicRMW:
684 case Instruction::Fence:
686 case Instruction::Load:
688 case Instruction::Store:
698 case Instruction::AtomicCmpXchg:
699 case Instruction::AtomicRMW:
700 case Instruction::Load:
710 case Instruction::AtomicCmpXchg:
711 case Instruction::AtomicRMW:
712 case Instruction::Store:
721 case Instruction::AtomicRMW:
722 return cast<AtomicRMWInst>(
this)->isVolatile();
723 case Instruction::Store:
724 return cast<StoreInst>(
this)->isVolatile();
725 case Instruction::Load:
726 return cast<LoadInst>(
this)->isVolatile();
727 case Instruction::AtomicCmpXchg:
728 return cast<AtomicCmpXchgInst>(
this)->isVolatile();
729 case Instruction::Call:
730 case Instruction::Invoke:
732 if (
auto *II = dyn_cast<IntrinsicInst>(
this)) {
733 if (
auto *
MI = dyn_cast<MemIntrinsic>(II))
734 return MI->isVolatile();
735 switch (II->getIntrinsicID()) {
737 case Intrinsic::matrix_column_major_load:
738 return cast<ConstantInt>(II->getArgOperand(2))->isOne();
739 case Intrinsic::matrix_column_major_store:
740 return cast<ConstantInt>(II->getArgOperand(3))->isOne();
749 case Instruction::Store:
750 return cast<StoreInst>(
this)->getValueOperand()->getType();
751 case Instruction::Load:
752 case Instruction::AtomicRMW:
754 case Instruction::AtomicCmpXchg:
755 return cast<AtomicCmpXchgInst>(
this)->getNewValOperand()->getType();
756 case Instruction::Call:
757 case Instruction::Invoke:
758 if (
const IntrinsicInst *II = dyn_cast<IntrinsicInst>(
this)) {
759 switch (II->getIntrinsicID()) {
760 case Intrinsic::masked_load:
761 case Intrinsic::masked_gather:
762 case Intrinsic::masked_expandload:
763 case Intrinsic::vp_load:
764 case Intrinsic::vp_gather:
765 case Intrinsic::experimental_vp_strided_load:
766 return II->getType();
767 case Intrinsic::masked_store:
768 case Intrinsic::masked_scatter:
769 case Intrinsic::masked_compressstore:
770 case Intrinsic::vp_store:
771 case Intrinsic::vp_scatter:
772 case Intrinsic::experimental_vp_strided_store:
773 return II->getOperand(0)->getType();
784 bool IncludePhaseOneUnwind) {
788 return IncludePhaseOneUnwind;
807 case Instruction::Call:
808 return !cast<CallInst>(
this)->doesNotThrow();
809 case Instruction::CleanupRet:
810 return cast<CleanupReturnInst>(
this)->unwindsToCaller();
811 case Instruction::CatchSwitch:
812 return cast<CatchSwitchInst>(
this)->unwindsToCaller();
813 case Instruction::Resume:
815 case Instruction::Invoke: {
818 BasicBlock *UnwindDest = cast<InvokeInst>(
this)->getUnwindDest();
820 if (
auto *LP = dyn_cast<LandingPadInst>(Pad))
824 case Instruction::CleanupPad:
826 return IncludePhaseOneUnwind;
843 if (
auto *SI = dyn_cast<StoreInst>(
this))
844 return !SI->isVolatile();
846 if (
const auto *CB = dyn_cast<CallBase>(
this))
847 return CB->hasFnAttr(Attribute::WillReturn);
852 auto *II = dyn_cast<IntrinsicInst>(
this);
856 return ID == Intrinsic::lifetime_start ||
ID == Intrinsic::lifetime_end;
860 auto *II = dyn_cast<IntrinsicInst>(
this);
864 return ID == Intrinsic::launder_invariant_group ||
865 ID == Intrinsic::strip_invariant_group;
869 return isa<DbgInfoIntrinsic>(
this) || isa<PseudoProbeInst>(
this);
875 if (!isa<DbgInfoIntrinsic>(
I) && !(SkipPseudoOp && isa<PseudoProbeInst>(
I)))
883 if (!isa<DbgInfoIntrinsic>(
I) && !(SkipPseudoOp && isa<PseudoProbeInst>(
I)))
889 if (isa<DbgInfoIntrinsic>(
this))
891 return Next->getDebugLoc();
903 return cast<FPMathOperator>(
this)->hasAllowReassoc() &&
904 cast<FPMathOperator>(
this)->hasNoSignedZeros();
911 if (
auto *II = dyn_cast<IntrinsicInst>(
this))
912 return II->isCommutative();
919#define HANDLE_TERM_INST(N, OPC, CLASS) \
920 case Instruction::OPC: \
921 return static_cast<const CLASS *>(this)->getNumSuccessors();
922#include "llvm/IR/Instruction.def"
931#define HANDLE_TERM_INST(N, OPC, CLASS) \
932 case Instruction::OPC: \
933 return static_cast<const CLASS *>(this)->getSuccessor(idx);
934#include "llvm/IR/Instruction.def"
943#define HANDLE_TERM_INST(N, OPC, CLASS) \
944 case Instruction::OPC: \
945 return static_cast<CLASS *>(this)->setSuccessor(idx, B);
946#include "llvm/IR/Instruction.def"
955 Idx != NumSuccessors; ++
Idx)
982 for (
unsigned M : WL)
989 for (
const auto &MD : TheMDs) {
990 if (WL.
empty() || WLS.count(MD.first))
993 if (WL.
empty() || WLS.count(LLVMContext::MD_dbg))
1002#define HANDLE_INST(num, opc, clas) \
1003 case Instruction::opc: \
1004 New = cast<clas>(this)->cloneImpl(); \
1006#include "llvm/IR/Instruction.def"
1011 New->copyMetadata(*
this);
amdgpu AMDGPU Register Bank Select
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
This file defines the DenseSet and SmallDenseSet classes.
static bool canUnwindPastLandingPad(const LandingPadInst *LP, bool IncludePhaseOneUnwind)
This file contains the declarations for profiling metadata utility functions.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
an instruction to allocate memory on the stack
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool empty() const
empty - Check if the array is empty.
An instruction that atomically checks whether a specified value is in a memory location,...
an instruction that atomically reads a memory location, combines it with another value,...
LLVM Basic Block Representation.
const_iterator getFirstInsertionPt() const
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
void renumberInstructions()
Renumber instructions and mark the ordering as valid.
const Instruction * getFirstNonPHI() const
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
const Function * getParent() const
Return the enclosing method, or null if none.
InstListType::iterator iterator
Instruction iterators...
bool isInstrOrderValid() const
Returns true if the Order field of child Instructions is valid.
void splice(BasicBlock::iterator ToIt, BasicBlock *FromBB)
Transfer all instructions from FromBB to this basic block at ToIt.
const Module * getModule() const
Return the module owning the function this basic block belongs to, or nullptr if the function does no...
CallBr instruction, tracking function calls that may not return control but instead transfer it to a ...
This class represents a function call, abstracting a target machine's calling convention.
This class is the base class for the comparison instructions.
This is an important base class in LLVM.
Implements a dense probed hash-table based set.
Convenience struct for specifying and reasoning about fast-math flags.
An instruction for ordering other memory operations.
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
This instruction inserts a struct field of array element value into an aggregate value.
const DebugLoc & getStableDebugLoc() const
Fetch the debug location for this node, unless this is a debug intrinsic, in which case fetch the deb...
bool mayThrow(bool IncludePhaseOneUnwind=false) const LLVM_READONLY
Return true if this instruction may throw an exception.
Instruction * clone() const
Create a copy of 'this' instruction that is identical in all ways except the following:
void setHasNoUnsignedWrap(bool b=true)
Set or clear the nuw flag on this instruction, which must be an operator which supports this flag.
bool hasNoNaNs() const LLVM_READONLY
Determine whether the no-NaNs flag is set.
void removeFromParent()
This method unlinks 'this' from the containing basic block, but does not delete it.
bool hasNoUnsignedWrap() const LLVM_READONLY
Determine whether the no unsigned wrap flag is set.
bool hasNoInfs() const LLVM_READONLY
Determine whether the no-infs flag is set.
bool isLifetimeStartOrEnd() const LLVM_READONLY
Return true if the instruction is a llvm.lifetime.start or llvm.lifetime.end marker.
void copyFastMathFlags(FastMathFlags FMF)
Convenience function for transferring all fast-math flag values to this instruction,...
bool isSameOperationAs(const Instruction *I, unsigned flags=0) const LLVM_READONLY
This function determines if the specified instruction executes the same operation as the current one.
void setHasNoSignedZeros(bool B)
Set or clear the no-signed-zeros flag on this instruction, which must be an operator which supports t...
bool hasNoSignedZeros() const LLVM_READONLY
Determine whether the no-signed-zeros flag is set.
bool isDebugOrPseudoInst() const LLVM_READONLY
Return true if the instruction is a DbgInfoIntrinsic or PseudoProbeInst.
unsigned getNumSuccessors() const LLVM_READONLY
Return the number of successors that this instruction has.
bool hasNoSignedWrap() const LLVM_READONLY
Determine whether the no signed wrap flag is set.
bool mayWriteToMemory() const LLVM_READONLY
Return true if this instruction may modify memory.
void copyIRFlags(const Value *V, bool IncludeWrapFlags=true)
Convenience method to copy supported exact, fast-math, and (optionally) wrapping flags from V to this...
void setHasAllowContract(bool B)
Set or clear the allow-contract flag on this instruction, which must be an operator which supports th...
bool hasAtomicStore() const LLVM_READONLY
Return true if this atomic instruction stores to memory.
void setHasNoSignedWrap(bool b=true)
Set or clear the nsw flag on this instruction, which must be an operator which supports this flag.
bool isOnlyUserOfAnyOperand()
It checks if this instruction is the only user of at least one of its operands.
void insertBefore(Instruction *InsertPos)
Insert an unlinked instruction into a basic block immediately before the specified instruction.
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
void andIRFlags(const Value *V)
Logical 'and' of any supported wrapping, exact, and fast-math flags of V and this instruction.
void setHasNoNaNs(bool B)
Set or clear the no-nans flag on this instruction, which must be an operator which supports this flag...
bool isAssociative() const LLVM_READONLY
Return true if the instruction is associative:
const Instruction * getPrevNonDebugInstruction(bool SkipPseudoOp=false) const
Return a pointer to the previous non-debug instruction in the same basic block as 'this',...
void setHasApproxFunc(bool B)
Set or clear the approximate-math-functions flag on this instruction, which must be an operator which...
void moveAfter(Instruction *MovePos)
Unlink this instruction from its current basic block and insert it into the basic block that MovePos ...
bool isCommutative() const LLVM_READONLY
Return true if the instruction is commutative:
bool hasMetadata() const
Return true if this instruction has any metadata attached to it.
bool isAtomic() const LLVM_READONLY
Return true if this instruction has an AtomicOrdering of unordered or higher.
void setHasAllowReassoc(bool B)
Set or clear the reassociation flag on this instruction, which must be an operator which supports thi...
void setFastMathFlags(FastMathFlags FMF)
Convenience function for setting multiple fast-math flags on this instruction, which must be an opera...
bool isEHPad() const
Return true if the instruction is a variety of EH-block.
const BasicBlock * getParent() const
bool isFast() const LLVM_READONLY
Determine whether all fast-math-flags are set.
void replaceSuccessorWith(BasicBlock *OldBB, BasicBlock *NewBB)
Replace specified successor OldBB to point at the provided block.
bool isExact() const LLVM_READONLY
Determine whether the exact flag is set.
bool isIdenticalToWhenDefined(const Instruction *I) const LLVM_READONLY
This is like isIdenticalTo, except that it ignores the SubclassOptionalData flags,...
const Function * getFunction() const
Return the function this instruction belongs to.
void swapProfMetadata()
If the instruction has "branch_weights" MD_prof metadata and the MDNode has three operands (including...
BasicBlock * getSuccessor(unsigned Idx) const LLVM_READONLY
Return the specified successor. This instruction must be a terminator.
bool mayHaveSideEffects() const LLVM_READONLY
Return true if the instruction may have side effects.
bool isTerminator() const
Type * getAccessType() const LLVM_READONLY
Return the type this instruction accesses in memory, if any.
bool hasSameSpecialState(const Instruction *I2, bool IgnoreAlignment=false) const LLVM_READONLY
This function determines if the speficied instruction has the same "special" characteristics as the c...
bool hasAllowReciprocal() const LLVM_READONLY
Determine whether the allow-reciprocal flag is set.
bool comesBefore(const Instruction *Other) const
Given an instruction Other in the same basic block as this instruction, return true if this instructi...
void dropUBImplyingAttrsAndMetadata()
Drop any attributes or metadata that can cause immediate undefined behavior.
bool hasPoisonGeneratingFlags() const LLVM_READONLY
Return true if this operator has flags which may cause this instruction to evaluate to poison despite...
bool mayReadFromMemory() const LLVM_READONLY
Return true if this instruction may read memory.
const Instruction * getNextNonDebugInstruction(bool SkipPseudoOp=false) const
Return a pointer to the next non-debug instruction in the same basic block as 'this',...
bool isUsedOutsideOfBlock(const BasicBlock *BB) const LLVM_READONLY
Return true if there are any uses of this instruction in blocks other than the specified block.
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
bool isVolatile() const LLVM_READONLY
Return true if this instruction has a volatile memory access.
void setHasNoInfs(bool B)
Set or clear the no-infs flag on this instruction, which must be an operator which supports this flag...
FastMathFlags getFastMathFlags() const LLVM_READONLY
Convenience function for getting all the fast-math flags, which must be an operator which supports th...
const char * getOpcodeName() const
bool willReturn() const LLVM_READONLY
Return true if the instruction will return (unwinding is considered as a form of returning control fl...
bool hasApproxFunc() const LLVM_READONLY
Determine whether the approximate-math-functions flag is set.
@ CompareIgnoringAlignment
Check for equivalence ignoring load/store alignment.
@ CompareUsingScalarTypes
Check for equivalence treating a type and a vector of that type as equivalent.
void getAllMetadataOtherThanDebugLoc(SmallVectorImpl< std::pair< unsigned, MDNode * > > &MDs) const
This does the same thing as getAllMetadata, except that it filters out the debug location.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
bool hasAtomicLoad() const LLVM_READONLY
Return true if this atomic instruction loads from memory.
void dropUnknownNonDebugMetadata()
void setIsExact(bool b=true)
Set or clear the exact flag on this instruction, which must be an operator which supports this flag.
void dropPoisonGeneratingMetadata()
Drops metadata that may generate poison.
Instruction * getInsertionPointAfterDef()
Get the first insertion point at which the result of this instruction is defined.
void setHasAllowReciprocal(bool B)
Set or clear the allow-reciprocal flag on this instruction, which must be an operator which supports ...
void dropPoisonGeneratingFlags()
Drops flags that may cause this instruction to evaluate to poison despite having non-poison inputs.
void dropUBImplyingAttrsAndUnknownMetadata(ArrayRef< unsigned > KnownIDs={})
This function drops non-debug unknown metadata (through dropUnknownNonDebugMetadata).
bool isIdenticalTo(const Instruction *I) const LLVM_READONLY
Return true if the specified instruction is exactly identical to the current one.
SymbolTableList< Instruction >::iterator insertInto(BasicBlock *ParentBB, SymbolTableList< Instruction >::iterator It)
Inserts an unlinked instruction into ParentBB at position It and returns the iterator of the inserted...
bool isLaunderOrStripInvariantGroup() const LLVM_READONLY
Return true if the instruction is a llvm.launder.invariant.group or llvm.strip.invariant....
bool hasAllowContract() const LLVM_READONLY
Determine whether the allow-contract flag is set.
bool hasPoisonGeneratingMetadata() const LLVM_READONLY
Return true if this instruction has poison-generating metadata.
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
Instruction(const Instruction &)=delete
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
void setSuccessor(unsigned Idx, BasicBlock *BB)
Update the specified successor to point at the provided block.
void copyMetadata(const Instruction &SrcInst, ArrayRef< unsigned > WL=ArrayRef< unsigned >())
Copy metadata from SrcInst to this instruction.
void setFast(bool B)
Set or clear all fast-math-flags on this instruction, which must be an operator which supports this f...
bool hasAllowReassoc() const LLVM_READONLY
Determine whether the allow-reassociation flag is set.
void insertAfter(Instruction *InsertPos)
Insert an unlinked instruction into a basic block immediately after the specified instruction.
void moveBefore(Instruction *MovePos)
Unlink this instruction from its current basic block and insert it into the basic block that MovePos ...
bool isSafeToRemove() const LLVM_READONLY
Return true if the instruction can be removed if the result is unused.
A wrapper class for inspecting calls to intrinsic functions.
The landingpad instruction holds all of the information necessary to generate correct exception handl...
bool isCleanup() const
Return 'true' if this landingpad instruction is a cleanup.
unsigned getNumClauses() const
Get the number of clauses for this landing pad.
bool isCatch(unsigned Idx) const
Return 'true' if the clause and index Idx is a catch clause.
bool isFilter(unsigned Idx) const
Return 'true' if the clause and index Idx is a filter clause.
Constant * getClause(unsigned Idx) const
Get the value of the clause at index Idx.
An instruction for reading from memory.
const MDOperand & getOperand(unsigned I) const
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
unsigned getNumOperands() const
Return number of MDNode operands.
LLVMContext & getContext() const
A Module instance is used to store all the information related to an LLVM module.
const_block_iterator block_begin() const
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
This instruction constructs a fixed permutation of two input vectors.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
The instances of the Type class are immutable: once they are created, they are never changed.
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
A Use represents the edge between a Value definition and its users.
Value * getOperand(unsigned i) const
unsigned getNumOperands() const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
unsigned char SubclassOptionalData
Hold subclass data that can be dropped.
bool isUsedByMetadata() const
Return true if there is metadata referencing this value.
bool eraseMetadata(unsigned KindID)
Erase all metadata attachments with the given kind.
iterator_range< use_iterator > uses()
Iterator for intrusive lists based on ilist_node.
self_iterator getIterator()
Instruction * getPrevNode()
Instruction * getNextNode()
Get the next node, or nullptr for the list tail.
iterator erase(iterator where)
pointer remove(iterator &IT)
iterator insert(iterator where, pointer New)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
AttributeMask getUBImplyingAttributes()
Get param/return attributes which imply immediate undefined behavior if an invalid value is passed.
This is an optimization pass for GlobalISel generic memory operations.
MDNode * getBranchWeightMDNode(const Instruction &I)
Get the branch weights metadata node.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
@ Or
Bitwise or logical OR of integers.
@ Mul
Product of integers.
@ Xor
Bitwise or logical XOR of integers.
@ And
Bitwise or logical AND of integers.