Skip to content

Commit

Permalink
[IR][IntrinsicInst] Add VPBinOpIntrinsic
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
michaelmaitland committed Sep 13, 2023
1 parent 05a11f3 commit c9e0d70
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
16 changes: 16 additions & 0 deletions llvm/include/llvm/IR/IntrinsicInst.h
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,22 @@ class VPCmpIntrinsic : public VPIntrinsic {
/// @}
};

class VPBinOpIntrinsic : public VPIntrinsic {
public:
static bool isVPBinOp(Intrinsic::ID ID);

/// Methods for support type inquiry through isa, cast, and dyn_cast:
/// @{
static bool classof(const IntrinsicInst *I) {
return VPBinOpIntrinsic::isVPBinOp(I->getIntrinsicID());
}
static bool classof(const Value *V) {
return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
}
/// @}
};


/// This is the common base class for constrained floating point intrinsics.
class ConstrainedFPIntrinsic : public IntrinsicInst {
public:
Expand Down
12 changes: 12 additions & 0 deletions llvm/lib/IR/IntrinsicInst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,18 @@ bool VPCmpIntrinsic::isVPCmp(Intrinsic::ID ID) {
return false;
}

bool VPBinOpIntrinsic::isVPBinOp(Intrinsic::ID ID) {
switch (ID) {
default:
break;
#define BEGIN_REGISTER_VP_INTRINSIC(VPID, ...) case Intrinsic::VPID:
#define VP_PROPERTY_BINARYOP return true;
#define END_REGISTER_VP_INTRINSIC(VPID) break;
#include "llvm/IR/VPIntrinsics.def"
}
return false;
}

static ICmpInst::Predicate getIntPredicateFromMD(const Value *Op) {
Metadata *MD = cast<MetadataAsValue>(Op)->getMetadata();
if (!MD || !isa<MDString>(MD))
Expand Down

0 comments on commit c9e0d70

Please sign in to comment.