diff options
author | Mel Chen <mel.chen@sifive.com> | 2024-07-25 15:14:39 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-25 15:14:39 +0800 |
commit | 6d12b3f67df429bffff6e1953d9f55867d7e2469 (patch) | |
tree | fde5b38e58156a1575a9d0c408823f39b682fd11 /llvm/lib/IR/IntrinsicInst.cpp | |
parent | 693d757b63e5020e0fa78bb71fc16acdad5f8232 (diff) | |
download | llvm-6d12b3f67df429bffff6e1953d9f55867d7e2469.zip llvm-6d12b3f67df429bffff6e1953d9f55867d7e2469.tar.gz llvm-6d12b3f67df429bffff6e1953d9f55867d7e2469.tar.bz2 |
[VP] Refactor VectorBuilder to avoid layering violation. NFC (#99276)
This patch refactors the handling of reduction to eliminate layering
violations.
* Introduced `getReductionIntrinsicID` in LoopUtils.h for mapping
recurrence kinds to llvm.vector.reduce.* intrinsic IDs.
* Updated `VectorBuilder::createSimpleTargetReduction` to accept
llvm.vector.reduce.* intrinsic directly.
* New function `VPIntrinsic::getForIntrinsic` for mapping intrinsic ID
to the same functional VP intrinsic ID.
Diffstat (limited to 'llvm/lib/IR/IntrinsicInst.cpp')
-rw-r--r-- | llvm/lib/IR/IntrinsicInst.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/lib/IR/IntrinsicInst.cpp b/llvm/lib/IR/IntrinsicInst.cpp index 64a14da..db3b019 100644 --- a/llvm/lib/IR/IntrinsicInst.cpp +++ b/llvm/lib/IR/IntrinsicInst.cpp @@ -599,6 +599,25 @@ Intrinsic::ID VPIntrinsic::getForOpcode(unsigned IROPC) { return Intrinsic::not_intrinsic; } +constexpr static Intrinsic::ID getForIntrinsic(Intrinsic::ID Id) { + if (::isVPIntrinsic(Id)) + return Id; + + switch (Id) { + default: + break; +#define BEGIN_REGISTER_VP_INTRINSIC(VPID, ...) break; +#define VP_PROPERTY_FUNCTIONAL_INTRINSIC(INTRIN) case Intrinsic::INTRIN: +#define END_REGISTER_VP_INTRINSIC(VPID) return Intrinsic::VPID; +#include "llvm/IR/VPIntrinsics.def" + } + return Intrinsic::not_intrinsic; +} + +Intrinsic::ID VPIntrinsic::getForIntrinsic(Intrinsic::ID Id) { + return ::getForIntrinsic(Id); +} + bool VPIntrinsic::canIgnoreVectorLengthParam() const { using namespace PatternMatch; |