diff options
Diffstat (limited to 'contrib/llvm-project/llvm/include/llvm/IR/Instructions.h')
-rw-r--r-- | contrib/llvm-project/llvm/include/llvm/IR/Instructions.h | 78 |
1 files changed, 72 insertions, 6 deletions
diff --git a/contrib/llvm-project/llvm/include/llvm/IR/Instructions.h b/contrib/llvm-project/llvm/include/llvm/IR/Instructions.h index 0afc585dfbe5..00ecc2aa7f37 100644 --- a/contrib/llvm-project/llvm/include/llvm/IR/Instructions.h +++ b/contrib/llvm-project/llvm/include/llvm/IR/Instructions.h @@ -27,6 +27,7 @@ #include "llvm/IR/Attributes.h" #include "llvm/IR/BasicBlock.h" #include "llvm/IR/CallingConv.h" +#include "llvm/IR/CFG.h" #include "llvm/IR/Constant.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Function.h" @@ -105,7 +106,7 @@ public: /// Get allocation size in bits. Returns None if size can't be determined, /// e.g. in case of a VLA. - Optional<uint64_t> getAllocationSizeInBits(const DataLayout &DL) const; + Optional<TypeSize> getAllocationSizeInBits(const DataLayout &DL) const; /// Return the type that is being allocated by the instruction. Type *getAllocatedType() const { return AllocatedType; } @@ -1289,6 +1290,30 @@ public: return !isEquality(P); } + /// Return true if the predicate is SGT or UGT. + /// + static bool isGT(Predicate P) { + return P == ICMP_SGT || P == ICMP_UGT; + } + + /// Return true if the predicate is SLT or ULT. + /// + static bool isLT(Predicate P) { + return P == ICMP_SLT || P == ICMP_ULT; + } + + /// Return true if the predicate is SGE or UGE. + /// + static bool isGE(Predicate P) { + return P == ICMP_SGE || P == ICMP_UGE; + } + + /// Return true if the predicate is SLE or ULE. + /// + static bool isLE(Predicate P) { + return P == ICMP_SLE || P == ICMP_ULE; + } + /// Exchange the two operands to this instruction in such a way that it does /// not modify the semantics of the instruction. The predicate value may be /// changed to retain the same result if the predicate is order dependent @@ -1560,6 +1585,16 @@ public: static CallInst *Create(CallInst *CI, ArrayRef<OperandBundleDef> Bundles, Instruction *InsertPt = nullptr); + /// Create a clone of \p CI with a different set of operand bundles and + /// insert it before \p InsertPt. + /// + /// The returned call instruction is identical \p CI in every way except that + /// the operand bundle for the new instruction is set to the operand bundle + /// in \p Bundle. + static CallInst *CreateWithReplacedBundle(CallInst *CI, + OperandBundleDef Bundle, + Instruction *InsertPt = nullptr); + /// Generate the IR for a call to malloc: /// 1. Compute the malloc call's argument as the specified type's size, /// possibly multiplied by the array size if the array size is not @@ -2035,8 +2070,9 @@ public: /// Examples: shufflevector <4 x n> A, <4 x n> B, <1,2,3> /// shufflevector <4 x n> A, <4 x n> B, <1,2,3,4,5> bool changesLength() const { - unsigned NumSourceElts = - cast<VectorType>(Op<0>()->getType())->getElementCount().Min; + unsigned NumSourceElts = cast<VectorType>(Op<0>()->getType()) + ->getElementCount() + .getKnownMinValue(); unsigned NumMaskElts = ShuffleMask.size(); return NumSourceElts != NumMaskElts; } @@ -2045,8 +2081,9 @@ public: /// elements than its source vectors. /// Example: shufflevector <2 x n> A, <2 x n> B, <1,2,3> bool increasesLength() const { - unsigned NumSourceElts = - cast<VectorType>(Op<0>()->getType())->getNumElements(); + unsigned NumSourceElts = cast<VectorType>(Op<0>()->getType()) + ->getElementCount() + .getKnownMinValue(); unsigned NumMaskElts = ShuffleMask.size(); return NumSourceElts < NumMaskElts; } @@ -2232,6 +2269,10 @@ public: static bool isExtractSubvectorMask(const Constant *Mask, int NumSrcElts, int &Index) { assert(Mask->getType()->isVectorTy() && "Shuffle needs vector constant."); + // Not possible to express a shuffle mask for a scalable vector for this + // case. + if (isa<ScalableVectorType>(Mask->getType())) + return false; SmallVector<int, 16> MaskAsInts; getShuffleMask(Mask, MaskAsInts); return isExtractSubvectorMask(MaskAsInts, NumSrcElts, Index); @@ -2239,7 +2280,13 @@ public: /// Return true if this shuffle mask is an extract subvector mask. bool isExtractSubvectorMask(int &Index) const { - int NumSrcElts = cast<VectorType>(Op<0>()->getType())->getNumElements(); + // Not possible to express a shuffle mask for a scalable vector for this + // case. + if (isa<ScalableVectorType>(getType())) + return false; + + int NumSrcElts = + cast<FixedVectorType>(Op<0>()->getType())->getNumElements(); return isExtractSubvectorMask(ShuffleMask, NumSrcElts, Index); } @@ -2743,6 +2790,15 @@ public: /// non-undef value. bool hasConstantOrUndefValue() const; + /// If the PHI node is complete which means all of its parent's predecessors + /// have incoming value in this PHI, return true, otherwise return false. + bool isComplete() const { + return llvm::all_of(predecessors(getParent()), + [this](const BasicBlock *Pred) { + return getBasicBlockIndex(Pred) >= 0; + }); + } + /// Methods for support type inquiry through isa, cast, and dyn_cast: static bool classof(const Instruction *I) { return I->getOpcode() == Instruction::PHI; @@ -3768,6 +3824,16 @@ public: static InvokeInst *Create(InvokeInst *II, ArrayRef<OperandBundleDef> Bundles, Instruction *InsertPt = nullptr); + /// Create a clone of \p II with a different set of operand bundles and + /// insert it before \p InsertPt. + /// + /// The returned invoke instruction is identical to \p II in every way except + /// that the operand bundle for the new instruction is set to the operand + /// bundle in \p Bundle. + static InvokeInst *CreateWithReplacedBundle(InvokeInst *II, + OperandBundleDef Bundles, + Instruction *InsertPt = nullptr); + // get*Dest - Return the destination basic blocks... BasicBlock *getNormalDest() const { return cast<BasicBlock>(Op<NormalDestOpEndIdx>()); |