From cce3d96bcc6585e5f134fc093ec50813659c5c5e Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Sun, 29 Mar 2020 13:07:43 -0400 Subject: [PATCH] GlobalISel: Add matcher for G_SHL --- llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h | 6 ++++++ llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h b/llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h index 65b1948..1fae635 100644 --- a/llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h +++ b/llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h @@ -242,6 +242,12 @@ inline BinaryOp_match m_GOr(const LHS &L, } template +inline BinaryOp_match +m_GShl(const LHS &L, const RHS &R) { + return BinaryOp_match(L, R); +} + +template inline BinaryOp_match m_GLShr(const LHS &L, const RHS &R) { return BinaryOp_match(L, R); diff --git a/llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp b/llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp index 172eca4..6a54084 100644 --- a/llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp +++ b/llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp @@ -137,6 +137,14 @@ TEST_F(AArch64GISelMITest, MatchBinaryOp) { EXPECT_TRUE(match); EXPECT_EQ(Src0, Copies[0]); EXPECT_EQ(Src1, TruncCopy1.getReg(0)); + + // Match shl, and make sure a different shift amount type works. + auto Shl = B.buildShl(s64, Copies[0], TruncCopy1); + match = mi_match(Shl.getReg(0), *MRI, + m_GShl(m_Reg(Src0), m_Reg(Src1))); + EXPECT_TRUE(match); + EXPECT_EQ(Src0, Copies[0]); + EXPECT_EQ(Src1, TruncCopy1.getReg(0)); } TEST_F(AArch64GISelMITest, MatchICmp) { -- 2.7.4