[llvm] Add SD matchers and unit test coverage for ISD::VECTOR_SHUFFLE (PR #119592)
Aidan Goldfarb via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 16 17:18:30 PST 2024
================
@@ -540,6 +540,48 @@ struct BinaryOpc_match {
}
};
+/// Matching while capturing mask
+template <typename T0, typename T1> struct SDShuffle_match {
+ T0 Op1;
+ T1 Op2;
+
+ ArrayRef<int> &CapturedMask;
+
+ // capturing mask
+ SDShuffle_match(const T0 &Op1, const T1 &Op2, ArrayRef<int> &MaskRef)
+ : Op1(Op1), Op2(Op2), CapturedMask(MaskRef) {}
+
+ template <typename MatchContext>
+ bool match(const MatchContext &Ctx, SDValue N) {
+ if (auto *I = dyn_cast<ShuffleVectorSDNode>(N)) {
+ CapturedMask = I->getMask();
----------------
AidanGoldfarb wrote:
I would guess that would be safer and more expected behavior. I cannot think of a reason why we would capture before hand, perhaps some debugging case. I'll change it
https://github.com/llvm/llvm-project/pull/119592
More information about the llvm-commits
mailing list