[llvm] Add ShuffleVectorInst. (PR #104891)
Jorge Gorbe Moya via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 20 12:22:15 PDT 2024
================
@@ -945,6 +948,283 @@ class ExtractElementInst final
}
};
+class ShuffleVectorInst final
+ : public SingleLLVMInstructionImpl<llvm::ShuffleVectorInst> {
+ /// Use Context::createShuffleVectorInst() instead.
+ ShuffleVectorInst(llvm::Instruction *I, Context &Ctx)
+ : SingleLLVMInstructionImpl(ClassID::ShuffleVector, Opcode::ShuffleVector,
+ I, Ctx) {}
+ friend class Context; // For accessing the constructor in create*()
+
+public:
+ static Value *create(Value *V1, Value *V2, Value *Mask,
+ Instruction *InsertBefore, Context &Ctx,
+ const Twine &Name = "");
+ static Value *create(Value *V1, Value *V2, Value *Mask,
+ BasicBlock *InsertAtEnd, Context &Ctx,
+ const Twine &Name = "");
+ static Value *create(Value *V1, Value *V2, ArrayRef<int> Mask,
+ Instruction *InsertBefore, Context &Ctx,
+ const Twine &Name = "");
+ static Value *create(Value *V1, Value *V2, ArrayRef<int> Mask,
+ BasicBlock *InsertAtEnd, Context &Ctx,
+ const Twine &Name = "");
+ static bool classof(const Value *From) {
+ return From->getSubclassID() == ClassID::ShuffleVector;
+ }
+
+ static bool isValidOperands(const Value *V1, const Value *V2,
+ const Value *Mask) {
+ return llvm::ShuffleVectorInst::isValidOperands(V1->Val, V2->Val,
+ Mask->Val);
+ }
+
+ static bool isValidOperands(const Value *V1, const Value *V2,
+ ArrayRef<int> Mask) {
+ return llvm::ShuffleVectorInst::isValidOperands(V1->Val, V2->Val, Mask);
+ }
+
+ void commute() { cast<llvm::ShuffleVectorInst>(Val)->commute(); }
+
+ VectorType *getType() const {
+ return cast<llvm::ShuffleVectorInst>(Val)->getType();
+ }
+
+ int getMaskValue(unsigned Elt) const {
+ return cast<llvm::ShuffleVectorInst>(Val)->getMaskValue(Elt);
+ }
+
+ static void getShuffleMask(const Constant *Mask,
+ SmallVectorImpl<int> &Result) {
+ llvm::ShuffleVectorInst::getShuffleMask(cast<llvm::Constant>(Mask->Val),
+ Result);
+ }
+
+ void getShuffleMask(SmallVectorImpl<int> &Result) const {
+ cast<llvm::ShuffleVectorInst>(Val)->getShuffleMask(Result);
+ }
+
+ Constant *getShuffleMaskForBitcode() const;
+
+ static Constant *convertShuffleMaskForBitcode(ArrayRef<int> Mask,
+ Type *ResultTy, Context &Ctx);
+
+ void setShuffleMask(ArrayRef<int> Mask) {
+ cast<llvm::ShuffleVectorInst>(Val)->setShuffleMask(Mask);
+ }
+
+ ArrayRef<int> getShuffleMask() const {
+ return cast<llvm::ShuffleVectorInst>(Val)->getShuffleMask();
+ }
+
+ bool changesLength() const {
+ return cast<llvm::ShuffleVectorInst>(Val)->changesLength();
+ }
+
+ bool increasesLength() const {
+ return cast<llvm::ShuffleVectorInst>(Val)->increasesLength();
+ }
+
+ static bool isSingleSourceMask(ArrayRef<int> Mask, int NumSrcElts) {
+ return llvm::ShuffleVectorInst::isSingleSourceMask(Mask, NumSrcElts);
+ }
+
+ static bool isSingleSourceMask(const Constant *Mask, int NumSrcElts) {
+ return llvm::ShuffleVectorInst::isSingleSourceMask(
+ cast<llvm::Constant>(Mask->Val), NumSrcElts);
+ }
+
+ bool isSingleSource() const {
+ return cast<llvm::ShuffleVectorInst>(Val)->isSingleSource();
+ }
+
+ static bool isIdentityMask(ArrayRef<int> Mask, int NumSrcElts) {
+ return llvm::ShuffleVectorInst::isIdentityMask(Mask, NumSrcElts);
+ }
+
+ static bool isIdentityMask(const Constant *Mask, int NumSrcElts) {
+ return llvm::ShuffleVectorInst::isIdentityMask(
+ cast<llvm::Constant>(Mask->Val), NumSrcElts);
+ }
+
+ bool isIdentity() const {
+ return cast<llvm::ShuffleVectorInst>(Val)->isIdentity();
+ }
+
+ bool isIdentityWithPadding() const {
+ return cast<llvm::ShuffleVectorInst>(Val)->isIdentityWithPadding();
+ }
+
+ bool isIdentityWithExtract() const {
+ return cast<llvm::ShuffleVectorInst>(Val)->isIdentityWithExtract();
+ }
+
+ bool isConcat() const {
+ return cast<llvm::ShuffleVectorInst>(Val)->isConcat();
+ }
+
+ static bool isSelectMask(ArrayRef<int> Mask, int NumSrcElts) {
+ return llvm::ShuffleVectorInst::isSelectMask(Mask, NumSrcElts);
+ }
+
+ static bool isSelectMask(const Constant *Mask, int NumSrcElts) {
+ return llvm::ShuffleVectorInst::isSelectMask(
+ cast<llvm::Constant>(Mask->Val), NumSrcElts);
+ }
+
+ bool isSelect() const {
+ return cast<llvm::ShuffleVectorInst>(Val)->isSelect();
+ }
+
+ static bool isReverseMask(ArrayRef<int> Mask, int NumSrcElts) {
+ return llvm::ShuffleVectorInst::isReverseMask(Mask, NumSrcElts);
+ }
+
+ static bool isReverseMask(const Constant *Mask, int NumSrcElts) {
+ return llvm::ShuffleVectorInst::isReverseMask(
+ cast<llvm::Constant>(Mask->Val), NumSrcElts);
+ }
+
+ bool isReverse() const {
+ return cast<llvm::ShuffleVectorInst>(Val)->isReverse();
+ }
+
+ static bool isZeroEltSplatMask(ArrayRef<int> Mask, int NumSrcElts) {
+ return llvm::ShuffleVectorInst::isZeroEltSplatMask(Mask, NumSrcElts);
+ }
+
+ static bool isZeroEltSplatMask(const Constant *Mask, int NumSrcElts) {
+ return llvm::ShuffleVectorInst::isZeroEltSplatMask(
+ cast<llvm::Constant>(Mask->Val), NumSrcElts);
+ }
+
+ bool isZeroEltSplat() const {
+ return cast<llvm::ShuffleVectorInst>(Val)->isZeroEltSplat();
+ }
+
+ static bool isTransposeMask(ArrayRef<int> Mask, int NumSrcElts) {
+ return llvm::ShuffleVectorInst::isTransposeMask(Mask, NumSrcElts);
+ }
+
+ static bool isTransposeMask(const Constant *Mask, int NumSrcElts) {
+ return llvm::ShuffleVectorInst::isTransposeMask(
+ cast<llvm::Constant>(Mask->Val), NumSrcElts);
+ }
+
+ bool isTranspose() const {
+ return cast<llvm::ShuffleVectorInst>(Val)->isTranspose();
+ }
+
+ static bool isSpliceMask(ArrayRef<int> Mask, int NumSrcElts, int &Index) {
+ return llvm::ShuffleVectorInst::isSpliceMask(Mask, NumSrcElts, Index);
+ }
+
+ static bool isSpliceMask(const Constant *Mask, int NumSrcElts, int &Index) {
+ return llvm::ShuffleVectorInst::isSpliceMask(
+ cast<llvm::Constant>(Mask->Val), NumSrcElts, Index);
+ }
+
+ bool isSplice(int &Index) const {
+ return cast<llvm::ShuffleVectorInst>(Val)->isSplice(Index);
+ }
+
+ static bool isExtractSubvectorMask(ArrayRef<int> Mask, int NumSrcElts,
+ int &Index) {
+ return llvm::ShuffleVectorInst::isExtractSubvectorMask(Mask, NumSrcElts,
+ Index);
+ }
+
+ static bool isExtractSubvectorMask(const Constant *Mask, int NumSrcElts,
+ int &Index) {
+ return llvm::ShuffleVectorInst::isExtractSubvectorMask(
+ cast<llvm::Constant>(Mask->Val), NumSrcElts, Index);
+ }
+
+ bool isExtractSubvectorMask(int &Index) const {
+ return cast<llvm::ShuffleVectorInst>(Val)->isExtractSubvectorMask(Index);
+ }
+
+ static bool isInsertSubvectorMask(ArrayRef<int> Mask, int NumSrcElts,
+ int &NumSubElts, int &Index) {
+ return llvm::ShuffleVectorInst::isInsertSubvectorMask(Mask, NumSrcElts,
+ NumSubElts, Index);
+ }
+
+ static bool isInsertSubvectorMask(const Constant *Mask, int NumSrcElts,
+ int &NumSubElts, int &Index) {
+ return llvm::ShuffleVectorInst::isInsertSubvectorMask(
+ cast<llvm::Constant>(Mask->Val), NumSrcElts, NumSubElts, Index);
+ }
+
+ bool isInsertSubvectorMask(int &NumSubElts, int &Index) const {
+ return cast<llvm::ShuffleVectorInst>(Val)->isInsertSubvectorMask(NumSubElts,
+ Index);
+ }
+
+ static bool isReplicationMask(ArrayRef<int> Mask, int &ReplicationFactor,
+ int &VF) {
+ return llvm::ShuffleVectorInst::isReplicationMask(Mask, ReplicationFactor,
+ VF);
+ }
+ static bool isReplicationMask(const Constant *Mask, int &ReplicationFactor,
+ int &VF) {
+ return llvm::ShuffleVectorInst::isReplicationMask(
+ cast<llvm::Constant>(Mask->Val), ReplicationFactor, VF);
+ }
+
+ /// Return true if this shuffle mask is a replication mask.
----------------
slackito wrote:
I actually copied this one over accidentally. I was thinking some LLVM IR method could change its semantics and, because we just delegate the implementation, the copy here would get out of sync.
Are we also documenting functions in the other instruction classes? or do we expect, as a general rule, that SandboxIR users will refer to the relevant LLVM IR comments/docs for details?
https://github.com/llvm/llvm-project/pull/104891
More information about the llvm-commits
mailing list