Skip to content

Commit 0f4c9a0

Browse files
[IR][IntrinsicInst] Add VPBinOpIntrinsic (#66132)
VPIntrinsics with VP_PROPERTY_BINARYOP property should have the ability to be queried with with VPBinOpIntrinsic::isVPBinOp, similiar to how intrinsics with the VP_PROPERTY_REDUCTION property can be queried with VPReductionIntrinsic::isVPReduction. This will be used in #65706. In that PR the usage of this class is tested.
1 parent 41eb82f commit 0f4c9a0

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

llvm/include/llvm/IR/IntrinsicInst.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,22 @@ class VPCmpIntrinsic : public VPIntrinsic {
672672
/// @}
673673
};
674674

675+
class VPBinOpIntrinsic : public VPIntrinsic {
676+
public:
677+
static bool isVPBinOp(Intrinsic::ID ID);
678+
679+
/// Methods for support type inquiry through isa, cast, and dyn_cast:
680+
/// @{
681+
static bool classof(const IntrinsicInst *I) {
682+
return VPBinOpIntrinsic::isVPBinOp(I->getIntrinsicID());
683+
}
684+
static bool classof(const Value *V) {
685+
return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
686+
}
687+
/// @}
688+
};
689+
690+
675691
/// This is the common base class for constrained floating point intrinsics.
676692
class ConstrainedFPIntrinsic : public IntrinsicInst {
677693
public:

llvm/lib/IR/IntrinsicInst.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,18 @@ bool VPCmpIntrinsic::isVPCmp(Intrinsic::ID ID) {
708708
return false;
709709
}
710710

711+
bool VPBinOpIntrinsic::isVPBinOp(Intrinsic::ID ID) {
712+
switch (ID) {
713+
default:
714+
break;
715+
#define BEGIN_REGISTER_VP_INTRINSIC(VPID, ...) case Intrinsic::VPID:
716+
#define VP_PROPERTY_BINARYOP return true;
717+
#define END_REGISTER_VP_INTRINSIC(VPID) break;
718+
#include "llvm/IR/VPIntrinsics.def"
719+
}
720+
return false;
721+
}
722+
711723
static ICmpInst::Predicate getIntPredicateFromMD(const Value *Op) {
712724
Metadata *MD = cast<MetadataAsValue>(Op)->getMetadata();
713725
if (!MD || !isa<MDString>(MD))

0 commit comments

Comments
 (0)