diff options
Diffstat (limited to 'contrib/llvm-project/llvm/lib/IR/IntrinsicInst.cpp')
| -rw-r--r-- | contrib/llvm-project/llvm/lib/IR/IntrinsicInst.cpp | 81 |
1 files changed, 74 insertions, 7 deletions
diff --git a/contrib/llvm-project/llvm/lib/IR/IntrinsicInst.cpp b/contrib/llvm-project/llvm/lib/IR/IntrinsicInst.cpp index 36d56699c64e..7a3b708e7400 100644 --- a/contrib/llvm-project/llvm/lib/IR/IntrinsicInst.cpp +++ b/contrib/llvm-project/llvm/lib/IR/IntrinsicInst.cpp @@ -235,7 +235,7 @@ void DbgAssignIntrinsic::setValue(Value *V) { int llvm::Intrinsic::lookupLLVMIntrinsicByName(ArrayRef<const char *> NameTable, StringRef Name) { - assert(Name.startswith("llvm.")); + assert(Name.starts_with("llvm.") && "Unexpected intrinsic prefix"); // Do successive binary searches of the dotted name components. For // "llvm.gc.experimental.statepoint.p1i8.p1i32", we will find the range of @@ -265,18 +265,18 @@ int llvm::Intrinsic::lookupLLVMIntrinsicByName(ArrayRef<const char *> NameTable, return -1; StringRef NameFound = *LastLow; if (Name == NameFound || - (Name.startswith(NameFound) && Name[NameFound.size()] == '.')) + (Name.starts_with(NameFound) && Name[NameFound.size()] == '.')) return LastLow - NameTable.begin(); return -1; } -ConstantInt *InstrProfInstBase::getNumCounters() const { +ConstantInt *InstrProfCntrInstBase::getNumCounters() const { if (InstrProfValueProfileInst::classof(this)) llvm_unreachable("InstrProfValueProfileInst does not have counters!"); return cast<ConstantInt>(const_cast<Value *>(getArgOperand(2))); } -ConstantInt *InstrProfInstBase::getIndex() const { +ConstantInt *InstrProfCntrInstBase::getIndex() const { if (InstrProfValueProfileInst::classof(this)) llvm_unreachable("Please use InstrProfValueProfileInst::getIndex()"); return cast<ConstantInt>(const_cast<Value *>(getArgOperand(3))); @@ -503,7 +503,7 @@ std::optional<unsigned> VPIntrinsic::getMemoryDataParamPos(Intrinsic::ID VPID) { return std::nullopt; } -bool VPIntrinsic::isVPIntrinsic(Intrinsic::ID ID) { +constexpr bool isVPIntrinsic(Intrinsic::ID ID) { switch (ID) { default: break; @@ -515,22 +515,70 @@ bool VPIntrinsic::isVPIntrinsic(Intrinsic::ID ID) { return false; } +bool VPIntrinsic::isVPIntrinsic(Intrinsic::ID ID) { + return ::isVPIntrinsic(ID); +} + // Equivalent non-predicated opcode +constexpr static std::optional<unsigned> +getFunctionalOpcodeForVP(Intrinsic::ID ID) { + switch (ID) { + default: + break; +#define BEGIN_REGISTER_VP_INTRINSIC(VPID, ...) case Intrinsic::VPID: +#define VP_PROPERTY_FUNCTIONAL_OPC(OPC) return Instruction::OPC; +#define END_REGISTER_VP_INTRINSIC(VPID) break; +#include "llvm/IR/VPIntrinsics.def" + } + return std::nullopt; +} + std::optional<unsigned> VPIntrinsic::getFunctionalOpcodeForVP(Intrinsic::ID ID) { + return ::getFunctionalOpcodeForVP(ID); +} + +// Equivalent non-predicated intrinsic ID +constexpr static std::optional<Intrinsic::ID> +getFunctionalIntrinsicIDForVP(Intrinsic::ID ID) { switch (ID) { default: break; #define BEGIN_REGISTER_VP_INTRINSIC(VPID, ...) case Intrinsic::VPID: -#define VP_PROPERTY_FUNCTIONAL_OPC(OPC) return Instruction::OPC; +#define VP_PROPERTY_FUNCTIONAL_INTRINSIC(INTRIN) return Intrinsic::INTRIN; #define END_REGISTER_VP_INTRINSIC(VPID) break; #include "llvm/IR/VPIntrinsics.def" } return std::nullopt; } +std::optional<Intrinsic::ID> +VPIntrinsic::getFunctionalIntrinsicIDForVP(Intrinsic::ID ID) { + return ::getFunctionalIntrinsicIDForVP(ID); +} + +constexpr static bool doesVPHaveNoFunctionalEquivalent(Intrinsic::ID ID) { + switch (ID) { + default: + break; +#define BEGIN_REGISTER_VP_INTRINSIC(VPID, ...) case Intrinsic::VPID: +#define VP_PROPERTY_NO_FUNCTIONAL return true; +#define END_REGISTER_VP_INTRINSIC(VPID) break; +#include "llvm/IR/VPIntrinsics.def" + } + return false; +} + +// All VP intrinsics should have an equivalent non-VP opcode or intrinsic +// defined, or be marked that they don't have one. +#define BEGIN_REGISTER_VP_INTRINSIC(VPID, ...) \ + static_assert(doesVPHaveNoFunctionalEquivalent(Intrinsic::VPID) || \ + getFunctionalOpcodeForVP(Intrinsic::VPID) || \ + getFunctionalIntrinsicIDForVP(Intrinsic::VPID)); +#include "llvm/IR/VPIntrinsics.def" + // Equivalent non-predicated constrained intrinsic -std::optional<unsigned> +std::optional<Intrinsic::ID> VPIntrinsic::getConstrainedIntrinsicIDForVP(Intrinsic::ID ID) { switch (ID) { default: @@ -621,6 +669,9 @@ Function *VPIntrinsic::getDeclarationForParams(Module *M, Intrinsic::ID VPID, VPFunc = Intrinsic::getDeclaration(M, VPID, {ReturnType, Params[0]->getType()}); break; + case Intrinsic::vp_is_fpclass: + VPFunc = Intrinsic::getDeclaration(M, VPID, {Params[0]->getType()}); + break; case Intrinsic::vp_merge: case Intrinsic::vp_select: VPFunc = Intrinsic::getDeclaration(M, VPID, {Params[1]->getType()}); @@ -691,6 +742,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)) @@ -807,6 +870,10 @@ const Value *GCProjectionInst::getStatepoint() const { if (isa<UndefValue>(Token)) return Token; + // Treat none token as if it was undef here + if (isa<ConstantTokenNone>(Token)) + return UndefValue::get(Token->getType()); + // This takes care both of relocates for call statepoints and relocates // on normal path of invoke statepoint. if (!isa<LandingPadInst>(Token)) |
